| 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 334 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 345 for (NodeVector::const_iterator it = children.begin(); it != children.end();
it++) { | 345 for (NodeVector::const_iterator it = children.begin(); it != children.end();
it++) { |
| 346 Node* child = it->get(); | 346 Node* child = it->get(); |
| 347 | 347 |
| 348 #if ENABLE(MUTATION_OBSERVERS) | 348 #if ENABLE(MUTATION_OBSERVERS) |
| 349 mutation.willRemoveChild(child); | 349 mutation.willRemoveChild(child); |
| 350 child->notifyMutationObserversNodeWillDetach(); | 350 child->notifyMutationObserversNodeWillDetach(); |
| 351 #endif | 351 #endif |
| 352 | 352 |
| 353 // fire removed from document mutation events. | 353 // fire removed from document mutation events. |
| 354 dispatchChildRemovalEvents(child); | 354 dispatchChildRemovalEvents(child); |
| 355 ChildFrameDisconnector(child).disconnect(); | |
| 356 } | 355 } |
| 356 |
| 357 ChildFrameDisconnector(container, ChildFrameDisconnector::DoNotIncludeRoot).
disconnect(); |
| 357 } | 358 } |
| 358 | 359 |
| 359 void ContainerNode::disconnectDescendantFrames() | 360 void ContainerNode::disconnectDescendantFrames() |
| 360 { | 361 { |
| 361 ChildFrameDisconnector(this).disconnect(); | 362 ChildFrameDisconnector(this).disconnect(); |
| 362 } | 363 } |
| 363 | 364 |
| 364 bool ContainerNode::removeChild(Node* oldChild, ExceptionCode& ec) | 365 bool ContainerNode::removeChild(Node* oldChild, ExceptionCode& ec) |
| 365 { | 366 { |
| 366 // Check that this node is not "floating". | 367 // Check that this node is not "floating". |
| (...skipping 10 matching lines...) Expand all Loading... |
| 377 return false; | 378 return false; |
| 378 } | 379 } |
| 379 | 380 |
| 380 // NOT_FOUND_ERR: Raised if oldChild is not a child of this node. | 381 // NOT_FOUND_ERR: Raised if oldChild is not a child of this node. |
| 381 if (!oldChild || oldChild->parentNode() != this) { | 382 if (!oldChild || oldChild->parentNode() != this) { |
| 382 ec = NOT_FOUND_ERR; | 383 ec = NOT_FOUND_ERR; |
| 383 return false; | 384 return false; |
| 384 } | 385 } |
| 385 | 386 |
| 386 RefPtr<Node> child = oldChild; | 387 RefPtr<Node> child = oldChild; |
| 387 willRemoveChild(child.get()); | |
| 388 | |
| 389 // Mutation events might have moved this child into a different parent. | |
| 390 if (child->parentNode() != this) { | |
| 391 ec = NOT_FOUND_ERR; | |
| 392 return false; | |
| 393 } | |
| 394 | 388 |
| 395 document()->removeFocusedNodeOfSubtree(child.get()); | 389 document()->removeFocusedNodeOfSubtree(child.get()); |
| 396 | 390 |
| 397 #if ENABLE(FULLSCREEN_API) | 391 #if ENABLE(FULLSCREEN_API) |
| 398 document()->removeFullScreenElementOfSubtree(child.get()); | 392 document()->removeFullScreenElementOfSubtree(child.get()); |
| 399 #endif | 393 #endif |
| 400 | 394 |
| 401 // Events fired when blurring currently focused node might have moved this | 395 // Events fired when blurring currently focused node might have moved this |
| 402 // child into a different parent. | 396 // child into a different parent. |
| 403 if (child->parentNode() != this) { | 397 if (child->parentNode() != this) { |
| 404 ec = NOT_FOUND_ERR; | 398 ec = NOT_FOUND_ERR; |
| 405 return false; | 399 return false; |
| 406 } | 400 } |
| 407 | 401 |
| 402 willRemoveChild(child.get()); |
| 403 |
| 404 // Mutation events might have moved this child into a different parent. |
| 405 if (child->parentNode() != this) { |
| 406 ec = NOT_FOUND_ERR; |
| 407 return false; |
| 408 } |
| 409 |
| 408 Node* prev = child->previousSibling(); | 410 Node* prev = child->previousSibling(); |
| 409 Node* next = child->nextSibling(); | 411 Node* next = child->nextSibling(); |
| 410 removeBetween(prev, next, child.get()); | 412 removeBetween(prev, next, child.get()); |
| 411 | 413 |
| 412 childrenChanged(false, prev, next, -1); | 414 childrenChanged(false, prev, next, -1); |
| 413 | 415 |
| 414 ChildNodeRemovalNotifier(this).notify(child.get()); | 416 ChildNodeRemovalNotifier(this).notify(child.get()); |
| 415 dispatchSubtreeModifiedEvent(); | 417 dispatchSubtreeModifiedEvent(); |
| 416 | 418 |
| 417 return child; | 419 return child; |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 463 // this differs from other remove functions because it forcibly removes all the
children, | 465 // this differs from other remove functions because it forcibly removes all the
children, |
| 464 // regardless of read-only status or event exceptions, e.g. | 466 // regardless of read-only status or event exceptions, e.g. |
| 465 void ContainerNode::removeChildren() | 467 void ContainerNode::removeChildren() |
| 466 { | 468 { |
| 467 if (!m_firstChild) | 469 if (!m_firstChild) |
| 468 return; | 470 return; |
| 469 | 471 |
| 470 // The container node can be removed from event handlers. | 472 // The container node can be removed from event handlers. |
| 471 RefPtr<ContainerNode> protect(this); | 473 RefPtr<ContainerNode> protect(this); |
| 472 | 474 |
| 473 // Do any prep work needed before actually starting to detach | |
| 474 // and remove... e.g. stop loading frames, fire unload events. | |
| 475 willRemoveChildren(protect.get()); | |
| 476 | |
| 477 // exclude this node when looking for removed focusedNode since only childre
n will be removed | 475 // exclude this node when looking for removed focusedNode since only childre
n will be removed |
| 478 document()->removeFocusedNodeOfSubtree(this, true); | 476 document()->removeFocusedNodeOfSubtree(this, true); |
| 479 | 477 |
| 480 #if ENABLE(FULLSCREEN_API) | 478 #if ENABLE(FULLSCREEN_API) |
| 481 document()->removeFullScreenElementOfSubtree(this, true); | 479 document()->removeFullScreenElementOfSubtree(this, true); |
| 482 #endif | 480 #endif |
| 483 | 481 |
| 482 // Do any prep work needed before actually starting to detach |
| 483 // and remove... e.g. stop loading frames, fire unload events. |
| 484 willRemoveChildren(protect.get()); |
| 485 |
| 484 forbidEventDispatch(); | 486 forbidEventDispatch(); |
| 485 Vector<RefPtr<Node>, 10> removedChildren; | 487 Vector<RefPtr<Node>, 10> removedChildren; |
| 486 removedChildren.reserveInitialCapacity(childNodeCount()); | 488 removedChildren.reserveInitialCapacity(childNodeCount()); |
| 487 while (RefPtr<Node> n = m_firstChild) { | 489 while (RefPtr<Node> n = m_firstChild) { |
| 488 Node* next = n->nextSibling(); | 490 Node* next = n->nextSibling(); |
| 489 | 491 |
| 490 // Remove the node from the tree before calling detach or removedFromDoc
ument (4427024, 4129744). | 492 // Remove the node from the tree before calling detach or removedFromDoc
ument (4427024, 4129744). |
| 491 // removeChild() does this after calling detach(). There is no explanati
on for | 493 // removeChild() does this after calling detach(). There is no explanati
on for |
| 492 // this discrepancy between removeChild() and its optimized version remo
veChildren(). | 494 // this discrepancy between removeChild() and its optimized version remo
veChildren(). |
| 493 n->setPreviousSibling(0); | 495 n->setPreviousSibling(0); |
| (...skipping 493 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 987 if (shouldLazyAttach) | 989 if (shouldLazyAttach) |
| 988 child->lazyAttach(); | 990 child->lazyAttach(); |
| 989 else | 991 else |
| 990 child->attach(); | 992 child->attach(); |
| 991 } | 993 } |
| 992 | 994 |
| 993 dispatchChildInsertionEvents(child); | 995 dispatchChildInsertionEvents(child); |
| 994 } | 996 } |
| 995 | 997 |
| 996 } // namespace WebCore | 998 } // namespace WebCore |
| OLD | NEW |