Chromium Code Reviews| Index: Source/core/dom/Position.cpp |
| diff --git a/Source/core/dom/Position.cpp b/Source/core/dom/Position.cpp |
| index 64f8730cc6f540937921deecae0cba42dc7c9d30..76324f6f02c07cedb10e9c51750b0b272049b719 100644 |
| --- a/Source/core/dom/Position.cpp |
| +++ b/Source/core/dom/Position.cpp |
| @@ -79,6 +79,14 @@ static Node* previousRenderedEditable(Node* node) |
| return 0; |
| } |
| +static bool isTextDirectionAuto(Node *node) |
|
leviw_travelin_and_unemployed
2014/05/29 16:32:18
This is asking to be misused. This function doesn'
|
| +{ |
| + bool isAuto = false; |
| + 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
|
| + toHTMLElement(node->document().focusedElement())->directionalityIfhasDirAutoAttribute(isAuto); |
| + return isAuto; |
| +} |
| + |
| Position::Position(PassRefPtr<Node> anchorNode, LegacyEditingOffset offset) |
| : m_anchorNode(anchorNode) |
| , m_offset(offset.value()) |
| @@ -1260,7 +1268,10 @@ void Position::getInlineBoxAndOffset(EAffinity affinity, TextDirection primaryDi |
| break; |
| inlineBox = prevBox; |
| } |
| - caretOffset = inlineBox->caretLeftmostOffset(); |
| + if (isTextDirectionAuto(m_anchorNode.get())) |
| + caretOffset = (inlineBox->bidiLevel() < level) ? inlineBox->caretLeftmostOffset() : inlineBox->caretRightmostOffset(); |
| + else |
| + caretOffset = inlineBox->caretLeftmostOffset(); |
| } else if (nextBox->bidiLevel() > level) { |
| // Left edge of a "tertiary" run. Set to the right edge of that run. |
| while (InlineBox* tertiaryBox = inlineBox->nextLeafChildIgnoringLineBreak()) { |