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

Side by Side Diff: Source/core/editing/TextIterator.cpp

Issue 189773005: Revert of Have Position deal with more references (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: 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/editing/ReplaceSelectionCommand.cpp ('k') | Source/core/editing/TypingCommand.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, 2007, 2008, 2009, 2010, 2012 Apple Inc. All r ights reserved. 2 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2012 Apple Inc. All r ights reserved.
3 * Copyright (C) 2005 Alexey Proskuryakov. 3 * Copyright (C) 2005 Alexey Proskuryakov.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions 6 * modification, are permitted provided that the following conditions
7 * are met: 7 * are met:
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 965 matching lines...) Expand 10 before | Expand all | Expand 10 after
976 // we would create VisiblePositions on every call to this function without t his check. 976 // we would create VisiblePositions on every call to this function without t his check.
977 if (!m_node->renderer() || m_node->renderer()->style()->visibility() != VISI BLE 977 if (!m_node->renderer() || m_node->renderer()->style()->visibility() != VISI BLE
978 || (m_node->renderer()->isRenderBlockFlow() && !toRenderBlock(m_node->re nderer())->height() && !m_node->hasTagName(bodyTag))) 978 || (m_node->renderer()->isRenderBlockFlow() && !toRenderBlock(m_node->re nderer())->height() && !m_node->hasTagName(bodyTag)))
979 return false; 979 return false;
980 980
981 // The startPos.isNotNull() check is needed because the start could be befor e the body, 981 // The startPos.isNotNull() check is needed because the start could be befor e the body,
982 // and in that case we'll get null. We don't want to put in newlines at the start in that case. 982 // and in that case we'll get null. We don't want to put in newlines at the start in that case.
983 // The currPos.isNotNull() check is needed because positions in non-HTML con tent 983 // The currPos.isNotNull() check is needed because positions in non-HTML con tent
984 // (like SVG) do not have visible positions, and we don't want to emit for t hem either. 984 // (like SVG) do not have visible positions, and we don't want to emit for t hem either.
985 VisiblePosition startPos = VisiblePosition(Position(m_startContainer, m_star tOffset, Position::PositionIsOffsetInAnchor), DOWNSTREAM); 985 VisiblePosition startPos = VisiblePosition(Position(m_startContainer, m_star tOffset, Position::PositionIsOffsetInAnchor), DOWNSTREAM);
986 VisiblePosition currPos = VisiblePosition(positionBeforeNode(*m_node), DOWNS TREAM); 986 VisiblePosition currPos = VisiblePosition(positionBeforeNode(m_node), DOWNST REAM);
987 return startPos.isNotNull() && currPos.isNotNull() && !inSameLine(startPos, currPos); 987 return startPos.isNotNull() && currPos.isNotNull() && !inSameLine(startPos, currPos);
988 } 988 }
989 989
990 bool TextIterator::shouldEmitSpaceBeforeAndAfterNode(Node* node) 990 bool TextIterator::shouldEmitSpaceBeforeAndAfterNode(Node* node)
991 { 991 {
992 return isRenderedTable(node) && (node->renderer()->isInline() || m_emitsChar actersBetweenAllVisiblePositions); 992 return isRenderedTable(node) && (node->renderer()->isInline() || m_emitsChar actersBetweenAllVisiblePositions);
993 } 993 }
994 994
995 void TextIterator::representNodeOffsetZero() 995 void TextIterator::representNodeOffsetZero()
996 { 996 {
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after
1189 if (Node* childAtOffset = startNode->traverseToChildAt(startOffset)) { 1189 if (Node* childAtOffset = startNode->traverseToChildAt(startOffset)) {
1190 startNode = childAtOffset; 1190 startNode = childAtOffset;
1191 startOffset = 0; 1191 startOffset = 0;
1192 } 1192 }
1193 } 1193 }
1194 if (!endNode->offsetInCharacters() && endOffset > 0) { 1194 if (!endNode->offsetInCharacters() && endOffset > 0) {
1195 // traverseToChildAt() will return 0 if the offset is out of range. We r ely on this behavior 1195 // traverseToChildAt() will return 0 if the offset is out of range. We r ely on this behavior
1196 // instead of calling countChildren() to avoid traversing the children t wice. 1196 // instead of calling countChildren() to avoid traversing the children t wice.
1197 if (Node* childAtOffset = endNode->traverseToChildAt(endOffset - 1)) { 1197 if (Node* childAtOffset = endNode->traverseToChildAt(endOffset - 1)) {
1198 endNode = childAtOffset; 1198 endNode = childAtOffset;
1199 endOffset = lastOffsetInNode(*endNode); 1199 endOffset = lastOffsetInNode(endNode);
1200 } 1200 }
1201 } 1201 }
1202 1202
1203 m_node = endNode; 1203 m_node = endNode;
1204 setUpFullyClippedStack(m_fullyClippedStack, m_node); 1204 setUpFullyClippedStack(m_fullyClippedStack, m_node);
1205 m_offset = endOffset; 1205 m_offset = endOffset;
1206 m_handledNode = false; 1206 m_handledNode = false;
1207 m_handledChildren = !endOffset; 1207 m_handledChildren = !endOffset;
1208 1208
1209 m_startNode = startNode; 1209 m_startNode = startNode;
(...skipping 871 matching lines...) Expand 10 before | Expand all | Expand 10 after
2081 if (!matchLength) 2081 if (!matchLength)
2082 return collapsedToBoundary(range, !(options & Backwards)); 2082 return collapsedToBoundary(range, !(options & Backwards));
2083 } 2083 }
2084 2084
2085 // Then, find the document position of the start and the end of the text. 2085 // Then, find the document position of the start and the end of the text.
2086 CharacterIterator computeRangeIterator(range, TextIteratorEntersTextControls | TextIteratorEntersAuthorShadowRoots); 2086 CharacterIterator computeRangeIterator(range, TextIteratorEntersTextControls | TextIteratorEntersAuthorShadowRoots);
2087 return characterSubrange(computeRangeIterator, matchStart, matchLength); 2087 return characterSubrange(computeRangeIterator, matchStart, matchLength);
2088 } 2088 }
2089 2089
2090 } 2090 }
OLDNEW
« no previous file with comments | « Source/core/editing/ReplaceSelectionCommand.cpp ('k') | Source/core/editing/TypingCommand.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698