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

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

Issue 23071006: Make Range::selectNode() and Range::surroundContents() to work with detached node (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: 2013-08-22T16:53:38 Created 7 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/dom/Range/surroundContents-for-detached-node-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 1308 matching lines...) Expand 10 before | Expand all | Expand 10 after
1319 break; 1319 break;
1320 case Node::ATTRIBUTE_NODE: 1320 case Node::ATTRIBUTE_NODE:
1321 case Node::DOCUMENT_FRAGMENT_NODE: 1321 case Node::DOCUMENT_FRAGMENT_NODE:
1322 case Node::DOCUMENT_NODE: 1322 case Node::DOCUMENT_NODE:
1323 case Node::ENTITY_NODE: 1323 case Node::ENTITY_NODE:
1324 case Node::NOTATION_NODE: 1324 case Node::NOTATION_NODE:
1325 es.throwDOMException(InvalidNodeTypeError); 1325 es.throwDOMException(InvalidNodeTypeError);
1326 return; 1326 return;
1327 } 1327 }
1328 1328
1329 if (!refNode->parentNode()) {
1330 es.throwDOMException(InvalidNodeTypeError);
Mike West 2013/08/22 08:17:11 1. Perhaps you could move this up above the for lo
yosin_UTC9 2013/08/22 09:48:44 Done.
1331 return;
1332 }
1333
1329 if (m_ownerDocument != refNode->document()) 1334 if (m_ownerDocument != refNode->document())
1330 setDocument(refNode->document()); 1335 setDocument(refNode->document());
1331 1336
1332 setStartBefore(refNode, es); 1337 setStart(refNode->parentNode(), refNode->nodeIndex(), es);
Mike West 2013/08/22 08:17:11 Can this throw an exception, given the node-type c
yosin_UTC9 2013/08/22 09:48:44 Done.
Mike West 2013/08/22 10:23:47 This was an honest question. I don't think it can
1333 if (es.hadException()) 1338 if (es.hadException())
1334 return; 1339 return;
1335 setEndAfter(refNode, es); 1340 setEnd(refNode->parentNode(), refNode->nodeIndex() + 1, es);
Mike West 2013/08/22 08:17:11 Same here.
yosin_UTC9 2013/08/22 09:48:44 Done.
1336 } 1341 }
1337 1342
1338 void Range::selectNodeContents(Node* refNode, ExceptionState& es) 1343 void Range::selectNodeContents(Node* refNode, ExceptionState& es)
1339 { 1344 {
1340 if (!m_start.container()) { 1345 if (!m_start.container()) {
1341 es.throwDOMException(InvalidStateError); 1346 es.throwDOMException(InvalidStateError);
1342 return; 1347 return;
1343 } 1348 }
1344 1349
1345 if (!refNode) { 1350 if (!refNode) {
(...skipping 570 matching lines...) Expand 10 before | Expand all | Expand 10 after
1916 1921
1917 void showTree(const WebCore::Range* range) 1922 void showTree(const WebCore::Range* range)
1918 { 1923 {
1919 if (range && range->boundaryPointsValid()) { 1924 if (range && range->boundaryPointsValid()) {
1920 range->startContainer()->showTreeAndMark(range->startContainer(), "S", r ange->endContainer(), "E"); 1925 range->startContainer()->showTreeAndMark(range->startContainer(), "S", r ange->endContainer(), "E");
1921 fprintf(stderr, "start offset: %d, end offset: %d\n", range->startOffset (), range->endOffset()); 1926 fprintf(stderr, "start offset: %d, end offset: %d\n", range->startOffset (), range->endOffset());
1922 } 1927 }
1923 } 1928 }
1924 1929
1925 #endif 1930 #endif
OLDNEW
« no previous file with comments | « LayoutTests/fast/dom/Range/surroundContents-for-detached-node-expected.txt ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698