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

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

Issue 1277793002: parserRemoveChild: Avoid unintended DOM modifications after user script run (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: add tests Created 5 years, 4 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 | Annotate | Revision Log
« no previous file with comments | « LayoutTests/fast/parser/scriptexec-during-parserRemoveChild-expected.txt ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 602 matching lines...) Expand 10 before | Expand all | Expand 10 after
613 oldChild.setParentOrShadowHostNode(nullptr); 613 oldChild.setParentOrShadowHostNode(nullptr);
614 614
615 document().adoptIfNeeded(oldChild); 615 document().adoptIfNeeded(oldChild);
616 } 616 }
617 617
618 void ContainerNode::parserRemoveChild(Node& oldChild) 618 void ContainerNode::parserRemoveChild(Node& oldChild)
619 { 619 {
620 ASSERT(oldChild.parentNode() == this); 620 ASSERT(oldChild.parentNode() == this);
621 ASSERT(!oldChild.isDocumentFragment()); 621 ASSERT(!oldChild.isDocumentFragment());
622 622
623 Node* prev = oldChild.previousSibling(); 623 // This may cause arbitrary Javascript execution via onunload handlers.
624 Node* next = oldChild.nextSibling();
625
626 if (oldChild.connectedSubframeCount()) 624 if (oldChild.connectedSubframeCount())
627 ChildFrameDisconnector(oldChild).disconnect(); 625 ChildFrameDisconnector(oldChild).disconnect();
628 626
627 if (oldChild.parentNode() != this)
628 return;
629
629 ChildListMutationScope(*this).willRemoveChild(oldChild); 630 ChildListMutationScope(*this).willRemoveChild(oldChild);
630 oldChild.notifyMutationObserversNodeWillDetach(); 631 oldChild.notifyMutationObserversNodeWillDetach();
631 632
633 Node* prev = oldChild.previousSibling();
634 Node* next = oldChild.nextSibling();
632 removeBetween(prev, next, oldChild); 635 removeBetween(prev, next, oldChild);
633 636
634 notifyNodeRemoved(oldChild); 637 notifyNodeRemoved(oldChild);
635 childrenChanged(ChildrenChange::forRemoval(oldChild, prev, next, ChildrenCha ngeSourceParser)); 638 childrenChanged(ChildrenChange::forRemoval(oldChild, prev, next, ChildrenCha ngeSourceParser));
636 } 639 }
637 640
638 // This differs from other remove functions because it forcibly removes all the children, 641 // This differs from other remove functions because it forcibly removes all the children,
639 // regardless of read-only status or event exceptions, e.g. 642 // regardless of read-only status or event exceptions, e.g.
640 void ContainerNode::removeChildren(SubtreeModificationAction action) 643 void ContainerNode::removeChildren(SubtreeModificationAction action)
641 { 644 {
(...skipping 869 matching lines...) Expand 10 before | Expand all | Expand 10 after
1511 return true; 1514 return true;
1512 1515
1513 if (node->isElementNode() && toElement(node)->shadow()) 1516 if (node->isElementNode() && toElement(node)->shadow())
1514 return true; 1517 return true;
1515 1518
1516 return false; 1519 return false;
1517 } 1520 }
1518 #endif 1521 #endif
1519 1522
1520 } // namespace blink 1523 } // namespace blink
OLDNEW
« no previous file with comments | « LayoutTests/fast/parser/scriptexec-during-parserRemoveChild-expected.txt ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698