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

Unified Diff: Source/core/paint/BackgroundImageGeometry.cpp

Issue 1332643002: Fix fixed-background offset issue (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Local change Created 5 years, 3 months 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
« no previous file with comments | « LayoutTests/paint/overflow/fixed-background-scroll-window-expected.html ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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);
}
« no previous file with comments | « LayoutTests/paint/overflow/fixed-background-scroll-window-expected.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698