Make CSSOM style() return CSSStyleDeclaration*
authorantti@apple.com <antti@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 31 Jan 2012 22:30:22 +0000 (22:30 +0000)
committerantti@apple.com <antti@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 31 Jan 2012 22:30:22 +0000 (22:30 +0000)
https://bugs.webkit.org/show_bug.cgi?id=77475

Reviewed by Anders Carlsson

CSSStyleRule::style() and some other places return CSSMutableStyleDeclaration.
They should return the plain CSSOM type instead.

CSSMutableStyleDeclaration* should be available through non-CSSOM function.

* css/CSSFontFaceRule.h:
(WebCore::CSSFontFaceRule::style):
(WebCore::CSSFontFaceRule::declaration):
* css/CSSFontSelector.cpp:
(WebCore::CSSFontSelector::addFontFaceRule):
* css/CSSStyleRule.h:
(WebCore::CSSStyleRule::style):
(WebCore::CSSStyleRule::declaration):
* css/CSSStyleSelector.cpp:
(WebCore::CSSStyleSelector::styleForKeyframe):
* css/WebKitCSSKeyframeRule.h:
(WebCore):
(WebCore::WebKitCSSKeyframeRule::style):
(WebCore::WebKitCSSKeyframeRule::declaration):
(WebKitCSSKeyframeRule):
* editing/EditingStyle.cpp:
(WebCore::styleFromMatchedRulesForElement):
* inspector/InspectorStyleSheet.cpp:
(WebCore::InspectorStyleSheet::revalidateStyle):
* page/PageSerializer.cpp:
(WebCore::PageSerializer::retrieveResourcesForCSSRule):
* svg/SVGFontFaceElement.cpp:
(WebCore::SVGFontFaceElement::parseMappedAttribute):
(WebCore::SVGFontFaceElement::fontFamily):
(WebCore::SVGFontFaceElement::rebuildFontFace):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@106393 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/css/CSSFontFaceRule.h
Source/WebCore/css/CSSFontSelector.cpp
Source/WebCore/css/CSSStyleRule.h
Source/WebCore/css/CSSStyleSelector.cpp
Source/WebCore/css/WebKitCSSKeyframeRule.h
Source/WebCore/editing/EditingStyle.cpp
Source/WebCore/inspector/InspectorStyleSheet.cpp
Source/WebCore/page/PageSerializer.cpp
Source/WebCore/svg/SVGFontFaceElement.cpp

index 4d48b1a..6149800 100644 (file)
@@ -1,3 +1,41 @@
+2012-01-31  Antti Koivisto  <antti@apple.com>
+
+        Make CSSOM style() return CSSStyleDeclaration*
+        https://bugs.webkit.org/show_bug.cgi?id=77475
+
+        Reviewed by Anders Carlsson
+
+        CSSStyleRule::style() and some other places return CSSMutableStyleDeclaration. 
+        They should return the plain CSSOM type instead.
+        
+        CSSMutableStyleDeclaration* should be available through non-CSSOM function.
+
+        * css/CSSFontFaceRule.h:
+        (WebCore::CSSFontFaceRule::style):
+        (WebCore::CSSFontFaceRule::declaration):
+        * css/CSSFontSelector.cpp:
+        (WebCore::CSSFontSelector::addFontFaceRule):
+        * css/CSSStyleRule.h:
+        (WebCore::CSSStyleRule::style):
+        (WebCore::CSSStyleRule::declaration):
+        * css/CSSStyleSelector.cpp:
+        (WebCore::CSSStyleSelector::styleForKeyframe):
+        * css/WebKitCSSKeyframeRule.h:
+        (WebCore):
+        (WebCore::WebKitCSSKeyframeRule::style):
+        (WebCore::WebKitCSSKeyframeRule::declaration):
+        (WebKitCSSKeyframeRule):
+        * editing/EditingStyle.cpp:
+        (WebCore::styleFromMatchedRulesForElement):
+        * inspector/InspectorStyleSheet.cpp:
+        (WebCore::InspectorStyleSheet::revalidateStyle):
+        * page/PageSerializer.cpp:
+        (WebCore::PageSerializer::retrieveResourcesForCSSRule):
+        * svg/SVGFontFaceElement.cpp:
+        (WebCore::SVGFontFaceElement::parseMappedAttribute):
+        (WebCore::SVGFontFaceElement::fontFamily):
+        (WebCore::SVGFontFaceElement::rebuildFontFace):
+
 2012-01-31  Scott Graham  <scottmg@chromium.org>
 
         [Chromium] Remove references to gyp cygwin build target
index 3d1f76c..545c90a 100644 (file)
@@ -42,10 +42,11 @@ public:
 
     ~CSSFontFaceRule();
 
-    CSSMutableStyleDeclaration* style() const { return m_style.get(); }
+    CSSStyleDeclaration* style() const { return m_style.get(); }
 
     String cssText() const;
 
+    CSSMutableStyleDeclaration* declaration() const { return m_style.get(); }
     void setDeclaration(PassRefPtr<CSSMutableStyleDeclaration> style) { m_style = style; }
 
     void addSubresourceStyleURLs(ListHashSet<KURL>& urls);
index ada612c..b13fffd 100644 (file)
@@ -86,7 +86,7 @@ bool CSSFontSelector::isEmpty() const
 void CSSFontSelector::addFontFaceRule(const CSSFontFaceRule* fontFaceRule)
 {
     // Obtain the font-family property and the src property.  Both must be defined.
-    const CSSMutableStyleDeclaration* style = fontFaceRule->style();
+    const CSSMutableStyleDeclaration* style = fontFaceRule->declaration();
     RefPtr<CSSValue> fontFamily = style->getPropertyCSSValue(CSSPropertyFontFamily);
     RefPtr<CSSValue> src = style->getPropertyCSSValue(CSSPropertySrc);
     RefPtr<CSSValue> unicodeRange = style->getPropertyCSSValue(CSSPropertyUnicodeRange);
index 7346350..713e682 100644 (file)
@@ -43,7 +43,7 @@ public:
     String selectorText() const;
     void setSelectorText(const String&);
 
-    CSSMutableStyleDeclaration* style() const { return m_style.get(); }
+    CSSStyleDeclaration* style() const { return m_style.get(); }
 
     String cssText() const;
 
@@ -51,7 +51,7 @@ public:
     void setDeclaration(PassRefPtr<CSSMutableStyleDeclaration> style) { ASSERT(style->parentRule() == this); m_style = style; }
 
     const CSSSelectorList& selectorList() const { return m_selectorList; }
-    CSSMutableStyleDeclaration* declaration() { return m_style.get(); }
+    CSSMutableStyleDeclaration* declaration() const { return m_style.get(); }
 
     void addSubresourceStyleURLs(ListHashSet<KURL>& urls);
 
index e7954ae..abac398 100644 (file)
@@ -1529,7 +1529,7 @@ PassRefPtr<RenderStyle> CSSStyleSelector::styleForElement(Element* element, Rend
 PassRefPtr<RenderStyle> CSSStyleSelector::styleForKeyframe(const RenderStyle* elementStyle, const WebKitCSSKeyframeRule* keyframeRule, KeyframeValue& keyframe)
 {
     if (keyframeRule->style())
-        addMatchedDeclaration(keyframeRule->style());
+        addMatchedDeclaration(keyframeRule->declaration());
 
     ASSERT(!m_style);
 
@@ -1568,7 +1568,7 @@ PassRefPtr<RenderStyle> CSSStyleSelector::styleForKeyframe(const RenderStyle* el
 #endif
 
     // Add all the animating properties to the keyframe.
-    if (CSSMutableStyleDeclaration* styleDeclaration = keyframeRule->style()) {
+    if (CSSMutableStyleDeclaration* styleDeclaration = keyframeRule->declaration()) {
         unsigned propertyCount = styleDeclaration->propertyCount();
         for (unsigned i = 0; i < propertyCount; ++i) {
             int property = styleDeclaration->propertyAt(i).id();
index 052c86b..0835187 100644 (file)
 #ifndef WebKitCSSKeyframeRule_h
 #define WebKitCSSKeyframeRule_h
 
+#include "CSSMutableStyleDeclaration.h"
 #include "CSSRule.h"
 #include <wtf/PassRefPtr.h>
 #include <wtf/RefPtr.h>
 
 namespace WebCore {
 
-class CSSMutableStyleDeclaration;
-
 typedef int ExceptionCode;
 
 class WebKitCSSKeyframeRule : public CSSRule {
@@ -54,15 +53,13 @@ public:
 
     void getKeys(Vector<float>& keys) const   { parseKeyString(m_key, keys); }
 
-    CSSMutableStyleDeclaration* style() const { return m_style.get(); }
+    CSSStyleDeclaration* style() const { return m_style.get(); }
 
     String cssText() const;
 
+    CSSMutableStyleDeclaration* declaration() const { return m_style.get(); }
     void setDeclaration(PassRefPtr<CSSMutableStyleDeclaration>);
 
-    CSSMutableStyleDeclaration*         declaration()       { return m_style.get(); }
-    const CSSMutableStyleDeclaration*   declaration() const { return m_style.get(); }
-
 private:
     static void parseKeyString(const String& s, Vector<float>& keys);
 
index 796ad1b..1bcd69c 100644 (file)
@@ -1018,7 +1018,7 @@ static PassRefPtr<CSSMutableStyleDeclaration> styleFromMatchedRulesForElement(El
     if (matchedRules) {
         for (unsigned i = 0; i < matchedRules->length(); i++) {
             if (matchedRules->item(i)->type() == CSSRule::STYLE_RULE) {
-                RefPtr<CSSMutableStyleDeclaration> s = static_cast<CSSStyleRule*>(matchedRules->item(i))->style();
+                RefPtr<CSSMutableStyleDeclaration> s = static_cast<CSSStyleRule*>(matchedRules->item(i))->declaration();
                 style->merge(s.get(), true);
             }
         }
index 8f5d45b..2f37f0d 100644 (file)
@@ -1085,7 +1085,7 @@ void InspectorStyleSheet::revalidateStyle(CSSStyleDeclaration* pageStyle)
     for (unsigned i = 0, size = m_flatRules.size(); i < size; ++i) {
         CSSStyleRule* parsedRule = m_flatRules.at(i);
         if (parsedRule->style() == pageStyle) {
-            if (parsedRule->style()->asText() != pageStyle->cssText()) {
+            if (parsedRule->declaration()->asText() != pageStyle->cssText()) {
                 // Clear the disabled properties for the invalid style here.
                 m_inspectorStyles.remove(pageStyle);
                 setStyleText(pageStyle, pageStyle->cssText());
index 7adde3e..99ab2ef 100644 (file)
@@ -303,7 +303,7 @@ void PageSerializer::addImageToResources(CachedImage* image, RenderObject* image
 
 void PageSerializer::retrieveResourcesForCSSRule(CSSStyleRule* rule)
 {
-    retrieveResourcesForCSSDeclaration(rule->style());
+    retrieveResourcesForCSSDeclaration(rule->declaration());
 }
 
 void PageSerializer::retrieveResourcesForCSSDeclaration(CSSMutableStyleDeclaration* styleDeclaration)
index 2ecb3d0..06e5001 100644 (file)
@@ -113,7 +113,7 @@ void SVGFontFaceElement::parseMappedAttribute(Attribute* attr)
 {    
     int propId = cssPropertyIdForSVGAttributeName(attr->name());
     if (propId > 0) {
-        m_fontFaceRule->style()->setProperty(propId, attr->value(), false);
+        m_fontFaceRule->declaration()->setProperty(propId, attr->value(), false);
         rebuildFontFace();
         return;
     }
@@ -258,7 +258,7 @@ int SVGFontFaceElement::descent() const
 
 String SVGFontFaceElement::fontFamily() const
 {
-    return m_fontFaceRule->style()->getPropertyValue(CSSPropertyFontFamily);
+    return m_fontFaceRule->declaration()->getPropertyValue(CSSPropertyFontFamily);
 }
 
 SVGFontElement* SVGFontFaceElement::associatedFontElement() const
@@ -299,11 +299,11 @@ void SVGFontFaceElement::rebuildFontFace()
     // Parse in-memory CSS rules
     CSSProperty srcProperty(CSSPropertySrc, list);
     const CSSProperty* srcPropertyRef = &srcProperty;
-    m_fontFaceRule->style()->addParsedProperties(&srcPropertyRef, 1);
+    m_fontFaceRule->declaration()->addParsedProperties(&srcPropertyRef, 1);
 
     if (describesParentFont) {    
         // Traverse parsed CSS values and associate CSSFontFaceSrcValue elements with ourselves.
-        RefPtr<CSSValue> src = m_fontFaceRule->style()->getPropertyCSSValue(CSSPropertySrc);
+        RefPtr<CSSValue> src = m_fontFaceRule->declaration()->getPropertyCSSValue(CSSPropertySrc);
         CSSValueList* srcList = static_cast<CSSValueList*>(src.get());
 
         unsigned srcLength = srcList ? srcList->length() : 0;