OLD | NEW |
---|---|
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 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
120 ? static_cast<float>(positioningAreaSize.height()) / imageIntrinsicS ize.height() : 1; | 120 ? static_cast<float>(positioningAreaSize.height()) / imageIntrinsicS ize.height() : 1; |
121 float scaleFactor = type == Contain ? std::min(horizontalScaleFactor, ve rticalScaleFactor) : std::max(horizontalScaleFactor, verticalScaleFactor); | 121 float scaleFactor = type == Contain ? std::min(horizontalScaleFactor, ve rticalScaleFactor) : std::max(horizontalScaleFactor, verticalScaleFactor); |
122 return IntSize(std::max(1l, lround(imageIntrinsicSize.width() * scaleFac tor)), std::max(1l, lround(imageIntrinsicSize.height() * scaleFactor))); | 122 return IntSize(std::max(1l, lround(imageIntrinsicSize.width() * scaleFac tor)), std::max(1l, lround(imageIntrinsicSize.height() * scaleFactor))); |
123 } | 123 } |
124 } | 124 } |
125 | 125 |
126 ASSERT_NOT_REACHED(); | 126 ASSERT_NOT_REACHED(); |
127 return IntSize(); | 127 return IntSize(); |
128 } | 128 } |
129 | 129 |
130 IntPoint accumulatedScrollOffset(const LayoutBoxModelObject& object, const Layou tBoxModelObject* container) | |
131 { | |
132 const LayoutBlock* block = object.isLayoutBlock() ? toLayoutBlock(&object) : object.containingBlock(); | |
133 IntPoint result; | |
134 while (block) { | |
135 if (block->hasOverflowClip()) | |
136 result += block->scrolledContentOffset(); | |
137 if (block == container) | |
138 break; | |
139 block = block->containingBlock(); | |
140 } | |
141 return result; | |
142 } | |
143 | |
130 } // anonymous namespace | 144 } // anonymous namespace |
131 | 145 |
132 void BackgroundImageGeometry::setNoRepeatX(int xOffset) | 146 void BackgroundImageGeometry::setNoRepeatX(int xOffset) |
133 { | 147 { |
134 m_destRect.move(std::max(xOffset, 0), 0); | 148 m_destRect.move(std::max(xOffset, 0), 0); |
135 m_phase.setX(-std::min(xOffset, 0)); | 149 m_phase.setX(-std::min(xOffset, 0)); |
136 m_destRect.setWidth(m_tileSize.width() + std::min(xOffset, 0)); | 150 m_destRect.setWidth(m_tileSize.width() + std::min(xOffset, 0)); |
137 } | 151 } |
138 | 152 |
139 void BackgroundImageGeometry::setNoRepeatY(int yOffset) | 153 void BackgroundImageGeometry::setNoRepeatY(int yOffset) |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
216 // Since left/top is relative to the paint rect, we need to offset t hem back. | 230 // Since left/top is relative to the paint rect, we need to offset t hem back. |
217 left -= paintRect.x(); | 231 left -= paintRect.x(); |
218 top -= paintRect.y(); | 232 top -= paintRect.y(); |
219 } else { | 233 } else { |
220 positioningAreaSize = pixelSnappedIntSize(paintRect.size() - LayoutS ize(left + right, top + bottom), paintRect.location()); | 234 positioningAreaSize = pixelSnappedIntSize(paintRect.size() - LayoutS ize(left + right, top + bottom), paintRect.location()); |
221 } | 235 } |
222 } else { | 236 } else { |
223 setHasNonLocalGeometry(); | 237 setHasNonLocalGeometry(); |
224 | 238 |
225 IntRect viewportRect = pixelSnappedIntRect(obj.viewRect()); | 239 IntRect viewportRect = pixelSnappedIntRect(obj.viewRect()); |
226 if (fixedBackgroundPaintsInLocalCoordinates(obj, globalPaintFlags)) | 240 if (fixedBackgroundPaintsInLocalCoordinates(obj, globalPaintFlags)) { |
227 viewportRect.setLocation(IntPoint()); | 241 viewportRect.setLocation(IntPoint()); |
228 else if (FrameView* frameView = obj.view()->frameView()) | 242 } else { |
229 viewportRect.setLocation(frameView->scrollPosition()); | 243 if (FrameView* frameView = obj.view()->frameView()) |
244 viewportRect.setLocation(frameView->scrollPosition()); | |
245 // Compensate the translations created by ScrollRecorders. | |
246 // 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.
| |
247 viewportRect.moveBy(accumulatedScrollOffset(obj, paintContainer)); | |
248 } | |
230 | 249 |
231 if (paintContainer) { | 250 if (paintContainer) { |
232 IntPoint absoluteContainerOffset = roundedIntPoint(paintContainer->l ocalToAbsolute(FloatPoint())); | 251 IntPoint absoluteContainerOffset = roundedIntPoint(paintContainer->l ocalToAbsolute(FloatPoint())); |
233 viewportRect.moveBy(-absoluteContainerOffset); | 252 viewportRect.moveBy(-absoluteContainerOffset); |
234 } | 253 } |
235 | 254 |
236 setDestRect(viewportRect); | 255 setDestRect(viewportRect); |
237 positioningAreaSize = destRect().size(); | 256 positioningAreaSize = destRect().size(); |
238 } | 257 } |
239 | 258 |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
325 setSpaceSize(IntSize(spaceSize().width(), 0)); | 344 setSpaceSize(IntSize(spaceSize().width(), 0)); |
326 } | 345 } |
327 | 346 |
328 if (fixedAttachment) | 347 if (fixedAttachment) |
329 useFixedAttachment(snappedPaintRect.location()); | 348 useFixedAttachment(snappedPaintRect.location()); |
330 | 349 |
331 clip(snappedPaintRect); | 350 clip(snappedPaintRect); |
332 } | 351 } |
333 | 352 |
334 } // namespace blink | 353 } // namespace blink |
OLD | NEW |