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

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

Issue 2745533004: Range.surroundContents() should not check node types 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/external/wpt/dom/ranges/Range-surroundContents-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 1362 matching lines...) Expand 10 before | Expand all | Expand 10 after
1373 parentOfNewParent = parentOfNewParent->parentNode(); 1373 parentOfNewParent = parentOfNewParent->parentNode();
1374 1374
1375 if (!parentOfNewParent) { 1375 if (!parentOfNewParent) {
1376 exceptionState.throwDOMException(HierarchyRequestError, 1376 exceptionState.throwDOMException(HierarchyRequestError,
1377 "The container node is a detached " 1377 "The container node is a detached "
1378 "character data node; no parent node is " 1378 "character data node; no parent node is "
1379 "available for insertion."); 1379 "available for insertion.");
1380 return; 1380 return;
1381 } 1381 }
1382 1382
1383 if (!parentOfNewParent->childTypeAllowed(newParent->getNodeType())) {
1384 exceptionState.throwDOMException(HierarchyRequestError,
1385 "The node provided is of type '" +
1386 newParent->nodeName() +
1387 "', which may not be inserted here.");
1388 return;
1389 }
1390
1391 EventQueueScope scope; 1383 EventQueueScope scope;
1392 1384
1385 // 3. Let fragment be the result of extracting context object.
1386 DocumentFragment* fragment = extractContents(exceptionState);
1387 if (exceptionState.hadException())
1388 return;
1389
1393 // 4. If newParent has children, replace all with null within newParent. 1390 // 4. If newParent has children, replace all with null within newParent.
1394 while (Node* n = newParent->firstChild()) { 1391 while (Node* n = newParent->firstChild()) {
1395 toContainerNode(newParent)->removeChild(n, exceptionState); 1392 toContainerNode(newParent)->removeChild(n, exceptionState);
1396 if (exceptionState.hadException()) 1393 if (exceptionState.hadException())
1397 return; 1394 return;
1398 } 1395 }
1399 1396
1400 // 3. Let fragment be the result of extracting context object.
1401 DocumentFragment* fragment = extractContents(exceptionState);
1402 if (exceptionState.hadException())
1403 return;
1404
1405 // 5. If newParent has children, replace all with null within newParent. 1397 // 5. If newParent has children, replace all with null within newParent.
1406 insertNode(newParent, exceptionState); 1398 insertNode(newParent, exceptionState);
1407 if (exceptionState.hadException()) 1399 if (exceptionState.hadException())
1408 return; 1400 return;
1409 1401
1410 // 6. Append fragment to newParent. 1402 // 6. Append fragment to newParent.
1411 newParent->appendChild(fragment, exceptionState); 1403 newParent->appendChild(fragment, exceptionState);
1412 if (exceptionState.hadException()) 1404 if (exceptionState.hadException())
1413 return; 1405 return;
1414 1406
(...skipping 413 matching lines...) Expand 10 before | Expand all | Expand 10 after
1828 .data() 1820 .data()
1829 << "start offset: " << range->startOffset() 1821 << "start offset: " << range->startOffset()
1830 << ", end offset: " << range->endOffset(); 1822 << ", end offset: " << range->endOffset();
1831 } else { 1823 } else {
1832 LOG(INFO) << "Cannot show tree if range is null, or if boundary points are " 1824 LOG(INFO) << "Cannot show tree if range is null, or if boundary points are "
1833 "invalid."; 1825 "invalid.";
1834 } 1826 }
1835 } 1827 }
1836 1828
1837 #endif 1829 #endif
OLDNEW
« no previous file with comments | « third_party/WebKit/LayoutTests/external/wpt/dom/ranges/Range-surroundContents-expected.txt ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698