RFR: JDK-8314731 : Add support for the alt attribute in the image type input HTML tag [v11]

Alexey Ivanov aivanov at openjdk.org
Wed Sep 10 15:02:52 UTC 2025


On Mon, 8 Sep 2025 09:13:09 GMT, ScientificWare <duke at openjdk.org> wrote:

>> This is referenced in Java Bug Database as
>> - [JDK-8314731 : Adds support for the alt attribute in the image type input HTML tag.](https://bugs.java.com/bugdatabase/view_bug?bug_id=8314731)
>> 
>> This is tracked in JBS as
>> - [JDK-8314731 : Add support for the alt attribute in the image type input HTML tag](https://bugs.openjdk.java.net/browse/JDK-8314731)
>> 
>> According [HTML 3.2 specification](https://www.w3.org/TR/2018/SPSD-html32-20180315/#input)
>> 
>> `alt` is not an attribute of the `input` element.
>> 
>> According [HTML 4.01 specifications](https://www.w3.org/TR/html4/interact/forms.html#h-17.4) : 
>> 
>>> ... For accessibility reasons, authors should provide [alternate text](https://www.w3.org/TR/html4/struct/objects.html#alternate-text) for the image via the [alt](https://www.w3.org/TR/html4/struct/objects.html#adef-alt) attribute. ...
>> 
>> This feature is not implemented in `FormView.java`.
>> 
>> ⚠️  ~~This also affects the HTML 32 DTD~~
>> 
>> ![Screenshot_20230817_025316](https://github.com/openjdk/jdk/assets/19194678/8e580574-d842-4a65-884b-26e33cd12138)
>> 
>> Left before the patch and right after the patch.
>> 
>> 
>> import java.awt.BorderLayout;
>> import java.awt.Dimension;
>> import javax.swing.JEditorPane;
>> import javax.swing.JFrame;
>> import javax.swing.JScrollPane;
>> import javax.swing.SwingUtilities;
>> import javax.swing.text.Document;
>> import javax.swing.text.html.HTMLEditorKit;
>> import javax.swing.text.html.StyleSheet;
>> 
>> public class HTMLAddsSupportAltInputTag {
>>   public static void main(String[] args) {
>>     new HTMLAddsSupportAltInputTag();
>>   }
>>   
>>   public HTMLAddsSupportAltInputTag() {
>>     SwingUtilities.invokeLater(new Runnable(){
>>       public void run(){
>>         JEditorPane jEditorPane = new JEditorPane();
>>         jEditorPane.setEditable(false);
>>         JScrollPane scrollPane = new JScrollPane(jEditorPane);
>>         HTMLEditorKit kit = new HTMLEditorKit();
>>         jEditorPane.setEditorKit(kit);
>>         StyleSheet styleSheet = kit.getStyleSheet();
>>         styleSheet.addRule("""
>>             body {
>>                 color: #000;
>>                 font-family: times;
>>                 margin: 4px;
>>             }
>>             """);
>>         String htmlString = """
>>             <html>
>>                 <body>
>>                     <input type=image name=point src="file:oracle_logo_50x50.jpg" alt="Logo Oracle JPG">
>>                     <p>
>>                     <input type=image name=point src="file:none_or...
>
> ScientificWare has updated the pull request with a new target base due to a merge or a rebase. The pull request now contains 27 commits:
> 
>  - Merge master
>  - Change the copyright year and apply the suggestions from the test code.
>    
>    bug8314731.java:
>    - Bump the copyright year to 2025.
>    - Rename or remove some methods.
>    - Simplify the code.
>    - Remove unused imports.
>    - Replace the anonymous class with a lambda.
>    
>    FormView.java:
>    - Fix misalignment.
>  - Merge master
>  - JDK-8314731 : Remove all indentations accidentally introduced by the previous commit.
>  - Merge master
>  - Merge master
>  - jdk-8314731 : FormView Alt Support.
>    
>    FormView.java :
>    - revert ALL unrelated changing to formatting.
>    
>    bug8314731.java :
>    - Fix the test description.
>    - Change where the user interface is created.
>    - Add a finall block to be sure the Frame is disposed.
>    - Replace "testPassed" with "testFailed".
>  - Merge master
>  - Replaces this title with "alt attribute test in HTML image type input".
>    
>    Moves this test to /jdk/test/jdk/javax/swing/text/html.
>  - bug8314731.java : Corrects the CopyRight date.
>  - ... and 17 more: https://git.openjdk.org/jdk/compare/bea2b029...25965200

Looks good to me, except for two minor comments.

I've run all client tests, all's green.

test/jdk/javax/swing/text/html/bug8314731.java line 106:

> 104:         for (Component c : container.getComponents()) {
> 105:             if (c instanceof JButton butt) {
> 106:                 return "Logo".equals(butt.getText());

Suggestion:

            if (c instanceof JButton button) {
                return "Logo".equals(button.getText());

Let's spell the word fully to avoid unwanted connotations; or use `btn`.

test/jdk/javax/swing/text/html/bug8314731.java line 113:

> 111:         return false;
> 112:     }
> 113: }

And now the blank line at the end of the file is missing, like @TejeshR13 [commented previously](https://github.com/openjdk/jdk/pull/15319#discussion_r2292964065).

Usually, files should end with a new line character.

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

Marked as reviewed by aivanov (Reviewer).

PR Review: https://git.openjdk.org/jdk/pull/15319#pullrequestreview-3206564981
PR Comment: https://git.openjdk.org/jdk/pull/15319#issuecomment-3275364988
PR Review Comment: https://git.openjdk.org/jdk/pull/15319#discussion_r2337041323
PR Review Comment: https://git.openjdk.org/jdk/pull/15319#discussion_r2337048716


More information about the client-libs-dev mailing list