Title: [102081] trunk/Source/WebCore
Revision
102081
Author
[email protected]
Date
2011-12-05 18:04:16 -0800 (Mon, 05 Dec 2011)

Log Message

Some small improvements to ContainerNode.h
https://bugs.webkit.org/show_bug.cgi?id=73786

Reviewed by Alexey Proskuryakov.

* dom/ContainerNode.cpp:
(WebCore::ContainerNode::suspendPostAttachCallbacks): Added a FIXME comment about the
peculiar behavior of this function. Somehow the post-attach suspend state is both
global and specific to a certain Page object. That can't be right. If it was truly
global then this would be a static member function. If it was truly per-page, then
the related functions could not be static.

* dom/ContainerNode.h: Removed some unneeded argument names. Moved the hasChildNodes
function up with the other basic getters. Put the other getters, childNodeCount and
childNode, right after the basic getters. Used ASSERT_NO_EXCEPTION in all the basic
mutation functions so they can be used in a cleaner fashion in C++ code where we have
some reason to know an exception won't occur. Grouped all the overrides of functions
from Node into a single paragraph and used the OVERRIDE macro on all of them. Made the
queuePostAttachCallback and postAttachCallbacksAreSuspended functions protected.

* dom/Element.h: Moved the include of ExceptionCodePlaceholder.h into ContainerNode.h.

* dom/Node.cpp:
(WebCore::Node::lazyAttach): Use hasChildNodes instead of firstChild for clarity.
(WebCore::Node::isDescendantOf): Ditto.

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (102080 => 102081)


--- trunk/Source/WebCore/ChangeLog	2011-12-06 01:51:27 UTC (rev 102080)
+++ trunk/Source/WebCore/ChangeLog	2011-12-06 02:04:16 UTC (rev 102081)
@@ -1,3 +1,31 @@
+2011-12-05  Darin Adler  <[email protected]>
+
+        Some small improvements to ContainerNode.h
+        https://bugs.webkit.org/show_bug.cgi?id=73786
+
+        Reviewed by Alexey Proskuryakov.
+
+        * dom/ContainerNode.cpp:
+        (WebCore::ContainerNode::suspendPostAttachCallbacks): Added a FIXME comment about the
+        peculiar behavior of this function. Somehow the post-attach suspend state is both
+        global and specific to a certain Page object. That can't be right. If it was truly
+        global then this would be a static member function. If it was truly per-page, then
+        the related functions could not be static.
+
+        * dom/ContainerNode.h: Removed some unneeded argument names. Moved the hasChildNodes
+        function up with the other basic getters. Put the other getters, childNodeCount and
+        childNode, right after the basic getters. Used ASSERT_NO_EXCEPTION in all the basic
+        mutation functions so they can be used in a cleaner fashion in C++ code where we have
+        some reason to know an exception won't occur. Grouped all the overrides of functions
+        from Node into a single paragraph and used the OVERRIDE macro on all of them. Made the
+        queuePostAttachCallback and postAttachCallbacksAreSuspended functions protected.
+
+        * dom/Element.h: Moved the include of ExceptionCodePlaceholder.h into ContainerNode.h.
+
+        * dom/Node.cpp:
+        (WebCore::Node::lazyAttach): Use hasChildNodes instead of firstChild for clarity.
+        (WebCore::Node::isDescendantOf): Ditto.
+
 2011-12-05  Benjamin Poulain  <[email protected]>
 
         Get rid of KURL::KURL(ParsedURLStringTag, const char*);

Modified: trunk/Source/WebCore/dom/ContainerNode.cpp (102080 => 102081)


--- trunk/Source/WebCore/dom/ContainerNode.cpp	2011-12-06 01:51:27 UTC (rev 102080)
+++ trunk/Source/WebCore/dom/ContainerNode.cpp	2011-12-06 02:04:16 UTC (rev 102081)
@@ -713,6 +713,8 @@
     if (!s_attachDepth) {
         ASSERT(!s_shouldReEnableMemoryCacheCallsAfterAttach);
         if (Page* page = document()->page()) {
+            // FIXME: How can this call be specific to one Page, while the
+            // s_attachDepth is a global? Doesn't make sense.
             if (page->areMemoryCacheClientCallsEnabled()) {
                 page->setMemoryCacheClientCallsEnabled(false);
                 s_shouldReEnableMemoryCacheCallsAfterAttach = true;

Modified: trunk/Source/WebCore/dom/ContainerNode.h (102080 => 102081)


--- trunk/Source/WebCore/dom/ContainerNode.h	2011-12-06 01:51:27 UTC (rev 102080)
+++ trunk/Source/WebCore/dom/ContainerNode.h	2011-12-06 02:04:16 UTC (rev 102081)
@@ -2,7 +2,7 @@
  * Copyright (C) 1999 Lars Knoll ([email protected])
  *           (C) 1999 Antti Koivisto ([email protected])
  *           (C) 2001 Dirk Mueller ([email protected])
- * Copyright (C) 2004, 2005, 2006, 2007, 2009, 2010 Apple Inc. All rights reserved.
+ * Copyright (C) 2004, 2005, 2006, 2007, 2009, 2010, 2011 Apple Inc. All rights reserved.
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Library General Public
@@ -24,6 +24,7 @@
 #ifndef ContainerNode_h
 #define ContainerNode_h
 
+#include "ExceptionCodePlaceholder.h"
 #include "Node.h"
 
 namespace WebCore {
@@ -34,7 +35,7 @@
 
 namespace Private { 
     template<class GenericNode, class GenericNodeContainer>
-    void addChildNodesToDeletionQueue(GenericNode*& head, GenericNode*& tail, GenericNodeContainer* container);
+    void addChildNodesToDeletionQueue(GenericNode*& head, GenericNode*& tail, GenericNodeContainer*);
 };
 
 class ContainerNode : public Node {
@@ -43,12 +44,16 @@
 
     Node* firstChild() const { return m_firstChild; }
     Node* lastChild() const { return m_lastChild; }
+    bool hasChildNodes() const { return m_firstChild; }
 
-    bool insertBefore(PassRefPtr<Node> newChild, Node* refChild, ExceptionCode&, bool shouldLazyAttach = false);
-    bool replaceChild(PassRefPtr<Node> newChild, Node* oldChild, ExceptionCode&, bool shouldLazyAttach = false);
-    bool removeChild(Node* child, ExceptionCode&);
-    bool appendChild(PassRefPtr<Node> newChild, ExceptionCode&, bool shouldLazyAttach = false);
+    unsigned childNodeCount() const;
+    Node* childNode(unsigned index) const;
 
+    bool insertBefore(PassRefPtr<Node> newChild, Node* refChild, ExceptionCode& = ASSERT_NO_EXCEPTION, bool shouldLazyAttach = false);
+    bool replaceChild(PassRefPtr<Node> newChild, Node* oldChild, ExceptionCode& = ASSERT_NO_EXCEPTION, bool shouldLazyAttach = false);
+    bool removeChild(Node* child, ExceptionCode& = ASSERT_NO_EXCEPTION);
+    bool appendChild(PassRefPtr<Node> newChild, ExceptionCode& = ASSERT_NO_EXCEPTION, bool shouldLazyAttach = false);
+
     // These methods are only used during parsing.
     // They don't send DOM mutation events or handle reparenting.
     // However, arbitrary code may be run by beforeload handlers.
@@ -56,49 +61,44 @@
     void parserRemoveChild(Node*);
     void parserInsertBefore(PassRefPtr<Node> newChild, Node* refChild);
 
-    bool hasChildNodes() const { return m_firstChild; }
-    virtual void attach();
-    virtual void detach();
-    virtual void willRemove();
-    virtual LayoutRect getRect() const;
-    virtual void setFocus(bool = true);
-    virtual void setActive(bool active = true, bool pause = false);
-    virtual void setHovered(bool = true);
-    unsigned childNodeCount() const;
-    Node* childNode(unsigned index) const;
-
-    virtual void insertedIntoDocument();
-    virtual void removedFromDocument();
-    virtual void insertedIntoTree(bool deep);
-    virtual void removedFromTree(bool deep);
-    virtual void childrenChanged(bool createdByParser = false, Node* beforeChange = 0, Node* afterChange = 0, int childCountDelta = 0);
-
     // FIXME: It's not good to have two functions with such similar names, especially public functions.
     // How do removeChildren and removeAllChildren differ?
     void removeChildren();
     void removeAllChildren();
+
     void takeAllChildrenFrom(ContainerNode*);
 
     void cloneChildNodes(ContainerNode* clone);
     
     bool dispatchBeforeLoadEvent(const String& sourceURL);
+    
+    virtual void attach() OVERRIDE;
+    virtual void detach() OVERRIDE;
+    virtual void willRemove() OVERRIDE;
+    virtual LayoutRect getRect() const OVERRIDE;
+    virtual void setFocus(bool = true) OVERRIDE;
+    virtual void setActive(bool active = true, bool pause = false) OVERRIDE;
+    virtual void setHovered(bool = true) OVERRIDE;
+    virtual void insertedIntoDocument() OVERRIDE;
+    virtual void removedFromDocument() OVERRIDE;
+    virtual void insertedIntoTree(bool deep) OVERRIDE;
+    virtual void removedFromTree(bool deep) OVERRIDE;
+    virtual void childrenChanged(bool createdByParser = false, Node* beforeChange = 0, Node* afterChange = 0, int childCountDelta = 0) OVERRIDE;
+    virtual void scheduleSetNeedsStyleRecalc(StyleChangeType = FullStyleChange) OVERRIDE;
 
-    virtual void scheduleSetNeedsStyleRecalc(StyleChangeType = FullStyleChange);
+protected:
+    ContainerNode(Document*, ConstructionType = CreateContainer);
 
     static void queuePostAttachCallback(NodeCallback, Node*, unsigned = 0);
     static bool postAttachCallbacksAreSuspended();
-    
-protected:
-    ContainerNode(Document*, ConstructionType = CreateContainer);
-
     void suspendPostAttachCallbacks();
     void resumePostAttachCallbacks();
 
     template<class GenericNode, class GenericNodeContainer>
-    friend void appendChildToContainer(GenericNode* child, GenericNodeContainer* container);
+    friend void appendChildToContainer(GenericNode* child, GenericNodeContainer*);
 
     template<class GenericNode, class GenericNodeContainer>
-    friend void Private::addChildNodesToDeletionQueue(GenericNode*& head, GenericNode*& tail, GenericNodeContainer* container);
+    friend void Private::addChildNodesToDeletionQueue(GenericNode*& head, GenericNode*& tail, GenericNodeContainer*);
 
     void setFirstChild(Node* child) { m_firstChild = child; }
     void setLastChild(Node* child) { m_lastChild = child; }

Modified: trunk/Source/WebCore/dom/Element.h (102080 => 102081)


--- trunk/Source/WebCore/dom/Element.h	2011-12-06 01:51:27 UTC (rev 102080)
+++ trunk/Source/WebCore/dom/Element.h	2011-12-06 02:04:16 UTC (rev 102081)
@@ -26,7 +26,6 @@
 #define Element_h
 
 #include "Document.h"
-#include "ExceptionCodePlaceholder.h"
 #include "FragmentScriptingPermission.h"
 #include "NamedNodeMap.h"
 #include "ScrollTypes.h"

Modified: trunk/Source/WebCore/dom/Node.cpp (102080 => 102081)


--- trunk/Source/WebCore/dom/Node.cpp	2011-12-06 01:51:27 UTC (rev 102080)
+++ trunk/Source/WebCore/dom/Node.cpp	2011-12-06 02:04:16 UTC (rev 102081)
@@ -931,7 +931,7 @@
 void Node::lazyAttach(ShouldSetAttached shouldSetAttached)
 {
     for (Node* n = this; n; n = n->traverseNextNode(this)) {
-        if (n->firstChild())
+        if (n->hasChildNodes())
             n->setChildNeedsStyleRecalc();
         n->setStyleChange(FullStyleChange);
         if (shouldSetAttached == SetAttached)
@@ -1348,7 +1348,7 @@
 bool Node::isDescendantOf(const Node *other) const
 {
     // Return true if other is an ancestor of this, otherwise false
-    if (!other || !other->firstChild() || inDocument() != other->inDocument())
+    if (!other || !other->hasChildNodes() || inDocument() != other->inDocument())
         return false;
     if (other == other->document())
         return document() == other && this != document() && inDocument();
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to