RFR: 8090547: Allow for transparent backgrounds in WebView

José Pereda jose.pereda at gluonhq.com
Fri Jul 2 17:05:42 UTC 2021


> * Should the new `WebView` property be a `Color` or should it be a
`Paint`?

WebPage.setBackgroundColor calls:

JNIEXPORT void JNICALL Java_com_sun_webkit_WebPage_twkSetBackgroundColor
(JNIEnv* env, jobject self, jlong pFrame, jint backgroundColor)

which only admits an int value for the background color (the hash value of
the color) that applies as:

frame->view()->setBaseBackgroundColor(...)

so I don't see a way to apply anything different than a plain color (with
any level of opacity) for the whole view.

For that reason, I didn't use Paint, but just Color.

> * You propose to add a new CSS element, `-fx-page-fill`. Do we need it or
can one of the existing elements work (e.g., `-fx-background-color`)? If we
do end up adding a new element, you will need to document it in
`cssref.html`.

If we can't use Paint that also means that we can't use
Background::BACKGROUND_COLOR (and -fx-background-color). That's the reason
I'm proposing this new CSS element.

> * @since 18
Ok, I'll fix that.





On Fri, Jul 2, 2021 at 2:50 PM Kevin Rushforth <kcr at openjdk.java.net> wrote:

> On Fri, 2 Jul 2021 11:01:56 GMT, Jose Pereda <jpereda at openjdk.org> wrote:
>
> > Currently, `WebPage` has already a public `setBackgroundColor()` method,
> but the class is not public. Therefore, public API is needed in `WebView`
> to allow developers access to it.
> >
> > In line with the `fontSmoothingType` property, this PR provides public
> support for setting the background color of a WebPage, by adding a
> `pageFill` property, and a CSR is required.
> >
> > The color for the background, that can be opaque, transparent or with
> any level of opacity, can be set via code or via CSS using `-fx-page-fill`.
> >
> > Unit tests and a system test are provided.
>
> This new API warrants a brief discussion on the mailing list prior to
> review. Some things to think about:
>
> * Should the new `WebView` property be a `Color` or should it be a `Paint`?
>
> * You propose to add a new CSS element, `-fx-page-fill`. Do we need it or
> can one of the existing elements work (e.g., `-fx-background-color`)? If we
> do end up adding a new element, you will need to document it in
> `cssref.html`.
>
> modules/javafx.web/src/main/java/javafx/scene/web/WebView.java line 706:
>
> > 704:      * Default color: White
> > 705:      *
> > 706:      * @since JavaFX 17
>
> We no longer use `JavaFX` in the version for `@since` commands. And  it's
> too late for 17, so this should be:
>
> * @since 18
>
> -------------
>
> PR: https://git.openjdk.java.net/jfx/pull/563
>


--


More information about the openjfx-dev mailing list