-
Notifications
You must be signed in to change notification settings - Fork 541
8357594: Additional geometry-based Text/TextFlow APIs #1817
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
8357594: Additional geometry-based Text/TextFlow APIs #1817
Conversation
Yes, internally. This PR has been out for quite a while, too. The priority here is not to break the existing applications that might have coded a workaround. We offer a new set of (better named) APIs withe the right behavior, while deprecating (not for removal) the existing ones. Adding a system property seems a worse choice since it will break the apps and force the change. |
Okay... the OpenJFX project states in CONTRIBUTING.md, section "New features / API additions": I'm not sure how "internal" discussions qualify. Oracle is not the only stakeholder in this project.
My question was whether this is an educated guess, or whether this problem is corroborated by data. |
|
Point taken. Posted to the mailing list.
It's an educated guess. |
kevinrushforth
left a comment
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.
I left a couple doc comments inline. I'm left wondering if we should do the same thing in Text that you are doing in TextFlow. Namely, deprecate the following four methods, adding getXxxxx methods as replacements:
- hitTest
- caretShape
- rangeShape
- underlineShape
Unlike TextFlow, there is no functional reason we need to do it. So the question is one of consistency. I note that you are already adding one of the four, getRangeShape (to add the lineSpacing parameter). What do you think?
| /** | ||
| * Maps local point to {@link HitInfo} in the content. | ||
| * <p> | ||
| * NOTE: this method may return incorrect value with non-empty border or padding. |
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 should be more explicit, and say that it will not take border or padding into account.
| * <p> | ||
| * NOTE: this shapes returned do not include line spacing. |
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.
I would remove the "NOTE:", making it a simple statement (and probably no need for the <p> tag), since this is just what the method does.
Question: should this method be deprecated to be consistent with TextFlow?
I am open to suggestions, but currently leaning toward leaving I feel making |
kevinrushforth
left a comment
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 API and docs look good to me now. I left a minor formatting suggestion for the deprecated methods (use @link to point to the replacement methods).
Update the CSR to match, and I'll Review it.
| * @param point the specified point to be tested | ||
| * @return a {@code HitInfo} representing the character index found | ||
| * @since 9 | ||
| * @deprecated replaced by {@code getHitInfo()} |
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.
I recommend @link here.
| * @param leading whether the caret is biased on the leading edge of the character | ||
| * @return an array of {@code PathElement} which can be used to create a {@code Shape} | ||
| * @since 9 | ||
| * @deprecated replaced by {@code getCaretShape()} |
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.
@link (here and in. other deprecated methods).
|
/issue remove 8357594 |
|
@andy-goryachev-oracle |
|
Made https://bugs.openjdk.org/browse/JDK-8357594 to be the main issue, closed https://bugs.openjdk.org/browse/JDK-8341438 as a duplicate of JDK-8357594 . |
kevinrushforth
left a comment
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.
LGTM
| private PathElement[] getRange(int start, int end, int type, boolean accountForInsets, double lineSpacing) { | ||
| double dx; | ||
| double dy; | ||
| if(accountForInsets) { |
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.
Minor: space after if
|
/integrate |
|
@andy-goryachev-oracle Pushed as commit 04c5e40. 💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored. |
Summary
This change adds new methods to the
TextFlowwhich work correctly in the presence of non-empty insets (borders/padding). For backward compatibility, the old buggy methods are getting deprecated (not for removal). Also, adds new methods in Text which provide missing functionality.Problem
A number of methods in
TextFlowfail to return correct values in the presence of non-empty insets (i.e. when either padding or border are set):Additionally, the current API fail to provide strike-through shape, and account for line spacing in the range shape, a problem shared between the
TextFlowand theTextclasses.Solution
The solution is two-fold:
The proposed solution retains the buggy methods for the purposes of backward compatibility in applications which employ the workarounds, while providing new APIs with additional parameters similar to those offered by the new TextLayout API https://bugs.openjdk.org/browse/JDK-8341670
Testing
Additional visualization of the data returned by the new APIs is available in the Monkey Tester using the following branch (in the Text and TextFlow pages):
https://github.com/andy-goryachev-oracle/MonkeyTest/tree/text.insets.corrected
Progress
Issues
Reviewers
Reviewing
Using
gitCheckout this PR locally:
$ git fetch https://git.openjdk.org/jfx.git pull/1817/head:pull/1817$ git checkout pull/1817Update a local copy of the PR:
$ git checkout pull/1817$ git pull https://git.openjdk.org/jfx.git pull/1817/headUsing Skara CLI tools
Checkout this PR locally:
$ git pr checkout 1817View PR using the GUI difftool:
$ git pr show -t 1817Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jfx/pull/1817.diff
Using Webrev
Link to Webrev Comment