| 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 Apple Inc. All rights reserv
ed. | 5 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserv
ed. |
| 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 321 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 332 | 332 |
| 333 if (document() != newChild->document()) | 333 if (document() != newChild->document()) |
| 334 document()->adoptNode(newChild.get(), ASSERT_NO_EXCEPTION); | 334 document()->adoptNode(newChild.get(), ASSERT_NO_EXCEPTION); |
| 335 | 335 |
| 336 insertBeforeCommon(nextChild, newChild.get()); | 336 insertBeforeCommon(nextChild, newChild.get()); |
| 337 | 337 |
| 338 newChild->updateAncestorConnectedSubframeCountForInsertion(); | 338 newChild->updateAncestorConnectedSubframeCountForInsertion(); |
| 339 | 339 |
| 340 ChildListMutationScope(this).childAdded(newChild.get()); | 340 ChildListMutationScope(this).childAdded(newChild.get()); |
| 341 | 341 |
| 342 childrenChanged(true, newChild->previousSibling(), nextChild, 1); | 342 childrenChanged(true, adoptRawResult(newChild->previousSibling()), adoptRawR
esult(nextChild), 1); |
| 343 ChildNodeInsertionNotifier(selfHandle()).notify(newChild.get()); | 343 ChildNodeInsertionNotifier(selfHandle()).notify(newChild.get()); |
| 344 } | 344 } |
| 345 | 345 |
| 346 bool ContainerNode::replaceChild(PassRefPtr<Node> newChild, Node* oldChild, Exce
ptionCode& ec, AttachBehavior attachBehavior) | 346 bool ContainerNode::replaceChild(PassRefPtr<Node> newChild, Node* oldChild, Exce
ptionCode& ec, AttachBehavior attachBehavior) |
| 347 { | 347 { |
| 348 HandleScope scope; | 348 HandleScope scope; |
| 349 // FIXME(oilpan): not needed when all Node pointers are handlified. | 349 // FIXME(oilpan): not needed when all Node pointers are handlified. |
| 350 Handle<Node> protect(this); | 350 Handle<Node> protect(this); |
| 351 | 351 |
| 352 ec = 0; | 352 ec = 0; |
| (...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 507 ec = NOT_FOUND_ERR; | 507 ec = NOT_FOUND_ERR; |
| 508 return false; | 508 return false; |
| 509 } | 509 } |
| 510 | 510 |
| 511 { | 511 { |
| 512 WidgetHierarchyUpdatesSuspensionScope suspendWidgetHierarchyUpdates; | 512 WidgetHierarchyUpdatesSuspensionScope suspendWidgetHierarchyUpdates; |
| 513 | 513 |
| 514 Node* prev = child->previousSibling(); | 514 Node* prev = child->previousSibling(); |
| 515 Node* next = child->nextSibling(); | 515 Node* next = child->nextSibling(); |
| 516 removeBetween(prev, next, child.get()); | 516 removeBetween(prev, next, child.get()); |
| 517 childrenChanged(false, prev, next, -1); | 517 childrenChanged(false, adoptRawResult(prev), adoptRawResult(next), -1); |
| 518 ChildNodeRemovalNotifier(selfHandle()).notify(child.get()); | 518 ChildNodeRemovalNotifier(selfHandle()).notify(child.get()); |
| 519 } | 519 } |
| 520 dispatchSubtreeModifiedEvent(); | 520 dispatchSubtreeModifiedEvent(); |
| 521 | 521 |
| 522 return child; | 522 return child; |
| 523 } | 523 } |
| 524 | 524 |
| 525 void ContainerNode::removeBetween(Node* previousChild, Node* nextChild, Node* ol
dChild) | 525 void ContainerNode::removeBetween(Node* previousChild, Node* nextChild, Node* ol
dChild) |
| 526 { | 526 { |
| 527 HandleScope scope; | 527 HandleScope scope; |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 560 Node* prev = oldChild->previousSibling(); | 560 Node* prev = oldChild->previousSibling(); |
| 561 Node* next = oldChild->nextSibling(); | 561 Node* next = oldChild->nextSibling(); |
| 562 | 562 |
| 563 oldChild->updateAncestorConnectedSubframeCountForRemoval(); | 563 oldChild->updateAncestorConnectedSubframeCountForRemoval(); |
| 564 | 564 |
| 565 ChildListMutationScope(this).willRemoveChild(oldChild); | 565 ChildListMutationScope(this).willRemoveChild(oldChild); |
| 566 oldChild->notifyMutationObserversNodeWillDetach(); | 566 oldChild->notifyMutationObserversNodeWillDetach(); |
| 567 | 567 |
| 568 removeBetween(prev, next, oldChild); | 568 removeBetween(prev, next, oldChild); |
| 569 | 569 |
| 570 childrenChanged(true, prev, next, -1); | 570 childrenChanged(true, adoptRawResult(prev), adoptRawResult(next), -1); |
| 571 ChildNodeRemovalNotifier(selfHandle()).notify(oldChild); | 571 ChildNodeRemovalNotifier(selfHandle()).notify(oldChild); |
| 572 } | 572 } |
| 573 | 573 |
| 574 // this differs from other remove functions because it forcibly removes all the
children, | 574 // this differs from other remove functions because it forcibly removes all the
children, |
| 575 // regardless of read-only status or event exceptions, e.g. | 575 // regardless of read-only status or event exceptions, e.g. |
| 576 void ContainerNode::removeChildren() | 576 void ContainerNode::removeChildren() |
| 577 { | 577 { |
| 578 HandleScope scope; | 578 HandleScope scope; |
| 579 if (!m_firstChild) | 579 if (!m_firstChild) |
| 580 return; | 580 return; |
| (...skipping 17 matching lines...) Expand all Loading... |
| 598 { | 598 { |
| 599 NoEventDispatchAssertion assertNoEventDispatch; | 599 NoEventDispatchAssertion assertNoEventDispatch; |
| 600 removedChildren.reserveInitialCapacity(childNodeCount()); | 600 removedChildren.reserveInitialCapacity(childNodeCount()); |
| 601 while (m_firstChild) { | 601 while (m_firstChild) { |
| 602 HandleScope scope; | 602 HandleScope scope; |
| 603 removedChildren.append(m_firstChild); | 603 removedChildren.append(m_firstChild); |
| 604 removeBetween(0, m_firstChild->nextSibling(), m_firstChild); | 604 removeBetween(0, m_firstChild->nextSibling(), m_firstChild); |
| 605 } | 605 } |
| 606 } | 606 } |
| 607 | 607 |
| 608 childrenChanged(false, 0, 0, -static_cast<int>(removedChildren.size())); | 608 childrenChanged(false, nullptr, nullptr, -static_cast<int>(removedChildr
en.size())); |
| 609 | 609 |
| 610 for (size_t i = 0; i < removedChildren.size(); ++i) { | 610 for (size_t i = 0; i < removedChildren.size(); ++i) { |
| 611 HandleScope scope; | 611 HandleScope scope; |
| 612 ChildNodeRemovalNotifier(selfHandle()).notify(removedChildren[i].get
()); | 612 ChildNodeRemovalNotifier(selfHandle()).notify(removedChildren[i].get
()); |
| 613 } | 613 } |
| 614 } | 614 } |
| 615 | 615 |
| 616 dispatchSubtreeModifiedEvent(); | 616 dispatchSubtreeModifiedEvent(); |
| 617 } | 617 } |
| 618 | 618 |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 692 NoEventDispatchAssertion assertNoEventDispatch; | 692 NoEventDispatchAssertion assertNoEventDispatch; |
| 693 // FIXME: This method should take a PassRefPtr. | 693 // FIXME: This method should take a PassRefPtr. |
| 694 appendChildToContainer(newChild.get(), this); | 694 appendChildToContainer(newChild.get(), this); |
| 695 treeScope()->adoptIfNeeded(newChild.get()); | 695 treeScope()->adoptIfNeeded(newChild.get()); |
| 696 } | 696 } |
| 697 | 697 |
| 698 newChild->updateAncestorConnectedSubframeCountForInsertion(); | 698 newChild->updateAncestorConnectedSubframeCountForInsertion(); |
| 699 | 699 |
| 700 ChildListMutationScope(this).childAdded(newChild.get()); | 700 ChildListMutationScope(this).childAdded(newChild.get()); |
| 701 | 701 |
| 702 childrenChanged(true, last, 0, 1); | 702 childrenChanged(true, adoptRawResult(last), nullptr, 1); |
| 703 ChildNodeInsertionNotifier(selfHandle()).notify(newChild.get()); | 703 ChildNodeInsertionNotifier(selfHandle()).notify(newChild.get()); |
| 704 } | 704 } |
| 705 | 705 |
| 706 void ContainerNode::suspendPostAttachCallbacks() | 706 void ContainerNode::suspendPostAttachCallbacks() |
| 707 { | 707 { |
| 708 if (!s_attachDepth) { | 708 if (!s_attachDepth) { |
| 709 ASSERT(!s_shouldReEnableMemoryCacheCallsAfterAttach); | 709 ASSERT(!s_shouldReEnableMemoryCacheCallsAfterAttach); |
| 710 if (Page* page = document()->page()) { | 710 if (Page* page = document()->page()) { |
| 711 // FIXME: How can this call be specific to one Page, while the | 711 // FIXME: How can this call be specific to one Page, while the |
| 712 // s_attachDepth is a global? Doesn't make sense. | 712 // s_attachDepth is a global? Doesn't make sense. |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 782 Node::attach(); | 782 Node::attach(); |
| 783 } | 783 } |
| 784 | 784 |
| 785 void ContainerNode::detach() | 785 void ContainerNode::detach() |
| 786 { | 786 { |
| 787 detachChildren(); | 787 detachChildren(); |
| 788 clearChildNeedsStyleRecalc(); | 788 clearChildNeedsStyleRecalc(); |
| 789 Node::detach(); | 789 Node::detach(); |
| 790 } | 790 } |
| 791 | 791 |
| 792 void ContainerNode::childrenChanged(bool changedByParser, Node*, Node*, int chil
dCountDelta) | 792 void ContainerNode::childrenChanged(bool changedByParser, const Handle<Node>&, c
onst Handle<Node>&, int childCountDelta) |
| 793 { | 793 { |
| 794 document()->incDOMTreeVersion(); | 794 document()->incDOMTreeVersion(); |
| 795 if (!changedByParser && childCountDelta) | 795 if (!changedByParser && childCountDelta) |
| 796 document()->updateRangesAfterChildrenChanged(selfHandle()); | 796 document()->updateRangesAfterChildrenChanged(selfHandle()); |
| 797 invalidateNodeListCachesInAncestors(); | 797 invalidateNodeListCachesInAncestors(); |
| 798 } | 798 } |
| 799 | 799 |
| 800 void ContainerNode::cloneChildNodes(const Handle<ContainerNode>& clone) | 800 void ContainerNode::cloneChildNodes(const Handle<ContainerNode>& clone) |
| 801 { | 801 { |
| 802 ExceptionCode ec = 0; | 802 ExceptionCode ec = 0; |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 926 c->dispatchScopedEvent(MutationEvent::create(eventNames().DOMNodeRem
ovedFromDocumentEvent, false)); | 926 c->dispatchScopedEvent(MutationEvent::create(eventNames().DOMNodeRem
ovedFromDocumentEvent, false)); |
| 927 } | 927 } |
| 928 } | 928 } |
| 929 | 929 |
| 930 static void updateTreeAfterInsertion(const Handle<ContainerNode>& parent, Node*
child, AttachBehavior attachBehavior) | 930 static void updateTreeAfterInsertion(const Handle<ContainerNode>& parent, Node*
child, AttachBehavior attachBehavior) |
| 931 { | 931 { |
| 932 ASSERT(child->refCount()); | 932 ASSERT(child->refCount()); |
| 933 | 933 |
| 934 ChildListMutationScope(parent.raw()).childAdded(child); | 934 ChildListMutationScope(parent.raw()).childAdded(child); |
| 935 | 935 |
| 936 parent->childrenChanged(false, child->previousSibling(), child->nextSibling(
), 1); | 936 parent->childrenChanged(false, adoptRawResult(child->previousSibling()), ado
ptRawResult(child->nextSibling()), 1); |
| 937 | 937 |
| 938 ChildNodeInsertionNotifier(parent).notify(child); | 938 ChildNodeInsertionNotifier(parent).notify(child); |
| 939 | 939 |
| 940 // FIXME: Attachment should be the first operation in this function, but som
e code | 940 // FIXME: Attachment should be the first operation in this function, but som
e code |
| 941 // (for example, HTMLFormControlElement's autofocus support) requires this o
rdering. | 941 // (for example, HTMLFormControlElement's autofocus support) requires this o
rdering. |
| 942 if (parent->attached() && !child->attached() && child->parentNode() == paren
t) { | 942 if (parent->attached() && !child->attached() && child->parentNode() == paren
t) { |
| 943 if (attachBehavior == AttachLazily) | 943 if (attachBehavior == AttachLazily) |
| 944 child->lazyAttach(); | 944 child->lazyAttach(); |
| 945 else | 945 else |
| 946 child->attach(); | 946 child->attach(); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 966 #endif | 966 #endif |
| 967 | 967 |
| 968 void ContainerNode::accept(Visitor* visitor) const | 968 void ContainerNode::accept(Visitor* visitor) const |
| 969 { | 969 { |
| 970 Node::accept(visitor); | 970 Node::accept(visitor); |
| 971 visitor->visit(m_firstChild); | 971 visitor->visit(m_firstChild); |
| 972 visitor->visit(m_lastChild); | 972 visitor->visit(m_lastChild); |
| 973 } | 973 } |
| 974 | 974 |
| 975 } // namespace WebCore | 975 } // namespace WebCore |
| OLD | NEW |