Changeset 245276 in webkit


Ignore:
Timestamp:
May 14, 2019 7:02:50 AM (5 years ago)
Author:
jh718.park@samsung.com
Message:

Implement page-break-* and -webkit-column-break-* as legacy-shorthands.
https://bugs.webkit.org/show_bug.cgi?id=197656

LayoutTests/imported/w3c:

Reviewed by Darin Adler.

According to https://drafts.csswg.org/css-cascade-4/#legacy-shorthand,
implement page-break-* and -webkit-column-break-* as legacy-shorthands for break-*.

This change also serialize page-break-* properties
to CSSStyleDeclaration,
per https://drafts.csswg.org/css-break/#page-break-properties.

  • web-platform-tests/css/cssom/serialize-values-expected.txt:

Source/WebCore:

Reviewed by Darin Adler.

According to https://drafts.csswg.org/css-cascade-4/#legacy-shorthand,
implement page-break-* and -webkit-column-break-* as legacy-shorthands for break-*.

This change also serialize page-break-* properties
to CSSStyleDeclaration,
per https://drafts.csswg.org/css-break/#page-break-properties.

  • css/CSSProperties.json:
  • css/StyleBuilderConverter.h:

(WebCore::StyleBuilderConverter::convertFontSynthesis):
(WebCore::StyleBuilderConverter::convertPageBreakBetween): Deleted.
(WebCore::StyleBuilderConverter::convertPageBreakInside): Deleted.
(WebCore::StyleBuilderConverter::convertColumnBreakBetween): Deleted.
(WebCore::StyleBuilderConverter::convertColumnBreakInside): Deleted.

  • css/StyleProperties.cpp:

(WebCore::StyleProperties::getPropertyValue const):
(WebCore::StyleProperties::pageBreakPropertyValue const):

  • css/StyleProperties.h:
  • css/parser/CSSPropertyParser.cpp:

(WebCore::CSSPropertyParser::parseValueStart):
(WebCore::mapFromPageBreakBetween):
(WebCore::CSSPropertyParser::parseShorthand):
(WebCore::isLegacyBreakProperty): Deleted.

Location:
trunk
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/imported/w3c/ChangeLog

    r245275 r245276  
     12019-05-14  Joonghun Park  <jh718.park@samsung.com>
     2
     3        Implement page-break-* and -webkit-column-break-* as legacy-shorthands.
     4        https://bugs.webkit.org/show_bug.cgi?id=197656
     5
     6        Reviewed by Darin Adler.
     7
     8        According to https://drafts.csswg.org/css-cascade-4/#legacy-shorthand,
     9        implement page-break-* and -webkit-column-break-* as legacy-shorthands for break-*.
     10
     11        This change also serialize page-break-* properties
     12        to CSSStyleDeclaration,
     13        per https://drafts.csswg.org/css-break/#page-break-properties.
     14
     15        * web-platform-tests/css/cssom/serialize-values-expected.txt:
     16
    1172019-05-14  Javier Fernandez  <jfernandez@igalia.com>
    218
  • trunk/LayoutTests/imported/w3c/web-platform-tests/css/cssom/serialize-values-expected.txt

    r232005 r245276  
    572572PASS padding-left: .5%
    573573PASS padding-left: inherit
    574 FAIL page-break-after: auto assert_equals: page-break-after raw inline style declaration expected "auto" but got ""
    575 FAIL page-break-after: always assert_equals: page-break-after raw inline style declaration expected "always" but got ""
    576 FAIL page-break-after: avoid assert_equals: page-break-after raw inline style declaration expected "avoid" but got ""
    577 FAIL page-break-after: left assert_equals: page-break-after raw inline style declaration expected "left" but got ""
    578 FAIL page-break-after: right assert_equals: page-break-after raw inline style declaration expected "right" but got ""
     574PASS page-break-after: auto
     575PASS page-break-after: always
     576PASS page-break-after: avoid
     577PASS page-break-after: left
     578PASS page-break-after: right
    579579PASS page-break-after: inherit
    580 FAIL page-break-before: auto assert_equals: page-break-before raw inline style declaration expected "auto" but got ""
    581 FAIL page-break-before: always assert_equals: page-break-before raw inline style declaration expected "always" but got ""
    582 FAIL page-break-before: avoid assert_equals: page-break-before raw inline style declaration expected "avoid" but got ""
    583 FAIL page-break-before: left assert_equals: page-break-before raw inline style declaration expected "left" but got ""
    584 FAIL page-break-before: right assert_equals: page-break-before raw inline style declaration expected "right" but got ""
     580PASS page-break-before: auto
     581PASS page-break-before: always
     582PASS page-break-before: avoid
     583PASS page-break-before: left
     584PASS page-break-before: right
    585585PASS page-break-before: inherit
    586 FAIL page-break-inside: avoid assert_equals: page-break-inside raw inline style declaration expected "avoid" but got ""
    587 FAIL page-break-inside: auto assert_equals: page-break-inside raw inline style declaration expected "auto" but got ""
     586PASS page-break-inside: avoid
     587PASS page-break-inside: auto
    588588PASS page-break-inside: inherit
    589589PASS position: static
  • trunk/Source/WebCore/ChangeLog

    r245275 r245276  
     12019-05-14  Joonghun Park  <pjh0718@gmail.com>
     2
     3        Implement page-break-* and -webkit-column-break-* as legacy-shorthands.
     4        https://bugs.webkit.org/show_bug.cgi?id=197656
     5
     6        Reviewed by Darin Adler.
     7
     8        According to https://drafts.csswg.org/css-cascade-4/#legacy-shorthand,
     9        implement page-break-* and -webkit-column-break-* as legacy-shorthands for break-*.
     10
     11        This change also serialize page-break-* properties
     12        to CSSStyleDeclaration,
     13        per https://drafts.csswg.org/css-break/#page-break-properties.
     14
     15        * css/CSSProperties.json:
     16        * css/StyleBuilderConverter.h:
     17        (WebCore::StyleBuilderConverter::convertFontSynthesis):
     18        (WebCore::StyleBuilderConverter::convertPageBreakBetween): Deleted.
     19        (WebCore::StyleBuilderConverter::convertPageBreakInside): Deleted.
     20        (WebCore::StyleBuilderConverter::convertColumnBreakBetween): Deleted.
     21        (WebCore::StyleBuilderConverter::convertColumnBreakInside): Deleted.
     22        * css/StyleProperties.cpp:
     23        (WebCore::StyleProperties::getPropertyValue const):
     24        (WebCore::StyleProperties::pageBreakPropertyValue const):
     25        * css/StyleProperties.h:
     26        * css/parser/CSSPropertyParser.cpp:
     27        (WebCore::CSSPropertyParser::parseValueStart):
     28        (WebCore::mapFromPageBreakBetween):
     29        (WebCore::CSSPropertyParser::parseShorthand):
     30        (WebCore::isLegacyBreakProperty): Deleted.
     31
    1322019-05-14  Javier Fernandez  <jfernandez@igalia.com>
    233
  • trunk/Source/WebCore/css/CSSProperties.json

    r245275 r245276  
    34153415        },
    34163416        "page-break-after": {
    3417             "values": [
    3418                 "auto",
    3419                 "always",
    3420                 "avoid",
    3421                 "left",
    3422                 "right"
    3423             ],
    3424             "codegen-properties": {
    3425                 "initial": "initialBreakBetween",
    3426                 "name-for-methods": "BreakAfter",
    3427                 "converter": "PageBreakBetween"
     3417            "codegen-properties": {
     3418                "longhands": [
     3419                    "break-after"
     3420                ]
    34283421            },
    34293422            "specification": {
     
    34333426        },
    34343427        "page-break-before": {
    3435             "values": [
    3436                 "auto",
    3437                 "always",
    3438                 "avoid",
    3439                 "left",
    3440                 "right"
    3441             ],
    3442             "codegen-properties": {
    3443                 "initial": "initialBreakBetween",
    3444                 "name-for-methods": "BreakBefore",
    3445                 "converter": "PageBreakBetween"
     3428            "codegen-properties": {
     3429                "longhands": [
     3430                    "break-before"
     3431                ]
    34463432            },
    34473433            "specification": {
     
    34513437        },
    34523438        "page-break-inside": {
    3453             "values": [
    3454                 "auto",
    3455                 "avoid"
    3456             ],
    3457             "codegen-properties": {
    3458                 "initial": "initialBreakInside",
    3459                 "name-for-methods": "BreakInside",
    3460                 "converter": "PageBreakInside"
     3439            "codegen-properties": {
     3440                "longhands": [
     3441                    "break-inside"
     3442                ]
    34613443            },
    34623444            "specification": {
     
    46914673        },
    46924674        "-webkit-column-break-after": {
    4693             "values": [
    4694                 "auto",
    4695                 "always",
    4696                 "avoid",
    4697                 "left",
    4698                 "right"
    4699             ],
    4700             "codegen-properties": {
    4701                 "initial": "initialBreakBetween",
    4702                 "name-for-methods": "BreakAfter",
    4703                 "converter": "ColumnBreakBetween"
     4675            "codegen-properties": {
     4676                "longhands": [
     4677                    "break-after"
     4678                ]
    47044679            },
    47054680            "status": {
     
    47124687        },
    47134688        "-webkit-column-break-before": {
    4714             "values": [
    4715                 "auto",
    4716                 "always",
    4717                 "avoid",
    4718                 "left",
    4719                 "right"
    4720             ],
    4721             "codegen-properties": {
    4722                 "initial": "initialBreakBetween",
    4723                 "name-for-methods": "BreakBefore",
    4724                 "converter": "ColumnBreakBetween"
     4689            "codegen-properties": {
     4690                "longhands": [
     4691                    "break-before"
     4692                ]
    47254693            },
    47264694            "status": {
     
    47334701        },
    47344702        "-webkit-column-break-inside": {
    4735             "values": [
    4736                 "auto",
    4737                 "avoid"
    4738             ],
    4739             "codegen-properties": {
    4740                 "initial": "initialBreakInside",
    4741                 "name-for-methods": "BreakInside",
    4742                 "converter": "ColumnBreakInside"
     4703            "codegen-properties": {
     4704                "longhands": [
     4705                    "break-inside"
     4706                ]
    47434707            },
    47444708            "status": {
  • trunk/Source/WebCore/css/StyleBuilderConverter.h

    r244408 r245276  
    15671567    return result;
    15681568}
    1569 
    1570 inline BreakBetween StyleBuilderConverter::convertPageBreakBetween(StyleResolver&, const CSSValue& value)
    1571 {
    1572     auto& primitiveValue = downcast<CSSPrimitiveValue>(value);
    1573     if (primitiveValue.valueID() == CSSValueAlways)
    1574         return BreakBetween::Page;
    1575     if (primitiveValue.valueID() == CSSValueAvoid)
    1576         return BreakBetween::AvoidPage;
    1577     return primitiveValue;
    1578 }
    1579 
    1580 inline BreakInside StyleBuilderConverter::convertPageBreakInside(StyleResolver&, const CSSValue& value)
    1581 {
    1582     auto& primitiveValue = downcast<CSSPrimitiveValue>(value);
    1583     if (primitiveValue.valueID() == CSSValueAvoid)
    1584         return BreakInside::AvoidPage;
    1585     return primitiveValue;
    1586 }
    1587 
    1588 inline BreakBetween StyleBuilderConverter::convertColumnBreakBetween(StyleResolver&, const CSSValue& value)
    1589 {
    1590     auto& primitiveValue = downcast<CSSPrimitiveValue>(value);
    1591     if (primitiveValue.valueID() == CSSValueAlways)
    1592         return BreakBetween::Column;
    1593     if (primitiveValue.valueID() == CSSValueAvoid)
    1594         return BreakBetween::AvoidColumn;
    1595     return primitiveValue;
    1596 }
    1597 
    1598 inline BreakInside StyleBuilderConverter::convertColumnBreakInside(StyleResolver&, const CSSValue& value)
    1599 {
    1600     auto& primitiveValue = downcast<CSSPrimitiveValue>(value);
    1601     if (primitiveValue.valueID() == CSSValueAvoid)
    1602         return BreakInside::AvoidColumn;
    1603     return primitiveValue;
    1604 }
    16051569   
    16061570inline OptionSet<SpeakAs> StyleBuilderConverter::convertSpeakAs(StyleResolver&, const CSSValue& value)
  • trunk/Source/WebCore/css/StyleProperties.cpp

    r240334 r245276  
    134134        if (!value || value->isPendingSubstitutionValue())
    135135            return String();
     136    // FIXME: If all longhands are the same css-generic keyword(e.g. initial or inherit),
     137    // then the shorthand should be serialized to that keyword.
     138    // It seems to be needed to handle this in a single function commonly for all the shorthands,
     139    // not in each of the shorthand serialization function.
     140    // We could call that function here.
    136141    }
    137142
     
    210215    case CSSPropertyGridRow:
    211216        return getShorthandValue(gridRowShorthand());
     217    case CSSPropertyPageBreakAfter:
     218        return pageBreakPropertyValue(pageBreakAfterShorthand());
     219    case CSSPropertyPageBreakBefore:
     220        return pageBreakPropertyValue(pageBreakBeforeShorthand());
     221    case CSSPropertyPageBreakInside:
     222        return pageBreakPropertyValue(pageBreakInsideShorthand());
    212223    case CSSPropertyPlaceContent:
    213224        return getAlignmentShorthandValue(placeContentShorthand());
     
    714725}
    715726
     727String StyleProperties::pageBreakPropertyValue(const StylePropertyShorthand& shorthand) const
     728{
     729    RefPtr<CSSValue> value = getPropertyCSSValueInternal(shorthand.properties()[0]);
     730    // FIXME: Remove this isGlobalKeyword check after we do this consistently for all shorthands in getPropertyValue.
     731    if (value->isGlobalKeyword())
     732        return value->cssText();
     733    CSSValueID valueId = downcast<CSSPrimitiveValue>(*value).valueID();
     734    switch (valueId) {
     735    case CSSValuePage:
     736        return "always"_s;
     737    case CSSValueAuto:
     738    case CSSValueAvoid:
     739    case CSSValueLeft:
     740    case CSSValueRight:
     741        return value->cssText();
     742    default:
     743        return String();
     744    }
     745}
     746
    716747RefPtr<CSSValue> StyleProperties::getPropertyCSSValue(CSSPropertyID propertyID) const
    717748{
  • trunk/Source/WebCore/css/StyleProperties.h

    r240251 r245276  
    164164    String getAlignmentShorthandValue(const StylePropertyShorthand&) const;
    165165    String borderPropertyValue(const StylePropertyShorthand&, const StylePropertyShorthand&, const StylePropertyShorthand&) const;
     166    String pageBreakPropertyValue(const StylePropertyShorthand&) const;
    166167    String getLayeredShorthandValue(const StylePropertyShorthand&) const;
    167168    String get2Values(const StylePropertyShorthand&) const;
  • trunk/Source/WebCore/css/parser/CSSPropertyParser.cpp

    r244408 r245276  
    315315}
    316316
    317 static bool isLegacyBreakProperty(CSSPropertyID propertyID)
    318 {
    319     switch (propertyID) {
    320     case CSSPropertyPageBreakAfter:
    321     case CSSPropertyPageBreakBefore:
    322     case CSSPropertyPageBreakInside:
    323     case CSSPropertyWebkitColumnBreakAfter:
    324     case CSSPropertyWebkitColumnBreakBefore:
    325     case CSSPropertyWebkitColumnBreakInside:
    326         return true;
    327     default:
    328         break;
    329     }
    330     return false;
    331 }
    332 
    333317bool CSSPropertyParser::parseValueStart(CSSPropertyID propertyID, bool important)
    334318{
     
    342326        // Variable references will fail to parse here and will fall out to the variable ref parser below.
    343327        if (parseShorthand(propertyID, important))
    344             return true;
    345     } else if (isLegacyBreakProperty(propertyID)) {
    346         // FIXME-NEWPARSER: Can turn this into a shorthand once old parser is gone, and then
    347         // we don't need the special case.
    348         if (consumeLegacyBreakProperty(propertyID, important))
    349328            return true;
    350329    } else {
     
    51405119    if (value == CSSValueAlways)
    51415120        return CSSValuePage;
    5142     if (value == CSSValueAuto || value == CSSValueLeft || value == CSSValueRight)
     5121    if (value == CSSValueAuto || value == CSSValueAvoid || value == CSSValueLeft || value == CSSValueRight)
    51435122        return value;
    5144     if (value == CSSValueAvoid)
    5145         return CSSValueAvoidPage;
    51465123    return CSSValueInvalid;
    51475124}
     
    58885865    case CSSPropertyBorderImage:
    58895866        return consumeBorderImage(property, important);
     5867    case CSSPropertyPageBreakAfter:
     5868    case CSSPropertyPageBreakBefore:
     5869    case CSSPropertyPageBreakInside:
     5870    case CSSPropertyWebkitColumnBreakAfter:
     5871    case CSSPropertyWebkitColumnBreakBefore:
     5872    case CSSPropertyWebkitColumnBreakInside:
     5873        return consumeLegacyBreakProperty(property, important);
    58905874    case CSSPropertyWebkitMaskPosition:
    58915875    case CSSPropertyBackgroundPosition: {
Note: See TracChangeset for help on using the changeset viewer.