Changeset 149457 in webkit


Ignore:
Timestamp:
May 1, 2013 3:01:10 PM (11 years ago)
Author:
hmuller@adobe.com
Message:

[CSS Exclusions] Programmatic layout tests fail when subpixel layout is disabled
https://bugs.webkit.org/show_bug.cgi?id=115455

Source/WebCore:

First round of changes to restore platform/mac exclusion tests that started failing when
subpixel layout was turned off.

Reviewed by Dirk Schulze.

  • rendering/ExclusionPolygon.cpp:

(WebCore::appendArc): Ensure that the 3rd of 5 added vertices is in the center of the arc.
(WebCore::ExclusionPolygon::firstIncludedIntervalLogicalTop): Use ceiledLayoutUnit() for downwards-snapping first fit location.

  • rendering/ExclusionRectangle.cpp:

(WebCore::ExclusionRectangle::firstIncludedIntervalLogicalTop): Ditto.

LayoutTests:

Reviewed by Dirk Schulze.

First round of changes to restore platform/mac exclusion tests that started failing when
subpixel layout was turned off. This set of changes just restores four tests. It also revises
the subpixel-utils code to bring it into line with the most recent LayoutUnit et al changes
and to simplify its use a little.

  • fast/exclusions/resources/rounded-rectangle.js:

(simulateShape): Revised dependencies on subpixel-utils.

  • fast/exclusions/resources/simple-polygon.js:

(polygonXIntercepts): Ditto.

  • fast/exclusions/resources/subpixel-utils.js:

(SubPixelLayout.): Substantially revised, see description.

  • fast/exclusions/shape-inside/shape-inside-polygon-layout-expected.txt:
  • fast/exclusions/shape-inside/shape-inside-polygon-layout.html:
  • fast/exclusions/shape-inside/shape-inside-polygon-padding-003-expected.txt:
  • fast/exclusions/shape-inside/shape-inside-polygon-padding-003.html:
  • fast/exclusions/shape-inside/shape-inside-rounded-rectangle-fit-002-expected.html:
  • fast/exclusions/shape-outside-floats/shape-outside-floats-diamond-margin-polygon-expected.txt:
  • fast/exclusions/shape-outside-floats/shape-outside-floats-diamond-margin-polygon.html:
  • fast/exclusions/shape-outside-floats/shape-outside-floats-ellipse-margin-left-expected.txt:
  • fast/exclusions/shape-outside-floats/shape-outside-floats-ellipse-margin-left.html:
  • fast/exclusions/shape-outside-floats/shape-outside-floats-ellipse-margin-right-expected.txt:
  • fast/exclusions/shape-outside-floats/shape-outside-floats-ellipse-margin-right.html:
  • platform/mac/TestExpectations:
Location:
trunk
Files:
19 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r149450 r149457  
     12013-05-01  Hans Muller  <hmuller@adobe.com>
     2
     3        [CSS Exclusions] Programmatic layout tests fail when subpixel layout is disabled
     4        https://bugs.webkit.org/show_bug.cgi?id=115455
     5
     6        Reviewed by Dirk Schulze.
     7
     8        First round of changes to restore platform/mac exclusion tests that started failing when
     9        subpixel layout was turned off. This set of changes just restores four tests. It also revises
     10        the subpixel-utils code to bring it into line with the most recent LayoutUnit et al changes
     11        and to simplify its use a little.
     12
     13        * fast/exclusions/resources/rounded-rectangle.js:
     14        (simulateShape): Revised dependencies on subpixel-utils.
     15        * fast/exclusions/resources/simple-polygon.js:
     16        (polygonXIntercepts): Ditto.
     17        * fast/exclusions/resources/subpixel-utils.js:
     18        (SubPixelLayout.): Substantially revised, see description.
     19        * fast/exclusions/shape-inside/shape-inside-polygon-layout-expected.txt:
     20        * fast/exclusions/shape-inside/shape-inside-polygon-layout.html:
     21        * fast/exclusions/shape-inside/shape-inside-polygon-padding-003-expected.txt:
     22        * fast/exclusions/shape-inside/shape-inside-polygon-padding-003.html:
     23        * fast/exclusions/shape-inside/shape-inside-rounded-rectangle-fit-002-expected.html:
     24        * fast/exclusions/shape-outside-floats/shape-outside-floats-diamond-margin-polygon-expected.txt:
     25        * fast/exclusions/shape-outside-floats/shape-outside-floats-diamond-margin-polygon.html:
     26        * fast/exclusions/shape-outside-floats/shape-outside-floats-ellipse-margin-left-expected.txt:
     27        * fast/exclusions/shape-outside-floats/shape-outside-floats-ellipse-margin-left.html:
     28        * fast/exclusions/shape-outside-floats/shape-outside-floats-ellipse-margin-right-expected.txt:
     29        * fast/exclusions/shape-outside-floats/shape-outside-floats-ellipse-margin-right.html:
     30        * platform/mac/TestExpectations:
     31
    1322013-05-01  Enrica Casucci  <enrica@apple.com>
    233
  • trunk/LayoutTests/fast/exclusions/resources/rounded-rectangle.js

    r148975 r149457  
    9696        var paddingLeft = document.createElement("div");
    9797        paddingLeft.setAttribute("class", "float left");
    98         paddingLeft.style.width = SubPixelLayout.roundLineLeft(dimensions.shapeX + inset) + "px";
     98        paddingLeft.style.width = SubPixelLayout.snapToLayoutUnit(dimensions.shapeX + inset) + "px";
    9999        element.appendChild(paddingLeft);
    100100
    101101        var paddingRight = document.createElement("div");
    102102        paddingRight.setAttribute("class", "float right");
    103         paddingRight.style.width = SubPixelLayout.roundLineRight((dimensions.width - dimensions.shapeWidth - dimensions.shapeX) + inset) + "px";
     103        paddingRight.style.width = SubPixelLayout.snapToLayoutUnit((dimensions.width - dimensions.shapeWidth - dimensions.shapeX) + inset) + "px";
    104104        element.appendChild(paddingRight);
    105105    }
  • trunk/LayoutTests/fast/exclusions/resources/simple-polygon.js

    r133384 r149457  
    9090        return [];
    9191
    92     return [SubPixelLayout.roundLineLeft(interceptsMinX), SubPixelLayout.roundLineRight(interceptsMaxX)];
     92    return [SubPixelLayout.snapToLayoutUnit(interceptsMinX), SubPixelLayout.snapTolayoutUnit(interceptsMaxX)];
    9393}
    9494
  • trunk/LayoutTests/fast/exclusions/resources/subpixel-utils.js

    r147249 r149457  
    11var SubPixelLayout = (function() {
    2     var _subPixelLayout = null;
    3     function initSubPixelLayout() {
    4         var elem = document.createElement('div');
    5         elem.style.setProperty('width', '4.5px');
    6         document.body.appendChild(elem);
    7         var bounds = elem.getBoundingClientRect();
    8         _subPixelLayout =  (bounds.width != Math.floor(bounds.width));
    9         document.body.removeChild(elem);
     2    var enabled = undefined;
     3
     4    function isEnabled()
     5    {
     6        if (enabled === undefined) {
     7            var elem = document.createElement('div');
     8            elem.style.setProperty('width', '4.5px');
     9            document.body.appendChild(elem);
     10            var bounds = elem.getBoundingClientRect();
     11            enabled = (bounds.width != Math.floor(bounds.width));
     12            document.body.removeChild(elem);
     13        }
     14        return enabled;
    1015    }
    11     document.addEventListener('DOMContentLoaded', initSubPixelLayout);
     16
    1217    return {
    13         initSubPixelLayout: initSubPixelLayout,
    14         roundLineLeft: function(f) {
    15             if (!_subPixelLayout)
    16                 return Math.floor(f);
    17             return Math.floor((Math.floor(f * 64) + 32) / 64); // see FractionLayoutUnit::round()
     18        isEnabled: isEnabled,
     19        snapToLayoutUnit: function(f) {
     20            return isEnabled() ? Math.floor(f * 64) / 64 : Math.floor(f); // as in LayoutUnit(f).toFloat()
    1821        },
    19         roundLineRight: function(f) {
    20             if (!_subPixelLayout)
    21                 return Math.floor(f);
    22             return Math.floor(Math.floor(f * 64) / 64); // see FractionLayoutUnit::floor()
    23         },
    24         isSubPixelLayoutEnabled: function() {
    25             return _subPixelLayout;
     22        ceilSnapToLayoutUnit: function(f) {
     23            return isEnabled() ? Math.ceil(f * 64) / 64 : Math.ceil(f); // see ceiledLayoutUnit(), LayoutUnit.h
    2624        }
    2725    }
  • trunk/LayoutTests/fast/exclusions/shape-inside/shape-inside-polygon-layout-expected.txt

    r148582 r149457  
    33X
    44X
    5 PASS shapeInsideRect('a').top is 7
    6 PASS shapeInsideRect('b').top is 22
    7 PASS shapeInsideRect('c').top is 37
    8 PASS shapeInsideRect('d').top is 52
    95
  • trunk/LayoutTests/fast/exclusions/shape-inside/shape-inside-polygon-layout.html

    r148582 r149457  
    33<head>
    44<script src="../../js/resources/js-test-pre.js"></script>
     5<script src="../resources/subpixel-utils.js"></script>
    56<script>
    67    if (window.internals)
     
    4849  }
    4950
    50   /* Verify that all four one-character lines are vertically adjacent and 15 pixels high. */
    51   shouldBe("shapeInsideRect('a').top", "7");
    52   shouldBe("shapeInsideRect('b').top", "22");
    53   shouldBe("shapeInsideRect('c').top", "37");
    54   shouldBe("shapeInsideRect('d').top", "52");
     51  // The top of the polygon is a horzontal edge at y=1.42%, and its parent's height is 500px.  The top of
     52  // the first line, span "a", will align with the top of the polygon. The ExclusionShape::firstIncludedIntervalLogicalTop()
     53  // methods use ceiledLayoutUnit() to ensure that their return value is within the shape.
     54  var lineATop = SubPixelLayout.ceilSnapToLayoutUnit(.0142 * 500);
     55
     56  // Verify that all four one-character lines are vertically adjacent and 15 pixels high.
     57  var quiet = true; // PASS output depends on SubPixelLayout.isEnabled()
     58  shouldBe("shapeInsideRect('a').top", String(lineATop), quiet);
     59  shouldBe("shapeInsideRect('b').top", String(lineATop + 15), quiet);
     60  shouldBe("shapeInsideRect('c').top", String(lineATop + 30), quiet);
     61  shouldBe("shapeInsideRect('d').top", String(lineATop + 45), quiet);
    5562</script>
    5663</html>
    57 
  • trunk/LayoutTests/fast/exclusions/shape-inside/shape-inside-polygon-padding-003-expected.txt

    r147111 r149457  
    55XXX
    66PASS shapeInsideRect('a').top is 50
    7 PASS shapeInsideRect('a').left is within 1 of 190.215
    87PASS shapeInsideRect('a').width is 150
    98PASS shapeInsideRect('b').top is 150
     
    1110PASS shapeInsideRect('b').width is 100
    1211PASS shapeInsideRect('c').top is 250
    13 PASS shapeInsideRect('c').left is within 1 of 190.215
    1412PASS shapeInsideRect('c').width is 150
    1513
  • trunk/LayoutTests/fast/exclusions/shape-inside/shape-inside-polygon-padding-003.html

    r147111 r149457  
    33<head>
    44<script src="../../js/resources/js-test-pre.js"></script>
     5<script src="../resources/subpixel-utils.js"></script>
    56<script>
    67    if (window.internals)
     
    7172  */
    7273
     74  var quiet = true; // PASS output depends on SubPixelLayout.isEnabled()
     75
    7376  shouldBe("shapeInsideRect('a').top", "50");
    74   shouldBeCloseTo("shapeInsideRect('a').left", 190.215, 1);
     77  shouldBeCloseTo("shapeInsideRect('a').left", SubPixelLayout.snapToLayoutUnit(190.215), 1, quiet);
    7578  shouldBe("shapeInsideRect('a').width", "150");
    7679
     
    8083
    8184  shouldBe("shapeInsideRect('c').top", "250");
    82   shouldBeCloseTo("shapeInsideRect('c').left", 190.215, 1);
     85  shouldBeCloseTo("shapeInsideRect('c').left", SubPixelLayout.snapToLayoutUnit(190.215), 1, quiet);
    8386  shouldBe("shapeInsideRect('c').width", "150");
    8487</script>
  • trunk/LayoutTests/fast/exclusions/shape-inside/shape-inside-rounded-rectangle-fit-002-expected.html

    r137518 r149457  
    4848<script>
    4949    function init() {
    50         if (!SubPixelLayout.isSubPixelLayoutEnabled())
     50        if (!SubPixelLayout.isEnabled())
    5151            document.getElementById("shape-inside").style.top = "30px";
    5252    }
  • trunk/LayoutTests/fast/exclusions/shape-outside-floats/shape-outside-floats-diamond-margin-polygon-expected.txt

    r147831 r149457  
     1X
     2X
     3X
     4
     5X
     6X
     7X
    18PASS elementRect('l1').top is 0
    29PASS elementRect('l1').left is within 1 of 98
     
    1118PASS elementRect('l6').top is 120
    1219PASS elementRect('l6').left is within 1 of 98
    13 X
    14 X
    15 X
    1620
    17 X
    18 X
    19 X
  • trunk/LayoutTests/fast/exclusions/shape-outside-floats/shape-outside-floats-diamond-margin-polygon.html

    r147831 r149457  
    1313    font: 20px/1 Ahem, sans-serif;
    1414    width: 200px;
    15     height: 300px;
     15    height: 150px;
    1616  }
    1717
     
    2626#svg-shape {
    2727    position: absolute;
    28     display:block;
     28    display: block;
     29    top: 0px;
     30    left: 0px;
    2931    width: 100px;
    3032    height: 100px;
    3133}
    3234</style>
    33 
    3435<body>
    35 <p></p>
    3636<div id="container">
    3737    <div id="float-left">
     
    4242    <span id="l1">X</span></br><span id="l2">X</span><br/><span id="l3">X</span><br/><br/><span id="l4">X</span><br/><span id="l5">X</span><br/><span id="l6">X</span>
    4343</div>
     44<div id="console"></div>
    4445</body>
    4546<script>
     
    5960function marginLeftXIntercept(lineNumber)
    6061{
    61     return SubPixelLayout.roundLineLeft(lineNumber * 20 + 20 * Math.sqrt(2) + 50);
     62    return SubPixelLayout.snapToLayoutUnit(lineNumber * 20 + 20 * Math.sqrt(2) + 50);
    6263}
     64
     65var quiet = true; // PASS output depends on SubPixelLayout.isEnabled()
    6366
    6467shouldBe("elementRect('l1').top", "0");
  • trunk/LayoutTests/fast/exclusions/shape-outside-floats/shape-outside-floats-ellipse-margin-left-expected.txt

    r147384 r149457  
    1 PASS elementRect('s1').top is 0
    2 PASS elementRect('s1').left is 347
    3 PASS elementRect('s2').top is 20
    4 PASS elementRect('s2').left is 390
    5 PASS elementRect('s3').top is 40
    6 PASS elementRect('s3').left is 417
    71The left edges of the three black squares should follow the outer ellipse boundary and each square should appear on a subsequent line.
    82
     
    104X
    115X
     6PASS elementRect('s1').top is 0
     7PASS elementRect('s2').top is 20
     8PASS elementRect('s3').top is 40
     9
  • trunk/LayoutTests/fast/exclusions/shape-outside-floats/shape-outside-floats-ellipse-margin-left.html

    r147384 r149457  
    5353    </div>
    5454</div>
     55<div id="console"></div>
    5556</body>
    5657<script>
     
    6768function marginEllipseLeftXIntercept(y, cx, rx, ry)
    6869{
    69     return String( SubPixelLayout.roundLineLeft(cx + rx * Math.sqrt(1 - Math.pow((ry - y) / ry, 2))) );
     70    return String( SubPixelLayout.snapToLayoutUnit(cx + rx * Math.sqrt(1 - Math.pow((ry - y) / ry, 2))) );
    7071}
    7172
     
    7374// That's why the Y coordinate in each of those tests is 20 greater than the ".top" test.
    7475
    75 SubPixelLayout.initSubPixelLayout();
     76var quiet = true; // PASS output depends on SubPixelLayout.isEnabled()
    7677
    7778shouldBe("elementRect('s1').top", "0");
    78 shouldBe("elementRect('s1').left", marginEllipseLeftXIntercept(20, 225, 225, 125));
     79shouldBe("elementRect('s1').left", marginEllipseLeftXIntercept(20, 225, 225, 125), quiet);
    7980
    8081shouldBe("elementRect('s2').top", "20");
    81 shouldBe("elementRect('s2').left", marginEllipseLeftXIntercept(40, 225, 225, 125));
     82shouldBe("elementRect('s2').left", marginEllipseLeftXIntercept(40, 225, 225, 125), quiet);
    8283
    8384shouldBe("elementRect('s3').top", "40");
    84 shouldBe("elementRect('s3').left", marginEllipseLeftXIntercept(60, 225, 225, 125));
     85shouldBe("elementRect('s3').left", marginEllipseLeftXIntercept(60, 225, 225, 125), quiet);
    8586
    8687</script>
  • trunk/LayoutTests/fast/exclusions/shape-outside-floats/shape-outside-floats-ellipse-margin-right-expected.txt

    r147384 r149457  
    1 PASS elementRect('s1').top is 0
    2 PASS elementRect('s1').right is 152
    3 PASS elementRect('s2').top is 20
    4 PASS elementRect('s2').right is 110
    5 PASS elementRect('s3').top is 40
    6 PASS elementRect('s3').right is 82
    71The right edges of the three black squares should follow the outer ellipse boundary and each square should appear on a subsequent line.
    82
     
    104X
    115X
     6PASS elementRect('s1').top is 0
     7PASS elementRect('s2').top is 20
     8PASS elementRect('s3').top is 40
     9
  • trunk/LayoutTests/fast/exclusions/shape-outside-floats/shape-outside-floats-ellipse-margin-right.html

    r147384 r149457  
    5454    </div>
    5555</div>
     56<div id="console"></div>
    5657</body>
    5758<script>
     
    6970{
    7071    var containerWidth = document.getElementById("container").getBoundingClientRect().width;
    71     return String( SubPixelLayout.roundLineRight(containerWidth - (cx + rx * Math.sqrt(1 - Math.pow((ry - y) / ry, 2)))) );
     72    return String( SubPixelLayout.snapToLayoutUnit(containerWidth - (cx + rx * Math.sqrt(1 - Math.pow((ry - y) / ry, 2)))) );
    7273}
    7374
     
    7576// That's why the Y coordinate in each of those tests is 20 greater than the ".top" test.
    7677
    77 SubPixelLayout.initSubPixelLayout();
     78var quiet = true; // PASS output depends on SubPixelLayout.isEnabled()
    7879
    7980shouldBe("elementRect('s1').top", "0");
    80 shouldBe("elementRect('s1').right", marginEllipseRightXIntercept(20, 225, 225, 125));
     81shouldBe("elementRect('s1').right", marginEllipseRightXIntercept(20, 225, 225, 125), quiet);
    8182
    8283shouldBe("elementRect('s2').top", "20");
    83 shouldBe("elementRect('s2').right", marginEllipseRightXIntercept(40, 225, 225, 125));
     84shouldBe("elementRect('s2').right", marginEllipseRightXIntercept(40, 225, 225, 125), quiet);
    8485
    8586shouldBe("elementRect('s3').top", "40");
    86 shouldBe("elementRect('s3').right", marginEllipseRightXIntercept(60, 225, 225, 125));
     87shouldBe("elementRect('s3').right", marginEllipseRightXIntercept(60, 225, 225, 125), quiet);
    8788
    8889</script>
  • trunk/LayoutTests/platform/mac/TestExpectations

    r149382 r149457  
    15181518webkit.org/b/115292 fast/exclusions/shape-inside/shape-inside-ellipse-padding.html
    15191519webkit.org/b/115292 fast/exclusions/shape-inside/shape-inside-ellipse.html
    1520 webkit.org/b/115292 fast/exclusions/shape-inside/shape-inside-polygon-layout.html
    15211520webkit.org/b/115292 fast/exclusions/shape-inside/shape-inside-polygon-padding-002.html
    1522 webkit.org/b/115292 fast/exclusions/shape-inside/shape-inside-polygon-padding-003.html
    1523 webkit.org/b/115292 fast/exclusions/shape-inside/shape-inside-rounded-rectangle-fit-002.html
    1524 webkit.org/b/115292 fast/exclusions/shape-outside-floats/shape-outside-floats-diamond-margin-polygon.html
    1525 webkit.org/b/115292 fast/exclusions/shape-outside-floats/shape-outside-floats-ellipse-margin-left.html
    15261521webkit.org/b/115292 fast/exclusions/shape-outside-floats/shape-outside-floats-non-zero-y.html
    15271522webkit.org/b/115292 fast/exclusions/shape-outside-floats/shape-outside-floats-simple-circle.html
  • trunk/Source/WebCore/ChangeLog

    r149450 r149457  
     12013-05-01  Hans Muller  <hmuller@adobe.com>
     2        [CSS Exclusions] Programmatic layout tests fail when subpixel layout is disabled
     3        https://bugs.webkit.org/show_bug.cgi?id=115455
     4
     5        First round of changes to restore platform/mac exclusion tests that started failing when
     6        subpixel layout was turned off.
     7
     8        Reviewed by Dirk Schulze.
     9
     10        * rendering/ExclusionPolygon.cpp:
     11        (WebCore::appendArc): Ensure that the 3rd of 5 added vertices is in the center of the arc.
     12        (WebCore::ExclusionPolygon::firstIncludedIntervalLogicalTop): Use ceiledLayoutUnit() for downwards-snapping first fit location.
     13        * rendering/ExclusionRectangle.cpp:
     14        (WebCore::ExclusionRectangle::firstIncludedIntervalLogicalTop): Ditto.
     15
    1162013-05-01  Enrica Casucci  <enrica@apple.com>
    217
  • trunk/Source/WebCore/rendering/ExclusionPolygon.cpp

    r149226 r149457  
    119119        endAngle += twoPI;
    120120    float angle = (startAngle > endAngle) ? (startAngle - endAngle) : (startAngle + twoPI - endAngle);
    121     const float arcSegmentCount = 5; // An odd number so that one arc vertex will be eactly arcRadius from arcCenter.
    122     float angle5 =  ((padding) ? -angle : twoPI - angle) / arcSegmentCount;
     121    const float arcSegmentCount = 6; // An even number so that one arc vertex will be eactly arcRadius from arcCenter.
     122    float arcSegmentAngle =  ((padding) ? -angle : twoPI - angle) / arcSegmentCount;
    123123
    124124    vertices.append(startArcVertex);
    125125    for (unsigned i = 1; i < arcSegmentCount; ++i) {
    126         float angle = startAngle + angle5 * i;
     126        float angle = startAngle + arcSegmentAngle * i;
    127127        vertices.append(arcCenter + FloatPoint(cos(angle) * arcRadius, sin(angle) * arcRadius));
    128128    }
     
    506506
    507507    if (firstFitFound)
    508         result = LayoutUnit::fromFloatCeil(firstFitRect.y());
     508        result = ceiledLayoutUnit(firstFitRect.y());
    509509    return firstFitFound;
    510510}
  • trunk/Source/WebCore/rendering/ExclusionRectangle.cpp

    r149226 r149457  
    214214        }
    215215        if (minIntervalHeight < bounds.height() - (2 * cornerIntercept.y())) {
    216             result = LayoutUnit::fromFloatCeil(bounds.y() + cornerIntercept.y());
     216            result = ceiledLayoutUnit(bounds.y() + cornerIntercept.y());
    217217            return true;
    218218        }
Note: See TracChangeset for help on using the changeset viewer.