Title: [86921] trunk/Source/WebCore
Revision
86921
Author
[email protected]
Date
2011-05-19 19:39:21 -0700 (Thu, 19 May 2011)

Log Message

2011-05-19  Julien Chaffraix  <[email protected]>

        Reviewed by Adam Barth.

        Remove Node::deprecatedParserAddChild
        https://bugs.webkit.org/show_bug.cgi?id=60818

        Refactoring only so no new tests.

        This patch fails short of one instance of deprecatedParserAddChild which will
        require a refactoring of <input> shadow DOM to be removed.

        * dom/XMLDocumentParser.cpp:
        (WebCore::XMLDocumentParser::pushCurrentNode): Updated to use a ContainerNode.
        (WebCore::XMLDocumentParser::clearCurrentNodeStack): We now need to clear
        up m_leafTextNode too.

        (WebCore::XMLDocumentParser::enterText):
        (WebCore::XMLDocumentParser::exitText):
        Those methods were updated to use m_leafTextNode instead of m_currentNode.

        * dom/XMLDocumentParser.h:
        Changed the currentNode logic to use ContainerNode. Also fixed the style of the
        forward declarations.

        * dom/XMLDocumentParserLibxml2.cpp:
        (WebCore::XMLDocumentParser::startElementNs):
        (WebCore::XMLDocumentParser::endElementNs):
        (WebCore::XMLDocumentParser::characters):
        (WebCore::XMLDocumentParser::processingInstruction):
        (WebCore::XMLDocumentParser::cdataBlock):
        (WebCore::XMLDocumentParser::comment):
        * dom/XMLDocumentParserQt.cpp:
        (WebCore::XMLDocumentParser::parse):
        (WebCore::XMLDocumentParser::parseStartElement):
        (WebCore::XMLDocumentParser::parseEndElement):
        (WebCore::XMLDocumentParser::parseCharacters):
        (WebCore::XMLDocumentParser::parseProcessingInstruction):
        (WebCore::XMLDocumentParser::parseCdata):
        (WebCore::XMLDocumentParser::parseComment):
        Removed the calls to deprecatedParserAddChild, changed the code to use
        m_leafTextNode when it made sense and used ContainerNode instead of
        Node for m_currentNode.

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (86920 => 86921)


--- trunk/Source/WebCore/ChangeLog	2011-05-20 02:01:05 UTC (rev 86920)
+++ trunk/Source/WebCore/ChangeLog	2011-05-20 02:39:21 UTC (rev 86921)
@@ -1,3 +1,47 @@
+2011-05-19  Julien Chaffraix  <[email protected]>
+
+        Reviewed by Adam Barth.
+
+        Remove Node::deprecatedParserAddChild
+        https://bugs.webkit.org/show_bug.cgi?id=60818
+
+        Refactoring only so no new tests.
+
+        This patch fails short of one instance of deprecatedParserAddChild which will
+        require a refactoring of <input> shadow DOM to be removed.
+
+        * dom/XMLDocumentParser.cpp:
+        (WebCore::XMLDocumentParser::pushCurrentNode): Updated to use a ContainerNode.
+        (WebCore::XMLDocumentParser::clearCurrentNodeStack): We now need to clear
+        up m_leafTextNode too.
+
+        (WebCore::XMLDocumentParser::enterText):
+        (WebCore::XMLDocumentParser::exitText):
+        Those methods were updated to use m_leafTextNode instead of m_currentNode.
+
+        * dom/XMLDocumentParser.h:
+        Changed the currentNode logic to use ContainerNode. Also fixed the style of the
+        forward declarations.
+
+        * dom/XMLDocumentParserLibxml2.cpp:
+        (WebCore::XMLDocumentParser::startElementNs):
+        (WebCore::XMLDocumentParser::endElementNs):
+        (WebCore::XMLDocumentParser::characters):
+        (WebCore::XMLDocumentParser::processingInstruction):
+        (WebCore::XMLDocumentParser::cdataBlock):
+        (WebCore::XMLDocumentParser::comment):
+        * dom/XMLDocumentParserQt.cpp:
+        (WebCore::XMLDocumentParser::parse):
+        (WebCore::XMLDocumentParser::parseStartElement):
+        (WebCore::XMLDocumentParser::parseEndElement):
+        (WebCore::XMLDocumentParser::parseCharacters):
+        (WebCore::XMLDocumentParser::parseProcessingInstruction):
+        (WebCore::XMLDocumentParser::parseCdata):
+        (WebCore::XMLDocumentParser::parseComment):
+        Removed the calls to deprecatedParserAddChild, changed the code to use
+        m_leafTextNode when it made sense and used ContainerNode instead of
+        Node for m_currentNode.
+
 2011-05-19  Mike Lawther  <[email protected]>
 
         Reviewed by Simon Fraser.

Modified: trunk/Source/WebCore/dom/XMLDocumentParser.cpp (86920 => 86921)


--- trunk/Source/WebCore/dom/XMLDocumentParser.cpp	2011-05-20 02:01:05 UTC (rev 86920)
+++ trunk/Source/WebCore/dom/XMLDocumentParser.cpp	2011-05-20 02:39:21 UTC (rev 86921)
@@ -68,7 +68,7 @@
 
 const int maxErrors = 25;
 
-void XMLDocumentParser::pushCurrentNode(Node* n)
+void XMLDocumentParser::pushCurrentNode(ContainerNode* n)
 {
     ASSERT(n);
     ASSERT(m_currentNode);
@@ -98,6 +98,7 @@
     if (m_currentNode && m_currentNode != document())
         m_currentNode->deref();
     m_currentNode = 0;
+    m_leafTextNode = 0;
 
     if (m_currentNodeStack.size()) { // Aborted parsing.
         for (size_t i = m_currentNodeStack.size() - 1; i != 0; --i)
@@ -167,9 +168,9 @@
 #if !USE(QXMLSTREAM)
     ASSERT(m_bufferedText.size() == 0);
 #endif
-    RefPtr<Node> newNode = Text::create(document(), "");
-    m_currentNode->deprecatedParserAddChild(newNode.get());
-    pushCurrentNode(newNode.get());
+    ASSERT(!m_leafTextNode);
+    m_leafTextNode = Text::create(document(), "");
+    m_currentNode->parserAddChild(m_leafTextNode.get());
 }
 
 #if !USE(QXMLSTREAM)
@@ -185,20 +186,20 @@
     if (isStopped())
         return;
 
-    if (!m_currentNode || !m_currentNode->isTextNode())
+    if (!m_leafTextNode)
         return;
 
 #if !USE(QXMLSTREAM)
     ExceptionCode ec = 0;
-    static_cast<Text*>(m_currentNode)->appendData(toString(m_bufferedText.data(), m_bufferedText.size()), ec);
+    m_leafTextNode->appendData(toString(m_bufferedText.data(), m_bufferedText.size()), ec);
     Vector<xmlChar> empty;
     m_bufferedText.swap(empty);
 #endif
 
-    if (m_view && m_currentNode && !m_currentNode->attached())
-        m_currentNode->attach();
+    if (m_view && !m_leafTextNode->attached())
+        m_leafTextNode->attach();
 
-    popCurrentNode();
+    m_leafTextNode = 0;
 }
 
 void XMLDocumentParser::detach()

Modified: trunk/Source/WebCore/dom/XMLDocumentParser.h (86920 => 86921)


--- trunk/Source/WebCore/dom/XMLDocumentParser.h	2011-05-20 02:01:05 UTC (rev 86920)
+++ trunk/Source/WebCore/dom/XMLDocumentParser.h	2011-05-20 02:39:21 UTC (rev 86921)
@@ -43,14 +43,15 @@
 
 namespace WebCore {
 
-    class Node;
-    class CachedScript;
-    class CachedResourceLoader;
-    class DocumentFragment;
-    class Document;
-    class Element;
-    class FrameView;
-    class PendingCallbacks;
+class ContainerNode;
+class CachedScript;
+class CachedResourceLoader;
+class DocumentFragment;
+class Document;
+class Element;
+class FrameView;
+class PendingCallbacks;
+class Text;
 
 #if !USE(QXMLSTREAM)
     class XMLParserContext : public RefCounted<XMLParserContext> {
@@ -161,7 +162,7 @@
     private:
         void initializeParserContext(const char* chunk = 0);
 
-        void pushCurrentNode(Node*);
+        void pushCurrentNode(ContainerNode*);
         void popCurrentNode();
         void clearCurrentNodeStack();
 
@@ -186,9 +187,11 @@
         OwnPtr<PendingCallbacks> m_pendingCallbacks;
         Vector<xmlChar> m_bufferedText;
 #endif
-        Node* m_currentNode;
-        Vector<Node*> m_currentNodeStack;
+        ContainerNode* m_currentNode;
+        Vector<ContainerNode*> m_currentNodeStack;
 
+        RefPtr<Text> m_leafTextNode;
+
         bool m_sawError;
         bool m_sawCSS;
         bool m_sawXSLTransform;

Modified: trunk/Source/WebCore/dom/XMLDocumentParserLibxml2.cpp (86920 => 86921)


--- trunk/Source/WebCore/dom/XMLDocumentParserLibxml2.cpp	2011-05-20 02:01:05 UTC (rev 86920)
+++ trunk/Source/WebCore/dom/XMLDocumentParserLibxml2.cpp	2011-05-20 02:39:21 UTC (rev 86921)
@@ -823,7 +823,7 @@
     if (scriptElement)
         m_scriptStartPosition = textPositionOneBased();
 
-    m_currentNode->deprecatedParserAddChild(newElement.get());
+    m_currentNode->parserAddChild(newElement.get());
 
     pushCurrentNode(newElement.get());
     if (m_view && !newElement->attached())
@@ -850,7 +850,7 @@
 
     exitText();
 
-    Node* n = m_currentNode;
+    ContainerNode* n = m_currentNode;
     n->finishParsingChildren();
 
     if (m_scriptingPermission == FragmentScriptingNotAllowed && n->isElementNode() && toScriptElement(static_cast<Element*>(n))) {
@@ -929,7 +929,7 @@
         return;
     }
 
-    if (!m_currentNode->isTextNode())
+    if (!m_leafTextNode)
         enterText();
     m_bufferedText.append(s, len);
 }
@@ -979,7 +979,7 @@
 
     pi->setCreatedByParser(true);
 
-    m_currentNode->deprecatedParserAddChild(pi.get());
+    m_currentNode->parserAddChild(pi.get());
     if (m_view && !pi->attached())
         pi->attach();
 
@@ -1006,8 +1006,8 @@
 
     exitText();
 
-    RefPtr<Node> newNode = CDATASection::create(document(), toString(s, len));
-    m_currentNode->deprecatedParserAddChild(newNode.get());
+    RefPtr<CDATASection> newNode = CDATASection::create(document(), toString(s, len));
+    m_currentNode->parserAddChild(newNode.get());
     if (m_view && !newNode->attached())
         newNode->attach();
 }
@@ -1024,8 +1024,8 @@
 
     exitText();
 
-    RefPtr<Node> newNode = Comment::create(document(), toString(s));
-    m_currentNode->deprecatedParserAddChild(newNode.get());
+    RefPtr<Comment> newNode = Comment::create(document(), toString(s));
+    m_currentNode->parserAddChild(newNode.get());
     if (m_view && !newNode->attached())
         newNode->attach();
 }

Modified: trunk/Source/WebCore/dom/XMLDocumentParserQt.cpp (86920 => 86921)


--- trunk/Source/WebCore/dom/XMLDocumentParserQt.cpp	2011-05-20 02:01:05 UTC (rev 86920)
+++ trunk/Source/WebCore/dom/XMLDocumentParserQt.cpp	2011-05-20 02:39:21 UTC (rev 86921)
@@ -425,12 +425,12 @@
                ) {
                 QString entity = m_stream.name().toString();
                 UChar c = decodeNamedEntity(entity.toUtf8().constData());
-                if (!m_currentNode->isTextNode())
+                if (!m_leafTextNode)
                     enterText();
                 ExceptionCode ec = 0;
                 String str(&c, 1);
                 // qDebug()<<" ------- adding entity "<<str;
-                static_cast<Text*>(m_currentNode)->appendData(str, ec);
+                m_leafTextNode->appendData(str, ec);
             }
         }
             break;
@@ -533,7 +533,7 @@
     if (scriptElement)
         m_scriptStartPosition = textPositionOneBased();
 
-    m_currentNode->deprecatedParserAddChild(newElement.get());
+    m_currentNode->parserAddChild(newElement.get());
 
     pushCurrentNode(newElement.get());
     if (m_view && !newElement->attached())
@@ -552,7 +552,7 @@
 {
     exitText();
 
-    Node* n = m_currentNode;
+    ContainerNode* n = m_currentNode;
     n->finishParsingChildren();
 
     if (m_scriptingPermission == FragmentScriptingNotAllowed && n->isElementNode() && toScriptElement(static_cast<Element*>(n))) {
@@ -613,10 +613,10 @@
 
 void XMLDocumentParser::parseCharacters()
 {
-    if (!m_currentNode->isTextNode())
+    if (!m_leafTextNode)
         enterText();
     ExceptionCode ec = 0;
-    static_cast<Text*>(m_currentNode)->appendData(m_stream.text(), ec);
+    m_leafTextNode->appendData(m_stream.text(), ec);
 }
 
 void XMLDocumentParser::parseProcessingInstruction()
@@ -633,7 +633,7 @@
 
     pi->setCreatedByParser(true);
 
-    m_currentNode->deprecatedParserAddChild(pi.get());
+    m_currentNode->parserAddChild(pi.get());
     if (m_view && !pi->attached())
         pi->attach();
 
@@ -652,9 +652,9 @@
 {
     exitText();
 
-    RefPtr<Node> newNode = CDATASection::create(document(), m_stream.text());
+    RefPtr<CDATASection> newNode = CDATASection::create(document(), m_stream.text());
 
-    m_currentNode->deprecatedParserAddChild(newNode.get());
+    m_currentNode->parserAddChild(newNode.get());
     if (m_view && !newNode->attached())
         newNode->attach();
 }
@@ -663,9 +663,9 @@
 {
     exitText();
 
-    RefPtr<Node> newNode = Comment::create(document(), m_stream.text());
+    RefPtr<Comment> newNode = Comment::create(document(), m_stream.text());
 
-    m_currentNode->deprecatedParserAddChild(newNode.get());
+    m_currentNode->parserAddChild(newNode.get());
     if (m_view && !newNode->attached())
         newNode->attach();
 }
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to