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

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

Issue 1000533004: Move implementation of Range::firstNode and Range::pastLastNode to Position (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: 2015-03-13T16:48:34 Created 5 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 | « Source/core/dom/Position.cpp ('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 1396 matching lines...) Expand 10 before | Expand all | Expand 10 after
1407 for (Node* n = firstNode(); n != pastLast; n = NodeTraversal::next(*n)) { 1407 for (Node* n = firstNode(); n != pastLast; n = NodeTraversal::next(*n)) {
1408 if (n->isDocumentTypeNode()) { 1408 if (n->isDocumentTypeNode()) {
1409 exceptionState.throwDOMException(HierarchyRequestError, "The Range c ontains a doctype node."); 1409 exceptionState.throwDOMException(HierarchyRequestError, "The Range c ontains a doctype node.");
1410 return; 1410 return;
1411 } 1411 }
1412 } 1412 }
1413 } 1413 }
1414 1414
1415 Node* Range::firstNode() const 1415 Node* Range::firstNode() const
1416 { 1416 {
1417 if (m_start.container()->offsetInCharacters()) 1417 return startPosition().toOffsetInAnchor().nodeAsRangeFirstNode();
sof 2015/05/05 08:23:23 Is this a meaning-preserving transformation - what
1418 return m_start.container();
1419 if (Node* child = NodeTraversal::childAt(*m_start.container(), m_start.offse t()))
1420 return child;
1421 if (!m_start.offset())
1422 return m_start.container();
1423 return NodeTraversal::nextSkippingChildren(*m_start.container());
1424 } 1418 }
1425 1419
1426 ShadowRoot* Range::shadowRoot() const 1420 ShadowRoot* Range::shadowRoot() const
1427 { 1421 {
1428 return startContainer() ? startContainer()->containingShadowRoot() : nullptr ; 1422 return startContainer() ? startContainer()->containingShadowRoot() : nullptr ;
1429 } 1423 }
1430 1424
1431 Node* Range::pastLastNode() const 1425 Node* Range::pastLastNode() const
1432 { 1426 {
1433 if (m_end.container()->offsetInCharacters()) 1427 return endPosition().toOffsetInAnchor().nodeAsRangePastLastNode();
1434 return NodeTraversal::nextSkippingChildren(*m_end.container());
1435 if (Node* child = NodeTraversal::childAt(*m_end.container(), m_end.offset()) )
1436 return child;
1437 return NodeTraversal::nextSkippingChildren(*m_end.container());
1438 } 1428 }
1439 1429
1440 IntRect Range::boundingBox() const 1430 IntRect Range::boundingBox() const
1441 { 1431 {
1442 IntRect result; 1432 IntRect result;
1443 Vector<IntRect> rects; 1433 Vector<IntRect> rects;
1444 textRects(rects); 1434 textRects(rects);
1445 for (const IntRect& rect : rects) 1435 for (const IntRect& rect : rects)
1446 result.unite(rect); 1436 result.unite(rect);
1447 return result; 1437 return result;
(...skipping 357 matching lines...) Expand 10 before | Expand all | Expand 10 after
1805 1795
1806 void showTree(const blink::Range* range) 1796 void showTree(const blink::Range* range)
1807 { 1797 {
1808 if (range && range->boundaryPointsValid()) { 1798 if (range && range->boundaryPointsValid()) {
1809 range->startContainer()->showTreeAndMark(range->startContainer(), "S", r ange->endContainer(), "E"); 1799 range->startContainer()->showTreeAndMark(range->startContainer(), "S", r ange->endContainer(), "E");
1810 fprintf(stderr, "start offset: %d, end offset: %d\n", range->startOffset (), range->endOffset()); 1800 fprintf(stderr, "start offset: %d, end offset: %d\n", range->startOffset (), range->endOffset());
1811 } 1801 }
1812 } 1802 }
1813 1803
1814 #endif 1804 #endif
OLDNEW
« no previous file with comments | « Source/core/dom/Position.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698