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

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: 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..281988d135096cd04f8cc2e789beed5959571014 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,10 +237,15 @@ 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.
+ // TODO(trchen): Fix this for SP phase 2. crbug.com/528226.
chrishtr 2015/09/09 22:46:33 Wrong bug? I was thinking a tracking bug for this
Xianzhu 2015/09/09 23:39:56 Wanted to reuse the bug for phase 2. Filed crbug.
+ viewportRect.moveBy(accumulatedScrollOffset(obj, paintContainer));
+ }
if (paintContainer) {
IntPoint absoluteContainerOffset = roundedIntPoint(paintContainer->localToAbsolute(FloatPoint()));
« 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