Commit 6d9bba7b authored by abarth@chromium.org's avatar abarth@chromium.org

Non-composited, fixed position should trigger main thread scrolling

In a recent change, I broke the logic for determining whether fixed position
elements should trigger main thread scrolling. This CL fixes the logic to
trigger main thread scrolling if we have fixed position elements that lack
composited layers.

R=vollick@chromium.org
BUG=402359

Review URL: https://codereview.chromium.org/465333004

git-svn-id: svn://svn.chromium.org/blink/trunk@180226 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent 96c40ae3
TEST
{
"bounds": [800, 600],
"children": [
{
"bounds": [800, 600],
"contentsOpaque": true,
"drawsContent": true
}
]
}
Has non-layer viewport-constrained objects
<!DOCTYPE html>
<html>
<head>
<style>
.fixed {
position: fixed;
left: 10px;
top: 10px;
}
</style>
<script>
if (window.internals)
window.internals.settings.setAcceleratedCompositingForFixedPositionEnabled(false);
if (window.testRunner) {
testRunner.dumpAsText();
window.addEventListener("load", function() {
document.getElementById("layerTree").innerText = window.internals.layerTreeAsText(document);
document.getElementById("mainThreadScrollingReasons").innerText = window.internals.mainThreadScrollingReasons(document);
}, false);
}
</script>
</head>
<body>
<div class="fixed">TEST</div>
<pre id="layerTree"></pre>
<pre id="mainThreadScrollingReasons"></pre>
</body>
</html>
...@@ -887,13 +887,23 @@ bool ScrollingCoordinator::hasVisibleSlowRepaintViewportConstrainedObjects(Frame ...@@ -887,13 +887,23 @@ bool ScrollingCoordinator::hasVisibleSlowRepaintViewportConstrainedObjects(Frame
return false; return false;
for (FrameView::ViewportConstrainedObjectSet::const_iterator it = viewportConstrainedObjects->begin(), end = viewportConstrainedObjects->end(); it != end; ++it) { for (FrameView::ViewportConstrainedObjectSet::const_iterator it = viewportConstrainedObjects->begin(), end = viewportConstrainedObjects->end(); it != end; ++it) {
RenderObject* viewportConstrainedObject = *it; RenderObject* renderer = *it;
if (!viewportConstrainedObject->isBoxModelObject() || !viewportConstrainedObject->hasLayer()) ASSERT(renderer->isBoxModelObject() && renderer->hasLayer());
return true; ASSERT(renderer->style()->position() == FixedPosition);
RenderLayer* layer = toRenderBoxModelObject(viewportConstrainedObject)->layer(); RenderLayer* layer = toRenderBoxModelObject(renderer)->layer();
// Composited layers that actually paint into their enclosing ancestor
// must also force main thread scrolling. // Whether the RenderLayer scrolls with the viewport is a tree-depenent
if (layer->compositingState() == HasOwnBackingButPaintsIntoAncestor) // property and our viewportConstrainedObjects collection is maintained
// with only RenderObject-level information.
if (!layer->scrollsWithViewport())
continue;
// We're only smart enough to scroll viewport-constrainted objects
// in the compositor if they have their own backing or they paint
// into a grouped back (which necessarily all have the same viewport
// constraints).
CompositingState compositingState = layer->compositingState();
if (compositingState != PaintsIntoOwnBacking && compositingState != PaintsIntoGroupedBacking)
return true; return true;
} }
return false; return false;
......
...@@ -305,7 +305,7 @@ void RenderLayer::dirtyAncestorChainHasSelfPaintingLayerDescendantStatus() ...@@ -305,7 +305,7 @@ void RenderLayer::dirtyAncestorChainHasSelfPaintingLayerDescendantStatus()
bool RenderLayer::scrollsWithViewport() const bool RenderLayer::scrollsWithViewport() const
{ {
return renderer()->style()->position() == FixedPosition && renderer()->containingBlock()->enclosingLayer()->isRootLayer(); return renderer()->style()->position() == FixedPosition && renderer()->containerForFixedPosition() == renderer()->view();
} }
bool RenderLayer::scrollsWithRespectTo(const RenderLayer* other) const bool RenderLayer::scrollsWithRespectTo(const RenderLayer* other) const
......
...@@ -656,6 +656,7 @@ public: ...@@ -656,6 +656,7 @@ public:
// If paintInvalidationContainer and paintInvalidationContainerSkipped are not null, on return *paintInvalidationContainerSkipped // If paintInvalidationContainer and paintInvalidationContainerSkipped are not null, on return *paintInvalidationContainerSkipped
// is true if the renderer returned is an ancestor of paintInvalidationContainer. // is true if the renderer returned is an ancestor of paintInvalidationContainer.
RenderObject* container(const RenderLayerModelObject* paintInvalidationContainer = 0, bool* paintInvalidationContainerSkipped = 0) const; RenderObject* container(const RenderLayerModelObject* paintInvalidationContainer = 0, bool* paintInvalidationContainerSkipped = 0) const;
RenderBlock* containerForFixedPosition(const RenderLayerModelObject* paintInvalidationContainer = 0, bool* paintInvalidationContainerSkipped = 0) const;
virtual RenderObject* hoverAncestor() const { return parent(); } virtual RenderObject* hoverAncestor() const { return parent(); }
...@@ -1158,8 +1159,6 @@ protected: ...@@ -1158,8 +1159,6 @@ protected:
private: private:
const RenderLayerModelObject* enclosingCompositedContainer() const; const RenderLayerModelObject* enclosingCompositedContainer() const;
RenderBlock* containerForFixedPosition(const RenderLayerModelObject* paintInvalidationContainer = 0, bool* paintInvalidationContainerSkipped = 0) const;
RenderFlowThread* locateFlowThreadContainingBlock() const; RenderFlowThread* locateFlowThreadContainingBlock() const;
void removeFromRenderFlowThread(); void removeFromRenderFlowThread();
void removeFromRenderFlowThreadRecursive(RenderFlowThread*); void removeFromRenderFlowThreadRecursive(RenderFlowThread*);
......
...@@ -149,7 +149,7 @@ CompositingReasons CompositingReasonFinder::nonStyleDeterminedDirectReasons(cons ...@@ -149,7 +149,7 @@ CompositingReasons CompositingReasonFinder::nonStyleDeterminedDirectReasons(cons
directReasons |= CompositingReasonOverflowScrollingTouch; directReasons |= CompositingReasonOverflowScrollingTouch;
} }
if (requiresCompositingForPositionFixed(renderer)) if (requiresCompositingForPositionFixed(layer))
directReasons |= CompositingReasonPositionFixed; directReasons |= CompositingReasonPositionFixed;
directReasons |= renderer->additionalCompositingReasons(); directReasons |= renderer->additionalCompositingReasons();
...@@ -166,15 +166,13 @@ bool CompositingReasonFinder::requiresCompositingForAnimation(RenderStyle* style ...@@ -166,15 +166,13 @@ bool CompositingReasonFinder::requiresCompositingForAnimation(RenderStyle* style
return style->shouldCompositeForCurrentAnimations(); return style->shouldCompositeForCurrentAnimations();
} }
bool CompositingReasonFinder::requiresCompositingForPositionFixed(RenderObject* renderer) const bool CompositingReasonFinder::requiresCompositingForPositionFixed(const RenderLayer* layer) const
{ {
if (!(m_compositingTriggers & ViewportConstrainedPositionedTrigger)) if (!(m_compositingTriggers & ViewportConstrainedPositionedTrigger))
return false; return false;
// Don't promote fixed position elements that are descendants of a non-view container, e.g. transformed elements. // Don't promote fixed position elements that are descendants of a non-view container, e.g. transformed elements.
// They will stay fixed wrt the container rather than the enclosing frame. // They will stay fixed wrt the container rather than the enclosing frame.
return renderer->style()->position() == FixedPosition return layer->scrollsWithViewport() && m_renderView.frameView()->isScrollable();
&& renderer->container() == &m_renderView
&& m_renderView.frameView()->isScrollable();
} }
} }
...@@ -34,7 +34,7 @@ private: ...@@ -34,7 +34,7 @@ private:
bool requiresCompositingForTransform(RenderObject*) const; bool requiresCompositingForTransform(RenderObject*) const;
bool requiresCompositingForAnimation(RenderStyle*) const; bool requiresCompositingForAnimation(RenderStyle*) const;
bool requiresCompositingForPositionFixed(RenderObject*) const; bool requiresCompositingForPositionFixed(const RenderLayer*) const;
RenderView& m_renderView; RenderView& m_renderView;
CompositingTriggerFlags m_compositingTriggers; CompositingTriggerFlags m_compositingTriggers;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment