[SCM] WebKit Debian packaging branch, webkit-1.2, updated. upstream/1.1.90-6072-g9a69373

eric at webkit.org eric at webkit.org
Thu Apr 8 02:09:51 UTC 2010


The following commit has been merged in the webkit-1.2 branch:
commit e251194245108b7f01f03ff9a1cec6c02baa750e
Author: eric at webkit.org <eric at webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Thu Mar 4 18:17:26 2010 +0000

    2010-03-04  Antoine Quint  <ml at graougraou.com>
    
            Reviewed by Darin Adler.
    
            DOM insertion mutation events should dispatch after a node is attached to the render tree
            https://bugs.webkit.org/show_bug.cgi?id=35590
    
            * fast/events/domnodeinsertedintodocument-dispatched-post-rendering-expected.txt: Added.
            * fast/events/domnodeinsertedintodocument-dispatched-post-rendering.html: Added.
    2010-03-04  Antoine Quint  <ml at graougraou.com>
    
            Reviewed by Darin Adler.
    
            DOM insertion mutation events should dispatch after a node is attached to the render tree
            https://bugs.webkit.org/show_bug.cgi?id=35590
    
            Test: fast/events/domnodeinsertedintodocument-dispatched-post-rendering.html
    
            Split off the internal-to-WebCore node insertion notification code from the DOM mutation
            event dispatching, originally in dispatchChildInsertionEvents(), to a new static function
            called notifyChildInserted(). This allows us to dispatch the mutation events at a later
            time upon insertion of a child into to the tree, specifically _after_ attachment to the render
            tree.
    
            * dom/ContainerNode.cpp:
            (WebCore::ContainerNode::insertBefore):
            (WebCore::ContainerNode::replaceChild):
            (WebCore::ContainerNode::appendChild):
            (WebCore::notifyChildInserted):
            (WebCore::dispatchChildInsertionEvents):
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@55532 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog
index cfcd6ed..726e563 100644
--- a/LayoutTests/ChangeLog
+++ b/LayoutTests/ChangeLog
@@ -1,3 +1,13 @@
+2010-03-04  Antoine Quint  <ml at graougraou.com>
+
+        Reviewed by Darin Adler.
+
+        DOM insertion mutation events should dispatch after a node is attached to the render tree
+        https://bugs.webkit.org/show_bug.cgi?id=35590
+
+        * fast/events/domnodeinsertedintodocument-dispatched-post-rendering-expected.txt: Added.
+        * fast/events/domnodeinsertedintodocument-dispatched-post-rendering.html: Added.
+
 2010-03-04  Csaba Osztrogonác  <ossy at webkit.org>
 
         Unreviewed.
diff --git a/LayoutTests/fast/events/domnodeinsertedintodocument-dispatched-post-rendering-expected.txt b/LayoutTests/fast/events/domnodeinsertedintodocument-dispatched-post-rendering-expected.txt
new file mode 100644
index 0000000..44a23c3
--- /dev/null
+++ b/LayoutTests/fast/events/domnodeinsertedintodocument-dispatched-post-rendering-expected.txt
@@ -0,0 +1,5 @@
+PASS
+
+PASS
+
+PASS
diff --git a/LayoutTests/fast/events/domnodeinsertedintodocument-dispatched-post-rendering.html b/LayoutTests/fast/events/domnodeinsertedintodocument-dispatched-post-rendering.html
new file mode 100644
index 0000000..d20602a
--- /dev/null
+++ b/LayoutTests/fast/events/domnodeinsertedintodocument-dispatched-post-rendering.html
@@ -0,0 +1,66 @@
+<!doctype html>
+<html class="a">
+ <head>
+  <title>DOMNodeInsertedIntoDocument: dispatch after appending to the render tree</title>
+  <style type="text/css">
+
+    .appended {
+      width: 100px;
+    }
+
+    .inserted {
+      width: 200px;
+    }
+
+    .replaced {
+      width: 300px;
+    }
+
+  </style>
+ </head>
+ <body>
+  <p id="original-message">FAIL (script did not run)</p>
+  <script>
+
+    if (window.layoutTestController)
+      layoutTestController.dumpAsText();
+
+    var body = document.body;
+
+    function log (msg) {
+      var original_message = document.getElementById('original-message');
+      if (original_message) {
+        body.removeChild(original_message);
+      }
+      body.appendChild(document.createElement('p')).textContent = msg;
+    };
+
+    function test (element, expected_width, methodName) {
+      var width = window.getComputedStyle(element, null).width;
+      log((width == expected_width) ? 'PASS' : 'FAIL: got width = "' + width + '" for element added to the tree with ' + methodName + '()');
+    };
+
+    var appended_element = document.createElement('div');
+    appended_element.className = 'appended';
+    appended_element.addEventListener('DOMNodeInsertedIntoDocument', function (event) {
+      test(appended_element, '100px', 'appendChild');
+    }, false);
+    body.appendChild(appended_element);
+
+    var inserted_element = document.createElement('div');
+    inserted_element.className = 'inserted';
+    inserted_element.addEventListener('DOMNodeInsertedIntoDocument', function (event) {
+      test(inserted_element, '200px', 'insertBefore');
+    }, false);
+    body.insertBefore(inserted_element, appended_element);
+
+    var replaced_element = document.createElement('div');
+    replaced_element.className = 'replaced';
+    replaced_element.addEventListener('DOMNodeInsertedIntoDocument', function (event) {
+      test(replaced_element, '300px', 'replaceChild');
+    }, false);
+    body.replaceChild(replaced_element, inserted_element);
+
+  </script>
+ </body>
+</html>
diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index 688be38..2e73338 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,25 @@
+2010-03-04  Antoine Quint  <ml at graougraou.com>
+
+        Reviewed by Darin Adler.
+
+        DOM insertion mutation events should dispatch after a node is attached to the render tree
+        https://bugs.webkit.org/show_bug.cgi?id=35590
+
+        Test: fast/events/domnodeinsertedintodocument-dispatched-post-rendering.html
+
+        Split off the internal-to-WebCore node insertion notification code from the DOM mutation
+        event dispatching, originally in dispatchChildInsertionEvents(), to a new static function
+        called notifyChildInserted(). This allows us to dispatch the mutation events at a later
+        time upon insertion of a child into to the tree, specifically _after_ attachment to the render
+        tree.
+
+        * dom/ContainerNode.cpp:
+        (WebCore::ContainerNode::insertBefore):
+        (WebCore::ContainerNode::replaceChild):
+        (WebCore::ContainerNode::appendChild):
+        (WebCore::notifyChildInserted):
+        (WebCore::dispatchChildInsertionEvents):
+
 2010-03-04  Fridrich Strba  <fridrich.strba at bluewin.ch>
 
         Reviewed by Holger Freyther.
diff --git a/WebCore/dom/ContainerNode.cpp b/WebCore/dom/ContainerNode.cpp
index b86d9b8..145dd0a 100644
--- a/WebCore/dom/ContainerNode.cpp
+++ b/WebCore/dom/ContainerNode.cpp
@@ -43,6 +43,7 @@
 
 namespace WebCore {
 
+static void notifyChildInserted(Node*);
 static void dispatchChildInsertionEvents(Node*);
 static void dispatchChildRemovalEvents(Node*);
 
@@ -144,9 +145,9 @@ bool ContainerNode::insertBefore(PassRefPtr<Node> newChild, Node* refChild, Exce
         child->setNextSibling(next.get());
         allowEventDispatch();
 
-        // Dispatch the mutation events.
+        // Send notification about the children change.
         childrenChanged(false, refChildPreviousSibling.get(), next.get(), 1);
-        dispatchChildInsertionEvents(child.get());
+        notifyChildInserted(child.get());
                 
         // Add child to the rendering tree.
         if (attached() && !child->attached() && child->parent() == this) {
@@ -156,6 +157,10 @@ bool ContainerNode::insertBefore(PassRefPtr<Node> newChild, Node* refChild, Exce
                 child->attach();
         }
 
+        // Now that the child is attached to the render tree, dispatch
+        // the relevant mutation events.
+        dispatchChildInsertionEvents(child.get());
+
         child = nextChild.release();
     }
 
@@ -256,8 +261,7 @@ bool ContainerNode::replaceChild(PassRefPtr<Node> newChild, Node* oldChild, Exce
         child->setNextSibling(next);
         allowEventDispatch();
 
-        // Dispatch the mutation events
-        dispatchChildInsertionEvents(child.get());
+        notifyChildInserted(child.get());
                 
         // Add child to the rendering tree
         if (attached() && !child->attached() && child->parent() == this) {
@@ -267,6 +271,10 @@ bool ContainerNode::replaceChild(PassRefPtr<Node> newChild, Node* oldChild, Exce
                 child->attach();
         }
 
+        // Now that the child is attached to the render tree, dispatch
+        // the relevant mutation events.
+        dispatchChildInsertionEvents(child.get());
+
         prev = child;
         child = nextChild.release();
     }
@@ -490,9 +498,9 @@ bool ContainerNode::appendChild(PassRefPtr<Node> newChild, ExceptionCode& ec, bo
         m_lastChild = child.get();
         allowEventDispatch();
 
-        // Dispatch the mutation events
+        // Send notification about the children change.
         childrenChanged(false, prev.get(), 0, 1);
-        dispatchChildInsertionEvents(child.get());
+        notifyChildInserted(child.get());
 
         // Add child to the rendering tree
         if (attached() && !child->attached() && child->parent() == this) {
@@ -501,6 +509,10 @@ bool ContainerNode::appendChild(PassRefPtr<Node> newChild, ExceptionCode& ec, bo
             else
                 child->attach();
         }
+
+        // Now that the child is attached to the render tree, dispatch
+        // the relevant mutation events.
+        dispatchChildInsertionEvents(child.get());
         
         child = nextChild.release();
     }
@@ -876,7 +888,7 @@ Node *ContainerNode::childNode(unsigned index) const
     return n;
 }
 
-static void dispatchChildInsertionEvents(Node* child)
+static void notifyChildInserted(Node* child)
 {
     ASSERT(!eventDispatchForbidden());
 
@@ -896,6 +908,14 @@ static void dispatchChildInsertionEvents(Node* child)
         c->insertedIntoTree(true);
 
     document->incDOMTreeVersion();
+}
+
+static void dispatchChildInsertionEvents(Node* child)
+{
+    ASSERT(!eventDispatchForbidden());
+
+    RefPtr<Node> c = child;
+    RefPtr<Document> document = child->document();
 
     if (c->parentNode() && document->hasListenerType(Document::DOMNODEINSERTED_LISTENER))
         c->dispatchEvent(MutationEvent::create(eventNames().DOMNodeInsertedEvent, true, c->parentNode()));

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list