Changeset 92742 in webkit


Ignore:
Timestamp:
Aug 9, 2011 6:44:07 PM (13 years ago)
Author:
macpherson@chromium.org
Message:

Implement string based properties in CSSStyleApplyProperty.
https://bugs.webkit.org/show_bug.cgi?id=65662

Reviewed by Darin Adler.

No new tests / refactoring only.

  • css/CSSStyleApplyProperty.cpp:

(WebCore::ApplyPropertyString::ApplyPropertyString):
Added class to handle string based properties.
(WebCore::ApplyPropertyString::applyValue):
(WebCore::CSSStyleApplyProperty::CSSStyleApplyProperty):
Add initializers for CSSPropertyWebkitHighlight and CSSPropertyWebkitHyphenateCharacter.

  • css/CSSStyleSelector.cpp:

(WebCore::CSSStyleSelector::applyProperty):
Remove existing implementations for CSSPropertyWebkitHighlight and CSSPropertyWebkitHyphenateCharacter.

Location:
trunk/Source/WebCore
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r92712 r92742  
     12011-08-09  Luke Macpherson   <macpherson@chromium.org>
     2
     3        Implement string based properties in CSSStyleApplyProperty.
     4        https://bugs.webkit.org/show_bug.cgi?id=65662
     5
     6        Reviewed by Darin Adler.
     7
     8        No new tests / refactoring only.
     9
     10        * css/CSSStyleApplyProperty.cpp:
     11        (WebCore::ApplyPropertyString::ApplyPropertyString):
     12        Added class to handle string based properties.
     13        (WebCore::ApplyPropertyString::applyValue):
     14        (WebCore::CSSStyleApplyProperty::CSSStyleApplyProperty):
     15        Add initializers for CSSPropertyWebkitHighlight and CSSPropertyWebkitHyphenateCharacter.
     16        * css/CSSStyleSelector.cpp:
     17        (WebCore::CSSStyleSelector::applyProperty):
     18        Remove existing implementations for CSSPropertyWebkitHighlight and CSSPropertyWebkitHyphenateCharacter.
     19
    1202011-08-09  Emil A Eklund  <eae@chromium.org>
    221
  • trunk/Source/WebCore/css/CSSStyleApplyProperty.cpp

    r92243 r92742  
    266266};
    267267
    268 enum LengthAuto {AutoDisabled = 0, AutoEnabled = 1};
    269 enum LengthIntrinsic {IntrinsicDisabled = 0, IntrinsicEnabled = 1};
    270 enum LengthMinIntrinsic {MinIntrinsicDisabled = 0, MinIntrinsicEnabled = 1};
    271 enum LengthNone {NoneDisabled = 0, NoneEnabled = 1};
    272 enum LengthUndefined {UndefinedDisabled = 0, UndefinedEnabled = 1};
    273 enum LengthFlexDirection {FlexDirectionDisabled = 0, FlexWidth = 1, FlexHeight};
     268enum LengthAuto { AutoDisabled = 0, AutoEnabled };
     269enum LengthIntrinsic { IntrinsicDisabled = 0, IntrinsicEnabled };
     270enum LengthMinIntrinsic { MinIntrinsicDisabled = 0, MinIntrinsicEnabled };
     271enum LengthNone { NoneDisabled = 0, NoneEnabled };
     272enum LengthUndefined { UndefinedDisabled = 0, UndefinedEnabled };
     273enum LengthFlexDirection { FlexDirectionDisabled = 0, FlexWidth, FlexHeight };
    274274template <LengthAuto autoEnabled = AutoDisabled,
    275275          LengthIntrinsic intrinsicEnabled = IntrinsicDisabled,
     
    330330                setValue(selector->style(), Length(primitiveValue->getDoubleValue(), Percent));
    331331        }
     332    }
     333};
     334
     335enum StringIdentBehavior { NothingMapsToNull = 0, MapNoneToNull, MapAutoToNull };
     336template <StringIdentBehavior identBehavior = NothingMapsToNull>
     337class ApplyPropertyString : public ApplyPropertyDefaultBase<const AtomicString&> {
     338public:
     339    ApplyPropertyString(GetterFunction getter, SetterFunction setter, InitialFunction initial)
     340        : ApplyPropertyDefaultBase<const AtomicString&>(getter, setter, initial)
     341    {
     342    }
     343
     344private:
     345    virtual void applyValue(CSSStyleSelector* selector, CSSValue* value) const
     346    {
     347        if (!value->isPrimitiveValue())
     348            return;
     349        CSSPrimitiveValue* primitiveValue = static_cast<CSSPrimitiveValue*>(value);
     350        if ((identBehavior == MapNoneToNull && primitiveValue->getIdent() == CSSValueNone)
     351            || (identBehavior == MapAutoToNull && primitiveValue->getIdent() == CSSValueAuto))
     352            setValue(selector->style(), nullAtom);
     353        else
     354            setValue(selector->style(), primitiveValue->getStringValue());
    332355    }
    333356};
     
    932955    setPropertyHandler(CSSPropertyWebkitColumnWidth, new ApplyPropertyAuto<float, ComputeLength>(&RenderStyle::columnWidth, &RenderStyle::setColumnWidth, &RenderStyle::hasAutoColumnWidth, &RenderStyle::setHasAutoColumnWidth));
    933956
     957    setPropertyHandler(CSSPropertyWebkitHighlight, new ApplyPropertyString<MapNoneToNull>(&RenderStyle::highlight, &RenderStyle::setHighlight, &RenderStyle::initialHighlight));
     958    setPropertyHandler(CSSPropertyWebkitHyphenateCharacter, new ApplyPropertyString<MapAutoToNull>(&RenderStyle::hyphenationString, &RenderStyle::setHyphenationString, &RenderStyle::initialHyphenationString));
     959
    934960    setPropertyHandler(CSSPropertyWebkitTextCombine, new ApplyPropertyDefault<TextCombine>(&RenderStyle::textCombine, &RenderStyle::setTextCombine, &RenderStyle::initialTextCombine));
    935961    setPropertyHandler(CSSPropertyWebkitTextEmphasisPosition, new ApplyPropertyDefault<TextEmphasisPosition>(&RenderStyle::textEmphasisPosition, &RenderStyle::setTextEmphasisPosition, &RenderStyle::initialTextEmphasisPosition));
  • trunk/Source/WebCore/css/CSSStyleSelector.cpp

    r92620 r92742  
    47424742        return;
    47434743    }
    4744     case CSSPropertyWebkitHighlight: {
    4745         HANDLE_INHERIT_AND_INITIAL(highlight, Highlight);
    4746         if (primitiveValue->getIdent() == CSSValueNone)
    4747             m_style->setHighlight(nullAtom);
    4748         else
    4749             m_style->setHighlight(primitiveValue->getStringValue());
    4750         return;
    4751     }
    47524744    case CSSPropertyWebkitHyphens:
    47534745        HANDLE_INHERIT_AND_INITIAL_AND_PRIMITIVE(hyphens, Hyphens);
    47544746        return;
    4755     case CSSPropertyWebkitHyphenateCharacter: {
    4756         HANDLE_INHERIT_AND_INITIAL(hyphenationString, HyphenationString);
    4757         if (primitiveValue->getIdent() == CSSValueAuto)
    4758             m_style->setHyphenationString(nullAtom);
    4759         else
    4760             m_style->setHyphenationString(primitiveValue->getStringValue());
    4761         return;
    4762     }
    47634747    case CSSPropertyWebkitHyphenateLimitAfter: {
    47644748        HANDLE_INHERIT_AND_INITIAL(hyphenationLimitAfter, HyphenationLimitAfter);
     
    52235207    case CSSPropertyWebkitColumnGap:
    52245208    case CSSPropertyWebkitColumnWidth:
     5209    case CSSPropertyWebkitHighlight:
     5210    case CSSPropertyWebkitHyphenateCharacter:
    52255211    case CSSPropertyWebkitTextCombine:
    52265212    case CSSPropertyWebkitTextEmphasisPosition:
Note: See TracChangeset for help on using the changeset viewer.