| 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 502 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 513 | 513 |
| 514 setDestRect(viewportRect); | 514 setDestRect(viewportRect); |
| 515 positioningArea = viewportRect; | 515 positioningArea = viewportRect; |
| 516 } | 516 } |
| 517 | 517 |
| 518 LayoutSize fillTileSize( | 518 LayoutSize fillTileSize( |
| 519 calculateFillTileSize(positioningBox, fillLayer, positioningArea.size())); | 519 calculateFillTileSize(positioningBox, fillLayer, positioningArea.size())); |
| 520 // It's necessary to apply the heuristic here prior to any further | 520 // It's necessary to apply the heuristic here prior to any further |
| 521 // calculations to avoid incorrectly using sub-pixel values that won't be | 521 // calculations to avoid incorrectly using sub-pixel values that won't be |
| 522 // present in the painted tile. | 522 // present in the painted tile. |
| 523 setTileSize(applySubPixelHeuristicToImageSize(fillTileSize, m_destRect)); | 523 setTileSize(applySubPixelHeuristicToImageSize(fillTileSize, positioningArea)); |
| 524 | 524 |
| 525 EFillRepeat backgroundRepeatX = fillLayer.repeatX(); | 525 EFillRepeat backgroundRepeatX = fillLayer.repeatX(); |
| 526 EFillRepeat backgroundRepeatY = fillLayer.repeatY(); | 526 EFillRepeat backgroundRepeatY = fillLayer.repeatY(); |
| 527 LayoutUnit unsnappedAvailableWidth = | 527 LayoutUnit unsnappedAvailableWidth = |
| 528 positioningArea.width() - fillTileSize.width(); | 528 positioningArea.width() - fillTileSize.width(); |
| 529 LayoutUnit unsnappedAvailableHeight = | 529 LayoutUnit unsnappedAvailableHeight = |
| 530 positioningArea.height() - fillTileSize.height(); | 530 positioningArea.height() - fillTileSize.height(); |
| 531 LayoutSize positioningAreaSize = | 531 LayoutSize positioningAreaSize = |
| 532 LayoutSize(snapSizeToPixel(positioningArea.width(), m_destRect.x()), | 532 LayoutSize(snapSizeToPixel(positioningArea.width(), m_destRect.x()), |
| 533 snapSizeToPixel(positioningArea.height(), m_destRect.y())); | 533 snapSizeToPixel(positioningArea.height(), m_destRect.y())); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 546 LayoutUnit roundedWidth = positioningAreaSize.width() / nrTiles; | 546 LayoutUnit roundedWidth = positioningAreaSize.width() / nrTiles; |
| 547 | 547 |
| 548 // Maintain aspect ratio if background-size: auto is set | 548 // Maintain aspect ratio if background-size: auto is set |
| 549 if (fillLayer.size().size.height().isAuto() && | 549 if (fillLayer.size().size.height().isAuto() && |
| 550 backgroundRepeatY != RoundFill) { | 550 backgroundRepeatY != RoundFill) { |
| 551 fillTileSize.setHeight(fillTileSize.height() * roundedWidth / | 551 fillTileSize.setHeight(fillTileSize.height() * roundedWidth / |
| 552 fillTileSize.width()); | 552 fillTileSize.width()); |
| 553 } | 553 } |
| 554 fillTileSize.setWidth(roundedWidth); | 554 fillTileSize.setWidth(roundedWidth); |
| 555 | 555 |
| 556 setTileSize(applySubPixelHeuristicToImageSize(fillTileSize, m_destRect)); | 556 setTileSize( |
| 557 applySubPixelHeuristicToImageSize(fillTileSize, positioningArea)); |
| 557 setPhaseX(tileSize().width() | 558 setPhaseX(tileSize().width() |
| 558 ? LayoutUnit(roundf( | 559 ? LayoutUnit(roundf( |
| 559 tileSize().width() - | 560 tileSize().width() - |
| 560 fmodf((computedXPosition + left), tileSize().width()))) | 561 fmodf((computedXPosition + left), tileSize().width()))) |
| 561 : LayoutUnit()); | 562 : LayoutUnit()); |
| 562 setSpaceSize(LayoutSize()); | 563 setSpaceSize(LayoutSize()); |
| 563 } | 564 } |
| 564 | 565 |
| 565 LayoutUnit computedYPosition = | 566 LayoutUnit computedYPosition = |
| 566 roundedMinimumValueForLength(fillLayer.yPosition(), availableHeight) - | 567 roundedMinimumValueForLength(fillLayer.yPosition(), availableHeight) - |
| 567 offsetInBackground.y(); | 568 offsetInBackground.y(); |
| 568 if (backgroundRepeatY == RoundFill && | 569 if (backgroundRepeatY == RoundFill && |
| 569 positioningAreaSize.height() > LayoutUnit() && | 570 positioningAreaSize.height() > LayoutUnit() && |
| 570 fillTileSize.height() > LayoutUnit()) { | 571 fillTileSize.height() > LayoutUnit()) { |
| 571 int nrTiles = std::max( | 572 int nrTiles = std::max( |
| 572 1, roundToInt(positioningAreaSize.height() / fillTileSize.height())); | 573 1, roundToInt(positioningAreaSize.height() / fillTileSize.height())); |
| 573 LayoutUnit roundedHeight = positioningAreaSize.height() / nrTiles; | 574 LayoutUnit roundedHeight = positioningAreaSize.height() / nrTiles; |
| 574 // Maintain aspect ratio if background-size: auto is set | 575 // Maintain aspect ratio if background-size: auto is set |
| 575 if (fillLayer.size().size.width().isAuto() && | 576 if (fillLayer.size().size.width().isAuto() && |
| 576 backgroundRepeatX != RoundFill) { | 577 backgroundRepeatX != RoundFill) { |
| 577 fillTileSize.setWidth(fillTileSize.width() * roundedHeight / | 578 fillTileSize.setWidth(fillTileSize.width() * roundedHeight / |
| 578 fillTileSize.height()); | 579 fillTileSize.height()); |
| 579 } | 580 } |
| 580 fillTileSize.setHeight(roundedHeight); | 581 fillTileSize.setHeight(roundedHeight); |
| 581 | 582 |
| 582 setTileSize(applySubPixelHeuristicToImageSize(fillTileSize, m_destRect)); | 583 setTileSize( |
| 584 applySubPixelHeuristicToImageSize(fillTileSize, positioningArea)); |
| 583 setPhaseY(tileSize().height() | 585 setPhaseY(tileSize().height() |
| 584 ? LayoutUnit(roundf( | 586 ? LayoutUnit(roundf( |
| 585 tileSize().height() - | 587 tileSize().height() - |
| 586 fmodf((computedYPosition + top), tileSize().height()))) | 588 fmodf((computedYPosition + top), tileSize().height()))) |
| 587 : LayoutUnit()); | 589 : LayoutUnit()); |
| 588 setSpaceSize(LayoutSize()); | 590 setSpaceSize(LayoutSize()); |
| 589 } | 591 } |
| 590 | 592 |
| 591 if (backgroundRepeatX == RepeatFill) { | 593 if (backgroundRepeatX == RepeatFill) { |
| 592 setRepeatX(fillLayer, fillTileSize.width(), availableWidth, | 594 setRepeatX(fillLayer, fillTileSize.width(), availableWidth, |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 634 useFixedAttachment(paintRect.location()); | 636 useFixedAttachment(paintRect.location()); |
| 635 | 637 |
| 636 // Clip the final output rect to the paint rect | 638 // Clip the final output rect to the paint rect |
| 637 m_destRect.intersect(paintRect); | 639 m_destRect.intersect(paintRect); |
| 638 | 640 |
| 639 // Snap as-yet unsnapped values. | 641 // Snap as-yet unsnapped values. |
| 640 setDestRect(LayoutRect(pixelSnappedIntRect(m_destRect))); | 642 setDestRect(LayoutRect(pixelSnappedIntRect(m_destRect))); |
| 641 } | 643 } |
| 642 | 644 |
| 643 } // namespace blink | 645 } // namespace blink |
| OLD | NEW |