Title: [139940] trunk/Source/WebCore
Revision
139940
Author
[email protected]
Date
2013-01-16 17:32:09 -0800 (Wed, 16 Jan 2013)

Log Message

Merge RenderObjectChildList::appendChildNode and insertChildNode
https://bugs.webkit.org/show_bug.cgi?id=106392

Reviewed by Eric Seidel.

insertChildNode and appendChildNode are nearly identical methods and
we can combine them into insertChildNode and handle cases where the
renderer to insert before is null as if it was an append.

No new tests, just refactoring.

* rendering/RenderObjectChildList.cpp:
(WebCore::RenderObjectChildList::insertChildNode):
* rendering/RenderObjectChildList.h:
(RenderObjectChildList):
(WebCore::RenderObjectChildList::appendChildNode):
    Now inline and delegates to insertChildNode.

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (139939 => 139940)


--- trunk/Source/WebCore/ChangeLog	2013-01-17 01:21:20 UTC (rev 139939)
+++ trunk/Source/WebCore/ChangeLog	2013-01-17 01:32:09 UTC (rev 139940)
@@ -1,5 +1,25 @@
 2013-01-16  Elliott Sprehn  <[email protected]>
 
+        Merge RenderObjectChildList::appendChildNode and insertChildNode
+        https://bugs.webkit.org/show_bug.cgi?id=106392
+
+        Reviewed by Eric Seidel.
+
+        insertChildNode and appendChildNode are nearly identical methods and
+        we can combine them into insertChildNode and handle cases where the
+        renderer to insert before is null as if it was an append.
+
+        No new tests, just refactoring.
+
+        * rendering/RenderObjectChildList.cpp:
+        (WebCore::RenderObjectChildList::insertChildNode):
+        * rendering/RenderObjectChildList.h:
+        (RenderObjectChildList):
+        (WebCore::RenderObjectChildList::appendChildNode):
+            Now inline and delegates to insertChildNode.
+
+2013-01-16  Elliott Sprehn  <[email protected]>
+
         Cursor stops blinking after clicking on scrollbar
         https://bugs.webkit.org/show_bug.cgi?id=106470
 

Modified: trunk/Source/WebCore/rendering/RenderObjectChildList.cpp (139939 => 139940)


--- trunk/Source/WebCore/rendering/RenderObjectChildList.cpp	2013-01-17 01:21:20 UTC (rev 139939)
+++ trunk/Source/WebCore/rendering/RenderObjectChildList.cpp	2013-01-17 01:32:09 UTC (rev 139940)
@@ -28,13 +28,8 @@
 #include "RenderObjectChildList.h"
 
 #include "AXObjectCache.h"
-#include "ContentData.h"
-#include "RenderBlock.h"
 #include "RenderCounter.h"
-#include "RenderLayer.h"
-#include "RenderListItem.h"
-#include "RenderNamedFlowThread.h"
-#include "RenderRegion.h"
+#include "RenderObject.h"
 #include "RenderStyle.h"
 #include "RenderView.h"
 
@@ -105,9 +100,8 @@
 
     // rendererRemovedFromTree walks the whole subtree. We can improve performance
     // by skipping this step when destroying the entire tree.
-    if (!owner->documentBeingDestroyed()) {
+    if (!owner->documentBeingDestroyed())
         RenderCounter::rendererRemovedFromTree(oldChild);
-    }
 
     if (AXObjectCache::accessibilityEnabled())
         owner->document()->axObjectCache()->childrenChanged(owner);
@@ -115,79 +109,52 @@
     return oldChild;
 }
 
-void RenderObjectChildList::appendChildNode(RenderObject* owner, RenderObject* newChild, bool notifyRenderer)
+void RenderObjectChildList::insertChildNode(RenderObject* owner, RenderObject* newChild, RenderObject* beforeChild, bool notifyRenderer)
 {
-    ASSERT(newChild->parent() == 0);
+    ASSERT(!newChild->parent());
     ASSERT(!owner->isBlockFlow() || (!newChild->isTableSection() && !newChild->isTableRow() && !newChild->isTableCell()));
 
-    newChild->setParent(owner);
-    RenderObject* lChild = lastChild();
-
-    if (lChild) {
-        newChild->setPreviousSibling(lChild);
-        lChild->setNextSibling(newChild);
-    } else
-        setFirstChild(newChild);
-
-    setLastChild(newChild);
-    
-    if (!owner->documentBeingDestroyed() && notifyRenderer)
-        newChild->insertedIntoTree();
-
-    if (!owner->documentBeingDestroyed()) {
-        RenderCounter::rendererSubtreeAttached(newChild);
-    }
-    newChild->setNeedsLayoutAndPrefWidthsRecalc(); // Goes up the containing block hierarchy.
-    if (!owner->normalChildNeedsLayout())
-        owner->setChildNeedsLayout(true); // We may supply the static position for an absolute positioned child.
-    
-    if (AXObjectCache::accessibilityEnabled())
-        owner->document()->axObjectCache()->childrenChanged(owner);
-}
-
-void RenderObjectChildList::insertChildNode(RenderObject* owner, RenderObject* child, RenderObject* beforeChild, bool notifyRenderer)
-{
-    if (!beforeChild) {
-        appendChildNode(owner, child, notifyRenderer);
-        return;
-    }
-
-    ASSERT(!child->parent());
-    while (beforeChild->parent() && beforeChild->parent() != owner)
+    while (beforeChild && beforeChild->parent() && beforeChild->parent() != owner)
         beforeChild = beforeChild->parent();
 
     // This should never happen, but if it does prevent render tree corruption
     // where child->parent() ends up being owner but child->nextSibling()->parent()
     // is not owner.
-    if (beforeChild->parent() != owner) {
+    if (beforeChild && beforeChild->parent() != owner) {
         ASSERT_NOT_REACHED();
         return;
     }
 
-    ASSERT(!owner->isBlockFlow() || (!child->isTableSection() && !child->isTableRow() && !child->isTableCell()));
+    newChild->setParent(owner);
 
-    if (beforeChild == firstChild())
-        setFirstChild(child);
+    if (firstChild() == beforeChild)
+        setFirstChild(newChild);
 
-    RenderObject* prev = beforeChild->previousSibling();
-    child->setNextSibling(beforeChild);
-    beforeChild->setPreviousSibling(child);
-    if (prev)
-        prev->setNextSibling(child);
-    child->setPreviousSibling(prev);
+    if (beforeChild) {
+        RenderObject* previousSibling = beforeChild->previousSibling();
+        if (previousSibling)
+            previousSibling->setNextSibling(newChild);
+        newChild->setPreviousSibling(previousSibling);
+        newChild->setNextSibling(beforeChild);
+        beforeChild->setPreviousSibling(newChild);
+    } else {
+        if (lastChild())
+            lastChild()->setNextSibling(newChild);
+        newChild->setPreviousSibling(lastChild());
+        setLastChild(newChild);
+    }
 
-    child->setParent(owner);
-    
     if (!owner->documentBeingDestroyed() && notifyRenderer)
-        child->insertedIntoTree();
+        newChild->insertedIntoTree();
 
     if (!owner->documentBeingDestroyed()) {
-        RenderCounter::rendererSubtreeAttached(child);
+        RenderCounter::rendererSubtreeAttached(newChild);
     }
-    child->setNeedsLayoutAndPrefWidthsRecalc();
+
+    newChild->setNeedsLayoutAndPrefWidthsRecalc();
     if (!owner->normalChildNeedsLayout())
         owner->setChildNeedsLayout(true); // We may supply the static position for an absolute positioned child.
-    
+
     if (AXObjectCache::accessibilityEnabled())
         owner->document()->axObjectCache()->childrenChanged(owner);
 }

Modified: trunk/Source/WebCore/rendering/RenderObjectChildList.h (139939 => 139940)


--- trunk/Source/WebCore/rendering/RenderObjectChildList.h	2013-01-17 01:21:20 UTC (rev 139939)
+++ trunk/Source/WebCore/rendering/RenderObjectChildList.h	2013-01-17 01:32:09 UTC (rev 139940)
@@ -31,7 +31,6 @@
 namespace WebCore {
 
 class RenderObject;
-class RenderStyle;
 
 class RenderObjectChildList {
 public:
@@ -43,17 +42,20 @@
 
     RenderObject* firstChild() const { return m_firstChild; }
     RenderObject* lastChild() const { return m_lastChild; }
-    
+
     // FIXME: Temporary while RenderBox still exists. Eventually this will just happen during insert/append/remove methods on the child list, and nobody
     // will need to manipulate firstChild or lastChild directly.
     void setFirstChild(RenderObject* child) { m_firstChild = child; }
     void setLastChild(RenderObject* child) { m_lastChild = child; }
-    
+
     void destroyLeftoverChildren();
 
     RenderObject* removeChildNode(RenderObject* owner, RenderObject*, bool notifyRenderer = true);
-    void appendChildNode(RenderObject* owner, RenderObject*, bool notifyRenderer = true);
-    void insertChildNode(RenderObject* owner, RenderObject* child, RenderObject* before, bool notifyRenderer = true);
+    void insertChildNode(RenderObject* owner, RenderObject* newChild, RenderObject* beforeChild, bool notifyRenderer = true);
+    void appendChildNode(RenderObject* owner, RenderObject* newChild, bool notifyRenderer = true)
+    {
+        insertChildNode(owner, newChild, 0, notifyRenderer);
+    }
 
 private:
     RenderObject* m_firstChild;
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to