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

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

Issue 889563002: Make RenderObject::style() return a const object (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Updated change after Doug's review. Created 5 years, 10 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
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 while (n && n->hasEditableStyle() != startNodeIsEditable) 1108 while (n && n->hasEditableStyle() != startNodeIsEditable)
1109 n = NodeTraversal::previousPostOrder(*n, startBlock); 1109 n = NodeTraversal::previousPostOrder(*n, startBlock);
1110 if (!n || !n->isDescendantOf(highestRoot)) 1110 if (!n || !n->isDescendantOf(highestRoot))
1111 break; 1111 break;
1112 } 1112 }
1113 LayoutObject* r = n->renderer(); 1113 LayoutObject* r = n->renderer();
1114 if (!r) { 1114 if (!r) {
1115 n = NodeTraversal::previousPostOrder(*n, startBlock); 1115 n = NodeTraversal::previousPostOrder(*n, startBlock);
1116 continue; 1116 continue;
1117 } 1117 }
1118 LayoutStyle* style = r->style(); 1118 const LayoutStyle& style = r->styleRef();
1119 if (style->visibility() != VISIBLE) { 1119 if (style.visibility() != VISIBLE) {
1120 n = NodeTraversal::previousPostOrder(*n, startBlock); 1120 n = NodeTraversal::previousPostOrder(*n, startBlock);
1121 continue; 1121 continue;
1122 } 1122 }
1123 1123
1124 if (r->isBR() || isBlock(n)) 1124 if (r->isBR() || isBlock(n))
1125 break; 1125 break;
1126 1126
1127 if (r->isText() && toRenderText(r)->renderedTextLength()) { 1127 if (r->isText() && toRenderText(r)->renderedTextLength()) {
1128 ASSERT_WITH_SECURITY_IMPLICATION(n->isTextNode()); 1128 ASSERT_WITH_SECURITY_IMPLICATION(n->isTextNode());
1129 type = Position::PositionIsOffsetInAnchor; 1129 type = Position::PositionIsOffsetInAnchor;
1130 if (style->preserveNewline()) { 1130 if (style.preserveNewline()) {
1131 RenderText* text = toRenderText(r); 1131 RenderText* text = toRenderText(r);
1132 int i = text->textLength(); 1132 int i = text->textLength();
1133 int o = offset; 1133 int o = offset;
1134 if (n == startNode && o < i) 1134 if (n == startNode && o < i)
1135 i = max(0, o); 1135 i = max(0, o);
1136 while (--i >= 0) { 1136 while (--i >= 0) {
1137 if ((*text)[i] == '\n') 1137 if ((*text)[i] == '\n')
1138 return VisiblePosition(Position(toText(n), i + 1), DOWNS TREAM); 1138 return VisiblePosition(Position(toText(n), i + 1), DOWNS TREAM);
1139 } 1139 }
1140 } 1140 }
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
1187 n = NodeTraversal::next(*n, stayInsideBlock); 1187 n = NodeTraversal::next(*n, stayInsideBlock);
1188 if (!n || !n->isDescendantOf(highestRoot)) 1188 if (!n || !n->isDescendantOf(highestRoot))
1189 break; 1189 break;
1190 } 1190 }
1191 1191
1192 LayoutObject* r = n->renderer(); 1192 LayoutObject* r = n->renderer();
1193 if (!r) { 1193 if (!r) {
1194 n = NodeTraversal::next(*n, stayInsideBlock); 1194 n = NodeTraversal::next(*n, stayInsideBlock);
1195 continue; 1195 continue;
1196 } 1196 }
1197 LayoutStyle* style = r->style(); 1197 const LayoutStyle& style = r->styleRef();
1198 if (style->visibility() != VISIBLE) { 1198 if (style.visibility() != VISIBLE) {
1199 n = NodeTraversal::next(*n, stayInsideBlock); 1199 n = NodeTraversal::next(*n, stayInsideBlock);
1200 continue; 1200 continue;
1201 } 1201 }
1202 1202
1203 if (r->isBR() || isBlock(n)) 1203 if (r->isBR() || isBlock(n))
1204 break; 1204 break;
1205 1205
1206 // FIXME: We avoid returning a position where the renderer can't accept the caret. 1206 // FIXME: We avoid returning a position where the renderer can't accept the caret.
1207 if (r->isText() && toRenderText(r)->renderedTextLength()) { 1207 if (r->isText() && toRenderText(r)->renderedTextLength()) {
1208 ASSERT_WITH_SECURITY_IMPLICATION(n->isTextNode()); 1208 ASSERT_WITH_SECURITY_IMPLICATION(n->isTextNode());
1209 int length = toRenderText(r)->textLength(); 1209 int length = toRenderText(r)->textLength();
1210 type = Position::PositionIsOffsetInAnchor; 1210 type = Position::PositionIsOffsetInAnchor;
1211 if (style->preserveNewline()) { 1211 if (style.preserveNewline()) {
1212 RenderText* text = toRenderText(r); 1212 RenderText* text = toRenderText(r);
1213 int o = n == startNode ? offset : 0; 1213 int o = n == startNode ? offset : 0;
1214 for (int i = o; i < length; ++i) { 1214 for (int i = o; i < length; ++i) {
1215 if ((*text)[i] == '\n') 1215 if ((*text)[i] == '\n')
1216 return VisiblePosition(Position(toText(n), i), DOWNSTREA M); 1216 return VisiblePosition(Position(toText(n), i), DOWNSTREA M);
1217 } 1217 }
1218 } 1218 }
1219 node = n; 1219 node = n;
1220 offset = r->caretMaxOffset(); 1220 offset = r->caretMaxOffset();
1221 n = NodeTraversal::next(*n, stayInsideBlock); 1221 n = NodeTraversal::next(*n, stayInsideBlock);
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after
1406 int caretOffset; 1406 int caretOffset;
1407 position.position().getInlineBoxAndOffset(position.affinity(), inlineBox, ca retOffset); 1407 position.position().getInlineBoxAndOffset(position.affinity(), inlineBox, ca retOffset);
1408 1408
1409 if (inlineBox) 1409 if (inlineBox)
1410 renderer = &inlineBox->renderer(); 1410 renderer = &inlineBox->renderer();
1411 1411
1412 return renderer->localCaretRect(inlineBox, caretOffset); 1412 return renderer->localCaretRect(inlineBox, caretOffset);
1413 } 1413 }
1414 1414
1415 } 1415 }
OLDNEW
« no previous file with comments | « Source/core/editing/SimplifyMarkupCommand.cpp ('k') | Source/core/editing/iterators/TextIterator.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698