Title: [174332] trunk/Source/WebCore
Revision
174332
Author
cdu...@apple.com
Date
2014-10-05 17:23:58 -0700 (Sun, 05 Oct 2014)

Log Message

Use is<>() / downcast<>() for StyleSheet subclasses
https://bugs.webkit.org/show_bug.cgi?id=137429

Reviewed by Benjamin Poulain.

Use is<>() / downcast<>() for StyleSheet subclasses.

No new tests, no behavior change.

* bindings/gobject/WebKitDOMPrivate.cpp:
(WebKit::wrap):
* css/CSSStyleSheet.h:
(isType):
* css/StyleSheet.h:
* dom/Document.cpp:
(WebCore::Document::applyXSLTransform):
* dom/DocumentStyleSheetCollection.cpp:
(WebCore::filterEnabledNonemptyCSSStyleSheets):
* dom/ProcessingInstruction.cpp:
(WebCore::ProcessingInstruction::parseStyleSheet):
* inspector/InspectorCSSAgent.cpp:
(WebCore::InspectorCSSAgent::getAllStyleSheets):
* xml/XSLStyleSheet.h:
(isType):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (174331 => 174332)


--- trunk/Source/WebCore/ChangeLog	2014-10-05 23:27:48 UTC (rev 174331)
+++ trunk/Source/WebCore/ChangeLog	2014-10-06 00:23:58 UTC (rev 174332)
@@ -1,5 +1,32 @@
 2014-10-05  Christophe Dumez  <cdu...@apple.com>
 
+        Use is<>() / downcast<>() for StyleSheet subclasses
+        https://bugs.webkit.org/show_bug.cgi?id=137429
+
+        Reviewed by Benjamin Poulain.
+
+        Use is<>() / downcast<>() for StyleSheet subclasses.
+
+        No new tests, no behavior change.
+
+        * bindings/gobject/WebKitDOMPrivate.cpp:
+        (WebKit::wrap):
+        * css/CSSStyleSheet.h:
+        (isType):
+        * css/StyleSheet.h:
+        * dom/Document.cpp:
+        (WebCore::Document::applyXSLTransform):
+        * dom/DocumentStyleSheetCollection.cpp:
+        (WebCore::filterEnabledNonemptyCSSStyleSheets):
+        * dom/ProcessingInstruction.cpp:
+        (WebCore::ProcessingInstruction::parseStyleSheet):
+        * inspector/InspectorCSSAgent.cpp:
+        (WebCore::InspectorCSSAgent::getAllStyleSheets):
+        * xml/XSLStyleSheet.h:
+        (isType):
+
+2014-10-05  Christophe Dumez  <cdu...@apple.com>
+
         Use is<>() / downcast<>() for CryptoAlgorithmParameters subclasses
         https://bugs.webkit.org/show_bug.cgi?id=137432
 

Modified: trunk/Source/WebCore/bindings/gobject/WebKitDOMPrivate.cpp (174331 => 174332)


--- trunk/Source/WebCore/bindings/gobject/WebKitDOMPrivate.cpp	2014-10-05 23:27:48 UTC (rev 174331)
+++ trunk/Source/WebCore/bindings/gobject/WebKitDOMPrivate.cpp	2014-10-06 00:23:58 UTC (rev 174332)
@@ -140,8 +140,8 @@
 {
     ASSERT(styleSheet);
 
-    if (styleSheet->isCSSStyleSheet())
-        return WEBKIT_DOM_STYLE_SHEET(wrapCSSStyleSheet(toCSSStyleSheet(styleSheet)));
+    if (is<CSSStyleSheet>(*styleSheet))
+        return WEBKIT_DOM_STYLE_SHEET(wrapCSSStyleSheet(downcast<CSSStyleSheet>(styleSheet)));
     return wrapStyleSheet(styleSheet);
 }
 

Modified: trunk/Source/WebCore/css/CSSStyleSheet.h (174331 => 174332)


--- trunk/Source/WebCore/css/CSSStyleSheet.h	2014-10-05 23:27:48 UTC (rev 174331)
+++ trunk/Source/WebCore/css/CSSStyleSheet.h	2014-10-06 00:23:58 UTC (rev 174332)
@@ -27,6 +27,7 @@
 #include <memory>
 #include <wtf/HashMap.h>
 #include <wtf/Noncopyable.h>
+#include <wtf/TypeCasts.h>
 #include <wtf/text/AtomicStringHash.h>
 
 namespace WebCore {
@@ -139,8 +140,10 @@
     mutable std::unique_ptr<CSSRuleList> m_ruleListCSSOMWrapper;
 };
 
-STYLE_SHEET_TYPE_CASTS(CSSStyleSheet)
+} // namespace WebCore
 
-} // namespace
+SPECIALIZE_TYPE_TRAITS_BEGIN(WebCore::CSSStyleSheet)
+    static bool isType(const WebCore::StyleSheet& styleSheet) { return styleSheet.isCSSStyleSheet(); }
+SPECIALIZE_TYPE_TRAITS_END()
 
-#endif
+#endif // CSSStyleSheet_h

Modified: trunk/Source/WebCore/css/StyleSheet.h (174331 => 174332)


--- trunk/Source/WebCore/css/StyleSheet.h	2014-10-05 23:27:48 UTC (rev 174331)
+++ trunk/Source/WebCore/css/StyleSheet.h	2014-10-06 00:23:58 UTC (rev 174332)
@@ -55,10 +55,6 @@
     virtual bool isXSLStyleSheet() const { return false; }
 };
 
-#define STYLE_SHEET_TYPE_CASTS(ToClassName) \
-    template<typename T> inline ToClassName* to##ToClassName(const RefPtr<T>& styleSheet) { return to##ToClassName(styleSheet.get()); } \
-    TYPE_CASTS_BASE(ToClassName, StyleSheet, styleSheet, styleSheet->is##ToClassName(), styleSheet.is##ToClassName())
+} // namespace WebCore
 
-} // namespace
-
-#endif
+#endif // StyleSheet_h

Modified: trunk/Source/WebCore/dom/Document.cpp (174331 => 174332)


--- trunk/Source/WebCore/dom/Document.cpp	2014-10-05 23:27:48 UTC (rev 174331)
+++ trunk/Source/WebCore/dom/Document.cpp	2014-10-06 00:23:58 UTC (rev 174332)
@@ -4383,7 +4383,7 @@
 void Document::applyXSLTransform(ProcessingInstruction* pi)
 {
     RefPtr<XSLTProcessor> processor = XSLTProcessor::create();
-    processor->setXSLStyleSheet(static_cast<XSLStyleSheet*>(pi->sheet()));
+    processor->setXSLStyleSheet(downcast<XSLStyleSheet>(pi->sheet()));
     String resultMIMEType;
     String newSource;
     String resultEncoding;

Modified: trunk/Source/WebCore/dom/DocumentStyleSheetCollection.cpp (174331 => 174332)


--- trunk/Source/WebCore/dom/DocumentStyleSheetCollection.cpp	2014-10-05 23:27:48 UTC (rev 174331)
+++ trunk/Source/WebCore/dom/DocumentStyleSheetCollection.cpp	2014-10-06 00:23:58 UTC (rev 174332)
@@ -409,14 +409,14 @@
 static void filterEnabledNonemptyCSSStyleSheets(Vector<RefPtr<CSSStyleSheet>>& result, const Vector<RefPtr<StyleSheet>>& sheets)
 {
     for (unsigned i = 0; i < sheets.size(); ++i) {
-        if (!sheets[i]->isCSSStyleSheet())
+        if (!is<CSSStyleSheet>(*sheets[i]))
             continue;
-        if (sheets[i]->disabled())
+        CSSStyleSheet& sheet = downcast<CSSStyleSheet>(*sheets[i]);
+        if (sheet.disabled())
             continue;
-        CSSStyleSheet* sheet = toCSSStyleSheet(sheets[i]);
-        if (!sheet->length())
+        if (!sheet.length())
             continue;
-        result.append(sheet);
+        result.append(&sheet);
     }
 }
 

Modified: trunk/Source/WebCore/dom/ProcessingInstruction.cpp (174331 => 174332)


--- trunk/Source/WebCore/dom/ProcessingInstruction.cpp	2014-10-05 23:27:48 UTC (rev 174331)
+++ trunk/Source/WebCore/dom/ProcessingInstruction.cpp	2014-10-06 00:23:58 UTC (rev 174332)
@@ -222,10 +222,10 @@
 void ProcessingInstruction::parseStyleSheet(const String& sheet)
 {
     if (m_isCSS)
-        toCSSStyleSheet(*m_sheet).contents().parseString(sheet);
+        downcast<CSSStyleSheet>(*m_sheet).contents().parseString(sheet);
 #if ENABLE(XSLT)
     else if (m_isXSL)
-        static_cast<XSLStyleSheet*>(m_sheet.get())->parseString(sheet);
+        downcast<XSLStyleSheet>(*m_sheet).parseString(sheet);
 #endif
 
     if (m_cachedSheet)
@@ -235,10 +235,10 @@
     m_loading = false;
 
     if (m_isCSS)
-        toCSSStyleSheet(*m_sheet).contents().checkLoaded();
+        downcast<CSSStyleSheet>(*m_sheet).contents().checkLoaded();
 #if ENABLE(XSLT)
     else if (m_isXSL)
-        static_cast<XSLStyleSheet*>(m_sheet.get())->checkLoaded();
+        downcast<XSLStyleSheet>(*m_sheet).checkLoaded();
 #endif
 }
 

Modified: trunk/Source/WebCore/inspector/InspectorCSSAgent.cpp (174331 => 174332)


--- trunk/Source/WebCore/inspector/InspectorCSSAgent.cpp	2014-10-05 23:27:48 UTC (rev 174331)
+++ trunk/Source/WebCore/inspector/InspectorCSSAgent.cpp	2014-10-06 00:23:58 UTC (rev 174332)
@@ -684,8 +684,8 @@
         StyleSheetList& list = (*it)->styleSheets();
         for (unsigned i = 0; i < list.length(); ++i) {
             StyleSheet& styleSheet = *list.item(i);
-            if (styleSheet.isCSSStyleSheet())
-                collectStyleSheets(&toCSSStyleSheet(styleSheet), styleInfos.get());
+            if (is<CSSStyleSheet>(styleSheet))
+                collectStyleSheets(&downcast<CSSStyleSheet>(styleSheet), styleInfos.get());
         }
     }
 }

Modified: trunk/Source/WebCore/xml/XSLStyleSheet.h (174331 => 174332)


--- trunk/Source/WebCore/xml/XSLStyleSheet.h	2014-10-05 23:27:48 UTC (rev 174331)
+++ trunk/Source/WebCore/xml/XSLStyleSheet.h	2014-10-06 00:23:58 UTC (rev 174332)
@@ -32,6 +32,7 @@
 #include <libxslt/transform.h>
 
 #include <wtf/PassRefPtr.h>
+#include <wtf/TypeCasts.h>
 
 namespace WebCore {
 
@@ -97,11 +98,11 @@
     virtual URL baseURL() const override { return m_finalURL; }
     virtual bool isLoading() const override;
 
-    virtual bool isXSLStyleSheet() const override { return true; }
-
 private:
     XSLStyleSheet(Node* parentNode, const String& originalURL, const URL& finalURL, bool embedded);
     XSLStyleSheet(XSLImportRule* parentImport, const String& originalURL, const URL& finalURL);
+
+    virtual bool isXSLStyleSheet() const override { return true; }
     
     Node* m_ownerNode;
     String m_originalURL;
@@ -121,6 +122,10 @@
 
 } // namespace WebCore
 
+SPECIALIZE_TYPE_TRAITS_BEGIN(WebCore::XSLStyleSheet)
+    static bool isType(const WebCore::StyleSheet& styleSheet) { return styleSheet.isXSLStyleSheet(); }
+SPECIALIZE_TYPE_TRAITS_END()
+
 #endif // ENABLE(XSLT)
 
 #endif // XSLStyleSheet_h
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to