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

Side by Side Diff: sky/engine/core/dom/ContainerNode.cpp

Issue 698123002: Remove more API from Node and ContainerNode. (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 6 years, 1 month 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 unified diff | Download patch
« no previous file with comments | « sky/engine/core/dom/ContainerNode.h ('k') | sky/engine/core/dom/Document.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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, 2013 Apple Inc. All rights reserved. 5 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2013 Apple Inc. All rights 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 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 DocumentFragment& fragment = toDocumentFragment(node); 53 DocumentFragment& fragment = toDocumentFragment(node);
54 getChildNodes(fragment, nodes); 54 getChildNodes(fragment, nodes);
55 fragment.removeChildren(); 55 fragment.removeChildren();
56 return; 56 return;
57 } 57 }
58 nodes.append(&node); 58 nodes.append(&node);
59 if (ContainerNode* oldParent = node.parentNode()) 59 if (ContainerNode* oldParent = node.parentNode())
60 oldParent->removeChild(&node, exceptionState); 60 oldParent->removeChild(&node, exceptionState);
61 } 61 }
62 62
63 #if !ENABLE(OILPAN)
64 void ContainerNode::removeDetachedChildren() 63 void ContainerNode::removeDetachedChildren()
65 { 64 {
66 ASSERT(needsAttach()); 65 ASSERT(needsAttach());
67 removeDetachedChildrenInContainer(*this); 66 removeDetachedChildrenInContainer(*this);
68 } 67 }
69 #endif
70
71 void ContainerNode::parserTakeAllChildrenFrom(ContainerNode& oldParent)
72 {
73 while (RefPtr<Node> child = oldParent.firstChild()) {
74 oldParent.parserRemoveChild(*child);
75 treeScope().adoptIfNeeded(*child);
76 parserAppendChild(child.get());
77 }
78 }
79 68
80 ContainerNode::~ContainerNode() 69 ContainerNode::~ContainerNode()
81 { 70 {
82 ASSERT(needsAttach()); 71 ASSERT(needsAttach());
83 #if !ENABLE(OILPAN) 72 #if !ENABLE(OILPAN)
84 willBeDeletedFromDocument(); 73 willBeDeletedFromDocument();
85 removeDetachedChildren(); 74 removeDetachedChildren();
86 #endif 75 #endif
87 } 76 }
88 77
(...skipping 374 matching lines...) Expand 10 before | Expand all | Expand 10 after
463 container.document().adoptIfNeeded(*n); 452 container.document().adoptIfNeeded(*n);
464 if (n->inDocument()) 453 if (n->inDocument())
465 container.notifyNodeRemoved(*n); 454 container.notifyNodeRemoved(*n);
466 } 455 }
467 } 456 }
468 457
469 container.setLastChild(0); 458 container.setLastChild(0);
470 } 459 }
471 #endif 460 #endif
472 461
473 void ContainerNode::trace(Visitor* visitor)
474 {
475 visitor->trace(m_firstChild);
476 visitor->trace(m_lastChild);
477 Node::trace(visitor);
478 }
479
480 PassRefPtr<Node> ContainerNode::removeChild(PassRefPtr<Node> oldChild, Exception State& exceptionState) 462 PassRefPtr<Node> ContainerNode::removeChild(PassRefPtr<Node> oldChild, Exception State& exceptionState)
481 { 463 {
482 #if !ENABLE(OILPAN) 464 #if !ENABLE(OILPAN)
483 // Check that this node is not "floating". 465 // Check that this node is not "floating".
484 // If it is, it can be deleted as a side effect of sending mutation events. 466 // If it is, it can be deleted as a side effect of sending mutation events.
485 ASSERT(refCount() || parentOrShadowHostNode()); 467 ASSERT(refCount() || parentOrShadowHostNode());
486 #endif 468 #endif
487 469
488 RefPtr<Node> protect(this); 470 RefPtr<Node> protect(this);
489 RefPtr<Node> child = oldChild; 471 RefPtr<Node> child = oldChild;
(...skipping 12 matching lines...) Expand all
502 // Mutation events might have moved this child into a different parent. 484 // Mutation events might have moved this child into a different parent.
503 if (child->parentNode() != this) { 485 if (child->parentNode() != this) {
504 exceptionState.throwDOMException(NotFoundError, "The node to be removed is no longer a child of this node. Perhaps it was moved in response to a mutatio n?"); 486 exceptionState.throwDOMException(NotFoundError, "The node to be removed is no longer a child of this node. Perhaps it was moved in response to a mutatio n?");
505 return nullptr; 487 return nullptr;
506 } 488 }
507 489
508 Node* prev = child->previousSibling(); 490 Node* prev = child->previousSibling();
509 Node* next = child->nextSibling(); 491 Node* next = child->nextSibling();
510 removeBetween(prev, next, *child); 492 removeBetween(prev, next, *child);
511 notifyNodeRemoved(*child); 493 notifyNodeRemoved(*child);
512 childrenChanged(ChildrenChange::forRemoval(*child, prev, next, ChildrenChang eSourceAPI)); 494 childrenChanged(ChildrenChange::forRemoval(*child, ChildrenChangeSourceAPI)) ;
513 495
514 return child; 496 return child;
515 } 497 }
516 498
517 void ContainerNode::removeBetween(Node* previousChild, Node* nextChild, Node& ol dChild) 499 void ContainerNode::removeBetween(Node* previousChild, Node* nextChild, Node& ol dChild)
518 { 500 {
519 EventDispatchForbiddenScope assertNoEventDispatch; 501 EventDispatchForbiddenScope assertNoEventDispatch;
520 502
521 ASSERT(oldChild.parentNode() == this); 503 ASSERT(oldChild.parentNode() == this);
522 504
(...skipping 23 matching lines...) Expand all
546 528
547 Node* prev = oldChild.previousSibling(); 529 Node* prev = oldChild.previousSibling();
548 Node* next = oldChild.nextSibling(); 530 Node* next = oldChild.nextSibling();
549 531
550 ChildListMutationScope(*this).willRemoveChild(oldChild); 532 ChildListMutationScope(*this).willRemoveChild(oldChild);
551 oldChild.notifyMutationObserversNodeWillDetach(); 533 oldChild.notifyMutationObserversNodeWillDetach();
552 534
553 removeBetween(prev, next, oldChild); 535 removeBetween(prev, next, oldChild);
554 536
555 notifyNodeRemoved(oldChild); 537 notifyNodeRemoved(oldChild);
556 childrenChanged(ChildrenChange::forRemoval(oldChild, prev, next, ChildrenCha ngeSourceParser)); 538 childrenChanged(ChildrenChange::forRemoval(oldChild, ChildrenChangeSourcePar ser));
557 } 539 }
558 540
559 // this differs from other remove functions because it forcibly removes all the children, 541 // this differs from other remove functions because it forcibly removes all the children,
560 // regardless of read-only status or event exceptions, e.g. 542 // regardless of read-only status or event exceptions, e.g.
561 void ContainerNode::removeChildren() 543 void ContainerNode::removeChildren()
562 { 544 {
563 if (!m_firstChild) 545 if (!m_firstChild)
564 return; 546 return;
565 547
566 // The container node can be removed from event handlers. 548 // The container node can be removed from event handlers.
(...skipping 25 matching lines...) Expand all
592 ScriptForbiddenScope forbidScript; 574 ScriptForbiddenScope forbidScript;
593 575
594 removedChildren.reserveInitialCapacity(countChildren()); 576 removedChildren.reserveInitialCapacity(countChildren());
595 577
596 while (RefPtr<Node> child = m_firstChild) { 578 while (RefPtr<Node> child = m_firstChild) {
597 removeBetween(0, child->nextSibling(), *child); 579 removeBetween(0, child->nextSibling(), *child);
598 removedChildren.append(child.get()); 580 removedChildren.append(child.get());
599 notifyNodeRemoved(*child); 581 notifyNodeRemoved(*child);
600 } 582 }
601 583
602 ChildrenChange change = {AllChildrenRemoved, nullptr, nullptr, ChildrenC hangeSourceAPI}; 584 ChildrenChange change = {AllChildrenRemoved, ChildrenChangeSourceAPI};
603 childrenChanged(change); 585 childrenChanged(change);
604 } 586 }
605 } 587 }
606 588
607 PassRefPtr<Node> ContainerNode::appendChild(PassRefPtr<Node> newChild, Exception State& exceptionState) 589 PassRefPtr<Node> ContainerNode::appendChild(PassRefPtr<Node> newChild, Exception State& exceptionState)
608 { 590 {
609 RefPtr<ContainerNode> protect(this); 591 RefPtr<ContainerNode> protect(this);
610 592
611 #if !ENABLE(OILPAN) 593 #if !ENABLE(OILPAN)
612 // Check that this node is not "floating". 594 // Check that this node is not "floating".
(...skipping 439 matching lines...) Expand 10 before | Expand all | Expand 10 after
1052 return true; 1034 return true;
1053 1035
1054 if (node->isElementNode() && toElement(node)->shadow()) 1036 if (node->isElementNode() && toElement(node)->shadow())
1055 return true; 1037 return true;
1056 1038
1057 return false; 1039 return false;
1058 } 1040 }
1059 #endif 1041 #endif
1060 1042
1061 } // namespace blink 1043 } // namespace blink
OLDNEW
« no previous file with comments | « sky/engine/core/dom/ContainerNode.h ('k') | sky/engine/core/dom/Document.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698