Title: [114058] branches/safari-534.57-branch

Diff

Modified: branches/safari-534.57-branch/LayoutTests/ChangeLog (114057 => 114058)


--- branches/safari-534.57-branch/LayoutTests/ChangeLog	2012-04-13 00:42:37 UTC (rev 114057)
+++ branches/safari-534.57-branch/LayoutTests/ChangeLog	2012-04-13 00:52:06 UTC (rev 114058)
@@ -1,3 +1,22 @@
+2012-04-12  Lucas Forschler  <[email protected]> 
+ 
+    <rdar://problem/11189647> Nectarine: XML error document creation should not fire mutation events (80765)
+ 
+    Merged ToT WebKit r112023. 
+ 
+    2012-03-24  Jeffrey Pfau  <[email protected]> 
+ 
+        XML error document creation should not fire mutation events 
+        https://bugs.webkit.org/show_bug.cgi?id=80765 
+ 
+        Reviewed by Adam Barth. 
+
+        Fixed tests that relied on old behavior. 
+ 
+        * fast/css/stylesheet-candidate-nodes-crash-expected.txt: 
+        * fast/css/stylesheet-candidate-nodes-crash.xhtml: 
+        * fast/dom/xml-parser-error-message-crash-expected.txt:
+ 	
 2012-04-12  Lucas Forschler  <[email protected]>
 
     Merge 109480

Modified: branches/safari-534.57-branch/LayoutTests/fast/css/stylesheet-candidate-nodes-crash-expected.txt (114057 => 114058)


--- branches/safari-534.57-branch/LayoutTests/fast/css/stylesheet-candidate-nodes-crash-expected.txt	2012-04-13 00:42:37 UTC (rev 114057)
+++ branches/safari-534.57-branch/LayoutTests/fast/css/stylesheet-candidate-nodes-crash-expected.txt	2012-04-13 00:52:06 UTC (rev 114058)
@@ -1,7 +1 @@
-This page contains the following errors:
-
-error on line 29 at column 9: Comment not terminated 
-error on line 32 at column 1: Comment not terminated
-Below is a rendering of the page up to the first error.
-
 PASS

Modified: branches/safari-534.57-branch/LayoutTests/fast/css/stylesheet-candidate-nodes-crash.xhtml (114057 => 114058)


--- branches/safari-534.57-branch/LayoutTests/fast/css/stylesheet-candidate-nodes-crash.xhtml	2012-04-13 00:42:37 UTC (rev 114057)
+++ branches/safari-534.57-branch/LayoutTests/fast/css/stylesheet-candidate-nodes-crash.xhtml	2012-04-13 00:52:06 UTC (rev 114058)
@@ -7,20 +7,20 @@
                     layoutTestController.dumpAsText();
                     layoutTestController.waitUntilDone();
                 }
-                
+
                 function runTest()
                 {
                     document.getElementsByTagNameNS('http://www.w3.org/1999/xhtml', 'style')[0];
-                    if (document.body)
+                    if (document.body) {
                         document.body.innerHTML = "PASS";
-                    
-                    if (window.layoutTestController)
-                        layoutTestController.notifyDone();
+                        if (window.layoutTestController)
+                            layoutTestController.notifyDone();
+                    }
                 }
             </script>
             <svg:style>
                 <xht:caption>
-                    <xht:iframe _onload_="runTest();"></xht:iframe>             
+                    <xht:iframe _onload_="runTest();"></xht:iframe>
                     <style></style>
                 </xht:caption>
             </svg:style>

Modified: branches/safari-534.57-branch/LayoutTests/fast/dom/xml-parser-error-message-crash-expected.txt (114057 => 114058)


--- branches/safari-534.57-branch/LayoutTests/fast/dom/xml-parser-error-message-crash-expected.txt	2012-04-13 00:42:37 UTC (rev 114057)
+++ branches/safari-534.57-branch/LayoutTests/fast/dom/xml-parser-error-message-crash-expected.txt	2012-04-13 00:52:06 UTC (rev 114058)
@@ -1 +1,6 @@
-PASS
+This page contains the following errors:
+
+error on line 14 at column 1: Extra content at the end of the document
+Below is a rendering of the page up to the first error.
+
+

Modified: branches/safari-534.57-branch/Source/WebCore/ChangeLog (114057 => 114058)


--- branches/safari-534.57-branch/Source/WebCore/ChangeLog	2012-04-13 00:42:37 UTC (rev 114057)
+++ branches/safari-534.57-branch/Source/WebCore/ChangeLog	2012-04-13 00:52:06 UTC (rev 114058)
@@ -1,3 +1,26 @@
+2012-04-12  Lucas Forschler  <[email protected]> 
+
+        <rdar://problem/11189647> Nectarine: XML error document creation should not fire mutation events (80765) 
+
+        Merged ToT WebKit r112023. 
+
+        * dom/Node.h: 
+        (WebCore::Node::reattach): Merged method from open source WebKit 
+        r87123. 
+
+    2012-03-24  Jeffrey Pfau  <[email protected]> 
+    
+        XML error document creation should not fire mutation events 
+        https://bugs.webkit.org/show_bug.cgi?id=80765 
+ 
+        Reviewed by Adam Barth. 
+ 
+        Broke two tests that expected the old behavior, which have now been updated. 
+ 
+        * xml/XMLErrors.cpp: 
+        (WebCore::createXHTMLParserErrorHeader): 
+        (WebCore::XMLErrors::insertErrorMessageBlock):
+
 2012-04-12  Lucas Forschler  <[email protected]>
 
     Merge 111977

Modified: branches/safari-534.57-branch/Source/WebCore/dom/Node.h (114057 => 114058)


--- branches/safari-534.57-branch/Source/WebCore/dom/Node.h	2012-04-13 00:42:37 UTC (rev 114057)
+++ branches/safari-534.57-branch/Source/WebCore/dom/Node.h	2012-04-13 00:52:06 UTC (rev 114058)
@@ -446,6 +446,8 @@
     // the node's rendering object from the rendering tree and delete it.
     virtual void detach();
 
+    void reattach();
+
     virtual void willRemove();
     void createRendererIfNeeded();
     PassRefPtr<RenderStyle> styleForRenderer();
@@ -732,6 +734,13 @@
     return parentOrHostNode();
 }
 
+inline void Node::reattach()
+{
+    if (attached())
+        detach();
+    attach();
+}
+
 } //namespace
 
 #ifndef NDEBUG

Modified: branches/safari-534.57-branch/Source/WebCore/dom/XMLDocumentParser.cpp (114057 => 114058)


--- branches/safari-534.57-branch/Source/WebCore/dom/XMLDocumentParser.cpp	2012-04-13 00:42:37 UTC (rev 114057)
+++ branches/safari-534.57-branch/Source/WebCore/dom/XMLDocumentParser.cpp	2012-04-13 00:52:06 UTC (rev 114058)
@@ -251,26 +251,31 @@
     return m_finishCalled;
 }
 
-static inline RefPtr<Element> createXHTMLParserErrorHeader(Document* doc, const String& errorMessages)
+static inline PassRefPtr<Element> createXHTMLParserErrorHeader(Document* doc, const String& errorMessages)
 {
-    RefPtr<Element> reportElement = doc->createElement(QualifiedName(nullAtom, "parsererror", xhtmlNamespaceURI), false);
-    reportElement->setAttribute(styleAttr, "display: block; white-space: pre; border: 2px solid #c77; padding: 0 1em 0 1em; margin: 1em; background-color: #fdd; color: black");
+    RefPtr<Element> reportElement = doc->createElement(QualifiedName(nullAtom, "parsererror", xhtmlNamespaceURI), true);
 
-    ExceptionCode ec = 0;
-    RefPtr<Element> h3 = doc->createElement(h3Tag, false);
-    reportElement->appendChild(h3.get(), ec);
-    h3->appendChild(doc->createTextNode("This page contains the following errors:"), ec);
+    RefPtr<NamedNodeMap> reportAttributes = NamedNodeMap::create();
+    reportAttributes->addAttribute(Attribute::createMapped(styleAttr, "display: block; white-space: pre; border: 2px solid #c77; padding: 0 1em 0 1em; margin: 1em; background-color: #fdd; color: black"));
+    reportElement->setAttributeMap(reportAttributes.release(), FragmentScriptingNotAllowed);
 
-    RefPtr<Element> fixed = doc->createElement(divTag, false);
-    reportElement->appendChild(fixed.get(), ec);
-    fixed->setAttribute(styleAttr, "font-family:monospace;font-size:12px");
-    fixed->appendChild(doc->createTextNode(errorMessages), ec);
+    RefPtr<Element> h3 = doc->createElement(h3Tag, true);
+    reportElement->parserAddChild(h3.get());
+    h3->parserAddChild(doc->createTextNode("This page contains the following errors:"));
 
-    h3 = doc->createElement(h3Tag, false);
-    reportElement->appendChild(h3.get(), ec);
-    h3->appendChild(doc->createTextNode("Below is a rendering of the page up to the first error."), ec);
+    RefPtr<Element> fixed = doc->createElement(divTag, true);
+    RefPtr<NamedNodeMap> fixedAttributes = NamedNodeMap::create();
+    fixedAttributes->addAttribute(Attribute::createMapped(styleAttr, "font-family:monospace;font-size:12px"));
+    fixed->setAttributeMap(fixedAttributes.release(), FragmentScriptingNotAllowed);
+    reportElement->parserAddChild(fixed.get());
 
-    return reportElement;
+    fixed->parserAddChild(doc->createTextNode(errorMessages));
+
+    h3 = doc->createElement(h3Tag, true);
+    reportElement->parserAddChild(h3.get());
+    h3->parserAddChild(doc->createTextNode("Below is a rendering of the page up to the first error."));
+
+    return reportElement.release();
 }
 
 void XMLDocumentParser::insertErrorMessageBlock()
@@ -284,36 +289,62 @@
     // where the errors are located)
 
     // Create elements for display
-    ExceptionCode ec = 0;
     Document* document = this->document();
     RefPtr<Element> documentElement = document->documentElement();
     if (!documentElement) {
-        RefPtr<Element> rootElement = document->createElement(htmlTag, false);
-        document->appendChild(rootElement, ec);
-        RefPtr<Element> body = document->createElement(bodyTag, false);
-        rootElement->appendChild(body, ec);
+        RefPtr<Element> rootElement = document->createElement(htmlTag, true);
+        RefPtr<Element> body = document->createElement(bodyTag, true);
+        rootElement->parserAddChild(body);
+        document->parserAddChild(rootElement);
+        if (document->attached() && !rootElement->attached())
+            rootElement->attach();
         documentElement = body.get();
     }
 #if ENABLE(SVG)
     else if (documentElement->namespaceURI() == SVGNames::svgNamespaceURI) {
-        RefPtr<Element> rootElement = document->createElement(htmlTag, false);
-        RefPtr<Element> body = document->createElement(bodyTag, false);
-        rootElement->appendChild(body, ec);
-        body->appendChild(documentElement, ec);
-        document->appendChild(rootElement.get(), ec);
+        RefPtr<Element> rootElement = document->createElement(htmlTag, true);
+        RefPtr<Element> body = document->createElement(bodyTag, true);
+        rootElement->parserAddChild(body);
+
+        documentElement->parentNode()->parserRemoveChild(documentElement.get());
+        if (documentElement->attached())
+            documentElement->detach();
+
+        body->parserAddChild(documentElement);
+        document->parserAddChild(rootElement.get());
+
+        if (document->attached()) {
+            // rootElement shouldn't be attached right now, but in some cases might be.
+            // See https://bugs.webkit.org/show_bug.cgi?id=81985
+            rootElement->reattach();
+        }
+
         documentElement = body.get();
     }
 #endif
+
     RefPtr<Element> reportElement = createXHTMLParserErrorHeader(document, m_errorMessages);
-    documentElement->insertBefore(reportElement, documentElement->firstChild(), ec);
+
 #if ENABLE(XSLT)
     if (document->transformSourceDocument()) {
-        RefPtr<Element> paragraph = document->createElement(pTag, false);
-        paragraph->setAttribute(styleAttr, "white-space: normal");
-        paragraph->appendChild(document->createTextNode("This document was created as the result of an XSL transformation. The line and column numbers given are from the transformed result."), ec);
-        reportElement->appendChild(paragraph.release(), ec);
+        RefPtr<NamedNodeMap> attributes = NamedNodeMap::create();
+        attributes->addAttribute(Attribute::createMapped(styleAttr, "white-space: normal"));
+        RefPtr<Element> paragraph = document->createElement(pTag, true);
+        paragraph->setAttributeMap(attributes.release(), FragmentScriptingNotAllowed);
+        paragraph->parserAddChild(document->createTextNode("This document was created as the result of an XSL transformation. The line and column numbers given are from the transformed result."));
+        reportElement->parserAddChild(paragraph.release());
     }
 #endif
+
+    Node* firstChild = documentElement->firstChild();
+    if (firstChild)
+        documentElement->parserInsertBefore(reportElement, documentElement->firstChild());
+    else
+        documentElement->parserAddChild(reportElement);
+
+    if (documentElement->attached() && !reportElement->attached())
+        reportElement->attach();
+
     document->updateStyleIfNeeded();
 }
 
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to