-
Notifications
You must be signed in to change notification settings - Fork 542
8319844 : Text/TextFlow.hitTest() is incorrect in RTL orientation #1323
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
Changes from all commits
8d42bd3
b23e491
cd270e1
87255aa
b08de73
a58f754
52ee61c
3012fae
cc89f12
43f1f18
8732047
7228785
e381273
f36199f
1376441
130587c
7ef09bf
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1021,27 +1021,33 @@ public final BooleanProperty caretBiasProperty() { | |
| public final HitInfo hitTest(Point2D point) { | ||
| if (point == null) return null; | ||
| TextLayout layout = getTextLayout(); | ||
|
|
||
| double x = point.getX() - getX(); | ||
| double y = point.getY() - getY() + getYRendering(); | ||
| GlyphList[] runs = getRuns(); | ||
| int runIndex = 0; | ||
| if (runs.length != 0) { | ||
| double ptY = localToParent(x, y).getY(); | ||
| while (runIndex < runs.length - 1) { | ||
| if (ptY > runs[runIndex].getLocation().y && ptY < runs[runIndex + 1].getLocation().y) { | ||
| break; | ||
| } | ||
| runIndex++; | ||
| } | ||
|
|
||
| int textRunStart = findFirstRunStart(); | ||
|
|
||
| double px = x; | ||
| double py = y; | ||
|
|
||
| if (isSpan()) { | ||
| Point2D pPoint = localToParent(point); | ||
| px = pPoint.getX(); | ||
| py = pPoint.getY(); | ||
| } | ||
| int textRunStart = 0; | ||
| int curRunStart = 0; | ||
| if (runs.length != 0) { | ||
| textRunStart = ((TextRun) runs[0]).getStart(); | ||
| curRunStart = ((TextRun) runs[runIndex]).getStart(); | ||
| TextLayout.Hit h = layout.getHitInfo((float)px, (float)py); | ||
| return new HitInfo(h.getCharIndex() - textRunStart, h.getInsertionIndex() - textRunStart, h.isLeading()); | ||
| } | ||
|
|
||
| private int findFirstRunStart() { | ||
| int start = Integer.MAX_VALUE; | ||
| for (GlyphList r: getRuns()) { | ||
|
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. the old code had a 0 check for getRuns.length, presumably to avoid the iterator creation. 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.
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. you are right! |
||
| int runStart = ((TextRun) r).getStart(); | ||
| if (runStart < start) { | ||
| start = runStart; | ||
| } | ||
| } | ||
| TextLayout.Hit h = layout.getHitInfo((float)x, (float)y, getText(), textRunStart, curRunStart); | ||
| return new HitInfo(h.getCharIndex(), h.getInsertionIndex(), h.isLeading()); | ||
| return start; | ||
| } | ||
|
|
||
| private PathElement[] getRange(int start, int end, int type) { | ||
|
|
||
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.
any reason why this code uses getClass() != obj.getClass() ?
perhaps a better choice might be the usual pattern
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.
There are long discussions about this, and not really worth going into. They both have their place. Generally, the
getClassversions are easier to get right without violating theequalscontract.instanceofcan be used, to allow comparisons with (trivial) subtypes, but then you must makeequalsfinal. Anything fancier violates the equals contract.