OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) | 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) |
3 * (C) 1999 Antti Koivisto (koivisto@kde.org) | 3 * (C) 1999 Antti Koivisto (koivisto@kde.org) |
4 * (C) 2001 Dirk Mueller (mueller@kde.org) | 4 * (C) 2001 Dirk Mueller (mueller@kde.org) |
5 * Copyright (C) 2004, 2005, 2006, 2007, 2009, 2010, 2011, 2013 Apple Inc. All r
ights reserved. | 5 * Copyright (C) 2004, 2005, 2006, 2007, 2009, 2010, 2011, 2013 Apple Inc. All r
ights reserved. |
6 * | 6 * |
7 * This library is free software; you can redistribute it and/or | 7 * This library is free software; you can redistribute it and/or |
8 * modify it under the terms of the GNU Library General Public | 8 * modify it under the terms of the GNU Library General Public |
9 * License as published by the Free Software Foundation; either | 9 * License as published by the Free Software Foundation; either |
10 * version 2 of the License, or (at your option) any later version. | 10 * version 2 of the License, or (at your option) any later version. |
(...skipping 25 matching lines...) Expand all Loading... |
36 template <typename NodeType> class StaticNodeTypeList; | 36 template <typename NodeType> class StaticNodeTypeList; |
37 typedef StaticNodeTypeList<Element> StaticElementList; | 37 typedef StaticNodeTypeList<Element> StaticElementList; |
38 | 38 |
39 // This constant controls how much buffer is initially allocated | 39 // This constant controls how much buffer is initially allocated |
40 // for a Node Vector that is used to store child Nodes of a given Node. | 40 // for a Node Vector that is used to store child Nodes of a given Node. |
41 // FIXME: Optimize the value. | 41 // FIXME: Optimize the value. |
42 const int initialNodeVectorSize = 11; | 42 const int initialNodeVectorSize = 11; |
43 typedef Vector<RefPtr<Node>, initialNodeVectorSize> NodeVector; | 43 typedef Vector<RefPtr<Node>, initialNodeVectorSize> NodeVector; |
44 | 44 |
45 class ContainerNode : public Node { | 45 class ContainerNode : public Node { |
| 46 DEFINE_WRAPPERTYPEINFO(); |
46 public: | 47 public: |
47 virtual ~ContainerNode(); | 48 virtual ~ContainerNode(); |
48 | 49 |
49 Node* firstChild() const { return m_firstChild; } | 50 Node* firstChild() const { return m_firstChild; } |
50 Node* lastChild() const { return m_lastChild; } | 51 Node* lastChild() const { return m_lastChild; } |
51 bool hasChildren() const { return m_firstChild; } | 52 bool hasChildren() const { return m_firstChild; } |
52 | 53 |
| 54 Element* firstElementChild() const; |
| 55 Element* lastElementChild() const; |
| 56 |
| 57 Vector<RefPtr<Node>> getChildNodes() const; |
| 58 Vector<RefPtr<Element>> getChildElements() const; |
| 59 |
| 60 // These functions release the nodes from |nodes|. |
| 61 void append(Vector<RefPtr<Node>>& nodes, ExceptionState&); |
| 62 void prepend(Vector<RefPtr<Node>>& nodes, ExceptionState&); |
| 63 PassRefPtr<Node> prependChild(PassRefPtr<Node> node, ExceptionState&); |
| 64 |
| 65 void removeChildren(); |
| 66 PassRefPtr<Node> setChild(PassRefPtr<Node> node, ExceptionState&); |
| 67 void setChildren(Vector<RefPtr<Node>>& nodes, ExceptionState&); |
| 68 |
53 bool hasOneChild() const { return m_firstChild && !m_firstChild->nextSibling
(); } | 69 bool hasOneChild() const { return m_firstChild && !m_firstChild->nextSibling
(); } |
54 bool hasOneTextChild() const { return hasOneChild() && m_firstChild->isTextN
ode(); } | 70 bool hasOneTextChild() const { return hasOneChild() && m_firstChild->isTextN
ode(); } |
55 | 71 |
56 unsigned countChildren() const; | 72 unsigned countChildren() const; |
57 | 73 |
58 PassRefPtr<Element> querySelector(const AtomicString& selectors, ExceptionSt
ate&); | 74 PassRefPtr<Element> querySelector(const AtomicString& selectors, ExceptionSt
ate&); |
59 PassRefPtr<StaticElementList> querySelectorAll(const AtomicString& selectors
, ExceptionState&); | 75 PassRefPtr<StaticElementList> querySelectorAll(const AtomicString& selectors
, ExceptionState&); |
60 | 76 |
61 PassRefPtr<Node> insertBefore(PassRefPtr<Node> newChild, Node* refChild, Exc
eptionState& = ASSERT_NO_EXCEPTION); | 77 PassRefPtr<Node> insertBefore(PassRefPtr<Node> newChild, Node* refChild, Exc
eptionState& = ASSERT_NO_EXCEPTION); |
62 PassRefPtr<Node> replaceChild(PassRefPtr<Node> newChild, PassRefPtr<Node> ol
dChild, ExceptionState& = ASSERT_NO_EXCEPTION); | 78 PassRefPtr<Node> replaceChild(PassRefPtr<Node> newChild, PassRefPtr<Node> ol
dChild, ExceptionState& = ASSERT_NO_EXCEPTION); |
63 PassRefPtr<Node> removeChild(PassRefPtr<Node> child, ExceptionState& = ASSER
T_NO_EXCEPTION); | 79 PassRefPtr<Node> removeChild(PassRefPtr<Node> child, ExceptionState& = ASSER
T_NO_EXCEPTION); |
64 PassRefPtr<Node> appendChild(PassRefPtr<Node> newChild, ExceptionState& = AS
SERT_NO_EXCEPTION); | 80 PassRefPtr<Node> appendChild(PassRefPtr<Node> newChild, ExceptionState& = AS
SERT_NO_EXCEPTION); |
65 | 81 |
66 Element* getElementById(const AtomicString& id) const; | 82 Element* getElementById(const AtomicString& id) const; |
67 | 83 |
68 // These methods are only used during parsing. | 84 // These methods are only used during parsing. |
69 // They don't send DOM mutation events or handle reparenting. | 85 // They don't send DOM mutation events or handle reparenting. |
70 void parserAppendChild(PassRefPtr<Node>); | 86 void parserAppendChild(PassRefPtr<Node>); |
71 | 87 |
72 void removeChildren(); | |
73 | 88 |
74 void cloneChildNodes(ContainerNode* clone); | 89 void cloneChildNodes(ContainerNode* clone); |
75 | 90 |
76 virtual void attach(const AttachContext& = AttachContext()) override; | 91 virtual void attach(const AttachContext& = AttachContext()) override; |
77 virtual void detach(const AttachContext& = AttachContext()) override; | 92 virtual void detach(const AttachContext& = AttachContext()) override; |
78 virtual LayoutRect boundingBox() const override final; | 93 virtual LayoutRect boundingBox() const override final; |
79 virtual void setFocus(bool) override; | 94 virtual void setFocus(bool) override; |
80 void focusStateChanged(); | 95 void focusStateChanged(); |
81 virtual void setActive(bool = true) override; | 96 virtual void setActive(bool = true) override; |
82 virtual void setHovered(bool = true) override; | 97 virtual void setHovered(bool = true) override; |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
209 if (!isContainerNode()) | 224 if (!isContainerNode()) |
210 return 0; | 225 return 0; |
211 return toContainerNode(this)->lastChild(); | 226 return toContainerNode(this)->lastChild(); |
212 } | 227 } |
213 | 228 |
214 inline bool Node::isTreeScope() const | 229 inline bool Node::isTreeScope() const |
215 { | 230 { |
216 return &treeScope().rootNode() == this; | 231 return &treeScope().rootNode() == this; |
217 } | 232 } |
218 | 233 |
219 inline void getChildNodes(ContainerNode& node, NodeVector& nodes) | 234 inline void appendChildNodes(ContainerNode& node, NodeVector& nodes) |
220 { | 235 { |
221 ASSERT(!nodes.size()); | 236 ASSERT(!nodes.size()); |
222 for (Node* child = node.firstChild(); child; child = child->nextSibling()) | 237 for (Node* child = node.firstChild(); child; child = child->nextSibling()) |
223 nodes.append(child); | 238 nodes.append(child); |
224 } | 239 } |
225 | 240 |
226 } // namespace blink | 241 } // namespace blink |
227 | 242 |
228 #endif // SKY_ENGINE_CORE_DOM_CONTAINERNODE_H_ | 243 #endif // SKY_ENGINE_CORE_DOM_CONTAINERNODE_H_ |
OLD | NEW |