Title: [101499] trunk/Source/WebCore
Revision
101499
Author
macpher...@chromium.org
Date
2011-11-30 05:48:25 -0800 (Wed, 30 Nov 2011)

Log Message

Implement Zoom Property in CSSSStyleApplyProperty.
https://bugs.webkit.org/show_bug.cgi?id=72840

Reviewed by Andreas Kling.

Covered by fast/css/*zoom*.html

* css/CSSStyleApplyProperty.cpp:
Add new handler for zoom property (based on existing code from CSSStyleSelector.cpp)
(WebCore::ApplyPropertyZoom::resetEffectiveZoom):
(WebCore::ApplyPropertyZoom::applyInheritValue):
(WebCore::ApplyPropertyZoom::applyInitialValue):
(WebCore::ApplyPropertyZoom::applyValue):
(WebCore::ApplyPropertyZoom::createHandler):
(WebCore::CSSStyleApplyProperty::CSSStyleApplyProperty):
* css/CSSStyleSelector.cpp:
Remove existing implementation.
(WebCore::CSSStyleSelector::applyProperty):
* css/CSSStyleSelector.h:
(WebCore::CSSStyleSelector::document):
Add getter for Document.

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (101498 => 101499)


--- trunk/Source/WebCore/ChangeLog	2011-11-30 13:46:21 UTC (rev 101498)
+++ trunk/Source/WebCore/ChangeLog	2011-11-30 13:48:25 UTC (rev 101499)
@@ -1,3 +1,27 @@
+2011-11-30  Luke Macpherson   <macpher...@chromium.org>
+
+        Implement Zoom Property in CSSSStyleApplyProperty.
+        https://bugs.webkit.org/show_bug.cgi?id=72840
+
+        Reviewed by Andreas Kling.
+
+        Covered by fast/css/*zoom*.html
+
+        * css/CSSStyleApplyProperty.cpp:
+        Add new handler for zoom property (based on existing code from CSSStyleSelector.cpp)
+        (WebCore::ApplyPropertyZoom::resetEffectiveZoom):
+        (WebCore::ApplyPropertyZoom::applyInheritValue):
+        (WebCore::ApplyPropertyZoom::applyInitialValue):
+        (WebCore::ApplyPropertyZoom::applyValue):
+        (WebCore::ApplyPropertyZoom::createHandler):
+        (WebCore::CSSStyleApplyProperty::CSSStyleApplyProperty):
+        * css/CSSStyleSelector.cpp:
+        Remove existing implementation.
+        (WebCore::CSSStyleSelector::applyProperty):
+        * css/CSSStyleSelector.h:
+        (WebCore::CSSStyleSelector::document):
+        Add getter for Document.
+
 2011-11-30  David Reveman  <reve...@chromium.org>
 
         [Chromium] Re-enable layer anti-aliasing on ChromeOS.

Modified: trunk/Source/WebCore/css/CSSStyleApplyProperty.cpp (101498 => 101499)


--- trunk/Source/WebCore/css/CSSStyleApplyProperty.cpp	2011-11-30 13:46:21 UTC (rev 101498)
+++ trunk/Source/WebCore/css/CSSStyleApplyProperty.cpp	2011-11-30 13:48:25 UTC (rev 101499)
@@ -35,6 +35,7 @@
 #include "Document.h"
 #include "Element.h"
 #include "Pair.h"
+#include "RenderObject.h"
 #include "RenderStyle.h"
 #include <wtf/StdLibExtras.h>
 #include <wtf/UnusedParam.h>
@@ -1120,6 +1121,59 @@
     }
 };
 
+class ApplyPropertyZoom {
+private:
+    static void resetEffectiveZoom(CSSStyleSelector* selector)
+    {
+        // Reset the zoom in effect. This allows the setZoom method to accurately compute a new zoom in effect.
+        selector->setEffectiveZoom(selector->parentStyle() ? selector->parentStyle()->effectiveZoom() : RenderStyle::initialZoom());
+    }
+
+public:
+    static void applyInheritValue(CSSStyleSelector* selector)
+    {
+        resetEffectiveZoom(selector);
+        selector->setZoom(selector->parentStyle()->zoom());
+    }
+
+    static void applyInitialValue(CSSStyleSelector* selector)
+    {
+        resetEffectiveZoom(selector);
+        selector->setZoom(RenderStyle::initialZoom());
+    }
+
+    static void applyValue(CSSStyleSelector* selector, CSSValue* value)
+    {
+        ASSERT(value->isPrimitiveValue());
+        CSSPrimitiveValue* primitiveValue = static_cast<CSSPrimitiveValue*>(value);
+
+        if (primitiveValue->getIdent() == CSSValueNormal) {
+            resetEffectiveZoom(selector);
+            selector->setZoom(RenderStyle::initialZoom());
+        } else if (primitiveValue->getIdent() == CSSValueReset) {
+            selector->setEffectiveZoom(RenderStyle::initialZoom());
+            selector->setZoom(RenderStyle::initialZoom());
+        } else if (primitiveValue->getIdent() == CSSValueDocument) {
+            float docZoom = selector->document()->renderer()->style()->zoom();
+            selector->setEffectiveZoom(docZoom);
+            selector->setZoom(docZoom);
+        } else if (primitiveValue->primitiveType() == CSSPrimitiveValue::CSS_PERCENTAGE) {
+            resetEffectiveZoom(selector);
+            if (float percent = primitiveValue->getFloatValue())
+                selector->setZoom(percent / 100.0f);
+        } else if (primitiveValue->primitiveType() == CSSPrimitiveValue::CSS_NUMBER) {
+            resetEffectiveZoom(selector);
+            if (float number = primitiveValue->getFloatValue())
+                selector->setZoom(number);
+        }
+    }
+
+    static PropertyHandler createHandler()
+    {
+        return PropertyHandler(&applyInheritValue, &applyInitialValue, &applyValue);
+    }
+};
+
 const CSSStyleApplyProperty& CSSStyleApplyProperty::sharedCSSStyleApplyProperty()
 {
     DEFINE_STATIC_LOCAL(CSSStyleApplyProperty, cssStyleApplyPropertyInstance, ());
@@ -1367,6 +1421,7 @@
     setPropertyHandler(CSSPropertyWebkitWrap, ApplyPropertyExpanding<SuppressValue, CSSPropertyWebkitWrapFlow, CSSPropertyWebkitWrapMargin, CSSPropertyWebkitWrapPadding>::createHandler());
 
     setPropertyHandler(CSSPropertyZIndex, ApplyPropertyAuto<int, &RenderStyle::zIndex, &RenderStyle::setZIndex, &RenderStyle::hasAutoZIndex, &RenderStyle::setHasAutoZIndex>::createHandler());
+    setPropertyHandler(CSSPropertyZoom, ApplyPropertyZoom::createHandler());
 }
 
 

Modified: trunk/Source/WebCore/css/CSSStyleSelector.cpp (101498 => 101499)


--- trunk/Source/WebCore/css/CSSStyleSelector.cpp	2011-11-30 13:46:21 UTC (rev 101498)
+++ trunk/Source/WebCore/css/CSSStyleSelector.cpp	2011-11-30 13:48:25 UTC (rev 101499)
@@ -3009,33 +3009,6 @@
         m_style->setTextDecoration(t);
         return;
     }
-
-    case CSSPropertyZoom:
-    {
-        // Reset the zoom in effect before we do anything.  This allows the setZoom method to accurately compute a new
-        // zoom in effect.
-        setEffectiveZoom(m_parentStyle ? m_parentStyle->effectiveZoom() : RenderStyle::initialZoom());
-
-        if (isInherit)
-            setZoom(m_parentStyle->zoom());
-        else if (isInitial || primitiveValue->getIdent() == CSSValueNormal)
-            setZoom(RenderStyle::initialZoom());
-        else if (primitiveValue->getIdent() == CSSValueReset) {
-            setEffectiveZoom(RenderStyle::initialZoom());
-            setZoom(RenderStyle::initialZoom());
-        } else if (primitiveValue->getIdent() == CSSValueDocument) {
-            float docZoom = m_checker.document()->renderer()->style()->zoom();
-            setEffectiveZoom(docZoom);
-            setZoom(docZoom);
-        } else if (primitiveValue->primitiveType() == CSSPrimitiveValue::CSS_PERCENTAGE) {
-            if (primitiveValue->getFloatValue())
-                setZoom(primitiveValue->getFloatValue() / 100.0f);
-        } else if (primitiveValue->primitiveType() == CSSPrimitiveValue::CSS_NUMBER) {
-            if (primitiveValue->getFloatValue())
-                setZoom(primitiveValue->getFloatValue());
-        }
-        return;
-    }
 // shorthand properties
     case CSSPropertyBackground:
         if (isInitial) {
@@ -3943,6 +3916,7 @@
     case CSSPropertyWebkitWrapThrough:
     case CSSPropertyWebkitWrap:
     case CSSPropertyZIndex:
+    case CSSPropertyZoom:
         ASSERT_NOT_REACHED();
         return;
 #if ENABLE(SVG)

Modified: trunk/Source/WebCore/css/CSSStyleSelector.h (101498 => 101499)


--- trunk/Source/WebCore/css/CSSStyleSelector.h	2011-11-30 13:46:21 UTC (rev 101498)
+++ trunk/Source/WebCore/css/CSSStyleSelector.h	2011-11-30 13:48:25 UTC (rev 101499)
@@ -118,6 +118,7 @@
     RenderStyle* parentStyle() const { return m_parentStyle; }
     RenderStyle* rootElementStyle() const { return m_rootElementStyle; }
     Element* element() const { return m_element; }
+    Document* document() const { return m_checker.document(); }
     FontDescription fontDescription() { return style()->fontDescription(); }
     FontDescription parentFontDescription() {return parentStyle()->fontDescription(); }
     void setFontDescription(FontDescription fontDescription) { m_fontDirty |= style()->setFontDescription(fontDescription); }
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to