]>
git.saurik.com Git - iphone-api.git/blob - WebCore/ContainerNode.h
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
3 * (C) 1999 Antti Koivisto (koivisto@kde.org)
4 * (C) 2001 Dirk Mueller (mueller@kde.org)
5 * Copyright (C) 2004, 2005, 2006, 2007 Apple Inc. All rights reserved.
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Library General Public
9 * License as published by the Free Software Foundation; either
10 * version 2 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Library General Public License for more details.
17 * You should have received a copy of the GNU Library General Public License
18 * along with this library; see the file COPYING.LIB. If not, write to
19 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
20 * Boston, MA 02110-1301, USA.
24 #ifndef ContainerNode_h
25 #define ContainerNode_h
27 #include "EventTargetNode.h"
28 #include "FloatPoint.h"
32 typedef void (*NodeCallback
)(Node
*);
35 template<class GenericNode
, class GenericNodeContainer
>
36 void addChildNodesToDeletionQueue(GenericNode
*& head
, GenericNode
*& tail
, GenericNodeContainer
* container
);
39 class ContainerNode
: public EventTargetNode
{
41 ContainerNode(Document
*, bool isElement
= false);
42 virtual ~ContainerNode();
44 Node
* firstChild() const { return m_firstChild
; }
45 Node
* lastChild() const { return m_lastChild
; }
47 virtual bool insertBefore(PassRefPtr
<Node
> newChild
, Node
* refChild
, ExceptionCode
&, bool shouldLazyAttach
= false);
48 virtual bool replaceChild(PassRefPtr
<Node
> newChild
, Node
* oldChild
, ExceptionCode
&, bool shouldLazyAttach
= false);
49 virtual bool removeChild(Node
* child
, ExceptionCode
&);
50 virtual bool appendChild(PassRefPtr
<Node
> newChild
, ExceptionCode
&, bool shouldLazyAttach
= false);
52 virtual ContainerNode
* addChild(PassRefPtr
<Node
>);
53 bool hasChildNodes() const { return m_firstChild
; }
54 virtual void attach();
55 virtual void detach();
56 virtual void willRemove();
57 virtual IntRect
getRect() const;
58 virtual void setFocus(bool = true);
59 virtual void setActive(bool active
= true, bool pause
= false);
60 virtual void setHovered(bool = true);
61 unsigned childNodeCount() const;
62 Node
* childNode(unsigned index
) const;
64 virtual void insertedIntoDocument();
65 virtual void removedFromDocument();
66 virtual void insertedIntoTree(bool deep
);
67 virtual void removedFromTree(bool deep
);
68 virtual void childrenChanged(bool createdByParser
= false, Node
* beforeChange
= 0, Node
* afterChange
= 0, int childCountDelta
= 0);
70 virtual bool removeChildren();
72 void removeAllChildren();
74 void cloneChildNodes(ContainerNode
* clone
);
77 static void queuePostAttachCallback(NodeCallback
, Node
*);
78 void suspendPostAttachCallbacks();
79 void resumePostAttachCallbacks();
81 template<class GenericNode
, class GenericNodeContainer
>
82 friend void appendChildToContainer(GenericNode
* child
, GenericNodeContainer
* container
);
84 template<class GenericNode
, class GenericNodeContainer
>
85 friend void Private::addChildNodesToDeletionQueue(GenericNode
*& head
, GenericNode
*& tail
, GenericNodeContainer
* container
);
87 void setFirstChild(Node
* child
) { m_firstChild
= child
; }
88 void setLastChild(Node
* child
) { m_lastChild
= child
; }
91 static void dispatchPostAttachCallbacks();
93 bool getUpperLeftCorner(FloatPoint
&) const;
94 bool getLowerRightCorner(FloatPoint
&) const;
100 inline unsigned Node::containerChildNodeCount() const
102 ASSERT(isContainerNode());
103 return static_cast<const ContainerNode
*>(this)->childNodeCount();
106 inline Node
* Node::containerChildNode(unsigned index
) const
108 ASSERT(isContainerNode());
109 return static_cast<const ContainerNode
*>(this)->childNode(index
);
112 inline Node
* Node::containerFirstChild() const
114 ASSERT(isContainerNode());
115 return static_cast<const ContainerNode
*>(this)->firstChild();
118 inline Node
* Node::containerLastChild() const
120 ASSERT(isContainerNode());
121 return static_cast<const ContainerNode
*>(this)->lastChild();
124 } // namespace WebCore
126 #endif // ContainerNode_h