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

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

Issue 69003004: Have NodeTraversal::previous*() take a reference (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: 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/ReplaceSelectionCommand.cpp ('k') | Source/core/html/HTMLCollection.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 1097 matching lines...) Expand 10 before | Expand all | Expand 10 after
1108 Node* highestRoot = highestEditableRoot(p); 1108 Node* highestRoot = highestEditableRoot(p);
1109 int offset = p.deprecatedEditingOffset(); 1109 int offset = p.deprecatedEditingOffset();
1110 Position::AnchorType type = p.anchorType(); 1110 Position::AnchorType type = p.anchorType();
1111 1111
1112 Node* n = startNode; 1112 Node* n = startNode;
1113 while (n) { 1113 while (n) {
1114 if (boundaryCrossingRule == CannotCrossEditingBoundary && !Position::nod eIsUserSelectAll(n) && n->rendererIsEditable() != startNode->rendererIsEditable( )) 1114 if (boundaryCrossingRule == CannotCrossEditingBoundary && !Position::nod eIsUserSelectAll(n) && n->rendererIsEditable() != startNode->rendererIsEditable( ))
1115 break; 1115 break;
1116 if (boundaryCrossingRule == CanSkipOverEditingBoundary) { 1116 if (boundaryCrossingRule == CanSkipOverEditingBoundary) {
1117 while (n && n->rendererIsEditable() != startNode->rendererIsEditable ()) 1117 while (n && n->rendererIsEditable() != startNode->rendererIsEditable ())
1118 n = NodeTraversal::previousPostOrder(n, startBlock); 1118 n = NodeTraversal::previousPostOrder(*n, startBlock);
1119 if (!n || !n->isDescendantOf(highestRoot)) 1119 if (!n || !n->isDescendantOf(highestRoot))
1120 break; 1120 break;
1121 } 1121 }
1122 RenderObject* r = n->renderer(); 1122 RenderObject* r = n->renderer();
1123 if (!r) { 1123 if (!r) {
1124 n = NodeTraversal::previousPostOrder(n, startBlock); 1124 n = NodeTraversal::previousPostOrder(*n, startBlock);
1125 continue; 1125 continue;
1126 } 1126 }
1127 RenderStyle* style = r->style(); 1127 RenderStyle* style = r->style();
1128 if (style->visibility() != VISIBLE) { 1128 if (style->visibility() != VISIBLE) {
1129 n = NodeTraversal::previousPostOrder(n, startBlock); 1129 n = NodeTraversal::previousPostOrder(*n, startBlock);
1130 continue; 1130 continue;
1131 } 1131 }
1132 1132
1133 if (r->isBR() || isBlock(n)) 1133 if (r->isBR() || isBlock(n))
1134 break; 1134 break;
1135 1135
1136 if (r->isText() && toRenderText(r)->renderedTextLength()) { 1136 if (r->isText() && toRenderText(r)->renderedTextLength()) {
1137 ASSERT_WITH_SECURITY_IMPLICATION(n->isTextNode()); 1137 ASSERT_WITH_SECURITY_IMPLICATION(n->isTextNode());
1138 type = Position::PositionIsOffsetInAnchor; 1138 type = Position::PositionIsOffsetInAnchor;
1139 if (style->preserveNewline()) { 1139 if (style->preserveNewline()) {
1140 RenderText* text = toRenderText(r); 1140 RenderText* text = toRenderText(r);
1141 int i = text->textLength(); 1141 int i = text->textLength();
1142 int o = offset; 1142 int o = offset;
1143 if (n == startNode && o < i) 1143 if (n == startNode && o < i)
1144 i = max(0, o); 1144 i = max(0, o);
1145 while (--i >= 0) { 1145 while (--i >= 0) {
1146 if ((*text)[i] == '\n') 1146 if ((*text)[i] == '\n')
1147 return VisiblePosition(Position(toText(n), i + 1), DOWNS TREAM); 1147 return VisiblePosition(Position(toText(n), i + 1), DOWNS TREAM);
1148 } 1148 }
1149 } 1149 }
1150 node = n; 1150 node = n;
1151 offset = 0; 1151 offset = 0;
1152 n = NodeTraversal::previousPostOrder(n, startBlock); 1152 n = NodeTraversal::previousPostOrder(*n, startBlock);
1153 } else if (editingIgnoresContent(n) || isRenderedTable(n)) { 1153 } else if (editingIgnoresContent(n) || isRenderedTable(n)) {
1154 node = n; 1154 node = n;
1155 type = Position::PositionIsBeforeAnchor; 1155 type = Position::PositionIsBeforeAnchor;
1156 n = n->previousSibling() ? n->previousSibling() : NodeTraversal::pre viousPostOrder(n, startBlock); 1156 n = n->previousSibling() ? n->previousSibling() : NodeTraversal::pre viousPostOrder(*n, startBlock);
1157 } else 1157 } else {
1158 n = NodeTraversal::previousPostOrder(n, startBlock); 1158 n = NodeTraversal::previousPostOrder(*n, startBlock);
1159 }
1159 } 1160 }
1160 1161
1161 if (type == Position::PositionIsOffsetInAnchor) { 1162 if (type == Position::PositionIsOffsetInAnchor) {
1162 ASSERT(type == Position::PositionIsOffsetInAnchor || !offset); 1163 ASSERT(type == Position::PositionIsOffsetInAnchor || !offset);
1163 return VisiblePosition(Position(node, offset, type), DOWNSTREAM); 1164 return VisiblePosition(Position(node, offset, type), DOWNSTREAM);
1164 } 1165 }
1165 1166
1166 return VisiblePosition(Position(node, type), DOWNSTREAM); 1167 return VisiblePosition(Position(node, type), DOWNSTREAM);
1167 } 1168 }
1168 1169
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after
1409 { 1410 {
1410 return direction == LTR ? logicalStartOfLine(c) : logicalEndOfLine(c); 1411 return direction == LTR ? logicalStartOfLine(c) : logicalEndOfLine(c);
1411 } 1412 }
1412 1413
1413 VisiblePosition rightBoundaryOfLine(const VisiblePosition& c, TextDirection dire ction) 1414 VisiblePosition rightBoundaryOfLine(const VisiblePosition& c, TextDirection dire ction)
1414 { 1415 {
1415 return direction == LTR ? logicalEndOfLine(c) : logicalStartOfLine(c); 1416 return direction == LTR ? logicalEndOfLine(c) : logicalStartOfLine(c);
1416 } 1417 }
1417 1418
1418 } 1419 }
OLDNEW
« no previous file with comments | « Source/core/editing/ReplaceSelectionCommand.cpp ('k') | Source/core/html/HTMLCollection.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698