Index: Source/core/dom/Position.cpp |
diff --git a/Source/core/dom/Position.cpp b/Source/core/dom/Position.cpp |
index dacff4069ead02e8d5f39e0d2d15bf0d9294ea25..f3189392a0f5bbdef35f8d0ce2a30e93a9fb10a5 100644 |
--- a/Source/core/dom/Position.cpp |
+++ b/Source/core/dom/Position.cpp |
@@ -79,6 +79,21 @@ static Node* previousRenderedEditable(Node* node) |
return 0; |
} |
+static bool hasDirectionAutoAttribute(Node* anchorNode) |
+{ |
+ Node* node = anchorNode; |
+ while (node) { |
+ if (node->selfOrAncestorHasDirAutoAttribute()) |
+ return true; |
+ if (node->isInShadowTree()) { |
leviw_travelin_and_unemployed
2014/06/04 17:16:32
If you're scoping your NodeTraversal to your ancho
Habib Virji
2014/06/05 18:57:53
Ok thanks, i have corrected it.
|
+ if (equalIgnoringCase(node->shadowHost()->fastGetAttribute(dirAttr), "auto")) |
leviw_travelin_and_unemployed
2014/06/04 17:16:32
is fastGetAttribute(dirAttr) == "auto" ever true w
Habib Virji
2014/06/05 18:57:53
@leviw: Yes it does work and satisfy the bug test
leviw_travelin_and_unemployed
2014/06/05 21:14:05
If while walking you come across an ancestor with
Habib Virji
2014/06/06 13:52:31
Done.
Thanks, updated code to check if direction
|
+ return true; |
+ } |
+ node = NodeTraversal::next(*node, anchorNode); |
leviw_travelin_and_unemployed
2014/06/04 17:16:32
Why are you using anchorNode as your container? Th
Habib Virji
2014/06/05 18:57:53
@leviw: i was trying to address, esphern comment a
leviw_travelin_and_unemployed
2014/06/05 21:14:05
I understand what you wanted to address, but this
Habib Virji
2014/06/06 13:52:31
Done. Corrected now.
|
+ } |
+ return false; |
+} |
+ |
Position::Position(PassRefPtrWillBeRawPtr<Node> anchorNode, LegacyEditingOffset offset) |
: m_anchorNode(anchorNode) |
, m_offset(offset.value()) |
@@ -1260,7 +1275,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()) { |