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, 2013 Apple Inc. All rights
reserved. | 5 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2013 Apple Inc. All rights
reserved. |
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 420 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
431 return child; | 431 return child; |
432 } | 432 } |
433 | 433 |
434 void ContainerNode::willRemoveChild(Node& child) | 434 void ContainerNode::willRemoveChild(Node& child) |
435 { | 435 { |
436 ASSERT(child.parentNode() == this); | 436 ASSERT(child.parentNode() == this); |
437 ChildListMutationScope(*this).willRemoveChild(child); | 437 ChildListMutationScope(*this).willRemoveChild(child); |
438 child.notifyMutationObserversNodeWillDetach(); | 438 child.notifyMutationObserversNodeWillDetach(); |
439 dispatchChildRemovalEvents(child); | 439 dispatchChildRemovalEvents(child); |
440 ChildFrameDisconnector(child).disconnect(); | 440 ChildFrameDisconnector(child).disconnect(); |
| 441 if (document() != child.document()) { |
| 442 // |child| was moved another document by DOM mutation event handler. |
| 443 return; |
| 444 } |
441 | 445 |
442 // nodeWillBeRemoved must be run after ChildFrameDisconnector, because Child
FrameDisconnector can run script | 446 // |nodeWillBeRemoved()| must be run after |ChildFrameDisconnector|, because |
443 // which may cause state that is to be invalidated by removing the node. | 447 // |ChildFrameDisconnector| can run script which may cause state that is to |
| 448 // be invalidated by removing the node. |
444 ScriptForbiddenScope scriptForbiddenScope; | 449 ScriptForbiddenScope scriptForbiddenScope; |
445 EventDispatchForbiddenScope assertNoEventDispatch; | 450 EventDispatchForbiddenScope assertNoEventDispatch; |
446 document().nodeWillBeRemoved(child); // e.g. mutation event listener can cre
ate a new range. | 451 // e.g. mutation event listener can create a new range. |
| 452 document().nodeWillBeRemoved(child); |
447 } | 453 } |
448 | 454 |
449 void ContainerNode::willRemoveChildren() | 455 void ContainerNode::willRemoveChildren() |
450 { | 456 { |
451 NodeVector children; | 457 NodeVector children; |
452 getChildNodes(*this, children); | 458 getChildNodes(*this, children); |
453 | 459 |
454 ChildListMutationScope mutation(*this); | 460 ChildListMutationScope mutation(*this); |
455 for (const auto& node : children) { | 461 for (const auto& node : children) { |
456 ASSERT(node); | 462 ASSERT(node); |
(...skipping 1060 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1517 return true; | 1523 return true; |
1518 | 1524 |
1519 if (node->isElementNode() && toElement(node)->shadow()) | 1525 if (node->isElementNode() && toElement(node)->shadow()) |
1520 return true; | 1526 return true; |
1521 | 1527 |
1522 return false; | 1528 return false; |
1523 } | 1529 } |
1524 #endif | 1530 #endif |
1525 | 1531 |
1526 } // namespace blink | 1532 } // namespace blink |
OLD | NEW |