Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(609)

Side by Side Diff: third_party/WebKit/Source/core/dom/ContainerNode.cpp

Issue 1555653002: Handle some failing DocumentOrderedMap ID lookups across tree removals. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: add test Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 568 matching lines...) Expand 10 before | Expand all | Expand 10 after
579 willRemoveChild(*child); 579 willRemoveChild(*child);
580 580
581 // Mutation events might have moved this child into a different parent. 581 // Mutation events might have moved this child into a different parent.
582 if (child->parentNode() != this) { 582 if (child->parentNode() != this) {
583 exceptionState.throwDOMException(NotFoundError, "The node to be removed is no longer a child of this node. Perhaps it was moved in response to a mutatio n?"); 583 exceptionState.throwDOMException(NotFoundError, "The node to be removed is no longer a child of this node. Perhaps it was moved in response to a mutatio n?");
584 return nullptr; 584 return nullptr;
585 } 585 }
586 586
587 { 587 {
588 HTMLFrameOwnerElement::UpdateSuspendScope suspendWidgetHierarchyUpdates; 588 HTMLFrameOwnerElement::UpdateSuspendScope suspendWidgetHierarchyUpdates;
589 589 #if ENABLE(ASSERT)
590 TreeScope::RemoveScope treeRemoveScope(this);
esprehn 2016/01/05 07:48:33 DocumentOrderedMap::RemoveScope
591 #endif
590 Node* prev = child->previousSibling(); 592 Node* prev = child->previousSibling();
591 Node* next = child->nextSibling(); 593 Node* next = child->nextSibling();
592 removeBetween(prev, next, *child); 594 removeBetween(prev, next, *child);
593 notifyNodeRemoved(*child); 595 notifyNodeRemoved(*child);
594 childrenChanged(ChildrenChange::forRemoval(*child, prev, next, ChildrenC hangeSourceAPI)); 596 childrenChanged(ChildrenChange::forRemoval(*child, prev, next, ChildrenC hangeSourceAPI));
595 } 597 }
596 dispatchSubtreeModifiedEvent(); 598 dispatchSubtreeModifiedEvent();
597 return child; 599 return child;
598 } 600 }
599 601
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
631 if (oldChild.connectedSubframeCount()) 633 if (oldChild.connectedSubframeCount())
632 ChildFrameDisconnector(oldChild).disconnect(); 634 ChildFrameDisconnector(oldChild).disconnect();
633 635
634 if (oldChild.parentNode() != this) 636 if (oldChild.parentNode() != this)
635 return; 637 return;
636 638
637 ChildListMutationScope(*this).willRemoveChild(oldChild); 639 ChildListMutationScope(*this).willRemoveChild(oldChild);
638 oldChild.notifyMutationObserversNodeWillDetach(); 640 oldChild.notifyMutationObserversNodeWillDetach();
639 641
640 HTMLFrameOwnerElement::UpdateSuspendScope suspendWidgetHierarchyUpdates; 642 HTMLFrameOwnerElement::UpdateSuspendScope suspendWidgetHierarchyUpdates;
643 #if ENABLE(ASSERT)
644 TreeScope::RemoveScope treeRemoveScope(this);
esprehn 2016/01/05 07:48:33 no need to pass anything if you just increment the
645 #endif
641 Node* prev = oldChild.previousSibling(); 646 Node* prev = oldChild.previousSibling();
642 Node* next = oldChild.nextSibling(); 647 Node* next = oldChild.nextSibling();
643 removeBetween(prev, next, oldChild); 648 removeBetween(prev, next, oldChild);
644 649
645 notifyNodeRemoved(oldChild); 650 notifyNodeRemoved(oldChild);
646 childrenChanged(ChildrenChange::forRemoval(oldChild, prev, next, ChildrenCha ngeSourceParser)); 651 childrenChanged(ChildrenChange::forRemoval(oldChild, prev, next, ChildrenCha ngeSourceParser));
647 } 652 }
648 653
649 // This differs from other remove functions because it forcibly removes all the children, 654 // This differs from other remove functions because it forcibly removes all the children,
650 // regardless of read-only status or event exceptions, e.g. 655 // regardless of read-only status or event exceptions, e.g.
(...skipping 27 matching lines...) Expand all
678 #if !ENABLE(OILPAN) 683 #if !ENABLE(OILPAN)
679 // FIXME: Remove this NodeVector. Right now WebPluginContainerImpl::m_elemen t is a 684 // FIXME: Remove this NodeVector. Right now WebPluginContainerImpl::m_elemen t is a
680 // raw ptr which means the code below can drop the last ref to a plugin elem ent and 685 // raw ptr which means the code below can drop the last ref to a plugin elem ent and
681 // then the code in UpdateSuspendScope::performDeferredWidgetTreeOperations will 686 // then the code in UpdateSuspendScope::performDeferredWidgetTreeOperations will
682 // try to destroy the plugin which will be a use-after-free. We should use a RefPtr 687 // try to destroy the plugin which will be a use-after-free. We should use a RefPtr
683 // in the WebPluginContainerImpl instead. 688 // in the WebPluginContainerImpl instead.
684 NodeVector removedChildren; 689 NodeVector removedChildren;
685 #endif 690 #endif
686 { 691 {
687 HTMLFrameOwnerElement::UpdateSuspendScope suspendWidgetHierarchyUpdates; 692 HTMLFrameOwnerElement::UpdateSuspendScope suspendWidgetHierarchyUpdates;
688 693 #if ENABLE(ASSERT)
694 TreeScope::RemoveScope treeRemoveScope(this);
695 #endif
689 { 696 {
690 EventDispatchForbiddenScope assertNoEventDispatch; 697 EventDispatchForbiddenScope assertNoEventDispatch;
691 ScriptForbiddenScope forbidScript; 698 ScriptForbiddenScope forbidScript;
692 699
693 #if !ENABLE(OILPAN) 700 #if !ENABLE(OILPAN)
694 removedChildren.reserveInitialCapacity(countChildren()); 701 removedChildren.reserveInitialCapacity(countChildren());
695 #endif 702 #endif
696 while (RefPtrWillBeRawPtr<Node> child = m_firstChild) { 703 while (RefPtrWillBeRawPtr<Node> child = m_firstChild) {
697 removeBetween(0, child->nextSibling(), *child); 704 removeBetween(0, child->nextSibling(), *child);
698 #if !ENABLE(OILPAN) 705 #if !ENABLE(OILPAN)
(...skipping 835 matching lines...) Expand 10 before | Expand all | Expand 10 after
1534 return true; 1541 return true;
1535 1542
1536 if (node->isElementNode() && toElement(node)->shadow()) 1543 if (node->isElementNode() && toElement(node)->shadow())
1537 return true; 1544 return true;
1538 1545
1539 return false; 1546 return false;
1540 } 1547 }
1541 #endif 1548 #endif
1542 1549
1543 } // namespace blink 1550 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698