diff options
author | Simon Hausmann <simon.hausmann@nokia.com> | 2012-08-12 09:27:39 +0200 |
---|---|---|
committer | Simon Hausmann <simon.hausmann@nokia.com> | 2012-08-12 09:27:39 +0200 |
commit | 3749d61e1f7a59f5ec5067e560af1eb610c82015 (patch) | |
tree | 73dc228333948738bbe02976cacca8cd382bc978 /Source/WebCore/page/scrolling | |
parent | b32b4dcd9a51ab8de6afc53d9e17f8707e1f7a5e (diff) | |
download | qtwebkit-3749d61e1f7a59f5ec5067e560af1eb610c82015.tar.gz |
Imported WebKit commit a77350243e054f3460d1137301d8b3faee3d2052 (http://svn.webkit.org/repository/webkit/trunk@125365)
New snapshot with build fixes for latest API changes in Qt and all WK1 Win MSVC fixes upstream
Diffstat (limited to 'Source/WebCore/page/scrolling')
7 files changed, 130 insertions, 30 deletions
diff --git a/Source/WebCore/page/scrolling/ScrollingCoordinator.cpp b/Source/WebCore/page/scrolling/ScrollingCoordinator.cpp index 6d1f2a60d..40feed77c 100644 --- a/Source/WebCore/page/scrolling/ScrollingCoordinator.cpp +++ b/Source/WebCore/page/scrolling/ScrollingCoordinator.cpp @@ -288,6 +288,23 @@ void ScrollingCoordinator::updateMainFrameScrollPosition(const IntPoint& scrollP frameView->setConstrainsScrollingToContentEdge(true); } +void ScrollingCoordinator::updateMainFrameScrollLayerPosition() +{ +#if USE(ACCELERATED_COMPOSITING) && ENABLE(THREADED_SCROLLING) + ASSERT(isMainThread()); + + if (!m_page) + return; + + FrameView* frameView = m_page->mainFrame()->view(); + if (!frameView) + return; + + if (GraphicsLayer* scrollLayer = scrollLayerForFrameView(frameView)) + scrollLayer->setPosition(-frameView->scrollPosition()); +#endif +} + void ScrollingCoordinator::updateMainFrameScrollPositionAndScrollLayerPosition() { #if USE(ACCELERATED_COMPOSITING) && ENABLE(THREADED_SCROLLING) @@ -415,6 +432,11 @@ void ScrollingCoordinator::setWheelEventHandlerCount(unsigned wheelEventHandlerC void ScrollingCoordinator::setShouldUpdateScrollLayerPositionOnMainThread(bool shouldUpdateScrollLayerPositionOnMainThread) { + // The FrameView's GraphicsLayer is likely to be out-of-synch with the PlatformLayer + // at this point. So we'll update it before we switch back to main thread scrolling + // in order to avoid layer positioning bugs. + if (shouldUpdateScrollLayerPositionOnMainThread) + updateMainFrameScrollLayerPosition(); m_scrollingTreeState->setShouldUpdateScrollLayerPositionOnMainThread(shouldUpdateScrollLayerPositionOnMainThread); scheduleTreeStateCommit(); } diff --git a/Source/WebCore/page/scrolling/ScrollingCoordinator.h b/Source/WebCore/page/scrolling/ScrollingCoordinator.h index 35649a91f..5d45eb620 100644 --- a/Source/WebCore/page/scrolling/ScrollingCoordinator.h +++ b/Source/WebCore/page/scrolling/ScrollingCoordinator.h @@ -153,6 +153,8 @@ private: void setWheelEventHandlerCount(unsigned); void setShouldUpdateScrollLayerPositionOnMainThread(bool); + void updateMainFrameScrollLayerPosition(); + Page* m_page; bool m_forceMainThreadScrollLayerPositionUpdates; diff --git a/Source/WebCore/page/scrolling/ScrollingTree.cpp b/Source/WebCore/page/scrolling/ScrollingTree.cpp index 36e6aaea3..ba6a52ac7 100644 --- a/Source/WebCore/page/scrolling/ScrollingTree.cpp +++ b/Source/WebCore/page/scrolling/ScrollingTree.cpp @@ -50,6 +50,7 @@ ScrollingTree::ScrollingTree(ScrollingCoordinator* scrollingCoordinator) , m_canGoForward(false) , m_mainFramePinnedToTheLeft(false) , m_mainFramePinnedToTheRight(false) + , m_scrollingPerformanceLoggingEnabled(false) { } @@ -218,6 +219,16 @@ bool ScrollingTree::willWheelEventStartSwipeGesture(const PlatformWheelEvent& wh return false; } +void ScrollingTree::setScrollingPerformanceLoggingEnabled(bool flag) +{ + m_scrollingPerformanceLoggingEnabled = flag; +} + +bool ScrollingTree::scrollingPeformanceLoggingEnabled() +{ + return m_scrollingPerformanceLoggingEnabled; +} + } // namespace WebCore #endif // ENABLE(THREADED_SCROLLING) diff --git a/Source/WebCore/page/scrolling/ScrollingTree.h b/Source/WebCore/page/scrolling/ScrollingTree.h index ef7792637..4120e9eac 100644 --- a/Source/WebCore/page/scrolling/ScrollingTree.h +++ b/Source/WebCore/page/scrolling/ScrollingTree.h @@ -97,6 +97,9 @@ public: void setDebugRootLayer(CALayer *); #endif + void setScrollingPerformanceLoggingEnabled(bool flag); + bool scrollingPeformanceLoggingEnabled(); + private: explicit ScrollingTree(ScrollingCoordinator*); @@ -116,6 +119,8 @@ private: bool m_mainFramePinnedToTheLeft; bool m_mainFramePinnedToTheRight; + bool m_scrollingPerformanceLoggingEnabled; + #if PLATFORM(MAC) RetainPtr<CALayer> m_debugInfoLayer; #endif diff --git a/Source/WebCore/page/scrolling/chromium/ScrollingCoordinatorChromium.cpp b/Source/WebCore/page/scrolling/chromium/ScrollingCoordinatorChromium.cpp index 99726087c..1db759404 100644 --- a/Source/WebCore/page/scrolling/chromium/ScrollingCoordinatorChromium.cpp +++ b/Source/WebCore/page/scrolling/chromium/ScrollingCoordinatorChromium.cpp @@ -29,17 +29,22 @@ #include "Frame.h" #include "FrameView.h" -#include "LayerChromium.h" #include "Region.h" #include "RenderLayerCompositor.h" #include "RenderView.h" -#include "ScrollbarLayerChromium.h" -#include "ScrollbarTheme.h" -#include "cc/CCProxy.h" +#include "ScrollbarThemeComposite.h" +#include "WebScrollbarThemeGeometryNative.h" #include <public/WebScrollableLayer.h> +#include <public/WebScrollbar.h> +#include <public/WebScrollbarLayer.h> +#include <public/WebScrollbarThemeGeometry.h> +#include <public/WebScrollbarThemePainter.h> using WebKit::WebLayer; +using WebKit::WebRect; using WebKit::WebScrollableLayer; +using WebKit::WebScrollbarLayer; +using WebKit::WebVector; namespace WebCore { @@ -53,19 +58,18 @@ public: { m_scrollLayer = layer; - int id = layer.isNull() ? 0 : layer.unwrap<LayerChromium>()->id(); if (!m_horizontalScrollbarLayer.isNull()) - m_horizontalScrollbarLayer.unwrap<ScrollbarLayerChromium>()->setScrollLayerId(id); + m_horizontalScrollbarLayer.setScrollLayer(layer); if (!m_verticalScrollbarLayer.isNull()) - m_verticalScrollbarLayer.unwrap<ScrollbarLayerChromium>()->setScrollLayerId(id); + m_verticalScrollbarLayer.setScrollLayer(layer); } - void setHorizontalScrollbarLayer(WebLayer layer) + void setHorizontalScrollbarLayer(WebScrollbarLayer layer) { m_horizontalScrollbarLayer = layer; } - void setVerticalScrollbarLayer(WebLayer layer) + void setVerticalScrollbarLayer(WebScrollbarLayer layer) { m_verticalScrollbarLayer = layer; } @@ -75,8 +79,8 @@ public: private: WebScrollableLayer m_scrollLayer; - WebLayer m_horizontalScrollbarLayer; - WebLayer m_verticalScrollbarLayer; + WebScrollbarLayer m_horizontalScrollbarLayer; + WebScrollbarLayer m_verticalScrollbarLayer; }; PassRefPtr<ScrollingCoordinator> ScrollingCoordinator::create(Page* page) @@ -108,14 +112,14 @@ static GraphicsLayer* scrollLayerForFrameView(FrameView* frameView) #endif } -static WebLayer createScrollbarLayer(Scrollbar* scrollbar, WebScrollableLayer scrollLayer, GraphicsLayer* scrollbarGraphicsLayer, FrameView* frameView) +static WebScrollbarLayer createScrollbarLayer(Scrollbar* scrollbar, WebScrollableLayer scrollLayer, GraphicsLayer* scrollbarGraphicsLayer, FrameView* frameView) { ASSERT(scrollbar); ASSERT(scrollbarGraphicsLayer); if (scrollLayer.isNull()) { // FIXME: sometimes we get called before setScrollLayer, workaround by finding the scroll layout ourselves. - scrollLayer = WebScrollableLayer(scrollLayerForFrameView(frameView)->platformLayer()); + scrollLayer = scrollLayerForFrameView(frameView)->platformLayer()->to<WebScrollableLayer>(); ASSERT(!scrollLayer.isNull()); } @@ -126,26 +130,30 @@ static WebLayer createScrollbarLayer(Scrollbar* scrollbar, WebScrollableLayer sc scrollbarGraphicsLayer->setContentsOpaque(isOpaqueRootScrollbar); // FIXME: Mac scrollbar themes are not thread-safe to paint. - // FIXME: Win scrollbars on XP Classic themes do not paint valid alpha - // values due to GDI. This needs to be fixed in theme code before it - // can be turned on here. bool platformSupported = true; -#if OS(DARWIN) || OS(WINDOWS) +#if OS(DARWIN) platformSupported = false; #endif - if (!platformSupported || scrollbar->isOverlayScrollbar()) { + if (!platformSupported || scrollbar->isCustomScrollbar()) { scrollbarGraphicsLayer->setContentsToMedia(0); scrollbarGraphicsLayer->setDrawsContent(true); - return WebLayer(); + return WebScrollbarLayer(); } - RefPtr<ScrollbarLayerChromium> scrollbarLayer = ScrollbarLayerChromium::create(scrollbar, scrollLayer.unwrap<LayerChromium>()->id()); - scrollbarGraphicsLayer->setContentsToMedia(scrollbarLayer.get()); + // All Chromium scrollbar themes derive from ScrollbarThemeComposite. + ScrollbarThemeComposite* themeComposite = static_cast<ScrollbarThemeComposite*>(scrollbar->theme()); + WebKit::WebScrollbarThemePainter painter(themeComposite, scrollbar); + OwnPtr<WebKit::WebScrollbarThemeGeometry> geometry(WebKit::WebScrollbarThemeGeometryNative::create(themeComposite)); + + WebScrollbarLayer scrollbarLayer = WebScrollbarLayer::create(scrollbar, painter, geometry.release()); + scrollbarLayer.setScrollLayer(scrollLayer); + + scrollbarGraphicsLayer->setContentsToMedia(&scrollbarLayer); scrollbarGraphicsLayer->setDrawsContent(false); - scrollbarLayer->setOpaque(scrollbarGraphicsLayer->contentsOpaque()); + scrollbarLayer.setOpaque(scrollbarGraphicsLayer->contentsOpaque()); - return WebLayer(scrollbarLayer.release()); + return scrollbarLayer; } void ScrollingCoordinator::frameViewHorizontalScrollbarLayerDidChange(FrameView* frameView, GraphicsLayer* horizontalScrollbarLayer) @@ -166,13 +174,21 @@ void ScrollingCoordinator::frameViewVerticalScrollbarLayerDidChange(FrameView* f void ScrollingCoordinator::setScrollLayer(GraphicsLayer* scrollLayer) { - m_private->setScrollLayer(WebScrollableLayer(scrollLayer ? scrollLayer->platformLayer() : 0)); + WebScrollableLayer layer; + if (scrollLayer) + layer = scrollLayer->platformLayer()->to<WebScrollableLayer>(); + m_private->setScrollLayer(layer); } void ScrollingCoordinator::setNonFastScrollableRegion(const Region& region) { - if (m_private->hasScrollLayer()) - m_private->scrollLayer().unwrap<LayerChromium>()->setNonFastScrollableRegion(region); + if (m_private->hasScrollLayer()) { + Vector<IntRect> rects = region.rects(); + WebVector<WebRect> webRects(rects.size()); + for (size_t i = 0; i < rects.size(); ++i) + webRects[i] = rects[i]; + m_private->scrollLayer().setNonFastScrollableRegion(webRects); + } } void ScrollingCoordinator::setScrollParameters(const ScrollParameters&) @@ -199,14 +215,14 @@ bool ScrollingCoordinator::supportsFixedPositionLayers() const void ScrollingCoordinator::setLayerIsContainerForFixedPositionLayers(GraphicsLayer* layer, bool enable) { - if (LayerChromium* platformLayer = layer->platformLayer()) - platformLayer->setIsContainerForFixedPositionLayers(enable); + if (WebLayer* platformLayer = layer->platformLayer()) + platformLayer->to<WebScrollableLayer>().setIsContainerForFixedPositionLayers(enable); } void ScrollingCoordinator::setLayerIsFixedToContainerLayer(GraphicsLayer* layer, bool enable) { - if (LayerChromium* platformLayer = layer->platformLayer()) - platformLayer->setFixedToContainerLayer(enable); + if (WebLayer* platformLayer = layer->platformLayer()) + platformLayer->to<WebScrollableLayer>().setFixedToContainerLayer(enable); } } diff --git a/Source/WebCore/page/scrolling/mac/ScrollingTreeNodeMac.h b/Source/WebCore/page/scrolling/mac/ScrollingTreeNodeMac.h index 8a1576e7a..4304b61bb 100644 --- a/Source/WebCore/page/scrolling/mac/ScrollingTreeNodeMac.h +++ b/Source/WebCore/page/scrolling/mac/ScrollingTreeNodeMac.h @@ -74,6 +74,8 @@ private: void updateMainFramePinState(const IntPoint& scrollPosition); + void logExposedUnfilledArea(); + ScrollElasticityController m_scrollElasticityController; RetainPtr<CFRunLoopTimerRef> m_snapRubberbandTimer; diff --git a/Source/WebCore/page/scrolling/mac/ScrollingTreeNodeMac.mm b/Source/WebCore/page/scrolling/mac/ScrollingTreeNodeMac.mm index a37bf40c1..38dd9e53e 100644 --- a/Source/WebCore/page/scrolling/mac/ScrollingTreeNodeMac.mm +++ b/Source/WebCore/page/scrolling/mac/ScrollingTreeNodeMac.mm @@ -31,6 +31,12 @@ #include "PlatformWheelEvent.h" #include "ScrollingTree.h" #include "ScrollingTreeState.h" +#include "Settings.h" +#include "TileCache.h" +#include "WebTileLayer.h" + +#include <wtf/CurrentTime.h> +#include <wtf/Deque.h> namespace WebCore { @@ -233,6 +239,9 @@ void ScrollingTreeNodeMac::setScrollPosition(const IntPoint& scrollPosition) newScrollPosition = newScrollPosition.expandedTo(minimumScrollPosition()); setScrollPositionWithoutContentEdgeConstraints(newScrollPosition); + + if (scrollingTree()->scrollingPeformanceLoggingEnabled()) + logExposedUnfilledArea(); } void ScrollingTreeNodeMac::setScrollPositionWithoutContentEdgeConstraints(const IntPoint& scrollPosition) @@ -288,6 +297,39 @@ void ScrollingTreeNodeMac::updateMainFramePinState(const IntPoint& scrollPositio scrollingTree()->setMainFramePinState(pinnedToTheLeft, pinnedToTheRight); } +void ScrollingTreeNodeMac::logExposedUnfilledArea() +{ + Region paintedVisibleTiles; + + Deque<CALayer*> layerQueue; + layerQueue.append(m_scrollLayer.get()); + WebTileLayerList tiles; + + while(!layerQueue.isEmpty() && tiles.isEmpty()) { + CALayer* layer = layerQueue.takeFirst(); + NSArray* sublayers = [[layer sublayers] copy]; + + // If this layer is the parent of a tile, it is the parent of all of the tiles and nothing else. + if ([[sublayers objectAtIndex:0] isKindOfClass:[WebTileLayer class]]) { + for (CALayer* sublayer in sublayers) { + ASSERT([sublayer isKindOfClass:[WebTileLayer class]]); + tiles.append(static_cast<WebTileLayer*>(sublayer)); + } + } else { + for (CALayer* sublayer in sublayers) + layerQueue.append(sublayer); + } + + [sublayers release]; + } + + IntPoint scrollPosition = this->scrollPosition(); + unsigned unfilledArea = TileCache::blankPixelCountForTiles(tiles, viewportRect(), IntPoint(-scrollPosition.x(), -scrollPosition.y())); + + if (unfilledArea) + printf("SCROLLING: Exposed tileless area. Time: %f Unfilled Pixels: %u\n", WTF::monotonicallyIncreasingTime(), unfilledArea); +} + } // namespace WebCore #endif // ENABLE(THREADED_SCROLLING) |