Changeset 132731 in webkit


Ignore:
Timestamp:
Oct 27, 2012, 10:18:12 AM (13 years ago)
Author:
leviw@chromium.org
Message:

Background images can incorrectly repeat with sub-pixel layout
https://bugs.webkit.org/show_bug.cgi?id=94622

Reviewed by Emil A Eklund.

Source/WebCore:

Attempting to better match author expectations when painting tiled background images. When under
the effects of zoom with sub-pixel layout enabled, the drawn size of a rendered element can
differ depending on its location. This change looks at the size of the scaled tiled background
image size, and either ceils or floors that value depending on if tiling that value will
result in us being one pixel or less short of covering the background size. This is a heuristic,
as sub-pixel/zooming isn't specced.

Test: fast/sub-pixel/scaled-background-image.html

  • rendering/RenderBoxModelObject.cpp:

(WebCore::applySubPixelHeuristicForTileSize):
(WebCore):
(WebCore::RenderBoxModelObject::calculateFillTileSize):

LayoutTests:

  • fast/sub-pixel/scaled-background-image-expected.html: Added.
  • fast/sub-pixel/scaled-background-image.html: Added.
Location:
trunk
Files:
2 added
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r132728 r132731  
     12012-10-27  Levi Weintraub  <leviw@chromium.org>
     2
     3        Background images can incorrectly repeat with sub-pixel layout
     4        https://bugs.webkit.org/show_bug.cgi?id=94622
     5
     6        Reviewed by Emil A Eklund.
     7
     8        * fast/sub-pixel/scaled-background-image-expected.html: Added.
     9        * fast/sub-pixel/scaled-background-image.html: Added.
     10
    1112012-10-26  Balazs Kelemen  <kbalazs@webkit.org>
    212
  • trunk/Source/WebCore/ChangeLog

    r132730 r132731  
     12012-10-27  Levi Weintraub  <leviw@chromium.org>
     2
     3        Background images can incorrectly repeat with sub-pixel layout
     4        https://bugs.webkit.org/show_bug.cgi?id=94622
     5
     6        Reviewed by Emil A Eklund.
     7
     8        Attempting to better match author expectations when painting tiled background images. When under
     9        the effects of zoom with sub-pixel layout enabled, the drawn size of a rendered element can
     10        differ depending on its location. This change looks at the size of the scaled tiled background
     11        image size, and either ceils or floors that value depending on if tiling that value will
     12        result in us being one pixel or less short of covering the background size. This is a heuristic,
     13        as sub-pixel/zooming isn't specced.
     14
     15        Test: fast/sub-pixel/scaled-background-image.html
     16
     17        * rendering/RenderBoxModelObject.cpp:
     18        (WebCore::applySubPixelHeuristicForTileSize):
     19        (WebCore):
     20        (WebCore::RenderBoxModelObject::calculateFillTileSize):
     21
    1222012-10-27  Sheriff Bot  <webkit.review.bot@gmail.com>
    223
  • trunk/Source/WebCore/rendering/RenderBoxModelObject.cpp

    r131402 r132731  
    10471047}
    10481048
     1049static inline void applySubPixelHeuristicForTileSize(LayoutSize& tileSize, const IntSize& positioningAreaSize)
     1050{
     1051    tileSize.setWidth(positioningAreaSize.width() - tileSize.width() <= 1 ? tileSize.width().ceil() : tileSize.width().floor());
     1052    tileSize.setHeight(positioningAreaSize.height() - tileSize.height() <= 1 ? tileSize.height().ceil() : tileSize.height().floor());
     1053}
     1054
    10491055IntSize RenderBoxModelObject::calculateFillTileSize(const FillLayer* fillLayer, const IntSize& positioningAreaSize) const
    10501056{
     
    10571063    switch (type) {
    10581064        case SizeLength: {
    1059             int w = positioningAreaSize.width();
    1060             int h = positioningAreaSize.height();
     1065            LayoutSize tileSize = positioningAreaSize;
    10611066
    10621067            Length layerWidth = fillLayer->size().size.width();
     
    10641069
    10651070            if (layerWidth.isFixed())
    1066                 w = layerWidth.value();
     1071                tileSize.setWidth(layerWidth.value());
    10671072            else if (layerWidth.isPercent() || layerHeight.isViewportPercentage())
    1068                 w = valueForLength(layerWidth, positioningAreaSize.width(), renderView);
     1073                tileSize.setWidth(valueForLength(layerWidth, positioningAreaSize.width(), renderView));
    10691074           
    10701075            if (layerHeight.isFixed())
    1071                 h = layerHeight.value();
     1076                tileSize.setHeight(layerHeight.value());
    10721077            else if (layerHeight.isPercent() || layerHeight.isViewportPercentage())
    1073                 h = valueForLength(layerHeight, positioningAreaSize.height(), renderView);
    1074            
     1078                tileSize.setHeight(valueForLength(layerHeight, positioningAreaSize.height(), renderView));
     1079
     1080            applySubPixelHeuristicForTileSize(tileSize, positioningAreaSize);
     1081
    10751082            // If one of the values is auto we have to use the appropriate
    10761083            // scale to maintain our aspect ratio.
    10771084            if (layerWidth.isAuto() && !layerHeight.isAuto()) {
    10781085                if (imageIntrinsicSize.height())
    1079                     w = imageIntrinsicSize.width() * h / imageIntrinsicSize.height();       
     1086                    tileSize.setWidth(imageIntrinsicSize.width() * tileSize.height() / imageIntrinsicSize.height());
    10801087            } else if (!layerWidth.isAuto() && layerHeight.isAuto()) {
    10811088                if (imageIntrinsicSize.width())
    1082                     h = imageIntrinsicSize.height() * w / imageIntrinsicSize.width();
     1089                    tileSize.setHeight(imageIntrinsicSize.height() * tileSize.width() / imageIntrinsicSize.width());
    10831090            } else if (layerWidth.isAuto() && layerHeight.isAuto()) {
    10841091                // If both width and height are auto, use the image's intrinsic size.
    1085                 w = imageIntrinsicSize.width();
    1086                 h = imageIntrinsicSize.height();
     1092                tileSize = imageIntrinsicSize;
    10871093            }
    10881094           
    1089             return IntSize(max(0, w), max(0, h));
     1095            tileSize.clampNegativeToZero();
     1096            return flooredIntSize(tileSize);
    10901097        }
    10911098        case SizeNone: {
Note: See TracChangeset for help on using the changeset viewer.