Title: [155167] trunk/Source/WebCore
Revision
155167
Author
[email protected]
Date
2013-09-05 18:24:45 -0700 (Thu, 05 Sep 2013)

Log Message

ContainerNode: Apply Ref<T> to some popular DOM functions.
<https://webkit.org/b/120800>

Reviewed by Antti Koivisto.

Use Ref to avoid a bunch of null checks in some popular DOM functions.

* dom/ContainerNode.cpp:
(WebCore::ContainerNode::insertBefore):

    'refChild' is never null here, so store it in a Ref.

(WebCore::ContainerNode::replaceChild):

    'removedChild' is never null here, so store it in a Ref.

(WebCore::ContainerNode::removeChild):

    'child' is never null here, so store it in a Ref.
    Also return "true" at the end of the function since we can't
    null-check 'child' anymore (not that it would ever be false!)

(WebCore::dispatchChildInsertionEvents):
(WebCore::dispatchChildRemovalEvents):

    Use Ref<Document> in both of these methods.

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (155166 => 155167)


--- trunk/Source/WebCore/ChangeLog	2013-09-06 01:08:48 UTC (rev 155166)
+++ trunk/Source/WebCore/ChangeLog	2013-09-06 01:24:45 UTC (rev 155167)
@@ -1,5 +1,34 @@
 2013-09-05  Andreas Kling  <[email protected]>
 
+        ContainerNode: Apply Ref<T> to some popular DOM functions.
+        <https://webkit.org/b/120800>
+
+        Reviewed by Antti Koivisto.
+
+        Use Ref to avoid a bunch of null checks in some popular DOM functions.
+
+        * dom/ContainerNode.cpp:
+        (WebCore::ContainerNode::insertBefore):
+
+            'refChild' is never null here, so store it in a Ref.
+
+        (WebCore::ContainerNode::replaceChild):
+
+            'removedChild' is never null here, so store it in a Ref.
+
+        (WebCore::ContainerNode::removeChild):
+
+            'child' is never null here, so store it in a Ref.
+            Also return "true" at the end of the function since we can't
+            null-check 'child' anymore (not that it would ever be false!)
+
+        (WebCore::dispatchChildInsertionEvents):
+        (WebCore::dispatchChildRemovalEvents):
+
+            Use Ref<Document> in both of these methods.
+
+2013-09-05  Andreas Kling  <[email protected]>
+
         ScrollView::children() should return a reference.
         <https://webkit.org/b/120795>
 

Modified: trunk/Source/WebCore/dom/ContainerNode.cpp (155166 => 155167)


--- trunk/Source/WebCore/dom/ContainerNode.cpp	2013-09-06 01:08:48 UTC (rev 155166)
+++ trunk/Source/WebCore/dom/ContainerNode.cpp	2013-09-06 01:24:45 UTC (rev 155167)
@@ -284,7 +284,7 @@
     if (refChild->previousSibling() == newChild || refChild == newChild) // nothing to do
         return true;
 
-    RefPtr<Node> next = refChild;
+    Ref<Node> next(*refChild);
 
     NodeVector targets;
     collectChildrenAndRemoveFromOldParent(newChild.get(), targets, ec);
@@ -314,7 +314,7 @@
 
         treeScope()->adoptIfNeeded(child);
 
-        insertBeforeCommon(next.get(), child);
+        insertBeforeCommon(&next.get(), child);
 
         updateTreeAfterInsertion(child, attachBehavior);
     }
@@ -431,7 +431,7 @@
     RefPtr<Node> next = oldChild->nextSibling();
 
     // Remove the node we're replacing
-    RefPtr<Node> removedChild = oldChild;
+    Ref<Node> removedChild(*oldChild);
     removeChild(oldChild, ec);
     if (ec)
         return false;
@@ -543,12 +543,12 @@
         return false;
     }
 
-    RefPtr<Node> child = oldChild;
+    Ref<Node> child(*oldChild);
 
-    document().removeFocusedNodeOfSubtree(child.get());
+    document().removeFocusedNodeOfSubtree(&child.get());
 
 #if ENABLE(FULLSCREEN_API)
-    document().removeFullScreenElementOfSubtree(child.get());
+    document().removeFullScreenElementOfSubtree(&child.get());
 #endif
 
     // Events fired when blurring currently focused node might have moved this
@@ -558,7 +558,7 @@
         return false;
     }
 
-    willRemoveChild(child.get());
+    willRemoveChild(&child.get());
 
     // Mutation events might have moved this child into a different parent.
     if (child->parentNode() != this) {
@@ -571,15 +571,15 @@
 
         Node* prev = child->previousSibling();
         Node* next = child->nextSibling();
-        removeBetween(prev, next, child.get());
+        removeBetween(prev, next, &child.get());
 
-        notifyChildRemoved(child.get(), prev, next, ChildChangeSourceAPI);
+        notifyChildRemoved(&child.get(), prev, next, ChildChangeSourceAPI);
 
-        ChildNodeRemovalNotifier(this).notify(child.get());
+        ChildNodeRemovalNotifier(this).notify(&child.get());
     }
     dispatchSubtreeModifiedEvent();
 
-    return child;
+    return true;
 }
 
 void ContainerNode::removeBetween(Node* previousChild, Node* nextChild, Node* oldChild)
@@ -1026,7 +1026,7 @@
     ASSERT(!NoEventDispatchAssertion::isEventDispatchForbidden());
 
     RefPtr<Node> c = child;
-    RefPtr<Document> document = &child->document();
+    Ref<Document> document(child->document());
 
     if (c->parentNode() && document->hasListenerType(Document::DOMNODEINSERTED_LISTENER))
         c->dispatchScopedEvent(MutationEvent::create(eventNames().DOMNodeInsertedEvent, true, c->parentNode()));
@@ -1051,7 +1051,7 @@
     InspectorInstrumentation::willRemoveDOMNode(&child->document(), child);
 
     RefPtr<Node> c = child;
-    RefPtr<Document> document = &child->document();
+    Ref<Document> document(child->document());
 
     // dispatch pre-removal mutation events
     if (c->parentNode() && document->hasListenerType(Document::DOMNODEREMOVED_LISTENER))
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to