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

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

Issue 181283002: Fixing a crash in InsertListCommand. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Update Created 6 years, 9 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 * (C) 1999 Lars Knoll (knoll@kde.org) 2 * (C) 1999 Lars Knoll (knoll@kde.org)
3 * (C) 2000 Gunnstein Lye (gunnstein@netcom.no) 3 * (C) 2000 Gunnstein Lye (gunnstein@netcom.no)
4 * (C) 2000 Frederik Holljen (frederik.holljen@hig.no) 4 * (C) 2000 Frederik Holljen (frederik.holljen@hig.no)
5 * (C) 2001 Peter Kelly (pmk@post.com) 5 * (C) 2001 Peter Kelly (pmk@post.com)
6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All r ights reserved. 6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All r ights reserved.
7 * Copyright (C) 2011 Motorola Mobility. All rights reserved. 7 * Copyright (C) 2011 Motorola Mobility. All rights reserved.
8 * 8 *
9 * This library is free software; you can redistribute it and/or 9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Library General Public 10 * modify it under the terms of the GNU Library General Public
(...skipping 883 matching lines...) Expand 10 before | Expand all | Expand 10 after
894 894
895 NodeVector nodes; 895 NodeVector nodes;
896 for (Node* child = firstChildInAncestorToProcess.get(); child; 896 for (Node* child = firstChildInAncestorToProcess.get(); child;
897 child = (direction == ProcessContentsForward) ? child->nextSibling() : child->previousSibling()) 897 child = (direction == ProcessContentsForward) ? child->nextSibling() : child->previousSibling())
898 nodes.append(child); 898 nodes.append(child);
899 899
900 for (NodeVector::const_iterator it = nodes.begin(); it != nodes.end(); + +it) { 900 for (NodeVector::const_iterator it = nodes.begin(); it != nodes.end(); + +it) {
901 Node* child = it->get(); 901 Node* child = it->get();
902 switch (action) { 902 switch (action) {
903 case DELETE_CONTENTS: 903 case DELETE_CONTENTS:
904 ancestor->removeChild(child, exceptionState); 904 // Prior call of ancestor->removeChild() may cause a tree change due to DOMSubtreeModified event.
905 // Therefore, we need to make sure |ancestor| is still |child|'s parent.
906 if (ancestor == child->parentNode())
907 ancestor->removeChild(child, exceptionState);
905 break; 908 break;
906 case EXTRACT_CONTENTS: // will remove child from ancestor 909 case EXTRACT_CONTENTS: // will remove child from ancestor
907 if (direction == ProcessContentsForward) 910 if (direction == ProcessContentsForward)
908 clonedContainer->appendChild(child, exceptionState); 911 clonedContainer->appendChild(child, exceptionState);
909 else 912 else
910 clonedContainer->insertBefore(child, clonedContainer->firstC hild(), exceptionState); 913 clonedContainer->insertBefore(child, clonedContainer->firstC hild(), exceptionState);
911 break; 914 break;
912 case CLONE_CONTENTS: 915 case CLONE_CONTENTS:
913 if (direction == ProcessContentsForward) 916 if (direction == ProcessContentsForward)
914 clonedContainer->appendChild(child->cloneNode(true), excepti onState); 917 clonedContainer->appendChild(child->cloneNode(true), excepti onState);
(...skipping 971 matching lines...) Expand 10 before | Expand all | Expand 10 after
1886 1889
1887 void showTree(const WebCore::Range* range) 1890 void showTree(const WebCore::Range* range)
1888 { 1891 {
1889 if (range && range->boundaryPointsValid()) { 1892 if (range && range->boundaryPointsValid()) {
1890 range->startContainer()->showTreeAndMark(range->startContainer(), "S", r ange->endContainer(), "E"); 1893 range->startContainer()->showTreeAndMark(range->startContainer(), "S", r ange->endContainer(), "E");
1891 fprintf(stderr, "start offset: %d, end offset: %d\n", range->startOffset (), range->endOffset()); 1894 fprintf(stderr, "start offset: %d, end offset: %d\n", range->startOffset (), range->endOffset());
1892 } 1895 }
1893 } 1896 }
1894 1897
1895 #endif 1898 #endif
OLDNEW
« no previous file with comments | « LayoutTests/editing/execCommand/insert-ordered-list-crash-expected.txt ('k') | Source/core/editing/InsertListCommand.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698