summaryrefslogtreecommitdiff
path: root/chromium/third_party/WebKit/Source/core/page/scrolling/ScrollingCoordinator.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'chromium/third_party/WebKit/Source/core/page/scrolling/ScrollingCoordinator.cpp')
-rw-r--r--chromium/third_party/WebKit/Source/core/page/scrolling/ScrollingCoordinator.cpp251
1 files changed, 157 insertions, 94 deletions
diff --git a/chromium/third_party/WebKit/Source/core/page/scrolling/ScrollingCoordinator.cpp b/chromium/third_party/WebKit/Source/core/page/scrolling/ScrollingCoordinator.cpp
index fbff981432f..51ecb5d055d 100644
--- a/chromium/third_party/WebKit/Source/core/page/scrolling/ScrollingCoordinator.cpp
+++ b/chromium/third_party/WebKit/Source/core/page/scrolling/ScrollingCoordinator.cpp
@@ -32,26 +32,24 @@
#include "core/dom/Node.h"
#include "core/dom/WheelController.h"
#include "core/html/HTMLElement.h"
-#include "core/page/Frame.h"
-#include "core/page/FrameView.h"
+#include "core/frame/Frame.h"
+#include "core/frame/FrameView.h"
#include "core/page/Page.h"
-#include "core/page/Settings.h"
-#include "core/platform/PlatformWheelEvent.h"
-#include "core/platform/ScrollAnimator.h"
-#include "core/platform/ScrollbarTheme.h"
-#include "core/platform/chromium/TraceEvent.h"
-#include "core/platform/chromium/support/WebScrollbarImpl.h"
-#include "core/platform/chromium/support/WebScrollbarThemeGeometryNative.h"
-#include "core/platform/graphics/GraphicsLayer.h"
-#include "core/platform/graphics/IntRect.h"
-#include "core/platform/graphics/Region.h"
-#include "core/platform/graphics/transforms/TransformState.h"
+#include "core/frame/Settings.h"
+#include "platform/TraceEvent.h"
+#include "platform/exported/WebScrollbarImpl.h"
+#include "platform/exported/WebScrollbarThemeGeometryNative.h"
+#include "platform/geometry/Region.h"
+#include "platform/geometry/TransformState.h"
+#include "platform/graphics/GraphicsLayer.h"
#if OS(MACOSX)
-#include "core/platform/mac/ScrollAnimatorMac.h"
+#include "platform/mac/ScrollAnimatorMac.h"
#endif
+#include "platform/scroll/ScrollAnimator.h"
+#include "platform/scroll/ScrollbarTheme.h"
#include "core/plugins/PluginView.h"
+#include "core/rendering/CompositedLayerMapping.h"
#include "core/rendering/RenderGeometryMap.h"
-#include "core/rendering/RenderLayerBacking.h"
#include "core/rendering/RenderLayerCompositor.h"
#include "core/rendering/RenderView.h"
#include "public/platform/Platform.h"
@@ -62,11 +60,11 @@
#include "public/platform/WebScrollbarThemePainter.h"
#include "wtf/text/StringBuilder.h"
-using WebKit::WebLayer;
-using WebKit::WebLayerPositionConstraint;
-using WebKit::WebRect;
-using WebKit::WebScrollbarLayer;
-using WebKit::WebVector;
+using blink::WebLayer;
+using blink::WebLayerPositionConstraint;
+using blink::WebRect;
+using blink::WebScrollbarLayer;
+using blink::WebVector;
namespace WebCore {
@@ -89,6 +87,10 @@ PassRefPtr<ScrollingCoordinator> ScrollingCoordinator::create(Page* page)
ScrollingCoordinator::ScrollingCoordinator(Page* page)
: m_page(page)
+ , m_scrollGestureRegionIsDirty(false)
+ , m_touchEventTargetRectsAreDirty(false)
+ , m_wasFrameScrollable(false)
+ , m_lastMainThreadScrollingReasons(0)
{
}
@@ -105,7 +107,8 @@ ScrollingCoordinator::~ScrollingCoordinator()
bool ScrollingCoordinator::touchHitTestingEnabled() const
{
RenderView* contentRenderer = m_page->mainFrame()->contentRenderer();
- return RuntimeEnabledFeatures::touchEnabled() && contentRenderer && contentRenderer->usesCompositing();
+ Settings* settings = m_page->mainFrame()->document()->settings();
+ return RuntimeEnabledFeatures::touchEnabled() && settings->compositorTouchHitTesting() && contentRenderer && contentRenderer->usesCompositing();
}
void ScrollingCoordinator::setShouldHandleScrollGestureOnMainThreadRegion(const Region& region)
@@ -119,29 +122,47 @@ void ScrollingCoordinator::setShouldHandleScrollGestureOnMainThreadRegion(const
}
}
-void ScrollingCoordinator::frameViewLayoutUpdated(FrameView* frameView)
+void ScrollingCoordinator::notifyLayoutUpdated()
{
- TRACE_EVENT0("input", "ScrollingCoordinator::frameViewLayoutUpdated");
+ // These computations need to happen after compositing is updated.
+ m_scrollGestureRegionIsDirty = true;
+ m_touchEventTargetRectsAreDirty = true;
+}
- // Compute the region of the page where we can't handle scroll gestures and mousewheel events
- // on the impl thread. This currently includes:
- // 1. All scrollable areas, such as subframes, overflow divs and list boxes, whose composited
- // scrolling are not enabled. We need to do this even if the frame view whose layout was updated
- // is not the main frame.
- // 2. Resize control areas, e.g. the small rect at the right bottom of div/textarea/iframe when
- // CSS property "resize" is enabled.
- // 3. Plugin areas.
- Region shouldHandleScrollGestureOnMainThreadRegion = computeShouldHandleScrollGestureOnMainThreadRegion(m_page->mainFrame(), IntPoint());
- setShouldHandleScrollGestureOnMainThreadRegion(shouldHandleScrollGestureOnMainThreadRegion);
+void ScrollingCoordinator::updateAfterCompositingChange()
+{
+ TRACE_EVENT0("input", "ScrollingCoordinator::updateAfterCompositingChange");
- if (touchHitTestingEnabled()) {
- LayerHitTestRects touchEventTargetRects;
- computeTouchEventTargetRects(touchEventTargetRects);
- setTouchEventTargetRects(touchEventTargetRects);
+ if (m_scrollGestureRegionIsDirty) {
+ // Compute the region of the page where we can't handle scroll gestures and mousewheel events
+ // on the impl thread. This currently includes:
+ // 1. All scrollable areas, such as subframes, overflow divs and list boxes, whose composited
+ // scrolling are not enabled. We need to do this even if the frame view whose layout was updated
+ // is not the main frame.
+ // 2. Resize control areas, e.g. the small rect at the right bottom of div/textarea/iframe when
+ // CSS property "resize" is enabled.
+ // 3. Plugin areas.
+ Region shouldHandleScrollGestureOnMainThreadRegion = computeShouldHandleScrollGestureOnMainThreadRegion(m_page->mainFrame(), IntPoint());
+ setShouldHandleScrollGestureOnMainThreadRegion(shouldHandleScrollGestureOnMainThreadRegion);
+ m_scrollGestureRegionIsDirty = false;
}
- if (WebLayer* scrollLayer = scrollingWebLayerForScrollableArea(frameView))
- scrollLayer->setBounds(frameView->contentsSize());
+ if (m_touchEventTargetRectsAreDirty) {
+ updateTouchEventTargetRectsIfNeeded();
+ m_touchEventTargetRectsAreDirty = false;
+ }
+
+ FrameView* frameView = m_page->mainFrame()->view();
+ bool frameIsScrollable = frameView && frameView->isScrollable();
+ if (m_wasFrameScrollable != frameIsScrollable)
+ updateShouldUpdateScrollLayerPositionOnMainThread();
+ m_wasFrameScrollable = frameIsScrollable;
+
+ const FrameTree& tree = m_page->mainFrame()->tree();
+ for (const Frame* child = tree.firstChild(); child; child = child->tree().nextSibling()) {
+ if (WebLayer* scrollLayer = scrollingWebLayerForScrollableArea(child->view()))
+ scrollLayer->setBounds(child->view()->contentsSize());
+ }
}
void ScrollingCoordinator::setLayerIsContainerForFixedPositionLayers(GraphicsLayer* layer, bool enable)
@@ -158,7 +179,7 @@ static void clearPositionConstraintExceptForLayer(GraphicsLayer* layer, Graphics
static WebLayerPositionConstraint computePositionConstraint(const RenderLayer* layer)
{
- ASSERT(layer->isComposited());
+ ASSERT(layer->hasCompositedLayerMapping());
do {
if (layer->renderer()->style()->position() == FixedPosition) {
const RenderObject* fixedPositionObject = layer->renderer();
@@ -168,19 +189,22 @@ static WebLayerPositionConstraint computePositionConstraint(const RenderLayer* l
}
layer = layer->parent();
- } while (layer && !layer->isComposited());
+
+ // Composited layers that inherit a fixed position state will be positioned with respect to the nearest compositedLayerMapping's GraphicsLayer.
+ // So, once we find a layer that has its own compositedLayerMapping, we can stop searching for a fixed position RenderObject.
+ } while (layer && !layer->hasCompositedLayerMapping());
return WebLayerPositionConstraint();
}
void ScrollingCoordinator::updateLayerPositionConstraint(RenderLayer* layer)
{
- ASSERT(layer->backing());
- RenderLayerBacking* backing = layer->backing();
- GraphicsLayer* mainLayer = backing->childForSuperlayers();
+ ASSERT(layer->hasCompositedLayerMapping());
+ CompositedLayerMappingPtr compositedLayerMapping = layer->compositedLayerMapping();
+ GraphicsLayer* mainLayer = compositedLayerMapping->childForSuperlayers();
// Avoid unnecessary commits
- clearPositionConstraintExceptForLayer(backing->ancestorClippingLayer(), mainLayer);
- clearPositionConstraintExceptForLayer(backing->graphicsLayer(), mainLayer);
+ clearPositionConstraintExceptForLayer(compositedLayerMapping->ancestorClippingLayer(), mainLayer);
+ clearPositionConstraintExceptForLayer(compositedLayerMapping->mainGraphicsLayer(), mainLayer);
if (WebLayer* scrollableLayer = scrollingWebLayerForGraphicsLayer(mainLayer))
scrollableLayer->setPositionConstraint(computePositionConstraint(layer));
@@ -202,18 +226,18 @@ void ScrollingCoordinator::removeWebScrollbarLayer(ScrollableArea* scrollableAre
static PassOwnPtr<WebScrollbarLayer> createScrollbarLayer(Scrollbar* scrollbar)
{
ScrollbarTheme* theme = scrollbar->theme();
- WebKit::WebScrollbarThemePainter painter(theme, scrollbar);
- OwnPtr<WebKit::WebScrollbarThemeGeometry> geometry(WebKit::WebScrollbarThemeGeometryNative::create(theme));
+ blink::WebScrollbarThemePainter painter(theme, scrollbar);
+ OwnPtr<blink::WebScrollbarThemeGeometry> geometry(blink::WebScrollbarThemeGeometryNative::create(theme));
- OwnPtr<WebScrollbarLayer> scrollbarLayer = adoptPtr(WebKit::Platform::current()->compositorSupport()->createScrollbarLayer(new WebKit::WebScrollbarImpl(scrollbar), painter, geometry.leakPtr()));
+ OwnPtr<WebScrollbarLayer> scrollbarLayer = adoptPtr(blink::Platform::current()->compositorSupport()->createScrollbarLayer(new blink::WebScrollbarImpl(scrollbar), painter, geometry.leakPtr()));
GraphicsLayer::registerContentsLayer(scrollbarLayer->layer());
return scrollbarLayer.release();
}
PassOwnPtr<WebScrollbarLayer> ScrollingCoordinator::createSolidColorScrollbarLayer(ScrollbarOrientation orientation, int thumbThickness, bool isLeftSideVerticalScrollbar)
{
- WebKit::WebScrollbar::Orientation webOrientation = (orientation == HorizontalScrollbar) ? WebKit::WebScrollbar::Horizontal : WebKit::WebScrollbar::Vertical;
- OwnPtr<WebScrollbarLayer> scrollbarLayer = adoptPtr(WebKit::Platform::current()->compositorSupport()->createSolidColorScrollbarLayer(webOrientation, thumbThickness, isLeftSideVerticalScrollbar));
+ blink::WebScrollbar::Orientation webOrientation = (orientation == HorizontalScrollbar) ? blink::WebScrollbar::Horizontal : blink::WebScrollbar::Vertical;
+ OwnPtr<WebScrollbarLayer> scrollbarLayer = adoptPtr(blink::Platform::current()->compositorSupport()->createSolidColorScrollbarLayer(webOrientation, thumbThickness, isLeftSideVerticalScrollbar));
GraphicsLayer::registerContentsLayer(scrollbarLayer->layer());
return scrollbarLayer.release();
}
@@ -240,7 +264,7 @@ static void setupScrollbarLayer(GraphicsLayer* scrollbarGraphicsLayer, WebScroll
scrollbarGraphicsLayer->setDrawsContent(false);
}
-WebScrollbarLayer* ScrollingCoordinator::addWebScrollbarLayer(ScrollableArea* scrollableArea, ScrollbarOrientation orientation, PassOwnPtr<WebKit::WebScrollbarLayer> scrollbarLayer)
+WebScrollbarLayer* ScrollingCoordinator::addWebScrollbarLayer(ScrollableArea* scrollableArea, ScrollbarOrientation orientation, PassOwnPtr<blink::WebScrollbarLayer> scrollbarLayer)
{
ScrollbarMap& scrollbars = orientation == HorizontalScrollbar ? m_horizontalScrollbars : m_verticalScrollbars;
return scrollbars.add(scrollableArea, scrollbarLayer).iterator->value.get();
@@ -319,6 +343,9 @@ bool ScrollingCoordinator::scrollableAreaScrollLayerDidChange(ScrollableArea* sc
webLayer->setScrollable(true);
webLayer->setScrollPosition(IntPoint(scrollableArea->scrollPosition() - scrollableArea->minimumScrollPosition()));
webLayer->setMaxScrollPosition(IntSize(scrollableArea->scrollSize(HorizontalScrollbar), scrollableArea->scrollSize(VerticalScrollbar)));
+ bool canScrollX = scrollableArea->userInputScrollable(HorizontalScrollbar);
+ bool canScrollY = scrollableArea->userInputScrollable(VerticalScrollbar);
+ webLayer->setUserScrollable(canScrollX, canScrollY);
}
if (WebScrollbarLayer* scrollbarLayer = getWebScrollbarLayer(scrollableArea, HorizontalScrollbar)) {
GraphicsLayer* horizontalScrollbarLayer = horizontalScrollbarLayerForScrollableArea(scrollableArea);
@@ -342,8 +369,8 @@ typedef HashMap<const RenderLayer*, Vector<const Frame*> > LayerFrameMap;
static void makeLayerChildFrameMap(const Frame* currentFrame, LayerFrameMap* map)
{
map->clear();
- const FrameTree* tree = currentFrame->tree();
- for (const Frame* child = tree->firstChild(); child; child = child->tree()->nextSibling()) {
+ const FrameTree& tree = currentFrame->tree();
+ for (const Frame* child = tree.firstChild(); child; child = child->tree().nextSibling()) {
const RenderLayer* containingLayer = child->ownerRenderer()->enclosingLayer();
LayerFrameMap::iterator iter = map->find(containingLayer);
if (iter == map->end())
@@ -393,7 +420,8 @@ static void convertLayerRectsToEnclosingCompositedLayerRecursive(
// If the enclosing composited layer itself is scrolled, we have to undo the subtraction
// of its scroll offset since we want the offset relative to the scrolling content, not
// the element itself.
- rect.move(compositedLayer->scrolledContentOffset());
+ if (compositedLayer->renderer()->hasOverflowClip())
+ rect.move(compositedLayer->renderBox()->scrolledContentOffset());
}
compIter->value.append(rect);
}
@@ -460,6 +488,30 @@ static void convertLayerRectsToEnclosingCompositedLayer(Frame* mainFrame, const
convertLayerRectsToEnclosingCompositedLayerRecursive(mainFrame->contentRenderer()->layer(), layerRects, compositorRects, geometryMap, layersWithRects, layerChildFrameMap);
}
+void ScrollingCoordinator::updateTouchEventTargetRectsIfNeeded()
+{
+ TRACE_EVENT0("input", "ScrollingCoordinator::updateTouchEventTargetRectsIfNeeded");
+
+ if (!touchHitTestingEnabled())
+ return;
+
+ LayerHitTestRects touchEventTargetRects;
+ computeTouchEventTargetRects(touchEventTargetRects);
+ setTouchEventTargetRects(touchEventTargetRects);
+}
+
+void ScrollingCoordinator::reset()
+{
+ m_horizontalScrollbars.clear();
+ m_verticalScrollbars.clear();
+ m_layersWithTouchRects.clear();
+ m_wasFrameScrollable = false;
+
+ // This is retained for testing.
+ m_lastMainThreadScrollingReasons = 0;
+ setShouldUpdateScrollLayerPositionOnMainThread(m_lastMainThreadScrollingReasons);
+}
+
// Note that in principle this could be called more often than computeTouchEventTargetRects, for
// example during a non-composited scroll (although that's not yet implemented - crbug.com/261307).
void ScrollingCoordinator::setTouchEventTargetRects(const LayerHitTestRects& layerRects)
@@ -477,12 +529,14 @@ void ScrollingCoordinator::setTouchEventTargetRects(const LayerHitTestRects& lay
WebVector<WebRect> webRects(iter->value.size());
for (size_t i = 0; i < iter->value.size(); ++i)
webRects[i] = enclosingIntRect(iter->value[i]);
- RenderLayerBacking* backing = layer->backing();
+ // This should be ensured by convertLayerRectsToEnclosingCompositedLayer above.
+ ASSERT(layer->hasCompositedLayerMapping());
+ CompositedLayerMappingPtr compositedLayerMapping = layer->compositedLayerMapping();
// If the layer is using composited scrolling, then it's the contents that these
// rects apply to.
- GraphicsLayer* graphicsLayer = backing->scrollingContentsLayer();
+ GraphicsLayer* graphicsLayer = compositedLayerMapping->scrollingContentsLayer();
if (!graphicsLayer)
- graphicsLayer = backing->graphicsLayer();
+ graphicsLayer = compositedLayerMapping->mainGraphicsLayer();
graphicsLayer->platformLayer()->setTouchEventHandlerRegion(webRects);
oldLayersWithTouchRects.remove(layer);
m_layersWithTouchRects.add(layer);
@@ -490,10 +544,14 @@ void ScrollingCoordinator::setTouchEventTargetRects(const LayerHitTestRects& lay
// If there are any layers left that we haven't updated, clear them out.
for (HashSet<const RenderLayer*>::iterator it = oldLayersWithTouchRects.begin(); it != oldLayersWithTouchRects.end(); ++it) {
- if (RenderLayerBacking* backing = (*it)->backing()) {
- GraphicsLayer* graphicsLayer = backing->scrollingContentsLayer();
+ // FIXME: This is a bug. What's happening here is that we're clearing touch regions for
+ // layers that we didn't visit above. That assumes a 1:1 mapping between RenderLayer and
+ // the graphics layer that owns the touch rects. This is false in the case of
+ // HasOwnBackingButPaintsIntoAncestor and will be extra-false in the world of squashing.
+ if ((*it)->hasCompositedLayerMapping()) {
+ GraphicsLayer* graphicsLayer = (*it)->compositedLayerMapping()->scrollingContentsLayer();
if (!graphicsLayer)
- graphicsLayer = backing->graphicsLayer();
+ graphicsLayer = (*it)->compositedLayerMapping()->mainGraphicsLayer();
graphicsLayer->platformLayer()->setTouchEventHandlerRegion(WebVector<WebRect>());
}
}
@@ -508,37 +566,31 @@ void ScrollingCoordinator::touchEventTargetRectsDidChange(const Document*)
if (m_page->mainFrame()->view()->needsLayout())
return;
- TRACE_EVENT0("input", "ScrollingCoordinator::touchEventTargetRectsDidChange");
+ // FIXME: scheduleAnimation() is just a method of forcing the compositor to realize that it
+ // needs to commit here. We should expose a cleaner API for this.
+ RenderView* renderView = m_page->mainFrame()->contentRenderer();
+ if (renderView && renderView->compositor() && renderView->compositor()->inCompositingMode())
+ m_page->mainFrame()->view()->scheduleAnimation();
- LayerHitTestRects touchEventTargetRects;
- computeTouchEventTargetRects(touchEventTargetRects);
- setTouchEventTargetRects(touchEventTargetRects);
+ m_touchEventTargetRectsAreDirty = true;
}
-void ScrollingCoordinator::updateScrollParentForLayer(RenderLayer* child, RenderLayer* parent)
+void ScrollingCoordinator::updateScrollParentForGraphicsLayer(GraphicsLayer* child, RenderLayer* parent)
{
- WebLayer* childWebLayer = scrollingWebLayerForGraphicsLayer(child->layerForScrollChild());
- if (!childWebLayer)
- return;
-
WebLayer* scrollParentWebLayer = 0;
- if (parent && parent->backing())
- scrollParentWebLayer = scrollingWebLayerForGraphicsLayer(parent->backing()->parentForSublayers());
+ if (parent && parent->hasCompositedLayerMapping())
+ scrollParentWebLayer = scrollingWebLayerForGraphicsLayer(parent->compositedLayerMapping()->parentForSublayers());
- childWebLayer->setScrollParent(scrollParentWebLayer);
+ child->setScrollParent(scrollParentWebLayer);
}
-void ScrollingCoordinator::updateClipParentForLayer(RenderLayer* child, RenderLayer* parent)
+void ScrollingCoordinator::updateClipParentForGraphicsLayer(GraphicsLayer* child, RenderLayer* parent)
{
- WebLayer* childWebLayer = scrollingWebLayerForGraphicsLayer(child->backing()->graphicsLayer());
- if (!childWebLayer)
- return;
-
WebLayer* clipParentWebLayer = 0;
- if (parent && parent->backing())
- clipParentWebLayer = scrollingWebLayerForGraphicsLayer(parent->backing()->parentForSublayers());
+ if (parent && parent->hasCompositedLayerMapping())
+ clipParentWebLayer = scrollingWebLayerForGraphicsLayer(parent->compositedLayerMapping()->parentForSublayers());
- childWebLayer->setClipParent(clipParentWebLayer);
+ child->setClipParent(clipParentWebLayer);
}
void ScrollingCoordinator::willDestroyRenderLayer(RenderLayer* layer)
@@ -552,16 +604,17 @@ void ScrollingCoordinator::setWheelEventHandlerCount(unsigned count)
scrollLayer->setHaveWheelEventHandlers(count > 0);
}
-void ScrollingCoordinator::recomputeWheelEventHandlerCountForFrameView(FrameView* frameView)
+void ScrollingCoordinator::recomputeWheelEventHandlerCountForFrameView(FrameView*)
{
- UNUSED_PARAM(frameView);
setWheelEventHandlerCount(computeCurrentWheelEventHandlerCount());
}
void ScrollingCoordinator::setShouldUpdateScrollLayerPositionOnMainThread(MainThreadScrollingReasons reasons)
{
- if (WebLayer* scrollLayer = scrollingWebLayerForScrollableArea(m_page->mainFrame()->view()))
+ if (WebLayer* scrollLayer = scrollingWebLayerForScrollableArea(m_page->mainFrame()->view())) {
+ m_lastMainThreadScrollingReasons = reasons;
scrollLayer->setShouldScrollOnMainThread(reasons);
+ }
}
void ScrollingCoordinator::pageDestroyed()
@@ -614,9 +667,9 @@ Region ScrollingCoordinator::computeShouldHandleScrollGestureOnMainThreadRegion(
// on main thread).
if (const FrameView::ResizerAreaSet* resizerAreas = frameView->resizerAreas()) {
for (FrameView::ResizerAreaSet::const_iterator it = resizerAreas->begin(), end = resizerAreas->end(); it != end; ++it) {
- RenderLayer* layer = *it;
- IntRect bounds = layer->renderer()->absoluteBoundingBoxRect();
- IntRect corner = layer->resizerCornerRect(bounds, ResizerForTouch);
+ RenderBox* box = *it;
+ IntRect bounds = box->absoluteBoundingBoxRect();
+ IntRect corner = box->layer()->scrollableArea()->touchResizerCornerRect(bounds);
corner.moveBy(offset);
shouldHandleScrollGestureOnMainThreadRegion.unite(corner);
}
@@ -633,8 +686,8 @@ Region ScrollingCoordinator::computeShouldHandleScrollGestureOnMainThreadRegion(
}
}
- FrameTree* tree = frame->tree();
- for (Frame* subFrame = tree->firstChild(); subFrame; subFrame = subFrame->tree()->nextSibling())
+ const FrameTree& tree = frame->tree();
+ for (Frame* subFrame = tree.firstChild(); subFrame; subFrame = subFrame->tree().nextSibling())
shouldHandleScrollGestureOnMainThreadRegion.unite(computeShouldHandleScrollGestureOnMainThreadRegion(subFrame, offset));
return shouldHandleScrollGestureOnMainThreadRegion;
@@ -701,7 +754,7 @@ unsigned ScrollingCoordinator::computeCurrentWheelEventHandlerCount()
{
unsigned wheelEventHandlerCount = 0;
- for (Frame* frame = m_page->mainFrame(); frame; frame = frame->tree()->traverseNext()) {
+ for (Frame* frame = m_page->mainFrame(); frame; frame = frame->tree().traverseNext()) {
if (frame->document())
wheelEventHandlerCount += WheelController::from(frame->document())->wheelEventHandlerCount();
}
@@ -780,7 +833,7 @@ void ScrollingCoordinator::frameViewRootLayerDidChange(FrameView* frameView)
if (!coordinatesScrollingForFrameView(frameView))
return;
- frameViewLayoutUpdated(frameView);
+ notifyLayoutUpdated();
recomputeWheelEventHandlerCountForFrameView(frameView);
updateShouldUpdateScrollLayerPositionOnMainThread();
}
@@ -813,12 +866,12 @@ bool ScrollingCoordinator::hasVisibleSlowRepaintViewportConstrainedObjects(Frame
return true;
RenderLayer* layer = toRenderBoxModelObject(viewportConstrainedObject)->layer();
// Any explicit reason that a fixed position element is not composited shouldn't cause slow scrolling.
- if (!layer->isComposited() && layer->viewportConstrainedNotCompositedReason() == RenderLayer::NoNotCompositedReason)
+ if (layer->compositingState() != PaintsIntoOwnBacking && layer->viewportConstrainedNotCompositedReason() == RenderLayer::NoNotCompositedReason)
return true;
// Composited layers that actually paint into their enclosing ancestor
// must also force main thread scrolling.
- if (layer->isComposited() && layer->backing()->paintsIntoCompositedAncestor())
+ if (layer->compositingState() == HasOwnBackingButPaintsIntoAncestor)
return true;
}
return false;
@@ -826,6 +879,9 @@ bool ScrollingCoordinator::hasVisibleSlowRepaintViewportConstrainedObjects(Frame
MainThreadScrollingReasons ScrollingCoordinator::mainThreadScrollingReasons() const
{
+ // The main thread scrolling reasons are applicable to scrolls of the main
+ // frame. If it does not exist or if it is not scrollable, there is no
+ // reason to force main thread scrolling.
FrameView* frameView = m_page->mainFrame()->view();
if (!frameView)
return static_cast<MainThreadScrollingReasons>(0);
@@ -863,7 +919,14 @@ String ScrollingCoordinator::mainThreadScrollingReasonsAsText(MainThreadScrollin
String ScrollingCoordinator::mainThreadScrollingReasonsAsText() const
{
- return mainThreadScrollingReasonsAsText(mainThreadScrollingReasons());
+ return mainThreadScrollingReasonsAsText(m_lastMainThreadScrollingReasons);
+}
+
+bool ScrollingCoordinator::frameViewIsScrollableIsDirty() const
+{
+ FrameView* frameView = m_page->mainFrame()->view();
+ bool frameIsScrollable = frameView && frameView->isScrollable();
+ return frameIsScrollable != m_wasFrameScrollable;
}
} // namespace WebCore