Chromium Code Reviews| 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, 2008, 2009, 2010, 2011 Apple Inc. All r ights reserved. | 5 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All r ights reserved. |
| 6 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies) | 6 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies) |
| 7 * Copyright (C) 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmo bile.com/) | 7 * Copyright (C) 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmo bile.com/) |
| 8 * | 8 * |
| 9 * This library is free software; you can redistribute it and/or | 9 * This library is free software; you can redistribute it and/or |
| 10 * modify it under the terms of the GNU Library General Public | 10 * modify it under the terms of the GNU Library General Public |
| (...skipping 361 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 372 | 372 |
| 373 PassRefPtr<Node> Node::appendChild(PassRefPtr<Node> newChild, ExceptionState& ex ceptionState) | 373 PassRefPtr<Node> Node::appendChild(PassRefPtr<Node> newChild, ExceptionState& ex ceptionState) |
| 374 { | 374 { |
| 375 if (isContainerNode()) | 375 if (isContainerNode()) |
| 376 return toContainerNode(this)->appendChild(newChild, exceptionState); | 376 return toContainerNode(this)->appendChild(newChild, exceptionState); |
| 377 | 377 |
| 378 exceptionState.ThrowDOMException(HierarchyRequestError, "This node type does not support this method."); | 378 exceptionState.ThrowDOMException(HierarchyRequestError, "This node type does not support this method."); |
| 379 return nullptr; | 379 return nullptr; |
| 380 } | 380 } |
| 381 | 381 |
| 382 Element* Node::previousElementSibling() | |
| 383 { | |
| 384 return ElementTraversal::previousSibling(*this); | |
| 385 } | |
| 386 | |
| 387 Element* Node::nextElementSibling() | |
| 388 { | |
| 389 return ElementTraversal::nextSibling(*this); | |
| 390 } | |
| 391 | |
| 392 void Node::newInsertBefore(Vector<RefPtr<Node>>& nodes, ExceptionState& es) | |
| 393 { | |
| 394 RefPtr<Node> protect(this); | |
| 395 for (auto& node : nodes) { | |
| 396 ContainerNode* parent = parentNode(); | |
| 397 if (!parent) | |
| 398 return; | |
| 399 parent->insertBefore(node.release(), this, es); | |
| 400 if (es.had_exception()) | |
| 401 return; | |
| 402 } | |
| 403 } | |
| 404 | |
| 405 void Node::newInsertAfter(Vector<RefPtr<Node>>& nodes, ExceptionState& es) | |
| 406 { | |
| 407 RefPtr<Node> protect(this); | |
| 408 ScriptForbiddenScope scope; | |
| 409 Node* refNode = this; | |
| 410 for (auto& node : nodes) { | |
| 411 ContainerNode* parent = refNode->parentNode(); | |
|
esprehn
2015/02/14 01:50:08
You don't need to keep checking parent node like t
| |
| 412 if (!parent) | |
| 413 return; | |
| 414 Node* nextRefNode = node.get() | |
| 415 parent->insertBefore(node.release(), refNode, es); | |
| 416 if (es.had_exception()) | |
| 417 return; | |
| 418 refNode = nextRefNode; | |
| 419 } | |
| 420 } | |
| 421 | |
| 422 void Node::replaceWith(Vector<RefPtr<Node>>& nodes, ExceptionState& es) | |
| 423 { | |
| 424 if (RefPtr<Node> next = m_next) { | |
| 425 remove(es); | |
| 426 if (es.had_exception()) | |
| 427 return; | |
| 428 next->newInsertBefore(nodes, es); | |
| 429 } else if (RefPtr<ContainerNode> parent = parentNode()) { | |
| 430 remove(es); | |
| 431 if (es.had_exception()) | |
| 432 return; | |
| 433 parent->append(nodes, es); | |
| 434 } | |
|
esprehn
2015/02/14 01:50:08
RefPtr<Node> parent = this->parent();
RefPtr<Node>
esprehn
2015/02/14 01:51:06
Sorry that's parent->insertBefore(this, next);
abarth-chromium
2015/02/14 02:30:53
We're trying to insert |nodes|, not |this|. Also,
esprehn
2015/02/14 02:37:43
Why not a loop then?
RefPtr<Node> parent = this->
| |
| 435 } | |
| 436 | |
| 382 void Node::remove(ExceptionState& exceptionState) | 437 void Node::remove(ExceptionState& exceptionState) |
| 383 { | 438 { |
| 384 if (ContainerNode* parent = parentNode()) | 439 if (ContainerNode* parent = parentNode()) |
| 385 parent->removeChild(this, exceptionState); | 440 parent->removeChild(this, exceptionState); |
| 386 } | 441 } |
| 387 | 442 |
| 388 const AtomicString& Node::localName() const | 443 const AtomicString& Node::localName() const |
| 389 { | 444 { |
| 390 return nullAtom; | 445 return nullAtom; |
| 391 } | 446 } |
| (...skipping 463 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 855 } | 910 } |
| 856 | 911 |
| 857 // FIXME: End of obviously misplaced HTML editing functions. Try to move these out of Node. | 912 // FIXME: End of obviously misplaced HTML editing functions. Try to move these out of Node. |
| 858 | 913 |
| 859 Document* Node::ownerDocument() const | 914 Document* Node::ownerDocument() const |
| 860 { | 915 { |
| 861 Document* doc = &document(); | 916 Document* doc = &document(); |
| 862 return doc == this ? 0 : doc; | 917 return doc == this ? 0 : doc; |
| 863 } | 918 } |
| 864 | 919 |
| 865 ContainerNode* Node::ownerScope() const | 920 ContainerNode* Node::owner() const |
| 866 { | 921 { |
| 867 if (inDocument()) | 922 if (inDocument()) |
| 868 return &treeScope().rootNode(); | 923 return &treeScope().rootNode(); |
| 869 if (ShadowRoot* root = containingShadowRoot()) | 924 if (ShadowRoot* root = containingShadowRoot()) |
| 870 return root; | 925 return root; |
| 871 return 0; | 926 return 0; |
| 872 } | 927 } |
| 873 | 928 |
| 874 String Node::textContent() const | 929 String Node::textContent() const |
| 875 { | 930 { |
| (...skipping 734 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1610 node->showTreeForThis(); | 1665 node->showTreeForThis(); |
| 1611 } | 1666 } |
| 1612 | 1667 |
| 1613 void showNodePath(const blink::Node* node) | 1668 void showNodePath(const blink::Node* node) |
| 1614 { | 1669 { |
| 1615 if (node) | 1670 if (node) |
| 1616 node->showNodePathForThis(); | 1671 node->showNodePathForThis(); |
| 1617 } | 1672 } |
| 1618 | 1673 |
| 1619 #endif | 1674 #endif |
| OLD | NEW |