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

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

Issue 20681004: Make first-letter style to work with editing Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: 2013-09-20T18:27:32 Created 7 years, 3 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 1116 matching lines...) Expand 10 before | Expand all | Expand 10 after
1127 if (style->visibility() != VISIBLE) { 1127 if (style->visibility() != VISIBLE) {
1128 n = NodeTraversal::previousPostOrder(n, startBlock); 1128 n = NodeTraversal::previousPostOrder(n, startBlock);
1129 continue; 1129 continue;
1130 } 1130 }
1131 1131
1132 if (r->isBR() || isBlock(n)) 1132 if (r->isBR() || isBlock(n))
1133 break; 1133 break;
1134 1134
1135 if (r->isText() && toRenderText(r)->renderedTextLength()) { 1135 if (r->isText() && toRenderText(r)->renderedTextLength()) {
1136 ASSERT_WITH_SECURITY_IMPLICATION(n->isTextNode()); 1136 ASSERT_WITH_SECURITY_IMPLICATION(n->isTextNode());
1137 RenderText* text = toRenderText(r);
1137 type = Position::PositionIsOffsetInAnchor; 1138 type = Position::PositionIsOffsetInAnchor;
1138 if (style->preserveNewline()) { 1139 if (style->preserveNewline()) {
1139 RenderText* text = toRenderText(r);
1140 int i = text->textLength(); 1140 int i = text->textLength();
1141 int o = offset; 1141 int o = offset;
1142 if (n == startNode && o < i) 1142 if (n == startNode && o < i)
1143 i = max(0, o); 1143 i = max(0, o);
1144 while (--i >= 0) { 1144 while (--i >= 0) {
1145 if ((*text)[i] == '\n') 1145 if ((*text)[i] == '\n')
1146 return VisiblePosition(Position(toText(n), i + 1), DOWNS TREAM); 1146 return VisiblePosition(Position(toText(n), i + text->tex tStartOffset() + 1), DOWNSTREAM);
1147 } 1147 }
1148 } 1148 }
1149 node = n; 1149 node = n;
1150 offset = 0; 1150 offset = 0;
1151 n = NodeTraversal::previousPostOrder(n, startBlock); 1151 n = NodeTraversal::previousPostOrder(n, startBlock);
1152 } else if (editingIgnoresContent(n) || isTableElement(n)) { 1152 } else if (editingIgnoresContent(n) || isTableElement(n)) {
1153 node = n; 1153 node = n;
1154 type = Position::PositionIsBeforeAnchor; 1154 type = Position::PositionIsBeforeAnchor;
1155 n = n->previousSibling() ? n->previousSibling() : NodeTraversal::pre viousPostOrder(n, startBlock); 1155 n = n->previousSibling() ? n->previousSibling() : NodeTraversal::pre viousPostOrder(n, startBlock);
1156 } else 1156 } else
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
1205 n = NodeTraversal::next(n, stayInsideBlock); 1205 n = NodeTraversal::next(n, stayInsideBlock);
1206 continue; 1206 continue;
1207 } 1207 }
1208 1208
1209 if (r->isBR() || isBlock(n)) 1209 if (r->isBR() || isBlock(n))
1210 break; 1210 break;
1211 1211
1212 // FIXME: We avoid returning a position where the renderer can't accept the caret. 1212 // FIXME: We avoid returning a position where the renderer can't accept the caret.
1213 if (r->isText() && toRenderText(r)->renderedTextLength()) { 1213 if (r->isText() && toRenderText(r)->renderedTextLength()) {
1214 ASSERT_WITH_SECURITY_IMPLICATION(n->isTextNode()); 1214 ASSERT_WITH_SECURITY_IMPLICATION(n->isTextNode());
1215 int length = toRenderText(r)->textLength(); 1215 RenderText* text = toRenderText(r);
1216 int length = text->textLength();
1216 type = Position::PositionIsOffsetInAnchor; 1217 type = Position::PositionIsOffsetInAnchor;
1217 if (style->preserveNewline()) { 1218 if (style->preserveNewline()) {
1218 RenderText* text = toRenderText(r);
1219 int o = n == startNode ? offset : 0; 1219 int o = n == startNode ? offset : 0;
1220 for (int i = o; i < length; ++i) { 1220 for (int i = o; i < length; ++i) {
1221 if ((*text)[i] == '\n') 1221 if ((*text)[i] == '\n')
1222 return VisiblePosition(Position(toText(n), i), DOWNSTREA M); 1222 return VisiblePosition(Position(toText(n), i + text->tex tStartOffset()), DOWNSTREAM);
1223 } 1223 }
1224 } 1224 }
1225 node = n; 1225 node = n;
1226 offset = r->caretMaxOffset(); 1226 offset = r->caretMaxOffset() + text->textStartOffset();
1227 n = NodeTraversal::next(n, stayInsideBlock); 1227 n = NodeTraversal::next(n, stayInsideBlock);
1228 } else if (editingIgnoresContent(n) || isTableElement(n)) { 1228 } else if (editingIgnoresContent(n) || isTableElement(n)) {
1229 node = n; 1229 node = n;
1230 type = Position::PositionIsAfterAnchor; 1230 type = Position::PositionIsAfterAnchor;
1231 n = NodeTraversal::nextSkippingChildren(n, stayInsideBlock); 1231 n = NodeTraversal::nextSkippingChildren(n, stayInsideBlock);
1232 } else 1232 } else
1233 n = NodeTraversal::next(n, stayInsideBlock); 1233 n = NodeTraversal::next(n, stayInsideBlock);
1234 } 1234 }
1235 1235
1236 if (type == Position::PositionIsOffsetInAnchor) 1236 if (type == Position::PositionIsOffsetInAnchor)
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
1407 { 1407 {
1408 return direction == LTR ? logicalStartOfLine(c) : logicalEndOfLine(c); 1408 return direction == LTR ? logicalStartOfLine(c) : logicalEndOfLine(c);
1409 } 1409 }
1410 1410
1411 VisiblePosition rightBoundaryOfLine(const VisiblePosition& c, TextDirection dire ction) 1411 VisiblePosition rightBoundaryOfLine(const VisiblePosition& c, TextDirection dire ction)
1412 { 1412 {
1413 return direction == LTR ? logicalEndOfLine(c) : logicalStartOfLine(c); 1413 return direction == LTR ? logicalEndOfLine(c) : logicalStartOfLine(c);
1414 } 1414 }
1415 1415
1416 } 1416 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698