-
Notifications
You must be signed in to change notification settings - Fork 498
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
8319844 : Text/TextFlow.hitTest() is incorrect in RTL orientation #1323
Closed
+1,100
−98
Closed
Changes from 1 commit
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
8d42bd3
Fix rtl text hittest issue
karthikpandelu b23e491
Code review changes
karthikpandelu cd270e1
Code review changes
karthikpandelu 87255aa
Fix multiline text insertion index calculation issue
karthikpandelu b08de73
Review changes
karthikpandelu a58f754
Fix issue with RTL text within LTR text
karthikpandelu 52ee61c
Fix issue with multiline text
karthikpandelu 3012fae
Code review changes
karthikpandelu cc89f12
Inline node issue fix
karthikpandelu 43f1f18
Fix emoji issue
karthikpandelu 8732047
Review comments
karthikpandelu 7228785
Code refactoring
karthikpandelu e381273
Merge branch 'master' into rtl_hittest_issue
karthikpandelu f36199f
Fix repeating text node issue
karthikpandelu 1376441
Simplified approach
karthikpandelu 130587c
Review comments
karthikpandelu 7ef09bf
Add unit test
karthikpandelu File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -503,19 +503,17 @@ public Hit getHitInfo(float x, float y, String text, int textRunStart, int curRu | |
|
||
for (int i = 0; i < runs.length; i++) { | ||
run = runs[i]; | ||
if (run.getStart() != curRunStart) { | ||
if (run.getTextSpan().getText().equals(text) && x > run.getWidth() && (run.getLevel() & 0x01) != 1) { | ||
x -= run.getWidth(); | ||
} | ||
if (run.getStart() != curRunStart && run.getTextSpan().getText().equals(text) && x > run.getWidth()) { | ||
x -= run.getWidth(); | ||
continue; | ||
} | ||
if (run.getTextSpan() != null && run.getTextSpan().getText().equals(text)) { | ||
if ((x > run.getWidth() && (!isMultiRunText || run.getStart() == curRunStart)) || textWidthPrevLine > 0) { | ||
getBounds(run.getTextSpan(), textBounds); | ||
x -= (run.getLocation().x - textBounds.getMinX()); | ||
x -= (runs[0].getLocation().x - textBounds.getMinX()); | ||
} | ||
for (int j = runs.length - 1; j > i; j--) { | ||
if (runs[j].getStart() != curRunStart && runs[j].getTextSpan().getText().equals(text)) { | ||
if (runs[j].getStart() != curRunStart && runs[j].getTextSpan().getText().equals(text) && !runs[j].isLinebreak()) { | ||
ltrIndex += runs[j].getLength(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. runs[j] is repeated 4 times... should it be a local variable? |
||
} | ||
} | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggestion: we are still in the for loop, so perhaps it makes sense to extract
(runs[0].getLocation().x - textBounds.getMinX());
to a variable outside of the loop
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The idea is that outside the loop we don't know if we need to subtract the textBound min x value and the starting location of the first run or not. That is why this is present inside the loop. Once this is done we are breaking out of the loop so this will not get called multiple times.
Let me know if you have any suggestions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you are right: I missed the
break
in line 520