Changeset 145450 in webkit


Ignore:
Timestamp:
Mar 11, 2013 6:10:35 PM (11 years ago)
Author:
commit-queue@webkit.org
Message:

[css3-text] Add partial parsing support for text-underline-position property from CSS3 Text
https://bugs.webkit.org/show_bug.cgi?id=102491

Patch by Lamarque V. Souza <Lamarque.Souza@basyskom.com> on 2013-03-11
Reviewed by Julien Chaffraix.

Source/WebCore:

This patch extends the existing parsing to support 'auto', 'alphabetic' and 'under'. We don't fully match
the specification as we don't support [ left | right ] and this is left for another implementation
as the rendering will need to be added.

Test: fast/css3-text/css3-text-decoration/getComputedStyle/getComputedStyle-text-underline-position.html

  • css/CSSComputedStyleDeclaration.cpp:

(WebCore::CSSComputedStyleDeclaration::getPropertyCSSValue):

  • css/CSSParser.cpp:

(WebCore::CSSParser::parseValue):
(WebCore::CSSParser::parseTextUnderlinePosition):

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

(WebCore::CSSPrimitiveValue::CSSPrimitiveValue):
(WebCore::CSSPrimitiveValue::operator TextUnderlinePosition):

  • css/CSSProperty.cpp:

(WebCore::CSSProperty::isInheritedProperty):
Added parsing-related checks for text-underline-position property.

  • css/CSSPropertyNames.in: Added '-webkit-underline-position' property.
  • css/CSSValueKeywords.in:
  • css/SVGCSSValueKeywords.in:
  • css/StyleBuilder.cpp:

(ApplyPropertyTextUnderlinePosition):
(WebCore::ApplyPropertyTextUnderlinePosition::applyValue):
(WebCore::ApplyPropertyTextUnderlinePosition::createHandler):
(WebCore::StyleBuilder::StyleBuilder):
Set property handler for text-underline-position.

  • css/StyleResolver.cpp:

(WebCore::StyleResolver::applyProperty):

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

(WebCore::StyleRareInheritedData::StyleRareInheritedData):
(WebCore::StyleRareInheritedData::operator==):
Added support for m_textUnderlinePosition on copy constructor and operator
assignment functions.

  • rendering/style/StyleRareInheritedData.h:

(StyleRareInheritedData): Added m_textUnderlinePosition here as it won't be used regularly.

LayoutTests:

Added getComputedStyle layout tests for 'text-underline-position' CSS3
property, with 'webkit' prefix.

  • fast/css3-text/css3-text-decoration/getComputedStyle/getComputedStyle-text-underline-position-expected.txt: Added.
  • fast/css3-text/css3-text-decoration/getComputedStyle/getComputedStyle-text-underline-position.html: Added.
  • fast/css3-text/css3-text-decoration/getComputedStyle/script-tests/getComputedStyle-text-underline-position.js: Added.

(testElementStyle):
(testComputedStyle):

Location:
trunk
Files:
3 added
16 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r145448 r145450  
     12013-03-11  Lamarque V. Souza  <Lamarque.Souza@basyskom.com>
     2
     3        [css3-text] Add partial parsing support for text-underline-position property from CSS3 Text
     4        https://bugs.webkit.org/show_bug.cgi?id=102491
     5
     6        Reviewed by Julien Chaffraix.
     7
     8        Added getComputedStyle layout tests for 'text-underline-position' CSS3
     9        property, with 'webkit' prefix.
     10
     11        * fast/css3-text/css3-text-decoration/getComputedStyle/getComputedStyle-text-underline-position-expected.txt: Added.
     12        * fast/css3-text/css3-text-decoration/getComputedStyle/getComputedStyle-text-underline-position.html: Added.
     13        * fast/css3-text/css3-text-decoration/getComputedStyle/script-tests/getComputedStyle-text-underline-position.js: Added.
     14        (testElementStyle):
     15        (testComputedStyle):
     16
    1172013-03-11  Christian Biesinger  <cbiesinger@chromium.org>
    218
  • trunk/Source/WebCore/ChangeLog

    r145448 r145450  
     12013-03-11  Lamarque V. Souza  <Lamarque.Souza@basyskom.com>
     2
     3        [css3-text] Add partial parsing support for text-underline-position property from CSS3 Text
     4        https://bugs.webkit.org/show_bug.cgi?id=102491
     5
     6        Reviewed by Julien Chaffraix.
     7
     8        This patch extends the existing parsing to support 'auto', 'alphabetic' and 'under'. We don't fully match
     9        the specification as we don't support [ left | right ] and this is left for another implementation
     10        as the rendering will need to be added.
     11
     12        Test: fast/css3-text/css3-text-decoration/getComputedStyle/getComputedStyle-text-underline-position.html
     13
     14        * css/CSSComputedStyleDeclaration.cpp:
     15        (WebCore::CSSComputedStyleDeclaration::getPropertyCSSValue):
     16        * css/CSSParser.cpp:
     17        (WebCore::CSSParser::parseValue):
     18        (WebCore::CSSParser::parseTextUnderlinePosition):
     19        * css/CSSParser.h:
     20        * css/CSSPrimitiveValueMappings.h:
     21        (WebCore::CSSPrimitiveValue::CSSPrimitiveValue):
     22        (WebCore::CSSPrimitiveValue::operator TextUnderlinePosition):
     23        * css/CSSProperty.cpp:
     24        (WebCore::CSSProperty::isInheritedProperty):
     25        Added parsing-related checks for text-underline-position property.
     26        * css/CSSPropertyNames.in: Added '-webkit-underline-position' property.
     27        * css/CSSValueKeywords.in:
     28        * css/SVGCSSValueKeywords.in:
     29        * css/StyleBuilder.cpp:
     30        (ApplyPropertyTextUnderlinePosition):
     31        (WebCore::ApplyPropertyTextUnderlinePosition::applyValue):
     32        (WebCore::ApplyPropertyTextUnderlinePosition::createHandler):
     33        (WebCore::StyleBuilder::StyleBuilder):
     34        Set property handler for text-underline-position.
     35        * css/StyleResolver.cpp:
     36        (WebCore::StyleResolver::applyProperty):
     37        * rendering/style/RenderStyle.h:
     38        * rendering/style/RenderStyleConstants.h:
     39        * rendering/style/StyleRareInheritedData.cpp:
     40        (WebCore::StyleRareInheritedData::StyleRareInheritedData):
     41        (WebCore::StyleRareInheritedData::operator==):
     42        Added support for m_textUnderlinePosition on copy constructor and operator
     43        assignment functions.
     44        * rendering/style/StyleRareInheritedData.h:
     45        (StyleRareInheritedData): Added m_textUnderlinePosition here as it won't be used regularly.
     46
    1472013-03-11  Christian Biesinger  <cbiesinger@chromium.org>
    248
  • trunk/Source/WebCore/css/CSSComputedStyleDeclaration.cpp

    r145168 r145450  
    192192    CSSPropertyWebkitTextDecorationStyle,
    193193    CSSPropertyWebkitTextAlignLast,
     194    CSSPropertyWebkitTextUnderlinePosition,
    194195#endif // CSS3_TEXT
    195196    CSSPropertyTextIndent,
     
    21562157        case CSSPropertyWebkitTextAlignLast:
    21572158            return cssValuePool().createValue(style->textAlignLast());
     2159        case CSSPropertyWebkitTextUnderlinePosition:
     2160            return cssValuePool().createValue(style->textUnderlinePosition());
    21582161#endif // CSS3_TEXT
    21592162        case CSSPropertyWebkitTextDecorationsInEffect:
  • trunk/Source/WebCore/css/CSSParser.cpp

    r145168 r145450  
    22972297            validPrimitive = true;
    22982298        break;
     2299
     2300    case CSSPropertyWebkitTextUnderlinePosition:
     2301        // auto | alphabetic | under
     2302        return parseTextUnderlinePosition(important);
    22992303#endif // CSS3_TEXT
    23002304
     
    91429146}
    91439147
     9148#if ENABLE(CSS3_TEXT)
     9149bool CSSParser::parseTextUnderlinePosition(bool important)
     9150{
     9151    // The text-underline-position property has sintax "auto | alphabetic | [ under || [ left | right ] ]".
     9152    // However, values 'left' and 'right' are not implemented yet, so we will parse sintax
     9153    // "auto | alphabetic | under" for now.
     9154    CSSParserValue* value = m_valueList->current();
     9155    switch (value->id) {
     9156    case CSSValueAuto:
     9157    case CSSValueAlphabetic:
     9158    case CSSValueUnder:
     9159        if (m_valueList->next())
     9160            return false;
     9161
     9162        addProperty(CSSPropertyWebkitTextUnderlinePosition, cssValuePool().createIdentifierValue(value->id), important);
     9163        return true;
     9164    }
     9165    return false;
     9166}
     9167#endif // CSS3_TEXT
     9168
    91449169bool CSSParser::parseTextEmphasisStyle(bool important)
    91459170{
  • trunk/Source/WebCore/css/CSSParser.h

    r145029 r145450  
    265265    void addTextDecorationProperty(CSSPropertyID, PassRefPtr<CSSValue>, bool important);
    266266    bool parseTextDecoration(CSSPropertyID propId, bool important);
     267#if ENABLE(CSS3_TEXT)
     268    bool parseTextUnderlinePosition(bool important);
     269#endif // CSS3_TEXT
    267270
    268271    bool parseLineBoxContain(bool important);
  • trunk/Source/WebCore/css/CSSPrimitiveValueMappings.h

    r145196 r145450  
    23972397    ASSERT_NOT_REACHED();
    23982398    return TextDecorationStyleSolid;
     2399}
     2400
     2401template<> inline CSSPrimitiveValue::CSSPrimitiveValue(TextUnderlinePosition e)
     2402    : CSSValue(PrimitiveClass)
     2403{
     2404    m_primitiveUnitType = CSS_IDENT;
     2405    switch (e) {
     2406    case TextUnderlinePositionAuto:
     2407        m_value.ident = CSSValueAuto;
     2408        break;
     2409    case TextUnderlinePositionAlphabetic:
     2410        m_value.ident = CSSValueAlphabetic;
     2411        break;
     2412    case TextUnderlinePositionUnder:
     2413        m_value.ident = CSSValueUnder;
     2414        break;
     2415    }
     2416
     2417    // FIXME: Implement support for 'under left' and 'under right' values.
     2418}
     2419
     2420template<> inline CSSPrimitiveValue::operator TextUnderlinePosition() const
     2421{
     2422    switch (m_value.ident) {
     2423    case CSSValueAuto:
     2424        return TextUnderlinePositionAuto;
     2425    case CSSValueAlphabetic:
     2426        return TextUnderlinePositionAlphabetic;
     2427    case CSSValueUnder:
     2428        return TextUnderlinePositionUnder;
     2429    }
     2430
     2431    // FIXME: Implement support for 'under left' and 'under right' values.
     2432
     2433    ASSERT_NOT_REACHED();
     2434    return TextUnderlinePositionAuto;
    23992435}
    24002436#endif // CSS3_TEXT
  • trunk/Source/WebCore/css/CSSProperty.cpp

    r145168 r145450  
    333333    case CSSPropertyWebkitTextDecorationLine:
    334334    case CSSPropertyWebkitTextAlignLast:
     335    case CSSPropertyWebkitTextUnderlinePosition:
    335336#endif // CSS3_TEXT
    336337    case CSSPropertyWebkitTextDecorationsInEffect:
  • trunk/Source/WebCore/css/CSSPropertyNames.in

    r145168 r145450  
    373373-webkit-text-decoration-style
    374374-webkit-text-align-last
     375-webkit-text-underline-position
    375376#endif
    376377-webkit-text-decorations-in-effect
  • trunk/Source/WebCore/css/CSSValueKeywords.in

    r145255 r145450  
    953953edges
    954954
     955#if (defined(ENABLE_SVG) && ENABLE_SVG) || (defined(ENABLE_CSS3_TEXT) && ENABLE_CSS3_TEXT)
     956alphabetic
     957#endif
     958
    955959// position
    956960#if defined(ENABLE_CSS_STICKY_POSITION) && ENABLE_CSS_STICKY_POSITION
  • trunk/Source/WebCore/css/SVGCSSValueKeywords.in

    r129018 r145450  
    242242text-after-edge
    243243ideographic
    244 alphabetic
    245244hanging
    246245mathematical
  • trunk/Source/WebCore/css/StyleBuilder.cpp

    r145168 r145450  
    11491149    }
    11501150};
     1151
     1152#if ENABLE(CSS3_TEXT)
     1153class ApplyPropertyTextUnderlinePosition {
     1154public:
     1155    static void applyValue(CSSPropertyID, StyleResolver* styleResolver, CSSValue* value)
     1156    {
     1157        // This is true if value is 'auto' or 'alphabetic'.
     1158        if (value->isPrimitiveValue()) {
     1159            TextUnderlinePosition t = *static_cast<CSSPrimitiveValue*>(value);
     1160            styleResolver->style()->setTextUnderlinePosition(t);
     1161            return;
     1162        }
     1163
     1164        unsigned t = 0;
     1165        for (CSSValueListIterator i(value); i.hasMore(); i.advance()) {
     1166            CSSValue* item = i.value();
     1167            ASSERT(item->isPrimitiveValue());
     1168            TextUnderlinePosition t2 = *static_cast<CSSPrimitiveValue*>(item);
     1169            t |= t2;
     1170        }
     1171        styleResolver->style()->setTextUnderlinePosition(static_cast<TextUnderlinePosition>(t));
     1172    }
     1173    static PropertyHandler createHandler()
     1174    {
     1175        PropertyHandler handler = ApplyPropertyDefaultBase<TextUnderlinePosition, &RenderStyle::textUnderlinePosition, TextUnderlinePosition, &RenderStyle::setTextUnderlinePosition, TextUnderlinePosition, &RenderStyle::initialTextUnderlinePosition>::createHandler();
     1176        return PropertyHandler(handler.inheritFunction(), handler.initialFunction(), &applyValue);
     1177    }
     1178};
     1179#endif // CSS3_TEXT
    11511180
    11521181class ApplyPropertyLineHeight {
     
    19041933    setPropertyHandler(CSSPropertyWebkitTextDecorationStyle, ApplyPropertyDefault<TextDecorationStyle, &RenderStyle::textDecorationStyle, TextDecorationStyle, &RenderStyle::setTextDecorationStyle, TextDecorationStyle, &RenderStyle::initialTextDecorationStyle>::createHandler());
    19051934    setPropertyHandler(CSSPropertyWebkitTextAlignLast, ApplyPropertyDefault<TextAlignLast, &RenderStyle::textAlignLast, TextAlignLast, &RenderStyle::setTextAlignLast, TextAlignLast, &RenderStyle::initialTextAlignLast>::createHandler());
     1935    setPropertyHandler(CSSPropertyWebkitTextUnderlinePosition, ApplyPropertyTextUnderlinePosition::createHandler());
    19061936#endif // CSS3_TEXT
    19071937    setPropertyHandler(CSSPropertyTextIndent, ApplyPropertyLength<&RenderStyle::textIndent, &RenderStyle::setTextIndent, &RenderStyle::initialTextIndent>::createHandler());
  • trunk/Source/WebCore/css/StyleResolver.cpp

    r145397 r145450  
    38053805    case CSSPropertyWebkitTextDecorationStyle:
    38063806    case CSSPropertyWebkitTextAlignLast:
     3807    case CSSPropertyWebkitTextUnderlinePosition:
    38073808#endif // CSS3_TEXT
    38083809    case CSSPropertyWebkitTextEmphasisColor:
  • trunk/Source/WebCore/rendering/style/RenderStyle.h

    r145391 r145450  
    576576    TextDecorationStyle textDecorationStyle() const { return static_cast<TextDecorationStyle>(rareNonInheritedData->m_textDecorationStyle); }
    577577    TextAlignLast textAlignLast() const { return static_cast<TextAlignLast>(rareInheritedData->m_textAlignLast); }
     578    TextUnderlinePosition textUnderlinePosition() const { return static_cast<TextUnderlinePosition>(rareInheritedData->m_textUnderlinePosition); }
    578579#else
    579580    TextDecorationStyle textDecorationStyle() const { return TextDecorationStyleSolid; }
     
    11381139    void setTextDecorationStyle(TextDecorationStyle v) { SET_VAR(rareNonInheritedData, m_textDecorationStyle, v); }
    11391140    void setTextAlignLast(TextAlignLast v) { SET_VAR(rareInheritedData, m_textAlignLast, v); }
     1141    void setTextUnderlinePosition(TextUnderlinePosition v) { SET_VAR(rareInheritedData, m_textUnderlinePosition, v); }
    11401142#endif // CSS3_TEXT
    11411143    void setDirection(TextDirection v) { inherited_flags._direction = v; }
     
    16121614    static TextDecorationStyle initialTextDecorationStyle() { return TextDecorationStyleSolid; }
    16131615    static TextAlignLast initialTextAlignLast() { return TextAlignLastAuto; }
     1616    static TextUnderlinePosition initialTextUnderlinePosition() { return TextUnderlinePositionAuto; }
    16141617#endif // CSS3_TEXT
    16151618    static float initialZoom() { return 1.0f; }
  • trunk/Source/WebCore/rendering/style/RenderStyleConstants.h

    r145003 r145450  
    359359    TextAlignLastAuto, TextAlignLastStart, TextAlignLastEnd, TextAlignLastLeft, TextAlignLastRight, TextAlignLastCenter, TextAlignLastJustify
    360360};
     361
     362enum TextUnderlinePosition {
     363    // FIXME: Implement support for 'under left' and 'under right' values.
     364    TextUnderlinePositionAuto = 0x1, TextUnderlinePositionAlphabetic = 0x2, TextUnderlinePositionUnder = 0x4
     365};
    361366#endif // CSS3_TEXT
    362367
  • trunk/Source/WebCore/rendering/style/StyleRareInheritedData.cpp

    r145168 r145450  
    104104#if ENABLE(CSS3_TEXT)
    105105    , m_textAlignLast(RenderStyle::initialTextAlignLast())
     106    , m_textUnderlinePosition(RenderStyle::initialTextUnderlinePosition())
    106107#endif // CSS3_TEXT
    107108    , m_rubyPosition(RenderStyle::initialRubyPosition())
     
    173174#if ENABLE(CSS3_TEXT)
    174175    , m_textAlignLast(o.m_textAlignLast)
     176    , m_textUnderlinePosition(o.m_textUnderlinePosition)
    175177#endif // CSS3_TEXT
    176178    , m_rubyPosition(o.m_rubyPosition)
     
    268270#if ENABLE(CSS3_TEXT)
    269271        && m_textAlignLast == o.m_textAlignLast
     272        && m_textUnderlinePosition == o.m_textUnderlinePosition
    270273#endif // CSS3_TEXT
    271274        && m_rubyPosition == o.m_rubyPosition
  • trunk/Source/WebCore/rendering/style/StyleRareInheritedData.h

    r145168 r145450  
    118118#if ENABLE(CSS3_TEXT)
    119119    unsigned m_textAlignLast : 3; // TextAlignLast
     120    unsigned m_textUnderlinePosition : 3; // TextUnderlinePosition
    120121#endif // CSS3_TEXT
    121122    unsigned m_rubyPosition : 1; // RubyPosition
Note: See TracChangeset for help on using the changeset viewer.