| 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 336 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 347 EFillRepeat backgroundRepeatY = fillLayer.repeatY(); | 347 EFillRepeat backgroundRepeatY = fillLayer.repeatY(); |
| 348 LayoutUnit unsnappedAvailableWidth = positioningAreaSize.width() - fillTileS
ize.width(); | 348 LayoutUnit unsnappedAvailableWidth = positioningAreaSize.width() - fillTileS
ize.width(); |
| 349 LayoutUnit unsnappedAvailableHeight = positioningAreaSize.height() - fillTil
eSize.height(); | 349 LayoutUnit unsnappedAvailableHeight = positioningAreaSize.height() - fillTil
eSize.height(); |
| 350 positioningAreaSize = LayoutSize(snapSizeToPixel(positioningAreaSize.width()
, m_destRect.x()), snapSizeToPixel(positioningAreaSize.height(), m_destRect.y())
); | 350 positioningAreaSize = LayoutSize(snapSizeToPixel(positioningAreaSize.width()
, m_destRect.x()), snapSizeToPixel(positioningAreaSize.height(), m_destRect.y())
); |
| 351 LayoutUnit availableWidth = positioningAreaSize.width() - tileSize().width()
; | 351 LayoutUnit availableWidth = positioningAreaSize.width() - tileSize().width()
; |
| 352 LayoutUnit availableHeight = positioningAreaSize.height() - tileSize().heigh
t(); | 352 LayoutUnit availableHeight = positioningAreaSize.height() - tileSize().heigh
t(); |
| 353 | 353 |
| 354 LayoutUnit computedXPosition = roundedMinimumValueForLength(fillLayer.xPosit
ion(), availableWidth); | 354 LayoutUnit computedXPosition = roundedMinimumValueForLength(fillLayer.xPosit
ion(), availableWidth); |
| 355 if (backgroundRepeatX == RoundFill && positioningAreaSize.width() > LayoutUn
it() && fillTileSize.width() > LayoutUnit()) { | 355 if (backgroundRepeatX == RoundFill && positioningAreaSize.width() > LayoutUn
it() && fillTileSize.width() > LayoutUnit()) { |
| 356 int nrTiles = std::max(1, roundToInt(positioningAreaSize.width() / fillT
ileSize.width())); | 356 int nrTiles = std::max(1, roundToInt(positioningAreaSize.width() / fillT
ileSize.width())); |
| 357 | 357 LayoutUnit roundedWidth = positioningAreaSize.width() / nrTiles; |
| 358 fillTileSize.setWidth(positioningAreaSize.width() / nrTiles); | |
| 359 | 358 |
| 360 // Maintain aspect ratio if background-size: auto is set | 359 // Maintain aspect ratio if background-size: auto is set |
| 361 if (fillLayer.size().size.height().isAuto() && backgroundRepeatY != Roun
dFill) { | 360 if (fillLayer.size().size.height().isAuto() && backgroundRepeatY != Roun
dFill) { |
| 362 fillTileSize.setHeight(fillTileSize.height() * positioningAreaSize.w
idth() / (nrTiles * fillTileSize.width())); | 361 fillTileSize.setHeight(fillTileSize.height() * roundedWidth / fillTi
leSize.width()); |
| 363 } | 362 } |
| 363 fillTileSize.setWidth(roundedWidth); |
| 364 |
| 364 setTileSize(applySubPixelHeuristicToImageSize(fillTileSize, m_destRect))
; | 365 setTileSize(applySubPixelHeuristicToImageSize(fillTileSize, m_destRect))
; |
| 365 setPhaseX(tileSize().width() | 366 setPhaseX(tileSize().width() |
| 366 ? LayoutUnit(roundf(tileSize().width() - fmodf((computedXPosition +
left), tileSize().width()))) | 367 ? LayoutUnit(roundf(tileSize().width() - fmodf((computedXPosition +
left), tileSize().width()))) |
| 367 : LayoutUnit()); | 368 : LayoutUnit()); |
| 368 setSpaceSize(LayoutSize()); | 369 setSpaceSize(LayoutSize()); |
| 369 } | 370 } |
| 370 | 371 |
| 371 LayoutUnit computedYPosition = roundedMinimumValueForLength(fillLayer.yPosit
ion(), availableHeight); | 372 LayoutUnit computedYPosition = roundedMinimumValueForLength(fillLayer.yPosit
ion(), availableHeight); |
| 372 if (backgroundRepeatY == RoundFill && positioningAreaSize.height() > LayoutU
nit() && fillTileSize.height() > LayoutUnit()) { | 373 if (backgroundRepeatY == RoundFill && positioningAreaSize.height() > LayoutU
nit() && fillTileSize.height() > LayoutUnit()) { |
| 373 int nrTiles = std::max(1, roundToInt(positioningAreaSize.height() / fill
TileSize.height())); | 374 int nrTiles = std::max(1, roundToInt(positioningAreaSize.height() / fill
TileSize.height())); |
| 374 | 375 LayoutUnit roundedHeight = positioningAreaSize.height() / nrTiles; |
| 375 fillTileSize.setHeight(positioningAreaSize.height() / nrTiles); | |
| 376 | |
| 377 // Maintain aspect ratio if background-size: auto is set | 376 // Maintain aspect ratio if background-size: auto is set |
| 378 if (fillLayer.size().size.width().isAuto() && backgroundRepeatX != Round
Fill) { | 377 if (fillLayer.size().size.width().isAuto() && backgroundRepeatX != Round
Fill) { |
| 379 fillTileSize.setWidth(fillTileSize.width() * positioningAreaSize.hei
ght() / (nrTiles * fillTileSize.height())); | 378 fillTileSize.setWidth(fillTileSize.width() * roundedHeight / fillTil
eSize.height()); |
| 380 } | 379 } |
| 380 fillTileSize.setHeight(roundedHeight); |
| 381 |
| 381 setTileSize(applySubPixelHeuristicToImageSize(fillTileSize, m_destRect))
; | 382 setTileSize(applySubPixelHeuristicToImageSize(fillTileSize, m_destRect))
; |
| 382 setPhaseY(tileSize().height() | 383 setPhaseY(tileSize().height() |
| 383 ? LayoutUnit(roundf(tileSize().height() - fmodf((computedYPosition +
top), tileSize().height()))) | 384 ? LayoutUnit(roundf(tileSize().height() - fmodf((computedYPosition +
top), tileSize().height()))) |
| 384 : LayoutUnit()); | 385 : LayoutUnit()); |
| 385 setSpaceSize(LayoutSize()); | 386 setSpaceSize(LayoutSize()); |
| 386 } | 387 } |
| 387 | 388 |
| 388 if (backgroundRepeatX == RepeatFill) { | 389 if (backgroundRepeatX == RepeatFill) { |
| 389 setRepeatX(fillLayer, fillTileSize.width(), availableWidth, unsnappedAva
ilableWidth, left); | 390 setRepeatX(fillLayer, fillTileSize.width(), availableWidth, unsnappedAva
ilableWidth, left); |
| 390 } else if (backgroundRepeatX == SpaceFill && tileSize().width() > LayoutUnit
()) { | 391 } else if (backgroundRepeatX == SpaceFill && tileSize().width() > LayoutUnit
()) { |
| (...skipping 28 matching lines...) Expand all Loading... |
| 419 // Clip the final output rect to the paint rect | 420 // Clip the final output rect to the paint rect |
| 420 m_destRect.intersect(paintRect); | 421 m_destRect.intersect(paintRect); |
| 421 | 422 |
| 422 // Snap as-yet unsnapped values. | 423 // Snap as-yet unsnapped values. |
| 423 DCHECK(m_phase == LayoutPoint(roundedIntPoint(m_phase))); | 424 DCHECK(m_phase == LayoutPoint(roundedIntPoint(m_phase))); |
| 424 setDestRect(LayoutRect(pixelSnappedIntRect(m_destRect))); | 425 setDestRect(LayoutRect(pixelSnappedIntRect(m_destRect))); |
| 425 | 426 |
| 426 } | 427 } |
| 427 | 428 |
| 428 } // namespace blink | 429 } // namespace blink |
| OLD | NEW |