| 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 "core/paint/BackgroundImageGeometry.h" | 5 #include "core/paint/BackgroundImageGeometry.h" |
| 6 | 6 |
| 7 #include "core/frame/FrameView.h" | 7 #include "core/frame/FrameView.h" |
| 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 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 112 ? positioningAreaSize.height().toFloat() / imageIntrinsicSize.height
() : 1; | 112 ? positioningAreaSize.height().toFloat() / imageIntrinsicSize.height
() : 1; |
| 113 float scaleFactor = type == Contain ? std::min(horizontalScaleFactor, ve
rticalScaleFactor) : std::max(horizontalScaleFactor, verticalScaleFactor); | 113 float scaleFactor = type == Contain ? std::min(horizontalScaleFactor, ve
rticalScaleFactor) : std::max(horizontalScaleFactor, verticalScaleFactor); |
| 114 return LayoutSize(std::max<LayoutUnit>(1, imageIntrinsicSize.width() * s
caleFactor), std::max<LayoutUnit>(1, imageIntrinsicSize.height() * scaleFactor))
; | 114 return LayoutSize(std::max<LayoutUnit>(1, imageIntrinsicSize.width() * s
caleFactor), std::max<LayoutUnit>(1, imageIntrinsicSize.height() * scaleFactor))
; |
| 115 } | 115 } |
| 116 } | 116 } |
| 117 | 117 |
| 118 ASSERT_NOT_REACHED(); | 118 ASSERT_NOT_REACHED(); |
| 119 return LayoutSize(); | 119 return LayoutSize(); |
| 120 } | 120 } |
| 121 | 121 |
| 122 IntPoint accumulatedScrollOffset(const LayoutBoxModelObject& object, const Layou
tBoxModelObject* container) | 122 IntPoint accumulatedScrollOffsetForFixedBackground(const LayoutBoxModelObject& o
bject, const LayoutBoxModelObject* container) |
| 123 { | 123 { |
| 124 const LayoutBlock* block = object.isLayoutBlock() ? toLayoutBlock(&object) :
object.containingBlock(); | |
| 125 IntPoint result; | 124 IntPoint result; |
| 126 while (block) { | 125 if (&object == container) |
| 126 return result; |
| 127 for (const LayoutBlock* block = object.containingBlock(); block; block = blo
ck->containingBlock()) { |
| 127 if (block->hasOverflowClip()) | 128 if (block->hasOverflowClip()) |
| 128 result += block->scrolledContentOffset(); | 129 result += block->scrolledContentOffset(); |
| 129 if (block == container) | 130 if (block == container) |
| 130 break; | 131 break; |
| 131 block = block->containingBlock(); | |
| 132 } | 132 } |
| 133 return result; | 133 return result; |
| 134 } | 134 } |
| 135 | 135 |
| 136 // When we match the sub-pixel fraction of the destination rect in a dimension,
we | 136 // When we match the sub-pixel fraction of the destination rect in a dimension,
we |
| 137 // snap the same way. This commonly occurs when the background is meant to fill
the | 137 // snap the same way. This commonly occurs when the background is meant to fill
the |
| 138 // padding box but there's a border (which in Blink is always stored as an integ
er). | 138 // padding box but there's a border (which in Blink is always stored as an integ
er). |
| 139 // Otherwise we floor to avoid growing our tile size. Often these tiles are from
a | 139 // Otherwise we floor to avoid growing our tile size. Often these tiles are from
a |
| 140 // sprite map, and bleeding adjactent sprites is visually worse than clipping th
e | 140 // sprite map, and bleeding adjactent sprites is visually worse than clipping th
e |
| 141 // intenteded one. | 141 // intenteded one. |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 250 setHasNonLocalGeometry(); | 250 setHasNonLocalGeometry(); |
| 251 | 251 |
| 252 LayoutRect viewportRect = obj.viewRect(); | 252 LayoutRect viewportRect = obj.viewRect(); |
| 253 if (fixedBackgroundPaintsInLocalCoordinates(obj, globalPaintFlags)) { | 253 if (fixedBackgroundPaintsInLocalCoordinates(obj, globalPaintFlags)) { |
| 254 viewportRect.setLocation(LayoutPoint()); | 254 viewportRect.setLocation(LayoutPoint()); |
| 255 } else { | 255 } else { |
| 256 if (FrameView* frameView = obj.view()->frameView()) | 256 if (FrameView* frameView = obj.view()->frameView()) |
| 257 viewportRect.setLocation(frameView->scrollPosition()); | 257 viewportRect.setLocation(frameView->scrollPosition()); |
| 258 // Compensate the translations created by ScrollRecorders. | 258 // Compensate the translations created by ScrollRecorders. |
| 259 // TODO(trchen): Fix this for SP phase 2. crbug.com/529963. | 259 // TODO(trchen): Fix this for SP phase 2. crbug.com/529963. |
| 260 viewportRect.moveBy(accumulatedScrollOffset(obj, paintContainer)); | 260 viewportRect.moveBy(accumulatedScrollOffsetForFixedBackground(obj, p
aintContainer)); |
| 261 } | 261 } |
| 262 | 262 |
| 263 if (paintContainer) | 263 if (paintContainer) |
| 264 viewportRect.moveBy(LayoutPoint(-paintContainer->localToAbsolute(Flo
atPoint()))); | 264 viewportRect.moveBy(LayoutPoint(-paintContainer->localToAbsolute(Flo
atPoint()))); |
| 265 | 265 |
| 266 setDestRect(viewportRect); | 266 setDestRect(viewportRect); |
| 267 positioningAreaSize = destRect().size(); | 267 positioningAreaSize = destRect().size(); |
| 268 } | 268 } |
| 269 | 269 |
| 270 LayoutSize fillTileSize(calculateFillTileSize(positioningBox, fillLayer, pos
itioningAreaSize)); | 270 LayoutSize fillTileSize(calculateFillTileSize(positioningBox, fillLayer, pos
itioningAreaSize)); |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 359 } | 359 } |
| 360 | 360 |
| 361 if (fixedAttachment) | 361 if (fixedAttachment) |
| 362 useFixedAttachment(paintRect.location()); | 362 useFixedAttachment(paintRect.location()); |
| 363 | 363 |
| 364 clip(paintRect); | 364 clip(paintRect); |
| 365 pixelSnapGeometry(); | 365 pixelSnapGeometry(); |
| 366 } | 366 } |
| 367 | 367 |
| 368 } // namespace blink | 368 } // namespace blink |
| OLD | NEW |