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
8320359: ImageView: add styleable fitWidth, fitHeight, preserveRatio, smooth properties #1293
8320359: ImageView: add styleable fitWidth, fitHeight, preserveRatio, smooth properties #1293
Conversation
/csr |
👋 Welcome back angorya! A progress list of the required criteria for merging this PR into |
@andy-goryachev-oracle has indicated that a compatibility and specification (CSR) request is needed for this pull request. @andy-goryachev-oracle please create a CSR request for issue JDK-8320359 with the correct fix version. This pull request cannot be integrated until the CSR request is approved. |
* | ||
* @since 22 | ||
*/ | ||
public static List<CssMetaData<? extends Styleable, ?>> initStyleables( |
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 think this enhancement shouldn't be a part of this PR.
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.
created JDK-8320796
Webrevs
|
/** | ||
* Utility methods for dealing with CSS. | ||
*/ | ||
public class CssUtil { |
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 think it's best for utility classes to make it final
and the constructor private
.
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.
this class is not accessible to the outside world, but sure, will do.
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
} | ||
|
||
/** immutable list with random access backed by an array */ | ||
private static class ImmutableArrayList<T> extends AbstractList<T> implements RandomAccess { |
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'd like to point that a skeletal implementation of AbstractList
will perform worse than ArrayList
for any method that needs to walk the list, as the AbstractList
will use iterators for methods like indexOf
, hashCode
and equals
. Now that will probably be irrelevant, but as this seems to be a micro optimization, you should be aware of all the trade offs.
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.
Good point, thanks!
This also applies to UnmodifiableArrayList.
For completeness sake, I wanted to mention a few issues (not in scope for this PR) that came out of the code review:
- could use
UnmodifiableArrayList
but it stores extra int size. perhaps a factory method can be added to it for whensize != elements.length
. - could improve UnmodifiableArrayList with fast(er)
indexOf
,hashCode
,equals
per @hjohn 's comment earlier Control.getCssMetaData()
can be improved to skip merging of two lists if skinBase is null- the same immutable list should be used in
Control.getCssMetaData()
instead ofArrayList()
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 wouldn't do any of the above unless there is a very good reason (and I'm not seeing one). Just use standard List.of
as the last step (or use the Collections.unmodifableList
wrapper); you'll get the most optimized, automatically maintained, bugfree, immutable List
implementation Java has to offer. It means another copy will be made; that's fine, this only happens once -- it's not in a hot path.
If you feel like optimizing something, don't bother with Control.getCssMetaData
either; instead, deduplicate the property lists so there is only one list per unique Skin
+ Control
combo. That saves a complete list per control instance.
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.
Good point, though I would still not use List.of() because of the unnecessary copy.
I agree on Skin
+ Control
copy. Just not sure how... a static hash table perhaps?
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 will approve this as is, but I agree with John that it would be better to use one of the existing implementations of List: new UnmodifiableArrayList
, List.of
, or Collections.unmodifiableList
. The cost of the extra copy for List.of
is in the noise compared to the benefit of not having to maintain yet another special case List class. Similarly, the extra word of data storage in UnmodifiableArrayList
is in the noise. This is a one-per-class not one-per instance list.
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.
Looks good. I left one HTML formatting comment on the newly added cssref.html
docs (I also left an editorial comment that you should feel free to ignore).
I'll reapprove if and when you make the suggested doc formatting change.
<th class="propertyname" scope="row">-fx-image</th> | ||
<th class="propertyname" scope="row">-fx-fit-height</th> | ||
<td class="value"><a href="#typenumber" class="typelink"><number></a></td> | ||
<td>0</td> |
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.
Since you don't specify a style class for the newly added properties, they will all be left justified. The existing null
value for -fx-image
specifies class="default"
which centers it. I recommend either adding the class="default"
to all of the newly added properties, or removing it from the default value of the existing fx-image
property.
I'll reapprove if you want to make the change.
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.
thank you! I am going to add class="default" as it allows for styling of the default column.
Two notes:
- There are a few other places where
class="default"
is omitted (HBox for instance). We may want to fix it in a separate PR. - I don't think the center alignment is the right choice here, I would rather see this column left aligned. Perhaps we should fix the
.default
class as part of the enhancement.
} | ||
|
||
/** immutable list with random access backed by an array */ | ||
private static class ImmutableArrayList<T> extends AbstractList<T> implements RandomAccess { |
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 will approve this as is, but I agree with John that it would be better to use one of the existing implementations of List: new UnmodifiableArrayList
, List.of
, or Collections.unmodifiableList
. The cost of the extra copy for List.of
is in the noise compared to the benefit of not having to maintain yet another special case List class. Similarly, the extra word of data storage in UnmodifiableArrayList
is in the noise. This is a one-per-class not one-per instance list.
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.
Looks good.
Once you update the CSR to match the HTML changes, I'll Review that and you can Finalize it.
updated already |
@andy-goryachev-oracle This change now passes all automated pre-integration checks. ℹ️ This project also has non-automated pre-integration requirements. Please see the file CONTRIBUTING.md for details. After integration, the commit message for the final commit will be:
You can use pull request commands such as /summary, /contributor and /issue to adjust it as needed. At the time when this comment was updated there had been 3 new commits pushed to the
Please see this link for an up-to-date comparison between the source branch of this pull request and the ➡️ To integrate this PR with the above commit message to the |
/integrate |
Going to push as commit aedc887.
Your commit was automatically rebased without conflicts. |
@andy-goryachev-oracle Pushed as commit aedc887. 💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored. |
Adding missing styleable properties to ImageView:
Updated CSS Reference.
Progress
Issues
Reviewers
Reviewing
Using
git
Checkout this PR locally:
$ git fetch https://git.openjdk.org/jfx.git pull/1293/head:pull/1293
$ git checkout pull/1293
Update a local copy of the PR:
$ git checkout pull/1293
$ git pull https://git.openjdk.org/jfx.git pull/1293/head
Using Skara CLI tools
Checkout this PR locally:
$ git pr checkout 1293
View PR using the GUI difftool:
$ git pr show -t 1293
Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jfx/pull/1293.diff
Webrev
Link to Webrev Comment