Chromium Code Reviews| Index: Source/core/paint/BackgroundImageGeometry.cpp |
| diff --git a/Source/core/paint/BackgroundImageGeometry.cpp b/Source/core/paint/BackgroundImageGeometry.cpp |
| index d4a3bedff08bf0af15358b19fe13c291f3f5f1f4..a548ce89a4f69e9c528980a447151935ea1d6312 100644 |
| --- a/Source/core/paint/BackgroundImageGeometry.cpp |
| +++ b/Source/core/paint/BackgroundImageGeometry.cpp |
| @@ -127,6 +127,20 @@ IntSize calculateFillTileSize(const LayoutBoxModelObject& obj, const FillLayer& |
| return IntSize(); |
| } |
| +IntPoint accumulatedScrollOffset(const LayoutBoxModelObject& object, const LayoutBoxModelObject* container) |
| +{ |
| + const LayoutBlock* block = object.isLayoutBlock() ? toLayoutBlock(&object) : object.containingBlock(); |
| + IntPoint result; |
| + while (block) { |
| + if (block->hasOverflowClip()) |
| + result += block->scrolledContentOffset(); |
| + if (block == container) |
| + break; |
| + block = block->containingBlock(); |
| + } |
| + return result; |
| +} |
| + |
| } // anonymous namespace |
| void BackgroundImageGeometry::setNoRepeatX(int xOffset) |
| @@ -223,12 +237,16 @@ void BackgroundImageGeometry::calculate(const LayoutBoxModelObject& obj, const L |
| setHasNonLocalGeometry(); |
| IntRect viewportRect = pixelSnappedIntRect(obj.viewRect()); |
| - if (fixedBackgroundPaintsInLocalCoordinates(obj, globalPaintFlags)) |
| + if (fixedBackgroundPaintsInLocalCoordinates(obj, globalPaintFlags)) { |
| viewportRect.setLocation(IntPoint()); |
| - else if (FrameView* frameView = obj.view()->frameView()) |
| - viewportRect.setLocation(frameView->scrollPosition()); |
| + } else { |
| + if (FrameView* frameView = obj.view()->frameView()) |
| + viewportRect.setLocation(frameView->scrollPosition()); |
| + // Compensate the translations created by ScrollRecorders. |
| + viewportRect.moveBy(accumulatedScrollOffset(obj, paintContainer)); |
|
chrishtr
2015/09/09 22:07:05
Add a TODO(trchen) to fix this for SP phase 2, and
Xianzhu
2015/09/09 22:40:47
Done.
|
| + } |
| - if (paintContainer) { |
| + if (paintContainer && paintContainer->view() == obj.view()) { |
|
chrishtr
2015/09/09 22:07:05
Why this change?
Xianzhu
2015/09/09 22:40:47
Thought paintContainer could be in ancestor view o
|
| IntPoint absoluteContainerOffset = roundedIntPoint(paintContainer->localToAbsolute(FloatPoint())); |
| viewportRect.moveBy(-absoluteContainerOffset); |
| } |