Summary
Add pageFill property to WebView, allowing setting its background color with any level of opacity.
Problem
WebPage::setBackgroundColor is a public method that allows setting the background color of the WebView, but WebPage has no public access.
Current workarounds make use of reflection to get access to such method, as a first step to set the WebView's background color.
Solution
A new public property can be added to WebView to allow accessing WebPage::setBackgroundColor, in the same line as WebVew::fontSmoothingType property access WebPage::setFontSmoothingType. This property will allow setting the WebView color via code and also via CSS, so a private new styleable property is also required in WebView.
Since the WebKit implementation only supports a single plain color, the property has to use Color and not Paint. The CSS element has to be a new one, and -fx-background-color can't be used.
Specification
The following property and methods are added to WebView:
/**
* Specifies the background color of the web page.
*
* With this property, the WebView control's background
* can have any solid color, including some or complete
* level of transparency.
* However, if the HTML content being loaded set its own
* background color, it will take precedence.
*
* @defaultValue {@code Color.WHITE}
*
* @since 18
*/
private ObjectProperty<Color> pageFill;
public final void setPageFill(Color value);
public final Color getPageFill();
public final ObjectProperty<Color> pageFillProperty();
Including this styleable property (cssref.html) that only applies to WebView:
<tr>
<th class="propertyname" scope="row">-fx-page-fill</th>
<td class="value"><a href="#typecolor" class="typeref"><color></a></td>
<td>white</td>
<td> </td>
</tr>
- csr of
-
JDK-8090547 Allow for transparent backgrounds in WebView
-
- Resolved
-