Changeset 150904 in webkit


Ignore:
Timestamp:
May 29, 2013 9:54:39 AM (11 years ago)
Author:
commit-queue@webkit.org
Message:

[CSS Shapes] Support parsing inset-rectangle shapes
https://bugs.webkit.org/show_bug.cgi?id=116638

Patch by Bem Jones-Bey <Bem Jones-Bey> on 2013-05-29
Reviewed by Dean Jackson.

Source/WebCore:

Add parsing for inset-rectangle. It's very similar to parsing for
rectangle.

No new tests, updated existing tests to cover this.

  • css/BasicShapeFunctions.cpp:

(WebCore::valueForBasicShape): Add support for inset rectangles.
(WebCore::basicShapeForValue): Add support for inset rectangles.

  • css/CSSBasicShapes.cpp:

(WebCore::buildInsetRectangleString): Create an inset-rectangle css

string.

(WebCore::CSSBasicShapeInsetRectangle::cssText): Convert inset

rectangle shape to a CSS string.

(WebCore::CSSBasicShapeInsetRectangle::equals): Compare two inset

rectangles.

(WebCore::CSSBasicShapeInsetRectangle::serializeResolvingVariables):

Create an inset rectangle string, with CSS variables resolved.

(WebCore::CSSBasicShapeInsetRectangle::hasVariableReference):

Determine if this inset rectangle has any CSS Variable references.

  • css/CSSBasicShapes.h:

(CSSBasicShapeInsetRectangle): Add inset rectangle class. This is a

direct representation of the CSS property. All the methods below
are just simple getters and setters, along with a construtor and a
factory method.

(WebCore::CSSBasicShapeInsetRectangle::create):
(WebCore::CSSBasicShapeInsetRectangle::top):
(WebCore::CSSBasicShapeInsetRectangle::right):
(WebCore::CSSBasicShapeInsetRectangle::bottom):
(WebCore::CSSBasicShapeInsetRectangle::left):
(WebCore::CSSBasicShapeInsetRectangle::radiusX):
(WebCore::CSSBasicShapeInsetRectangle::radiusY):
(WebCore::CSSBasicShapeInsetRectangle::setTop):
(WebCore::CSSBasicShapeInsetRectangle::setRight):
(WebCore::CSSBasicShapeInsetRectangle::setBottom):
(WebCore::CSSBasicShapeInsetRectangle::setLeft):
(WebCore::CSSBasicShapeInsetRectangle::setRadiusX):
(WebCore::CSSBasicShapeInsetRectangle::setRadiusY):
(WebCore::CSSBasicShapeInsetRectangle::type):
(WebCore::CSSBasicShapeInsetRectangle::CSSBasicShapeInsetRectangle):
(WebCore):

  • css/CSSParser.cpp:

(WebCore::CSSParser::parseBasicShapeInsetRectangle): Parse the

inset-rectangle CSS property and create a
CSSBasicShapeInsetRectangle.

(WebCore::CSSParser::parseBasicShape): Add a call to parse

inset-rectangle.

  • rendering/ExclusionShapeInsideInfo.cpp:

(WebCore::ExclusionShapeInsideInfo::isEnabledFor): Disable

inset-rectangles, since only the parsing has been implemented so
far.

  • rendering/ExclusionShapeOutsideInfo.cpp:

(WebCore::ExclusionShapeOutsideInfo::isEnabledFor): Disable

inset-rectangles, since only the parsing has been implemented so
far.

  • rendering/style/BasicShapes.cpp:

(WebCore::BasicShapeInsetRectangle::path): Calculate the Path for an

inset-rectangle.

(WebCore::BasicShapeInsetRectangle::blend): Blend two inset rectangles

together at a point depending on the "progress" and return the
blended rectangle.

  • rendering/style/BasicShapes.h:

(BasicShapeInsetRectangle): Add higher level inset rectangle class.

This is used outside of the CSS representation. The methods below
are just simple getters and setters, along with a constructor and
a factory method.

(WebCore::BasicShapeInsetRectangle::create):
(WebCore::BasicShapeInsetRectangle::top):
(WebCore::BasicShapeInsetRectangle::right):
(WebCore::BasicShapeInsetRectangle::bottom):
(WebCore::BasicShapeInsetRectangle::left):
(WebCore::BasicShapeInsetRectangle::cornerRadiusX):
(WebCore::BasicShapeInsetRectangle::cornerRadiusY):
(WebCore::BasicShapeInsetRectangle::setTop):
(WebCore::BasicShapeInsetRectangle::setRight):
(WebCore::BasicShapeInsetRectangle::setBottom):
(WebCore::BasicShapeInsetRectangle::setLeft):
(WebCore::BasicShapeInsetRectangle::setCornerRadiusX):
(WebCore::BasicShapeInsetRectangle::setCornerRadiusY):
(WebCore::BasicShapeInsetRectangle::type):
(WebCore::BasicShapeInsetRectangle::BasicShapeInsetRectangle):

LayoutTests:

Updated to test for inset-rectangle cases.

  • fast/exclusions/parsing/parsing-shape-inside-expected.txt:
  • fast/exclusions/parsing/parsing-shape-lengths-expected.txt:
  • fast/exclusions/parsing/script-tests/parsing-shape-lengths.js:
  • fast/exclusions/parsing/script-tests/parsing-test-utils.js:
Location:
trunk
Files:
16 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r150892 r150904  
     12013-05-29  Bem Jones-Bey  <bjonesbe@adobe.com>
     2
     3        [CSS Shapes] Support parsing inset-rectangle shapes
     4        https://bugs.webkit.org/show_bug.cgi?id=116638
     5
     6        Reviewed by Dean Jackson.
     7
     8        Updated to test for inset-rectangle cases.
     9
     10        * fast/exclusions/parsing/parsing-shape-inside-expected.txt:
     11        * fast/exclusions/parsing/parsing-shape-lengths-expected.txt:
     12        * fast/exclusions/parsing/script-tests/parsing-shape-lengths.js:
     13        * fast/exclusions/parsing/script-tests/parsing-test-utils.js:
     14
    1152013-05-29  Gabor Abraham  <abrhm@inf.u-szeged.hu>
    216
  • trunk/LayoutTests/fast/exclusions/parsing/parsing-shape-inside-expected.txt

    r150542 r150904  
    1212PASS getCSSText("-webkit-shape-inside", "rectangle(10px, 20px, 30px, 40px, 5px, 10px)") is "rectangle(10px, 20px, 30px, 40px, 5px, 10px)"
    1313PASS getComputedStyleValue("-webkit-shape-inside", "rectangle(10px, 20px, 30px, 40px, 5px, 10px)") is "rectangle(10px, 20px, 30px, 40px, 5px, 10px)"
     14PASS getCSSText("-webkit-shape-inside", "inset-rectangle(10px, 20px, 30px, 40px)") is "inset-rectangle(10px, 20px, 30px, 40px)"
     15PASS getComputedStyleValue("-webkit-shape-inside", "inset-rectangle(10px, 20px, 30px, 40px)") is "inset-rectangle(10px, 20px, 30px, 40px)"
     16PASS getCSSText("-webkit-shape-inside", "inset-rectangle(10px, 20px, 30px, 40px, 5px)") is "inset-rectangle(10px, 20px, 30px, 40px, 5px)"
     17PASS getComputedStyleValue("-webkit-shape-inside", "inset-rectangle(10px, 20px, 30px, 40px, 5px)") is "inset-rectangle(10px, 20px, 30px, 40px, 5px)"
     18PASS getCSSText("-webkit-shape-inside", "inset-rectangle(10px, 20px, 30px, 40px, 5px, 10px)") is "inset-rectangle(10px, 20px, 30px, 40px, 5px, 10px)"
     19PASS getComputedStyleValue("-webkit-shape-inside", "inset-rectangle(10px, 20px, 30px, 40px, 5px, 10px)") is "inset-rectangle(10px, 20px, 30px, 40px, 5px, 10px)"
    1420PASS getCSSText("-webkit-shape-inside", "circle(10px, 20px, 30px)") is "circle(10px, 20px, 30px)"
    1521PASS getComputedStyleValue("-webkit-shape-inside", "circle(10px, 20px, 30px)") is "circle(10px, 20px, 30px)"
     
    4248PASS getCSSText("-webkit-shape-inside", "rectangle(10px, 20px, 30px, 40px, 50px, 60px, 70px)") is ""
    4349PASS getComputedStyleValue("-webkit-shape-inside", "rectangle(10px, 20px, 30px, 40px, 50px, 60px, 70px)") is "outside-shape"
     50PASS getCSSText("-webkit-shape-inside", "inset-rectangle()") is ""
     51PASS getComputedStyleValue("-webkit-shape-inside", "inset-rectangle()") is "outside-shape"
     52PASS getCSSText("-webkit-shape-inside", "inset-rectangle(10px)") is ""
     53PASS getComputedStyleValue("-webkit-shape-inside", "inset-rectangle(10px)") is "outside-shape"
     54PASS getCSSText("-webkit-shape-inside", "inset-rectangle(10px, 10px)") is ""
     55PASS getComputedStyleValue("-webkit-shape-inside", "inset-rectangle(10px, 10px)") is "outside-shape"
     56PASS getCSSText("-webkit-shape-inside", "inset-rectangle(10px, 20px, 30px)") is ""
     57PASS getComputedStyleValue("-webkit-shape-inside", "inset-rectangle(10px, 20px, 30px)") is "outside-shape"
     58PASS getCSSText("-webkit-shape-inside", "inset-rectangle(10px 20px 30px 40px)") is ""
     59PASS getComputedStyleValue("-webkit-shape-inside", "inset-rectangle(10px 20px 30px 40px)") is "outside-shape"
     60PASS getCSSText("-webkit-shape-inside", "inset-rectangle(10px, 20px, 30px, 40px, 50px, 60px, 70px)") is ""
     61PASS getComputedStyleValue("-webkit-shape-inside", "inset-rectangle(10px, 20px, 30px, 40px, 50px, 60px, 70px)") is "outside-shape"
    4462PASS getCSSText("-webkit-shape-inside", "circle()") is ""
    4563PASS getComputedStyleValue("-webkit-shape-inside", "circle()") is "outside-shape"
  • trunk/LayoutTests/fast/exclusions/parsing/parsing-shape-lengths-expected.txt

    r150542 r150904  
    99PASS getStyleValue("-webkit-shape-inside", "circle(-.5px, +.5px, .5px)") is "circle(-0.5px, 0.5px, 0.5px)"
    1010PASS getStyleValue("-webkit-shape-inside", "rectangle(1cm, 1mm, 1in, 1px, 1pt, 1pc)") is "rectangle(1cm, 1mm, 1in, 1px, 1pt, 1pc)"
     11PASS getStyleValue("-webkit-shape-inside", "inset-rectangle(1cm, 1mm, 1in, 1px, 1pt, 1pc)") is "inset-rectangle(1cm, 1mm, 1in, 1px, 1pt, 1pc)"
    1112PASS getStyleValue("-webkit-shape-inside", "circle(-1em, +1em, 1em)") is "circle(-1em, 1em, 1em)"
    1213PASS getStyleValue("-webkit-shape-inside", "circle(-1.5em, +1.5em, 1.5em)") is "circle(-1.5em, 1.5em, 1.5em)"
     
    2425PASS getStyleValue("-webkit-shape-inside", "circle(100%, 100%, 100%)") is "circle(100%, 100%, 100%)"
    2526PASS getStyleValue("-webkit-shape-inside", "rectangle(45%, 45%, 90%, 60%, 25%, 10%)") is "rectangle(45%, 45%, 90%, 60%, 25%, 10%)"
     27PASS getStyleValue("-webkit-shape-inside", "inset-rectangle(45%, 45%, 90%, 60%, 25%, 10%)") is "inset-rectangle(45%, 45%, 90%, 60%, 25%, 10%)"
    2628PASS getStyleValue("-webkit-shape-inside", "ellipse(100%, 100%, 100%, 100%)") is "ellipse(100%, 100%, 100%, 100%)"
    2729PASS getStyleValue("-webkit-shape-inside", "polygon(10% 20%, 30% 40%, 40% 50%)") is "polygon(nonzero, 10% 20%, 30% 40%, 40% 50%)"
    2830PASS getComputedStyleValue("-webkit-shape-inside", "circle(50%, 100%, 150%)") is "circle(50%, 100%, 150%)"
    2931PASS getComputedStyleValue("-webkit-shape-inside", "rectangle(45%, 45%, 90%, 60%, 25%, 10%)") is "rectangle(45%, 45%, 90%, 60%, 25%, 10%)"
     32PASS getComputedStyleValue("-webkit-shape-inside", "inset-rectangle(45%, 45%, 90%, 60%, 25%, 10%)") is "inset-rectangle(45%, 45%, 90%, 60%, 25%, 10%)"
    3033PASS getComputedStyleValue("-webkit-shape-inside", "ellipse(100%, 100%, 100%, 100%)") is "ellipse(100%, 100%, 100%, 100%)"
    3134PASS getComputedStyleValue("-webkit-shape-inside", "polygon(10% 20%, 30% 40%, 40% 50%)") is "polygon(nonzero, 10% 20%, 30% 40%, 40% 50%)"
     
    4447PASS getStyleValue("-webkit-shape-inside", "rectangle(1cm, 1mm, 1in, 1px, 1pt, -1pc)") is null
    4548PASS getComputedStyleValue("-webkit-shape-inside", "rectangle(1cm, 1mm, 1in, 1px, 1pt, -1pc)") is "outside-shape"
     49PASS getStyleValue("-webkit-shape-inside", "inset-rectangle(1cm, 1mm, 1in, 1px, -1pt, 1pc)") is null
     50PASS getComputedStyleValue("-webkit-shape-inside", "inset-rectangle(1cm, 1mm, 1in, 1px, -1pt, 1pc)") is "outside-shape"
     51PASS getStyleValue("-webkit-shape-inside", "inset-rectangle(1cm, 1mm, 1in, 1px, 1pt, -1pc)") is null
     52PASS getComputedStyleValue("-webkit-shape-inside", "inset-rectangle(1cm, 1mm, 1in, 1px, 1pt, -1pc)") is "outside-shape"
    4653PASS getStyleValue("-webkit-shape-inside", "ellipse(1em, 1em, -1em, 1em)") is null
    4754PASS getComputedStyleValue("-webkit-shape-inside", "ellipse(1em, 1em, -1em, 1em)") is "outside-shape"
     
    5259PASS getStyleValue("-webkit-shape-inside", "rectangle(1cm, 1mm, 1in, -1px, 1pt, 1pc)") is null
    5360PASS getComputedStyleValue("-webkit-shape-inside", "rectangle(1cm, 1mm, 1in, -1px, 1pt, 1pc)") is "outside-shape"
     61PASS getStyleValue("-webkit-shape-inside", "inset-rectangle(-1cm, 1mm, 1in, 1px, 1pt, 1pc)") is null
     62PASS getComputedStyleValue("-webkit-shape-inside", "inset-rectangle(-1cm, 1mm, 1in, 1px, 1pt, 1pc)") is "outside-shape"
     63PASS getStyleValue("-webkit-shape-inside", "inset-rectangle(1cm, -1mm, 1in, 1px, 1pt, 1pc)") is null
     64PASS getComputedStyleValue("-webkit-shape-inside", "inset-rectangle(1cm, -1mm, 1in, 1px, 1pt, 1pc)") is "outside-shape"
     65PASS getStyleValue("-webkit-shape-inside", "inset-rectangle(1cm, 1mm, -1in, 1px, 1pt, 1pc)") is null
     66PASS getComputedStyleValue("-webkit-shape-inside", "inset-rectangle(1cm, 1mm, -1in, 1px, 1pt, 1pc)") is "outside-shape"
     67PASS getStyleValue("-webkit-shape-inside", "inset-rectangle(1cm, 1mm, 1in, -1px, 1pt, 1pc)") is null
     68PASS getComputedStyleValue("-webkit-shape-inside", "inset-rectangle(1cm, 1mm, 1in, -1px, 1pt, 1pc)") is "outside-shape"
    5469PASS successfullyParsed is true
    5570
  • trunk/LayoutTests/fast/exclusions/parsing/parsing-shape-outside-expected.txt

    r150542 r150904  
    1212PASS getCSSText("-webkit-shape-outside", "rectangle(10px, 20px, 30px, 40px, 5px, 10px)") is "rectangle(10px, 20px, 30px, 40px, 5px, 10px)"
    1313PASS getComputedStyleValue("-webkit-shape-outside", "rectangle(10px, 20px, 30px, 40px, 5px, 10px)") is "rectangle(10px, 20px, 30px, 40px, 5px, 10px)"
     14PASS getCSSText("-webkit-shape-outside", "inset-rectangle(10px, 20px, 30px, 40px)") is "inset-rectangle(10px, 20px, 30px, 40px)"
     15PASS getComputedStyleValue("-webkit-shape-outside", "inset-rectangle(10px, 20px, 30px, 40px)") is "inset-rectangle(10px, 20px, 30px, 40px)"
     16PASS getCSSText("-webkit-shape-outside", "inset-rectangle(10px, 20px, 30px, 40px, 5px)") is "inset-rectangle(10px, 20px, 30px, 40px, 5px)"
     17PASS getComputedStyleValue("-webkit-shape-outside", "inset-rectangle(10px, 20px, 30px, 40px, 5px)") is "inset-rectangle(10px, 20px, 30px, 40px, 5px)"
     18PASS getCSSText("-webkit-shape-outside", "inset-rectangle(10px, 20px, 30px, 40px, 5px, 10px)") is "inset-rectangle(10px, 20px, 30px, 40px, 5px, 10px)"
     19PASS getComputedStyleValue("-webkit-shape-outside", "inset-rectangle(10px, 20px, 30px, 40px, 5px, 10px)") is "inset-rectangle(10px, 20px, 30px, 40px, 5px, 10px)"
    1420PASS getCSSText("-webkit-shape-outside", "circle(10px, 20px, 30px)") is "circle(10px, 20px, 30px)"
    1521PASS getComputedStyleValue("-webkit-shape-outside", "circle(10px, 20px, 30px)") is "circle(10px, 20px, 30px)"
     
    4046PASS getCSSText("-webkit-shape-outside", "rectangle(10px, 20px, 30px, 40px, 50px, 60px, 70px)") is ""
    4147PASS getComputedStyleValue("-webkit-shape-outside", "rectangle(10px, 20px, 30px, 40px, 50px, 60px, 70px)") is "auto"
     48PASS getCSSText("-webkit-shape-outside", "inset-rectangle()") is ""
     49PASS getComputedStyleValue("-webkit-shape-outside", "inset-rectangle()") is "auto"
     50PASS getCSSText("-webkit-shape-outside", "inset-rectangle(10px)") is ""
     51PASS getComputedStyleValue("-webkit-shape-outside", "inset-rectangle(10px)") is "auto"
     52PASS getCSSText("-webkit-shape-outside", "inset-rectangle(10px, 10px)") is ""
     53PASS getComputedStyleValue("-webkit-shape-outside", "inset-rectangle(10px, 10px)") is "auto"
     54PASS getCSSText("-webkit-shape-outside", "inset-rectangle(10px, 20px, 30px)") is ""
     55PASS getComputedStyleValue("-webkit-shape-outside", "inset-rectangle(10px, 20px, 30px)") is "auto"
     56PASS getCSSText("-webkit-shape-outside", "inset-rectangle(10px 20px 30px 40px)") is ""
     57PASS getComputedStyleValue("-webkit-shape-outside", "inset-rectangle(10px 20px 30px 40px)") is "auto"
     58PASS getCSSText("-webkit-shape-outside", "inset-rectangle(10px, 20px, 30px, 40px, 50px, 60px, 70px)") is ""
     59PASS getComputedStyleValue("-webkit-shape-outside", "inset-rectangle(10px, 20px, 30px, 40px, 50px, 60px, 70px)") is "auto"
    4260PASS getCSSText("-webkit-shape-outside", "circle()") is ""
    4361PASS getComputedStyleValue("-webkit-shape-outside", "circle()") is "auto"
  • trunk/LayoutTests/fast/exclusions/parsing/script-tests/parsing-shape-lengths.js

    r150542 r150904  
    3434
    3535testStyleValue("rectangle(1cm, 1mm, 1in, 1px, 1pt, 1pc)", "rectangle(1cm, 1mm, 1in, 1px, 1pt, 1pc)");
     36testStyleValue("inset-rectangle(1cm, 1mm, 1in, 1px, 1pt, 1pc)", "inset-rectangle(1cm, 1mm, 1in, 1px, 1pt, 1pc)");
    3637
    3738// font-relative lengths - number serialization, units, resolution
     
    5960testStyleValue("circle(100%, 100%, 100%)", "circle(100%, 100%, 100%)");
    6061testStyleValue("rectangle(45%, 45%, 90%, 60%, 25%, 10%)", "rectangle(45%, 45%, 90%, 60%, 25%, 10%)");
     62testStyleValue("inset-rectangle(45%, 45%, 90%, 60%, 25%, 10%)", "inset-rectangle(45%, 45%, 90%, 60%, 25%, 10%)");
    6163testStyleValue("ellipse(100%, 100%, 100%, 100%)", "ellipse(100%, 100%, 100%, 100%)");
    6264testStyleValue("polygon(10% 20%, 30% 40%, 40% 50%)", "polygon(nonzero, 10% 20%, 30% 40%, 40% 50%)");
     
    6466testComputedStyleValue("circle(50%, 100%, 150%)", "circle(50%, 100%, 150%)");
    6567testComputedStyleValue("rectangle(45%, 45%, 90%, 60%, 25%, 10%)", "rectangle(45%, 45%, 90%, 60%, 25%, 10%)");
     68testComputedStyleValue("inset-rectangle(45%, 45%, 90%, 60%, 25%, 10%)", "inset-rectangle(45%, 45%, 90%, 60%, 25%, 10%)");
    6669testComputedStyleValue("ellipse(100%, 100%, 100%, 100%)", "ellipse(100%, 100%, 100%, 100%)");
    6770testComputedStyleValue("polygon(10% 20%, 30% 40%, 40% 50%)", "polygon(nonzero, 10% 20%, 30% 40%, 40% 50%)");
     
    7780testInvalidValue("-webkit-shape-inside", "rectangle(1cm, 1mm, 1in, 1px, -1pt, 1pc)");
    7881testInvalidValue("-webkit-shape-inside", "rectangle(1cm, 1mm, 1in, 1px, 1pt, -1pc)");
     82testInvalidValue("-webkit-shape-inside", "inset-rectangle(1cm, 1mm, 1in, 1px, -1pt, 1pc)");
     83testInvalidValue("-webkit-shape-inside", "inset-rectangle(1cm, 1mm, 1in, 1px, 1pt, -1pc)");
    7984testInvalidValue("-webkit-shape-inside", "ellipse(1em, 1em, -1em, 1em)");
    8085testInvalidValue("-webkit-shape-inside", "ellipse(1em, 1em, 1em, -1em)");
     
    8388testInvalidValue("-webkit-shape-inside", "rectangle(1cm, 1mm, -1in, 1px, 1pt, 1pc)");
    8489testInvalidValue("-webkit-shape-inside", "rectangle(1cm, 1mm, 1in, -1px, 1pt, 1pc)");
     90
     91// reject negative top, right, bottom, and left
     92testInvalidValue("-webkit-shape-inside", "inset-rectangle(-1cm, 1mm, 1in, 1px, 1pt, 1pc)");
     93testInvalidValue("-webkit-shape-inside", "inset-rectangle(1cm, -1mm, 1in, 1px, 1pt, 1pc)");
     94testInvalidValue("-webkit-shape-inside", "inset-rectangle(1cm, 1mm, -1in, 1px, 1pt, 1pc)");
     95testInvalidValue("-webkit-shape-inside", "inset-rectangle(1cm, 1mm, 1in, -1px, 1pt, 1pc)");
  • trunk/LayoutTests/fast/exclusions/parsing/script-tests/parsing-test-utils.js

    r150542 r150904  
    66    "rectangle(10px, 20px, 30px, 40px, 5px)",
    77    "rectangle(10px, 20px, 30px, 40px, 5px, 10px)",
     8
     9    "inset-rectangle(10px, 20px, 30px, 40px)",
     10    "inset-rectangle(10px, 20px, 30px, 40px, 5px)",
     11    "inset-rectangle(10px, 20px, 30px, 40px, 5px, 10px)",
    812
    913    "circle(10px, 20px, 30px)",
     
    2832    "rectangle(10px 20px 30px 40px)",
    2933    "rectangle(10px, 20px, 30px, 40px, 50px, 60px, 70px)",
     34
     35    "inset-rectangle()",
     36    "inset-rectangle(10px)",
     37    "inset-rectangle(10px, 10px)",
     38    "inset-rectangle(10px, 20px, 30px)",
     39    "inset-rectangle(10px 20px 30px 40px)",
     40    "inset-rectangle(10px, 20px, 30px, 40px, 50px, 60px, 70px)",
    3041
    3142    "circle()",
  • trunk/Source/WebCore/ChangeLog

    r150901 r150904  
     12013-05-29  Bem Jones-Bey  <bjonesbe@adobe.com>
     2
     3        [CSS Shapes] Support parsing inset-rectangle shapes
     4        https://bugs.webkit.org/show_bug.cgi?id=116638
     5
     6        Reviewed by Dean Jackson.
     7
     8        Add parsing for inset-rectangle. It's very similar to parsing for
     9        rectangle.
     10
     11        No new tests, updated existing tests to cover this.
     12
     13        * css/BasicShapeFunctions.cpp:
     14        (WebCore::valueForBasicShape): Add support for inset rectangles.
     15        (WebCore::basicShapeForValue): Add support for inset rectangles.
     16        * css/CSSBasicShapes.cpp:
     17        (WebCore::buildInsetRectangleString): Create an inset-rectangle css
     18            string.
     19        (WebCore::CSSBasicShapeInsetRectangle::cssText): Convert inset
     20            rectangle shape to a CSS string.
     21        (WebCore::CSSBasicShapeInsetRectangle::equals): Compare two inset
     22            rectangles.
     23        (WebCore::CSSBasicShapeInsetRectangle::serializeResolvingVariables):
     24            Create an inset rectangle string, with CSS variables resolved.
     25        (WebCore::CSSBasicShapeInsetRectangle::hasVariableReference):
     26            Determine if this inset rectangle has any CSS Variable references.
     27        * css/CSSBasicShapes.h:
     28        (CSSBasicShapeInsetRectangle): Add inset rectangle class. This is a
     29            direct representation of the CSS property. All the methods below
     30            are just simple getters and setters, along with a construtor and a
     31            factory method.
     32        (WebCore::CSSBasicShapeInsetRectangle::create):
     33        (WebCore::CSSBasicShapeInsetRectangle::top):
     34        (WebCore::CSSBasicShapeInsetRectangle::right):
     35        (WebCore::CSSBasicShapeInsetRectangle::bottom):
     36        (WebCore::CSSBasicShapeInsetRectangle::left):
     37        (WebCore::CSSBasicShapeInsetRectangle::radiusX):
     38        (WebCore::CSSBasicShapeInsetRectangle::radiusY):
     39        (WebCore::CSSBasicShapeInsetRectangle::setTop):
     40        (WebCore::CSSBasicShapeInsetRectangle::setRight):
     41        (WebCore::CSSBasicShapeInsetRectangle::setBottom):
     42        (WebCore::CSSBasicShapeInsetRectangle::setLeft):
     43        (WebCore::CSSBasicShapeInsetRectangle::setRadiusX):
     44        (WebCore::CSSBasicShapeInsetRectangle::setRadiusY):
     45        (WebCore::CSSBasicShapeInsetRectangle::type):
     46        (WebCore::CSSBasicShapeInsetRectangle::CSSBasicShapeInsetRectangle):
     47        (WebCore):
     48        * css/CSSParser.cpp:
     49        (WebCore::CSSParser::parseBasicShapeInsetRectangle): Parse the
     50            inset-rectangle CSS property and create a
     51            CSSBasicShapeInsetRectangle.
     52        (WebCore::CSSParser::parseBasicShape): Add a call to parse
     53            inset-rectangle.
     54        * rendering/ExclusionShapeInsideInfo.cpp:
     55        (WebCore::ExclusionShapeInsideInfo::isEnabledFor): Disable
     56            inset-rectangles, since only the parsing has been implemented so
     57            far.
     58        * rendering/ExclusionShapeOutsideInfo.cpp:
     59        (WebCore::ExclusionShapeOutsideInfo::isEnabledFor): Disable
     60            inset-rectangles, since only the parsing has been implemented so
     61            far.
     62        * rendering/style/BasicShapes.cpp:
     63        (WebCore::BasicShapeInsetRectangle::path): Calculate the Path for an
     64            inset-rectangle.
     65        (WebCore::BasicShapeInsetRectangle::blend): Blend two inset rectangles
     66            together at a point depending on the "progress" and return the
     67            blended rectangle.
     68        * rendering/style/BasicShapes.h:
     69        (BasicShapeInsetRectangle): Add higher level inset rectangle class.
     70            This is used outside of the CSS representation. The methods below
     71            are just simple getters and setters, along with a constructor and
     72            a factory method.
     73        (WebCore::BasicShapeInsetRectangle::create):
     74        (WebCore::BasicShapeInsetRectangle::top):
     75        (WebCore::BasicShapeInsetRectangle::right):
     76        (WebCore::BasicShapeInsetRectangle::bottom):
     77        (WebCore::BasicShapeInsetRectangle::left):
     78        (WebCore::BasicShapeInsetRectangle::cornerRadiusX):
     79        (WebCore::BasicShapeInsetRectangle::cornerRadiusY):
     80        (WebCore::BasicShapeInsetRectangle::setTop):
     81        (WebCore::BasicShapeInsetRectangle::setRight):
     82        (WebCore::BasicShapeInsetRectangle::setBottom):
     83        (WebCore::BasicShapeInsetRectangle::setLeft):
     84        (WebCore::BasicShapeInsetRectangle::setCornerRadiusX):
     85        (WebCore::BasicShapeInsetRectangle::setCornerRadiusY):
     86        (WebCore::BasicShapeInsetRectangle::type):
     87        (WebCore::BasicShapeInsetRectangle::BasicShapeInsetRectangle):
     88
    1892013-05-29  Andreas Kling  <akling@apple.com>
    290
  • trunk/Source/WebCore/css/BasicShapeFunctions.cpp

    r148645 r150904  
    9595        break;
    9696    }
     97    case BasicShape::BASIC_SHAPE_INSET_RECTANGLE: {
     98        const BasicShapeInsetRectangle* rectangle = static_cast<const BasicShapeInsetRectangle*>(basicShape);
     99        RefPtr<CSSBasicShapeInsetRectangle> rectangleValue = CSSBasicShapeInsetRectangle::create();
     100
     101        rectangleValue->setTop(cssValuePool().createValue(rectangle->top()));
     102        rectangleValue->setRight(cssValuePool().createValue(rectangle->right()));
     103        rectangleValue->setBottom(cssValuePool().createValue(rectangle->bottom()));
     104        rectangleValue->setLeft(cssValuePool().createValue(rectangle->left()));
     105        if (!rectangle->cornerRadiusX().isUndefined()) {
     106            rectangleValue->setRadiusX(cssValuePool().createValue(rectangle->cornerRadiusX()));
     107            if (!rectangle->cornerRadiusY().isUndefined())
     108                rectangleValue->setRadiusY(cssValuePool().createValue(rectangle->cornerRadiusY()));
     109        }
     110
     111        basicShapeValue = rectangleValue.release();
     112        break;
     113    }
    97114    default:
    98115        break;
     
    162179        break;
    163180    }
     181    case CSSBasicShape::CSS_BASIC_SHAPE_INSET_RECTANGLE: {
     182        const CSSBasicShapeInsetRectangle* rectValue = static_cast<const CSSBasicShapeInsetRectangle *>(basicShapeValue);
     183        RefPtr<BasicShapeInsetRectangle> rect = BasicShapeInsetRectangle::create();
     184
     185        rect->setTop(convertToLength(style, rootStyle, rectValue->top()));
     186        rect->setRight(convertToLength(style, rootStyle, rectValue->right()));
     187        rect->setBottom(convertToLength(style, rootStyle, rectValue->bottom()));
     188        rect->setLeft(convertToLength(style, rootStyle, rectValue->left()));
     189        if (rectValue->radiusX()) {
     190            rect->setCornerRadiusX(convertToLength(style, rootStyle, rectValue->radiusX()));
     191            if (rectValue->radiusY())
     192                rect->setCornerRadiusY(convertToLength(style, rootStyle, rectValue->radiusY()));
     193        }
     194        basicShape = rect.release();
     195        break;
     196    }
    164197    default:
    165198        break;
  • trunk/Source/WebCore/css/CSSBasicShapes.cpp

    r142444 r150904  
    269269#endif
    270270
     271static String buildInsetRectangleString(const String& top, const String& right, const String& bottom, const String& left, const String& radiusX, const String& radiusY)
     272{
     273    char opening[] = "inset-rectangle(";
     274    char separator[] = ", ";
     275    StringBuilder result;
     276    // Compute the required capacity in advance to reduce allocations.
     277    result.reserveCapacity((sizeof(opening) - 1) + (5 * (sizeof(separator) - 1)) + 1 + top.length() + right.length() + bottom.length() + left.length() + radiusX.length() + radiusY.length());
     278    result.appendLiteral(opening);
     279    result.append(top);
     280    result.appendLiteral(separator);
     281    result.append(right);
     282    result.appendLiteral(separator);
     283    result.append(bottom);
     284    result.appendLiteral(separator);
     285    result.append(left);
     286    if (!radiusX.isNull()) {
     287        result.appendLiteral(separator);
     288        result.append(radiusX);
     289        if (!radiusY.isNull()) {
     290            result.appendLiteral(separator);
     291            result.append(radiusY);
     292        }
     293    }
     294    result.append(')');
     295    return result.toString();
     296}
     297
     298String CSSBasicShapeInsetRectangle::cssText() const
     299{
     300    return buildInsetRectangleString(m_top->cssText(),
     301        m_right->cssText(),
     302        m_bottom->cssText(),
     303        m_left->cssText(),
     304        m_radiusX.get() ? m_radiusX->cssText() : String(),
     305        m_radiusY.get() ? m_radiusY->cssText() : String());
     306}
     307
     308bool CSSBasicShapeInsetRectangle::equals(const CSSBasicShape& shape) const
     309{
     310    if (shape.type() != CSS_BASIC_SHAPE_INSET_RECTANGLE)
     311        return false;
     312
     313    const CSSBasicShapeInsetRectangle& other = static_cast<const CSSBasicShapeInsetRectangle&>(shape);
     314    return compareCSSValuePtr(m_top, other.m_top)
     315        && compareCSSValuePtr(m_right, other.m_right)
     316        && compareCSSValuePtr(m_bottom, other.m_bottom)
     317        && compareCSSValuePtr(m_left, other.m_left)
     318        && compareCSSValuePtr(m_radiusX, other.m_radiusX)
     319        && compareCSSValuePtr(m_radiusY, other.m_radiusY);
     320}
     321
     322#if ENABLE(CSS_VARIABLES)
     323String CSSBasicShapeInsetRectangle::serializeResolvingVariables(const HashMap<AtomicString, String>& variables) const
     324{
     325    return buildInsetRectangleString(m_top->serializeResolvingVariables(variables),
     326        m_right->serializeResolvingVariables(variables),
     327        m_bottom->serializeResolvingVariables(variables),
     328        m_left->serializeResolvingVariables(variables),
     329        m_radiusX.get() ? m_radiusX->serializeResolvingVariables(variables) : String(),
     330        m_radiusY.get() ? m_radiusY->serializeResolvingVariables(variables) : String());
     331}
     332
     333bool CSSBasicShapeInsetRectangle::hasVariableReference() const
     334{
     335    return m_top->hasVariableReference()
     336        || m_right->hasVariableReference()
     337        || m_bottom->hasVariableReference()
     338        || m_left->hasVariableReference()
     339        || (m_radiusX.get() && m_radiusX->hasVariableReference())
     340        || (m_radiusY.get() && m_radiusY->hasVariableReference());
     341}
     342#endif
     343
    271344} // namespace WebCore
    272345
  • trunk/Source/WebCore/css/CSSBasicShapes.h

    r142444 r150904  
    4545        CSS_BASIC_SHAPE_CIRCLE = 2,
    4646        CSS_BASIC_SHAPE_ELLIPSE = 3,
    47         CSS_BASIC_SHAPE_POLYGON = 4
     47        CSS_BASIC_SHAPE_POLYGON = 4,
     48        CSS_BASIC_SHAPE_INSET_RECTANGLE = 5
    4849    };
    4950
     
    102103};
    103104
     105class CSSBasicShapeInsetRectangle : public CSSBasicShape {
     106public:
     107    static PassRefPtr<CSSBasicShapeInsetRectangle> create() { return adoptRef(new CSSBasicShapeInsetRectangle); }
     108
     109    CSSPrimitiveValue* top() const { return m_top.get(); }
     110    CSSPrimitiveValue* right() const { return m_right.get(); }
     111    CSSPrimitiveValue* bottom() const { return m_bottom.get(); }
     112    CSSPrimitiveValue* left() const { return m_left.get(); }
     113    CSSPrimitiveValue* radiusX() const { return m_radiusX.get(); }
     114    CSSPrimitiveValue* radiusY() const { return m_radiusY.get(); }
     115
     116    void setTop(PassRefPtr<CSSPrimitiveValue> top) { m_top = top; }
     117    void setRight(PassRefPtr<CSSPrimitiveValue> right) { m_right = right; }
     118    void setBottom(PassRefPtr<CSSPrimitiveValue> bottom) { m_bottom = bottom; }
     119    void setLeft(PassRefPtr<CSSPrimitiveValue> left) { m_left = left; }
     120    void setRadiusX(PassRefPtr<CSSPrimitiveValue> radiusX) { m_radiusX = radiusX; }
     121    void setRadiusY(PassRefPtr<CSSPrimitiveValue> radiusY) { m_radiusY = radiusY; }
     122
     123    virtual Type type() const { return CSS_BASIC_SHAPE_INSET_RECTANGLE; }
     124    virtual String cssText() const;
     125    virtual bool equals(const CSSBasicShape&) const;
     126
     127#if ENABLE(CSS_VARIABLES)
     128    virtual String serializeResolvingVariables(const HashMap<AtomicString, String>&) const;
     129    virtual bool hasVariableReference() const;
     130#endif
     131
     132private:
     133    CSSBasicShapeInsetRectangle() { }
     134
     135    RefPtr<CSSPrimitiveValue> m_right;
     136    RefPtr<CSSPrimitiveValue> m_top;
     137    RefPtr<CSSPrimitiveValue> m_bottom;
     138    RefPtr<CSSPrimitiveValue> m_left;
     139    RefPtr<CSSPrimitiveValue> m_radiusX;
     140    RefPtr<CSSPrimitiveValue> m_radiusY;
     141};
     142
    104143class CSSBasicShapeCircle : public CSSBasicShape {
    105144public:
  • trunk/Source/WebCore/css/CSSParser.cpp

    r150791 r150904  
    51385138}
    51395139
     5140PassRefPtr<CSSBasicShape> CSSParser::parseBasicShapeInsetRectangle(CSSParserValueList* args)
     5141{
     5142    ASSERT(args);
     5143
     5144    // inset-rectangle(top, right, bottom, left, [[rx], ry])
     5145    if (args->size() != 7 && args->size() != 9 && args->size() != 11)
     5146        return 0;
     5147
     5148    RefPtr<CSSBasicShapeInsetRectangle> shape = CSSBasicShapeInsetRectangle::create();
     5149
     5150    unsigned argumentNumber = 0;
     5151    CSSParserValue* argument = args->current();
     5152    while (argument) {
     5153        Units unitFlags = FLength | FPercent | FNonNeg;
     5154        if (!validUnit(argument, unitFlags))
     5155            return 0;
     5156
     5157        RefPtr<CSSPrimitiveValue> length = createPrimitiveNumericValue(argument);
     5158        ASSERT(argumentNumber < 6);
     5159        switch (argumentNumber) {
     5160        case 0:
     5161            shape->setTop(length);
     5162            break;
     5163        case 1:
     5164            shape->setRight(length);
     5165            break;
     5166        case 2:
     5167            shape->setBottom(length);
     5168            break;
     5169        case 3:
     5170            shape->setLeft(length);
     5171            break;
     5172        case 4:
     5173            shape->setRadiusX(length);
     5174            break;
     5175        case 5:
     5176            shape->setRadiusY(length);
     5177            break;
     5178        }
     5179        argument = args->next();
     5180        if (argument) {
     5181            if (!isComma(argument))
     5182                return 0;
     5183
     5184            argument = args->next();
     5185        }
     5186        argumentNumber++;
     5187    }
     5188
     5189    if (argumentNumber < 4)
     5190        return 0;
     5191    return shape;
     5192}
     5193
    51405194PassRefPtr<CSSBasicShape> CSSParser::parseBasicShapeCircle(CSSParserValueList* args)
    51415195{
     
    53085362    else if (equalIgnoringCase(value->function->name, "polygon("))
    53095363        shape = parseBasicShapePolygon(args);
     5364    else if (equalIgnoringCase(value->function->name, "inset-rectangle("))
     5365        shape = parseBasicShapeInsetRectangle(args);
    53105366
    53115367    if (!shape)
  • trunk/Source/WebCore/css/CSSParser.h

    r150791 r150904  
    178178    PassRefPtr<CSSBasicShape> parseBasicShapeEllipse(CSSParserValueList* args);
    179179    PassRefPtr<CSSBasicShape> parseBasicShapePolygon(CSSParserValueList* args);
     180    PassRefPtr<CSSBasicShape> parseBasicShapeInsetRectangle(CSSParserValueList* args);
    180181
    181182    bool parseFont(bool important);
  • trunk/Source/WebCore/rendering/ExclusionShapeInsideInfo.cpp

    r150387 r150904  
    4747{
    4848    ExclusionShapeValue* shapeValue = renderer->style()->resolvedShapeInside();
    49     return (shapeValue && shapeValue->type() == ExclusionShapeValue::Shape) ? shapeValue->shape() : 0;
     49    if (!shapeValue || shapeValue->type() != ExclusionShapeValue::Shape)
     50        return false;
     51
     52    BasicShape* shape = shapeValue->shape();
     53    return shape && shape->type() != BasicShape::BASIC_SHAPE_INSET_RECTANGLE;
    5054}
    5155
  • trunk/Source/WebCore/rendering/ExclusionShapeOutsideInfo.cpp

    r150387 r150904  
    4040{
    4141    ExclusionShapeValue* value = box->style()->shapeOutside();
    42     return (box->isFloatingWithShapeOutside() && value->type() == ExclusionShapeValue::Shape) ? value->shape() : 0;
     42    if (!box->isFloatingWithShapeOutside() || value->type() != ExclusionShapeValue::Shape)
     43        return false;
     44
     45    BasicShape* shape = value->shape();
     46    return shape && shape->type() != BasicShape::BASIC_SHAPE_INSET_RECTANGLE;
    4347}
    4448
  • trunk/Source/WebCore/rendering/style/BasicShapes.cpp

    r134736 r150904  
    170170    return result.release();
    171171}
    172 }
     172
     173void BasicShapeInsetRectangle::path(Path& path, const FloatRect& boundingBox)
     174{
     175    ASSERT(path.isEmpty());
     176    float left = floatValueForLength(m_left, boundingBox.width());
     177    float top = floatValueForLength(m_top, boundingBox.height());
     178    path.addRoundedRect(FloatRect(left + boundingBox.x(), top + boundingBox.y(),
     179                                  std::max<float>(boundingBox.width() - left - floatValueForLength(m_right, boundingBox.width()), 0),
     180                                  std::max<float>(boundingBox.height() - top - floatValueForLength(m_bottom, boundingBox.height()), 0)),
     181                        FloatSize(m_cornerRadiusX.isUndefined() ? 0 : floatValueForLength(m_cornerRadiusX, boundingBox.width()),
     182                                  m_cornerRadiusY.isUndefined() ? 0 : floatValueForLength(m_cornerRadiusY, boundingBox.height())));
     183}
     184
     185PassRefPtr<BasicShape> BasicShapeInsetRectangle::blend(const BasicShape* other, double progress) const
     186{
     187    ASSERT(type() == other->type());
     188
     189    const BasicShapeInsetRectangle* o = static_cast<const BasicShapeInsetRectangle*>(other);
     190    RefPtr<BasicShapeInsetRectangle> result =  BasicShapeInsetRectangle::create();
     191    result->setTop(m_top.blend(o->top(), progress));
     192    result->setRight(m_right.blend(o->right(), progress));
     193    result->setBottom(m_bottom.blend(o->bottom(), progress));
     194    result->setLeft(m_left.blend(o->left(), progress));
     195    if (!m_cornerRadiusX.isUndefined() && !o->cornerRadiusX().isUndefined())
     196        result->setCornerRadiusX(m_cornerRadiusX.blend(o->cornerRadiusX(), progress));
     197    if (!m_cornerRadiusY.isUndefined() && !o->cornerRadiusY().isUndefined())
     198        result->setCornerRadiusY(m_cornerRadiusY.blend(o->cornerRadiusY(), progress));
     199    return result.release();
     200}
     201}
  • trunk/Source/WebCore/rendering/style/BasicShapes.h

    r134679 r150904  
    5050        BASIC_SHAPE_CIRCLE = 2,
    5151        BASIC_SHAPE_ELLIPSE = 3,
    52         BASIC_SHAPE_POLYGON = 4
     52        BASIC_SHAPE_POLYGON = 4,
     53        BASIC_SHAPE_INSET_RECTANGLE = 5
    5354    };
    5455
     
    176177    Vector<Length> m_values;
    177178};
     179
     180class BasicShapeInsetRectangle : public BasicShape {
     181public:
     182    static PassRefPtr<BasicShapeInsetRectangle> create() { return adoptRef(new BasicShapeInsetRectangle); }
     183
     184    Length top() const { return m_top; }
     185    Length right() const { return m_right; }
     186    Length bottom() const { return m_bottom; }
     187    Length left() const { return m_left; }
     188    Length cornerRadiusX() const { return m_cornerRadiusX; }
     189    Length cornerRadiusY() const { return m_cornerRadiusY; }
     190
     191    void setTop(Length top) { m_top = top; }
     192    void setRight(Length right) { m_right = right; }
     193    void setBottom(Length bottom) { m_bottom = bottom; }
     194    void setLeft(Length left) { m_left = left; }
     195    void setCornerRadiusX(Length radiusX) { m_cornerRadiusX = radiusX; }
     196    void setCornerRadiusY(Length radiusY) { m_cornerRadiusY = radiusY; }
     197
     198    virtual void path(Path&, const FloatRect&) OVERRIDE;
     199    virtual PassRefPtr<BasicShape> blend(const BasicShape*, double) const OVERRIDE;
     200
     201    virtual Type type() const { return BASIC_SHAPE_INSET_RECTANGLE; }
     202private:
     203    BasicShapeInsetRectangle()
     204        : m_cornerRadiusX(Undefined)
     205        , m_cornerRadiusY(Undefined)
     206    { }
     207
     208    Length m_right;
     209    Length m_top;
     210    Length m_bottom;
     211    Length m_left;
     212    Length m_cornerRadiusX;
     213    Length m_cornerRadiusY;
     214};
    178215}
    179216#endif
Note: See TracChangeset for help on using the changeset viewer.