Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (C) 2004, 2005, 2006, 2009 Apple Inc. All rights reserved. | 2 * Copyright (C) 2004, 2005, 2006, 2009 Apple Inc. All rights reserved. |
| 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 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 72 if (!renderer) | 72 if (!renderer) |
| 73 continue; | 73 continue; |
| 74 if (!node->rendererIsEditable()) | 74 if (!node->rendererIsEditable()) |
| 75 continue; | 75 continue; |
| 76 if ((renderer->isBox() && toRenderBox(renderer)->inlineBoxWrapper()) || (renderer->isText() && toRenderText(renderer)->firstTextBox())) | 76 if ((renderer->isBox() && toRenderBox(renderer)->inlineBoxWrapper()) || (renderer->isText() && toRenderText(renderer)->firstTextBox())) |
| 77 return node; | 77 return node; |
| 78 } | 78 } |
| 79 return 0; | 79 return 0; |
| 80 } | 80 } |
| 81 | 81 |
| 82 static bool isTextDirectionAuto(Node *node) | |
|
leviw_travelin_and_unemployed
2014/05/29 16:32:18
This is asking to be misused. This function doesn'
| |
| 83 { | |
| 84 bool isAuto = false; | |
| 85 if (node->document().focusedElement()) | |
|
leviw_travelin_and_unemployed
2014/05/29 16:32:18
This just isn't right. getInlineBoxAndOffset shoul
Habib Virji
2014/05/30 16:05:10
On 2014/05/29 16:32:18, leviw wrote:
@leviw: An up
| |
| 86 toHTMLElement(node->document().focusedElement())->directionalityIfhasDir AutoAttribute(isAuto); | |
| 87 return isAuto; | |
| 88 } | |
| 89 | |
| 82 Position::Position(PassRefPtr<Node> anchorNode, LegacyEditingOffset offset) | 90 Position::Position(PassRefPtr<Node> anchorNode, LegacyEditingOffset offset) |
| 83 : m_anchorNode(anchorNode) | 91 : m_anchorNode(anchorNode) |
| 84 , m_offset(offset.value()) | 92 , m_offset(offset.value()) |
| 85 , m_anchorType(anchorTypeForLegacyEditingPosition(m_anchorNode.get(), m_offs et)) | 93 , m_anchorType(anchorTypeForLegacyEditingPosition(m_anchorNode.get(), m_offs et)) |
| 86 , m_isLegacyEditingPosition(true) | 94 , m_isLegacyEditingPosition(true) |
| 87 { | 95 { |
| 88 ASSERT(!m_anchorNode || !m_anchorNode->isPseudoElement()); | 96 ASSERT(!m_anchorNode || !m_anchorNode->isPseudoElement()); |
| 89 } | 97 } |
| 90 | 98 |
| 91 Position::Position(PassRefPtr<Node> anchorNode, AnchorType anchorType) | 99 Position::Position(PassRefPtr<Node> anchorNode, AnchorType anchorType) |
| (...skipping 1161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1253 } | 1261 } |
| 1254 } else { | 1262 } else { |
| 1255 InlineBox* nextBox = inlineBox->nextLeafChildIgnoringLineBreak(); | 1263 InlineBox* nextBox = inlineBox->nextLeafChildIgnoringLineBreak(); |
| 1256 if (!nextBox || nextBox->bidiLevel() < level) { | 1264 if (!nextBox || nextBox->bidiLevel() < level) { |
| 1257 // Right edge of a secondary run. Set to the left edge of the entire run. | 1265 // Right edge of a secondary run. Set to the left edge of the entire run. |
| 1258 while (InlineBox* prevBox = inlineBox->prevLeafChildIgnoringLineBrea k()) { | 1266 while (InlineBox* prevBox = inlineBox->prevLeafChildIgnoringLineBrea k()) { |
| 1259 if (prevBox->bidiLevel() < level) | 1267 if (prevBox->bidiLevel() < level) |
| 1260 break; | 1268 break; |
| 1261 inlineBox = prevBox; | 1269 inlineBox = prevBox; |
| 1262 } | 1270 } |
| 1263 caretOffset = inlineBox->caretLeftmostOffset(); | 1271 if (isTextDirectionAuto(m_anchorNode.get())) |
| 1272 caretOffset = (inlineBox->bidiLevel() < level) ? inlineBox->care tLeftmostOffset() : inlineBox->caretRightmostOffset(); | |
| 1273 else | |
| 1274 caretOffset = inlineBox->caretLeftmostOffset(); | |
| 1264 } else if (nextBox->bidiLevel() > level) { | 1275 } else if (nextBox->bidiLevel() > level) { |
| 1265 // Left edge of a "tertiary" run. Set to the right edge of that run. | 1276 // Left edge of a "tertiary" run. Set to the right edge of that run. |
| 1266 while (InlineBox* tertiaryBox = inlineBox->nextLeafChildIgnoringLine Break()) { | 1277 while (InlineBox* tertiaryBox = inlineBox->nextLeafChildIgnoringLine Break()) { |
| 1267 if (tertiaryBox->bidiLevel() <= level) | 1278 if (tertiaryBox->bidiLevel() <= level) |
| 1268 break; | 1279 break; |
| 1269 inlineBox = tertiaryBox; | 1280 inlineBox = tertiaryBox; |
| 1270 } | 1281 } |
| 1271 caretOffset = inlineBox->caretRightmostOffset(); | 1282 caretOffset = inlineBox->caretRightmostOffset(); |
| 1272 } | 1283 } |
| 1273 } | 1284 } |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1360 pos.showTreeForThis(); | 1371 pos.showTreeForThis(); |
| 1361 } | 1372 } |
| 1362 | 1373 |
| 1363 void showTree(const WebCore::Position* pos) | 1374 void showTree(const WebCore::Position* pos) |
| 1364 { | 1375 { |
| 1365 if (pos) | 1376 if (pos) |
| 1366 pos->showTreeForThis(); | 1377 pos->showTreeForThis(); |
| 1367 } | 1378 } |
| 1368 | 1379 |
| 1369 #endif | 1380 #endif |
| OLD | NEW |