Changeset 196075 in webkit


Ignore:
Timestamp:
Feb 3, 2016 12:54:30 PM (8 years ago)
Author:
hyatt@apple.com
Message:

Implement hanging-punctuation property parsing.
https://bugs.webkit.org/show_bug.cgi?id=18109.

Reviewed by Zalan Bujtas.

Source/WebCore:

Added parsing test in fast/css.

  • css/CSSComputedStyleDeclaration.cpp:

(WebCore::renderEmphasisPositionFlagsToCSSValue):
(WebCore::hangingPunctuationToCSSValue):
(WebCore::fillRepeatToCSSValue):
(WebCore::ComputedStyleExtractor::propertyValue):

  • css/CSSParser.cpp:

(WebCore::CSSParser::parseValue):
(WebCore::CSSParser::parseTextIndent):
(WebCore::CSSParser::parseHangingPunctuation):
(WebCore::CSSParser::parseLineBoxContain):

  • css/CSSParser.h:
  • css/CSSPrimitiveValueMappings.h:

(WebCore::CSSPrimitiveValue::CSSPrimitiveValue):
(WebCore::CSSPrimitiveValue::operator HangingPunctuation):
(WebCore::CSSPrimitiveValue::operator LineBreak):

  • css/CSSPropertyNames.in:
  • css/CSSValueKeywords.in:
  • css/StyleBuilderConverter.h:

(WebCore::StyleBuilderConverter::convertRegionBreakInside):
(WebCore::StyleBuilderConverter::convertHangingPunctuation):

  • rendering/style/RenderStyle.cpp:

(WebCore::RenderStyle::changeRequiresLayout):

  • rendering/style/RenderStyle.h:
  • rendering/style/RenderStyleConstants.h:

(WebCore::operator| ):
(WebCore::operator|= ):

  • rendering/style/StyleRareInheritedData.cpp:

(WebCore::StyleRareInheritedData::StyleRareInheritedData):
(WebCore::StyleRareInheritedData::operator==):

  • rendering/style/StyleRareInheritedData.h:

LayoutTests:

  • fast/css/parsing-hanging-punctuation-expected.txt: Added.
  • fast/css/parsing-hanging-punctuation.html: Added.
  • fast/css/resources/parsing-hanging-punctuation.js: Added.

(test):

Location:
trunk
Files:
3 added
14 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r196069 r196075  
     12016-02-03  Dave Hyatt  <hyatt@apple.com>
     2
     3        Implement hanging-punctuation property parsing.
     4        https://bugs.webkit.org/show_bug.cgi?id=18109.
     5
     6        Reviewed by Zalan Bujtas.
     7
     8        * fast/css/parsing-hanging-punctuation-expected.txt: Added.
     9        * fast/css/parsing-hanging-punctuation.html: Added.
     10        * fast/css/resources/parsing-hanging-punctuation.js: Added.
     11        (test):
     12
    1132016-02-03  Ryan Haddad  <ryanhaddad@apple.com>
    214
  • trunk/Source/WebCore/ChangeLog

    r196070 r196075  
     12016-02-03  Dave Hyatt  <hyatt@apple.com>
     2
     3        Implement hanging-punctuation property parsing.
     4        https://bugs.webkit.org/show_bug.cgi?id=18109.
     5
     6        Reviewed by Zalan Bujtas.
     7
     8        Added parsing test in fast/css.
     9
     10        * css/CSSComputedStyleDeclaration.cpp:
     11        (WebCore::renderEmphasisPositionFlagsToCSSValue):
     12        (WebCore::hangingPunctuationToCSSValue):
     13        (WebCore::fillRepeatToCSSValue):
     14        (WebCore::ComputedStyleExtractor::propertyValue):
     15        * css/CSSParser.cpp:
     16        (WebCore::CSSParser::parseValue):
     17        (WebCore::CSSParser::parseTextIndent):
     18        (WebCore::CSSParser::parseHangingPunctuation):
     19        (WebCore::CSSParser::parseLineBoxContain):
     20        * css/CSSParser.h:
     21        * css/CSSPrimitiveValueMappings.h:
     22        (WebCore::CSSPrimitiveValue::CSSPrimitiveValue):
     23        (WebCore::CSSPrimitiveValue::operator HangingPunctuation):
     24        (WebCore::CSSPrimitiveValue::operator LineBreak):
     25        * css/CSSPropertyNames.in:
     26        * css/CSSValueKeywords.in:
     27        * css/StyleBuilderConverter.h:
     28        (WebCore::StyleBuilderConverter::convertRegionBreakInside):
     29        (WebCore::StyleBuilderConverter::convertHangingPunctuation):
     30        * rendering/style/RenderStyle.cpp:
     31        (WebCore::RenderStyle::changeRequiresLayout):
     32        * rendering/style/RenderStyle.h:
     33        * rendering/style/RenderStyleConstants.h:
     34        (WebCore::operator| ):
     35        (WebCore::operator|= ):
     36        * rendering/style/StyleRareInheritedData.cpp:
     37        (WebCore::StyleRareInheritedData::StyleRareInheritedData):
     38        (WebCore::StyleRareInheritedData::operator==):
     39        * rendering/style/StyleRareInheritedData.h:
     40
    1412016-02-03  Jessie Berlin  <jberlin@webkit.org>
    242
  • trunk/Source/WebCore/css/CSSComputedStyleDeclaration.cpp

    r195892 r196075  
    16961696}
    16971697
     1698static Ref<CSSValue> hangingPunctuationToCSSValue(HangingPunctuation hangingPunctuation)
     1699{
     1700    auto& cssValuePool = CSSValuePool::singleton();
     1701    RefPtr<CSSValueList> list = CSSValueList::createSpaceSeparated();
     1702    if (hangingPunctuation & FirstHangingPunctuation)
     1703        list->append(cssValuePool.createIdentifierValue(CSSValueFirst));
     1704    if (hangingPunctuation & AllowEndHangingPunctuation)
     1705        list->append(cssValuePool.createIdentifierValue(CSSValueAllowEnd));
     1706    if (hangingPunctuation & ForceEndHangingPunctuation)
     1707        list->append(cssValuePool.createIdentifierValue(CSSValueForceEnd));
     1708    if (hangingPunctuation & LastHangingPunctuation)
     1709        list->append(cssValuePool.createIdentifierValue(CSSValueLast));
     1710    if (!list->length())
     1711        return cssValuePool.createIdentifierValue(CSSValueNone);
     1712    return list.releaseNonNull();
     1713}
     1714   
    16981715static Ref<CSSValue> fillRepeatToCSSValue(EFillRepeat xRepeat, EFillRepeat yRepeat)
    16991716{
     
    30193036        case CSSPropertyBreakInside:
    30203037            return cssValuePool.createValue(style->breakInside());
     3038        case CSSPropertyHangingPunctuation:
     3039            return hangingPunctuationToCSSValue(style->hangingPunctuation());
    30213040        case CSSPropertyPosition:
    30223041            return cssValuePool.createValue(style->position());
  • trunk/Source/WebCore/css/CSSParser.cpp

    r195951 r196075  
    30883088        break;
    30893089
     3090    case CSSPropertyHangingPunctuation:
     3091        return parseHangingPunctuation(important);
    30903092    case CSSPropertyWebkitLineBoxContain:
    30913093        if (id == CSSValueNone)
     
    1051210514}
    1051310515
     10516bool CSSParser::parseHangingPunctuation(bool important)
     10517{
     10518    CSSParserValue* value = m_valueList->current();
     10519    if (value && value->id == CSSValueNone) {
     10520        addProperty(CSSPropertyHangingPunctuation, CSSValuePool::singleton().createIdentifierValue(CSSValueNone), important);
     10521        m_valueList->next();
     10522        return true;
     10523    }
     10524   
     10525    RefPtr<CSSValueList> list = CSSValueList::createSpaceSeparated();
     10526    bool isValid = true;
     10527    std::bitset<numCSSValueKeywords> seenValues;
     10528    while (isValid && value) {
     10529        if (seenValues[value->id]
     10530            || (value->id == CSSValueAllowEnd && seenValues[CSSValueForceEnd])
     10531            || (value->id == CSSValueForceEnd && seenValues[CSSValueAllowEnd])) {
     10532            isValid = false;
     10533            break;
     10534        }
     10535        switch (value->id) {
     10536        case CSSValueAllowEnd:
     10537        case CSSValueFirst:
     10538        case CSSValueForceEnd:
     10539        case CSSValueLast:
     10540            list->append(CSSValuePool::singleton().createIdentifierValue(value->id));
     10541            seenValues.set(value->id);
     10542            break;
     10543        default:
     10544            isValid = false;
     10545            break;
     10546        }
     10547        if (isValid)
     10548            value = m_valueList->next();
     10549    }
     10550   
     10551    // Values are either valid or in shorthand scope.
     10552    if (list->length() && isValid) {
     10553        addProperty(CSSPropertyHangingPunctuation, list.release(), important);
     10554        return true;
     10555    }
     10556   
     10557    return false;
     10558}
     10559
    1051410560bool CSSParser::parseLineBoxContain(bool important)
    1051510561{
  • trunk/Source/WebCore/css/CSSParser.h

    r195304 r196075  
    338338    RefPtr<CSSValue> parseTextIndent();
    339339   
     340    bool parseHangingPunctuation(bool important);
     341
    340342    bool parseLineBoxContain(bool important);
    341343    RefPtr<CSSCalcValue> parseCalculation(CSSParserValue&, CalculationPermittedValueRange);
  • trunk/Source/WebCore/css/CSSPrimitiveValueMappings.h

    r195892 r196075  
    16251625        break;
    16261626    }
     1627}
     1628
     1629template<> inline CSSPrimitiveValue::operator HangingPunctuation() const
     1630{
     1631    ASSERT(isValueID());
     1632   
     1633    switch (m_value.valueID) {
     1634    case CSSValueNone:
     1635        return NoHangingPunctuation;
     1636    case CSSValueFirst:
     1637        return FirstHangingPunctuation;
     1638    case CSSValueLast:
     1639        return LastHangingPunctuation;
     1640    case CSSValueAllowEnd:
     1641        return AllowEndHangingPunctuation;
     1642    case CSSValueForceEnd:
     1643        return ForceEndHangingPunctuation;
     1644    default:
     1645        break;
     1646    }
     1647   
     1648    ASSERT_NOT_REACHED();
     1649    return NoHangingPunctuation;
    16271650}
    16281651
  • trunk/Source/WebCore/css/CSSPropertyNames.in

    r195892 r196075  
    237237glyph-orientation-horizontal [Inherited, SVG, Converter=GlyphOrientation]
    238238glyph-orientation-vertical [Inherited, SVG, Converter=GlyphOrientationOrAuto]
     239hanging-punctuation [Inherited, Converter=HangingPunctuation]
    239240height [Initial=initialSize, Converter=LengthSizing]
    240241#if defined(ENABLE_CSS_IMAGE_ORIENTATION) && ENABLE_CSS_IMAGE_ORIENTATION
  • trunk/Source/WebCore/css/CSSValueKeywords.in

    r195892 r196075  
    11921192manipulation
    11931193#endif
     1194
     1195// hanging-punctuation
     1196allow-end
     1197first
     1198force-end
     1199last
  • trunk/Source/WebCore/css/StyleBuilderConverter.h

    r195892 r196075  
    136136    static BreakInside convertRegionBreakInside(StyleResolver&, CSSValue&);
    137137#endif
     138   
     139    static HangingPunctuation convertHangingPunctuation(StyleResolver&, CSSValue&);
    138140
    139141private:
     
    12801282#endif
    12811283
     1284inline HangingPunctuation StyleBuilderConverter::convertHangingPunctuation(StyleResolver&, CSSValue& value)
     1285{
     1286    HangingPunctuation result = RenderStyle::initialHangingPunctuation();
     1287    if (is<CSSValueList>(value)) {
     1288        for (auto& currentValue : downcast<CSSValueList>(value))
     1289            result |= downcast<CSSPrimitiveValue>(currentValue.get());
     1290    }
     1291    return result;
     1292}
     1293
    12821294} // namespace WebCore
    12831295
  • trunk/Source/WebCore/rendering/style/RenderStyle.cpp

    r196031 r196075  
    614614            || rareInheritedData->m_lineSnap != other.rareInheritedData->m_lineSnap
    615615            || rareInheritedData->m_lineAlign != other.rareInheritedData->m_lineAlign
     616            || rareInheritedData->m_hangingPunctuation != other.rareInheritedData->m_hangingPunctuation
    616617#if ENABLE(ACCELERATED_OVERFLOW_SCROLLING)
    617618            || rareInheritedData->useTouchOverflowScrolling != other.rareInheritedData->useTouchOverflowScrolling
  • trunk/Source/WebCore/rendering/style/RenderStyle.h

    r195892 r196075  
    880880    BreakBetween breakBefore() const { return static_cast<BreakBetween>(rareNonInheritedData->m_breakBefore); }
    881881    BreakBetween breakAfter() const { return static_cast<BreakBetween>(rareNonInheritedData->m_breakAfter); }
     882   
     883    HangingPunctuation hangingPunctuation() const { return static_cast<HangingPunctuation>(rareInheritedData->m_hangingPunctuation); }
    882884
    883885    float outlineOffset() const
     
    16231625    void setBreakAfter(BreakBetween breakBehavior) { SET_VAR(rareNonInheritedData, m_breakAfter, breakBehavior); }
    16241626    void setBreakInside(BreakInside breakBehavior) { SET_VAR(rareNonInheritedData, m_breakInside, breakBehavior); }
     1627   
     1628    void setHangingPunctuation(HangingPunctuation punctuation) { SET_VAR(rareInheritedData, m_hangingPunctuation, punctuation); }
    16251629
    16261630    // End CSS3 Setters
     
    18821886    static BreakBetween initialBreakBetween() { return AutoBreakBetween; }
    18831887    static BreakInside initialBreakInside() { return AutoBreakInside; }
     1888    static HangingPunctuation initialHangingPunctuation() { return NoHangingPunctuation; }
    18841889    static ETableLayout initialTableLayout() { return TAUTO; }
    18851890    static EBorderCollapse initialBorderCollapse() { return BSEPARATE; }
  • trunk/Source/WebCore/rendering/style/RenderStyleConstants.h

    r195892 r196075  
    484484    AutoBreakInside, AvoidBreakInside, AvoidColumnBreakInside, AvoidPageBreakInside, AvoidRegionBreakInside
    485485};
    486    
     486
     487enum HangingPunctuation {
     488    NoHangingPunctuation = 0,
     489    FirstHangingPunctuation = 1 << 0,
     490    LastHangingPunctuation = 1 << 1,
     491    AllowEndHangingPunctuation = 1 << 2,
     492    ForceEndHangingPunctuation = 1 << 3
     493};
     494inline HangingPunctuation operator| (HangingPunctuation a, HangingPunctuation b) { return HangingPunctuation(int(a) | int(b)); }
     495inline HangingPunctuation& operator|= (HangingPunctuation& a, HangingPunctuation b) { return a = a | b; }
     496
    487497enum EEmptyCell {
    488498    SHOW, HIDE
  • trunk/Source/WebCore/rendering/style/StyleRareInheritedData.cpp

    r192290 r196075  
    126126    , trailingWord(static_cast<unsigned>(RenderStyle::initialTrailingWord()))
    127127#endif
     128    , m_hangingPunctuation(RenderStyle::initialHangingPunctuation())
    128129    , hyphenationLimitBefore(-1)
    129130    , hyphenationLimitAfter(-1)
     
    208209    , trailingWord(o.trailingWord)
    209210#endif
     211    , m_hangingPunctuation(o.m_hangingPunctuation)
    210212    , hyphenationString(o.hyphenationString)
    211213    , hyphenationLimitBefore(o.hyphenationLimitBefore)
     
    314316        && trailingWord == o.trailingWord
    315317#endif
     318        && m_hangingPunctuation == o.m_hangingPunctuation
    316319        && m_customProperties == o.m_customProperties
    317320        && arePointingToEqualData(listStyleImage, o.listStyleImage);
  • trunk/Source/WebCore/rendering/style/StyleRareInheritedData.h

    r195699 r196075  
    138138#endif
    139139
     140    unsigned m_hangingPunctuation : 4;
     141
    140142    AtomicString hyphenationString;
    141143    short hyphenationLimitBefore;
Note: See TracChangeset for help on using the changeset viewer.