Changeset 162210 in webkit


Ignore:
Timestamp:
Jan 17, 2014 12:13:33 PM (10 years ago)
Author:
betravis@adobe.com
Message:

[CSS Shapes] Basic shapes' computed position should be a horizontal and vertical offset
https://bugs.webkit.org/show_bug.cgi?id=127010

Reviewed by Rob Buis.

Source/WebCore:

This patch updates the computed position values used for blending to be a horizontal
left offset and a vertical top offset. When positions include a center, bottom, or
right position offset, it is converted to the appropriate top/left coordinate as
a calc expression. Serialized values still use the original bottom/right directions
when present, and also omit the top/left keywords where possible.

Updated parsing and animation tests.

  • css/BasicShapeFunctions.cpp:

(WebCore::valueForCenterCoordinate): Use the simplified BasicShapeCenterCoordinate,
which includes an offset and whether the direction is from the top/left or bottom/right.
(WebCore::valueForBasicShape): Ditto.
(WebCore::convertToCenterCoordinate): Ditto.
(WebCore::basicShapeForValue): Ditto.
(WebCore::floatValueForCenterCoordinate): Ditto.

  • page/animation/CSSPropertyAnimation.cpp:

(WebCore::blendFunc): Remove the RenderBox parameter, which is no longer needed.

  • rendering/style/BasicShapes.cpp:

(WebCore::BasicShapeCenterCoordinate::updateComputedLength): Calculate the computed
position offset for this center coordinate.
(WebCore::BasicShapeRectangle::blend): Remove the RenderBox parameter.
(WebCore::DeprecatedBasicShapeCircle::blend): Ditto.
(WebCore::BasicShapeCircle::blend): Ditto.
(WebCore::DeprecatedBasicShapeEllipse::blend): Ditto.
(WebCore::BasicShapeEllipse::blend): Ditto.
(WebCore::BasicShapePolygon::blend): Ditto.
(WebCore::BasicShapeInsetRectangle::blend): Ditto.
(WebCore::BasicShapeInset::blend): Ditto.

  • rendering/style/BasicShapes.h:

(WebCore::BasicShapeCenterCoordinate::BasicShapeCenterCoordinate): Simplify
BasicShapeCenterCoordinate to contain an offset and a direction. Also add a
computed length, which is an offset from the top/left direction.
(WebCore::BasicShapeCenterCoordinate::direction):
(WebCore::BasicShapeCenterCoordinate::computedLength):
(WebCore::BasicShapeCenterCoordinate::blend):

LayoutTests:

Update existing parsing and animation tests. For parsing tests, top / left keywords
are omitted whenever possible. For animation tests, animations to bottom / right
offsets will use calc values based from the top / left direction.

  • animations/resources/animation-test-helpers.js:

(parseBasicShape): Parse non-numerical arguments to the shape function.
(basicShapeParametersMatch): Match non-numerical arguments to the shape function.

  • fast/shapes/parsing/parsing-shape-inside-expected.txt: Update serialized values

to omit top / left keywords when possible.

  • fast/shapes/parsing/parsing-shape-outside-expected.txt: Update serialized values

to omit top / left keywords when possible.

  • fast/shapes/parsing/parsing-test-utils.js: Modify shape parsing test expectations.
  • fast/shapes/shape-outside-floats/shape-outside-animation-expected.txt: Ditto.
  • fast/shapes/shape-outside-floats/shape-outside-animation.html: Ditto.
Location:
trunk
Files:
12 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r162207 r162210  
     12014-01-17  Bear Travis  <betravis@adobe.com>
     2
     3        [CSS Shapes] Basic shapes' computed position should be a horizontal and vertical offset
     4        https://bugs.webkit.org/show_bug.cgi?id=127010
     5
     6        Reviewed by Rob Buis.
     7
     8        Update existing parsing and animation tests. For parsing tests, top / left keywords
     9        are omitted whenever possible. For animation tests, animations to bottom / right
     10        offsets will use calc values based from the top / left direction.
     11
     12        * animations/resources/animation-test-helpers.js:
     13        (parseBasicShape): Parse non-numerical arguments to the shape function.
     14        (basicShapeParametersMatch): Match non-numerical arguments to the shape function.
     15        * fast/shapes/parsing/parsing-shape-inside-expected.txt: Update serialized values
     16        to omit top / left keywords when possible.
     17        * fast/shapes/parsing/parsing-shape-outside-expected.txt: Update serialized values
     18        to omit top / left keywords when possible.
     19        * fast/shapes/parsing/parsing-test-utils.js: Modify shape parsing test expectations.
     20        * fast/shapes/shape-outside-floats/shape-outside-animation-expected.txt: Ditto.
     21        * fast/shapes/shape-outside-floats/shape-outside-animation.html: Ditto.
     22
    1232014-01-16  Myles C. Maxfield  <mmaxfield@apple.com>
    224
  • trunk/LayoutTests/animations/resources/animation-test-helpers.js

    r160429 r162210  
    239239    // Normalize percentage values.
    240240    for (; i < matches.length; ++i) {
    241         var param = matches[i];
    242         matches[i] = parseFloat(matches[i]);
    243         if (param.indexOf('%') != -1)
    244             matches[i] = matches[i] / 100;
     241        var param = parseFloat(matches[i]);
     242
     243        if (isNaN(param))
     244            continue;
     245
     246        if (matches[i].indexOf('%') != -1)
     247            matches[i] = param / 100;
     248        else
     249            matches[i] = param;
    245250    }
    246251
     
    314319        return false;
    315320    var i = 0;
    316     if (paramList1.shape == "polygon") {
    317         if (paramList1.params[0] != paramList2.params[0])
    318             return false; // fill-rule's don't match
    319         i++;
    320     }
    321321    for (; i < paramList1.params.length; ++i) {
    322322        var param1 = paramList1.params[i],
    323323            param2 = paramList2.params[i];
     324        if (param1 === param2)
     325            continue;
    324326        var match = isCloseEnough(param1, param2, tolerance);
    325327        if (!match)
  • trunk/LayoutTests/fast/shapes/parsing/parsing-shape-inside-expected.txt

    r161436 r162210  
    4747PASS getComputedStyleValue("-webkit-shape-inside", "circle(at right bottom)") is "circle(closest-side at 100% 100%)"
    4848PASS getCSSText("-webkit-shape-inside", "circle(10px at left top 10px)") is "circle(10px at left 0% top 10px)"
    49 PASS getComputedStyleValue("-webkit-shape-inside", "circle(10px at left top 10px)") is "circle(10px at left 0% top 10px)"
     49PASS getComputedStyleValue("-webkit-shape-inside", "circle(10px at left top 10px)") is "circle(10px at 0% 10px)"
    5050PASS getCSSText("-webkit-shape-inside", "circle(10px at top 10px left 10px)") is "circle(10px at left 10px top 10px)"
    51 PASS getComputedStyleValue("-webkit-shape-inside", "circle(10px at top 10px left 10px)") is "circle(10px at left 10px top 10px)"
     51PASS getComputedStyleValue("-webkit-shape-inside", "circle(10px at top 10px left 10px)") is "circle(10px at 10px 10px)"
    5252PASS getCSSText("-webkit-shape-inside", "circle(10px at right 10px bottom 10px)") is "circle(10px at right 10px bottom 10px)"
    5353PASS getComputedStyleValue("-webkit-shape-inside", "circle(10px at right 10px bottom 10px)") is "circle(10px at right 10px bottom 10px)"
     
    7575PASS getComputedStyleValue("-webkit-shape-inside", "ellipse(at right bottom)") is "ellipse(closest-side closest-side at 100% 100%)"
    7676PASS getCSSText("-webkit-shape-inside", "ellipse(10px at left top 10px)") is "ellipse(10px at left 0% top 10px)"
    77 PASS getComputedStyleValue("-webkit-shape-inside", "ellipse(10px at left top 10px)") is "ellipse(10px closest-side at left 0% top 10px)"
     77PASS getComputedStyleValue("-webkit-shape-inside", "ellipse(10px at left top 10px)") is "ellipse(10px closest-side at 0% 10px)"
    7878PASS getCSSText("-webkit-shape-inside", "ellipse(10px at top 10px left 10px)") is "ellipse(10px at left 10px top 10px)"
    79 PASS getComputedStyleValue("-webkit-shape-inside", "ellipse(10px at top 10px left 10px)") is "ellipse(10px closest-side at left 10px top 10px)"
     79PASS getComputedStyleValue("-webkit-shape-inside", "ellipse(10px at top 10px left 10px)") is "ellipse(10px closest-side at 10px 10px)"
    8080PASS getCSSText("-webkit-shape-inside", "ellipse(10px at right 10px bottom 10px)") is "ellipse(10px at right 10px bottom 10px)"
    8181PASS getComputedStyleValue("-webkit-shape-inside", "ellipse(10px at right 10px bottom 10px)") is "ellipse(10px closest-side at right 10px bottom 10px)"
    8282PASS getCSSText("-webkit-shape-inside", "ellipse(10px 20px at left top 10px)") is "ellipse(10px 20px at left 0% top 10px)"
    83 PASS getComputedStyleValue("-webkit-shape-inside", "ellipse(10px 20px at left top 10px)") is "ellipse(10px 20px at left 0% top 10px)"
     83PASS getComputedStyleValue("-webkit-shape-inside", "ellipse(10px 20px at left top 10px)") is "ellipse(10px 20px at 0% 10px)"
    8484PASS getCSSText("-webkit-shape-inside", "ellipse(10px 20px at top 10px left 10px)") is "ellipse(10px 20px at left 10px top 10px)"
    85 PASS getComputedStyleValue("-webkit-shape-inside", "ellipse(10px 20px at top 10px left 10px)") is "ellipse(10px 20px at left 10px top 10px)"
     85PASS getComputedStyleValue("-webkit-shape-inside", "ellipse(10px 20px at top 10px left 10px)") is "ellipse(10px 20px at 10px 10px)"
    8686PASS getCSSText("-webkit-shape-inside", "ellipse(10px 20px at right 10px bottom 10px)") is "ellipse(10px 20px at right 10px bottom 10px)"
    8787PASS getComputedStyleValue("-webkit-shape-inside", "ellipse(10px 20px at right 10px bottom 10px)") is "ellipse(10px 20px at right 10px bottom 10px)"
  • trunk/LayoutTests/fast/shapes/parsing/parsing-shape-outside-expected.txt

    r161436 r162210  
    4747PASS getComputedStyleValue("-webkit-shape-outside", "circle(at right bottom)") is "circle(closest-side at 100% 100%)"
    4848PASS getCSSText("-webkit-shape-outside", "circle(10px at left top 10px)") is "circle(10px at left 0% top 10px)"
    49 PASS getComputedStyleValue("-webkit-shape-outside", "circle(10px at left top 10px)") is "circle(10px at left 0% top 10px)"
     49PASS getComputedStyleValue("-webkit-shape-outside", "circle(10px at left top 10px)") is "circle(10px at 0% 10px)"
    5050PASS getCSSText("-webkit-shape-outside", "circle(10px at top 10px left 10px)") is "circle(10px at left 10px top 10px)"
    51 PASS getComputedStyleValue("-webkit-shape-outside", "circle(10px at top 10px left 10px)") is "circle(10px at left 10px top 10px)"
     51PASS getComputedStyleValue("-webkit-shape-outside", "circle(10px at top 10px left 10px)") is "circle(10px at 10px 10px)"
    5252PASS getCSSText("-webkit-shape-outside", "circle(10px at right 10px bottom 10px)") is "circle(10px at right 10px bottom 10px)"
    5353PASS getComputedStyleValue("-webkit-shape-outside", "circle(10px at right 10px bottom 10px)") is "circle(10px at right 10px bottom 10px)"
     
    7575PASS getComputedStyleValue("-webkit-shape-outside", "ellipse(at right bottom)") is "ellipse(closest-side closest-side at 100% 100%)"
    7676PASS getCSSText("-webkit-shape-outside", "ellipse(10px at left top 10px)") is "ellipse(10px at left 0% top 10px)"
    77 PASS getComputedStyleValue("-webkit-shape-outside", "ellipse(10px at left top 10px)") is "ellipse(10px closest-side at left 0% top 10px)"
     77PASS getComputedStyleValue("-webkit-shape-outside", "ellipse(10px at left top 10px)") is "ellipse(10px closest-side at 0% 10px)"
    7878PASS getCSSText("-webkit-shape-outside", "ellipse(10px at top 10px left 10px)") is "ellipse(10px at left 10px top 10px)"
    79 PASS getComputedStyleValue("-webkit-shape-outside", "ellipse(10px at top 10px left 10px)") is "ellipse(10px closest-side at left 10px top 10px)"
     79PASS getComputedStyleValue("-webkit-shape-outside", "ellipse(10px at top 10px left 10px)") is "ellipse(10px closest-side at 10px 10px)"
    8080PASS getCSSText("-webkit-shape-outside", "ellipse(10px at right 10px bottom 10px)") is "ellipse(10px at right 10px bottom 10px)"
    8181PASS getComputedStyleValue("-webkit-shape-outside", "ellipse(10px at right 10px bottom 10px)") is "ellipse(10px closest-side at right 10px bottom 10px)"
    8282PASS getCSSText("-webkit-shape-outside", "ellipse(10px 20px at left top 10px)") is "ellipse(10px 20px at left 0% top 10px)"
    83 PASS getComputedStyleValue("-webkit-shape-outside", "ellipse(10px 20px at left top 10px)") is "ellipse(10px 20px at left 0% top 10px)"
     83PASS getComputedStyleValue("-webkit-shape-outside", "ellipse(10px 20px at left top 10px)") is "ellipse(10px 20px at 0% 10px)"
    8484PASS getCSSText("-webkit-shape-outside", "ellipse(10px 20px at top 10px left 10px)") is "ellipse(10px 20px at left 10px top 10px)"
    85 PASS getComputedStyleValue("-webkit-shape-outside", "ellipse(10px 20px at top 10px left 10px)") is "ellipse(10px 20px at left 10px top 10px)"
     85PASS getComputedStyleValue("-webkit-shape-outside", "ellipse(10px 20px at top 10px left 10px)") is "ellipse(10px 20px at 10px 10px)"
    8686PASS getCSSText("-webkit-shape-outside", "ellipse(10px 20px at right 10px bottom 10px)") is "ellipse(10px 20px at right 10px bottom 10px)"
    8787PASS getComputedStyleValue("-webkit-shape-outside", "ellipse(10px 20px at right 10px bottom 10px)") is "ellipse(10px 20px at right 10px bottom 10px)"
  • trunk/LayoutTests/fast/shapes/parsing/parsing-test-utils.js

    r161436 r162210  
    3131    ["circle(at top left)", "circle(at 0% 0%)", "circle(closest-side at 0% 0%)"],
    3232    ["circle(at right bottom)", "circle(at 100% 100%)", "circle(closest-side at 100% 100%)"],
    33     ["circle(10px at left top 10px)", "circle(10px at left 0% top 10px)"],
    34     ["circle(10px at top 10px left 10px)", "circle(10px at left 10px top 10px)"],
     33    ["circle(10px at left top 10px)", "circle(10px at left 0% top 10px)", "circle(10px at 0% 10px)"],
     34    ["circle(10px at top 10px left 10px)", "circle(10px at left 10px top 10px)", "circle(10px at 10px 10px)"],
    3535    ["circle(10px at right 10px bottom 10px)", "circle(10px at right 10px bottom 10px)"],
    3636
     
    4747    ["ellipse(at top left)", "ellipse(at 0% 0%)", "ellipse(closest-side closest-side at 0% 0%)"],
    4848    ["ellipse(at right bottom)", "ellipse(at 100% 100%)", "ellipse(closest-side closest-side at 100% 100%)"],
    49     ["ellipse(10px at left top 10px)", "ellipse(10px at left 0% top 10px)", "ellipse(10px closest-side at left 0% top 10px)"],
    50     ["ellipse(10px at top 10px left 10px)", "ellipse(10px at left 10px top 10px)", "ellipse(10px closest-side at left 10px top 10px)"],
     49    ["ellipse(10px at left top 10px)", "ellipse(10px at left 0% top 10px)", "ellipse(10px closest-side at 0% 10px)"],
     50    ["ellipse(10px at top 10px left 10px)", "ellipse(10px at left 10px top 10px)", "ellipse(10px closest-side at 10px 10px)"],
    5151    ["ellipse(10px at right 10px bottom 10px)", "ellipse(10px at right 10px bottom 10px)", "ellipse(10px closest-side at right 10px bottom 10px)"],
    52     ["ellipse(10px 20px at left top 10px)", "ellipse(10px 20px at left 0% top 10px)"],
    53     ["ellipse(10px 20px at top 10px left 10px)", "ellipse(10px 20px at left 10px top 10px)"],
     52    ["ellipse(10px 20px at left top 10px)", "ellipse(10px 20px at left 0% top 10px)", "ellipse(10px 20px at 0% 10px)"],
     53    ["ellipse(10px 20px at top 10px left 10px)", "ellipse(10px 20px at left 10px top 10px)", "ellipse(10px 20px at 10px 10px)"],
    5454    ["ellipse(10px 20px at right 10px bottom 10px)", "ellipse(10px 20px at right 10px bottom 10px)"],
    5555
  • trunk/LayoutTests/fast/shapes/shape-outside-floats/shape-outside-animation-expected.txt

    r160770 r162210  
    2323PASS - "webkitShapeOutside" property for "circle-to-bottomright-using-keyword-box" element at 1s saw something close to: circle(35% at 75% 75%)
    2424PASS - "webkitShapeOutside" property for "circle-to-bottomright-extended-box" element at 1s saw something close to: circle(35% at 75% 75%)
    25 PASS - "webkitShapeOutside" property for "circle-to-bottomright-extended-using-keyword-box" element at 1s saw something close to: circle(35% at 70% 70%)
    26 PASS - "webkitShapeOutside" property for "circle-to-bottomright-extended-using-keyword-2-box" element at 1s saw something close to: circle(35% at 70% 70%)
     25PASS - "webkitShapeOutside" property for "circle-to-bottomright-extended-using-keyword-box" element at 1s saw something close to: circle(35% at calc((50% * 0.5) + ((100% - 10%) * 0.5)) calc((50% * 0.5) + ((100% - 20px) * 0.5)))
     26PASS - "webkitShapeOutside" property for "circle-to-bottomright-extended-using-keyword-2-box" element at 1s saw something close to: circle(35% at calc((50% * 0.5) + ((100% - 10%) * 0.5)) calc((50% * 0.5) + ((100% - 10px) * 0.5)))
    2727
  • trunk/LayoutTests/fast/shapes/shape-outside-floats/shape-outside-animation.html

    r160770 r162210  
    147147      ["circle-to-bottomright-using-keyword-anim",  1, "circle-to-bottomright-using-keyword-box", "webkitShapeOutside", "circle(35% at 75% 75%)", 0.05],
    148148      ["circle-to-bottomright-extended-anim",  1, "circle-to-bottomright-extended-box", "webkitShapeOutside", "circle(35% at 75% 75%)", 0.05],
    149       ["circle-to-bottomright-extended-using-keyword-anim",  1, "circle-to-bottomright-extended-using-keyword-box", "webkitShapeOutside", "circle(35% at 70% 70%)", 0.01],
    150       ["circle-to-bottomright-extended-using-keyword-2-anim",  1, "circle-to-bottomright-extended-using-keyword-2-box", "webkitShapeOutside", "circle(35% at 70% 70%)", 0.01],
     149      ["circle-to-bottomright-extended-using-keyword-anim",  1, "circle-to-bottomright-extended-using-keyword-box", "webkitShapeOutside", "circle(35% at calc((50% * 0.5) + ((100% - 10%) * 0.5)) calc((50% * 0.5) + ((100% - 20px) * 0.5)))", 0.01],
     150      ["circle-to-bottomright-extended-using-keyword-2-anim",  1, "circle-to-bottomright-extended-using-keyword-2-box", "webkitShapeOutside", "circle(35% at calc((50% * 0.5) + ((100% - 10%) * 0.5)) calc((50% * 0.5) + ((100% - 10px) * 0.5)))", 0.01],
    151151    ];
    152152   
  • trunk/Source/WebCore/ChangeLog

    r162208 r162210  
     12014-01-17  Bear Travis  <betravis@adobe.com>
     2
     3        [CSS Shapes] Basic shapes' computed position should be a horizontal and vertical offset
     4        https://bugs.webkit.org/show_bug.cgi?id=127010
     5
     6        Reviewed by Rob Buis.
     7
     8        This patch updates the computed position values used for blending to be a horizontal
     9        left offset and a vertical top offset. When positions include a center, bottom, or
     10        right position offset, it is converted to the appropriate top/left coordinate as
     11        a calc expression. Serialized values still use the original bottom/right directions
     12        when present, and also omit the top/left keywords where possible.
     13
     14        Updated parsing and animation tests.
     15
     16        * css/BasicShapeFunctions.cpp:
     17        (WebCore::valueForCenterCoordinate): Use the simplified BasicShapeCenterCoordinate,
     18        which includes an offset and whether the direction is from the top/left or bottom/right.
     19        (WebCore::valueForBasicShape): Ditto.
     20        (WebCore::convertToCenterCoordinate): Ditto.
     21        (WebCore::basicShapeForValue): Ditto.
     22        (WebCore::floatValueForCenterCoordinate): Ditto.
     23        * page/animation/CSSPropertyAnimation.cpp:
     24        (WebCore::blendFunc): Remove the RenderBox parameter, which is no longer needed.
     25        * rendering/style/BasicShapes.cpp:
     26        (WebCore::BasicShapeCenterCoordinate::updateComputedLength): Calculate the computed
     27        position offset for this center coordinate.
     28        (WebCore::BasicShapeRectangle::blend): Remove the RenderBox parameter.
     29        (WebCore::DeprecatedBasicShapeCircle::blend): Ditto.
     30        (WebCore::BasicShapeCircle::blend): Ditto.
     31        (WebCore::DeprecatedBasicShapeEllipse::blend): Ditto.
     32        (WebCore::BasicShapeEllipse::blend): Ditto.
     33        (WebCore::BasicShapePolygon::blend): Ditto.
     34        (WebCore::BasicShapeInsetRectangle::blend): Ditto.
     35        (WebCore::BasicShapeInset::blend): Ditto.
     36        * rendering/style/BasicShapes.h:
     37        (WebCore::BasicShapeCenterCoordinate::BasicShapeCenterCoordinate): Simplify
     38        BasicShapeCenterCoordinate to contain an offset and a direction. Also add a
     39        computed length, which is an offset from the top/left direction.
     40        (WebCore::BasicShapeCenterCoordinate::direction):
     41        (WebCore::BasicShapeCenterCoordinate::computedLength):
     42        (WebCore::BasicShapeCenterCoordinate::blend):
     43
    1442014-01-17  Alexey Proskuryakov  <ap@apple.com>
    245
  • trunk/Source/WebCore/css/BasicShapeFunctions.cpp

    r162001 r162210  
    4040namespace WebCore {
    4141
    42 static PassRefPtr<CSSPrimitiveValue> valueForCenterCoordinate(CSSValuePool& pool, const RenderStyle* style, const BasicShapeCenterCoordinate& center)
    43 {
    44     CSSValueID keyword = CSSValueInvalid;
    45     switch (center.keyword()) {
    46     case BasicShapeCenterCoordinate::None:
     42static PassRefPtr<CSSPrimitiveValue> valueForCenterCoordinate(CSSValuePool& pool, const RenderStyle* style, const BasicShapeCenterCoordinate& center, EBoxOrient orientation)
     43{
     44    if (center.direction() == BasicShapeCenterCoordinate::TopLeft)
    4745        return pool.createValue(center.length(), style);
    48     case BasicShapeCenterCoordinate::Top:
    49         keyword = CSSValueTop;
    50         break;
    51     case BasicShapeCenterCoordinate::Right:
    52         keyword = CSSValueRight;
    53         break;
    54     case BasicShapeCenterCoordinate::Bottom:
    55         keyword = CSSValueBottom;
    56         break;
    57     case BasicShapeCenterCoordinate::Left:
    58         keyword = CSSValueLeft;
    59         break;
    60     }
     46
     47    CSSValueID keyword = orientation == HORIZONTAL ? CSSValueRight : CSSValueBottom;
    6148
    6249    return pool.createValue(Pair::create(pool.createIdentifierValue(keyword), pool.createValue(center.length(), style)));
     
    113100        RefPtr<CSSBasicShapeCircle> circleValue = CSSBasicShapeCircle::create();
    114101
    115         circleValue->setCenterX(valueForCenterCoordinate(pool, style, circle->centerX()));
    116         circleValue->setCenterY(valueForCenterCoordinate(pool, style, circle->centerY()));
     102        circleValue->setCenterX(valueForCenterCoordinate(pool, style, circle->centerX(), HORIZONTAL));
     103        circleValue->setCenterY(valueForCenterCoordinate(pool, style, circle->centerY(), VERTICAL));
    117104        circleValue->setRadius(basicShapeRadiusToCSSValue(style, pool, circle->radius()));
    118105        basicShapeValue = circleValue.release();
     
    135122        RefPtr<CSSBasicShapeEllipse> ellipseValue = CSSBasicShapeEllipse::create();
    136123
    137         ellipseValue->setCenterX(valueForCenterCoordinate(pool, style, ellipse->centerX()));
    138         ellipseValue->setCenterY(valueForCenterCoordinate(pool, style, ellipse->centerY()));
     124        ellipseValue->setCenterX(valueForCenterCoordinate(pool, style, ellipse->centerX(), HORIZONTAL));
     125        ellipseValue->setCenterY(valueForCenterCoordinate(pool, style, ellipse->centerY(), VERTICAL));
    139126        ellipseValue->setRadiusX(basicShapeRadiusToCSSValue(style, pool, ellipse->radiusX()));
    140127        ellipseValue->setRadiusY(basicShapeRadiusToCSSValue(style, pool, ellipse->radiusY()));
     
    202189static BasicShapeCenterCoordinate convertToCenterCoordinate(const RenderStyle* style, const RenderStyle* rootStyle, CSSPrimitiveValue* value)
    203190{
    204     if (Pair* pair = value->getPairValue()) {
    205         BasicShapeCenterCoordinate::Keyword keyword = BasicShapeCenterCoordinate::None;
    206         switch (pair->first()->getValueID()) {
    207         case CSSValueTop:
    208             keyword = BasicShapeCenterCoordinate::Top;
    209             break;
    210         case CSSValueRight:
    211             keyword = BasicShapeCenterCoordinate::Right;
    212             break;
    213         case CSSValueBottom:
    214             keyword = BasicShapeCenterCoordinate::Bottom;
    215             break;
    216         case CSSValueLeft:
    217             keyword = BasicShapeCenterCoordinate::Left;
    218             break;
    219         default:
    220             ASSERT_NOT_REACHED();
    221             break;
    222         }
    223         return BasicShapeCenterCoordinate(keyword, convertToLength(style, rootStyle, pair->second()));
    224     }
    225 
    226     return BasicShapeCenterCoordinate(convertToLength(style, rootStyle, value));
     191    BasicShapeCenterCoordinate::Direction direction;
     192    Length offset = Length(0, Fixed);
     193
     194    CSSValueID keyword = CSSValueTop;
     195    if (!value)
     196        keyword = CSSValueCenter;
     197    else if (value->isValueID())
     198        keyword = value->getValueID();
     199    else if (Pair* pair = value->getPairValue()) {
     200        keyword = pair->first()->getValueID();
     201        offset = convertToLength(style, rootStyle, pair->second());
     202    } else
     203        offset = convertToLength(style, rootStyle, value);
     204
     205    switch (keyword) {
     206    case CSSValueTop:
     207    case CSSValueLeft:
     208        direction = BasicShapeCenterCoordinate::TopLeft;
     209        break;
     210    case CSSValueRight:
     211    case CSSValueBottom:
     212        direction = BasicShapeCenterCoordinate::BottomRight;
     213        break;
     214    case CSSValueCenter:
     215        direction = BasicShapeCenterCoordinate::TopLeft;
     216        offset = Length(50, Percent);
     217        break;
     218    default:
     219        ASSERT_NOT_REACHED();
     220        direction = BasicShapeCenterCoordinate::TopLeft;
     221        break;
     222    }
     223
     224    return BasicShapeCenterCoordinate(direction, offset);
    227225}
    228226
     
    289287        RefPtr<BasicShapeCircle> circle = BasicShapeCircle::create();
    290288
    291         if (circleValue->centerX() && circleValue->centerY()) {
    292             circle->setCenterX(convertToCenterCoordinate(style, rootStyle, circleValue->centerX()));
    293             circle->setCenterY(convertToCenterCoordinate(style, rootStyle, circleValue->centerY()));
    294         } else {
    295             circle->setCenterX(BasicShapeCenterCoordinate(Length(50, Percent)));
    296             circle->setCenterY(BasicShapeCenterCoordinate(Length(50, Percent)));
    297         }
     289        circle->setCenterX(convertToCenterCoordinate(style, rootStyle, circleValue->centerX()));
     290        circle->setCenterY(convertToCenterCoordinate(style, rootStyle, circleValue->centerY()));
    298291        circle->setRadius(cssValueToBasicShapeRadius(style, rootStyle, circleValue->radius()));
    299292
     
    317310        RefPtr<BasicShapeEllipse> ellipse = BasicShapeEllipse::create();
    318311
    319         if (ellipseValue->centerX() && ellipseValue->centerY()) {
    320             ellipse->setCenterX(convertToCenterCoordinate(style, rootStyle, ellipseValue->centerX()));
    321             ellipse->setCenterY(convertToCenterCoordinate(style, rootStyle, ellipseValue->centerY()));
    322         } else {
    323             ellipse->setCenterX(BasicShapeCenterCoordinate(Length(50, Percent)));
    324             ellipse->setCenterY(BasicShapeCenterCoordinate(Length(50, Percent)));
    325         }
     312        ellipse->setCenterX(convertToCenterCoordinate(style, rootStyle, ellipseValue->centerX()));
     313        ellipse->setCenterY(convertToCenterCoordinate(style, rootStyle, ellipseValue->centerY()));
     314
    326315        ellipse->setRadiusX(cssValueToBasicShapeRadius(style, rootStyle, ellipseValue->radiusX()));
    327316        ellipse->setRadiusY(cssValueToBasicShapeRadius(style, rootStyle, ellipseValue->radiusY()));
     
    429418{
    430419    float offset = floatValueForLength(center.length(), boxDimension);
    431     switch (center.keyword()) {
    432     case BasicShapeCenterCoordinate::None:
     420    if (center.direction() == BasicShapeCenterCoordinate::TopLeft)
    433421        return offset;
    434     case BasicShapeCenterCoordinate::Top:
    435     case BasicShapeCenterCoordinate::Left:
    436         return offset;
    437     case BasicShapeCenterCoordinate::Bottom:
    438     case BasicShapeCenterCoordinate::Right:
    439         return boxDimension - offset;
    440     }
    441 
    442     ASSERT_NOT_REACHED();
    443     return 0;
    444 }
    445 
    446 }
     422    return boxDimension - offset;
     423}
     424
     425}
  • trunk/Source/WebCore/page/animation/CSSPropertyAnimation.cpp

    r161696 r162210  
    126126}
    127127
    128 static inline PassRefPtr<ClipPathOperation> blendFunc(const AnimationBase* anim, ClipPathOperation* from, ClipPathOperation* to, double progress)
     128static inline PassRefPtr<ClipPathOperation> blendFunc(const AnimationBase*, ClipPathOperation* from, ClipPathOperation* to, double progress)
    129129{
    130130    if (!from || !to)
     
    141141        return to;
    142142
    143     ASSERT(anim->renderer()->isBox());
    144     return ShapeClipPathOperation::create(toShape->blend(fromShape, progress, *toRenderBox(anim->renderer())));
     143    return ShapeClipPathOperation::create(toShape->blend(fromShape, progress));
    145144}
    146145
    147146#if ENABLE(CSS_SHAPES)
    148 static inline PassRefPtr<ShapeValue> blendFunc(const AnimationBase* anim, ShapeValue* from, ShapeValue* to, double progress)
     147static inline PassRefPtr<ShapeValue> blendFunc(const AnimationBase*, ShapeValue* from, ShapeValue* to, double progress)
    149148{
    150149    if (!from || !to)
     
    161160        return to;
    162161
    163     ASSERT(anim->renderer()->isBox());
    164     return ShapeValue::createShapeValue(toShape->blend(fromShape, progress, *toRenderBox(anim->renderer())));
     162    return ShapeValue::createShapeValue(toShape->blend(fromShape, progress));
    165163}
    166164#endif
  • trunk/Source/WebCore/rendering/style/BasicShapes.cpp

    r161569 r162210  
    3333
    3434#include "BasicShapeFunctions.h"
     35#include "CalculationValue.h"
    3536#include "FloatRect.h"
    3637#include "LengthFunctions.h"
     
    3940
    4041namespace WebCore {
     42
     43void BasicShapeCenterCoordinate::updateComputedLength()
     44{
     45    if (m_direction == TopLeft) {
     46        m_computedLength = m_length.isUndefined() ? Length(0, Fixed) : m_length;
     47        return;
     48    }
     49    if (m_length.isUndefined()) {
     50        m_computedLength = Length(100, Percent);
     51        return;
     52    }
     53
     54    OwnPtr<CalcExpressionLength> lhs = adoptPtr(new CalcExpressionLength(Length(100, Percent)));
     55    OwnPtr<CalcExpressionLength> rhs = adoptPtr(new CalcExpressionLength(m_length));
     56    OwnPtr<CalcExpressionBinaryOperation> op = adoptPtr(new CalcExpressionBinaryOperation(lhs.release(), rhs.release(), CalcSubtract));
     57    m_computedLength = Length(CalculationValue::create(op.release(), CalculationRangeAll));
     58}
    4159
    4260bool BasicShape::canBlend(const BasicShape* other) const
     
    7492}
    7593
    76 FloatSize BasicShape::referenceBoxSize(const RenderBox& renderer) const
    77 {
    78     switch (layoutBox()) {
    79     case ContentBox:
    80         return renderer.contentBoxRect().size();
    81     case PaddingBox:
    82         return renderer.paddingBoxRect().size();
    83     case BorderBox:
    84         return renderer.size();
    85     case BoxMissing: // If <box> is not supplied, then the reference box defaults to margin-box.
    86     case MarginBox:
    87         return FloatSize(renderer.marginLeft() + renderer.width() + renderer.marginRight(),
    88             renderer.marginTop() + renderer.height() + renderer.marginBottom());
    89     case BoundingBox:
    90         break;
    91     }
    92 
    93     ASSERT_NOT_REACHED();
    94     return FloatSize();
    95 }
    96 
    97 Length BasicShapeCenterCoordinate::lengthForBlending(const FloatSize& boxSize) const
    98 {
    99     Length length = this->length();
    100     if (keyword() == Right)
    101         return Length(100 - (length.isPercent() ? length.percent() : 100.f * (length.value() / boxSize.width())), Percent);
    102     if (keyword() == Bottom)
    103         return Length(100 - (length.isPercent() ? length.percent() : 100.f * (length.value() / boxSize.height())), Percent);
    104     return length;
    105 }
    106 
    10794void BasicShapeRectangle::path(Path& path, const FloatRect& boundingBox)
    10895{
     
    122109}
    123110
    124 PassRefPtr<BasicShape> BasicShapeRectangle::blend(const BasicShape* other, double progress, const RenderBox&) const
     111PassRefPtr<BasicShape> BasicShapeRectangle::blend(const BasicShape* other, double progress) const
    125112{
    126113    ASSERT(type() == other->type());
     
    152139}
    153140
    154 PassRefPtr<BasicShape> DeprecatedBasicShapeCircle::blend(const BasicShape* other, double progress, const RenderBox&) const
     141PassRefPtr<BasicShape> DeprecatedBasicShapeCircle::blend(const BasicShape* other, double progress) const
    155142{
    156143    ASSERT(type() == other->type());
     
    194181}
    195182
    196 PassRefPtr<BasicShape> BasicShapeCircle::blend(const BasicShape* other, double progress, const RenderBox& renderer) const
     183PassRefPtr<BasicShape> BasicShapeCircle::blend(const BasicShape* other, double progress) const
    197184{
    198185    ASSERT(type() == other->type());
     
    200187    RefPtr<BasicShapeCircle> result =  BasicShapeCircle::create();
    201188
    202     FloatSize boxSize = referenceBoxSize(renderer);
    203     result->setCenterX(m_centerX.blend(o->centerX(), progress, boxSize));
    204     result->setCenterY(m_centerY.blend(o->centerY(), progress, boxSize));
     189    result->setCenterX(m_centerX.blend(o->centerX(), progress));
     190    result->setCenterY(m_centerY.blend(o->centerY(), progress));
    205191    result->setRadius(m_radius.blend(o->radius(), progress));
    206192    return result.release();
     
    222208}
    223209
    224 PassRefPtr<BasicShape> DeprecatedBasicShapeEllipse::blend(const BasicShape* other, double progress, const RenderBox&) const
     210PassRefPtr<BasicShape> DeprecatedBasicShapeEllipse::blend(const BasicShape* other, double progress) const
    225211{
    226212    ASSERT(type() == other->type());
     
    262248}
    263249
    264 PassRefPtr<BasicShape> BasicShapeEllipse::blend(const BasicShape* other, double progress, const RenderBox& renderer) const
     250PassRefPtr<BasicShape> BasicShapeEllipse::blend(const BasicShape* other, double progress) const
    265251{
    266252    ASSERT(type() == other->type());
     
    277263    }
    278264
    279     FloatSize boxSize = referenceBoxSize(renderer);
    280     result->setCenterX(m_centerX.blend(o->centerX(), progress, boxSize));
    281     result->setCenterY(m_centerY.blend(o->centerY(), progress, boxSize));
     265    result->setCenterX(m_centerX.blend(o->centerX(), progress));
     266    result->setCenterY(m_centerY.blend(o->centerY(), progress));
    282267    result->setRadiusX(m_radiusX.blend(o->radiusX(), progress));
    283268    result->setRadiusY(m_radiusY.blend(o->radiusY(), progress));
     
    303288}
    304289
    305 PassRefPtr<BasicShape> BasicShapePolygon::blend(const BasicShape* other, double progress, const RenderBox&) const
     290PassRefPtr<BasicShape> BasicShapePolygon::blend(const BasicShape* other, double progress) const
    306291{
    307292    ASSERT(type() == other->type());
     
    345330}
    346331
    347 PassRefPtr<BasicShape> BasicShapeInsetRectangle::blend(const BasicShape* other, double progress, const RenderBox&) const
     332PassRefPtr<BasicShape> BasicShapeInsetRectangle::blend(const BasicShape* other, double progress) const
    348333{
    349334    ASSERT(type() == other->type());
     
    391376}
    392377
    393 PassRefPtr<BasicShape> BasicShapeInset::blend(const BasicShape* other, double progress, const RenderBox&) const
     378PassRefPtr<BasicShape> BasicShapeInset::blend(const BasicShape* other, double progress) const
    394379{
    395380    ASSERT(type() == other->type());
  • trunk/Source/WebCore/rendering/style/BasicShapes.h

    r162139 r162210  
    6464    virtual void path(Path&, const FloatRect&) = 0;
    6565    virtual WindRule windRule() const { return RULE_NONZERO; }
    66     virtual PassRefPtr<BasicShape> blend(const BasicShape*, double, const RenderBox&) const = 0;
     66    virtual PassRefPtr<BasicShape> blend(const BasicShape*, double) const = 0;
    6767
    6868    virtual Type type() const = 0;
     
    7676    {
    7777    }
    78 
    79     FloatSize referenceBoxSize(const RenderBox&) const;
    8078
    8179private:
     
    110108
    111109    virtual void path(Path&, const FloatRect&) override;
    112     virtual PassRefPtr<BasicShape> blend(const BasicShape*, double, const RenderBox&) const override;
     110    virtual PassRefPtr<BasicShape> blend(const BasicShape*, double) const override;
    113111
    114112    virtual Type type() const override { return BasicShapeRectangleType; }
     
    126124class BasicShapeCenterCoordinate {
    127125public:
    128     enum Keyword {
    129         None,
    130         Top,
    131         Right,
    132         Bottom,
    133         Left
     126    enum Direction {
     127        TopLeft,
     128        BottomRight
    134129    };
    135     BasicShapeCenterCoordinate() : m_keyword(None), m_length(Undefined) { }
    136     explicit BasicShapeCenterCoordinate(Length length) : m_keyword(None), m_length(length) { }
    137     BasicShapeCenterCoordinate(Keyword keyword, Length length) : m_keyword(keyword), m_length(length) { }
    138     BasicShapeCenterCoordinate(const BasicShapeCenterCoordinate& other) : m_keyword(other.keyword()), m_length(other.length()) { }
    139 
    140     Keyword keyword() const { return m_keyword; }
     130
     131    BasicShapeCenterCoordinate()
     132        : m_direction(TopLeft)
     133        , m_length(Undefined)
     134    {
     135        updateComputedLength();
     136    }
     137
     138    BasicShapeCenterCoordinate(Direction direction, Length length)
     139        : m_direction(direction)
     140        , m_length(length)
     141    {
     142        updateComputedLength();
     143    }
     144
     145    BasicShapeCenterCoordinate(const BasicShapeCenterCoordinate& other)
     146        : m_direction(other.direction())
     147        , m_length(other.length())
     148        , m_computedLength(other.m_computedLength)
     149    {
     150    }
     151
     152    Direction direction() const { return m_direction; }
    141153    const Length& length() const { return m_length; }
    142     Length lengthForBlending(const FloatSize&) const;
    143 
    144     BasicShapeCenterCoordinate blend(const BasicShapeCenterCoordinate& other, double progress, const FloatSize& boxSize) const
    145     {
    146         return BasicShapeCenterCoordinate(lengthForBlending(boxSize).blend(other.lengthForBlending(boxSize), progress));
    147     }
    148 
    149 private:
    150     Keyword m_keyword;
     154    const Length& computedLength() const { return m_computedLength; }
     155
     156    BasicShapeCenterCoordinate blend(const BasicShapeCenterCoordinate& other, double progress) const
     157    {
     158        return BasicShapeCenterCoordinate(TopLeft, m_computedLength.blend(other.m_computedLength, progress));
     159    }
     160
     161private:
     162    Direction m_direction;
    151163    Length m_length;
     164    Length m_computedLength;
     165
     166    void updateComputedLength();
    152167};
    153168
     
    201216
    202217    virtual void path(Path&, const FloatRect&) override;
    203     virtual PassRefPtr<BasicShape> blend(const BasicShape*, double, const RenderBox&) const override;
     218    virtual PassRefPtr<BasicShape> blend(const BasicShape*, double) const override;
    204219
    205220    virtual Type type() const override { return BasicShapeCircleType; }
     
    225240
    226241    virtual void path(Path&, const FloatRect&) override;
    227     virtual PassRefPtr<BasicShape> blend(const BasicShape*, double, const RenderBox&) const override;
     242    virtual PassRefPtr<BasicShape> blend(const BasicShape*, double) const override;
    228243
    229244    virtual Type type() const override { return DeprecatedBasicShapeCircleType; }
     
    252267
    253268    virtual void path(Path&, const FloatRect&) override;
    254     virtual PassRefPtr<BasicShape> blend(const BasicShape*, double, const RenderBox&) const override;
     269    virtual PassRefPtr<BasicShape> blend(const BasicShape*, double) const override;
    255270
    256271    virtual Type type() const override { return BasicShapeEllipseType; }
     
    279294
    280295    virtual void path(Path&, const FloatRect&) override;
    281     virtual PassRefPtr<BasicShape> blend(const BasicShape*, double, const RenderBox&) const override;
     296    virtual PassRefPtr<BasicShape> blend(const BasicShape*, double) const override;
    282297
    283298    virtual Type type() const override { return DeprecatedBasicShapeEllipseType; }
     
    303318
    304319    virtual void path(Path&, const FloatRect&) override;
    305     virtual PassRefPtr<BasicShape> blend(const BasicShape*, double, const RenderBox&) const override;
     320    virtual PassRefPtr<BasicShape> blend(const BasicShape*, double) const override;
    306321
    307322    virtual WindRule windRule() const override { return m_windRule; }
     
    344359
    345360    virtual void path(Path&, const FloatRect&) override;
    346     virtual PassRefPtr<BasicShape> blend(const BasicShape*, double, const RenderBox&) const override;
     361    virtual PassRefPtr<BasicShape> blend(const BasicShape*, double) const override;
    347362
    348363    virtual Type type() const override { return BasicShapeInsetRectangleType; }
     
    383398
    384399    virtual void path(Path&, const FloatRect&) override;
    385     virtual PassRefPtr<BasicShape> blend(const BasicShape*, double, const RenderBox&) const override;
     400    virtual PassRefPtr<BasicShape> blend(const BasicShape*, double) const override;
    386401
    387402    virtual Type type() const override { return BasicShapeInsetType; }
Note: See TracChangeset for help on using the changeset viewer.