Commit 16204d14 authored by commit-queue@webkit.org's avatar commit-queue@webkit.org
Browse files

2011-04-07 Luke Macpherson <macpherson@chromium.org>

        Reviewed by Dimitri Glazkov.

        Implement Backgroun and Mask properties in CSSStyleApplyProperty
        https://bugs.webkit.org/show_bug.cgi?id=57922

        No tests added as no behavioral changes.

        * css/CSSStyleApplyProperty.cpp:
        Added ApplyPropertyFillLayer test to handle Background and Mask CSS Properties.
        (WebCore::CSSStyleApplyProperty::CSSStyleApplyProperty):
        Added constructor calls to set up:
          CSSPropertyBackgroundAttachment
          CSSPropertyBackgroundClip
          CSSPropertyWebkitBackgroundClip
          CSSPropertyWebkitBackgroundComposite
          CSSPropertyBackgroundOrigin
          CSSPropertyWebkitBackgroundOrigin
          CSSPropertyBackgroundSize
          CSSPropertyWebkitBackgroundSize
          CSSPropertyWebkitMaskAttachment
          CSSPropertyWebkitMaskClip
          CSSPropertyWebkitMaskComposite
          CSSPropertyWebkitMaskOrigin
          CSSPropertyWebkitMaskSize
        * css/CSSStyleApplyProperty.h:
        (WebCore::CSSStyleApplyProperty::setPropertyValue):
        Add function to specify an equivalent property value in the lookup table.
        * css/CSSStyleSelector.cpp:
        (WebCore::CSSStyleSelector::applyProperty):
        Remove sections now implemented by CSSStyleApplyProperty.
        * css/CSSStyleSelector.h:
        Make CSSStyleApplyProperty a friend class so that the mapFill* functions are accessible.

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@83241 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 5bee2940
2011-04-07 Luke Macpherson <macpherson@chromium.org>
Reviewed by Dimitri Glazkov.
Implement Backgroun and Mask properties in CSSStyleApplyProperty
https://bugs.webkit.org/show_bug.cgi?id=57922
No tests added as no behavioral changes.
* css/CSSStyleApplyProperty.cpp:
Added ApplyPropertyFillLayer test to handle Background and Mask CSS Properties.
(WebCore::CSSStyleApplyProperty::CSSStyleApplyProperty):
Added constructor calls to set up:
CSSPropertyBackgroundAttachment
CSSPropertyBackgroundClip
CSSPropertyWebkitBackgroundClip
CSSPropertyWebkitBackgroundComposite
CSSPropertyBackgroundOrigin
CSSPropertyWebkitBackgroundOrigin
CSSPropertyBackgroundSize
CSSPropertyWebkitBackgroundSize
CSSPropertyWebkitMaskAttachment
CSSPropertyWebkitMaskClip
CSSPropertyWebkitMaskComposite
CSSPropertyWebkitMaskOrigin
CSSPropertyWebkitMaskSize
* css/CSSStyleApplyProperty.h:
(WebCore::CSSStyleApplyProperty::setPropertyValue):
Add function to specify an equivalent property value in the lookup table.
* css/CSSStyleSelector.cpp:
(WebCore::CSSStyleSelector::applyProperty):
Remove sections now implemented by CSSStyleApplyProperty.
* css/CSSStyleSelector.h:
Make CSSStyleApplyProperty a friend class so that the mapFill* functions are accessible.
2011-04-04 Eric Seidel <eric@webkit.org>
 
Reviewed by Ryosuke Niwa.
......@@ -153,13 +153,105 @@ public:
}
};
template <typename T>
class ApplyPropertyFillLayer : public ApplyPropertyBase {
public:
ApplyPropertyFillLayer(CSSPropertyID propertyId, EFillLayerType fillLayerType, FillLayer* (RenderStyle::*accessLayers)(),
const FillLayer* (RenderStyle::*layers)() const, bool (FillLayer::*test)() const, T (FillLayer::*get)() const,
void (FillLayer::*set)(T), void (FillLayer::*clear)(), T (*initial)(EFillLayerType),
void (CSSStyleSelector::*mapFill)(CSSPropertyID, FillLayer*, CSSValue*))
: m_propertyId(propertyId)
, m_fillLayerType(fillLayerType)
, m_accessLayers(accessLayers)
, m_layers(layers)
, m_test(test)
, m_get(get)
, m_set(set)
, m_clear(clear)
, m_initial(initial)
, m_mapFill(mapFill)
{
}
virtual void inherit(CSSStyleSelector* selector) const
{
FillLayer* currChild = (selector->style()->*m_accessLayers)();
FillLayer* prevChild = 0;
const FillLayer* currParent = (selector->parentStyle()->*m_layers)();
while (currParent && (currParent->*m_test)()) {
if (!currChild) {
/* Need to make a new layer.*/
currChild = new FillLayer(m_fillLayerType);
prevChild->setNext(currChild);
}
(currChild->*m_set)((currParent->*m_get)());
prevChild = currChild;
currChild = prevChild->next();
currParent = currParent->next();
}
while (currChild) {
/* Reset any remaining layers to not have the property set. */
(currChild->*m_clear)();
currChild = currChild->next();
}
}
virtual void initial(CSSStyleSelector* selector) const
{
FillLayer* currChild = (selector->style()->*m_accessLayers)();
(currChild->*m_set)((*m_initial)(m_fillLayerType));
for (currChild = currChild->next(); currChild; currChild = currChild->next())
(currChild->*m_clear)();
}
virtual void value(CSSStyleSelector* selector, CSSValue* value) const
{
FillLayer* currChild = (selector->style()->*m_accessLayers)();
FillLayer* prevChild = 0;
if (value->isValueList()) {
/* Walk each value and put it into a layer, creating new layers as needed. */
CSSValueList* valueList = static_cast<CSSValueList*>(value);
for (unsigned int i = 0; i < valueList->length(); i++) {
if (!currChild) {
/* Need to make a new layer to hold this value */
currChild = new FillLayer(m_fillLayerType);
prevChild->setNext(currChild);
}
(selector->*m_mapFill)(m_propertyId, currChild, valueList->itemWithoutBoundsCheck(i));
prevChild = currChild;
currChild = currChild->next();
}
} else {
(selector->*m_mapFill)(m_propertyId, currChild, value);
currChild = currChild->next();
}
while (currChild) {
/* Reset all remaining layers to not have the property set. */
(currChild->*m_clear)();
currChild = currChild->next();
}
}
protected:
CSSPropertyID m_propertyId;
EFillLayerType m_fillLayerType;
FillLayer* (RenderStyle::*m_accessLayers)();
const FillLayer* (RenderStyle::*m_layers)() const;
bool (FillLayer::*m_test)() const;
T (FillLayer::*m_get)() const;
void (FillLayer::*m_set)(T);
void (FillLayer::*m_clear)();
T (*m_initial)(EFillLayerType);
void (CSSStyleSelector::*m_mapFill)(CSSPropertyID, FillLayer*, CSSValue*);
};
const CSSStyleApplyProperty& CSSStyleApplyProperty::sharedCSSStyleApplyProperty()
{
DEFINE_STATIC_LOCAL(CSSStyleApplyProperty, cssStyleApplyPropertyInstance, ());
return cssStyleApplyPropertyInstance;
}
CSSStyleApplyProperty::CSSStyleApplyProperty()
{
for (int i = 0; i < numCSSProperties; ++i)
......@@ -167,6 +259,32 @@ CSSStyleApplyProperty::CSSStyleApplyProperty()
setPropertyValue(CSSPropertyColor, new ApplyPropertyColor(&RenderStyle::color, &RenderStyle::setColor, RenderStyle::initialColor));
setPropertyValue(CSSPropertyDirection, new ApplyPropertyDirection(&RenderStyle::direction, &RenderStyle::setDirection, RenderStyle::initialDirection));
setPropertyValue(CSSPropertyBackgroundAttachment, new ApplyPropertyFillLayer<EFillAttachment>(CSSPropertyBackgroundAttachment, BackgroundFillLayer, &RenderStyle::accessBackgroundLayers, &RenderStyle::backgroundLayers,
&FillLayer::isAttachmentSet, &FillLayer::attachment, &FillLayer::setAttachment, &FillLayer::clearAttachment, &FillLayer::initialFillAttachment, &CSSStyleSelector::mapFillAttachment));
setPropertyValue(CSSPropertyBackgroundClip, new ApplyPropertyFillLayer<EFillBox>(CSSPropertyBackgroundClip, BackgroundFillLayer, &RenderStyle::accessBackgroundLayers, &RenderStyle::backgroundLayers,
&FillLayer::isClipSet, &FillLayer::clip, &FillLayer::setClip, &FillLayer::clearClip, &FillLayer::initialFillClip, &CSSStyleSelector::mapFillClip));
setPropertyValue(CSSPropertyWebkitBackgroundClip, CSSPropertyBackgroundClip);
setPropertyValue(CSSPropertyWebkitBackgroundComposite, new ApplyPropertyFillLayer<CompositeOperator>(CSSPropertyWebkitBackgroundComposite, BackgroundFillLayer, &RenderStyle::accessBackgroundLayers, &RenderStyle::backgroundLayers,
&FillLayer::isCompositeSet, &FillLayer::composite, &FillLayer::setComposite, &FillLayer::clearComposite, &FillLayer::initialFillComposite, &CSSStyleSelector::mapFillComposite));
setPropertyValue(CSSPropertyBackgroundOrigin, new ApplyPropertyFillLayer<EFillBox>(CSSPropertyBackgroundOrigin, BackgroundFillLayer, &RenderStyle::accessBackgroundLayers, &RenderStyle::backgroundLayers,
&FillLayer::isOriginSet, &FillLayer::origin, &FillLayer::setOrigin, &FillLayer::clearOrigin, &FillLayer::initialFillOrigin, &CSSStyleSelector::mapFillOrigin));
setPropertyValue(CSSPropertyWebkitBackgroundOrigin, CSSPropertyBackgroundOrigin);
setPropertyValue(CSSPropertyBackgroundSize, new ApplyPropertyFillLayer<FillSize>(CSSPropertyBackgroundSize, BackgroundFillLayer, &RenderStyle::accessBackgroundLayers, &RenderStyle::backgroundLayers,
&FillLayer::isSizeSet, &FillLayer::size, &FillLayer::setSize, &FillLayer::clearSize, &FillLayer::initialFillSize, &CSSStyleSelector::mapFillSize));
setPropertyValue(CSSPropertyWebkitBackgroundSize, CSSPropertyBackgroundSize);
setPropertyValue(CSSPropertyWebkitMaskAttachment, new ApplyPropertyFillLayer<EFillAttachment>(CSSPropertyWebkitMaskAttachment, MaskFillLayer, &RenderStyle::accessMaskLayers, &RenderStyle::maskLayers,
&FillLayer::isAttachmentSet, &FillLayer::attachment, &FillLayer::setAttachment, &FillLayer::clearAttachment, &FillLayer::initialFillAttachment, &CSSStyleSelector::mapFillAttachment));
setPropertyValue(CSSPropertyWebkitMaskClip, new ApplyPropertyFillLayer<EFillBox>(CSSPropertyWebkitMaskClip, MaskFillLayer, &RenderStyle::accessMaskLayers, &RenderStyle::maskLayers,
&FillLayer::isClipSet, &FillLayer::clip, &FillLayer::setClip, &FillLayer::clearClip, &FillLayer::initialFillClip, &CSSStyleSelector::mapFillClip));
setPropertyValue(CSSPropertyWebkitMaskComposite, new ApplyPropertyFillLayer<CompositeOperator>(CSSPropertyWebkitMaskComposite, MaskFillLayer, &RenderStyle::accessMaskLayers, &RenderStyle::maskLayers,
&FillLayer::isCompositeSet, &FillLayer::composite, &FillLayer::setComposite, &FillLayer::clearComposite, &FillLayer::initialFillComposite, &CSSStyleSelector::mapFillComposite));
setPropertyValue(CSSPropertyWebkitMaskOrigin, new ApplyPropertyFillLayer<EFillBox>(CSSPropertyWebkitMaskOrigin, MaskFillLayer, &RenderStyle::accessMaskLayers, &RenderStyle::maskLayers,
&FillLayer::isOriginSet, &FillLayer::origin, &FillLayer::setOrigin, &FillLayer::clearOrigin, &FillLayer::initialFillOrigin, &CSSStyleSelector::mapFillOrigin));
setPropertyValue(CSSPropertyWebkitMaskSize, new ApplyPropertyFillLayer<FillSize>(CSSPropertyWebkitMaskSize, MaskFillLayer, &RenderStyle::accessMaskLayers, &RenderStyle::maskLayers,
&FillLayer::isSizeSet, &FillLayer::size, &FillLayer::setSize, &FillLayer::clearSize, &FillLayer::initialFillSize, &CSSStyleSelector::mapFillSize));
setPropertyValue(CSSPropertyBackgroundColor, new ApplyPropertyColorBase(&RenderStyle::backgroundColor, 0, &RenderStyle::setBackgroundColor));
setPropertyValue(CSSPropertyBorderBottomColor, new ApplyPropertyColorBase(&RenderStyle::borderBottomColor, &RenderStyle::color, &RenderStyle::setBorderBottomColor));
setPropertyValue(CSSPropertyBorderLeftColor, new ApplyPropertyColorBase(&RenderStyle::borderLeftColor, &RenderStyle::color, &RenderStyle::setBorderLeftColor));
......
......@@ -91,6 +91,13 @@ private:
m_propertyMap[index(property)] = value;
}
void setPropertyValue(CSSPropertyID newProperty, CSSPropertyID equivalentProperty)
{
ASSERT(valid(newProperty));
ASSERT(valid(equivalentProperty));
m_propertyMap[index(newProperty)] = m_propertyMap[index(equivalentProperty)];
}
ApplyPropertyBase* propertyValue(CSSPropertyID property) const
{
ASSERT(valid(property));
......
......@@ -3650,39 +3650,6 @@ void CSSStyleSelector::applyProperty(int id, CSSValue *value)
// are only hit when mapping "inherit" or "initial" into front-end values.
switch (property) {
// ident only properties
case CSSPropertyBackgroundAttachment:
HANDLE_BACKGROUND_VALUE(attachment, Attachment, value)
return;
case CSSPropertyBackgroundClip:
case CSSPropertyWebkitBackgroundClip:
HANDLE_BACKGROUND_VALUE(clip, Clip, value)
return;
case CSSPropertyWebkitBackgroundComposite:
HANDLE_BACKGROUND_VALUE(composite, Composite, value)
return;
case CSSPropertyBackgroundOrigin:
case CSSPropertyWebkitBackgroundOrigin:
HANDLE_BACKGROUND_VALUE(origin, Origin, value)
return;
case CSSPropertyBackgroundSize:
case CSSPropertyWebkitBackgroundSize:
HANDLE_BACKGROUND_VALUE(size, Size, value)
return;
case CSSPropertyWebkitMaskAttachment:
HANDLE_MASK_VALUE(attachment, Attachment, value)
return;
case CSSPropertyWebkitMaskClip:
HANDLE_MASK_VALUE(clip, Clip, value)
return;
case CSSPropertyWebkitMaskComposite:
HANDLE_MASK_VALUE(composite, Composite, value)
return;
case CSSPropertyWebkitMaskOrigin:
HANDLE_MASK_VALUE(origin, Origin, value)
return;
case CSSPropertyWebkitMaskSize:
HANDLE_MASK_VALUE(size, Size, value)
return;
case CSSPropertyBorderCollapse:
HANDLE_INHERIT_AND_INITIAL(borderCollapse, BorderCollapse)
if (!primitiveValue)
......@@ -6195,6 +6162,19 @@ void CSSStyleSelector::applyProperty(int id, CSSValue *value)
// These properties are implemented in the CSSStyleApplyProperty lookup table.
case CSSPropertyColor:
case CSSPropertyDirection:
case CSSPropertyBackgroundAttachment:
case CSSPropertyBackgroundClip:
case CSSPropertyWebkitBackgroundClip:
case CSSPropertyWebkitBackgroundComposite:
case CSSPropertyBackgroundOrigin:
case CSSPropertyWebkitBackgroundOrigin:
case CSSPropertyBackgroundSize:
case CSSPropertyWebkitBackgroundSize:
case CSSPropertyWebkitMaskAttachment:
case CSSPropertyWebkitMaskClip:
case CSSPropertyWebkitMaskComposite:
case CSSPropertyWebkitMaskOrigin:
case CSSPropertyWebkitMaskSize:
case CSSPropertyBackgroundColor:
case CSSPropertyBorderBottomColor:
case CSSPropertyBorderLeftColor:
......
......@@ -85,6 +85,7 @@ public:
// This class selects a RenderStyle for a given element based on a collection of stylesheets.
class CSSStyleSelector {
friend class CSSStyleApplyProperty;
WTF_MAKE_NONCOPYABLE(CSSStyleSelector); WTF_MAKE_FAST_ALLOCATED;
public:
CSSStyleSelector(Document*, StyleSheetList* authorSheets, CSSStyleSheet* mappedElementSheet,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment