Chromium Code Reviews| Index: Source/core/paint/DeprecatedPaintLayer.cpp |
| diff --git a/Source/core/paint/DeprecatedPaintLayer.cpp b/Source/core/paint/DeprecatedPaintLayer.cpp |
| index 7efcb1de19bc2510a2d8fdf498145e7b3b390274..cdb0de9b19bf351c5cfa08af8b3a26c41059cd1b 100644 |
| --- a/Source/core/paint/DeprecatedPaintLayer.cpp |
| +++ b/Source/core/paint/DeprecatedPaintLayer.cpp |
| @@ -700,6 +700,19 @@ bool DeprecatedPaintLayer::update3DTransformedDescendantStatus() |
| return has3DTransform(); |
| } |
| +LayoutPoint DeprecatedPaintLayer::locationSansOverflowScroll() const |
| +{ |
| + // Our m_location already has scroll offset baked-in. We have to revert it here. |
| + IntSize scrollOffset; |
| + if (DeprecatedPaintLayer* positionedParent = layoutObject()->isOutOfFlowPositioned() ? enclosingPositionedAncestor() : nullptr) { |
| + if (positionedParent->layoutObject()->hasOverflowClip()) |
| + scrollOffset = positionedParent->layoutBox()->scrolledContentOffset(); |
| + } else if (parent() && parent()->layoutObject()->hasOverflowClip()) { |
| + scrollOffset = parent()->layoutBox()->scrolledContentOffset(); |
| + } |
| + return location() + LayoutSize(scrollOffset); |
|
pdr.
2015/08/25 20:47:55
Shouldn't this be subtraction?
trchen
2015/08/26 07:39:04
A layer moves up (subtraction) when it scrolls, so
|
| +} |
| + |
| bool DeprecatedPaintLayer::updateLayerPosition() |
| { |
| LayoutPoint localPoint; |
| @@ -1292,6 +1305,67 @@ void DeprecatedPaintLayer::convertToLayerCoords(const DeprecatedPaintLayer* ance |
| currLayer = accumulateOffsetTowardsAncestor(currLayer, ancestorLayer, location); |
| } |
| +// TODO(trchen): Deduplicate. |
| +static inline const DeprecatedPaintLayer* accumulateOffsetTowardsAncestorSansOverflowScroll(const DeprecatedPaintLayer* layer, const DeprecatedPaintLayer* ancestorLayer, LayoutPoint& location) |
| +{ |
| + ASSERT(ancestorLayer != layer); |
| + |
| + const LayoutBoxModelObject* layoutObject = layer->layoutObject(); |
| + EPosition position = layoutObject->style()->position(); |
| + |
| + if (position == FixedPosition && (!ancestorLayer || ancestorLayer == layoutObject->view()->layer())) { |
| + // If the fixed layer's container is the root, just add in the offset of the view. We can obtain this by calling |
| + // localToAbsolute() on the LayoutView. |
| + FloatPoint absPos = layoutObject->localToAbsolute(FloatPoint(), IsFixed); |
| + location += LayoutSize(absPos.x(), absPos.y()); |
| + return ancestorLayer; |
| + } |
| + |
| + DeprecatedPaintLayer* parentLayer; |
| + if (position == AbsolutePosition || position == FixedPosition) { |
| + bool foundAncestorFirst; |
| + parentLayer = layer->enclosingPositionedAncestor(ancestorLayer, &foundAncestorFirst); |
| + |
| + if (foundAncestorFirst) { |
| + // Found ancestorLayer before the container of the out-of-flow object, so compute offset |
| + // of both relative to the container and subtract. |
| + |
| + LayoutPoint thisCoords; |
| + layer->convertToLayerCoordsSansOverflowScroll(parentLayer, thisCoords); |
| + |
| + LayoutPoint ancestorCoords; |
| + ancestorLayer->convertToLayerCoordsSansOverflowScroll(parentLayer, ancestorCoords); |
| + |
| + location += (thisCoords - ancestorCoords); |
| + return ancestorLayer; |
| + } |
| + } else if (layoutObject->isColumnSpanAll()) { |
| + LayoutBlock* multicolContainer = layoutObject->containingBlock(); |
| + ASSERT(toLayoutBlockFlow(multicolContainer)->multiColumnFlowThread()); |
| + parentLayer = multicolContainer->layer(); |
| + ASSERT(parentLayer); |
| + } else { |
| + parentLayer = layer->parent(); |
| + } |
| + |
| + if (!parentLayer) |
| + return nullptr; |
| + |
| + location += layer->locationSansOverflowScroll(); |
| + return parentLayer; |
| +} |
| + |
| +// TODO(trchen): Deduplicate. |
| +void DeprecatedPaintLayer::convertToLayerCoordsSansOverflowScroll(const DeprecatedPaintLayer* ancestorLayer, LayoutPoint& location) const |
| +{ |
| + if (ancestorLayer == this) |
| + return; |
| + |
| + const DeprecatedPaintLayer* currLayer = this; |
| + while (currLayer && currLayer != ancestorLayer) |
| + currLayer = accumulateOffsetTowardsAncestorSansOverflowScroll(currLayer, ancestorLayer, location); |
| +} |
| + |
| void DeprecatedPaintLayer::convertToLayerCoords(const DeprecatedPaintLayer* ancestorLayer, LayoutRect& rect) const |
| { |
| LayoutPoint delta; |
| @@ -1405,7 +1479,7 @@ void DeprecatedPaintLayer::collectFragments(DeprecatedPaintLayerFragments& fragm |
| outlineRectInFlowThread, &offsetWithinPaginatedLayer); |
| // Take our bounding box within the flow thread and clip it. |
| - LayoutRect layerBoundingBoxInFlowThread = layerBoundingBox ? *layerBoundingBox : physicalBoundingBox(enclosingPaginationLayer(), &offsetWithinPaginatedLayer); |
| + LayoutRect layerBoundingBoxInFlowThread = layerBoundingBox ? *layerBoundingBox : physicalBoundingBox(nullptr, &offsetWithinPaginatedLayer); |
| layerBoundingBoxInFlowThread.intersect(backgroundRectInFlowThread.rect()); |
| // Make the dirty rect relative to the fragmentation context (multicol container, etc.). |
| @@ -2014,6 +2088,7 @@ bool DeprecatedPaintLayer::hasBlockSelectionGapBounds() const |
| bool DeprecatedPaintLayer::intersectsDamageRect(const LayoutRect& layerBounds, const LayoutRect& damageRect, const DeprecatedPaintLayer* rootLayer, const LayoutPoint* offsetFromRoot) const |
| { |
| + ASSERT(!(rootLayer && offsetFromRoot)); |
| // Always examine the canvas and the root. |
| // FIXME: Could eliminate the isDocumentElement() check if we fix background painting so that the LayoutView |
| // paints the root's background. |
| @@ -2082,6 +2157,7 @@ static inline LayoutRect flippedLogicalBoundingBox(LayoutRect boundingBox, Layou |
| LayoutRect DeprecatedPaintLayer::physicalBoundingBox(const DeprecatedPaintLayer* ancestorLayer, const LayoutPoint* offsetFromRoot) const |
| { |
| + ASSERT(!(ancestorLayer && offsetFromRoot)); |
| LayoutRect result = flippedLogicalBoundingBox(logicalBoundingBox(), layoutObject()); |
| if (offsetFromRoot) |
| result.moveBy(*offsetFromRoot); |
| @@ -2129,10 +2205,10 @@ static void expandRectForReflectionAndStackingChildren(const DeprecatedPaintLaye |
| } |
| } |
| -LayoutRect DeprecatedPaintLayer::physicalBoundingBoxIncludingReflectionAndStackingChildren(const DeprecatedPaintLayer* ancestorLayer, const LayoutPoint& offsetFromRoot) const |
| +LayoutRect DeprecatedPaintLayer::physicalBoundingBoxIncludingReflectionAndStackingChildren(const LayoutPoint& offsetFromRoot) const |
| { |
| LayoutPoint origin; |
| - LayoutRect result = physicalBoundingBox(ancestorLayer, &origin); |
| + LayoutRect result = physicalBoundingBox(nullptr, &origin); |
| const_cast<DeprecatedPaintLayer*>(this)->stackingNode()->updateLayerListsIfNeeded(); |
| @@ -2167,7 +2243,7 @@ LayoutRect DeprecatedPaintLayer::boundingBoxForCompositing(const DeprecatedPaint |
| LayoutRect result = clipper().localClipRect(); |
| if (result == LayoutRect::infiniteIntRect()) { |
| LayoutPoint origin; |
| - result = physicalBoundingBox(ancestorLayer, &origin); |
| + result = physicalBoundingBox(nullptr, &origin); |
| const_cast<DeprecatedPaintLayer*>(this)->stackingNode()->updateLayerListsIfNeeded(); |