| OLD | NEW |
| 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 1106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1117 } | 1117 } |
| 1118 LayoutStyle* style = r->style(); | 1118 LayoutStyle* style = r->style(); |
| 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() && toLayoutText(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 LayoutText* text = toLayoutText(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 } |
| 1141 node = n; | 1141 node = n; |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1197 LayoutStyle* style = r->style(); | 1197 LayoutStyle* style = r->style(); |
| 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() && toLayoutText(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 = toLayoutText(r)->textLength(); |
| 1210 type = Position::PositionIsOffsetInAnchor; | 1210 type = Position::PositionIsOffsetInAnchor; |
| 1211 if (style->preserveNewline()) { | 1211 if (style->preserveNewline()) { |
| 1212 RenderText* text = toRenderText(r); | 1212 LayoutText* text = toLayoutText(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); |
| 1222 } else if (editingIgnoresContent(n) || isRenderedTableElement(n)) { | 1222 } else if (editingIgnoresContent(n) || isRenderedTableElement(n)) { |
| (...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 } |
| OLD | NEW |