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

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

Issue 95493004: Editing - Code refactoring to avoid several calls to rendererIsEditable() in loop (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@bgColorIssue
Patch Set: Created 7 years 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 | « no previous file | 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 * 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 1092 matching lines...) Expand 10 before | Expand all | Expand 10 after
1103 return positionBeforeNode(startNode); 1103 return positionBeforeNode(startNode);
1104 1104
1105 Node* startBlock = enclosingBlock(startNode); 1105 Node* startBlock = enclosingBlock(startNode);
1106 1106
1107 Node* node = startNode; 1107 Node* node = startNode;
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 bool editable = startNode->rendererIsEditable();
ojan 2013/12/04 20:47:41 How about calling this variable startNodeIsEditabl
1113 while (n) { 1114 while (n) {
1114 if (boundaryCrossingRule == CannotCrossEditingBoundary && !Position::nod eIsUserSelectAll(n) && n->rendererIsEditable() != startNode->rendererIsEditable( )) 1115 if (boundaryCrossingRule == CannotCrossEditingBoundary && !Position::nod eIsUserSelectAll(n) && n->rendererIsEditable() != editable)
1115 break; 1116 break;
1116 if (boundaryCrossingRule == CanSkipOverEditingBoundary) { 1117 if (boundaryCrossingRule == CanSkipOverEditingBoundary) {
1117 while (n && n->rendererIsEditable() != startNode->rendererIsEditable ()) 1118 while (n && n->rendererIsEditable() != editable)
1118 n = NodeTraversal::previousPostOrder(*n, startBlock); 1119 n = NodeTraversal::previousPostOrder(*n, startBlock);
1119 if (!n || !n->isDescendantOf(highestRoot)) 1120 if (!n || !n->isDescendantOf(highestRoot))
1120 break; 1121 break;
1121 } 1122 }
1122 RenderObject* r = n->renderer(); 1123 RenderObject* r = n->renderer();
1123 if (!r) { 1124 if (!r) {
1124 n = NodeTraversal::previousPostOrder(*n, startBlock); 1125 n = NodeTraversal::previousPostOrder(*n, startBlock);
1125 continue; 1126 continue;
1126 } 1127 }
1127 RenderStyle* style = r->style(); 1128 RenderStyle* style = r->style();
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
1180 1181
1181 Node* startBlock = enclosingBlock(startNode); 1182 Node* startBlock = enclosingBlock(startNode);
1182 Node* stayInsideBlock = startBlock; 1183 Node* stayInsideBlock = startBlock;
1183 1184
1184 Node* node = startNode; 1185 Node* node = startNode;
1185 Node* highestRoot = highestEditableRoot(p); 1186 Node* highestRoot = highestEditableRoot(p);
1186 int offset = p.deprecatedEditingOffset(); 1187 int offset = p.deprecatedEditingOffset();
1187 Position::AnchorType type = p.anchorType(); 1188 Position::AnchorType type = p.anchorType();
1188 1189
1189 Node* n = startNode; 1190 Node* n = startNode;
1191 bool editable = startNode->rendererIsEditable();
ojan 2013/12/04 20:47:41 ditto
1190 while (n) { 1192 while (n) {
1191 if (boundaryCrossingRule == CannotCrossEditingBoundary && !Position::nod eIsUserSelectAll(n) && n->rendererIsEditable() != startNode->rendererIsEditable( )) 1193 if (boundaryCrossingRule == CannotCrossEditingBoundary && !Position::nod eIsUserSelectAll(n) && n->rendererIsEditable() != editable)
1192 break; 1194 break;
1193 if (boundaryCrossingRule == CanSkipOverEditingBoundary) { 1195 if (boundaryCrossingRule == CanSkipOverEditingBoundary) {
1194 while (n && n->rendererIsEditable() != startNode->rendererIsEditable ()) 1196 while (n && n->rendererIsEditable() != editable)
1195 n = NodeTraversal::next(*n, stayInsideBlock); 1197 n = NodeTraversal::next(*n, stayInsideBlock);
1196 if (!n || !n->isDescendantOf(highestRoot)) 1198 if (!n || !n->isDescendantOf(highestRoot))
1197 break; 1199 break;
1198 } 1200 }
1199 1201
1200 RenderObject* r = n->renderer(); 1202 RenderObject* r = n->renderer();
1201 if (!r) { 1203 if (!r) {
1202 n = NodeTraversal::next(*n, stayInsideBlock); 1204 n = NodeTraversal::next(*n, stayInsideBlock);
1203 continue; 1205 continue;
1204 } 1206 }
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after
1410 { 1412 {
1411 return direction == LTR ? logicalStartOfLine(c) : logicalEndOfLine(c); 1413 return direction == LTR ? logicalStartOfLine(c) : logicalEndOfLine(c);
1412 } 1414 }
1413 1415
1414 VisiblePosition rightBoundaryOfLine(const VisiblePosition& c, TextDirection dire ction) 1416 VisiblePosition rightBoundaryOfLine(const VisiblePosition& c, TextDirection dire ction)
1415 { 1417 {
1416 return direction == LTR ? logicalEndOfLine(c) : logicalStartOfLine(c); 1418 return direction == LTR ? logicalEndOfLine(c) : logicalStartOfLine(c);
1417 } 1419 }
1418 1420
1419 } 1421 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698