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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « Source/core/paint/BackgroundImageGeometry.h ('k') | Source/core/paint/BlockPainter.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "config.h" 5 #include "config.h"
6 #include "core/paint/BackgroundImageGeometry.h" 6 #include "core/paint/BackgroundImageGeometry.h"
7 7
8 #include "core/layout/LayoutBox.h" 8 #include "core/layout/LayoutBox.h"
9 #include "core/layout/LayoutBoxModelObject.h" 9 #include "core/layout/LayoutBoxModelObject.h"
10 #include "core/layout/LayoutView.h" 10 #include "core/layout/LayoutView.h"
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
149 m_phase.move(std::max(alignedPoint.x() - m_destRect.x(), 0), std::max(aligne dPoint.y() - m_destRect.y(), 0)); 149 m_phase.move(std::max(alignedPoint.x() - m_destRect.x(), 0), std::max(aligne dPoint.y() - m_destRect.y(), 0));
150 } 150 }
151 151
152 void BackgroundImageGeometry::clip(const IntRect& clipRect) 152 void BackgroundImageGeometry::clip(const IntRect& clipRect)
153 { 153 {
154 m_destRect.intersect(clipRect); 154 m_destRect.intersect(clipRect);
155 } 155 }
156 156
157 void BackgroundImageGeometry::calculate(const LayoutBoxModelObject& obj, const L ayoutBoxModelObject* paintContainer, 157 void BackgroundImageGeometry::calculate(const LayoutBoxModelObject& obj, const L ayoutBoxModelObject* paintContainer,
158 const GlobalPaintFlags globalPaintFlags, const FillLayer& fillLayer, const L ayoutRect& paintRect, 158 const GlobalPaintFlags globalPaintFlags, const FillLayer& fillLayer, const L ayoutRect& paintRect,
159 LayoutObject* backgroundObject) 159 const IntPoint& accumulatedScrollOffsetSincePaintContainer, LayoutObject* ba ckgroundObject)
160 { 160 {
161 LayoutUnit left = 0; 161 LayoutUnit left = 0;
162 LayoutUnit top = 0; 162 LayoutUnit top = 0;
163 IntSize positioningAreaSize; 163 IntSize positioningAreaSize;
164 IntRect snappedPaintRect = pixelSnappedIntRect(paintRect); 164 IntRect snappedPaintRect = pixelSnappedIntRect(paintRect);
165 bool isLayoutView = obj.isLayoutView(); 165 bool isLayoutView = obj.isLayoutView();
166 const LayoutBox* rootBox = nullptr; 166 const LayoutBox* rootBox = nullptr;
167 if (isLayoutView) { 167 if (isLayoutView) {
168 // It is only possible reach here when root element has a box. 168 // It is only possible reach here when root element has a box.
169 Element* documentElement = obj.document().documentElement(); 169 Element* documentElement = obj.document().documentElement();
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
216 // Since left/top is relative to the paint rect, we need to offset t hem back. 216 // Since left/top is relative to the paint rect, we need to offset t hem back.
217 left -= paintRect.x(); 217 left -= paintRect.x();
218 top -= paintRect.y(); 218 top -= paintRect.y();
219 } else { 219 } else {
220 positioningAreaSize = pixelSnappedIntSize(paintRect.size() - LayoutS ize(left + right, top + bottom), paintRect.location()); 220 positioningAreaSize = pixelSnappedIntSize(paintRect.size() - LayoutS ize(left + right, top + bottom), paintRect.location());
221 } 221 }
222 } else { 222 } else {
223 setHasNonLocalGeometry(); 223 setHasNonLocalGeometry();
224 224
225 IntRect viewportRect = pixelSnappedIntRect(obj.viewRect()); 225 IntRect viewportRect = pixelSnappedIntRect(obj.viewRect());
226 if (fixedBackgroundPaintsInLocalCoordinates(obj, globalPaintFlags)) 226 if (fixedBackgroundPaintsInLocalCoordinates(obj, globalPaintFlags)) {
227 viewportRect.setLocation(IntPoint()); 227 viewportRect.setLocation(IntPoint());
228 else if (FrameView* frameView = obj.view()->frameView()) 228 } else {
229 viewportRect.setLocation(frameView->scrollPosition()); 229 if (FrameView* frameView = obj.view()->frameView()) {
230 viewportRect.setLocation(frameView->scrollPosition());
231 viewportRect.moveBy(accumulatedScrollOffsetSincePaintContainer);
232 }
230 233
231 if (paintContainer) { 234 if (paintContainer) {
232 IntPoint absoluteContainerOffset = roundedIntPoint(paintContainer->l ocalToAbsolute(FloatPoint())); 235 IntPoint absoluteContainerOffset = roundedIntPoint(paintContainer->l ocalToAbsolute(FloatPoint()));
chrishtr 2015/09/09 17:05:41 localToAbsolute includes scroll offsets...why isn'
Xianzhu 2015/09/09 17:09:09 It includes scroll offsets from root to the paint
chrishtr 2015/09/09 17:29:16 Oh right. How about replacing your code with mapL
Xianzhu 2015/09/09 20:40:03 This seems not to work because we only need to com
chrishtr 2015/09/09 20:48:15 Maybe just make a one-off method that accumulates
Xianzhu 2015/09/09 22:04:06 Good idea! Done.
233 viewportRect.moveBy(-absoluteContainerOffset); 236 viewportRect.moveBy(-absoluteContainerOffset);
234 } 237 }
235 238
236 setDestRect(viewportRect); 239 setDestRect(viewportRect);
237 positioningAreaSize = destRect().size(); 240 positioningAreaSize = destRect().size();
238 } 241 }
239 242
240 const LayoutObject* clientForBackgroundImage = backgroundObject ? background Object : &obj; 243 const LayoutObject* clientForBackgroundImage = backgroundObject ? background Object : &obj;
241 IntSize fillTileSize = calculateFillTileSize(positioningBox, fillLayer, posi tioningAreaSize); 244 IntSize fillTileSize = calculateFillTileSize(positioningBox, fillLayer, posi tioningAreaSize);
242 fillLayer.image()->setContainerSizeForLayoutObject(clientForBackgroundImage, fillTileSize, obj.style()->effectiveZoom()); 245 fillLayer.image()->setContainerSizeForLayoutObject(clientForBackgroundImage, fillTileSize, obj.style()->effectiveZoom());
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
325 setSpaceSize(IntSize(spaceSize().width(), 0)); 328 setSpaceSize(IntSize(spaceSize().width(), 0));
326 } 329 }
327 330
328 if (fixedAttachment) 331 if (fixedAttachment)
329 useFixedAttachment(snappedPaintRect.location()); 332 useFixedAttachment(snappedPaintRect.location());
330 333
331 clip(snappedPaintRect); 334 clip(snappedPaintRect);
332 } 335 }
333 336
334 } // namespace blink 337 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/paint/BackgroundImageGeometry.h ('k') | Source/core/paint/BlockPainter.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698