8374822: Platform media query#2193
Conversation
|
👋 Welcome back mstrauss! A progress list of the required criteria for merging this PR into |
|
@mstr2 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 5 new commits pushed to the
As there are no conflicts, your changes will automatically be rebased on top of these commits when integrating. If you prefer to avoid this automatic rebasing, please check the documentation for the /integrate command for further details. ➡️ To integrate this PR with the above commit message to the |
|
@mstr2 has indicated that a compatibility and specification (CSR) request is needed for this pull request. @mstr2 please create a CSR request for issue JDK-8374822 with the correct fix version. This pull request cannot be integrated until the CSR request is approved. |
Webrevs
|
Maran23
left a comment
There was a problem hiding this comment.
Looks good and the logic is very similar to the previous ConditionalFeature PR: #2161
I also like the change that the DEFAULT variable is not public anymore (I commented on that back in the Conditional stylesheet imports PR: #2031 (comment)).
Conceptually, it is a bit strange to have unix as a standalone platform. It seems to include the Linux and Solaris platform when looking into PlatformUtil. But not Mac, which is also a Unix platform and even Unix certified AFAIK.
So that might be something we should have a look at before baking it into the new -fx-platform API. If Solaris is not important anymore, we could probably replace isUnix with isLinux (only used 2 times in prod code).
You're right, let's remove "unix" for now because its semantics are unclear. It's not even used in CSS, and we can always add it later if we see the need to do so. |
|
I am not using these features, preferring to build stylesheets programmatically, so please forgive my silly question: Should the platform media query be tied to a particular look and feel instead of the hardware platform? While it makes sense in many areas to have things like |
Good question. I think that themes shouldn't excessively change styles based on the platform, because that's a very broad category. On the web, you'll see a trend of moving to finer-grained capabilities (for example, In an earlier revision of this media query, I've had sub-categories like |
| </tr> | ||
| <tr> | ||
| <td class="value nowrap">-fx-platform</td> | ||
| <td class="value">android | embedded | headless | ios | linux | macos | windows</td> |
There was a problem hiding this comment.
what does embedded mean in this context?
is an embedded linux a linux or embedded?
maybe just remove it, like unix?
There was a problem hiding this comment.
The problem is that a stylesheet is loaded when embedded is true.
So it is needed to replace that. As far as I understand, embedded is like headless, a platform that can be used together with e.g. linux. You could just set the system property (like we do for our headless tests) and it will match the platform.
I agree with your point. However, I think it's worth noting that on the desktop side, there are legitimate use cases beyond refining Modena and Caspian for the platform media query. The distinction here is that browsers already provide the native look and feel (header bar, window controls), and the website lives inside the browser. I'm not aware of a common use case where websites aim to look different on each OS (And unstyled HTML also usually does not match the native look and feel). And there are already community projects with such themes, one example is JMetro. So I think the use case for platform queries is valid and will make it easy to change some CSS variables or things like the |
|
I've decided to remove both Of course, as @Maran23 pointed out, the current themes do switch stylesheets based on whatever "embedded" means. However, the "embedded" stylesheet does nothing more than remove I think that we should instead add the update media query for this purpose, which matches |
andy-goryachev-oracle
left a comment
There was a problem hiding this comment.
Should there be another, catch-all case where the platform does not fit the linux/macos/windows triad? Solaris, for example?
Also, the CSR will need to be updated, and perhaps it should contain some explanation of the case when the platform does not map to the three defined choices.
Maran23
left a comment
There was a problem hiding this comment.
Looks good.
CSR need to be updated.
I think this should be requirement-driven. If there is a need for another platform like Solaris, someone will likely file an issue or post in the mailing list at one point. |
|
I agree with the sentiment, my question was "what happens". It will not evaluate the |
Ahh got you, yes, it will match none in this case. Similar as for I think thats why Michael said it should not be excessively used. Btw., adding to what I wrote above regarding theming the application based on the OS and this comment, there is actually one usecase in JavaFX where things are different depending of the OS: jfx/modules/javafx.controls/src/main/java/javafx/scene/control/ButtonBar.java Lines 475 to 487 in edf20b5 Which shows how I think @mstr2 unrelated to this PR, do you think the code in |
andy-goryachev-oracle
left a comment
There was a problem hiding this comment.
All the explanations make sense, thanks!
|
I think we can define Calling the feature value The developers of Firefox also chose those semantics with the same rationale: pub enum Platform {
/// Matches any Android version.
Android,
/// For our purposes here, "linux" is just "gtk" (so unix-but-not-mac).
/// There's no need for our front-end code to differentiate between those
/// platforms and they already use the "linux" string elsewhere (e.g.,
/// toolkit/themes/linux).
Linux,
/// Matches any iOS version.
Ios,
/// Matches any macOS version.
Macos,
/// Matches any Windows version.
Windows,
} |
Yes, this looks like a good candidate for the new media query. |
| static Map<String, BooleanSupplier> PLATFORMS = Map.of( | ||
| "android", PlatformUtil::isAndroid, | ||
| "ios", PlatformUtil::isIOS, | ||
| "linux", PlatformUtil::isUnix, // for our purposes, "linux" means "unix but not macOS" |
There was a problem hiding this comment.
I wonder if the GTK aspect is more important here, and also in the cssref.html?
It's not about file path separators or some such, it's about GUI toolkit, isn't it?
There was a problem hiding this comment.
Yes, you're right that the purpose of this media query is not so much technicalities like file separators. I'd say that it is more about the "look and feel" of the OS, and how style themes can adapt to it. In this sense, it also isn't about whether JavaFX uses GTK to show the window, or whether it uses some other way to achieve the same thing.
So it's not about GTK, but then again "linux" is also not a precisely-defined look-and-feel. However, if you conducted a survey, I think you'd find that in actual usage, "linux" does imply a certain look-and-feel, at least to an extent (because most people don't use exotic distros). And that's probably the only utility you'll get out of this particular media query.
andy-goryachev-oracle
left a comment
There was a problem hiding this comment.
Thank you for clarifications! I think is should be clear enough for everyone.
Maran23
left a comment
There was a problem hiding this comment.
Makes sense. Maybe we should rename isUnix to isLinuxOrSolaris or isUnixButNotMac.
Mostly for better readablity in the other code locations, but thats for another PR.
|
/integrate |
|
Going to push as commit 46f2cad.
Your commit was automatically rebased without conflicts. |
Add the
-fx-platformmedia query (similar to-moz-platformin Firefox) that allows applications to switch styles based on the operating system on which the application is running./reviewers 2
/csr
Progress
Issues
Reviewers
Reviewing
Using
gitCheckout this PR locally:
$ git fetch https://git.openjdk.org/jfx.git pull/2193/head:pull/2193$ git checkout pull/2193Update a local copy of the PR:
$ git checkout pull/2193$ git pull https://git.openjdk.org/jfx.git pull/2193/headUsing Skara CLI tools
Checkout this PR locally:
$ git pr checkout 2193View PR using the GUI difftool:
$ git pr show -t 2193Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jfx/pull/2193.diff
Using Webrev
Link to Webrev Comment