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

Unified Diff: sky/engine/core/dom/Node.cpp

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: less 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
« no previous file with comments | « sky/engine/core/dom/Node.h ('k') | sky/engine/core/dom/Node.idl » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sky/engine/core/dom/Node.cpp
diff --git a/sky/engine/core/dom/Node.cpp b/sky/engine/core/dom/Node.cpp
index 6ff1d2c4ee935c46e4b4327b91585d8c90026f4b..8bac2ea63766e293a57d177ee822cc39aa9eb32d 100644
--- a/sky/engine/core/dom/Node.cpp
+++ b/sky/engine/core/dom/Node.cpp
@@ -379,6 +379,60 @@ PassRefPtr<Node> Node::appendChild(PassRefPtr<Node> newChild, ExceptionState& ex
return nullptr;
}
+Element* Node::previousElementSibling()
+{
+ return ElementTraversal::previousSibling(*this);
+}
+
+Element* Node::nextElementSibling()
+{
+ return ElementTraversal::nextSibling(*this);
+}
+
+void Node::newInsertBefore(Vector<RefPtr<Node>>& nodes, ExceptionState& es)
+{
+ ScriptForbiddenScope scope;
+ RefPtr<ContainerNode> parent = parentNode();
+ if (!parent)
+ return;
+ RefPtr<Node> protect(this);
+ for (auto& node : nodes) {
+ parent->insertBefore(node.release(), this, es);
+ if (es.had_exception())
+ return;
+ }
+}
+
+void Node::newInsertAfter(Vector<RefPtr<Node>>& nodes, ExceptionState& es)
+{
+ ScriptForbiddenScope scope;
+ RefPtr<ContainerNode> parent = this->parentNode();
+ if (!parent)
+ return;
+ RefPtr<Node> reference = m_next;
+ for (auto& node : nodes) {
+ parent->insertBefore(node.release(), reference, es);
+ if (es.had_exception())
+ return;
+ }
+}
+
+void Node::replaceWith(Vector<RefPtr<Node>>& nodes, ExceptionState& es)
+{
+ RefPtr<ContainerNode> parent = this->parentNode();
+ if (!parent)
+ return;
+ RefPtr<Node> reference = m_next;
+ remove(es);
+ if (es.had_exception())
+ return;
+ for (auto& node : nodes) {
+ parent->insertBefore(node, reference.get(), es);
+ if (es.had_exception())
+ return;
+ }
+}
+
void Node::remove(ExceptionState& exceptionState)
{
if (ContainerNode* parent = parentNode())
@@ -862,7 +916,7 @@ Document* Node::ownerDocument() const
return doc == this ? 0 : doc;
}
-ContainerNode* Node::ownerScope() const
+ContainerNode* Node::owner() const
{
if (inDocument())
return &treeScope().rootNode();
« no previous file with comments | « sky/engine/core/dom/Node.h ('k') | sky/engine/core/dom/Node.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698