| 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 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 163 m_phase.move(std::max(alignedPoint.x() - m_destRect.x(), 0), std::max(aligne
dPoint.y() - m_destRect.y(), 0)); | 163 m_phase.move(std::max(alignedPoint.x() - m_destRect.x(), 0), std::max(aligne
dPoint.y() - m_destRect.y(), 0)); |
| 164 } | 164 } |
| 165 | 165 |
| 166 void BackgroundImageGeometry::clip(const IntRect& clipRect) | 166 void BackgroundImageGeometry::clip(const IntRect& clipRect) |
| 167 { | 167 { |
| 168 m_destRect.intersect(clipRect); | 168 m_destRect.intersect(clipRect); |
| 169 } | 169 } |
| 170 | 170 |
| 171 void BackgroundImageGeometry::calculate(const LayoutBoxModelObject& obj, const L
ayoutBoxModelObject* paintContainer, | 171 void BackgroundImageGeometry::calculate(const LayoutBoxModelObject& obj, const L
ayoutBoxModelObject* paintContainer, |
| 172 const GlobalPaintFlags globalPaintFlags, const FillLayer& fillLayer, const L
ayoutRect& paintRect, | 172 const GlobalPaintFlags globalPaintFlags, const FillLayer& fillLayer, const L
ayoutRect& paintRect, |
| 173 LayoutObject* backgroundObject) | 173 LayoutObject*) |
| 174 { | 174 { |
| 175 LayoutUnit left = 0; | 175 LayoutUnit left = 0; |
| 176 LayoutUnit top = 0; | 176 LayoutUnit top = 0; |
| 177 IntSize positioningAreaSize; | 177 IntSize positioningAreaSize; |
| 178 IntRect snappedPaintRect = pixelSnappedIntRect(paintRect); | 178 IntRect snappedPaintRect = pixelSnappedIntRect(paintRect); |
| 179 bool isLayoutView = obj.isLayoutView(); | 179 bool isLayoutView = obj.isLayoutView(); |
| 180 const LayoutBox* rootBox = nullptr; | 180 const LayoutBox* rootBox = nullptr; |
| 181 if (isLayoutView) { | 181 if (isLayoutView) { |
| 182 // It is only possible reach here when root element has a box. | 182 // It is only possible reach here when root element has a box. |
| 183 Element* documentElement = obj.document().documentElement(); | 183 Element* documentElement = obj.document().documentElement(); |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 249 | 249 |
| 250 if (paintContainer) { | 250 if (paintContainer) { |
| 251 IntPoint absoluteContainerOffset = roundedIntPoint(paintContainer->l
ocalToAbsolute(FloatPoint())); | 251 IntPoint absoluteContainerOffset = roundedIntPoint(paintContainer->l
ocalToAbsolute(FloatPoint())); |
| 252 viewportRect.moveBy(-absoluteContainerOffset); | 252 viewportRect.moveBy(-absoluteContainerOffset); |
| 253 } | 253 } |
| 254 | 254 |
| 255 setDestRect(viewportRect); | 255 setDestRect(viewportRect); |
| 256 positioningAreaSize = destRect().size(); | 256 positioningAreaSize = destRect().size(); |
| 257 } | 257 } |
| 258 | 258 |
| 259 const LayoutObject* clientForBackgroundImage = backgroundObject ? background
Object : &obj; | |
| 260 IntSize fillTileSize = calculateFillTileSize(positioningBox, fillLayer, posi
tioningAreaSize); | 259 IntSize fillTileSize = calculateFillTileSize(positioningBox, fillLayer, posi
tioningAreaSize); |
| 261 fillLayer.image()->setContainerSizeForLayoutObject(clientForBackgroundImage,
fillTileSize, obj.style()->effectiveZoom()); | |
| 262 setTileSize(fillTileSize); | 260 setTileSize(fillTileSize); |
| 263 | 261 |
| 264 EFillRepeat backgroundRepeatX = fillLayer.repeatX(); | 262 EFillRepeat backgroundRepeatX = fillLayer.repeatX(); |
| 265 EFillRepeat backgroundRepeatY = fillLayer.repeatY(); | 263 EFillRepeat backgroundRepeatY = fillLayer.repeatY(); |
| 266 int availableWidth = positioningAreaSize.width() - tileSize().width(); | 264 int availableWidth = positioningAreaSize.width() - tileSize().width(); |
| 267 int availableHeight = positioningAreaSize.height() - tileSize().height(); | 265 int availableHeight = positioningAreaSize.height() - tileSize().height(); |
| 268 | 266 |
| 269 LayoutUnit computedXPosition = roundedMinimumValueForLength(fillLayer.xPosit
ion(), availableWidth); | 267 LayoutUnit computedXPosition = roundedMinimumValueForLength(fillLayer.xPosit
ion(), availableWidth); |
| 270 if (backgroundRepeatX == RoundFill && positioningAreaSize.width() > 0 && fil
lTileSize.width() > 0) { | 268 if (backgroundRepeatX == RoundFill && positioningAreaSize.width() > 0 && fil
lTileSize.width() > 0) { |
| 271 long nrTiles = std::max(1l, lroundf((float)positioningAreaSize.width() /
fillTileSize.width())); | 269 long nrTiles = std::max(1l, lroundf((float)positioningAreaSize.width() /
fillTileSize.width())); |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 344 setSpaceSize(IntSize(spaceSize().width(), 0)); | 342 setSpaceSize(IntSize(spaceSize().width(), 0)); |
| 345 } | 343 } |
| 346 | 344 |
| 347 if (fixedAttachment) | 345 if (fixedAttachment) |
| 348 useFixedAttachment(snappedPaintRect.location()); | 346 useFixedAttachment(snappedPaintRect.location()); |
| 349 | 347 |
| 350 clip(snappedPaintRect); | 348 clip(snappedPaintRect); |
| 351 } | 349 } |
| 352 | 350 |
| 353 } // namespace blink | 351 } // namespace blink |
| OLD | NEW |