| 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/LayoutTableCell.h" | 10 #include "core/layout/LayoutTableCell.h" |
| (...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 218 LayoutUnit extraOffset, | 218 LayoutUnit extraOffset, |
| 219 LayoutUnit offsetForCell) { | 219 LayoutUnit offsetForCell) { |
| 220 // We would like to identify the phase as a fraction of the image size in the | 220 // We would like to identify the phase as a fraction of the image size in the |
| 221 // absence of snapping, then re-apply it to the snapped values. This is to | 221 // absence of snapping, then re-apply it to the snapped values. This is to |
| 222 // handle large positions. | 222 // handle large positions. |
| 223 if (unsnappedTileWidth) { | 223 if (unsnappedTileWidth) { |
| 224 LayoutUnit computedXPosition = | 224 LayoutUnit computedXPosition = |
| 225 roundedMinimumValueForLength(fillLayer.xPosition(), | 225 roundedMinimumValueForLength(fillLayer.xPosition(), |
| 226 unsnappedAvailableWidth) - | 226 unsnappedAvailableWidth) - |
| 227 offsetForCell; | 227 offsetForCell; |
| 228 float numberOfTilesInPosition; |
| 228 if (fillLayer.backgroundXOrigin() == RightEdge) { | 229 if (fillLayer.backgroundXOrigin() == RightEdge) { |
| 229 float numberOfTilesInPosition = | 230 numberOfTilesInPosition = |
| 230 (snappedAvailableWidth - computedXPosition + extraOffset).toFloat() / | 231 (snappedAvailableWidth - computedXPosition + extraOffset).toFloat() / |
| 231 unsnappedTileWidth.toFloat(); | 232 unsnappedTileWidth.toFloat(); |
| 232 float fractionalPositionWithinTile = | |
| 233 numberOfTilesInPosition - truncf(numberOfTilesInPosition); | |
| 234 setPhaseX(LayoutUnit( | |
| 235 roundf(fractionalPositionWithinTile * tileSize().width()))); | |
| 236 } else { | 233 } else { |
| 237 float numberOfTilesInPosition = | 234 numberOfTilesInPosition = (computedXPosition + extraOffset).toFloat() / |
| 238 (computedXPosition + extraOffset).toFloat() / | 235 unsnappedTileWidth.toFloat(); |
| 239 unsnappedTileWidth.toFloat(); | |
| 240 float fractionalPositionWithinTile = | |
| 241 1.0f - (numberOfTilesInPosition - truncf(numberOfTilesInPosition)); | |
| 242 setPhaseX(LayoutUnit( | |
| 243 roundf(fractionalPositionWithinTile * tileSize().width()))); | |
| 244 } | 236 } |
| 237 float fractionalPositionWithinTile = |
| 238 1.0f - (numberOfTilesInPosition - truncf(numberOfTilesInPosition)); |
| 239 setPhaseX( |
| 240 LayoutUnit(roundf(fractionalPositionWithinTile * tileSize().width()))); |
| 245 } else { | 241 } else { |
| 246 setPhaseX(LayoutUnit()); | 242 setPhaseX(LayoutUnit()); |
| 247 } | 243 } |
| 248 setSpaceSize(LayoutSize(LayoutUnit(), spaceSize().height())); | 244 setSpaceSize(LayoutSize(LayoutUnit(), spaceSize().height())); |
| 249 } | 245 } |
| 250 | 246 |
| 251 void BackgroundImageGeometry::setRepeatY(const FillLayer& fillLayer, | 247 void BackgroundImageGeometry::setRepeatY(const FillLayer& fillLayer, |
| 252 LayoutUnit unsnappedTileHeight, | 248 LayoutUnit unsnappedTileHeight, |
| 253 LayoutUnit snappedAvailableHeight, | 249 LayoutUnit snappedAvailableHeight, |
| 254 LayoutUnit unsnappedAvailableHeight, | 250 LayoutUnit unsnappedAvailableHeight, |
| 255 LayoutUnit extraOffset, | 251 LayoutUnit extraOffset, |
| 256 LayoutUnit offsetForCell) { | 252 LayoutUnit offsetForCell) { |
| 257 // We would like to identify the phase as a fraction of the image size in the | 253 // We would like to identify the phase as a fraction of the image size in the |
| 258 // absence of snapping, then re-apply it to the snapped values. This is to | 254 // absence of snapping, then re-apply it to the snapped values. This is to |
| 259 // handle large positions. | 255 // handle large positions. |
| 260 if (unsnappedTileHeight) { | 256 if (unsnappedTileHeight) { |
| 261 LayoutUnit computedYPosition = | 257 LayoutUnit computedYPosition = |
| 262 roundedMinimumValueForLength(fillLayer.yPosition(), | 258 roundedMinimumValueForLength(fillLayer.yPosition(), |
| 263 unsnappedAvailableHeight) - | 259 unsnappedAvailableHeight) - |
| 264 offsetForCell; | 260 offsetForCell; |
| 261 float numberOfTilesInPosition; |
| 265 if (fillLayer.backgroundYOrigin() == BottomEdge) { | 262 if (fillLayer.backgroundYOrigin() == BottomEdge) { |
| 266 float numberOfTilesInPosition = | 263 numberOfTilesInPosition = |
| 267 (snappedAvailableHeight - computedYPosition + extraOffset).toFloat() / | 264 (snappedAvailableHeight - computedYPosition + extraOffset).toFloat() / |
| 268 unsnappedTileHeight.toFloat(); | 265 unsnappedTileHeight.toFloat(); |
| 269 float fractionalPositionWithinTile = | |
| 270 numberOfTilesInPosition - truncf(numberOfTilesInPosition); | |
| 271 setPhaseY(LayoutUnit( | |
| 272 roundf(fractionalPositionWithinTile * tileSize().height()))); | |
| 273 } else { | 266 } else { |
| 274 float numberOfTilesInPosition = | 267 numberOfTilesInPosition = (computedYPosition + extraOffset).toFloat() / |
| 275 (computedYPosition + extraOffset).toFloat() / | 268 unsnappedTileHeight.toFloat(); |
| 276 unsnappedTileHeight.toFloat(); | |
| 277 float fractionalPositionWithinTile = | |
| 278 1.0f - (numberOfTilesInPosition - truncf(numberOfTilesInPosition)); | |
| 279 setPhaseY(LayoutUnit( | |
| 280 roundf(fractionalPositionWithinTile * tileSize().height()))); | |
| 281 } | 269 } |
| 270 float fractionalPositionWithinTile = |
| 271 1.0f - (numberOfTilesInPosition - truncf(numberOfTilesInPosition)); |
| 272 setPhaseY( |
| 273 LayoutUnit(roundf(fractionalPositionWithinTile * tileSize().height()))); |
| 282 } else { | 274 } else { |
| 283 setPhaseY(LayoutUnit()); | 275 setPhaseY(LayoutUnit()); |
| 284 } | 276 } |
| 285 setSpaceSize(LayoutSize(spaceSize().width(), LayoutUnit())); | 277 setSpaceSize(LayoutSize(spaceSize().width(), LayoutUnit())); |
| 286 } | 278 } |
| 287 | 279 |
| 288 void BackgroundImageGeometry::setSpaceX(LayoutUnit space, | 280 void BackgroundImageGeometry::setSpaceX(LayoutUnit space, |
| 289 LayoutUnit availableWidth, | 281 LayoutUnit availableWidth, |
| 290 LayoutUnit extraOffset) { | 282 LayoutUnit extraOffset) { |
| 291 LayoutUnit computedXPosition = | 283 LayoutUnit computedXPosition = |
| (...skipping 347 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 639 useFixedAttachment(paintRect.location()); | 631 useFixedAttachment(paintRect.location()); |
| 640 | 632 |
| 641 // Clip the final output rect to the paint rect | 633 // Clip the final output rect to the paint rect |
| 642 m_destRect.intersect(paintRect); | 634 m_destRect.intersect(paintRect); |
| 643 | 635 |
| 644 // Snap as-yet unsnapped values. | 636 // Snap as-yet unsnapped values. |
| 645 setDestRect(LayoutRect(pixelSnappedIntRect(m_destRect))); | 637 setDestRect(LayoutRect(pixelSnappedIntRect(m_destRect))); |
| 646 } | 638 } |
| 647 | 639 |
| 648 } // namespace blink | 640 } // namespace blink |
| OLD | NEW |