From 5f4f4a8ff2154f3775ce5988565753b1a0b9c1b6 Mon Sep 17 00:00:00 2001 From: John Reck Date: Fri, 25 May 2012 14:03:02 -0700 Subject: Copy scroll position for scrolling layer Bug: 6557664 Change-Id: I32aa77b6fd408dc4f1097513cbb1211184a93885 --- Source/WebKit/android/nav/WebView.cpp | 36 +++++++++++++++-------------------- 1 file changed, 15 insertions(+), 21 deletions(-) diff --git a/Source/WebKit/android/nav/WebView.cpp b/Source/WebKit/android/nav/WebView.cpp index a730907..ad69042 100644 --- a/Source/WebKit/android/nav/WebView.cpp +++ b/Source/WebKit/android/nav/WebView.cpp @@ -486,28 +486,23 @@ void postInvalidateDelayed(int64_t delay, const WebCore::IntRect& bounds) } #if ENABLE(ANDROID_OVERFLOW_SCROLL) -static void copyScrollPositionRecursive(const LayerAndroid* from, - LayerAndroid* root) +static void copyScrollPosition(const LayerAndroid* fromRoot, + LayerAndroid* toRoot, int layerId) { - if (!from || !root) + if (!fromRoot || !toRoot) return; - for (int i = 0; i < from->countChildren(); i++) { - const LayerAndroid* l = from->getChild(i); - if (l->contentIsScrollable()) { - const SkPoint& pos = l->getPosition(); - LayerAndroid* match = root->findById(l->uniqueId()); - if (match && match->contentIsScrollable()) - match->setPosition(pos.fX, pos.fY); - } - copyScrollPositionRecursive(l, root); - } + const LayerAndroid* from = fromRoot->findById(layerId); + LayerAndroid* to = toRoot->findById(layerId); + if (!from || !to || !from->contentIsScrollable() || !to->contentIsScrollable()) + return; + to->setScrollOffset(from->getScrollOffset()); } #endif BaseLayerAndroid* getBaseLayer() const { return m_baseLayer; } bool setBaseLayer(BaseLayerAndroid* newBaseLayer, bool showVisualIndicator, - bool isPictureAfterFirstLayout) + bool isPictureAfterFirstLayout, int scrollingLayer) { bool queueFull = false; #if USE(ACCELERATED_COMPOSITING) @@ -517,10 +512,7 @@ bool setBaseLayer(BaseLayerAndroid* newBaseLayer, bool showVisualIndicator, #endif #if ENABLE(ANDROID_OVERFLOW_SCROLL) - if (newBaseLayer) { - // TODO: the below tree position copies are only necessary in software rendering - copyScrollPositionRecursive(m_baseLayer, newBaseLayer); - } + copyScrollPosition(m_baseLayer, newBaseLayer, scrollingLayer); #endif SkSafeUnref(m_baseLayer); m_baseLayer = newBaseLayer; @@ -949,11 +941,13 @@ static bool nativeEvaluateLayersAnimations(JNIEnv *env, jobject obj, jint native static bool nativeSetBaseLayer(JNIEnv *env, jobject obj, jint nativeView, jint layer, jboolean showVisualIndicator, - jboolean isPictureAfterFirstLayout) + jboolean isPictureAfterFirstLayout, + jint scrollingLayer) { BaseLayerAndroid* layerImpl = reinterpret_cast(layer); return reinterpret_cast(nativeView)->setBaseLayer(layerImpl, showVisualIndicator, - isPictureAfterFirstLayout); + isPictureAfterFirstLayout, + scrollingLayer); } static BaseLayerAndroid* nativeGetBaseLayer(JNIEnv *env, jobject obj, jint nativeView) @@ -1306,7 +1300,7 @@ static JNINativeMethod gJavaWebViewMethods[] = { (void*) nativeGetSelection }, { "nativeSetHeightCanMeasure", "(Z)V", (void*) nativeSetHeightCanMeasure }, - { "nativeSetBaseLayer", "(IIZZ)Z", + { "nativeSetBaseLayer", "(IIZZI)Z", (void*) nativeSetBaseLayer }, { "nativeGetBaseLayer", "(I)I", (void*) nativeGetBaseLayer }, -- cgit v1.1