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

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

Issue 182383012: Have positionInParentBeforeNode() / positionInParentAfterNode() take a reference (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Rebase Created 6 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 | Annotate | Revision Log
« no previous file with comments | « Source/core/dom/Position.h ('k') | Source/core/dom/PositionIterator.cpp » ('j') | 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 * Copyright (C) 2004, 2005, 2006, 2009 Apple Inc. All rights reserved. 2 * Copyright (C) 2004, 2005, 2006, 2009 Apple Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after
203 // Neighbor-anchored positions are invalid DOM positions, so they need to be 203 // Neighbor-anchored positions are invalid DOM positions, so they need to be
204 // fixed up before handing them off to the Range object. 204 // fixed up before handing them off to the Range object.
205 Position Position::parentAnchoredEquivalent() const 205 Position Position::parentAnchoredEquivalent() const
206 { 206 {
207 if (!m_anchorNode) 207 if (!m_anchorNode)
208 return Position(); 208 return Position();
209 209
210 // FIXME: This should only be necessary for legacy positions, but is also ne eded for positions before and after Tables 210 // FIXME: This should only be necessary for legacy positions, but is also ne eded for positions before and after Tables
211 if (m_offset <= 0 && (m_anchorType != PositionIsAfterAnchor && m_anchorType != PositionIsAfterChildren)) { 211 if (m_offset <= 0 && (m_anchorType != PositionIsAfterAnchor && m_anchorType != PositionIsAfterChildren)) {
212 if (m_anchorNode->parentNode() && (editingIgnoresContent(m_anchorNode.ge t()) || isRenderedTableElement(m_anchorNode.get()))) 212 if (m_anchorNode->parentNode() && (editingIgnoresContent(m_anchorNode.ge t()) || isRenderedTableElement(m_anchorNode.get())))
213 return positionInParentBeforeNode(m_anchorNode.get()); 213 return positionInParentBeforeNode(*m_anchorNode);
214 return Position(m_anchorNode.get(), 0, PositionIsOffsetInAnchor); 214 return Position(m_anchorNode.get(), 0, PositionIsOffsetInAnchor);
215 } 215 }
216 if (!m_anchorNode->offsetInCharacters() 216 if (!m_anchorNode->offsetInCharacters()
217 && (m_anchorType == PositionIsAfterAnchor || m_anchorType == PositionIsA fterChildren || static_cast<unsigned>(m_offset) == m_anchorNode->countChildren() ) 217 && (m_anchorType == PositionIsAfterAnchor || m_anchorType == PositionIsA fterChildren || static_cast<unsigned>(m_offset) == m_anchorNode->countChildren() )
218 && (editingIgnoresContent(m_anchorNode.get()) || isRenderedTableElement( m_anchorNode.get())) 218 && (editingIgnoresContent(m_anchorNode.get()) || isRenderedTableElement( m_anchorNode.get()))
219 && containerNode()) { 219 && containerNode()) {
220 return positionInParentAfterNode(m_anchorNode.get()); 220 return positionInParentAfterNode(*m_anchorNode);
221 } 221 }
222 222
223 return Position(containerNode(), computeOffsetInContainerNode(), PositionIsO ffsetInAnchor); 223 return Position(containerNode(), computeOffsetInContainerNode(), PositionIsO ffsetInAnchor);
224 } 224 }
225 225
226 Node* Position::computeNodeBeforePosition() const 226 Node* Position::computeNodeBeforePosition() const
227 { 227 {
228 if (!m_anchorNode) 228 if (!m_anchorNode)
229 return 0; 229 return 0;
230 230
(...skipping 1156 matching lines...) Expand 10 before | Expand all | Expand 10 after
1387 pos.showTreeForThis(); 1387 pos.showTreeForThis();
1388 } 1388 }
1389 1389
1390 void showTree(const WebCore::Position* pos) 1390 void showTree(const WebCore::Position* pos)
1391 { 1391 {
1392 if (pos) 1392 if (pos)
1393 pos->showTreeForThis(); 1393 pos->showTreeForThis();
1394 } 1394 }
1395 1395
1396 #endif 1396 #endif
OLDNEW
« no previous file with comments | « Source/core/dom/Position.h ('k') | Source/core/dom/PositionIterator.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698