Changeset 166784 in webkit


Ignore:
Timestamp:
Apr 4, 2014 9:30:18 AM (10 years ago)
Author:
Alan Bujtas
Message:

Subpixel rendering: Move background images to device pixel boundaries.
https://bugs.webkit.org/show_bug.cgi?id=131144

Reviewed by Simon Fraser.

Replace integral snapping with device pixel snapping.
Background image geometry calculation uses LayoutUnits and we snap to device pixels right before painting.

Source/WebCore:

Tests: fast/backgrounds/hidpi-bitmap-background-on-subpixel-position.html

fast/backgrounds/hidpi-bitmap-background-origin-on-subpixel-position.html
fast/backgrounds/hidpi-bitmap-background-repeat-on-subpixel-position.html
fast/backgrounds/hidpi-generated-gradient-background-on-subpixel-position.html

  • platform/graphics/GraphicsLayer.h:

(WebCore::GraphicsLayer::setContentsTilePhase):
(WebCore::GraphicsLayer::contentsTilePhase):
(WebCore::GraphicsLayer::setContentsTileSize):
(WebCore::GraphicsLayer::contentsTileSize):

  • platform/graphics/texmap/TextureMapperLayer.cpp:

(WebCore::TextureMapperLayer::setContentsTileSize):
(WebCore::TextureMapperLayer::setContentsTilePhase):

  • platform/graphics/texmap/TextureMapperLayer.h:
  • platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.cpp:

(WebCore::CoordinatedGraphicsLayer::setContentsTileSize):
(WebCore::CoordinatedGraphicsLayer::setContentsTilePhase):

  • platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.h:
  • platform/graphics/texmap/coordinated/CoordinatedGraphicsState.h:
  • rendering/RenderBox.cpp:

(WebCore::RenderBox::repaintLayerRectsForImage):

  • rendering/RenderBoxModelObject.cpp:

(WebCore::RenderBoxModelObject::paintFillLayerExtended):
(WebCore::resolveWidthForRatio):
(WebCore::resolveHeightForRatio):
(WebCore::resolveAgainstIntrinsicWidthOrHeightAndRatio):
(WebCore::resolveAgainstIntrinsicRatio):
(WebCore::RenderBoxModelObject::calculateImageIntrinsicDimensions):
(WebCore::RenderBoxModelObject::calculateFillTileSize):
(WebCore::RenderBoxModelObject::BackgroundImageGeometry::setNoRepeatX):
(WebCore::RenderBoxModelObject::BackgroundImageGeometry::setNoRepeatY):
(WebCore::RenderBoxModelObject::BackgroundImageGeometry::useFixedAttachment):
(WebCore::RenderBoxModelObject::BackgroundImageGeometry::clip):
(WebCore::RenderBoxModelObject::BackgroundImageGeometry::relativePhase):
(WebCore::getSpace):
(WebCore::RenderBoxModelObject::pixelSnapBackgroundImageGeometryForPainting):
(WebCore::RenderBoxModelObject::calculateBackgroundImageGeometry):
(WebCore::RenderBoxModelObject::getGeometryForBackgroundImage):
(WebCore::RenderBoxModelObject::paintNinePieceImage):
(WebCore::applySubPixelHeuristicForTileSize): Deleted.

  • rendering/RenderBoxModelObject.h:

(WebCore::RenderBoxModelObject::BackgroundImageGeometry::destOrigin):
(WebCore::RenderBoxModelObject::BackgroundImageGeometry::setDestOrigin):
(WebCore::RenderBoxModelObject::BackgroundImageGeometry::destRect):
(WebCore::RenderBoxModelObject::BackgroundImageGeometry::setDestRect):
(WebCore::RenderBoxModelObject::BackgroundImageGeometry::phase):
(WebCore::RenderBoxModelObject::BackgroundImageGeometry::setPhase):
(WebCore::RenderBoxModelObject::BackgroundImageGeometry::tileSize):
(WebCore::RenderBoxModelObject::BackgroundImageGeometry::setTileSize):
(WebCore::RenderBoxModelObject::BackgroundImageGeometry::spaceSize):
(WebCore::RenderBoxModelObject::BackgroundImageGeometry::setSpaceSize):
(WebCore::RenderBoxModelObject::BackgroundImageGeometry::setPhaseX):
(WebCore::RenderBoxModelObject::BackgroundImageGeometry::setPhaseY):

  • rendering/RenderLayerBacking.cpp:

(WebCore::RenderLayerBacking::updateDirectlyCompositedBackgroundImage):

  • rendering/shapes/ShapeOutsideInfo.cpp:

(WebCore::getShapeImageAndRect):

LayoutTests:

  • css3/background/background-repeat-round-auto1-expected.html:
  • css3/background/background-repeat-round-auto1.html:
  • css3/background/background-repeat-round-auto2-expected.html:
  • css3/background/background-repeat-round-auto2.html:
  • css3/background/background-repeat-round-border-expected.html:
  • css3/background/background-repeat-round-border.html:
  • css3/background/background-repeat-round-content-expected.html:
  • css3/background/background-repeat-round-content.html:
  • css3/background/background-repeat-space-content-expected.html:
  • css3/background/background-repeat-space-content.html:
  • css3/background/background-repeat-space-padding-expected.html:
  • css3/background/background-repeat-space-padding.html:
  • css3/masking/mask-repeat-round-auto1-expected.html:
  • css3/masking/mask-repeat-round-auto1.html:
  • css3/masking/mask-repeat-round-auto2-expected.html:
  • css3/masking/mask-repeat-round-auto2.html:
  • css3/masking/mask-repeat-round-border-expected.html:
  • css3/masking/mask-repeat-round-border.html:
  • css3/masking/mask-repeat-round-content-expected.html:
  • css3/masking/mask-repeat-round-content.html:
  • css3/masking/mask-repeat-space-content-expected.html:
  • css3/masking/mask-repeat-space-content.html:
  • css3/masking/mask-repeat-space-padding-expected.html:
  • css3/masking/mask-repeat-space-padding.html:
  • fast/backgrounds/hidpi-bitmap-background-on-subpixel-position-expected.html: Added.
  • fast/backgrounds/hidpi-bitmap-background-on-subpixel-position.html: Added.
  • fast/backgrounds/hidpi-bitmap-background-origin-on-subpixel-position-expected.html: Added.
  • fast/backgrounds/hidpi-bitmap-background-origin-on-subpixel-position.html: Added.
  • fast/backgrounds/hidpi-bitmap-background-repeat-on-subpixel-position-expected.html: Added.
  • fast/backgrounds/hidpi-bitmap-background-repeat-on-subpixel-position.html: Added.
  • fast/backgrounds/hidpi-generated-gradient-background-on-subpixel-position-expected.html: Added.
  • fast/backgrounds/hidpi-generated-gradient-background-on-subpixel-position.html: Added.
  • fast/backgrounds/resources/black25x25.png: Added.
Location:
trunk
Files:
9 added
37 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r166781 r166784  
     12014-04-04  Zalan Bujtas  <zalan@apple.com>
     2
     3        Subpixel rendering: Move background images to device pixel boundaries.
     4        https://bugs.webkit.org/show_bug.cgi?id=131144
     5
     6        Reviewed by Simon Fraser.
     7
     8        Replace integral snapping with device pixel snapping.
     9        Background image geometry calculation uses LayoutUnits and we snap to device pixels right before painting.
     10
     11        * css3/background/background-repeat-round-auto1-expected.html:
     12        * css3/background/background-repeat-round-auto1.html:
     13        * css3/background/background-repeat-round-auto2-expected.html:
     14        * css3/background/background-repeat-round-auto2.html:
     15        * css3/background/background-repeat-round-border-expected.html:
     16        * css3/background/background-repeat-round-border.html:
     17        * css3/background/background-repeat-round-content-expected.html:
     18        * css3/background/background-repeat-round-content.html:
     19        * css3/background/background-repeat-space-content-expected.html:
     20        * css3/background/background-repeat-space-content.html:
     21        * css3/background/background-repeat-space-padding-expected.html:
     22        * css3/background/background-repeat-space-padding.html:
     23        * css3/masking/mask-repeat-round-auto1-expected.html:
     24        * css3/masking/mask-repeat-round-auto1.html:
     25        * css3/masking/mask-repeat-round-auto2-expected.html:
     26        * css3/masking/mask-repeat-round-auto2.html:
     27        * css3/masking/mask-repeat-round-border-expected.html:
     28        * css3/masking/mask-repeat-round-border.html:
     29        * css3/masking/mask-repeat-round-content-expected.html:
     30        * css3/masking/mask-repeat-round-content.html:
     31        * css3/masking/mask-repeat-space-content-expected.html:
     32        * css3/masking/mask-repeat-space-content.html:
     33        * css3/masking/mask-repeat-space-padding-expected.html:
     34        * css3/masking/mask-repeat-space-padding.html:
     35        * fast/backgrounds/hidpi-bitmap-background-on-subpixel-position-expected.html: Added.
     36        * fast/backgrounds/hidpi-bitmap-background-on-subpixel-position.html: Added.
     37        * fast/backgrounds/hidpi-bitmap-background-origin-on-subpixel-position-expected.html: Added.
     38        * fast/backgrounds/hidpi-bitmap-background-origin-on-subpixel-position.html: Added.
     39        * fast/backgrounds/hidpi-bitmap-background-repeat-on-subpixel-position-expected.html: Added.
     40        * fast/backgrounds/hidpi-bitmap-background-repeat-on-subpixel-position.html: Added.
     41        * fast/backgrounds/hidpi-generated-gradient-background-on-subpixel-position-expected.html: Added.
     42        * fast/backgrounds/hidpi-generated-gradient-background-on-subpixel-position.html: Added.
     43        * fast/backgrounds/resources/black25x25.png: Added.
     44
    1452014-04-04  Mihnea Ovidenie  <mihnea@adobe.com>
    246
  • trunk/LayoutTests/css3/background/background-repeat-round-auto1-expected.html

    r156322 r166784  
    1010                border: 50px solid transparent;
    1111                background-image: url(resources/circle.png);
    12                 background-size: 111px 88px;
     12                background-size: 50px auto;
    1313                background-repeat: repeat;
    1414                background-origin: border-box;
  • trunk/LayoutTests/css3/background/background-repeat-round-auto1.html

    r153582 r166784  
    1010                border: 50px solid transparent;
    1111                background-image: url(resources/circle.png);
    12                 background-size: 106px auto;
     12                background-size: 50px auto;
    1313                background-repeat: round repeat;
    1414                background-origin: border-box;
  • trunk/LayoutTests/css3/background/background-repeat-round-auto2-expected.html

    r156322 r166784  
    1010                border: 50px solid transparent;
    1111                background-image: url(resources/circle.png);
    12                 background-size: 124px 100px;
     12                background-size: auto 50px;
    1313                background-repeat: repeat;
    1414                background-origin: border-box;
  • trunk/LayoutTests/css3/background/background-repeat-round-auto2.html

    r153582 r166784  
    1010                border: 50px solid transparent;
    1111                background-image: url(resources/circle.png);
    12                 background-size: auto 99px;
     12                background-size: auto 50px;
    1313                background-repeat: repeat round;
    1414                background-origin: border-box;
  • trunk/LayoutTests/css3/background/background-repeat-round-border-expected.html

    r156322 r166784  
    1010                border: 50px solid transparent;
    1111                background-image: url(resources/circle.png);
    12                 background-size: 111px 85px;
     12                background-size: 50px;
    1313                background-repeat: repeat;
    1414                background-origin: border-box;
  • trunk/LayoutTests/css3/background/background-repeat-round-border.html

    r153582 r166784  
    1010                border: 50px solid transparent;
    1111                background-image: url(resources/circle.png);
    12                 background-size: 106px;
     12                background-size: 50px;
    1313                background-repeat: round;
    1414                background-origin: border-box;
  • trunk/LayoutTests/css3/background/background-repeat-round-content-expected.html

    r156322 r166784  
    1010                border: 50px solid transparent;
    1111                background-image: url(resources/circle.png);
    12                 background-size: 72px 40px;
     12                background-size: 100px;
    1313                background-repeat: repeat;
    1414                background-origin: content-box;
  • trunk/LayoutTests/css3/background/background-repeat-round-content.html

    r153582 r166784  
    1010                border: 50px solid transparent;
    1111                background-image: url(resources/circle.png);
    12                 background-size: 70px 40px;
     12                background-size: 100px;
    1313                background-repeat: round;
    1414                background-origin: content-box;
  • trunk/LayoutTests/css3/background/background-repeat-space-content-expected.html

    r161884 r166784  
    44        <style>
    55            div {
    6                 width: 800px;
     6                width: 600px;
    77                height: 400px;
    88                border: 50px solid transparent;
    99                padding: 50px;
    10             }
     10                background-origin: content-box;
     11                background-clip: content-box;
     12                background-repeat: no-repeat;
     13           }
    1114        </style>
    1215        <script>
    13             var sizeX = 121, sizeY = 93, spaceX = 14, spaceY = 9, width = 800, height = 400;
     16            var sizeX = 100, sizeY = 80, spaceX = 0, spaceY = 0, width = 600, height = 400;
    1417
    1518            var urls = Array(), size = Array(), position = Array();
     
    2831                div.style.cssText += "background-image: " + urls.join(", ") + ";" +
    2932                                     "background-size: " + size.join(", ")  + ";" +
    30                                      "background-position: " + position.join(", ") + ";" +
    31                                      "background-repeat: no-repeat;" +
    32                                      "background-origin: content-box;" +
    33                                      "background-clip: content-box;";
     33                                     "background-position: " + position.join(", ") + ";";
    3434           }
    3535       </script>
  • trunk/LayoutTests/css3/background/background-repeat-space-content.html

    r154875 r166784  
    44        <style>
    55            div {
    6                 width: 800px;
     6                width: 600px;
    77                height: 400px;
    88                border: 50px solid transparent;
    99                padding: 50px;
    1010                background-image: url("resources/circle.png");
    11                 background-size: 121px 93px;
     11                background-size: 100px;
    1212                background-repeat: space space;
    1313                background-origin: content-box;
  • trunk/LayoutTests/css3/background/background-repeat-space-padding-expected.html

    r161884 r166784  
    88                border: 50px solid transparent;
    99                padding: 50px;
     10                background-repeat: no-repeat;
     11                background-origin: padding-box;
     12                background-clip: padding-box;
    1013            }
    1114        </style>
    1215        <script>
    13             var sizeX = 153, sizeY = 127, spaceX = 20, spaceY = 9, width = 700, height = 600;
     16            var sizeX = 150, sizeY = 120, spaceX = 25, spaceY = 20, width = 400, height = 300;
    1417
    1518            var urls = Array(), size = Array(), position = Array();
     
    2831                div.style.cssText += "background-image: " + urls.join(", ") + ";" +
    2932                                     "background-size: " + size.join(", ")  + ";" +
    30                                      "background-position: " + position.join(", ") + ";" +
    31                                      "background-repeat: no-repeat;" +
    32                                      "background-origin: padding-box;" +
    33                                      "background-clip: padding-box;";
     33                                     "background-position: " + position.join(", ") + ";";
    3434           }
    3535       </script>
  • trunk/LayoutTests/css3/background/background-repeat-space-padding.html

    r154875 r166784  
    99                padding: 50px;
    1010                background-image: url("resources/circle.png");
    11                 background-size: 153px 127px;
     11                background-size: 150px;
    1212                background-repeat: space;
    1313                background-origin: padding-box;
  • trunk/LayoutTests/css3/masking/mask-repeat-round-auto1-expected.html

    r156322 r166784  
    1515                padding: 50px;
    1616                -webkit-mask-image: url(resources/circle.png);
    17                 -webkit-mask-size: 111px 88px;
     17                -webkit-mask-size: 100px;
    1818                -webkit-mask-repeat: repeat;
    1919                -webkit-mask-origin: border-box;
  • trunk/LayoutTests/css3/masking/mask-repeat-round-auto1.html

    r153582 r166784  
    1515                padding: 50px;
    1616                -webkit-mask-image: url(resources/circle.png);
    17                 -webkit-mask-size: 106px auto;
     17                -webkit-mask-size: 100px;
    1818                -webkit-mask-repeat: round repeat;
    1919                -webkit-mask-origin: border-box;
  • trunk/LayoutTests/css3/masking/mask-repeat-round-auto2-expected.html

    r156322 r166784  
    1515                padding: 50px;
    1616                -webkit-mask-image: url(resources/circle.png);
    17                 -webkit-mask-size: 124px 100px;
     17                -webkit-mask-size: 50px;
    1818                -webkit-mask-repeat: repeat;
    1919                -webkit-mask-origin: border-box;
  • trunk/LayoutTests/css3/masking/mask-repeat-round-auto2.html

    r153582 r166784  
    1515                padding: 50px;
    1616                -webkit-mask-image: url(resources/circle.png);
    17                 -webkit-mask-size: auto 99px;
     17                -webkit-mask-size: 50px;
    1818                -webkit-mask-repeat: repeat round;
    1919                -webkit-mask-origin: border-box;
  • trunk/LayoutTests/css3/masking/mask-repeat-round-border-expected.html

    r156322 r166784  
    1515                padding: 50px;
    1616                -webkit-mask-image: url(resources/circle.png);
    17                 -webkit-mask-size: 111px 85px;
     17                -webkit-mask-size: 50px;
    1818                -webkit-mask-repeat: repeat;
    1919                -webkit-mask-origin: border-box;
  • trunk/LayoutTests/css3/masking/mask-repeat-round-border.html

    r153582 r166784  
    1515                padding: 50px;
    1616                -webkit-mask-image: url(resources/circle.png);
    17                 -webkit-mask-size: 106px;
     17                -webkit-mask-size: 50px;
    1818                -webkit-mask-repeat: round;
    1919                -webkit-mask-origin: border-box;
  • trunk/LayoutTests/css3/masking/mask-repeat-round-content-expected.html

    r156322 r166784  
    1515                padding: 50px;
    1616                -webkit-mask-image: url(resources/circle.png);
    17                 -webkit-mask-size: 72px 40px;
     17                -webkit-mask-size: 50px;
    1818                -webkit-mask-repeat: repeat;
    1919                -webkit-mask-origin: content-box;
  • trunk/LayoutTests/css3/masking/mask-repeat-round-content.html

    r153582 r166784  
    1515                padding: 50px;
    1616                -webkit-mask-image: url(resources/circle.png);
    17                 -webkit-mask-size: 70px 40px;
     17                -webkit-mask-size: 50px;
    1818                -webkit-mask-repeat: round;
    1919                -webkit-mask-origin: content-box;
  • trunk/LayoutTests/css3/masking/mask-repeat-space-content-expected.html

    r161884 r166784  
    1414                border: 50px solid blue;
    1515                padding: 50px;
     16                -webkit-mask-repeat: no-repeat;
     17                -webkit-mask-origin: content-box;
     18                -webkit-mask-clip: content-box;
    1619            }
    1720        </style>
    1821        <script>
    19             var sizeX = 121, sizeY = 93, spaceX = 58, spaceY = 10, width = 300, height = 300;
     22            var sizeX = 100, sizeY = 80, spaceX = 0, spaceY = 30, width = 300, height = 300;
    2023
    2124            var urls = Array(), size = Array(), position = Array();
     
    2427                for (var x = 0; x < width; x += sizeX + spaceX) {
    2528                    for (var y = 0; y < height; y += sizeY + spaceY) {
    26                         urls.push("url(resources/circle.svg)");
     29                        urls.push("url(resources/circle.png)");
    2730                        size.push(sizeX + "px " + sizeY + "px");
    2831                        position.push(x + "px " + y + "px");
     
    3437                div.style.cssText += "-webkit-mask-image: " + urls.join(", ") + ";" +
    3538                                     "-webkit-mask-size: " + size.join(", ")  + ";" +
    36                                      "-webkit-mask-position: " + position.join(", ") + ";" +
    37                                      "-webkit-mask-repeat: no-repeat;" +
    38                                      "-webkit-mask-origin: content-box;" +
    39                                      "-webkit-mask-clip: content-box;";
     39                                     "-webkit-mask-position: " + position.join(", ") + ";";
    4040           }
    4141       </script>
  • trunk/LayoutTests/css3/masking/mask-repeat-space-content.html

    r154875 r166784  
    1414                border: 50px solid blue;
    1515                padding: 50px;
    16                 -webkit-mask-image: url("resources/circle.svg");
    17                 -webkit-mask-size: 121px 93px;
     16                -webkit-mask-image: url("resources/circle.png");
     17                -webkit-mask-size: 100px;
    1818                -webkit-mask-repeat: space space;
    1919                -webkit-mask-origin: content-box;
  • trunk/LayoutTests/css3/masking/mask-repeat-space-padding-expected.html

    r161884 r166784  
    1414                border: 50px solid blue;
    1515                padding: 50px;
     16                -webkit-mask-repeat: no-repeat;
     17                -webkit-mask-origin: padding-box;
     18                -webkit-mask-clip: padding-box;
    1619            }
    1720        </style>
    1821        <script>
    19             var sizeX = 153, sizeY = 127, spaceX = 20, spaceY = 9, width = 700, height = 600;
     22            var sizeX = 100, sizeY = 80, spaceX = 0, spaceY = 0, width = 700, height = 600;
    2023
    2124            var urls = Array(), size = Array(), position = Array();
     
    3437                div.style.cssText += "-webkit-mask-image: " + urls.join(", ") + ";" +
    3538                                     "-webkit-mask-size: " + size.join(", ")  + ";" +
    36                                      "-webkit-mask-position: " + position.join(", ") + ";" +
    37                                      "-webkit-mask-repeat: no-repeat;" +
    38                                      "-webkit-mask-origin: padding-box;" +
    39                                      "-webkit-mask-clip: padding-box;";
     39                                     "-webkit-mask-position: " + position.join(", ") + ";";
    4040           }
    4141       </script>
  • trunk/LayoutTests/css3/masking/mask-repeat-space-padding.html

    r156097 r166784  
    1515                padding: 50px;
    1616                -webkit-mask-image: url("resources/circle.png");
    17                 -webkit-mask-size: 153px 127px;
     17                -webkit-mask-size: 100px;
    1818                -webkit-mask-repeat: space;
    1919                -webkit-mask-origin: padding-box;
  • trunk/Source/WebCore/ChangeLog

    r166783 r166784  
     12014-04-04  Zalan Bujtas  <zalan@apple.com>
     2
     3        Subpixel rendering: Move background images to device pixel boundaries.
     4        https://bugs.webkit.org/show_bug.cgi?id=131144
     5
     6        Reviewed by Simon Fraser.
     7
     8        Replace integral snapping with device pixel snapping.
     9        Background image geometry calculation uses LayoutUnits and we snap to device pixels right before painting.
     10
     11        Tests: fast/backgrounds/hidpi-bitmap-background-on-subpixel-position.html
     12               fast/backgrounds/hidpi-bitmap-background-origin-on-subpixel-position.html
     13               fast/backgrounds/hidpi-bitmap-background-repeat-on-subpixel-position.html
     14               fast/backgrounds/hidpi-generated-gradient-background-on-subpixel-position.html
     15
     16        * platform/graphics/GraphicsLayer.h:
     17        (WebCore::GraphicsLayer::setContentsTilePhase):
     18        (WebCore::GraphicsLayer::contentsTilePhase):
     19        (WebCore::GraphicsLayer::setContentsTileSize):
     20        (WebCore::GraphicsLayer::contentsTileSize):
     21        * platform/graphics/texmap/TextureMapperLayer.cpp:
     22        (WebCore::TextureMapperLayer::setContentsTileSize):
     23        (WebCore::TextureMapperLayer::setContentsTilePhase):
     24        * platform/graphics/texmap/TextureMapperLayer.h:
     25        * platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.cpp:
     26        (WebCore::CoordinatedGraphicsLayer::setContentsTileSize):
     27        (WebCore::CoordinatedGraphicsLayer::setContentsTilePhase):
     28        * platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.h:
     29        * platform/graphics/texmap/coordinated/CoordinatedGraphicsState.h:
     30        * rendering/RenderBox.cpp:
     31        (WebCore::RenderBox::repaintLayerRectsForImage):
     32        * rendering/RenderBoxModelObject.cpp:
     33        (WebCore::RenderBoxModelObject::paintFillLayerExtended):
     34        (WebCore::resolveWidthForRatio):
     35        (WebCore::resolveHeightForRatio):
     36        (WebCore::resolveAgainstIntrinsicWidthOrHeightAndRatio):
     37        (WebCore::resolveAgainstIntrinsicRatio):
     38        (WebCore::RenderBoxModelObject::calculateImageIntrinsicDimensions):
     39        (WebCore::RenderBoxModelObject::calculateFillTileSize):
     40        (WebCore::RenderBoxModelObject::BackgroundImageGeometry::setNoRepeatX):
     41        (WebCore::RenderBoxModelObject::BackgroundImageGeometry::setNoRepeatY):
     42        (WebCore::RenderBoxModelObject::BackgroundImageGeometry::useFixedAttachment):
     43        (WebCore::RenderBoxModelObject::BackgroundImageGeometry::clip):
     44        (WebCore::RenderBoxModelObject::BackgroundImageGeometry::relativePhase):
     45        (WebCore::getSpace):
     46        (WebCore::RenderBoxModelObject::pixelSnapBackgroundImageGeometryForPainting):
     47        (WebCore::RenderBoxModelObject::calculateBackgroundImageGeometry):
     48        (WebCore::RenderBoxModelObject::getGeometryForBackgroundImage):
     49        (WebCore::RenderBoxModelObject::paintNinePieceImage):
     50        (WebCore::applySubPixelHeuristicForTileSize): Deleted.
     51        * rendering/RenderBoxModelObject.h:
     52        (WebCore::RenderBoxModelObject::BackgroundImageGeometry::destOrigin):
     53        (WebCore::RenderBoxModelObject::BackgroundImageGeometry::setDestOrigin):
     54        (WebCore::RenderBoxModelObject::BackgroundImageGeometry::destRect):
     55        (WebCore::RenderBoxModelObject::BackgroundImageGeometry::setDestRect):
     56        (WebCore::RenderBoxModelObject::BackgroundImageGeometry::phase):
     57        (WebCore::RenderBoxModelObject::BackgroundImageGeometry::setPhase):
     58        (WebCore::RenderBoxModelObject::BackgroundImageGeometry::tileSize):
     59        (WebCore::RenderBoxModelObject::BackgroundImageGeometry::setTileSize):
     60        (WebCore::RenderBoxModelObject::BackgroundImageGeometry::spaceSize):
     61        (WebCore::RenderBoxModelObject::BackgroundImageGeometry::setSpaceSize):
     62        (WebCore::RenderBoxModelObject::BackgroundImageGeometry::setPhaseX):
     63        (WebCore::RenderBoxModelObject::BackgroundImageGeometry::setPhaseY):
     64        * rendering/RenderLayerBacking.cpp:
     65        (WebCore::RenderLayerBacking::updateDirectlyCompositedBackgroundImage):
     66        * rendering/shapes/ShapeOutsideInfo.cpp:
     67        (WebCore::getShapeImageAndRect):
     68
    1692014-04-04  Brent Fulgham  <bfulgham@apple.com>
    270
  • trunk/Source/WebCore/platform/graphics/GraphicsLayer.h

    r166308 r166784  
    369369
    370370    // The tile phase is relative to the GraphicsLayer bounds.
    371     virtual void setContentsTilePhase(const IntPoint& p) { m_contentsTilePhase = p; }
    372     IntPoint contentsTilePhase() const { return m_contentsTilePhase; }
    373 
    374     virtual void setContentsTileSize(const IntSize& s) { m_contentsTileSize = s; }
    375     IntSize contentsTileSize() const { return m_contentsTileSize; }
     371    virtual void setContentsTilePhase(const FloatPoint& p) { m_contentsTilePhase = p; }
     372    FloatPoint contentsTilePhase() const { return m_contentsTilePhase; }
     373
     374    virtual void setContentsTileSize(const FloatSize& s) { m_contentsTileSize = s; }
     375    FloatSize contentsTileSize() const { return m_contentsTileSize; }
    376376    bool hasContentsTiling() const { return !m_contentsTileSize.isEmpty(); }
    377377
     
    611611    FloatRect m_contentsRect;
    612612    FloatRect m_contentsClippingRect;
    613     IntPoint m_contentsTilePhase;
    614     IntSize m_contentsTileSize;
     613    FloatPoint m_contentsTilePhase;
     614    FloatSize m_contentsTileSize;
    615615
    616616    int m_repaintCount;
  • trunk/Source/WebCore/platform/graphics/texmap/TextureMapperLayer.cpp

    r165665 r166784  
    569569}
    570570
    571 void TextureMapperLayer::setContentsTileSize(const IntSize& size)
     571void TextureMapperLayer::setContentsTileSize(const FloatSize& size)
    572572{
    573573    if (size == m_state.contentsTileSize)
     
    577577}
    578578
    579 void TextureMapperLayer::setContentsTilePhase(const IntPoint& phase)
     579void TextureMapperLayer::setContentsTilePhase(const FloatPoint& phase)
    580580{
    581581    if (phase == m_state.contentsTilePhase)
  • trunk/Source/WebCore/platform/graphics/texmap/TextureMapperLayer.h

    r165341 r166784  
    100100    void setOpacity(float);
    101101    void setSolidColor(const Color&);
    102     void setContentsTileSize(const IntSize&);
    103     void setContentsTilePhase(const IntPoint&);
     102    void setContentsTileSize(const FloatSize&);
     103    void setContentsTilePhase(const FloatPoint&);
    104104#if ENABLE(CSS_FILTERS)
    105105    void setFilters(const FilterOperations&);
     
    211211        float opacity;
    212212        FloatRect contentsRect;
    213         IntSize contentsTileSize;
    214         IntPoint contentsTilePhase;
     213        FloatSize contentsTileSize;
     214        FloatPoint contentsTilePhase;
    215215        TextureMapperLayer* maskLayer;
    216216        TextureMapperLayer* replicaLayer;
  • trunk/Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.cpp

    r165354 r166784  
    347347}
    348348
    349 void CoordinatedGraphicsLayer::setContentsTileSize(const IntSize& s)
     349void CoordinatedGraphicsLayer::setContentsTileSize(const FloatSize& s)
    350350{
    351351    if (contentsTileSize() == s)
     
    358358}
    359359
    360 void CoordinatedGraphicsLayer::setContentsTilePhase(const IntPoint& p)
     360void CoordinatedGraphicsLayer::setContentsTilePhase(const FloatPoint& p)
    361361{
    362362    if (contentsTilePhase() == p)
  • trunk/Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.h

    r165354 r166784  
    8686    virtual void setOpacity(float) override;
    8787    virtual void setContentsRect(const FloatRect&) override;
    88     virtual void setContentsTilePhase(const IntPoint&) override;
    89     virtual void setContentsTileSize(const IntSize&) override;
     88    virtual void setContentsTilePhase(const FloatPoint&) override;
     89    virtual void setContentsTileSize(const FloatSize&) override;
    9090    virtual void setContentsToImage(Image*) override;
    9191    virtual void setContentsToSolidColor(const Color&) override;
  • trunk/Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedGraphicsState.h

    r165341 r166784  
    143143    TransformationMatrix childrenTransform;
    144144    FloatRect contentsRect;
    145     IntPoint contentsTilePhase;
    146     IntSize contentsTileSize;
     145    FloatPoint contentsTilePhase;
     146    FloatSize contentsTileSize;
    147147    float opacity;
    148148    Color solidColor;
  • trunk/Source/WebCore/rendering/RenderBox.cpp

    r166422 r166784  
    16241624            }
    16251625           
    1626             IntRect rectToRepaint = geometry.destRect();
     1626            LayoutRect rectToRepaint = geometry.destRect();
    16271627            bool shouldClipToLayer = true;
    16281628
  • trunk/Source/WebCore/rendering/RenderBoxModelObject.cpp

    r166138 r166784  
    774774    // by verifying whether the background image covers the entire layout rect.
    775775    if (!bgLayer->next()) {
    776         IntRect backgroundRect(pixelSnappedIntRect(scrolledPaintRect));
     776        LayoutRect backgroundRect(scrolledPaintRect);
    777777        bool boxShadowShouldBeAppliedToBackground = this->boxShadowShouldBeAppliedToBackground(bleedAvoidance, box);
    778778        if (boxShadowShouldBeAppliedToBackground || !shouldPaintBackgroundImage || !bgLayer->hasOpaqueImage(this) || !bgLayer->hasRepeatXY()) {
    779779            if (!boxShadowShouldBeAppliedToBackground)
    780                 backgroundRect.intersect(pixelSnappedIntRect(paintInfo.rect));
     780                backgroundRect.intersect(paintInfo.rect);
    781781
    782782            // If we have an alpha and we are painting the root element, go ahead and blend with the base background color.
     
    793793                applyBoxShadowForBackground(context, &style());
    794794
     795            FloatRect backgroundRectForPainting = pixelSnappedForPainting(backgroundRect, deviceScaleFactor);
    795796            if (baseColor.alpha()) {
    796797                if (bgColor.alpha())
    797798                    baseColor = baseColor.blend(bgColor);
    798799
    799                 context->fillRect(backgroundRect, baseColor, style().colorSpace(), CompositeCopy);
     800                context->fillRect(backgroundRectForPainting, baseColor, style().colorSpace(), CompositeCopy);
    800801            } else if (bgColor.alpha()) {
    801802                CompositeOperator operation = shouldClearBackground ? CompositeCopy : context->compositeOperation();
    802                 context->fillRect(backgroundRect, bgColor, style().colorSpace(), operation);
     803                context->fillRect(backgroundRectForPainting, bgColor, style().colorSpace(), operation);
    803804            } else if (shouldClearBackground)
    804                 context->clearRect(backgroundRect);
     805                context->clearRect(backgroundRectForPainting);
    805806        }
    806807    }
     
    810811        BackgroundImageGeometry geometry;
    811812        calculateBackgroundImageGeometry(paintInfo.paintContainer, bgLayer, scrolledPaintRect, geometry, backgroundObject);
    812         geometry.clip(pixelSnappedIntRect(paintInfo.rect));
     813        geometry.clip(LayoutRect(pixelSnappedRect));
    813814        if (!geometry.destRect().isEmpty()) {
    814815            CompositeOperator compositeOp = op == CompositeSourceOver ? bgLayer->composite() : op;
     
    819820            if (image.get())
    820821                image->setSpaceSize(geometry.spaceSize());
    821             context->drawTiledImage(image.get(), style().colorSpace(), geometry.destRect(), geometry.relativePhase(), geometry.tileSize(),
    822                 compositeOp, useLowQualityScaling, bgLayer->blendMode());
     822            context->drawTiledImage(image.get(), style().colorSpace(), geometry.destRect(), geometry.relativePhase(), geometry.tileSize(), compositeOp, useLowQualityScaling, bgLayer->blendMode());
    823823        }
    824824    }
     
    830830}
    831831
    832 static inline int resolveWidthForRatio(int height, const FloatSize& intrinsicRatio)
    833 {
    834     return ceilf(height * intrinsicRatio.width() / intrinsicRatio.height());
    835 }
    836 
    837 static inline int resolveHeightForRatio(int width, const FloatSize& intrinsicRatio)
    838 {
    839     return ceilf(width * intrinsicRatio.height() / intrinsicRatio.width());
    840 }
    841 
    842 static inline IntSize resolveAgainstIntrinsicWidthOrHeightAndRatio(const IntSize& size, const FloatSize& intrinsicRatio, int useWidth, int useHeight)
     832static inline int resolveWidthForRatio(LayoutUnit height, const FloatSize& intrinsicRatio)
     833{
     834    return height * intrinsicRatio.width() / intrinsicRatio.height();
     835}
     836
     837static inline int resolveHeightForRatio(LayoutUnit width, const FloatSize& intrinsicRatio)
     838{
     839    return width * intrinsicRatio.height() / intrinsicRatio.width();
     840}
     841
     842static inline LayoutSize resolveAgainstIntrinsicWidthOrHeightAndRatio(const LayoutSize& size, const FloatSize& intrinsicRatio, LayoutUnit useWidth, LayoutUnit useHeight)
    843843{
    844844    if (intrinsicRatio.isEmpty()) {
    845845        if (useWidth)
    846             return IntSize(useWidth, size.height());
    847         return IntSize(size.width(), useHeight);
     846            return LayoutSize(useWidth, size.height());
     847        return LayoutSize(size.width(), useHeight);
    848848    }
    849849
    850850    if (useWidth)
    851         return IntSize(useWidth, resolveHeightForRatio(useWidth, intrinsicRatio));
    852     return IntSize(resolveWidthForRatio(useHeight, intrinsicRatio), useHeight);
    853 }
    854 
    855 static inline IntSize resolveAgainstIntrinsicRatio(const IntSize& size, const FloatSize& intrinsicRatio)
     851        return LayoutSize(useWidth, resolveHeightForRatio(useWidth, intrinsicRatio));
     852    return LayoutSize(resolveWidthForRatio(useHeight, intrinsicRatio), useHeight);
     853}
     854
     855static inline LayoutSize resolveAgainstIntrinsicRatio(const LayoutSize& size, const FloatSize& intrinsicRatio)
    856856{
    857857    // Two possible solutions: (size.width(), solutionHeight) or (solutionWidth, size.height())
    858858    // "... must be assumed to be the largest dimensions..." = easiest answer: the rect with the largest surface area.
    859859
    860     int solutionWidth = resolveWidthForRatio(size.height(), intrinsicRatio);
    861     int solutionHeight = resolveHeightForRatio(size.width(), intrinsicRatio);
     860    LayoutUnit solutionWidth = resolveWidthForRatio(size.height(), intrinsicRatio);
     861    LayoutUnit solutionHeight = resolveHeightForRatio(size.width(), intrinsicRatio);
    862862    if (solutionWidth <= size.width()) {
    863863        if (solutionHeight <= size.height()) {
    864864            // If both solutions fit, choose the one covering the larger area.
    865             int areaOne = solutionWidth * size.height();
    866             int areaTwo = size.width() * solutionHeight;
     865            LayoutUnit areaOne = solutionWidth * size.height();
     866            LayoutUnit areaTwo = size.width() * solutionHeight;
    867867            if (areaOne < areaTwo)
    868                 return IntSize(size.width(), solutionHeight);
    869             return IntSize(solutionWidth, size.height());
     868                return LayoutSize(size.width(), solutionHeight);
     869            return LayoutSize(solutionWidth, size.height());
    870870        }
    871871
    872872        // Only the first solution fits.
    873         return IntSize(solutionWidth, size.height());
     873        return LayoutSize(solutionWidth, size.height());
    874874    }
    875875
    876876    // Only the second solution fits, assert that.
    877877    ASSERT(solutionHeight <= size.height());
    878     return IntSize(size.width(), solutionHeight);
    879 }
    880 
    881 IntSize RenderBoxModelObject::calculateImageIntrinsicDimensions(StyleImage* image, const IntSize& positioningAreaSize, ScaleByEffectiveZoomOrNot shouldScaleOrNot) const
     878    return LayoutSize(size.width(), solutionHeight);
     879}
     880
     881LayoutSize RenderBoxModelObject::calculateImageIntrinsicDimensions(StyleImage* image, const LayoutSize& positioningAreaSize, ScaleByEffectiveZoomOrNot shouldScaleOrNot) const
    882882{
    883883    // A generated image without a fixed size, will always return the container size as intrinsic size.
    884884    if (image->isGeneratedImage() && image->usesImageContainerSize())
    885         return IntSize(positioningAreaSize.width(), positioningAreaSize.height());
     885        return LayoutSize(positioningAreaSize.width(), positioningAreaSize.height());
    886886
    887887    Length intrinsicWidth;
     
    896896    if (intrinsicWidth.isPercent() && intrinsicHeight.isPercent() && intrinsicRatio.isEmpty()) {
    897897        // Resolve width/height percentages against positioningAreaSize, only if no intrinsic ratio is provided.
    898         int resolvedWidth = static_cast<int>(round(positioningAreaSize.width() * intrinsicWidth.percent() / 100));
    899         int resolvedHeight = static_cast<int>(round(positioningAreaSize.height() * intrinsicHeight.percent() / 100));
    900         return IntSize(resolvedWidth, resolvedHeight);
    901     }
    902 
    903     IntSize resolvedSize(intrinsicWidth.isFixed() ? intrinsicWidth.value() : 0, intrinsicHeight.isFixed() ? intrinsicHeight.value() : 0);
    904     IntSize minimumSize(resolvedSize.width() > 0 ? 1 : 0, resolvedSize.height() > 0 ? 1 : 0);
     898        float resolvedWidth = positioningAreaSize.width() * intrinsicWidth.percent() / 100;
     899        float resolvedHeight = positioningAreaSize.height() * intrinsicHeight.percent() / 100;
     900        return LayoutSize(resolvedWidth, resolvedHeight);
     901    }
     902
     903    LayoutSize resolvedSize(intrinsicWidth.isFixed() ? intrinsicWidth.value() : 0, intrinsicHeight.isFixed() ? intrinsicHeight.value() : 0);
     904    LayoutSize minimumSize(resolvedSize.width() > 0 ? 1 : 0, resolvedSize.height() > 0 ? 1 : 0);
    905905    if (shouldScaleOrNot == ScaleByEffectiveZoom)
    906906        resolvedSize.scale(style().effectiveZoom());
     
    928928}
    929929
    930 static inline void applySubPixelHeuristicForTileSize(LayoutSize& tileSize, const IntSize& positioningAreaSize)
    931 {
    932     tileSize.setWidth(positioningAreaSize.width() - tileSize.width() <= 1 ? tileSize.width().ceil() : tileSize.width().floor());
    933     tileSize.setHeight(positioningAreaSize.height() - tileSize.height() <= 1 ? tileSize.height().ceil() : tileSize.height().floor());
    934 }
    935 
    936 IntSize RenderBoxModelObject::calculateFillTileSize(const FillLayer* fillLayer, const IntSize& positioningAreaSize) const
     930LayoutSize RenderBoxModelObject::calculateFillTileSize(const FillLayer* fillLayer, const LayoutSize& positioningAreaSize) const
    937931{
    938932    StyleImage* image = fillLayer->image();
    939933    EFillSizeType type = fillLayer->size().type;
    940934
    941     IntSize imageIntrinsicSize = calculateImageIntrinsicDimensions(image, positioningAreaSize, ScaleByEffectiveZoom);
     935    LayoutSize imageIntrinsicSize = calculateImageIntrinsicDimensions(image, positioningAreaSize, ScaleByEffectiveZoom);
    942936    imageIntrinsicSize.scale(1 / image->imageScaleFactor(), 1 / image->imageScaleFactor());
    943937    switch (type) {
     
    957951            else if (layerHeight.isPercent() || layerHeight.isViewportPercentage())
    958952                tileSize.setHeight(valueForLength(layerHeight, positioningAreaSize.height()));
    959 
    960             applySubPixelHeuristicForTileSize(tileSize, positioningAreaSize);
    961953
    962954            // If one of the values is auto we have to use the appropriate
     
    974966           
    975967            tileSize.clampNegativeToZero();
    976             return flooredIntSize(tileSize);
     968            return tileSize;
    977969        }
    978970        case SizeNone: {
     
    987979        case Contain:
    988980        case Cover: {
    989             float horizontalScaleFactor = imageIntrinsicSize.width()
    990                 ? static_cast<float>(positioningAreaSize.width()) / imageIntrinsicSize.width() : 1;
    991             float verticalScaleFactor = imageIntrinsicSize.height()
    992                 ? static_cast<float>(positioningAreaSize.height()) / imageIntrinsicSize.height() : 1;
     981            float horizontalScaleFactor = imageIntrinsicSize.width() ? (positioningAreaSize.width() / imageIntrinsicSize.width()).toFloat() : 1;
     982            float verticalScaleFactor = imageIntrinsicSize.height() ? (positioningAreaSize.height() / imageIntrinsicSize.height()).toFloat() : 1;
    993983            float scaleFactor = type == Contain ? std::min(horizontalScaleFactor, verticalScaleFactor) : std::max(horizontalScaleFactor, verticalScaleFactor);
    994             return IntSize(std::max(1, static_cast<int>(imageIntrinsicSize.width() * scaleFactor)), std::max(1, static_cast<int>(imageIntrinsicSize.height() * scaleFactor)));
     984            float deviceScaleFactor = document().deviceScaleFactor();
     985            return LayoutSize(std::max<LayoutUnit>(1 / deviceScaleFactor, imageIntrinsicSize.width() * scaleFactor),
     986                std::max<LayoutUnit>(1 / deviceScaleFactor, imageIntrinsicSize.height() * scaleFactor));
    995987       }
    996988    }
    997989
    998990    ASSERT_NOT_REACHED();
    999     return IntSize();
    1000 }
    1001 
    1002 void RenderBoxModelObject::BackgroundImageGeometry::setNoRepeatX(int xOffset)
    1003 {
    1004     m_destRect.move(std::max(xOffset, 0), 0);
    1005     m_phase.setX(-std::min(xOffset, 0));
    1006     m_destRect.setWidth(m_tileSize.width() + std::min(xOffset, 0));
    1007 }
    1008 void RenderBoxModelObject::BackgroundImageGeometry::setNoRepeatY(int yOffset)
    1009 {
    1010     m_destRect.move(0, std::max(yOffset, 0));
    1011     m_phase.setY(-std::min(yOffset, 0));
    1012     m_destRect.setHeight(m_tileSize.height() + std::min(yOffset, 0));
    1013 }
    1014 
    1015 void RenderBoxModelObject::BackgroundImageGeometry::useFixedAttachment(const IntPoint& attachmentPoint)
    1016 {
    1017     IntPoint alignedPoint = attachmentPoint;
    1018     m_phase.move(std::max(alignedPoint.x() - m_destRect.x(), 0), std::max(alignedPoint.y() - m_destRect.y(), 0));
    1019 }
    1020 
    1021 void RenderBoxModelObject::BackgroundImageGeometry::clip(const IntRect& clipRect)
     991    return LayoutSize();
     992}
     993
     994void RenderBoxModelObject::BackgroundImageGeometry::setNoRepeatX(LayoutUnit xOffset)
     995{
     996    m_destRect.move(std::max<LayoutUnit>(xOffset, 0), 0);
     997    m_phase.setX(-std::min<LayoutUnit>(xOffset, 0));
     998    m_destRect.setWidth(m_tileSize.width() + std::min<float>(xOffset, 0));
     999}
     1000void RenderBoxModelObject::BackgroundImageGeometry::setNoRepeatY(LayoutUnit yOffset)
     1001{
     1002    m_destRect.move(0, std::max<LayoutUnit>(yOffset, 0));
     1003    m_phase.setY(-std::min<LayoutUnit>(yOffset, 0));
     1004    m_destRect.setHeight(m_tileSize.height() + std::min<float>(yOffset, 0));
     1005}
     1006
     1007void RenderBoxModelObject::BackgroundImageGeometry::useFixedAttachment(const LayoutPoint& attachmentPoint)
     1008{
     1009    FloatPoint alignedPoint = attachmentPoint;
     1010    m_phase.move(std::max<LayoutUnit>(alignedPoint.x() - m_destRect.x(), 0), std::max<LayoutUnit>(alignedPoint.y() - m_destRect.y(), 0));
     1011}
     1012
     1013void RenderBoxModelObject::BackgroundImageGeometry::clip(const LayoutRect& clipRect)
    10221014{
    10231015    m_destRect.intersect(clipRect);
    10241016}
    10251017
    1026 IntPoint RenderBoxModelObject::BackgroundImageGeometry::relativePhase() const
    1027 {
    1028     IntPoint phase = m_phase;
     1018LayoutPoint RenderBoxModelObject::BackgroundImageGeometry::relativePhase() const
     1019{
     1020    LayoutPoint phase = m_phase;
    10291021    phase += m_destRect.location() - m_destOrigin;
    10301022    return phase;
     
    10461038}
    10471039
    1048 static inline int getSpace(int areaSize, int tileSize)
     1040static inline LayoutUnit getSpace(LayoutUnit areaSize, LayoutUnit tileSize)
    10491041{
    10501042    int numberOfTiles = areaSize / tileSize;
    1051     int space = -1;
     1043    LayoutUnit space = -1;
    10521044
    10531045    if (numberOfTiles > 1)
    1054         space = roundedLayoutUnit((float)(areaSize - numberOfTiles * tileSize) / (numberOfTiles - 1));
     1046        space = (areaSize - numberOfTiles * tileSize) / (numberOfTiles - 1);
    10551047
    10561048    return space;
     1049}
     1050
     1051void RenderBoxModelObject::pixelSnapBackgroundImageGeometryForPainting(BackgroundImageGeometry& geometry) const
     1052{
     1053    float deviceScaleFactor = document().deviceScaleFactor();
     1054    // FIXME: We need a better rounding strategy to round/space out tiles.
     1055    geometry.setTileSize(LayoutSize(pixelSnappedForPainting(LayoutRect(geometry.destRect().location(), geometry.tileSize()), deviceScaleFactor).size()));
     1056    geometry.setSpaceSize(LayoutSize(pixelSnappedForPainting(LayoutRect(LayoutPoint(), geometry.spaceSize()), deviceScaleFactor).size()));
     1057    geometry.setDestOrigin(LayoutPoint(roundedForPainting(geometry.destOrigin(), deviceScaleFactor)));
     1058    geometry.setDestRect(LayoutRect(pixelSnappedForPainting(geometry.destRect(), deviceScaleFactor)));
     1059    geometry.setPhase(LayoutPoint(roundedForPainting(geometry.phase(), deviceScaleFactor)));
    10571060}
    10581061
     
    10621065    LayoutUnit left = 0;
    10631066    LayoutUnit top = 0;
    1064     IntSize positioningAreaSize;
    1065     IntRect snappedPaintRect = pixelSnappedIntRect(paintRect);
    1066 
     1067    LayoutSize positioningAreaSize;
    10671068    // Determine the background positioning area and set destRect to the background painting area.
    10681069    // destRect will be adjusted later if the background is non-repeating.
     
    10811082
    10821083    if (!fixedAttachment) {
    1083         geometry.setDestRect(snappedPaintRect);
     1084        geometry.setDestRect(paintRect);
    10841085
    10851086        LayoutUnit right = 0;
     
    11031104        // the background positioning area.
    11041105        if (isRoot()) {
    1105             positioningAreaSize = pixelSnappedIntSize(toRenderBox(this)->size() - LayoutSize(left + right, top + bottom), toRenderBox(this)->location());
     1106            positioningAreaSize = toRenderBox(this)->size() - LayoutSize(left + right, top + bottom);
    11061107            if (view().frameView().hasExtendedBackgroundRectForPainting()) {
    1107                 IntRect extendedBackgroundRect = view().frameView().extendedBackgroundRectForPainting();
     1108                LayoutRect extendedBackgroundRect = view().frameView().extendedBackgroundRectForPainting();
    11081109                left += (marginLeft() - extendedBackgroundRect.x());
    11091110                top += (marginTop() - extendedBackgroundRect.y());
    11101111            }
    11111112        } else
    1112             positioningAreaSize = pixelSnappedIntSize(paintRect.size() - LayoutSize(left + right, top + bottom), paintRect.location());
     1113            positioningAreaSize = paintRect.size() - LayoutSize(left + right, top + bottom);
    11131114    } else {
    11141115        geometry.setHasNonLocalGeometry();
     
    11201121            viewportRect.setLocation(toLayoutPoint(view().frameView().scrollOffsetForFixedPosition()));
    11211122
    1122         if (paintContainer) {
    1123             LayoutPoint absoluteContainerOffset = roundedLayoutPoint(paintContainer->localToAbsolute(FloatPoint()));
    1124             viewportRect.moveBy(-absoluteContainerOffset);
    1125         }
    1126 
    1127         geometry.setDestRect(pixelSnappedIntRect(viewportRect));
     1123        if (paintContainer)
     1124            viewportRect.moveBy(LayoutPoint(-paintContainer->localToAbsolute(FloatPoint())));
     1125
     1126        geometry.setDestRect(viewportRect);
    11281127        positioningAreaSize = geometry.destRect().size();
    11291128    }
    11301129
    11311130    auto clientForBackgroundImage = backgroundObject ? backgroundObject : this;
    1132     IntSize fillTileSize = calculateFillTileSize(fillLayer, positioningAreaSize);
     1131    LayoutSize fillTileSize = calculateFillTileSize(fillLayer, positioningAreaSize);
    11331132    fillLayer->image()->setContainerSizeForRenderer(clientForBackgroundImage, fillTileSize, style().effectiveZoom());
    11341133    geometry.setTileSize(fillTileSize);
     
    11361135    EFillRepeat backgroundRepeatX = fillLayer->repeatX();
    11371136    EFillRepeat backgroundRepeatY = fillLayer->repeatY();
    1138     int availableWidth = positioningAreaSize.width() - geometry.tileSize().width();
    1139     int availableHeight = positioningAreaSize.height() - geometry.tileSize().height();
     1137    LayoutUnit availableWidth = positioningAreaSize.width() - geometry.tileSize().width();
     1138    LayoutUnit availableHeight = positioningAreaSize.height() - geometry.tileSize().height();
    11401139
    11411140    LayoutUnit computedXPosition = minimumValueForLength(fillLayer->xPosition(), availableWidth, true);
    11421141    if (backgroundRepeatX == RoundFill && positioningAreaSize.width() > 0 && fillTileSize.width() > 0) {
    1143         long nrTiles = lroundf((float)positioningAreaSize.width() / fillTileSize.width());
    1144         if (!nrTiles)
    1145             nrTiles = 1;
    1146 
     1142        int numTiles = std::max(1, roundToInt(positioningAreaSize.width() / fillTileSize.width()));
    11471143        if (fillLayer->size().size.height().isAuto() && backgroundRepeatY != RoundFill)
    1148             fillTileSize.setHeight(fillTileSize.height() * positioningAreaSize.width() / (nrTiles * fillTileSize.width()));
    1149 
    1150         fillTileSize.setWidth(positioningAreaSize.width() / nrTiles);
     1144            fillTileSize.setHeight(fillTileSize.height() * positioningAreaSize.width() / (numTiles * fillTileSize.width()));
     1145
     1146        fillTileSize.setWidth(positioningAreaSize.width() / numTiles);
    11511147        geometry.setTileSize(fillTileSize);
    1152         geometry.setPhaseX(geometry.tileSize().width() ? geometry.tileSize().width() - roundToInt(computedXPosition + left) % geometry.tileSize().width() : 0);
    1153         geometry.setSpaceSize(FloatSize());
     1148        geometry.setPhaseX(geometry.tileSize().width() ? geometry.tileSize().width() - fmodf((computedXPosition + left), geometry.tileSize().width()) : 0);
     1149        geometry.setSpaceSize(LayoutSize());
    11541150    }
    11551151
    11561152    LayoutUnit computedYPosition = minimumValueForLength(fillLayer->yPosition(), availableHeight, true);
    11571153    if (backgroundRepeatY == RoundFill && positioningAreaSize.height() > 0 && fillTileSize.height() > 0) {
    1158         long nrTiles = lroundf((float)positioningAreaSize.height() / fillTileSize.height());
    1159         if (!nrTiles)
    1160             nrTiles = 1;
    1161 
     1154        int numTiles = std::max(1, roundToInt(positioningAreaSize.height() / fillTileSize.height()));
    11621155        if (fillLayer->size().size.width().isAuto() && backgroundRepeatX != RoundFill)
    1163             fillTileSize.setWidth(fillTileSize.width() * positioningAreaSize.height() / (nrTiles * fillTileSize.height()));
    1164 
    1165         fillTileSize.setHeight(positioningAreaSize.height() / nrTiles);
     1156            fillTileSize.setWidth(fillTileSize.width() * positioningAreaSize.height() / (numTiles * fillTileSize.height()));
     1157
     1158        fillTileSize.setHeight(positioningAreaSize.height() / numTiles);
    11661159        geometry.setTileSize(fillTileSize);
    1167         geometry.setPhaseY(geometry.tileSize().height() ? geometry.tileSize().height() - roundToInt(computedYPosition + top) % geometry.tileSize().height() : 0);
    1168         geometry.setSpaceSize(FloatSize());
     1160        geometry.setPhaseY(geometry.tileSize().height() ? geometry.tileSize().height() - fmodf((computedYPosition + top), geometry.tileSize().height()) : 0);
     1161        geometry.setSpaceSize(LayoutSize());
    11691162    }
    11701163
    11711164    if (backgroundRepeatX == RepeatFill) {
    1172         geometry.setPhaseX(geometry.tileSize().width() ? geometry.tileSize().width() - roundToInt(computedXPosition + left) % geometry.tileSize().width() : 0);
    1173         geometry.setSpaceSize(FloatSize(0, geometry.spaceSize().height()));
     1165        geometry.setPhaseX(geometry.tileSize().width() ? geometry.tileSize().width() -  fmodf(computedXPosition + left, geometry.tileSize().width()): 0);
     1166        geometry.setSpaceSize(LayoutSize(0, geometry.spaceSize().height()));
    11741167    } else if (backgroundRepeatX == SpaceFill && fillTileSize.width() > 0) {
    1175         int space = getSpace(positioningAreaSize.width(), geometry.tileSize().width());
    1176         int actualWidth = geometry.tileSize().width() + space;
     1168        LayoutUnit space = getSpace(positioningAreaSize.width(), geometry.tileSize().width());
     1169        LayoutUnit actualWidth = geometry.tileSize().width() + space;
    11771170
    11781171        if (space >= 0) {
    11791172            computedXPosition = minimumValueForLength(Length(), availableWidth, true);
    1180             geometry.setSpaceSize(FloatSize(space, 0));
    1181             geometry.setPhaseX(actualWidth ? actualWidth - roundToInt(computedXPosition + left) % actualWidth : 0);
     1173            geometry.setSpaceSize(LayoutSize(space, 0));
     1174            geometry.setPhaseX(actualWidth ? actualWidth - fmodf((computedXPosition + left), actualWidth) : 0);
    11821175        } else
    11831176            backgroundRepeatX = NoRepeatFill;
    11841177    }
    11851178    if (backgroundRepeatX == NoRepeatFill) {
    1186         int xOffset = fillLayer->backgroundXOrigin() == RightEdge ? availableWidth - computedXPosition : computedXPosition;
     1179        LayoutUnit xOffset = fillLayer->backgroundXOrigin() == RightEdge ? availableWidth - computedXPosition : computedXPosition;
    11871180        geometry.setNoRepeatX(left + xOffset);
    1188         geometry.setSpaceSize(FloatSize(0, geometry.spaceSize().height()));
     1181        geometry.setSpaceSize(LayoutSize(0, geometry.spaceSize().height()));
    11891182    }
    11901183
    11911184    if (backgroundRepeatY == RepeatFill) {
    1192         geometry.setPhaseY(geometry.tileSize().height() ? geometry.tileSize().height() - roundToInt(computedYPosition + top) % geometry.tileSize().height() : 0);
    1193         geometry.setSpaceSize(FloatSize(geometry.spaceSize().width(), 0));
     1185        geometry.setPhaseY(geometry.tileSize().height() ? geometry.tileSize().height() - fmodf(computedYPosition + top, geometry.tileSize().height()) : 0);
     1186        geometry.setSpaceSize(LayoutSize(geometry.spaceSize().width(), 0));
    11941187    } else if (backgroundRepeatY == SpaceFill && fillTileSize.height() > 0) {
    1195         int space = getSpace(positioningAreaSize.height(), geometry.tileSize().height());
    1196         int actualHeight = geometry.tileSize().height() + space;
     1188        LayoutUnit space = getSpace(positioningAreaSize.height(), geometry.tileSize().height());
     1189        LayoutUnit actualHeight = geometry.tileSize().height() + space;
    11971190
    11981191        if (space >= 0) {
    11991192            computedYPosition = minimumValueForLength(Length(), availableHeight, true);
    1200             geometry.setSpaceSize(FloatSize(geometry.spaceSize().width(), space));
    1201             geometry.setPhaseY(actualHeight ? actualHeight - roundToInt(computedYPosition + top) % actualHeight : 0);
     1193            geometry.setSpaceSize(LayoutSize(geometry.spaceSize().width(), space));
     1194            geometry.setPhaseY(actualHeight ? actualHeight - fmodf((computedYPosition + top), actualHeight) : 0);
    12021195        } else
    12031196            backgroundRepeatY = NoRepeatFill;
    12041197    }
    12051198    if (backgroundRepeatY == NoRepeatFill) {
    1206         int yOffset = fillLayer->backgroundYOrigin() == BottomEdge ? availableHeight - computedYPosition : computedYPosition;
     1199        LayoutUnit yOffset = fillLayer->backgroundYOrigin() == BottomEdge ? availableHeight - computedYPosition : computedYPosition;
    12071200        geometry.setNoRepeatY(top + yOffset);
    1208         geometry.setSpaceSize(FloatSize(geometry.spaceSize().width(), 0));
     1201        geometry.setSpaceSize(LayoutSize(geometry.spaceSize().width(), 0));
    12091202    }
    12101203
    12111204    if (fixedAttachment)
    1212         geometry.useFixedAttachment(snappedPaintRect.location());
    1213 
    1214     geometry.clip(snappedPaintRect);
     1205        geometry.useFixedAttachment(paintRect.location());
     1206
     1207    geometry.clip(paintRect);
    12151208    geometry.setDestOrigin(geometry.destRect().location());
    1216 }
    1217 
    1218 void RenderBoxModelObject::getGeometryForBackgroundImage(const RenderLayerModelObject* paintContainer, IntRect& destRect, IntPoint& phase, IntSize& tileSize) const
     1209
     1210    pixelSnapBackgroundImageGeometryForPainting(geometry);
     1211}
     1212
     1213void RenderBoxModelObject::getGeometryForBackgroundImage(const RenderLayerModelObject* paintContainer, FloatRect& destRect, FloatPoint& phase, FloatSize& tileSize) const
    12191214{
    12201215    const FillLayer* backgroundLayer = style().backgroundLayers();
    12211216    BackgroundImageGeometry geometry;
    1222     calculateBackgroundImageGeometry(paintContainer, backgroundLayer, destRect, geometry);
     1217    LayoutRect paintRect = LayoutRect(destRect);
     1218    calculateBackgroundImageGeometry(paintContainer, backgroundLayer, paintRect, geometry);
    12231219    phase = geometry.phase();
    12241220    tileSize = geometry.tileSize();
     
    12541250    IntRect borderImageRect = pixelSnappedIntRect(rectWithOutsets);
    12551251
    1256     IntSize imageSize = calculateImageIntrinsicDimensions(styleImage, borderImageRect.size(), DoNotScaleByEffectiveZoom);
     1252    LayoutSize imageSize = calculateImageIntrinsicDimensions(styleImage, borderImageRect.size(), DoNotScaleByEffectiveZoom);
    12571253
    12581254    // If both values are ‘auto’ then the intrinsic width and/or height of the image should be used, if any.
  • trunk/Source/WebCore/rendering/RenderBoxModelObject.h

    r165689 r166784  
    184184    bool canHaveBoxInfoInRegion() const { return !isFloating() && !isReplaced() && !isInline() && !hasColumns() && !isTableCell() && isRenderBlock() && !isRenderSVGBlock(); }
    185185
    186     void getGeometryForBackgroundImage(const RenderLayerModelObject* paintContainer, IntRect& destRect, IntPoint& phase, IntSize& tileSize) const;
     186    void getGeometryForBackgroundImage(const RenderLayerModelObject* paintContainer, FloatRect& destRect, FloatPoint& phase, FloatSize& tileSize) const;
    187187    void contentChanged(ContentChangeType);
    188188    bool hasAcceleratedCompositing() const;
     
    209209            : m_hasNonLocalGeometry(false)
    210210        { }
    211         IntPoint destOrigin() const { return m_destOrigin; }
    212         void setDestOrigin(const IntPoint& destOrigin)
    213         {
    214             m_destOrigin = destOrigin;
    215         }
    216        
    217         IntRect destRect() const { return m_destRect; }
    218         void setDestRect(const IntRect& destRect)
    219         {
    220             m_destRect = destRect;
    221         }
     211        LayoutPoint destOrigin() const { return m_destOrigin; }
     212        void setDestOrigin(const LayoutPoint& destOrigin) { m_destOrigin = destOrigin; }
     213       
     214        LayoutRect destRect() const { return m_destRect; }
     215        void setDestRect(const LayoutRect& destRect) { m_destRect = destRect; }
    222216
    223217        // Returns the phase relative to the destination rectangle.
    224         IntPoint relativePhase() const;
    225        
    226         IntPoint phase() const { return m_phase; }   
    227         void setPhase(const IntPoint& phase)
    228         {
    229             m_phase = phase;
    230         }
    231 
    232         IntSize tileSize() const { return m_tileSize; }   
    233         void setTileSize(const IntSize& tileSize)
    234         {
    235             m_tileSize = tileSize;
    236         }
    237         FloatSize spaceSize() const { return m_space; }
    238         void setSpaceSize(const FloatSize& space)
    239         {
    240             m_space = space;
    241         }
    242 
    243         void setPhaseX(int x) { m_phase.setX(x); }
    244         void setPhaseY(int y) { m_phase.setY(y); }
    245        
    246         void setNoRepeatX(int xOffset);
    247         void setNoRepeatY(int yOffset);
    248        
    249         void useFixedAttachment(const IntPoint& attachmentPoint);
    250        
    251         void clip(const IntRect&);
     218        LayoutPoint relativePhase() const;
     219       
     220        LayoutPoint phase() const { return m_phase; }
     221        void setPhase(const LayoutPoint& phase) { m_phase = phase; }
     222
     223        LayoutSize tileSize() const { return m_tileSize; }
     224        void setTileSize(const LayoutSize& tileSize) { m_tileSize = tileSize; }
     225
     226        LayoutSize spaceSize() const { return m_space; }
     227        void setSpaceSize(const LayoutSize& space) { m_space = space; }
     228
     229        void setPhaseX(LayoutUnit  x) { m_phase.setX(x); }
     230        void setPhaseY(LayoutUnit y) { m_phase.setY(y); }
     231       
     232        void setNoRepeatX(LayoutUnit xOffset);
     233        void setNoRepeatY(LayoutUnit yOffset);
     234       
     235        void useFixedAttachment(const LayoutPoint& attachmentPoint);
     236       
     237        void clip(const LayoutRect&);
    252238       
    253239        void setHasNonLocalGeometry(bool hasNonLocalGeometry = true) { m_hasNonLocalGeometry = hasNonLocalGeometry; }
     
    255241
    256242    private:
    257         IntRect m_destRect;
    258         IntPoint m_destOrigin;
    259         IntPoint m_phase;
    260         IntSize m_tileSize;
    261         FloatSize m_space;
     243        LayoutRect m_destRect;
     244        LayoutPoint m_destOrigin;
     245        LayoutPoint m_phase;
     246        LayoutSize m_tileSize;
     247        LayoutSize m_space;
    262248        bool m_hasNonLocalGeometry; // Has background-attachment: fixed. Implies that we can't always cheaply compute destRect.
    263249    };
     
    314300
    315301    enum ScaleByEffectiveZoomOrNot { ScaleByEffectiveZoom, DoNotScaleByEffectiveZoom };
    316     IntSize calculateImageIntrinsicDimensions(StyleImage*, const IntSize& scaledPositioningAreaSize, ScaleByEffectiveZoomOrNot) const;
     302    LayoutSize calculateImageIntrinsicDimensions(StyleImage*, const LayoutSize& scaledPositioningAreaSize, ScaleByEffectiveZoomOrNot) const;
    317303
    318304private:
     
    321307    virtual LayoutRect frameRectForStickyPositioning() const = 0;
    322308
    323     IntSize calculateFillTileSize(const FillLayer*, const IntSize& scaledPositioningAreaSize) const;
     309    LayoutSize calculateFillTileSize(const FillLayer*, const LayoutSize& scaledPositioningAreaSize) const;
    324310
    325311    RoundedRect getBackgroundRoundedRect(const LayoutRect&, InlineFlowBox*, LayoutUnit inlineBoxWidth, LayoutUnit inlineBoxHeight,
     
    343329        Color, EBorderStyle, BackgroundBleedAvoidance, bool includeLogicalLeftEdge, bool includeLogicalRightEdge);
    344330    void paintMaskForTextFillBox(ImageBuffer*, const IntRect&, InlineFlowBox*, const LayoutRect&, RenderNamedFlowFragment*);
     331
     332    void pixelSnapBackgroundImageGeometryForPainting(BackgroundImageGeometry&) const;
    345333};
    346334
  • trunk/Source/WebCore/rendering/RenderLayerBacking.cpp

    r166566 r166784  
    16161616    }
    16171617
    1618     IntRect destRect = pixelSnappedIntRect(LayoutRect(backgroundBoxForPainting()));
    1619     IntPoint phase;
    1620     IntSize tileSize;
     1618    FloatRect destRect = backgroundBoxForPainting();
     1619    FloatPoint phase;
     1620    FloatSize tileSize;
    16211621
    16221622    RefPtr<Image> image = style.backgroundLayers()->image()->cachedImage()->image();
  • trunk/Source/WebCore/rendering/shapes/ShapeOutsideInfo.cpp

    r166752 r166784  
    138138    StyleImage* styleImage = shapeValue->image();
    139139
    140     const IntSize& imageSize = renderBox->calculateImageIntrinsicDimensions(styleImage, roundedIntSize(referenceBoxSize), RenderImage::ScaleByEffectiveZoom);
     140    const LayoutSize& imageSize = renderBox->calculateImageIntrinsicDimensions(styleImage, roundedIntSize(referenceBoxSize), RenderImage::ScaleByEffectiveZoom);
    141141    styleImage->setContainerSizeForRenderer(renderBox, imageSize, renderBox->style().effectiveZoom());
    142142
Note: See TracChangeset for help on using the changeset viewer.