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

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

Issue 67473002: Have ElementTraversal / NodeTraversal's next() methods take a reference (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Rebase on master Created 7 years, 1 month 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/editing/TextIterator.cpp ('k') | Source/core/editing/htmlediting.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 Apple Inc. All rights reserv ed. 2 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserv ed.
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 1173 matching lines...) Expand 10 before | Expand all | Expand 10 after
1184 Node* highestRoot = highestEditableRoot(p); 1184 Node* highestRoot = highestEditableRoot(p);
1185 int offset = p.deprecatedEditingOffset(); 1185 int offset = p.deprecatedEditingOffset();
1186 Position::AnchorType type = p.anchorType(); 1186 Position::AnchorType type = p.anchorType();
1187 1187
1188 Node* n = startNode; 1188 Node* n = startNode;
1189 while (n) { 1189 while (n) {
1190 if (boundaryCrossingRule == CannotCrossEditingBoundary && !Position::nod eIsUserSelectAll(n) && n->rendererIsEditable() != startNode->rendererIsEditable( )) 1190 if (boundaryCrossingRule == CannotCrossEditingBoundary && !Position::nod eIsUserSelectAll(n) && n->rendererIsEditable() != startNode->rendererIsEditable( ))
1191 break; 1191 break;
1192 if (boundaryCrossingRule == CanSkipOverEditingBoundary) { 1192 if (boundaryCrossingRule == CanSkipOverEditingBoundary) {
1193 while (n && n->rendererIsEditable() != startNode->rendererIsEditable ()) 1193 while (n && n->rendererIsEditable() != startNode->rendererIsEditable ())
1194 n = NodeTraversal::next(n, stayInsideBlock); 1194 n = NodeTraversal::next(*n, stayInsideBlock);
1195 if (!n || !n->isDescendantOf(highestRoot)) 1195 if (!n || !n->isDescendantOf(highestRoot))
1196 break; 1196 break;
1197 } 1197 }
1198 1198
1199 RenderObject* r = n->renderer(); 1199 RenderObject* r = n->renderer();
1200 if (!r) { 1200 if (!r) {
1201 n = NodeTraversal::next(n, stayInsideBlock); 1201 n = NodeTraversal::next(*n, stayInsideBlock);
1202 continue; 1202 continue;
1203 } 1203 }
1204 RenderStyle* style = r->style(); 1204 RenderStyle* style = r->style();
1205 if (style->visibility() != VISIBLE) { 1205 if (style->visibility() != VISIBLE) {
1206 n = NodeTraversal::next(n, stayInsideBlock); 1206 n = NodeTraversal::next(*n, stayInsideBlock);
1207 continue; 1207 continue;
1208 } 1208 }
1209 1209
1210 if (r->isBR() || isBlock(n)) 1210 if (r->isBR() || isBlock(n))
1211 break; 1211 break;
1212 1212
1213 // FIXME: We avoid returning a position where the renderer can't accept the caret. 1213 // FIXME: We avoid returning a position where the renderer can't accept the caret.
1214 if (r->isText() && toRenderText(r)->renderedTextLength()) { 1214 if (r->isText() && toRenderText(r)->renderedTextLength()) {
1215 ASSERT_WITH_SECURITY_IMPLICATION(n->isTextNode()); 1215 ASSERT_WITH_SECURITY_IMPLICATION(n->isTextNode());
1216 int length = toRenderText(r)->textLength(); 1216 int length = toRenderText(r)->textLength();
1217 type = Position::PositionIsOffsetInAnchor; 1217 type = Position::PositionIsOffsetInAnchor;
1218 if (style->preserveNewline()) { 1218 if (style->preserveNewline()) {
1219 RenderText* text = toRenderText(r); 1219 RenderText* text = toRenderText(r);
1220 int o = n == startNode ? offset : 0; 1220 int o = n == startNode ? offset : 0;
1221 for (int i = o; i < length; ++i) { 1221 for (int i = o; i < length; ++i) {
1222 if ((*text)[i] == '\n') 1222 if ((*text)[i] == '\n')
1223 return VisiblePosition(Position(toText(n), i), DOWNSTREA M); 1223 return VisiblePosition(Position(toText(n), i), DOWNSTREA M);
1224 } 1224 }
1225 } 1225 }
1226 node = n; 1226 node = n;
1227 offset = r->caretMaxOffset(); 1227 offset = r->caretMaxOffset();
1228 n = NodeTraversal::next(n, stayInsideBlock); 1228 n = NodeTraversal::next(*n, stayInsideBlock);
1229 } else if (editingIgnoresContent(n) || isRenderedTable(n)) { 1229 } else if (editingIgnoresContent(n) || isRenderedTable(n)) {
1230 node = n; 1230 node = n;
1231 type = Position::PositionIsAfterAnchor; 1231 type = Position::PositionIsAfterAnchor;
1232 n = NodeTraversal::nextSkippingChildren(n, stayInsideBlock); 1232 n = NodeTraversal::nextSkippingChildren(n, stayInsideBlock);
1233 } else 1233 } else {
1234 n = NodeTraversal::next(n, stayInsideBlock); 1234 n = NodeTraversal::next(*n, stayInsideBlock);
1235 }
1235 } 1236 }
1236 1237
1237 if (type == Position::PositionIsOffsetInAnchor) 1238 if (type == Position::PositionIsOffsetInAnchor)
1238 return VisiblePosition(Position(node, offset, type), DOWNSTREAM); 1239 return VisiblePosition(Position(node, offset, type), DOWNSTREAM);
1239 1240
1240 return VisiblePosition(Position(node, type), DOWNSTREAM); 1241 return VisiblePosition(Position(node, type), DOWNSTREAM);
1241 } 1242 }
1242 1243
1243 // FIXME: isStartOfParagraph(startOfNextParagraph(pos)) is not always true 1244 // FIXME: isStartOfParagraph(startOfNextParagraph(pos)) is not always true
1244 VisiblePosition startOfNextParagraph(const VisiblePosition& visiblePosition) 1245 VisiblePosition startOfNextParagraph(const VisiblePosition& visiblePosition)
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
1408 { 1409 {
1409 return direction == LTR ? logicalStartOfLine(c) : logicalEndOfLine(c); 1410 return direction == LTR ? logicalStartOfLine(c) : logicalEndOfLine(c);
1410 } 1411 }
1411 1412
1412 VisiblePosition rightBoundaryOfLine(const VisiblePosition& c, TextDirection dire ction) 1413 VisiblePosition rightBoundaryOfLine(const VisiblePosition& c, TextDirection dire ction)
1413 { 1414 {
1414 return direction == LTR ? logicalEndOfLine(c) : logicalStartOfLine(c); 1415 return direction == LTR ? logicalEndOfLine(c) : logicalStartOfLine(c);
1415 } 1416 }
1416 1417
1417 } 1418 }
OLDNEW
« no previous file with comments | « Source/core/editing/TextIterator.cpp ('k') | Source/core/editing/htmlediting.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698