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.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; }