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 795 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
806 Node::detach(); | 806 Node::detach(); |
807 } | 807 } |
808 | 808 |
809 void ContainerNode::insertedIntoDocument() | 809 void ContainerNode::insertedIntoDocument() |
810 { | 810 { |
811 RefPtr<Node> protect(this); | 811 RefPtr<Node> protect(this); |
812 | 812 |
813 Node::insertedIntoDocument(); | 813 Node::insertedIntoDocument(); |
814 insertedIntoTree(false); | 814 insertedIntoTree(false); |
815 | 815 |
816 for (RefPtr<Node> child = m_firstChild; child; child = child->nextSibling())
{ | 816 NodeVector children; |
817 // Guard against mutation during re-parenting. | 817 collectNodes(this, children); |
818 if (!inDocument()) // Check for self being removed from document while r
eparenting. | 818 for (size_t i = 0; i < children.size(); ++i) { |
| 819 // If we have been removed from the document during this loop, then |
| 820 // we don't want to tell the rest of our children that they've been |
| 821 // inserted into the document because they haven't. |
| 822 if (!inDocument()) |
819 break; | 823 break; |
820 if (child->parentNode() != this) // Check for child being removed from s
ubtree while reparenting. | 824 if (children[i]->parentNode() != this) |
821 break; | 825 continue; |
822 child->insertedIntoDocument(); | 826 children[i]->insertedIntoDocument(); |
823 } | 827 } |
824 } | 828 } |
825 | 829 |
826 void ContainerNode::removedFromDocument() | 830 void ContainerNode::removedFromDocument() |
827 { | 831 { |
828 Node::removedFromDocument(); | 832 Node::removedFromDocument(); |
829 if (document()->cssTarget() == this) | 833 if (document()->cssTarget() == this) |
830 document()->setCSSTarget(0); | 834 document()->setCSSTarget(0); |
831 clearInDocument(); | 835 clearInDocument(); |
832 removedFromTree(false); | 836 removedFromTree(false); |
833 for (Node* child = m_firstChild; child; child = child->nextSibling()) | 837 |
834 child->removedFromDocument(); | 838 NodeVector children; |
| 839 collectNodes(this, children); |
| 840 for (size_t i = 0; i < children.size(); ++i) { |
| 841 // If we have been added to the document during this loop, then we |
| 842 // don't want to tell the rest of our children that they've been |
| 843 // removed from the document because they haven't. |
| 844 if (inDocument()) |
| 845 break; |
| 846 if (children[i]->parentNode() != this) |
| 847 continue; |
| 848 children[i]->removedFromDocument(); |
| 849 } |
835 } | 850 } |
836 | 851 |
837 void ContainerNode::insertedIntoTree(bool deep) | 852 void ContainerNode::insertedIntoTree(bool deep) |
838 { | 853 { |
839 if (!deep) | 854 if (!deep) |
840 return; | 855 return; |
841 for (Node* child = m_firstChild; child; child = child->nextSibling()) | 856 for (Node* child = m_firstChild; child; child = child->nextSibling()) |
842 child->insertedIntoTree(true); | 857 child->insertedIntoTree(true); |
843 } | 858 } |
844 | 859 |
(...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1176 if (!document()->hasListenerType(Document::BEFORELOAD_LISTENER)) | 1191 if (!document()->hasListenerType(Document::BEFORELOAD_LISTENER)) |
1177 return true; | 1192 return true; |
1178 | 1193 |
1179 RefPtr<ContainerNode> protector(this); | 1194 RefPtr<ContainerNode> protector(this); |
1180 RefPtr<BeforeLoadEvent> beforeLoadEvent = BeforeLoadEvent::create(sourceURL)
; | 1195 RefPtr<BeforeLoadEvent> beforeLoadEvent = BeforeLoadEvent::create(sourceURL)
; |
1181 dispatchEvent(beforeLoadEvent.get()); | 1196 dispatchEvent(beforeLoadEvent.get()); |
1182 return !beforeLoadEvent->defaultPrevented(); | 1197 return !beforeLoadEvent->defaultPrevented(); |
1183 } | 1198 } |
1184 | 1199 |
1185 } // namespace WebCore | 1200 } // namespace WebCore |
OLD | NEW |