Modified: trunk/Source/WebCore/ChangeLog (102551 => 102552)
--- trunk/Source/WebCore/ChangeLog 2011-12-12 01:22:49 UTC (rev 102551)
+++ trunk/Source/WebCore/ChangeLog 2011-12-12 02:24:28 UTC (rev 102552)
@@ -1,3 +1,22 @@
+2011-12-11 Luke Macpherson <macpher...@chromium.org>
+
+ Implement CSS display property in CSSStyleApplyProperty.
+ https://bugs.webkit.org/show_bug.cgi?id=73500
+
+ Reviewed by Andreas Kling.
+
+ Refactoring only / no functionality changed.
+
+ * css/CSSStyleApplyProperty.cpp:
+ (WebCore::ApplyPropertyDisplay::isValidDisplayValue):
+ (WebCore::ApplyPropertyDisplay::applyInheritValue):
+ (WebCore::ApplyPropertyDisplay::applyInitialValue):
+ (WebCore::ApplyPropertyDisplay::applyValue):
+ (WebCore::ApplyPropertyDisplay::createHandler):
+ (WebCore::CSSStyleApplyProperty::CSSStyleApplyProperty):
+ * css/CSSStyleSelector.cpp:
+ (WebCore::CSSStyleSelector::applyProperty):
+
2011-12-11 Geoffrey Garen <gga...@apple.com>
Try to fix the Qt build.
Modified: trunk/Source/WebCore/css/CSSStyleApplyProperty.cpp (102551 => 102552)
--- trunk/Source/WebCore/css/CSSStyleApplyProperty.cpp 2011-12-12 01:22:49 UTC (rev 102551)
+++ trunk/Source/WebCore/css/CSSStyleApplyProperty.cpp 2011-12-12 02:24:28 UTC (rev 102552)
@@ -1349,6 +1349,49 @@
}
};
+class ApplyPropertyDisplay {
+private:
+ static inline bool isValidDisplayValue(CSSStyleSelector* selector, EDisplay displayPropertyValue)
+ {
+#if ENABLE(SVG)
+ if (selector->element() && selector->element()->isSVGElement() && selector->style()->styleType() == NOPSEUDO)
+ return (displayPropertyValue == INLINE || displayPropertyValue == BLOCK || displayPropertyValue == NONE);
+#endif
+ return true;
+ }
+public:
+ static void applyInheritValue(CSSStyleSelector* selector)
+ {
+ EDisplay display = selector->parentStyle()->display();
+ if (!isValidDisplayValue(selector, display))
+ return;
+ selector->style()->setDisplay(display);
+ }
+
+ static void applyInitialValue(CSSStyleSelector* selector)
+ {
+ selector->style()->setDisplay(RenderStyle::initialDisplay());
+ }
+
+ static void applyValue(CSSStyleSelector* selector, CSSValue* value)
+ {
+ if (!value->isPrimitiveValue())
+ return;
+
+ EDisplay display = *static_cast<CSSPrimitiveValue*>(value);
+
+ if (!isValidDisplayValue(selector, display))
+ return;
+
+ selector->style()->setDisplay(display);
+ }
+
+ static PropertyHandler createHandler()
+ {
+ return PropertyHandler(&applyInheritValue, &applyInitialValue, &applyValue);
+ }
+};
+
const CSSStyleApplyProperty& CSSStyleApplyProperty::sharedCSSStyleApplyProperty()
{
DEFINE_STATIC_LOCAL(CSSStyleApplyProperty, cssStyleApplyPropertyInstance, ());
@@ -1373,6 +1416,8 @@
setPropertyHandler(CSSPropertyWebkitBackgroundComposite, ApplyPropertyFillLayer<CompositeOperator, CSSPropertyWebkitBackgroundComposite, BackgroundFillLayer, &RenderStyle::accessBackgroundLayers, &RenderStyle::backgroundLayers,
&FillLayer::isCompositeSet, &FillLayer::composite, &FillLayer::setComposite, &FillLayer::clearComposite, &FillLayer::initialFillComposite, &CSSStyleSelector::mapFillComposite>::createHandler());
+ setPropertyHandler(CSSPropertyDisplay, ApplyPropertyDisplay::createHandler());
+
setPropertyHandler(CSSPropertyBackgroundImage, ApplyPropertyFillLayer<StyleImage*, CSSPropertyBackgroundImage, BackgroundFillLayer, &RenderStyle::accessBackgroundLayers, &RenderStyle::backgroundLayers,
&FillLayer::isImageSet, &FillLayer::image, &FillLayer::setImage, &FillLayer::clearImage, &FillLayer::initialFillImage, &CSSStyleSelector::mapFillImage>::createHandler());
Modified: trunk/Source/WebCore/css/CSSStyleSelector.cpp (102551 => 102552)
--- trunk/Source/WebCore/css/CSSStyleSelector.cpp 2011-12-12 01:22:49 UTC (rev 102551)
+++ trunk/Source/WebCore/css/CSSStyleSelector.cpp 2011-12-12 02:24:28 UTC (rev 102552)
@@ -2504,53 +2504,6 @@
return false;
}
-class SVGDisplayPropertyGuard {
- WTF_MAKE_NONCOPYABLE(SVGDisplayPropertyGuard);
-public:
- SVGDisplayPropertyGuard(Element*, RenderStyle*);
- ~SVGDisplayPropertyGuard();
-private:
-#if ENABLE(SVG)
- RenderStyle* m_style;
- EDisplay m_originalDisplayPropertyValue;
-#endif
-};
-
-#if !ENABLE(SVG)
-inline SVGDisplayPropertyGuard::SVGDisplayPropertyGuard(Element*, RenderStyle*)
-{
-}
-
-inline SVGDisplayPropertyGuard::~SVGDisplayPropertyGuard()
-{
-}
-#else
-static inline bool isAcceptableForSVGElement(EDisplay displayPropertyValue)
-{
- return displayPropertyValue == INLINE || displayPropertyValue == BLOCK || displayPropertyValue == NONE;
-}
-
-inline SVGDisplayPropertyGuard::SVGDisplayPropertyGuard(Element* element, RenderStyle* style)
-{
- if (!(element && element->isSVGElement() && style->styleType() == NOPSEUDO)) {
- m_originalDisplayPropertyValue = NONE;
- m_style = 0;
- return;
- }
- m_style = style;
- m_originalDisplayPropertyValue = style->display();
- ASSERT(isAcceptableForSVGElement(m_originalDisplayPropertyValue));
-}
-
-inline SVGDisplayPropertyGuard::~SVGDisplayPropertyGuard()
-{
- if (!m_style || isAcceptableForSVGElement(m_style->display()))
- return;
- m_style->setDisplay(m_originalDisplayPropertyValue);
-}
-#endif
-
-
// SVG handles zooming in a different way compared to CSS. The whole document is scaled instead
// of each individual length value in the render style / tree. CSSPrimitiveValue::computeLength*()
// multiplies each resolved length with the zoom multiplier - so for SVG we need to disable that.
@@ -2670,11 +2623,6 @@
case CSSPropertyClear:
HANDLE_INHERIT_AND_INITIAL_AND_PRIMITIVE(clear, Clear)
return;
- case CSSPropertyDisplay: {
- SVGDisplayPropertyGuard guard(m_element, m_style.get());
- HANDLE_INHERIT_AND_INITIAL_AND_PRIMITIVE(display, Display)
- return;
- }
case CSSPropertyEmptyCells:
HANDLE_INHERIT_AND_INITIAL_AND_PRIMITIVE(emptyCells, EmptyCells)
return;
@@ -3796,6 +3744,7 @@
// These properties are implemented in the CSSStyleApplyProperty lookup table.
case CSSPropertyColor:
case CSSPropertyDirection:
+ case CSSPropertyDisplay:
case CSSPropertyBackgroundAttachment:
case CSSPropertyBackgroundClip:
case CSSPropertyWebkitBackgroundClip: