Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(914)

Unified Diff: sky/engine/core/dom/ContainerNode.h

Issue 924203002: Morph the APIs for Node, ParentNode, and Element closer to the specs (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: sky/engine/core/dom/ContainerNode.h
diff --git a/sky/engine/core/dom/ContainerNode.h b/sky/engine/core/dom/ContainerNode.h
index 3c947b2e98eb92052ab6f130eaa800a3f3e9120f..bc9108d363699bf723c811c6a172e21449a29595 100644
--- a/sky/engine/core/dom/ContainerNode.h
+++ b/sky/engine/core/dom/ContainerNode.h
@@ -43,6 +43,7 @@ const int initialNodeVectorSize = 11;
typedef Vector<RefPtr<Node>, initialNodeVectorSize> NodeVector;
class ContainerNode : public Node {
+ DEFINE_WRAPPERTYPEINFO();
public:
virtual ~ContainerNode();
@@ -50,6 +51,21 @@ public:
Node* lastChild() const { return m_lastChild; }
bool hasChildren() const { return m_firstChild; }
+ Element* firstElementChild() const;
eseidel 2015/02/14 00:12:23 So now ContainerNode knows about its subclass Elem
+ Element* lastElementChild() const;
+
+ Vector<RefPtr<Node>> getChildNodes() const;
eseidel 2015/02/14 00:12:23 Are you sure you want to copy the vector? :)
+ Vector<RefPtr<Element>> getChildElements() const;
+
+ // These functions release the nodes from |nodes|.
+ void append(Vector<RefPtr<Node>>& nodes, ExceptionState&);
eseidel 2015/02/14 00:12:23 Another way to do this would be to use a PassOwnPt
+ void prepend(Vector<RefPtr<Node>>& nodes, ExceptionState&);
+ PassRefPtr<Node> prependChild(PassRefPtr<Node> node, ExceptionState&);
+
+ void removeChildren();
+ PassRefPtr<Node> setChild(PassRefPtr<Node> node, ExceptionState&);
+ void setChildren(Vector<RefPtr<Node>>& nodes, ExceptionState&);
+
bool hasOneChild() const { return m_firstChild && !m_firstChild->nextSibling(); }
bool hasOneTextChild() const { return hasOneChild() && m_firstChild->isTextNode(); }
@@ -69,7 +85,6 @@ public:
// They don't send DOM mutation events or handle reparenting.
void parserAppendChild(PassRefPtr<Node>);
- void removeChildren();
void cloneChildNodes(ContainerNode* clone);
@@ -216,7 +231,7 @@ inline bool Node::isTreeScope() const
return &treeScope().rootNode() == this;
}
-inline void getChildNodes(ContainerNode& node, NodeVector& nodes)
+inline void appendChildNodes(ContainerNode& node, NodeVector& nodes)
{
ASSERT(!nodes.size());
for (Node* child = node.firstChild(); child; child = child->nextSibling())

Powered by Google App Engine
This is Rietveld 408576698