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 516 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
527 // Remove the node from the tree before calling detach or removedFromDoc
ument (4427024, 4129744). | 527 // Remove the node from the tree before calling detach or removedFromDoc
ument (4427024, 4129744). |
528 // removeChild() does this after calling detach(). There is no explanati
on for | 528 // removeChild() does this after calling detach(). There is no explanati
on for |
529 // this discrepancy between removeChild() and its optimized version remo
veChildren(). | 529 // this discrepancy between removeChild() and its optimized version remo
veChildren(). |
530 n->setPreviousSibling(0); | 530 n->setPreviousSibling(0); |
531 n->setNextSibling(0); | 531 n->setNextSibling(0); |
532 n->setParent(0); | 532 n->setParent(0); |
533 | 533 |
534 m_firstChild = next; | 534 m_firstChild = next; |
535 if (n == m_lastChild) | 535 if (n == m_lastChild) |
536 m_lastChild = 0; | 536 m_lastChild = 0; |
537 | |
538 if (n->attached()) | |
539 n->detach(); | |
540 | |
541 removedChildren.append(n.release()); | 537 removedChildren.append(n.release()); |
542 } | 538 } |
543 allowEventDispatch(); | |
544 | 539 |
545 size_t removedChildrenCount = removedChildren.size(); | 540 size_t removedChildrenCount = removedChildren.size(); |
| 541 size_t i; |
| 542 |
| 543 // Detach the nodes only after properly removed from the tree because |
| 544 // a. detaching requires a proper DOM tree (for counters and quotes for |
| 545 // example) and during the previous loop the next sibling still points to |
| 546 // the node being removed while the node being removed does not point back |
| 547 // and does not point to the same parent as its next sibling. |
| 548 // b. destroying Renderers of standalone nodes is sometimes faster. |
| 549 for (i = 0; i < removedChildrenCount; ++i) { |
| 550 Node* removedChild = removedChildren[i].get(); |
| 551 if (removedChild->attached()) |
| 552 removedChild->detach(); |
| 553 } |
| 554 |
| 555 allowEventDispatch(); |
546 | 556 |
547 // Dispatch a single post-removal mutation event denoting a modified subtree
. | 557 // Dispatch a single post-removal mutation event denoting a modified subtree
. |
548 childrenChanged(false, 0, 0, -static_cast<int>(removedChildrenCount)); | 558 childrenChanged(false, 0, 0, -static_cast<int>(removedChildrenCount)); |
549 dispatchSubtreeModifiedEvent(); | 559 dispatchSubtreeModifiedEvent(); |
550 | 560 |
551 for (size_t i = 0; i < removedChildrenCount; ++i) { | 561 for (i = 0; i < removedChildrenCount; ++i) { |
552 Node* removedChild = removedChildren[i].get(); | 562 Node* removedChild = removedChildren[i].get(); |
553 if (removedChild->inDocument()) | 563 if (removedChild->inDocument()) |
554 removedChild->removedFromDocument(); | 564 removedChild->removedFromDocument(); |
555 // removeChild() calls removedFromTree(true) if the child was not in the | 565 // removeChild() calls removedFromTree(true) if the child was not in the |
556 // document. There is no explanation for this discrepancy between remove
Child() | 566 // document. There is no explanation for this discrepancy between remove
Child() |
557 // and its optimized version removeChildren(). | 567 // and its optimized version removeChildren(). |
558 } | 568 } |
559 } | 569 } |
560 | 570 |
561 bool ContainerNode::appendChild(PassRefPtr<Node> newChild, ExceptionCode& ec, bo
ol shouldLazyAttach) | 571 bool ContainerNode::appendChild(PassRefPtr<Node> newChild, ExceptionCode& ec, bo
ol shouldLazyAttach) |
(...skipping 530 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1092 if (!document()->hasListenerType(Document::BEFORELOAD_LISTENER)) | 1102 if (!document()->hasListenerType(Document::BEFORELOAD_LISTENER)) |
1093 return true; | 1103 return true; |
1094 | 1104 |
1095 RefPtr<ContainerNode> protector(this); | 1105 RefPtr<ContainerNode> protector(this); |
1096 RefPtr<BeforeLoadEvent> beforeLoadEvent = BeforeLoadEvent::create(sourceURL)
; | 1106 RefPtr<BeforeLoadEvent> beforeLoadEvent = BeforeLoadEvent::create(sourceURL)
; |
1097 dispatchEvent(beforeLoadEvent.get()); | 1107 dispatchEvent(beforeLoadEvent.get()); |
1098 return !beforeLoadEvent->defaultPrevented(); | 1108 return !beforeLoadEvent->defaultPrevented(); |
1099 } | 1109 } |
1100 | 1110 |
1101 } // namespace WebCore | 1111 } // namespace WebCore |
OLD | NEW |