On 21-Feb-19 9:21 PM, Shashidhara Veerabhadraiah wrote:
Hi Prashanta, Thank you for pointing that information. It was useful. But then
again what we actually use is CSS-1, not CSS-2 and here is the link per
CSS.java: http://www.w3.org/TR/REC-CSS1. So for the color attribute, here is
the link for it: https://www.w3.org/TR/REC-CSS1/#color-units.
The comments for this function needs to be changed to "The three-digit RGB notation
(#rgb) is converted into six-digit form (#rrggbb) by replicating digits, not by adding
zeros." to be more clear.
The fn comment was generic "an attempt will be made to fix it up"..so I
guess it is correct. I will add the above line to my comment where I add
the code, when I push. Any other objection?
Regards
Prasanta
Thanks and regards,
Shashi
-----Original Message-----
From: Prasanta Sadhukhan
Sent: Thursday, February 21, 2019 8:20 PM
To: Shashidhara Veerabhadraiah <shashidhara.veerabhadra...@oracle.com>;
swing-dev@openjdk.java.net
Subject: Re: <Swing Dev> [13] RFR JDK-8213781:web page background renders blue
in JEditorPane
Also, as per https://www.w3.org/TR/CSS2/syndata.html#value-def-color, we have
The three-digit RGB notation (#rgb) is converted into six-digit form
(#rrggbb) by replicating digits, not by adding zeros. For example, #fb0 expands
to #ffbb00. This ensures that white (#ffffff) can be specified with the short
notation (#fff) and removes any dependencies on the color depth of the display.
Regards
Prasanta
On 21-Feb-19 7:45 PM, Prasanta Sadhukhan wrote:
Hi Shashi,
As you can see, Color.decode() called from hexToColor() accepts an
opaque 24 bit integer which is what returns the actual color that will
be rendered. Normally, it's 2D api's (ie Color.java) job to use
ColorSpace/ColorModel to give back the correct color and hexToColor's
job is to give a 6 digit string. The basic premise of the issue is CSS
parser gets a 3-digit string #fff instead of 6digit string #ffffff.
Please do not get confused by r,g,b variable name, it can as well be
a, b, c variables.
Regarding doing the logic at hexToColor(), it's because the comment of
that fn itself says "If the color specification is bad, an attempt
will be made to fix it up" so I made the attempt to fix it in that
function as expected by that comment.
Hope this clarifies.
Regards
Prasanta
On 21-Feb-19 3:46 PM, Shashidhara Veerabhadraiah wrote:
Hi Prashanta, I have a question on the proposed solution. Shouldn’t
one check for the color depth of the system like true color(24 bit)
or high color system(12 bit or non-true color system) before applying
this logic? Assuming 24 bit color system isn't the right thing to do
I think but again that may be mostly default these days. I also think
we should receive the expanded form at the hexToColor() rather than
expanding at this function. We should simply apply the received color
at this lower function level I think.
Thanks and regards,
Shashi
-----Original Message-----
From: Prasanta Sadhukhan
Sent: Thursday, February 21, 2019 2:04 PM
To: swing-dev@openjdk.java.net
Subject: <Swing Dev> [13] RFR JDK-8213781:web page background renders
blue in JEditorPane
Hi All,
Please review a fix for an issue where it is seen that some webpage
shows wrong background color when displayed in JEditorPane.
It seems that some webpage can have #rgb [as in #fff] as CSS
attributes which when parsed and passed to hexToColor() it is decoded
as 0x000fff resulting in primarily blue background instead of white
as desired.
Now, hexToColor() is only able to handle 24 bit hex string as in
#FFFFFF but not 12bit hexstring. So, fix is to make it recognize #fff
and use
Color.decode() to decode it correctly to 0xffffff.
Bug: https://bugs.openjdk.java.net/browse/JDK-8213781
webrev: http://cr.openjdk.java.net/~psadhukhan/8213781/webrev.0/
Regards
Prasanta