Title: [99059] trunk/Source/WebCore
Revision
99059
Author
[email protected]
Date
2011-11-02 08:02:03 -0700 (Wed, 02 Nov 2011)

Log Message

CSSRule: Devirtualize cssText()
https://bugs.webkit.org/show_bug.cgi?id=71292

Patch by Andreas Kling <[email protected]> on 2011-11-02
Reviewed by Antti Koivisto.

Have CSSRule::cssText() redirect to the appropriate subclass based on type().
This is one of the last steps of devirtualizing CSSRule completely, which will
allow us to get rid of its vtable, and each instance's pointer thereto.

* css/CSSCharsetRule.h:
* css/CSSFontFaceRule.h:
* css/CSSImportRule.h:
* css/CSSMediaRule.h:
* css/CSSRegionStyleRule.h:
* css/CSSRule.cpp:
(WebCore::CSSRule::cssText):
* css/CSSRule.h:
* css/CSSStyleRule.h:
* css/WebKitCSSKeyframeRule.h:
* css/WebKitCSSKeyframesRule.h:

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (99058 => 99059)


--- trunk/Source/WebCore/ChangeLog	2011-11-02 14:24:31 UTC (rev 99058)
+++ trunk/Source/WebCore/ChangeLog	2011-11-02 15:02:03 UTC (rev 99059)
@@ -1,3 +1,26 @@
+2011-11-02  Andreas Kling  <[email protected]>
+
+        CSSRule: Devirtualize cssText()
+        https://bugs.webkit.org/show_bug.cgi?id=71292
+
+        Reviewed by Antti Koivisto.
+
+        Have CSSRule::cssText() redirect to the appropriate subclass based on type().
+        This is one of the last steps of devirtualizing CSSRule completely, which will
+        allow us to get rid of its vtable, and each instance's pointer thereto.
+
+        * css/CSSCharsetRule.h:
+        * css/CSSFontFaceRule.h:
+        * css/CSSImportRule.h:
+        * css/CSSMediaRule.h:
+        * css/CSSRegionStyleRule.h:
+        * css/CSSRule.cpp:
+        (WebCore::CSSRule::cssText):
+        * css/CSSRule.h:
+        * css/CSSStyleRule.h:
+        * css/WebKitCSSKeyframeRule.h:
+        * css/WebKitCSSKeyframesRule.h:
+
 2011-11-02  Patrick Gansterer  <[email protected]>
 
         Unreviewed build fix for !ENABLE(FILTERS) after r98989.

Modified: trunk/Source/WebCore/css/CSSCharsetRule.h (99058 => 99059)


--- trunk/Source/WebCore/css/CSSCharsetRule.h	2011-11-02 14:24:31 UTC (rev 99058)
+++ trunk/Source/WebCore/css/CSSCharsetRule.h	2011-11-02 15:02:03 UTC (rev 99059)
@@ -39,7 +39,7 @@
     const String& encoding() const { return m_encoding; }
     void setEncoding(const String& encoding, ExceptionCode&) { m_encoding = encoding; }
 
-    virtual String cssText() const;
+    String cssText() const;
 
 private:
     CSSCharsetRule(CSSStyleSheet* parent, const String& encoding);

Modified: trunk/Source/WebCore/css/CSSFontFaceRule.h (99058 => 99059)


--- trunk/Source/WebCore/css/CSSFontFaceRule.h	2011-11-02 14:24:31 UTC (rev 99058)
+++ trunk/Source/WebCore/css/CSSFontFaceRule.h	2011-11-02 15:02:03 UTC (rev 99059)
@@ -45,7 +45,7 @@
 
     CSSMutableStyleDeclaration* style() const { return m_style.get(); }
 
-    virtual String cssText() const;
+    String cssText() const;
 
     void setDeclaration(PassRefPtr<CSSMutableStyleDeclaration>);
 

Modified: trunk/Source/WebCore/css/CSSImportRule.h (99058 => 99059)


--- trunk/Source/WebCore/css/CSSImportRule.h	2011-11-02 14:24:31 UTC (rev 99058)
+++ trunk/Source/WebCore/css/CSSImportRule.h	2011-11-02 15:02:03 UTC (rev 99059)
@@ -47,7 +47,7 @@
     MediaList* media() const { return m_lstMedia.get(); }
     CSSStyleSheet* styleSheet() const { return m_styleSheet.get(); }
 
-    virtual String cssText() const;
+    String cssText() const;
 
     // Not part of the CSSOM
     bool isLoading() const;

Modified: trunk/Source/WebCore/css/CSSMediaRule.h (99058 => 99059)


--- trunk/Source/WebCore/css/CSSMediaRule.h	2011-11-02 14:24:31 UTC (rev 99058)
+++ trunk/Source/WebCore/css/CSSMediaRule.h	2011-11-02 15:02:03 UTC (rev 99059)
@@ -46,7 +46,7 @@
     unsigned insertRule(const String& rule, unsigned index, ExceptionCode&);
     void deleteRule(unsigned index, ExceptionCode&);
 
-    virtual String cssText() const;
+    String cssText() const;
 
     // Not part of the CSSOM
     unsigned append(CSSRule*);

Modified: trunk/Source/WebCore/css/CSSRegionStyleRule.h (99058 => 99059)


--- trunk/Source/WebCore/css/CSSRegionStyleRule.h	2011-11-02 14:24:31 UTC (rev 99058)
+++ trunk/Source/WebCore/css/CSSRegionStyleRule.h	2011-11-02 15:02:03 UTC (rev 99059)
@@ -51,7 +51,7 @@
 
     virtual ~CSSRegionStyleRule();
 
-    virtual String cssText() const;
+    String cssText() const;
     const CSSSelectorList& selectorList() const { return m_selectorList; }
     CSSRuleList* cssRules() const { return m_ruleList.get(); }
 

Modified: trunk/Source/WebCore/css/CSSRule.cpp (99058 => 99059)


--- trunk/Source/WebCore/css/CSSRule.cpp	2011-11-02 14:24:31 UTC (rev 99058)
+++ trunk/Source/WebCore/css/CSSRule.cpp	2011-11-02 15:02:03 UTC (rev 99059)
@@ -22,6 +22,15 @@
 #include "config.h"
 #include "CSSRule.h"
 
+#include "CSSCharsetRule.h"
+#include "CSSFontFaceRule.h"
+#include "CSSImportRule.h"
+#include "CSSMediaRule.h"
+#include "CSSPageRule.h"
+#include "CSSRegionStyleRule.h"
+#include "CSSStyleRule.h"
+#include "WebKitCSSKeyframeRule.h"
+#include "WebKitCSSKeyframesRule.h"
 #include "NotImplemented.h"
 
 namespace WebCore {
@@ -31,4 +40,31 @@
     notImplemented();
 }
 
+String CSSRule::cssText() const
+{
+    switch (type()) {
+    case UNKNOWN_RULE:
+        return String();
+    case STYLE_RULE:
+    case PAGE_RULE:
+        return static_cast<const CSSStyleRule*>(this)->cssText();
+    case CHARSET_RULE:
+        return static_cast<const CSSCharsetRule*>(this)->cssText();
+    case IMPORT_RULE:
+        return static_cast<const CSSImportRule*>(this)->cssText();
+    case MEDIA_RULE:
+        return static_cast<const CSSMediaRule*>(this)->cssText();
+    case FONT_FACE_RULE:
+        return static_cast<const CSSFontFaceRule*>(this)->cssText();
+    case WEBKIT_KEYFRAMES_RULE:
+        return static_cast<const WebKitCSSKeyframesRule*>(this)->cssText();
+    case WEBKIT_KEYFRAME_RULE:
+        return static_cast<const WebKitCSSKeyframeRule*>(this)->cssText();
+    case WEBKIT_REGION_STYLE_RULE:
+        return static_cast<const CSSRegionStyleRule*>(this)->cssText();
+    }
+    ASSERT_NOT_REACHED();
+    return String();
+}
+
 } // namespace WebCore

Modified: trunk/Source/WebCore/css/CSSRule.h (99058 => 99059)


--- trunk/Source/WebCore/css/CSSRule.h	2011-11-02 14:24:31 UTC (rev 99058)
+++ trunk/Source/WebCore/css/CSSRule.h	2011-11-02 15:02:03 UTC (rev 99059)
@@ -91,7 +91,7 @@
 
     CSSRule* parentRule() const { return m_parentIsRule ? m_parentRule : 0; }
 
-    virtual String cssText() const = 0;
+    String cssText() const;
     void setCssText(const String&, ExceptionCode&);
 
     KURL baseURL() const

Modified: trunk/Source/WebCore/css/CSSStyleRule.h (99058 => 99059)


--- trunk/Source/WebCore/css/CSSStyleRule.h	2011-11-02 14:24:31 UTC (rev 99058)
+++ trunk/Source/WebCore/css/CSSStyleRule.h	2011-11-02 15:02:03 UTC (rev 99059)
@@ -45,7 +45,7 @@
 
     CSSMutableStyleDeclaration* style() const { return m_style.get(); }
 
-    virtual String cssText() const;
+    String cssText() const;
 
     void adoptSelectorVector(Vector<OwnPtr<CSSParserSelector> >& selectors) { m_selectorList.adoptSelectorVector(selectors); }
     void setDeclaration(PassRefPtr<CSSMutableStyleDeclaration>);

Modified: trunk/Source/WebCore/css/WebKitCSSKeyframeRule.h (99058 => 99059)


--- trunk/Source/WebCore/css/WebKitCSSKeyframeRule.h	2011-11-02 14:24:31 UTC (rev 99058)
+++ trunk/Source/WebCore/css/WebKitCSSKeyframeRule.h	2011-11-02 15:02:03 UTC (rev 99059)
@@ -56,7 +56,7 @@
 
     CSSMutableStyleDeclaration* style() const { return m_style.get(); }
 
-    virtual String cssText() const;
+    String cssText() const;
 
     void setDeclaration(PassRefPtr<CSSMutableStyleDeclaration>);
 

Modified: trunk/Source/WebCore/css/WebKitCSSKeyframesRule.h (99058 => 99059)


--- trunk/Source/WebCore/css/WebKitCSSKeyframesRule.h	2011-11-02 14:24:31 UTC (rev 99058)
+++ trunk/Source/WebCore/css/WebKitCSSKeyframesRule.h	2011-11-02 15:02:03 UTC (rev 99059)
@@ -68,7 +68,7 @@
     void deleteRule(const String& key);
     WebKitCSSKeyframeRule* findRule(const String& key);
 
-    virtual String cssText() const;
+    String cssText() const;
 
     /* not part of the DOM */
     unsigned length() const;
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to