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

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

Issue 364293004: CANCEL: Make Range::insertNode to validate new end boundary point before using it (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: 2014-07-04T05:04:32 Created 6 years, 5 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
« no previous file with comments | « LayoutTests/fast/dom/Range/surroundContents-iframe-crash-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 * (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 877 matching lines...) Expand 10 before | Expand all | Expand 10 after
888 EventQueueScope scope; 888 EventQueueScope scope;
889 bool collapsed = m_start == m_end; 889 bool collapsed = m_start == m_end;
890 RefPtrWillBeRawPtr<Node> container = nullptr; 890 RefPtrWillBeRawPtr<Node> container = nullptr;
891 if (startIsText) { 891 if (startIsText) {
892 container = m_start.container(); 892 container = m_start.container();
893 RefPtrWillBeRawPtr<Text> newText = toText(container)->splitText(m_start. offset(), exceptionState); 893 RefPtrWillBeRawPtr<Text> newText = toText(container)->splitText(m_start. offset(), exceptionState);
894 if (exceptionState.hadException()) 894 if (exceptionState.hadException())
895 return; 895 return;
896 896
897 container = m_start.container(); 897 container = m_start.container();
898 // When |newNode| is IFRAME, |newText| can be removed from current
899 // document by "load" event handler.
898 container->parentNode()->insertBefore(newNode.release(), newText.get(), exceptionState); 900 container->parentNode()->insertBefore(newNode.release(), newText.get(), exceptionState);
899 if (exceptionState.hadException()) 901 if (exceptionState.hadException())
900 return; 902 return;
901 903
902 if (collapsed) 904 if (collapsed && newText->parentNode())
903 m_end.setToBeforeChild(*newText); 905 m_end.setToBeforeChild(*newText);
904 } else { 906 } else {
905 RefPtrWillBeRawPtr<Node> lastChild = (newNodeType == Node::DOCUMENT_FRAG MENT_NODE) ? toDocumentFragment(newNode)->lastChild() : newNode.get(); 907 RefPtrWillBeRawPtr<Node> lastChild = (newNodeType == Node::DOCUMENT_FRAG MENT_NODE) ? toDocumentFragment(newNode)->lastChild() : newNode.get();
906 if (lastChild && lastChild == m_start.childBefore()) { 908 if (lastChild && lastChild == m_start.childBefore()) {
907 // The insertion will do nothing, but we need to extend the range to include 909 // The insertion will do nothing, but we need to extend the range to include
908 // the inserted nodes. 910 // the inserted nodes.
909 Node* firstChild = (newNodeType == Node::DOCUMENT_FRAGMENT_NODE) ? t oDocumentFragment(newNode)->firstChild() : newNode.get(); 911 Node* firstChild = (newNodeType == Node::DOCUMENT_FRAGMENT_NODE) ? t oDocumentFragment(newNode)->firstChild() : newNode.get();
910 ASSERT(firstChild); 912 ASSERT(firstChild);
911 m_start.setToBeforeChild(*firstChild); 913 m_start.setToBeforeChild(*firstChild);
912 return; 914 return;
(...skipping 800 matching lines...) Expand 10 before | Expand all | Expand 10 after
1713 1715
1714 void showTree(const WebCore::Range* range) 1716 void showTree(const WebCore::Range* range)
1715 { 1717 {
1716 if (range && range->boundaryPointsValid()) { 1718 if (range && range->boundaryPointsValid()) {
1717 range->startContainer()->showTreeAndMark(range->startContainer(), "S", r ange->endContainer(), "E"); 1719 range->startContainer()->showTreeAndMark(range->startContainer(), "S", r ange->endContainer(), "E");
1718 fprintf(stderr, "start offset: %d, end offset: %d\n", range->startOffset (), range->endOffset()); 1720 fprintf(stderr, "start offset: %d, end offset: %d\n", range->startOffset (), range->endOffset());
1719 } 1721 }
1720 } 1722 }
1721 1723
1722 #endif 1724 #endif
OLDNEW
« no previous file with comments | « LayoutTests/fast/dom/Range/surroundContents-iframe-crash-expected.txt ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698