Chromium Code Reviews| Index: Source/core/dom/Position.cpp |
| diff --git a/Source/core/dom/Position.cpp b/Source/core/dom/Position.cpp |
| index dacff4069ead02e8d5f39e0d2d15bf0d9294ea25..288e66d133a4d2b57b60d5d569dd312a479e7a80 100644 |
| --- a/Source/core/dom/Position.cpp |
| +++ b/Source/core/dom/Position.cpp |
| @@ -79,6 +79,20 @@ static Node* previousRenderedEditable(Node* node) |
| return 0; |
| } |
| +static bool hasDirectionAutoAttribute(Node* node) |
| +{ |
| + if (node->selfOrAncestorHasDirAutoAttribute()) |
| + return true; |
| + if (node->isInShadowTree()) { |
| + while (node) { |
| + if (node->isShadowRoot()) |
|
esprehn
2014/06/11 00:58:01
This can just be node->containingShadowRoot() whic
Habib Virji
2014/06/11 08:56:01
Done.
|
| + return node->shadowHost()->selfOrAncestorHasDirAutoAttribute(); |
| + node = node->parentNode(); |
| + } |
| + } |
| + return false; |
| +} |
| + |
| Position::Position(PassRefPtrWillBeRawPtr<Node> anchorNode, LegacyEditingOffset offset) |
| : m_anchorNode(anchorNode) |
| , m_offset(offset.value()) |
| @@ -1260,7 +1274,10 @@ void Position::getInlineBoxAndOffset(EAffinity affinity, TextDirection primaryDi |
| break; |
| inlineBox = prevBox; |
| } |
| - caretOffset = inlineBox->caretLeftmostOffset(); |
| + if (hasDirectionAutoAttribute(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()) { |