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

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

Issue 2740293002: Range: surroundContents() should not check detached CharacterData node beforehand. (Closed)
Patch Set: Created 3 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
« no previous file with comments | « third_party/WebKit/LayoutTests/fast/dom/Range/31684-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 6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All
7 * rights reserved. 7 * rights reserved.
8 * Copyright (C) 2011 Motorola Mobility. All rights reserved. 8 * Copyright (C) 2011 Motorola Mobility. All rights reserved.
9 * 9 *
10 * This library is free software; you can redistribute it and/or 10 * This library is free software; you can redistribute it and/or
(...skipping 1343 matching lines...) Expand 10 before | Expand all | Expand 10 after
1354 "The node provided is of type '" + newParent->nodeName() + "'."); 1354 "The node provided is of type '" + newParent->nodeName() + "'.");
1355 return; 1355 return;
1356 case Node::kCdataSectionNode: 1356 case Node::kCdataSectionNode:
1357 case Node::kCommentNode: 1357 case Node::kCommentNode:
1358 case Node::kElementNode: 1358 case Node::kElementNode:
1359 case Node::kProcessingInstructionNode: 1359 case Node::kProcessingInstructionNode:
1360 case Node::kTextNode: 1360 case Node::kTextNode:
1361 break; 1361 break;
1362 } 1362 }
1363 1363
1364 // Raise a HierarchyRequestError if m_start.container() doesn't accept
1365 // children like newParent.
1366 Node* parentOfNewParent = m_start.container();
1367
1368 // If m_start.container() is a character data node, it will be split and it
1369 // will be its parent that will need to accept newParent (or in the case of a
1370 // comment, it logically "would" be inserted into the parent, although this
1371 // will fail below for another reason).
1372 if (parentOfNewParent->isCharacterDataNode())
1373 parentOfNewParent = parentOfNewParent->parentNode();
1374
1375 if (!parentOfNewParent) {
1376 exceptionState.throwDOMException(HierarchyRequestError,
1377 "The container node is a detached "
1378 "character data node; no parent node is "
1379 "available for insertion.");
1380 return;
1381 }
1382
1383 EventQueueScope scope; 1364 EventQueueScope scope;
1384 1365
1385 // 3. Let fragment be the result of extracting context object. 1366 // 3. Let fragment be the result of extracting context object.
1386 DocumentFragment* fragment = extractContents(exceptionState); 1367 DocumentFragment* fragment = extractContents(exceptionState);
1387 if (exceptionState.hadException()) 1368 if (exceptionState.hadException())
1388 return; 1369 return;
1389 1370
1390 // 4. If newParent has children, replace all with null within newParent. 1371 // 4. If newParent has children, replace all with null within newParent.
1391 while (Node* n = newParent->firstChild()) { 1372 while (Node* n = newParent->firstChild()) {
1392 toContainerNode(newParent)->removeChild(n, exceptionState); 1373 toContainerNode(newParent)->removeChild(n, exceptionState);
(...skipping 427 matching lines...) Expand 10 before | Expand all | Expand 10 after
1820 .data() 1801 .data()
1821 << "start offset: " << range->startOffset() 1802 << "start offset: " << range->startOffset()
1822 << ", end offset: " << range->endOffset(); 1803 << ", end offset: " << range->endOffset();
1823 } else { 1804 } else {
1824 LOG(INFO) << "Cannot show tree if range is null, or if boundary points are " 1805 LOG(INFO) << "Cannot show tree if range is null, or if boundary points are "
1825 "invalid."; 1806 "invalid.";
1826 } 1807 }
1827 } 1808 }
1828 1809
1829 #endif 1810 #endif
OLDNEW
« no previous file with comments | « third_party/WebKit/LayoutTests/fast/dom/Range/31684-expected.txt ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698