]> git.saurik.com Git - iphone-api.git/blame - WebCore/ContainerNode.h
Add support for new WinterBoard Settings features.
[iphone-api.git] / WebCore / ContainerNode.h
CommitLineData
a90939db
JF
1/*
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.
6 *
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.
11 *
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.
16 *
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.
21 *
22 */
23
24#ifndef ContainerNode_h
25#define ContainerNode_h
26
27#include "EventTargetNode.h"
28#include "FloatPoint.h"
29
30namespace WebCore {
31
32typedef void (*NodeCallback)(Node*);
33
34namespace Private {
35 template<class GenericNode, class GenericNodeContainer>
36 void addChildNodesToDeletionQueue(GenericNode*& head, GenericNode*& tail, GenericNodeContainer* container);
37};
38
39class ContainerNode : public EventTargetNode {
40public:
41 ContainerNode(Document*, bool isElement = false);
42 virtual ~ContainerNode();
43
44 Node* firstChild() const { return m_firstChild; }
45 Node* lastChild() const { return m_lastChild; }
46
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);
51
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;
63
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);
69
70 virtual bool removeChildren();
71
72 void removeAllChildren();
73
74 void cloneChildNodes(ContainerNode* clone);
75
76protected:
77 static void queuePostAttachCallback(NodeCallback, Node*);
78 void suspendPostAttachCallbacks();
79 void resumePostAttachCallbacks();
80
81 template<class GenericNode, class GenericNodeContainer>
82 friend void appendChildToContainer(GenericNode* child, GenericNodeContainer* container);
83
84 template<class GenericNode, class GenericNodeContainer>
85 friend void Private::addChildNodesToDeletionQueue(GenericNode*& head, GenericNode*& tail, GenericNodeContainer* container);
86
87 void setFirstChild(Node* child) { m_firstChild = child; }
88 void setLastChild(Node* child) { m_lastChild = child; }
89
90private:
91 static void dispatchPostAttachCallbacks();
92
93 bool getUpperLeftCorner(FloatPoint&) const;
94 bool getLowerRightCorner(FloatPoint&) const;
95
96 Node* m_firstChild;
97 Node* m_lastChild;
98};
99
100inline unsigned Node::containerChildNodeCount() const
101{
102 ASSERT(isContainerNode());
103 return static_cast<const ContainerNode*>(this)->childNodeCount();
104}
105
106inline Node* Node::containerChildNode(unsigned index) const
107{
108 ASSERT(isContainerNode());
109 return static_cast<const ContainerNode*>(this)->childNode(index);
110}
111
112inline Node* Node::containerFirstChild() const
113{
114 ASSERT(isContainerNode());
115 return static_cast<const ContainerNode*>(this)->firstChild();
116}
117
118inline Node* Node::containerLastChild() const
119{
120 ASSERT(isContainerNode());
121 return static_cast<const ContainerNode*>(this)->lastChild();
122}
123
124} // namespace WebCore
125
126#endif // ContainerNode_h