Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(724)

Unified Diff: Source/core/dom/Position.cpp

Issue 302433015: Use correct offset when attribute auto is present (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Position trying to look in multiple level for direction auto Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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()) {

Powered by Google App Engine
This is Rietveld 408576698