Title: [97751] trunk/Source/WebCore
Revision
97751
Author
[email protected]
Date
2011-10-18 07:35:11 -0700 (Tue, 18 Oct 2011)

Log Message

XSLStyleSheet only needs to manage XSLImportRule children.
https://bugs.webkit.org/show_bug.cgi?id=70326

Reviewed by Antti Koivisto.

* css/StyleBase.h:
* xml/XSLImportRule.h:
* css/CSSRule.h:
(WebCore::CSSRule::isImportRule):

    Move StyleBase::isImportRule() down to CSSRule. Since XSLImportRule no longer
    implements it, it's now specific to CSSImportRule.

* xml/XSLStyleSheet.h:

    Change m_children to be a vector of XSLImportRules. Also remove length(),
    item() and append() since they were only used internally to modify m_children.

* xml/XSLStyleSheetQt.cpp:
(WebCore::XSLStyleSheet::~XSLStyleSheet):
* xml/XSLStyleSheetLibxslt.cpp:
(WebCore::XSLStyleSheet::~XSLStyleSheet):
(WebCore::XSLStyleSheet::isLoading):
(WebCore::XSLStyleSheet::clearDocuments):
(WebCore::XSLStyleSheet::loadChildSheet):
(WebCore::XSLStyleSheet::locateStylesheetSubResource):

    Remove now-unnecessary isImportRule() checks and tidy up the code a bit.

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (97750 => 97751)


--- trunk/Source/WebCore/ChangeLog	2011-10-18 14:22:24 UTC (rev 97750)
+++ trunk/Source/WebCore/ChangeLog	2011-10-18 14:35:11 UTC (rev 97751)
@@ -1,3 +1,34 @@
+2011-10-18  Andreas Kling  <[email protected]>
+
+        XSLStyleSheet only needs to manage XSLImportRule children.
+        https://bugs.webkit.org/show_bug.cgi?id=70326
+
+        Reviewed by Antti Koivisto.
+
+        * css/StyleBase.h:
+        * xml/XSLImportRule.h:
+        * css/CSSRule.h:
+        (WebCore::CSSRule::isImportRule):
+
+            Move StyleBase::isImportRule() down to CSSRule. Since XSLImportRule no longer
+            implements it, it's now specific to CSSImportRule.
+
+        * xml/XSLStyleSheet.h:
+
+            Change m_children to be a vector of XSLImportRules. Also remove length(),
+            item() and append() since they were only used internally to modify m_children.
+
+        * xml/XSLStyleSheetQt.cpp:
+        (WebCore::XSLStyleSheet::~XSLStyleSheet):
+        * xml/XSLStyleSheetLibxslt.cpp:
+        (WebCore::XSLStyleSheet::~XSLStyleSheet):
+        (WebCore::XSLStyleSheet::isLoading):
+        (WebCore::XSLStyleSheet::clearDocuments):
+        (WebCore::XSLStyleSheet::loadChildSheet):
+        (WebCore::XSLStyleSheet::locateStylesheetSubResource):
+
+            Remove now-unnecessary isImportRule() checks and tidy up the code a bit.
+
 2011-10-18  Zan Dobersek  <[email protected]>
 
         [Gtk] Support for client-based geolocation

Modified: trunk/Source/WebCore/css/CSSRule.h (97750 => 97751)


--- trunk/Source/WebCore/css/CSSRule.h	2011-10-18 14:22:24 UTC (rev 97750)
+++ trunk/Source/WebCore/css/CSSRule.h	2011-10-18 14:35:11 UTC (rev 97751)
@@ -57,6 +57,7 @@
     virtual bool isPageRule() const { return false; }
     virtual bool isStyleRule() const { return false; }
     virtual bool isRegionStyleRule() const { return false; }
+    virtual bool isImportRule() const { return false; }
 
     CSSStyleSheet* parentStyleSheet() const;
     CSSRule* parentRule() const;

Modified: trunk/Source/WebCore/css/StyleBase.h (97750 => 97751)


--- trunk/Source/WebCore/css/StyleBase.h	2011-10-18 14:22:24 UTC (rev 97750)
+++ trunk/Source/WebCore/css/StyleBase.h	2011-10-18 14:35:11 UTC (rev 97751)
@@ -48,7 +48,6 @@
         KURL baseURL() const;
 
         virtual bool isRule() const { return false; }
-        virtual bool isImportRule() const { return false; }
 
         virtual bool isStyleSheet() const { return false; }
         virtual bool isCSSStyleSheet() const { return false; }

Modified: trunk/Source/WebCore/xml/XSLImportRule.h (97750 => 97751)


--- trunk/Source/WebCore/xml/XSLImportRule.h	2011-10-18 14:22:24 UTC (rev 97750)
+++ trunk/Source/WebCore/xml/XSLImportRule.h	2011-10-18 14:35:11 UTC (rev 97751)
@@ -55,8 +55,6 @@
 private:
     XSLImportRule(XSLStyleSheet* parentSheet, const String& href);
 
-    virtual bool isImportRule() const { return true; }
-
     virtual void setXSLStyleSheet(const String& href, const KURL& baseURL, const String& sheet);
     
     String m_strHref;

Modified: trunk/Source/WebCore/xml/XSLStyleSheet.h (97750 => 97751)


--- trunk/Source/WebCore/xml/XSLStyleSheet.h	2011-10-18 14:22:24 UTC (rev 97750)
+++ trunk/Source/WebCore/xml/XSLStyleSheet.h	2011-10-18 14:35:11 UTC (rev 97751)
@@ -56,9 +56,6 @@
         return adoptRef(new XSLStyleSheet(parentNode, finalURL.string(), finalURL, true));
     }
 
-    unsigned length() const { return m_children.size(); }
-    StyleBase* item(unsigned index) { return index < length() ? m_children.at(index).get() : 0; }
-
     // Taking an arbitrary node is unsafe, because owner node pointer can become stale.
     // XSLTProcessor ensures that the stylesheet doesn't outlive its parent, in part by not exposing it to _javascript_.
     static PassRefPtr<XSLStyleSheet> createForXSLTProcessor(Node* parentNode, const String& originalURL, const KURL& finalURL)
@@ -100,17 +97,12 @@
     bool processed() const { return m_processed; }
 
 private:
-    void append(PassRefPtr<StyleBase> child)
-    {
-        m_children.append(child);
-    }
-
     XSLStyleSheet(Node* parentNode, const String& originalURL, const KURL& finalURL, bool embedded);
 #if !USE(QXMLQUERY)
     XSLStyleSheet(XSLImportRule* parentImport, const String& originalURL, const KURL& finalURL);
 #endif
 
-    Vector<RefPtr<StyleBase> > m_children;
+    Vector<RefPtr<XSLImportRule> > m_children;
 
     Document* m_ownerDocument;
     bool m_embedded;

Modified: trunk/Source/WebCore/xml/XSLStyleSheetLibxslt.cpp (97750 => 97751)


--- trunk/Source/WebCore/xml/XSLStyleSheetLibxslt.cpp	2011-10-18 14:22:24 UTC (rev 97750)
+++ trunk/Source/WebCore/xml/XSLStyleSheetLibxslt.cpp	2011-10-18 14:35:11 UTC (rev 97751)
@@ -79,22 +79,17 @@
     if (!m_stylesheetDocTaken)
         xmlFreeDoc(m_stylesheetDoc);
 
-    for (unsigned i = 0; i < length(); ++i) {
-        ASSERT(item(i)->parent() == this);
-        item(i)->setParent(0);
+    for (unsigned i = 0; i < m_children.size(); ++i) {
+        ASSERT(m_children.at(i)->parent() == this);
+        m_children.at(i)->setParent(0);
     }
 }
 
 bool XSLStyleSheet::isLoading()
 {
-    unsigned len = length();
-    for (unsigned i = 0; i < len; ++i) {
-        StyleBase* rule = item(i);
-        if (rule->isImportRule()) {
-            XSLImportRule* import = static_cast<XSLImportRule*>(rule);
-            if (import->isLoading())
-                return true;
-        }
+    for (unsigned i = 0; i < m_children.size(); ++i) {
+        if (m_children.at(i)->isLoading())
+            return true;
     }
     return false;
 }
@@ -119,14 +114,10 @@
 void XSLStyleSheet::clearDocuments()
 {
     m_stylesheetDoc = 0;
-    unsigned len = length();
-    for (unsigned i = 0; i < len; ++i) {
-        StyleBase* rule = item(i);
-        if (rule->isImportRule()) {
-            XSLImportRule* import = static_cast<XSLImportRule*>(rule);
-            if (import->styleSheet())
-                import->styleSheet()->clearDocuments();
-        }
+    for (unsigned i = 0; i < m_children.size(); ++i) {
+        XSLImportRule* import = m_children.at(i).get();
+        if (import->styleSheet())
+            import->styleSheet()->clearDocuments();
     }
 }
 
@@ -239,7 +230,7 @@
 void XSLStyleSheet::loadChildSheet(const String& href)
 {
     RefPtr<XSLImportRule> childRule = XSLImportRule::create(this, href);
-    append(childRule);
+    m_children.append(childRule);
     childRule->loadSheet();
 }
 
@@ -276,38 +267,34 @@
 xmlDocPtr XSLStyleSheet::locateStylesheetSubResource(xmlDocPtr parentDoc, const xmlChar* uri)
 {
     bool matchedParent = (parentDoc == document());
-    unsigned len = length();
-    for (unsigned i = 0; i < len; ++i) {
-        StyleBase* rule = item(i);
-        if (rule->isImportRule()) {
-            XSLImportRule* import = static_cast<XSLImportRule*>(rule);
-            XSLStyleSheet* child = import->styleSheet();
-            if (!child)
-                continue;
-            if (matchedParent) {
-                if (child->processed())
-                    continue; // libxslt has been given this sheet already.
+    for (unsigned i = 0; i < m_children.size(); ++i) {
+        XSLImportRule* import = m_children.at(i).get();
+        XSLStyleSheet* child = import->styleSheet();
+        if (!child)
+            continue;
+        if (matchedParent) {
+            if (child->processed())
+                continue; // libxslt has been given this sheet already.
 
-                // Check the URI of the child stylesheet against the doc URI.
-                // In order to ensure that libxml canonicalized both URLs, we get the original href
-                // string from the import rule and canonicalize it using libxml before comparing it
-                // with the URI argument.
-                CString importHref = import->href().utf8();
-                xmlChar* base = xmlNodeGetBase(parentDoc, (xmlNodePtr)parentDoc);
-                xmlChar* childURI = xmlBuildURI((const xmlChar*)importHref.data(), base);
-                bool equalURIs = xmlStrEqual(uri, childURI);
-                xmlFree(base);
-                xmlFree(childURI);
-                if (equalURIs) {
-                    child->markAsProcessed();
-                    return child->document();
-                }
-            } else {
-                xmlDocPtr result = import->styleSheet()->locateStylesheetSubResource(parentDoc, uri);
-                if (result)
-                    return result;
+            // Check the URI of the child stylesheet against the doc URI.
+            // In order to ensure that libxml canonicalized both URLs, we get the original href
+            // string from the import rule and canonicalize it using libxml before comparing it
+            // with the URI argument.
+            CString importHref = import->href().utf8();
+            xmlChar* base = xmlNodeGetBase(parentDoc, (xmlNodePtr)parentDoc);
+            xmlChar* childURI = xmlBuildURI((const xmlChar*)importHref.data(), base);
+            bool equalURIs = xmlStrEqual(uri, childURI);
+            xmlFree(base);
+            xmlFree(childURI);
+            if (equalURIs) {
+                child->markAsProcessed();
+                return child->document();
             }
+            continue;
         }
+        xmlDocPtr result = import->styleSheet()->locateStylesheetSubResource(parentDoc, uri);
+        if (result)
+            return result;
     }
 
     return 0;

Modified: trunk/Source/WebCore/xml/XSLStyleSheetQt.cpp (97750 => 97751)


--- trunk/Source/WebCore/xml/XSLStyleSheetQt.cpp	2011-10-18 14:22:24 UTC (rev 97750)
+++ trunk/Source/WebCore/xml/XSLStyleSheetQt.cpp	2011-10-18 14:35:11 UTC (rev 97751)
@@ -28,6 +28,7 @@
 #include "Document.h"
 #include "Node.h"
 #include "NotImplemented.h"
+#include "XSLImportRule.h"
 #include "XSLTProcessor.h"
 
 namespace WebCore {
@@ -40,9 +41,9 @@
 
 XSLStyleSheet::~XSLStyleSheet()
 {
-    for (unsigned i = 0; i < length(); ++i) {
-        ASSERT(item(i)->parent() == this);
-        item(i)->setParent(0);
+    for (unsigned i = 0; i < m_children.size(); ++i) {
+        ASSERT(m_children.at(i)->parent() == this);
+        m_children.at(i)->setParent(0);
     }
 }
 
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to