Chromium Code Reviews| 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 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.
| |
| 247 } | |
| 230 | 248 |
| 231 if (paintContainer) { | 249 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
| |
| 232 IntPoint absoluteContainerOffset = roundedIntPoint(paintContainer->l ocalToAbsolute(FloatPoint())); | 250 IntPoint absoluteContainerOffset = roundedIntPoint(paintContainer->l ocalToAbsolute(FloatPoint())); |
| 233 viewportRect.moveBy(-absoluteContainerOffset); | 251 viewportRect.moveBy(-absoluteContainerOffset); |
| 234 } | 252 } |
| 235 | 253 |
| 236 setDestRect(viewportRect); | 254 setDestRect(viewportRect); |
| 237 positioningAreaSize = destRect().size(); | 255 positioningAreaSize = destRect().size(); |
| 238 } | 256 } |
| 239 | 257 |
| 240 const LayoutObject* clientForBackgroundImage = backgroundObject ? background Object : &obj; | 258 const LayoutObject* clientForBackgroundImage = backgroundObject ? background Object : &obj; |
| 241 IntSize fillTileSize = calculateFillTileSize(positioningBox, fillLayer, posi tioningAreaSize); | 259 IntSize fillTileSize = calculateFillTileSize(positioningBox, fillLayer, posi tioningAreaSize); |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 325 setSpaceSize(IntSize(spaceSize().width(), 0)); | 343 setSpaceSize(IntSize(spaceSize().width(), 0)); |
| 326 } | 344 } |
| 327 | 345 |
| 328 if (fixedAttachment) | 346 if (fixedAttachment) |
| 329 useFixedAttachment(snappedPaintRect.location()); | 347 useFixedAttachment(snappedPaintRect.location()); |
| 330 | 348 |
| 331 clip(snappedPaintRect); | 349 clip(snappedPaintRect); |
| 332 } | 350 } |
| 333 | 351 |
| 334 } // namespace blink | 352 } // namespace blink |
| OLD | NEW |