Changeset 207622 in webkit


Ignore:
Timestamp:
Oct 20, 2016 10:25:01 AM (7 years ago)
Author:
hyatt@apple.com
Message:

[CSS Parser] Fix font family parsing and add CSS region property parsing
https://bugs.webkit.org/show_bug.cgi?id=163741

Reviewed by Zalan Bujtas.

  • css/parser/CSSParser.cpp:

(WebCore::isKeywordPropertyID):
(WebCore::parseKeywordValue):
(WebCore::CSSParser::parseValue):
Modify the old CSSParser to have its own keyword check, since keywords were
incorrectly added to the new parser when this check was consolidated. Column
and region breaks are considered keyword properties by the old parser, but
not by the new parser, since the new parser special cases them and maps them
into the generic break property.

  • css/parser/CSSParserFastPaths.cpp:

(WebCore::CSSParserFastPaths::isValidKeywordPropertyAndValue):
(WebCore::CSSParserFastPaths::isKeywordPropertyID):
Update for regions to make sure all the region properties are there. Remove the
column and region break properties, since they're not supposed to be here in the
new parser.

  • css/parser/CSSPropertyParser.cpp:

(WebCore::consumeFamilyName):
Fix font parsing to make font family values so that fonts work.

(WebCore::consumeFlowProperty):
Add a function for handling -webkit-flow-from and -webkit-flow-into.

(WebCore::CSSPropertyParser::parseSingleValue):
Add support for the region properties.

(WebCore::mapFromRegionBreakBetween):
(WebCore::mapFromColumnRegionOrPageBreakInside):
(WebCore::mapFromLegacyBreakProperty):
(WebCore::CSSPropertyParser::consumeLegacyBreakProperty):
(WebCore::mapFromColumnOrPageBreakInside): Deleted.
Update to handle the region break properties in the same way that column break
properties are handled.

Location:
trunk/Source/WebCore
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r207621 r207622  
     12016-10-20  Dave Hyatt  <hyatt@apple.com>
     2
     3        [CSS Parser] Fix font family parsing and add CSS region property parsing
     4        https://bugs.webkit.org/show_bug.cgi?id=163741
     5
     6        Reviewed by Zalan Bujtas.
     7
     8        * css/parser/CSSParser.cpp:
     9        (WebCore::isKeywordPropertyID):
     10        (WebCore::parseKeywordValue):
     11        (WebCore::CSSParser::parseValue):
     12        Modify the old CSSParser to have its own keyword check, since keywords were
     13        incorrectly added to the new parser when this check was consolidated. Column
     14        and region breaks are considered keyword properties by the old parser, but
     15        not by the new parser, since the new parser special cases them and maps them
     16        into the generic break property.
     17
     18        * css/parser/CSSParserFastPaths.cpp:
     19        (WebCore::CSSParserFastPaths::isValidKeywordPropertyAndValue):
     20        (WebCore::CSSParserFastPaths::isKeywordPropertyID):
     21        Update for regions to make sure all the region properties are there. Remove the
     22        column and region break properties, since they're not supposed to be here in the
     23        new parser.
     24
     25        * css/parser/CSSPropertyParser.cpp:
     26        (WebCore::consumeFamilyName):
     27        Fix font parsing to make font family values so that fonts work.
     28
     29        (WebCore::consumeFlowProperty):
     30        Add a function for handling -webkit-flow-from and -webkit-flow-into.
     31
     32        (WebCore::CSSPropertyParser::parseSingleValue):
     33        Add support for the region properties.
     34
     35        (WebCore::mapFromRegionBreakBetween):
     36        (WebCore::mapFromColumnRegionOrPageBreakInside):
     37        (WebCore::mapFromLegacyBreakProperty):
     38        (WebCore::CSSPropertyParser::consumeLegacyBreakProperty):
     39        (WebCore::mapFromColumnOrPageBreakInside): Deleted.
     40        Update to handle the region break properties in the same way that column break
     41        properties are handled.
     42
    1432016-10-20  Jer Noble  <jer.noble@apple.com>
    244
  • trunk/Source/WebCore/css/parser/CSSParser.cpp

    r207581 r207622  
    11501150}
    11511151
     1152static bool isKeywordPropertyID(CSSPropertyID propertyID)
     1153{
     1154    switch (propertyID) {
     1155        case CSSPropertyWebkitColumnBreakAfter:
     1156        case CSSPropertyWebkitColumnBreakBefore:
     1157        case CSSPropertyWebkitColumnBreakInside:
     1158#if ENABLE(CSS_REGIONS)
     1159        case CSSPropertyWebkitRegionBreakAfter:
     1160        case CSSPropertyWebkitRegionBreakBefore:
     1161        case CSSPropertyWebkitRegionBreakInside:
     1162#endif
     1163            return true;
     1164        default:
     1165            break;
     1166    }
     1167   
     1168    return CSSParserFastPaths::isKeywordPropertyID(propertyID);
     1169}
     1170
    11521171static CSSParser::ParseResult parseKeywordValue(MutableStyleProperties& declaration, CSSPropertyID propertyId, const String& string, bool important, const CSSParserContext& parserContext, StyleSheetContents* styleSheetContents)
    11531172{
    11541173    ASSERT(!string.isEmpty());
    11551174
    1156     if (!CSSParserFastPaths::isKeywordPropertyID(propertyId)) {
     1175    if (!isKeywordPropertyID(propertyId)) {
    11571176        if (!isUniversalKeyword(string))
    11581177            return CSSParser::ParseResult::Error;
     
    18431862        return false; // "all" doesn't allow you to specify anything other than inherit/initial/unset.
    18441863
    1845     if (CSSParserFastPaths::isKeywordPropertyID(propId)) {
     1864    if (isKeywordPropertyID(propId)) {
    18461865        if (!isValidKeywordPropertyAndValue(propId, id, m_context, m_styleSheet))
    18471866            return false;
  • trunk/Source/WebCore/css/parser/CSSParserFastPaths.cpp

    r207567 r207622  
    746746    case CSSPropertyWebkitBorderFit:
    747747        return valueID == CSSValueBorder || valueID == CSSValueLines;
     748#if ENABLE(CSS_REGIONS)
     749    case CSSPropertyWebkitRegionFragment:
     750        return valueID == CSSValueAuto || valueID == CSSValueBreak;
     751#endif
    748752#if ENABLE(CSS_SCROLL_SNAP)
    749753    case CSSPropertyWebkitScrollSnapType: // none | mandatory | proximity
     
    840844    case CSSPropertyWebkitBoxPack:
    841845    case CSSPropertyWebkitColumnAxis:
    842     case CSSPropertyWebkitColumnBreakAfter:
    843     case CSSPropertyWebkitColumnBreakBefore:
    844     case CSSPropertyWebkitColumnBreakInside:
    845846    case CSSPropertyWebkitFontKerning:
    846847    case CSSPropertyWebkitFontSmoothing:
     
    931932#endif
    932933#if ENABLE(CSS_REGIONS)
    933     case CSSPropertyWebkitRegionBreakAfter:
    934     case CSSPropertyWebkitRegionBreakBefore:
    935     case CSSPropertyWebkitRegionBreakInside:
    936934    case CSSPropertyWebkitRegionFragment:
    937935#endif
  • trunk/Source/WebCore/css/parser/CSSPropertyParser.cpp

    r207549 r207622  
    707707{
    708708    if (range.peek().type() == StringToken)
    709         return CSSPrimitiveValue::create(range.consumeIncludingWhitespace().value().toString(), CSSPrimitiveValue::UnitTypes::CSS_STRING);
     709        return CSSValuePool::singleton().createFontFamilyValue(range.consumeIncludingWhitespace().value().toString());
    710710    if (range.peek().type() != IdentToken)
    711711        return nullptr;
     
    713713    if (familyName.isNull())
    714714        return nullptr;
    715     return CSSPrimitiveValue::create(familyName, CSSPrimitiveValue::UnitTypes::CSS_STRING);
     715    return CSSValuePool::singleton().createFontFamilyValue(familyName);
    716716}
    717717
     
    30073007    return CSSGridTemplateAreasValue::create(gridAreaMap, rowCount, columnCount);
    30083008}
     3009
     3010#if ENABLE(CSS_REGIONS)
     3011static RefPtr<CSSValue> consumeFlowProperty(CSSParserTokenRange& range)
     3012{
     3013    RefPtr<CSSValue> result;
     3014    if (range.peek().id() == CSSValueNone)
     3015        result = consumeIdent(range);
     3016    else
     3017        result = consumeCustomIdent(range);
     3018    return result;
     3019}
     3020#endif
    30093021
    30103022RefPtr<CSSValue> CSSPropertyParser::parseSingleValue(CSSPropertyID property, CSSPropertyID currentShorthand)
     
    33693381    case CSSPropertyGridAutoFlow:
    33703382        return consumeGridAutoFlow(m_range);
     3383#if ENABLE(CSS_REGIONS)
     3384    case CSSPropertyWebkitFlowInto:
     3385    case CSSPropertyWebkitFlowFrom:
     3386        return consumeFlowProperty(m_range);
     3387#endif
    33713388    default:
    33723389        return nullptr;
     
    40014018}
    40024019
    4003 static inline CSSValueID mapFromColumnOrPageBreakInside(CSSValueID value)
     4020#if ENABLE(CSS_REGIONS)
     4021static inline CSSValueID mapFromRegionBreakBetween(CSSValueID value)
     4022{
     4023    if (value == CSSValueAlways)
     4024        return CSSValueRegion;
     4025    if (value == CSSValueAuto || value == CSSValueAvoid)
     4026        return value;
     4027    return CSSValueInvalid;
     4028}
     4029#endif
     4030
     4031static inline CSSValueID mapFromColumnRegionOrPageBreakInside(CSSValueID value)
    40044032{
    40054033    if (value == CSSValueAuto || value == CSSValueAvoid)
     
    40144042    if (property == CSSPropertyPageBreakBefore || property == CSSPropertyWebkitColumnBreakBefore)
    40154043        return CSSPropertyBreakBefore;
     4044#if ENABLE(CSS_REGIONS)
     4045    if (property == CSSPropertyWebkitRegionBreakAfter)
     4046        return CSSPropertyBreakAfter;
     4047    if (property == CSSPropertyWebkitRegionBreakBefore)
     4048        return CSSPropertyBreakBefore;
     4049    ASSERT(property == CSSPropertyPageBreakInside || property == CSSPropertyWebkitColumnBreakInside || property == CSSPropertyWebkitRegionBreakInside);
     4050#else
    40164051    ASSERT(property == CSSPropertyPageBreakInside || property == CSSPropertyWebkitColumnBreakInside);
     4052#endif
    40174053    return CSSPropertyBreakInside;
    40184054}
     
    40384074        value = mapFromColumnBreakBetween(value);
    40394075        break;
     4076#if ENABLE(CSS_REGIONS)
     4077    case CSSPropertyWebkitRegionBreakAfter:
     4078    case CSSPropertyWebkitRegionBreakBefore:
     4079        value = mapFromRegionBreakBetween(value);
     4080        break;
     4081    case CSSPropertyWebkitRegionBreakInside:
     4082#endif
    40404083    case CSSPropertyPageBreakInside:
    40414084    case CSSPropertyWebkitColumnBreakInside:
    4042         value = mapFromColumnOrPageBreakInside(value);
     4085        value = mapFromColumnRegionOrPageBreakInside(value);
    40434086        break;
    40444087    default:
Note: See TracChangeset for help on using the changeset viewer.