From 70adfd756fa5e71bd6913f3a1d8223ca26d8ec92 Mon Sep 17 00:00:00 2001 From: Chris Craik Date: Thu, 1 Dec 2011 15:31:25 -0800 Subject: [PATCH] Scroll position now passed to all layers bug:5666027 Previously, only the most recent version of the scrollablelayerandroid would have its position updated. This caused issues with position inconsistency between the painting and drawing version of the layer, if both existed. Change-Id: Ife29ae4e2cb00fbaa2f6fc95d9914b3434862f10 --- .../platform/graphics/android/GLWebViewState.cpp | 4 +++- .../WebCore/platform/graphics/android/GLWebViewState.h | 2 +- .../graphics/android/ScrollableLayerAndroid.cpp | 3 --- .../WebCore/platform/graphics/android/TreeManager.cpp | 18 ++++++++++++++++++ Source/WebCore/platform/graphics/android/TreeManager.h | 6 ++++++ Source/WebKit/android/nav/WebView.cpp | 9 +++++++++ 6 files changed, 37 insertions(+), 5 deletions(-) diff --git a/Source/WebCore/platform/graphics/android/GLWebViewState.cpp b/Source/WebCore/platform/graphics/android/GLWebViewState.cpp index f72f8ce38..900d0fd9f 100644 --- a/Source/WebCore/platform/graphics/android/GLWebViewState.cpp +++ b/Source/WebCore/platform/graphics/android/GLWebViewState.cpp @@ -150,8 +150,10 @@ void GLWebViewState::setBaseLayer(BaseLayerAndroid* layer, const SkRegion& inval TilesManager::instance()->setShowVisualIndicator(showVisualIndicator); } -void GLWebViewState::scrolledLayer(ScrollableLayerAndroid*) +void GLWebViewState::scrollLayer(int layerId, int x, int y) { + m_treeManager.updateScrollableLayer(layerId, x, y); + // TODO: only inval the area of the scrolled layer instead of // doing a fullInval() if (m_layersRenderingMode == kSingleSurfaceRendering) diff --git a/Source/WebCore/platform/graphics/android/GLWebViewState.h b/Source/WebCore/platform/graphics/android/GLWebViewState.h index cffd28f5e..8d89704d5 100644 --- a/Source/WebCore/platform/graphics/android/GLWebViewState.h +++ b/Source/WebCore/platform/graphics/android/GLWebViewState.h @@ -248,7 +248,7 @@ public: }; LayersRenderingMode layersRenderingMode() { return m_layersRenderingMode; } - void scrolledLayer(ScrollableLayerAndroid*); + void scrollLayer(int layerId, int x, int y); void invalRegion(const SkRegion& region); diff --git a/Source/WebCore/platform/graphics/android/ScrollableLayerAndroid.cpp b/Source/WebCore/platform/graphics/android/ScrollableLayerAndroid.cpp index 2643d2c2d..3c2ced54b 100644 --- a/Source/WebCore/platform/graphics/android/ScrollableLayerAndroid.cpp +++ b/Source/WebCore/platform/graphics/android/ScrollableLayerAndroid.cpp @@ -22,9 +22,6 @@ bool ScrollableLayerAndroid::scrollTo(int x, int y) setPosition(m_scrollLimits.fLeft - newX, m_scrollLimits.fTop - newY); - if (state()) - state()->scrolledLayer(this); - return true; } diff --git a/Source/WebCore/platform/graphics/android/TreeManager.cpp b/Source/WebCore/platform/graphics/android/TreeManager.cpp index fe55df89e..71e5f6b57 100644 --- a/Source/WebCore/platform/graphics/android/TreeManager.cpp +++ b/Source/WebCore/platform/graphics/android/TreeManager.cpp @@ -28,6 +28,7 @@ #include "Layer.h" #include "BaseLayerAndroid.h" +#include "ScrollableLayerAndroid.h" #include "TilesManager.h" #include @@ -175,6 +176,23 @@ void TreeManager::updateWithTree(Layer* newTree, bool brandNew) m_paintingTree->setIsPainting(m_drawingTree); } +void TreeManager::updateScrollableLayerInTree(Layer* tree, int layerId, int x, int y) +{ + LayerAndroid* layer; + if (tree && tree->countChildren()) { + layer = static_cast(tree->getChild(0))->findById(layerId); + if (layer && layer->contentIsScrollable()) + static_cast(layer)->scrollTo(x, y); + } +} + +void TreeManager::updateScrollableLayer(int layerId, int x, int y) +{ + updateScrollableLayerInTree(m_queuedTree, layerId, x, y); + updateScrollableLayerInTree(m_paintingTree, layerId, x, y); + updateScrollableLayerInTree(m_drawingTree, layerId, x, y); +} + bool TreeManager::drawGL(double currentTime, IntRect& viewRect, SkRect& visibleRect, float scale, bool enterFastSwapMode, bool* treesSwappedPtr, bool* newTreeHasAnimPtr, diff --git a/Source/WebCore/platform/graphics/android/TreeManager.h b/Source/WebCore/platform/graphics/android/TreeManager.h index d2e10c82c..83d53008a 100644 --- a/Source/WebCore/platform/graphics/android/TreeManager.h +++ b/Source/WebCore/platform/graphics/android/TreeManager.h @@ -28,6 +28,7 @@ #include "TestExport.h" #include +#include "PerformanceMonitor.h" class Layer; class SkRect; @@ -46,6 +47,8 @@ public: void updateWithTree(Layer* tree, bool brandNew); + void updateScrollableLayer(int layerId, int x, int y); + bool drawGL(double currentTime, IntRect& viewRect, SkRect& visibleRect, float scale, bool enterFastSwapMode, bool* treesSwappedPtr, bool* newTreeHasAnimPtr, @@ -60,6 +63,8 @@ public: int baseContentHeight(); private: + static void updateScrollableLayerInTree(Layer* tree, int layerId, int x, int y); + void swap(); void clearTrees(); @@ -70,6 +75,7 @@ private: Layer* m_queuedTree; bool m_fastSwapMode; + PerformanceMonitor m_perf; }; } // namespace WebCore diff --git a/Source/WebKit/android/nav/WebView.cpp b/Source/WebKit/android/nav/WebView.cpp index 2be01dc57..4a15a5b27 100644 --- a/Source/WebKit/android/nav/WebView.cpp +++ b/Source/WebKit/android/nav/WebView.cpp @@ -1093,6 +1093,12 @@ int scrollableLayer(int x, int y, SkIRect* layerRect, SkIRect* bounds) return 0; } +void scrollLayer(int layerId, int x, int y) +{ + if (m_glWebViewState) + m_glWebViewState->scrollLayer(layerId, x, y); +} + int getBlockLeftEdge(int x, int y, float scale) { CachedRoot* root = getFrameCache(AllowNewer); @@ -2659,6 +2665,9 @@ static bool nativeScrollLayer(JNIEnv* env, jobject obj, jint layerId, jint x, { #if ENABLE(ANDROID_OVERFLOW_SCROLL) WebView* view = GET_NATIVE_VIEW(env, obj); + view->scrollLayer(layerId, x, y); + + //TODO: the below only needed for the SW rendering path LayerAndroid* root = view->compositeRoot(); if (!root) return false; -- 2.11.0