Changeset 175625 in webkit


Ignore:
Timestamp:
Nov 5, 2014 10:24:57 AM (10 years ago)
Author:
Chris Dumez
Message:

Move text-align CSS property to the new StyleBuilder
https://bugs.webkit.org/show_bug.cgi?id=138398

Reviewed by Antti Koivisto.

Move text-align CSS property from DeprecatedStyleBuilder to the new
StyleBuilder so that it is now generated from CSSPropertyNames.in.
This patch adds a TextAlign Converter to support this.

No new tests, no behavior change.

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

(WebCore::DeprecatedStyleBuilder::DeprecatedStyleBuilder):
(WebCore::ApplyPropertyTextAlign::applyValue): Deleted.
(WebCore::ApplyPropertyTextAlign::createHandler): Deleted.

  • css/StyleBuilderConverter.h:

(WebCore::StyleBuilderConverter::convertTextAlign):

Location:
trunk/Source/WebCore
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r175623 r175625  
     12014-11-05  Chris Dumez  <cdumez@apple.com>
     2
     3        Move text-align CSS property to the new StyleBuilder
     4        https://bugs.webkit.org/show_bug.cgi?id=138398
     5
     6        Reviewed by Antti Koivisto.
     7
     8        Move text-align CSS property from DeprecatedStyleBuilder to the new
     9        StyleBuilder so that it is now generated from CSSPropertyNames.in.
     10        This patch adds a TextAlign Converter 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::ApplyPropertyTextAlign::applyValue): Deleted.
     18        (WebCore::ApplyPropertyTextAlign::createHandler): Deleted.
     19        * css/StyleBuilderConverter.h:
     20        (WebCore::StyleBuilderConverter::convertTextAlign):
     21
    1222014-11-05  Sanghyup Lee  <sh53.lee@samsung.com>
    223
  • trunk/Source/WebCore/css/CSSPropertyNames.in

    r175581 r175625  
    216216table-layout [NewStyleBuilder]
    217217tab-size [Inherited, NewStyleBuilder, TypeName=unsigned]
    218 text-align [Inherited]
     218text-align [Inherited, NewStyleBuilder, Converter=TextAlign]
    219219text-decoration [NewStyleBuilder, Converter=TextDecoration]
    220220text-indent [Inherited]
  • trunk/Source/WebCore/css/DeprecatedStyleBuilder.cpp

    r175581 r175625  
    978978
    979979    static PropertyHandler createHandler() { return PropertyHandler(&applyInheritValue, &applyInitialValue, &applyValue); }
    980 };
    981 
    982 class ApplyPropertyTextAlign {
    983 public:
    984     static void applyValue(CSSPropertyID, StyleResolver* styleResolver, CSSValue* value)
    985     {
    986         if (!is<CSSPrimitiveValue>(*value))
    987             return;
    988 
    989         CSSPrimitiveValue& primitiveValue = downcast<CSSPrimitiveValue>(*value);
    990         ASSERT(primitiveValue.isValueID());
    991 
    992         if (primitiveValue.getValueID() != CSSValueWebkitMatchParent)
    993             styleResolver->style()->setTextAlign(primitiveValue);
    994         else if (styleResolver->parentStyle()->textAlign() == TASTART)
    995             styleResolver->style()->setTextAlign(styleResolver->parentStyle()->isLeftToRightDirection() ? LEFT : RIGHT);
    996         else if (styleResolver->parentStyle()->textAlign() == TAEND)
    997             styleResolver->style()->setTextAlign(styleResolver->parentStyle()->isLeftToRightDirection() ? RIGHT : LEFT);
    998         else
    999             styleResolver->style()->setTextAlign(styleResolver->parentStyle()->textAlign());
    1000     }
    1001     static PropertyHandler createHandler()
    1002     {
    1003         PropertyHandler handler = ApplyPropertyDefaultBase<ETextAlign, &RenderStyle::textAlign, ETextAlign, &RenderStyle::setTextAlign, ETextAlign, &RenderStyle::initialTextAlign>::createHandler();
    1004         return PropertyHandler(handler.inheritFunction(), handler.initialFunction(), &applyValue);
    1005     }
    1006980};
    1007981
     
    19381912    setPropertyHandler(CSSPropertyResize, ApplyPropertyResize::createHandler());
    19391913    setPropertyHandler(CSSPropertySize, ApplyPropertyPageSize::createHandler());
    1940     setPropertyHandler(CSSPropertyTextAlign, ApplyPropertyTextAlign::createHandler());
    19411914    setPropertyHandler(CSSPropertyWebkitTextDecorationColor, ApplyPropertyColor<NoInheritFromParent, &RenderStyle::textDecorationColor, &RenderStyle::setTextDecorationColor, &RenderStyle::setVisitedLinkTextDecorationColor, &RenderStyle::color>::createHandler());
    19421915    setPropertyHandler(CSSPropertyWebkitTextDecorationSkip, ApplyPropertyTextDecorationSkip::createHandler());
  • trunk/Source/WebCore/css/StyleBuilderConverter.h

    r175581 r175625  
    5858    static String convertStringOrNone(StyleResolver&, CSSValue&);
    5959    static TextEmphasisPosition convertTextEmphasisPosition(StyleResolver&, CSSValue&);
     60    static ETextAlign convertTextAlign(StyleResolver&, CSSValue&);
    6061
    6162private:
     
    308309}
    309310
     311inline ETextAlign StyleBuilderConverter::convertTextAlign(StyleResolver& styleResolver, CSSValue& value)
     312{
     313    auto& primitiveValue = downcast<CSSPrimitiveValue>(value);
     314    ASSERT(primitiveValue.isValueID());
     315
     316    if (primitiveValue.getValueID() != CSSValueWebkitMatchParent)
     317        return primitiveValue;
     318
     319    auto* parentStyle = styleResolver.parentStyle();
     320    if (parentStyle->textAlign() == TASTART)
     321        return parentStyle->isLeftToRightDirection() ? LEFT : RIGHT;
     322    if (parentStyle->textAlign() == TAEND)
     323        return parentStyle->isLeftToRightDirection() ? RIGHT : LEFT;
     324    return parentStyle->textAlign();
     325}
     326
    310327} // namespace WebCore
    311328
Note: See TracChangeset for help on using the changeset viewer.