diff options
author | John Reck <jreck@google.com> | 2012-05-25 14:03:02 -0700 |
---|---|---|
committer | John Reck <jreck@google.com> | 2012-05-25 14:55:32 -0700 |
commit | 5f4f4a8ff2154f3775ce5988565753b1a0b9c1b6 (patch) | |
tree | 440ae81c5ada7e0137f72ba24809b33118ef8861 | |
parent | 917ab176521f67983bd1c7cdb99f55ce8fc412f5 (diff) | |
download | external_webkit-5f4f4a8ff2154f3775ce5988565753b1a0b9c1b6.zip external_webkit-5f4f4a8ff2154f3775ce5988565753b1a0b9c1b6.tar.gz external_webkit-5f4f4a8ff2154f3775ce5988565753b1a0b9c1b6.tar.bz2 |
Copy scroll position for scrolling layer
Bug: 6557664
Change-Id: I32aa77b6fd408dc4f1097513cbb1211184a93885
-rw-r--r-- | Source/WebKit/android/nav/WebView.cpp | 36 |
1 files 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<BaseLayerAndroid*>(layer); return reinterpret_cast<WebView*>(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 }, |