2006-03-13 Eric Seidel <eseidel@apple.com>
authoreseidel <eseidel@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 14 Mar 2006 03:30:36 +0000 (03:30 +0000)
committereseidel <eseidel@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 14 Mar 2006 03:30:36 +0000 (03:30 +0000)
        Reviewed by ggaren & TimH.

        <rdar://problem/4473288> XSL file containing <xsl:include href="../Styles/EscapeString.xsl" /> fails to load file
        XML_DTD_NODE objects in the tree were causing loadChildSheets to
        fail to preload child stylesheets, this patch causes us to
        correctly ignore all nodes besides the first XML_ELEMENT_NODE at
        the root level when searching the tree for xsl:include statements
        to pre-load.

        Test: fast/xsl/xslt-second-level-import.xml

        * khtml/xsl/xsl_stylesheetimpl.cpp:
        (WebCore::XSLStyleSheetImpl::loadChildSheets):

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

LayoutTests/ChangeLog
LayoutTests/fast/xsl/resources/xslt-second-level-import.xsl [new file with mode: 0644]
LayoutTests/fast/xsl/resources/xslt-second-level-import.xsl.dtd [new file with mode: 0644]
LayoutTests/fast/xsl/resources/xslt-second-level-import2.xsl [new file with mode: 0644]
LayoutTests/fast/xsl/xslt-second-level-import-expected.txt [new file with mode: 0644]
LayoutTests/fast/xsl/xslt-second-level-import.xml [new file with mode: 0644]
WebCore/ChangeLog
WebCore/khtml/xsl/xsl_stylesheetimpl.cpp

index 8f32abf9c6f166e2e416a84b897e12994fe1abe7..bdbcc28ffe3b010ad4e17cd4545f1db250353f82 100644 (file)
@@ -1,3 +1,13 @@
+2006-03-13  Eric Seidel  <eseidel@apple.com>
+
+        Reviewed by ggaren & TimH.
+
+        * fast/xsl/resources/xslt-second-level-import.xsl: Added.
+        * fast/xsl/resources/xslt-second-level-import.xsl.dtd: Added.
+        * fast/xsl/resources/xslt-second-level-import2.xsl: Added.
+        * fast/xsl/xslt-second-level-import-expected.txt: Added.
+        * fast/xsl/xslt-second-level-import.xml: Added.
+
 2006-03-12  Rob Buis  <buis@kde.org>
 
         Reviewed by darin.  Landed by eseidel.
diff --git a/LayoutTests/fast/xsl/resources/xslt-second-level-import.xsl b/LayoutTests/fast/xsl/resources/xslt-second-level-import.xsl
new file mode 100644 (file)
index 0000000..96b4980
--- /dev/null
@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!DOCTYPE xsl:stylesheet SYSTEM "resources/xslt-second-level-import.xsl.dtd">
+<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
+  <xsl:include href="xslt-second-level-import2.xsl" />
+  <xsl:template match="/">
+    <script>
+        if (window.layoutTestController)
+            layoutTestController.dumpAsText();
+    </script>
+    <p>&success;</p>
+  </xsl:template>
+</xsl:stylesheet>
diff --git a/LayoutTests/fast/xsl/resources/xslt-second-level-import.xsl.dtd b/LayoutTests/fast/xsl/resources/xslt-second-level-import.xsl.dtd
new file mode 100644 (file)
index 0000000..068f1af
--- /dev/null
@@ -0,0 +1 @@
+<!ENTITY success "SUCCESS">
diff --git a/LayoutTests/fast/xsl/resources/xslt-second-level-import2.xsl b/LayoutTests/fast/xsl/resources/xslt-second-level-import2.xsl
new file mode 100644 (file)
index 0000000..04ddaad
--- /dev/null
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="utf-8"?>
+<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
+<xsl:output method="html" encoding="UTF-8"/>
+</xsl:stylesheet>
diff --git a/LayoutTests/fast/xsl/xslt-second-level-import-expected.txt b/LayoutTests/fast/xsl/xslt-second-level-import-expected.txt
new file mode 100644 (file)
index 0000000..86aefce
--- /dev/null
@@ -0,0 +1,3 @@
+SUCCESS
+
+
diff --git a/LayoutTests/fast/xsl/xslt-second-level-import.xml b/LayoutTests/fast/xsl/xslt-second-level-import.xml
new file mode 100644 (file)
index 0000000..2f2768f
--- /dev/null
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="utf-8"?>
+<?xml-stylesheet type="text/xsl" href="resources/xslt-second-level-import.xsl"?>
+<stub>
+FAIL
+
+This test checks to make sure that XML_DTD_NODE objects being at the top level of an external stylesheet does not cause pre-loading of child stylesheets to fail.
+
+</stub>
index d57763cbf7098d90bd1564cfbd0c79aefb63a011..6db3700d7c38eadba0dc35e0e9c11e6a364f7da7 100644 (file)
@@ -1,3 +1,19 @@
+2006-03-13  Eric Seidel  <eseidel@apple.com>
+
+        Reviewed by ggaren & TimH.
+
+        <rdar://problem/4473288> XSL file containing <xsl:include href="../Styles/EscapeString.xsl" /> fails to load file
+        XML_DTD_NODE objects in the tree were causing loadChildSheets to 
+        fail to preload child stylesheets, this patch causes us to 
+        correctly ignore all nodes besides the first XML_ELEMENT_NODE at 
+        the root level when searching the tree for xsl:include statements 
+        to pre-load.
+
+        Test: fast/xsl/xslt-second-level-import.xml
+
+        * khtml/xsl/xsl_stylesheetimpl.cpp:
+        (WebCore::XSLStyleSheetImpl::loadChildSheets):
+
 2006-03-10  Rob Buis  <buis@kde.org>
 
         Reviewed by darin.  Landed by eseidel.
index 6691b01ca78c8d5c2da232f6563089f6cfdfebb3..c5d11a06e0be8c67d67aed7f69ed4d5168331314 100644 (file)
@@ -142,11 +142,16 @@ void XSLStyleSheetImpl::loadChildSheets()
         return;
     
     xmlNodePtr stylesheetRoot = document()->children;
+    
+    // Top level children may include other things such as DTD nodes, we ignore those.
+    while (stylesheetRoot && stylesheetRoot->type != XML_ELEMENT_NODE)
+        stylesheetRoot = stylesheetRoot->next;
+    
     if (m_embedded) {
         // We have to locate (by ID) the appropriate embedded stylesheet element, so that we can walk the 
         // import/include list.
         xmlAttrPtr idNode = xmlGetID(document(), (const xmlChar*)(href().qstring().utf8().data()));
-        if (idNode == NULL)
+        if (!idNode)
             return;
         stylesheetRoot = idNode->parent;
     } else {