Changeset 207629 in webkit


Ignore:
Timestamp:
Oct 20, 2016 11:35:56 AM (8 years ago)
Author:
hyatt@apple.com
Message:

[CSS Parser] Fix region, column and page break parsing
https://bugs.webkit.org/show_bug.cgi?id=163743

Reviewed by Simon Fraser.

  • css/parser/CSSParserFastPaths.cpp:

(WebCore::CSSParserFastPaths::isValidKeywordPropertyAndValue):
Add the missing values for break support.

  • css/parser/CSSPropertyParser.cpp:

(WebCore::isLegacyBreakProperty):
(WebCore::CSSPropertyParser::parseValueStart):
Add a special case for handling legacy break properties. Blink treats them like
shorthands, but we can't do that without breaking the old parser, so for now
we add a special case.

(WebCore::mapFromPageBreakBetween):
(WebCore::mapFromColumnBreakBetween):
(WebCore::mapFromRegionBreakBetween):
Updated to have the AvoidXXX values (where XXX is Column/Page/Region).

(WebCore::CSSPropertyParser::parseShorthand):
Remove the consumeLegacyBreak from the shorthand function, since we can't treat
the legacy break properties as shorthands yet.

Location:
trunk/Source/WebCore
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r207627 r207629  
     12016-10-20  Dave Hyatt  <hyatt@apple.com>
     2
     3        [CSS Parser] Fix region, column and page break parsing
     4        https://bugs.webkit.org/show_bug.cgi?id=163743
     5
     6        Reviewed by Simon Fraser.
     7
     8        * css/parser/CSSParserFastPaths.cpp:
     9        (WebCore::CSSParserFastPaths::isValidKeywordPropertyAndValue):
     10        Add the missing values for break support.
     11
     12        * css/parser/CSSPropertyParser.cpp:
     13        (WebCore::isLegacyBreakProperty):
     14        (WebCore::CSSPropertyParser::parseValueStart):
     15        Add a special case for handling legacy break properties. Blink treats them like
     16        shorthands, but we can't do that without breaking the old parser, so for now
     17        we add a special case.
     18
     19        (WebCore::mapFromPageBreakBetween):
     20        (WebCore::mapFromColumnBreakBetween):
     21        (WebCore::mapFromRegionBreakBetween):
     22        Updated to have the AvoidXXX values (where XXX is Column/Page/Region).
     23
     24        (WebCore::CSSPropertyParser::parseShorthand):
     25        Remove the consumeLegacyBreak from the shorthand function, since we can't treat
     26        the legacy break properties as shorthands yet.
     27
    1282016-10-20  Sam Weinig  <sam@webkit.org>
    229
  • trunk/Source/WebCore/css/parser/CSSParserFastPaths.cpp

    r207622 r207629  
    597597    case CSSPropertyBreakAfter:
    598598    case CSSPropertyBreakBefore:
    599         return valueID == CSSValueAuto || valueID == CSSValueAvoid || valueID == CSSValueAvoidPage || valueID == CSSValuePage || valueID == CSSValueLeft || valueID == CSSValueRight || valueID == CSSValueRecto || valueID == CSSValueVerso || valueID == CSSValueAvoidColumn || valueID == CSSValueColumn;
     599        return valueID == CSSValueAuto || valueID == CSSValueAvoid || valueID == CSSValueAvoidPage || valueID == CSSValuePage || valueID == CSSValueLeft || valueID == CSSValueRight || valueID == CSSValueRecto || valueID == CSSValueVerso || valueID == CSSValueAvoidColumn || valueID == CSSValueColumn
     600#if ENABLE(CSS_REGIONS)
     601            || valueID == CSSValueRegion || valueID == CSSValueAvoidRegion
     602#endif
     603        ;
    600604    case CSSPropertyBreakInside:
    601         return valueID == CSSValueAuto || valueID == CSSValueAvoid || valueID == CSSValueAvoidPage || valueID == CSSValueAvoidColumn;
     605        return valueID == CSSValueAuto || valueID == CSSValueAvoid || valueID == CSSValueAvoidPage || valueID == CSSValueAvoidColumn
     606#if ENABLE(CSS_REGIONS)
     607            || valueID == CSSValueAvoidRegion
     608#endif
     609        ;
    602610    case CSSPropertyPointerEvents:
    603611        // none | visiblePainted | visibleFill | visibleStroke | visible |
  • trunk/Source/WebCore/css/parser/CSSPropertyParser.cpp

    r207622 r207629  
    267267}
    268268
     269static bool isLegacyBreakProperty(CSSPropertyID propertyID)
     270{
     271    switch (propertyID) {
     272    case CSSPropertyPageBreakAfter:
     273    case CSSPropertyPageBreakBefore:
     274    case CSSPropertyPageBreakInside:
     275    case CSSPropertyWebkitColumnBreakAfter:
     276    case CSSPropertyWebkitColumnBreakBefore:
     277    case CSSPropertyWebkitColumnBreakInside:
     278#if ENABLE(CSS_REGIONS)
     279    case CSSPropertyWebkitRegionBreakAfter:
     280    case CSSPropertyWebkitRegionBreakBefore:
     281    case CSSPropertyWebkitRegionBreakInside:
     282#endif
     283        return true;
     284    default:
     285        break;
     286    }
     287    return false;
     288}
     289
    269290bool CSSPropertyParser::parseValueStart(CSSPropertyID propertyID, bool important)
    270291{
     
    278299        // Variable references will fail to parse here and will fall out to the variable ref parser below.
    279300        if (parseShorthand(propertyID, important))
     301            return true;
     302    } else if (isLegacyBreakProperty(propertyID)) {
     303        // FIXME-NEWPARSER: Can turn this into a shorthand once old parser is gone, and then
     304        // we don't need the special case.
     305        if (consumeLegacyBreakProperty(propertyID, important))
    280306            return true;
    281307    } else {
     
    40044030    if (value == CSSValueAlways)
    40054031        return CSSValuePage;
    4006     if (value == CSSValueAuto || value == CSSValueAvoid || value == CSSValueLeft || value == CSSValueRight)
     4032    if (value == CSSValueAuto || value == CSSValueLeft || value == CSSValueRight)
    40074033        return value;
     4034    if (value == CSSValueAvoid)
     4035        return CSSValueAvoidPage;
    40084036    return CSSValueInvalid;
    40094037}
     
    40134041    if (value == CSSValueAlways)
    40144042        return CSSValueColumn;
    4015     if (value == CSSValueAuto || value == CSSValueAvoid)
     4043    if (value == CSSValueAuto)
    40164044        return value;
     4045    if (value == CSSValueAvoid)
     4046        return CSSValueAvoidColumn;
    40174047    return CSSValueInvalid;
    40184048}
     
    40234053    if (value == CSSValueAlways)
    40244054        return CSSValueRegion;
    4025     if (value == CSSValueAuto || value == CSSValueAvoid)
     4055    if (value == CSSValueAuto)
    40264056        return value;
     4057    if (value == CSSValueAvoid)
     4058        return CSSValueAvoidRegion;
    40274059    return CSSValueInvalid;
    40284060}
     
    45724604    case CSSPropertyBorderImage:
    45734605        return consumeBorderImage(property, important);
    4574     case CSSPropertyPageBreakAfter:
    4575     case CSSPropertyPageBreakBefore:
    4576     case CSSPropertyPageBreakInside:
    4577     case CSSPropertyWebkitColumnBreakAfter:
    4578     case CSSPropertyWebkitColumnBreakBefore:
    4579     case CSSPropertyWebkitColumnBreakInside:
    4580         return consumeLegacyBreakProperty(property, important);
    45814606    case CSSPropertyWebkitMaskPosition:
    45824607    case CSSPropertyBackgroundPosition: {
Note: See TracChangeset for help on using the changeset viewer.