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 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
65 | 65 |
66 for (Node* child = node->firstChild(); child; child = child->nextSibling()) | 66 for (Node* child = node->firstChild(); child; child = child->nextSibling()) |
67 nodes.append(child); | 67 nodes.append(child); |
68 } | 68 } |
69 | 69 |
70 void ContainerNode::removeAllChildren() | 70 void ContainerNode::removeAllChildren() |
71 { | 71 { |
72 removeAllChildrenInContainer<Node, ContainerNode>(this); | 72 removeAllChildrenInContainer<Node, ContainerNode>(this); |
73 } | 73 } |
74 | 74 |
75 | |
76 void ContainerNode::takeAllChildrenFrom(ContainerNode* oldParent) | 75 void ContainerNode::takeAllChildrenFrom(ContainerNode* oldParent) |
77 { | 76 { |
78 NodeVector children; | 77 NodeVector children; |
79 for (Node* child = oldParent->firstChild(); child; child = child->nextSiblin
g()) | 78 for (Node* child = oldParent->firstChild(); child; child = child->nextSiblin
g()) |
80 children.append(child); | 79 children.append(child); |
81 oldParent->removeAllChildren(); | 80 oldParent->removeAllChildren(); |
82 | 81 |
83 for (unsigned i = 0; i < children.size(); ++i) { | 82 for (unsigned i = 0; i < children.size(); ++i) { |
84 ExceptionCode ec = 0; | 83 ExceptionCode ec = 0; |
| 84 if (children[i]->attached()) |
| 85 children[i]->detach(); |
85 // FIXME: We need a no mutation event version of adoptNode. | 86 // FIXME: We need a no mutation event version of adoptNode. |
86 RefPtr<Node> child = document()->adoptNode(children[i].release(), ec); | 87 RefPtr<Node> child = document()->adoptNode(children[i].release(), ec); |
87 ASSERT(!ec); | 88 ASSERT(!ec); |
88 parserAddChild(child.release()); | 89 parserAddChild(child.get()); |
| 90 if (attached() && !child->attached()) |
| 91 child->attach(); |
89 } | 92 } |
90 } | 93 } |
91 | 94 |
92 ContainerNode::~ContainerNode() | 95 ContainerNode::~ContainerNode() |
93 { | 96 { |
94 removeAllChildren(); | 97 removeAllChildren(); |
95 } | 98 } |
96 | 99 |
97 bool ContainerNode::insertBefore(PassRefPtr<Node> newChild, Node* refChild, Exce
ptionCode& ec, bool shouldLazyAttach) | 100 bool ContainerNode::insertBefore(PassRefPtr<Node> newChild, Node* refChild, Exce
ptionCode& ec, bool shouldLazyAttach) |
98 { | 101 { |
(...skipping 947 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1046 if (!document()->hasListenerType(Document::BEFORELOAD_LISTENER)) | 1049 if (!document()->hasListenerType(Document::BEFORELOAD_LISTENER)) |
1047 return true; | 1050 return true; |
1048 | 1051 |
1049 RefPtr<ContainerNode> protector(this); | 1052 RefPtr<ContainerNode> protector(this); |
1050 RefPtr<BeforeLoadEvent> beforeLoadEvent = BeforeLoadEvent::create(sourceURL)
; | 1053 RefPtr<BeforeLoadEvent> beforeLoadEvent = BeforeLoadEvent::create(sourceURL)
; |
1051 dispatchEvent(beforeLoadEvent.get()); | 1054 dispatchEvent(beforeLoadEvent.get()); |
1052 return !beforeLoadEvent->defaultPrevented(); | 1055 return !beforeLoadEvent->defaultPrevented(); |
1053 } | 1056 } |
1054 | 1057 |
1055 } // namespace WebCore | 1058 } // namespace WebCore |
OLD | NEW |