RFR: 8090547: Allow for transparent backgrounds in WebView [v4]
Jose Pereda
jpereda at openjdk.java.net
Fri Aug 27 09:29:26 UTC 2021
On Wed, 25 Aug 2021 23:49:10 GMT, Kevin Rushforth <kcr at openjdk.org> wrote:
>> Jose Pereda has updated the pull request incrementally with one additional commit since the last revision:
>>
>> Update cssref.html
>
> modules/javafx.web/src/main/java/javafx/scene/web/WebView.java line 733:
>
>> 731: Color color = get();
>> 732: page.setBackgroundColor(color != null ? color.hashCode() :
>> 733: DEFAULT_PAGE_FILL.hashCode());
>
> This is relying on an undocumented, implementation detail. The current implementation of `Color::hashCode` happens to do what you want, but it is not specified. It seems safer to create a utility method to do this.
Yes, that makes total sense.
In fact, there was also the need to add a new [method](https://github.com/openjdk/jfx/pull/563/files#diff-b80bc720bf639cde38c5197a7619561221abcd34fb9ff7a933f4b932a1f36735R2579) in `WebPage` to read back the color from the int value, so I was thinking that it would be better to add a new method to `WebPage` like:
public void setBackgroundColor(Color backgroundColor) {
int int32Color = WebPage.getBackgroundInt32Color(backgroundColor);
setBackgroundColor(int32Color);
}
private static int getBackgroundInt32Color(Color color) {
// implementation similar to Color::hashCode
}
and from webView we could simply do:
page.setBackgroundColor(color);
Thoughts?
-------------
PR: https://git.openjdk.java.net/jfx/pull/563
More information about the openjfx-dev
mailing list