Skip to content

Drop the HTML.Attribute dependency from the parsers and sinks - #1095

Merged
slachiewicz merged 2 commits into
masterfrom
agent/drop-html-attribute
Sep 3, 2026
Merged

slachiewicz merged 2 commits into
masterfrom
agent/drop-html-attribute

Conversation

@slachiewicz

Copy link
Copy Markdown
Member

Phases 1 and 2 of #1092, in two commits so each stands on its own.

HTML.Attribute is gone from every main source. All 42 uses were Attribute.X.toString() —
a constant table that cost doxia-core and three modules a java.desktop dependency. The eleven
names in use match their SinkEventAttributes constant exactly; I checked that by running
HTML.Attribute against the literals rather than reading them off, so no generated output moves.
The sink tests that assert exact HTML (Xhtml5SinkTest, XdocSinkTest, MarkdownSinkTest) pass
unchanged, which is the real evidence.

Five of those uses passed the Attribute object itself as an attribute key, in XdocSink and
Xhtml5Sink. They worked only because addAttribute calls name.toString() on the key while
getAttribute, isDefined and removeAttribute do not — so such an entry could only ever be read
back with a String. All keys are String now.

SinkEventAttributes gains CONTENT, the one name in use it lacked.

Phase 2 is smaller than #1092 claims, and that is my error in the issue. It says to move
SinkUtils.getAttributeString, asCssString and filterAttributes onto entrySet(). That is not
possible in 2.x: all three take javax.swing.text.AttributeSet, which has no entrySet(), and
widening those parameters is a binary break. The same applies to
Xhtml5BaseSink.writeStartTag(Tag, MutableAttributeSet, boolean) and to the SinkEventAttributeSet
methods that implement the Swing interface. Only two sites were free, both already holding a
SinkEventAttributes. The rest waits on phase 4.

What is left of javax.swing after this: HTML.Tag (phase 3) and AttributeSet/MutableAttributeSet
(phase 4).

Verified: mvn verify green — japicmp on both published modules, RAT and checkstyle across all ten,
every test passing.

Part of #1092

This change was created with AI assistance.

Every one of the 42 uses was Attribute.X.toString(), a constant table that
cost doxia-core and three modules a java.desktop dependency. All eleven names
in use match the SinkEventAttributes constant exactly, checked by running
HTML.Attribute against the literals rather than reading them off, so no
generated output moves.

Five of the uses passed the Attribute object itself as an attribute key
(XdocSink, Xhtml5Sink). Those worked only because addAttribute calls
name.toString() on the key while getAttribute, isDefined and removeAttribute
do not, so such an entry could only ever be read back with a String. They are
Strings now like every other key.

SinkEventAttributes gains CONTENT, the one name in use it lacked.

Part of #1092
…tion

Only two places can move today: both already hold a SinkEventAttributes, so
they can use the entrySet added in 2.1.0.

SinkUtils.getAttributeString, asCssString and filterAttributes cannot follow.
They take javax.swing.text.AttributeSet, which has no entrySet, and widening
those parameters is a binary break. They stay on getAttributeNames until the
Swing supertype goes in the next major.

Part of #1092
@slachiewicz
slachiewicz marked this pull request as ready for review September 3, 2026 22:29
@slachiewicz
slachiewicz merged commit 1bef39d into master Sep 3, 2026
16 checks passed
@slachiewicz
slachiewicz deleted the agent/drop-html-attribute branch September 3, 2026 22:54
@github-actions github-actions Bot added this to the 2.2.0 milestone Sep 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant