Changeset 175581 in webkit


Ignore:
Timestamp:
Nov 4, 2014 2:32:15 PM (10 years ago)
Author:
Chris Dumez
Message:

Move -webkit-text-emphasis-position to the new StyleBuilder
https://bugs.webkit.org/show_bug.cgi?id=138359

Reviewed by Andreas Kling.

Move -webkit-text-emphasis-position from DeprecatedStyleBilder to the
new StyleBuilder so that it is now generated from CSSPropertyNames.in.
A new TextEmphasisPosition Converter was added to support this.

No new tests, no behavior change.

  • css/CSSPropertyNames.in:
  • css/DeprecatedStyleBuilder.cpp:

(WebCore::DeprecatedStyleBuilder::DeprecatedStyleBuilder):
(WebCore::valueToEmphasisPosition): Deleted.
(WebCore::ApplyPropertyTextEmphasisPosition::applyValue): Deleted.
(WebCore::ApplyPropertyTextEmphasisPosition::createHandler): Deleted.

  • css/StyleBuilderConverter.h:

(WebCore::StyleBuilderConverter::valueToEmphasisPosition):
(WebCore::StyleBuilderConverter::convertTextEmphasisPosition):

Location:
trunk/Source/WebCore
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r175580 r175581  
     12014-11-04  Chris Dumez  <cdumez@apple.com>
     2
     3        Move -webkit-text-emphasis-position to the new StyleBuilder
     4        https://bugs.webkit.org/show_bug.cgi?id=138359
     5
     6        Reviewed by Andreas Kling.
     7
     8        Move -webkit-text-emphasis-position from DeprecatedStyleBilder to the
     9        new StyleBuilder so that it is now generated from CSSPropertyNames.in.
     10        A new TextEmphasisPosition Converter was added to support this.
     11
     12        No new tests, no behavior change.
     13
     14        * css/CSSPropertyNames.in:
     15        * css/DeprecatedStyleBuilder.cpp:
     16        (WebCore::DeprecatedStyleBuilder::DeprecatedStyleBuilder):
     17        (WebCore::valueToEmphasisPosition): Deleted.
     18        (WebCore::ApplyPropertyTextEmphasisPosition::applyValue): Deleted.
     19        (WebCore::ApplyPropertyTextEmphasisPosition::createHandler): Deleted.
     20        * css/StyleBuilderConverter.h:
     21        (WebCore::StyleBuilderConverter::valueToEmphasisPosition):
     22        (WebCore::StyleBuilderConverter::convertTextEmphasisPosition):
     23
    1242014-11-04  Andreas Kling  <akling@apple.com>
    225
  • trunk/Source/WebCore/css/CSSPropertyNames.in

    r175481 r175581  
    482482-epub-text-emphasis-color = -webkit-text-emphasis-color
    483483text-emphasis-color = -webkit-text-emphasis-color
    484 -webkit-text-emphasis-position [Inherited]
     484-webkit-text-emphasis-position [Inherited, NewStyleBuilder, Converter=TextEmphasisPosition]
    485485text-emphasis-position = -webkit-text-emphasis-position
    486486-webkit-text-emphasis-style [Inherited]
  • trunk/Source/WebCore/css/DeprecatedStyleBuilder.cpp

    r175513 r175581  
    14761476
    14771477    static PropertyHandler createHandler() { return PropertyHandler(&applyInheritValue, &applyInitialValue, &applyValue); }
    1478 };
    1479 
    1480 static TextEmphasisPosition valueToEmphasisPosition(CSSPrimitiveValue& primitiveValue)
    1481 {
    1482     ASSERT(primitiveValue.isValueID());
    1483 
    1484     switch (primitiveValue.getValueID()) {
    1485     case CSSValueOver:
    1486         return TextEmphasisPositionOver;
    1487     case CSSValueUnder:
    1488         return TextEmphasisPositionUnder;
    1489     case CSSValueLeft:
    1490         return TextEmphasisPositionLeft;
    1491     case CSSValueRight:
    1492         return TextEmphasisPositionRight;
    1493     default:
    1494         break;
    1495     }
    1496 
    1497     ASSERT_NOT_REACHED();
    1498     return RenderStyle::initialTextEmphasisPosition();
    1499 }
    1500 
    1501 class ApplyPropertyTextEmphasisPosition {
    1502 public:
    1503     static void applyValue(CSSPropertyID, StyleResolver* styleResolver, CSSValue* value)
    1504     {
    1505         if (is<CSSPrimitiveValue>(*value)) {
    1506             styleResolver->style()->setTextEmphasisPosition(valueToEmphasisPosition(downcast<CSSPrimitiveValue>(*value)));
    1507             return;
    1508         }
    1509 
    1510         TextEmphasisPosition position = 0;
    1511         if (is<CSSValueList>(*value)) {
    1512             for (auto& currentValue : downcast<CSSValueList>(*value))
    1513                 position |= valueToEmphasisPosition(downcast<CSSPrimitiveValue>(currentValue.get()));
    1514         }
    1515         styleResolver->style()->setTextEmphasisPosition(position);
    1516     }
    1517     static PropertyHandler createHandler()
    1518     {
    1519         PropertyHandler handler = ApplyPropertyDefaultBase<TextEmphasisPosition, &RenderStyle::textEmphasisPosition, TextEmphasisPosition, &RenderStyle::setTextEmphasisPosition, TextEmphasisPosition, &RenderStyle::initialTextEmphasisPosition>::createHandler();
    1520         return PropertyHandler(handler.inheritFunction(), handler.initialFunction(), &applyValue);
    1521     }
    15221478};
    15231479
     
    20271983    setPropertyHandler(CSSPropertyWebkitPerspectiveOrigin, ApplyPropertyExpanding<SuppressValue, CSSPropertyWebkitPerspectiveOriginX, CSSPropertyWebkitPerspectiveOriginY>::createHandler());
    20281984    setPropertyHandler(CSSPropertyWebkitTextEmphasisColor, ApplyPropertyColor<NoInheritFromParent, &RenderStyle::textEmphasisColor, &RenderStyle::setTextEmphasisColor, &RenderStyle::setVisitedLinkTextEmphasisColor, &RenderStyle::color>::createHandler());
    2029     setPropertyHandler(CSSPropertyWebkitTextEmphasisPosition, ApplyPropertyTextEmphasisPosition::createHandler());
    20301985    setPropertyHandler(CSSPropertyWebkitTextEmphasisStyle, ApplyPropertyTextEmphasisStyle::createHandler());
    20311986    setPropertyHandler(CSSPropertyWebkitTextFillColor, ApplyPropertyColor<NoInheritFromParent, &RenderStyle::textFillColor, &RenderStyle::setTextFillColor, &RenderStyle::setVisitedLinkTextFillColor, &RenderStyle::color>::createHandler());
  • trunk/Source/WebCore/css/StyleBuilderConverter.h

    r175487 r175581  
    5757    static String convertStringOrAuto(StyleResolver&, CSSValue&);
    5858    static String convertStringOrNone(StyleResolver&, CSSValue&);
     59    static TextEmphasisPosition convertTextEmphasisPosition(StyleResolver&, CSSValue&);
    5960
    6061private:
    6162    static Length convertToRadiusLength(CSSToLengthConversionData&, CSSPrimitiveValue&);
     63    static TextEmphasisPosition valueToEmphasisPosition(CSSPrimitiveValue&);
    6264};
    6365
     
    274276}
    275277
     278inline TextEmphasisPosition StyleBuilderConverter::valueToEmphasisPosition(CSSPrimitiveValue& primitiveValue)
     279{
     280    ASSERT(primitiveValue.isValueID());
     281
     282    switch (primitiveValue.getValueID()) {
     283    case CSSValueOver:
     284        return TextEmphasisPositionOver;
     285    case CSSValueUnder:
     286        return TextEmphasisPositionUnder;
     287    case CSSValueLeft:
     288        return TextEmphasisPositionLeft;
     289    case CSSValueRight:
     290        return TextEmphasisPositionRight;
     291    default:
     292        break;
     293    }
     294
     295    ASSERT_NOT_REACHED();
     296    return RenderStyle::initialTextEmphasisPosition();
     297}
     298
     299inline TextEmphasisPosition StyleBuilderConverter::convertTextEmphasisPosition(StyleResolver&, CSSValue& value)
     300{
     301    if (is<CSSPrimitiveValue>(value))
     302        return valueToEmphasisPosition(downcast<CSSPrimitiveValue>(value));
     303
     304    TextEmphasisPosition position = 0;
     305    for (auto& currentValue : downcast<CSSValueList>(value))
     306        position |= valueToEmphasisPosition(downcast<CSSPrimitiveValue>(currentValue.get()));
     307    return position;
     308}
     309
    276310} // namespace WebCore
    277311
Note: See TracChangeset for help on using the changeset viewer.