Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(101)

Unified Diff: third_party/WebKit/Source/core/layout/compositing/CompositedLayerMapping.cpp

Issue 1448253002: Clip scrollbars to box bounds when they don't fit. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/core/layout/compositing/CompositedLayerMapping.cpp
diff --git a/third_party/WebKit/Source/core/layout/compositing/CompositedLayerMapping.cpp b/third_party/WebKit/Source/core/layout/compositing/CompositedLayerMapping.cpp
index d61ec02d198ed490b539551d63177555d9def36d..21c7ec14add5521c44300d1a72d71d5f64b70304 100644
--- a/third_party/WebKit/Source/core/layout/compositing/CompositedLayerMapping.cpp
+++ b/third_party/WebKit/Source/core/layout/compositing/CompositedLayerMapping.cpp
@@ -709,11 +709,11 @@ void CompositedLayerMapping::updateGraphicsLayerGeometry(const PaintLayer* compo
// Might update graphicsLayerParentLocation.
updateAncestorClippingLayerGeometry(compositingContainer, snappedOffsetFromCompositedAncestor, graphicsLayerParentLocation);
- updateOverflowControlsHostLayerGeometry(compositingStackingContext, compositingContainer);
FloatSize contentsSize = relativeCompositingBounds.size();
updateMainGraphicsLayerGeometry(relativeCompositingBounds, localCompositingBounds, graphicsLayerParentLocation);
+ updateOverflowControlsHostLayerGeometry(compositingStackingContext, compositingContainer);
updateContentsOffsetInCompositingLayer(snappedOffsetFromCompositedAncestor, graphicsLayerParentLocation);
updateSquashingLayerGeometry(offsetFromCompositedAncestor, graphicsLayerParentLocation, m_owningLayer, m_squashedLayers, m_squashingLayer.get(), &m_squashingLayerOffsetFromTransformedAncestor, layersNeedingPaintInvalidation);
@@ -828,12 +828,14 @@ void CompositedLayerMapping::updateOverflowControlsHostLayerGeometry(const Paint
if (!m_overflowControlsHostLayer)
return;
+ LayoutPoint hostLayerPosition;
+
if (needsToReparentOverflowControls()) {
- if (m_overflowControlsClippingLayer) {
- m_overflowControlsClippingLayer->setSize(m_ancestorClippingLayer->size());
- m_overflowControlsClippingLayer->setOffsetFromLayoutObject(m_ancestorClippingLayer->offsetFromLayoutObject());
- m_overflowControlsClippingLayer->setMasksToBounds(true);
- m_overflowControlsHostLayer->setPosition(IntPoint(-m_overflowControlsClippingLayer->offsetFromLayoutObject()));
+ if (m_overflowControlsAncestorClippingLayer) {
+ m_overflowControlsAncestorClippingLayer->setSize(m_ancestorClippingLayer->size());
+ m_overflowControlsAncestorClippingLayer->setOffsetFromLayoutObject(m_ancestorClippingLayer->offsetFromLayoutObject());
+ m_overflowControlsAncestorClippingLayer->setMasksToBounds(true);
+ hostLayerPosition = toLayoutPoint(LayoutSize(-m_overflowControlsAncestorClippingLayer->offsetFromLayoutObject()));
FloatPoint position = m_ancestorClippingLayer->position();
if (compositingStackingContext != compositingContainer) {
@@ -843,20 +845,25 @@ void CompositedLayerMapping::updateOverflowControlsHostLayerGeometry(const Paint
position += offsetFromStackingContainer;
}
- m_overflowControlsClippingLayer->setPosition(position);
+ m_overflowControlsAncestorClippingLayer->setPosition(position);
} else {
// The controls are in the same 2D space as the compositing container, so we can map them into the space of the container.
TransformState transformState(TransformState::ApplyTransformDirection, FloatPoint());
m_owningLayer.layoutObject()->mapLocalToContainer(compositingStackingContext->layoutObject(), transformState, ApplyContainerFlip);
transformState.flatten();
- LayoutPoint offsetFromStackingContainer = LayoutPoint(transformState.lastPlanarPoint());
+ hostLayerPosition = LayoutPoint(transformState.lastPlanarPoint());
if (PaintLayerScrollableArea* scrollableArea = compositingStackingContext->scrollableArea())
- offsetFromStackingContainer.move(LayoutSize(scrollableArea->adjustedScrollOffset()));
- m_overflowControlsHostLayer->setPosition(FloatPoint(offsetFromStackingContainer));
+ hostLayerPosition.move(LayoutSize(scrollableArea->adjustedScrollOffset()));
}
- } else {
- m_overflowControlsHostLayer->setPosition(FloatPoint());
}
+
+ IntSize offsetFromLayoutObject = m_graphicsLayer->offsetFromLayoutObject() - roundedIntSize(m_owningLayer.subpixelAccumulation());
chrishtr 2015/11/19 17:29:52 Add comments explaining what this is doing and why
skobes 2015/11/19 18:30:07 Done.
+ hostLayerPosition.move(-offsetFromLayoutObject);
+ m_overflowControlsHostLayer->setPosition(FloatPoint(hostLayerPosition));
+
+ const IntRect borderBox = toLayoutBox(m_owningLayer.layoutObject())->pixelSnappedBorderBoxRect();
+ m_overflowControlsHostLayer->setSize(borderBox.size());
+ m_overflowControlsHostLayer->setMasksToBounds(true);
}
void CompositedLayerMapping::updateChildContainmentLayerGeometry(const IntRect& clippingBox, const IntRect& localCompositingBounds)
@@ -1103,7 +1110,7 @@ void CompositedLayerMapping::updateInternalHierarchy()
bottomLayer = m_graphicsLayer.get();
if (m_isMainFrameLayoutViewLayer)
bottomLayer = layoutObject()->frame()->page()->frameHost().visualViewport().containerLayer();
- updateBottomLayer(m_overflowControlsClippingLayer.get());
+ updateBottomLayer(m_overflowControlsAncestorClippingLayer.get());
updateBottomLayer(m_overflowControlsHostLayer.get());
if (m_layerForHorizontalScrollbar)
m_overflowControlsHostLayer->addChild(m_layerForHorizontalScrollbar.get());
@@ -1344,8 +1351,8 @@ bool CompositedLayerMapping::updateOverflowControlsLayers(bool needsHorizontalSc
bool needsOverflowControlsHostLayer = needsHorizontalScrollbarLayer || needsVerticalScrollbarLayer || needsScrollCornerLayer;
toggleScrollbarLayerIfNeeded(m_overflowControlsHostLayer, needsOverflowControlsHostLayer, CompositingReasonLayerForOverflowControlsHost);
- bool needsOverflowClipLayer = needsOverflowControlsHostLayer && needsAncestorClip;
- toggleScrollbarLayerIfNeeded(m_overflowControlsClippingLayer, needsOverflowClipLayer, CompositingReasonLayerForOverflowControlsHost);
+ bool needsOverflowAncestorClipLayer = needsOverflowControlsHostLayer && needsAncestorClip;
+ toggleScrollbarLayerIfNeeded(m_overflowControlsAncestorClippingLayer, needsOverflowAncestorClipLayer, CompositingReasonLayerForOverflowControlsHost);
if (ScrollingCoordinator* scrollingCoordinator = scrollingCoordinatorFromLayer(m_owningLayer)) {
if (horizontalScrollbarLayerChanged)
@@ -1359,11 +1366,10 @@ bool CompositedLayerMapping::updateOverflowControlsLayers(bool needsHorizontalSc
void CompositedLayerMapping::positionOverflowControlsLayers()
{
- IntSize offsetFromLayoutObject = m_graphicsLayer->offsetFromLayoutObject() - roundedIntSize(m_owningLayer.subpixelAccumulation());
if (GraphicsLayer* layer = layerForHorizontalScrollbar()) {
Scrollbar* hBar = m_owningLayer.scrollableArea()->horizontalScrollbar();
if (hBar) {
- layer->setPosition(hBar->frameRect().location() - offsetFromLayoutObject);
chrishtr 2015/11/19 17:29:52 subpixelAccumulation was incorrectly omitted befor
skobes 2015/11/19 18:30:07 No, what I have done is to move this offset out of
+ layer->setPosition(hBar->frameRect().location());
layer->setSize(hBar->frameRect().size());
if (layer->hasContentsLayer())
layer->setContentsRect(IntRect(IntPoint(), hBar->frameRect().size()));
@@ -1374,7 +1380,7 @@ void CompositedLayerMapping::positionOverflowControlsLayers()
if (GraphicsLayer* layer = layerForVerticalScrollbar()) {
Scrollbar* vBar = m_owningLayer.scrollableArea()->verticalScrollbar();
if (vBar) {
- layer->setPosition(vBar->frameRect().location() - offsetFromLayoutObject);
+ layer->setPosition(vBar->frameRect().location());
layer->setSize(vBar->frameRect().size());
if (layer->hasContentsLayer())
layer->setContentsRect(IntRect(IntPoint(), vBar->frameRect().size()));
@@ -1384,7 +1390,7 @@ void CompositedLayerMapping::positionOverflowControlsLayers()
if (GraphicsLayer* layer = layerForScrollCorner()) {
const IntRect& scrollCornerAndResizer = m_owningLayer.scrollableArea()->scrollCornerAndResizerRect();
- layer->setPosition(FloatPoint(scrollCornerAndResizer.location() - offsetFromLayoutObject));
+ layer->setPosition(FloatPoint(scrollCornerAndResizer.location()));
layer->setSize(FloatSize(scrollCornerAndResizer.size()));
layer->setDrawsContent(!scrollCornerAndResizer.isEmpty());
}
@@ -1959,7 +1965,7 @@ bool CompositedLayerMapping::needsToReparentOverflowControls() const
GraphicsLayer* CompositedLayerMapping::detachLayerForOverflowControls(const PaintLayer& enclosingLayer)
{
- GraphicsLayer* host = m_overflowControlsClippingLayer.get();
+ GraphicsLayer* host = m_overflowControlsAncestorClippingLayer.get();
if (!host)
host = m_overflowControlsHostLayer.get();
host->removeFromParent();
@@ -1983,6 +1989,22 @@ GraphicsLayer* CompositedLayerMapping::parentForSublayers() const
return m_graphicsLayer.get();
}
+void CompositedLayerMapping::setSublayers(const GraphicsLayerVector& sublayers)
+{
+ GraphicsLayer* overflowControlsContainer = m_overflowControlsAncestorClippingLayer
+ ? m_overflowControlsAncestorClippingLayer.get()
+ : m_overflowControlsHostLayer.get();
+ GraphicsLayer* parent = parentForSublayers();
+ bool needsOverflowControlsReattached = overflowControlsContainer && overflowControlsContainer->parent() == parent;
+
+ parent->setChildren(sublayers);
+
+ // If we have scrollbars, but are not using composited scrolling, then parentForSublayers may return m_graphicsLayer.
+ // In that case, the above call to setChildren has clobbered the overflow controls host layer, so we need to reattach it.
+ if (needsOverflowControlsReattached)
+ parent->addChild(overflowControlsContainer);
+}
+
GraphicsLayer* CompositedLayerMapping::childForSuperlayers() const
{
if (m_squashingContainmentLayer)
@@ -2502,8 +2524,8 @@ String CompositedLayerMapping::debugName(const GraphicsLayer* graphicsLayer) con
name = "Scroll Corner Layer";
} else if (graphicsLayer == m_overflowControlsHostLayer.get()) {
name = "Overflow Controls Host Layer";
- } else if (graphicsLayer == m_overflowControlsClippingLayer.get()) {
- name = "Overflow Controls ClipLayer Layer";
+ } else if (graphicsLayer == m_overflowControlsAncestorClippingLayer.get()) {
+ name = "Overflow Controls Ancestor Clipping Layer";
} else if (graphicsLayer == m_scrollingLayer.get()) {
name = "Scrolling Layer";
} else if (graphicsLayer == m_scrollingContentsLayer.get()) {

Powered by Google App Engine
This is Rietveld 408576698