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 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
109 { | 109 { |
110 removeAllChildren(); | 110 removeAllChildren(); |
111 } | 111 } |
112 | 112 |
113 bool ContainerNode::insertBefore(PassRefPtr<Node> newChild, Node* refChild, Exce
ptionCode& ec, bool shouldLazyAttach) | 113 bool ContainerNode::insertBefore(PassRefPtr<Node> newChild, Node* refChild, Exce
ptionCode& ec, bool shouldLazyAttach) |
114 { | 114 { |
115 // Check that this node is not "floating". | 115 // Check that this node is not "floating". |
116 // If it is, it can be deleted as a side effect of sending mutation events. | 116 // If it is, it can be deleted as a side effect of sending mutation events. |
117 ASSERT(refCount() || parentOrHostNode()); | 117 ASSERT(refCount() || parentOrHostNode()); |
118 | 118 |
| 119 RefPtr<Node> protect(this); |
| 120 |
119 ec = 0; | 121 ec = 0; |
120 | 122 |
121 // insertBefore(node, 0) is equivalent to appendChild(node) | 123 // insertBefore(node, 0) is equivalent to appendChild(node) |
122 if (!refChild) | 124 if (!refChild) |
123 return appendChild(newChild, ec, shouldLazyAttach); | 125 return appendChild(newChild, ec, shouldLazyAttach); |
124 | 126 |
125 // Make sure adding the new child is OK. | 127 // Make sure adding the new child is OK. |
126 checkAddChild(newChild.get(), ec); | 128 checkAddChild(newChild.get(), ec); |
127 if (ec) | 129 if (ec) |
128 return false; | 130 return false; |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
254 notifyChildInserted(child); | 256 notifyChildInserted(child); |
255 } | 257 } |
256 } | 258 } |
257 | 259 |
258 bool ContainerNode::replaceChild(PassRefPtr<Node> newChild, Node* oldChild, Exce
ptionCode& ec, bool shouldLazyAttach) | 260 bool ContainerNode::replaceChild(PassRefPtr<Node> newChild, Node* oldChild, Exce
ptionCode& ec, bool shouldLazyAttach) |
259 { | 261 { |
260 // Check that this node is not "floating". | 262 // Check that this node is not "floating". |
261 // If it is, it can be deleted as a side effect of sending mutation events. | 263 // If it is, it can be deleted as a side effect of sending mutation events. |
262 ASSERT(refCount() || parentOrHostNode()); | 264 ASSERT(refCount() || parentOrHostNode()); |
263 | 265 |
| 266 RefPtr<Node> protect(this); |
| 267 |
264 ec = 0; | 268 ec = 0; |
265 | 269 |
266 if (oldChild == newChild) // nothing to do | 270 if (oldChild == newChild) // nothing to do |
267 return true; | 271 return true; |
268 | 272 |
269 // Make sure replacing the old child with the new is ok | 273 // Make sure replacing the old child with the new is ok |
270 checkReplaceChild(newChild.get(), oldChild, ec); | 274 checkReplaceChild(newChild.get(), oldChild, ec); |
271 if (ec) | 275 if (ec) |
272 return false; | 276 return false; |
273 | 277 |
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
420 child->willRemove(); | 424 child->willRemove(); |
421 } | 425 } |
422 } | 426 } |
423 | 427 |
424 bool ContainerNode::removeChild(Node* oldChild, ExceptionCode& ec) | 428 bool ContainerNode::removeChild(Node* oldChild, ExceptionCode& ec) |
425 { | 429 { |
426 // Check that this node is not "floating". | 430 // Check that this node is not "floating". |
427 // If it is, it can be deleted as a side effect of sending mutation events. | 431 // If it is, it can be deleted as a side effect of sending mutation events. |
428 ASSERT(refCount() || parentOrHostNode()); | 432 ASSERT(refCount() || parentOrHostNode()); |
429 | 433 |
| 434 RefPtr<Node> protect(this); |
| 435 |
430 ec = 0; | 436 ec = 0; |
431 | 437 |
432 // NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly. | 438 // NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly. |
433 if (isReadOnlyNode()) { | 439 if (isReadOnlyNode()) { |
434 ec = NO_MODIFICATION_ALLOWED_ERR; | 440 ec = NO_MODIFICATION_ALLOWED_ERR; |
435 return false; | 441 return false; |
436 } | 442 } |
437 | 443 |
438 // NOT_FOUND_ERR: Raised if oldChild is not a child of this node. | 444 // NOT_FOUND_ERR: Raised if oldChild is not a child of this node. |
439 if (!oldChild || oldChild->parentNode() != this) { | 445 if (!oldChild || oldChild->parentNode() != this) { |
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
598 if (removedChild->inDocument()) | 604 if (removedChild->inDocument()) |
599 removedChild->removedFromDocument(); | 605 removedChild->removedFromDocument(); |
600 // removeChild() calls removedFromTree(true) if the child was not in the | 606 // removeChild() calls removedFromTree(true) if the child was not in the |
601 // document. There is no explanation for this discrepancy between remove
Child() | 607 // document. There is no explanation for this discrepancy between remove
Child() |
602 // and its optimized version removeChildren(). | 608 // and its optimized version removeChildren(). |
603 } | 609 } |
604 } | 610 } |
605 | 611 |
606 bool ContainerNode::appendChild(PassRefPtr<Node> newChild, ExceptionCode& ec, bo
ol shouldLazyAttach) | 612 bool ContainerNode::appendChild(PassRefPtr<Node> newChild, ExceptionCode& ec, bo
ol shouldLazyAttach) |
607 { | 613 { |
608 RefPtr<ContainerNode> protector(this); | 614 RefPtr<ContainerNode> protect(this); |
609 | 615 |
610 // Check that this node is not "floating". | 616 // Check that this node is not "floating". |
611 // If it is, it can be deleted as a side effect of sending mutation events. | 617 // If it is, it can be deleted as a side effect of sending mutation events. |
612 ASSERT(refCount() || parentOrHostNode()); | 618 ASSERT(refCount() || parentOrHostNode()); |
613 | 619 |
614 ec = 0; | 620 ec = 0; |
615 | 621 |
616 // Make sure adding the new child is ok | 622 // Make sure adding the new child is ok |
617 checkAddChild(newChild.get(), ec); | 623 checkAddChild(newChild.get(), ec); |
618 if (ec) | 624 if (ec) |
(...skipping 547 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1166 if (!document()->hasListenerType(Document::BEFORELOAD_LISTENER)) | 1172 if (!document()->hasListenerType(Document::BEFORELOAD_LISTENER)) |
1167 return true; | 1173 return true; |
1168 | 1174 |
1169 RefPtr<ContainerNode> protector(this); | 1175 RefPtr<ContainerNode> protector(this); |
1170 RefPtr<BeforeLoadEvent> beforeLoadEvent = BeforeLoadEvent::create(sourceURL)
; | 1176 RefPtr<BeforeLoadEvent> beforeLoadEvent = BeforeLoadEvent::create(sourceURL)
; |
1171 dispatchEvent(beforeLoadEvent.get()); | 1177 dispatchEvent(beforeLoadEvent.get()); |
1172 return !beforeLoadEvent->defaultPrevented(); | 1178 return !beforeLoadEvent->defaultPrevented(); |
1173 } | 1179 } |
1174 | 1180 |
1175 } // namespace WebCore | 1181 } // namespace WebCore |
OLD | NEW |