Skip to content

Replace Batik with an internal hand-written CSS parser and drop SAC#4092

Draft
vogella wants to merge 1 commit into
eclipse-platform:masterfrom
vogella:css-internal-css-parser
Draft

Replace Batik with an internal hand-written CSS parser and drop SAC#4092
vogella wants to merge 1 commit into
eclipse-platform:masterfrom
vogella:css-internal-css-parser

Conversation

@vogella

@vogella vogella commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

Replaces the Apache Batik CSS parser and the vendored W3C SAC layer with a small internal recursive-descent parser (tokenizer plus parser) scoped to the CSS subset the engine actually uses.
The engine parses through it end to end, the org.apache.batik.css Require-Bundle is removed, and the only remaining SAC type is the LexicalUnit interface that a later step drops.
Parsing in isolation measures about 22% faster and the engine sheds an external runtime dependency, with no change to styling behaviour: @media, @font-face and @page are still parsed and discarded as before.
Verified against the full css.core and css.swt test suites and by a differential comparison against the Batik output over all shipped Eclipse themes.

Contributes to #3980.

@vogella

vogella commented Jun 12, 2026

Copy link
Copy Markdown
Contributor Author

#4091 should be merged before this one to catch potential regressions.

@eclipse-platform-bot

eclipse-platform-bot commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

This pull request changes some projects for the first time in this development cycle.
Therefore the following files need a version increment:

bundles/org.eclipse.e4.ui.css.swt.theme/META-INF/MANIFEST.MF

An additional commit containing all the necessary changes was pushed to the top of this PR's branch. To obtain these changes (for example if you want to push more changes) either fetch from your fork or apply the git patch.

Git patch
From 541118a068a8b0317e14d586d40c72d156aa712d Mon Sep 17 00:00:00 2001
From: Eclipse Platform Bot <platform-bot@eclipse.org>
Date: Fri, 12 Jun 2026 19:59:11 +0000
Subject: [PATCH] Version bump(s) for 4.41 stream


diff --git a/bundles/org.eclipse.e4.ui.css.swt.theme/META-INF/MANIFEST.MF b/bundles/org.eclipse.e4.ui.css.swt.theme/META-INF/MANIFEST.MF
index 7e12ccd454..f60a78e861 100644
--- a/bundles/org.eclipse.e4.ui.css.swt.theme/META-INF/MANIFEST.MF
+++ b/bundles/org.eclipse.e4.ui.css.swt.theme/META-INF/MANIFEST.MF
@@ -1,7 +1,7 @@
 Manifest-Version: 1.0
 Bundle-ManifestVersion: 2
 Bundle-SymbolicName: org.eclipse.e4.ui.css.swt.theme;singleton:=true
-Bundle-Version: 0.15.100.qualifier
+Bundle-Version: 0.15.200.qualifier
 Bundle-Name: %pluginName
 Bundle-Vendor: %providerName
 Bundle-Localization: plugin
-- 
2.54.0

Further information are available in Common Build Issues - Missing version increments.

@github-actions

github-actions Bot commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

Test Results

   867 files  +  3     867 suites  +3   44m 26s ⏱️ - 2m 49s
 8 069 tests + 19   7 823 ✅ + 16  243 💤 ± 0  3 ❌ +3 
20 471 runs  +190  19 846 ✅ +160  622 💤 +27  3 ❌ +3 

For more details on these failures, see this check.

Results for commit 5228127. ± Comparison against base commit 8a0d043.

♻️ This comment has been updated with latest results.

@vogella vogella force-pushed the css-internal-css-parser branch from 10719f2 to f284769 Compare June 12, 2026 19:55
Introduce an internal recursive-descent CSS parser under impl/parser (a
tokenizer, a LexicalUnit implementation, and CssParser) and wire it into
CSSEngineImpl, removing the Batik/SAC parser stack in the same change so
no intermediate state ships an unused parser.

The parser produces the same model the SAC/Batik path produced
(CSSStyleSheetImpl with CSSStyleRuleImpl / CSSImportRuleImpl rules,
internal Selectors selector trees, and CSSValueFactory values). It is
scoped to the subset the engine uses: type / class / id / attribute /
pseudo selectors, child / descendant / adjacent combinators, length /
percentage / number / colour / identifier / string / url() / rgb()
values, !important, and @import. @media, @font-face and @page are parsed
and discarded. Selector trees mirror the previous SAC translator so
specificity and matching are unchanged.

parseStyleSheet, parseStyleDeclaration, parsePropertyValue and
parseSelectors now go through the internal parser; the InputSource-based
overloads are gone, replaced by a parseStyleSheet(InputStream, uri)
method that carries the base location for relative @import resolution.

Deleted: the vendored SAC plumbing (impl/sac, core/sac), the SAC-backed
CSSParser / AbstractCSSParser / parser factories, SacTranslator and
SACConstants. The org.apache.batik.css Require-Bundle is removed. The
only remaining SAC type is the LexicalUnit interface used by the
impl/dom value model, which Phase 4 replaces.

ThemeEngine and the test helpers move off InputSource; the css.swt
margin/padding handlers throw IllegalArgumentException instead of the
SAC CSSException. A malformed, unterminated at-rule block is now
rejected. Verified by the full css.core (119) and css.swt (210) test
suites, by CssParserTest, and by a differential comparison against Batik
over all shipped Eclipse themes.
@vogella vogella force-pushed the css-internal-css-parser branch from f284769 to 5228127 Compare June 12, 2026 19:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants