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

Unified Diff: third_party/WebKit/Source/core/editing/VisibleUnits.cpp

Issue 2220923002: Make computeInlineBoxPosition() to handle unicode-bidi:isolate correctly (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 2016-08-08T15:03:39 Created 4 years, 4 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
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/editing/VisibleUnitsTest.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/core/editing/VisibleUnits.cpp
diff --git a/third_party/WebKit/Source/core/editing/VisibleUnits.cpp b/third_party/WebKit/Source/core/editing/VisibleUnits.cpp
index b1535f51565e740c6135cfb7437e321e04198236..30dc1f5d6bb8878d5b6727191fe61abb7c8524dd 100644
--- a/third_party/WebKit/Source/core/editing/VisibleUnits.cpp
+++ b/third_party/WebKit/Source/core/editing/VisibleUnits.cpp
@@ -1971,6 +1971,20 @@ PositionTemplate<Strategy> upstreamIgnoringEditingBoundaries(PositionTemplate<St
return position;
}
+// Returns true if |inlineBox| starts different direction of embedded text ru.
+// See [1] for details.
+// [1] UNICODE BIDIRECTIONAL ALGORITHM, http://unicode.org/reports/tr9/
+static bool isStartOfDifferentDirection(const InlineBox* inlineBox)
+{
+ InlineBox* prevBox = inlineBox->prevLeafChild();
+ if (!prevBox)
+ return true;
+ if (prevBox->direction() == inlineBox->direction())
+ return true;
+ DCHECK_NE(prevBox->bidiLevel(), inlineBox->bidiLevel());
+ return prevBox->bidiLevel() > inlineBox->bidiLevel();
+}
+
template <typename Strategy>
static InlineBoxPosition computeInlineBoxPositionTemplate(const PositionTemplate<Strategy>& position, TextAffinity affinity, TextDirection primaryDirection)
{
@@ -2064,11 +2078,10 @@ static InlineBoxPosition computeInlineBoxPositionTemplate(const PositionTemplate
return InlineBoxPosition(inlineBox, inlineBox->caretRightmostOffset());
}
- InlineBox* prevBox = inlineBox->prevLeafChild();
- if (!prevBox || prevBox->bidiLevel() >= level)
+ if (isStartOfDifferentDirection(inlineBox))
return InlineBoxPosition(inlineBox, caretOffset);
- level = prevBox->bidiLevel();
+ level = inlineBox->prevLeafChild()->bidiLevel();
InlineBox* nextBox = inlineBox;
do {
nextBox = nextBox->nextLeafChild();
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/editing/VisibleUnitsTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698