On Tue, 9 Apr 2024 18:36:46 GMT, Harshitha Onkar <[email protected]> wrote:

>> The value of the 
>> [`text-decoration`](https://www.w3.org/TR/REC-CSS1/#text-decoration) CSS 
>> property is not inherited correctly in Swing. If the `<span>` element is 
>> mixed with `<u>` or `<s>`, only the value from the `style` attribute of 
>> `<span>` is applied.
>> 
>> The fix to this issue is not as simple as that for the previous one in PR 
>> #17659, [JDK-8323801](https://bugs.openjdk.org/browse/JDK-8323801). Even in 
>> the seemingly simple case where `<u>` is followed by `<span 
>> style='text-decoration: line-through'>`, the situation is more complex 
>> because the styles are stored in `MuxingAttributeSet` in different elements 
>> of the array.
>> 
>> To resolve this problem, `CSS.Attribute.TEXT_DECORATION` is treated as a 
>> special case. Indeed, it is a special case: the values set to a single 
>> `text-decoration` property should be combined across the entire tree of 
>> nested HTML elements and their styles.
>> 
>> So, `MuxingAttributeSet` looks for `text-decoration` in the entire array and 
>> combines all the values.
>> 
>> The same way, `StyleSheet` also goes up the inheritance chain by combining 
>> the current value of `text-decoration` with that from `getResolveParent`.
>> 
>> The `ConvertSpanAction` combines the value of `text-decoration` of adjacent 
>> `<span>` elements.
>> 
>> Finally, `ConvertAction` and `CharacterAction` are refactored. The 
>> `ConvertAction` class duplicated the code from `CharacterAction`. Now 
>> `ConvertAction` extends `CharacterAction` and overrides a method to provide 
>> additional handling.
>> 
>> Thus, [JDK-8325620](https://bugs.openjdk.org/browse/JDK-8325620) is also 
>> resolved by this PR, the action used for `<b>`, `<i>`, `<u>` is 
>> `CharacterAction` as specified.
>
> test/jdk/javax/swing/text/html/HTMLDocument/HTMLTextDecoration.java line 90:
> 
>> 88:             <div class="lineThrough"><p class="underline">underline + 
>> line-through?</p></div>
>> 89: 
>> 90:             <div class="underline"><div class="lineThrough">underline + 
>> line-through?</div></div>
> 
> The test fails when multiple CSS classes are on the same tag. Are we 
> considering such cases as part of this fix?
> 
> For instance `<div class="underline lineThrough">This text should be 
> striken</div>`
> When testing on a normal HTML editor, the 1st class - underline is overriden 
> and lineThrough is applied since both are related to text-decoration.
> But when tested using HTMLTestDecoration.java it is not striken as expected.
> 
> For example: 
> 
> <!DOCTYPE html>
> <html lang="en">
>    <head>
>       <meta charset="UTF-8">
>       <title>underline + line-through text</title>
>       <style>
>          .underline   { text-decoration: underline }
>          .lineThrough { text-decoration: line-through }
>       </style>
>    </head>
>    <body>
>       <div class="underline lineThrough">This text should be striken</div>
>    </body>
> </html>

I'm pretty sure there are other cases where `text-decoration` isn't resolved 
correctly. It is not a goal to resolve all of the possible issues.

I'll check whether this scenario can be handled easily. I don't think it is. If 
not, I'll submit another bug.

-------------

PR Review Comment: https://git.openjdk.org/jdk/pull/18550#discussion_r1558234784

Reply via email to