From 3fa5853060ac401db97a6e6c87c79e609fa994c0 Mon Sep 17 00:00:00 2001 From: Lars Vogel Date: Fri, 3 Jul 2026 16:27:59 +0200 Subject: [PATCH 1/2] Retire CSSValueImpl and pin the W3C value facade CSSValueImpl is unreferenced since the computed-style cascade moved to internal types; delete it, together with the COUNTER_ERROR and RECT_ERROR message keys it was the last user of. Document the remaining W3C surface (the CssValues records and CSSStyleDeclarationImpl) as a permanent compatibility facade rather than a transitional bridge: IStylingEngine.getStyle and IThemeEngine.getStyle return W3C types and propertyHandler contributions receive values as W3C CSSValue, so this surface stays. Also drop the redundant CSSStyleDeclaration implements clause from CSSComputedStyleImpl. --- .../css/core/exceptions/DOMExceptionImpl.java | 2 - .../core/exceptions/ExceptionResource.java | 2 - .../core/impl/dom/CSSComputedStyleImpl.java | 9 +- .../impl/dom/CSSStyleDeclarationImpl.java | 5 + .../e4/ui/css/core/impl/dom/CSSValueImpl.java | 92 ------------------- .../e4/ui/css/core/impl/dom/CssValues.java | 7 +- 6 files changed, 12 insertions(+), 105 deletions(-) delete mode 100644 bundles/org.eclipse.e4.ui.css.core/src/org/eclipse/e4/ui/css/core/impl/dom/CSSValueImpl.java diff --git a/bundles/org.eclipse.e4.ui.css.core/src/org/eclipse/e4/ui/css/core/exceptions/DOMExceptionImpl.java b/bundles/org.eclipse.e4.ui.css.core/src/org/eclipse/e4/ui/css/core/exceptions/DOMExceptionImpl.java index ec2bf4774bc..574c21172ad 100644 --- a/bundles/org.eclipse.e4.ui.css.core/src/org/eclipse/e4/ui/css/core/exceptions/DOMExceptionImpl.java +++ b/bundles/org.eclipse.e4.ui.css.core/src/org/eclipse/e4/ui/css/core/exceptions/DOMExceptionImpl.java @@ -38,8 +38,6 @@ public class DOMExceptionImpl extends DOMException { public static final int EXPECTING_PAGE_RULE = 9; public static final int FLOAT_ERROR = 10; public static final int STRING_ERROR = 11; - public static final int COUNTER_ERROR = 12; - public static final int RECT_ERROR = 13; public static final int RGBCOLOR_ERROR = 14; public static final int CHARSET_NOT_FIRST = 15; public static final int CHARSET_NOT_UNIQUE = 16; diff --git a/bundles/org.eclipse.e4.ui.css.core/src/org/eclipse/e4/ui/css/core/exceptions/ExceptionResource.java b/bundles/org.eclipse.e4.ui.css.core/src/org/eclipse/e4/ui/css/core/exceptions/ExceptionResource.java index ef5fc5124bf..7dfdccc6e42 100644 --- a/bundles/org.eclipse.e4.ui.css.core/src/org/eclipse/e4/ui/css/core/exceptions/ExceptionResource.java +++ b/bundles/org.eclipse.e4.ui.css.core/src/org/eclipse/e4/ui/css/core/exceptions/ExceptionResource.java @@ -39,8 +39,6 @@ public Object[][] getContents() { {"s9", "The text does not represent a page rule"}, {"s10", "This isn't a Float type"}, {"s11", "This isn't a String type"}, - {"s12", "This isn't a Counter type"}, - {"s13", "This isn't a Rect type"}, {"s14", "This isn't an RGBColor type"}, {"s15", "A charset rule must be the first rule"}, {"s16", "A charset rule already exists"}, diff --git a/bundles/org.eclipse.e4.ui.css.core/src/org/eclipse/e4/ui/css/core/impl/dom/CSSComputedStyleImpl.java b/bundles/org.eclipse.e4.ui.css.core/src/org/eclipse/e4/ui/css/core/impl/dom/CSSComputedStyleImpl.java index 541e223b475..939e32ee1d9 100644 --- a/bundles/org.eclipse.e4.ui.css.core/src/org/eclipse/e4/ui/css/core/impl/dom/CSSComputedStyleImpl.java +++ b/bundles/org.eclipse.e4.ui.css.core/src/org/eclipse/e4/ui/css/core/impl/dom/CSSComputedStyleImpl.java @@ -18,15 +18,12 @@ import java.util.List; import org.eclipse.e4.ui.css.core.dom.CSSProperty; import org.eclipse.e4.ui.css.core.dom.CSSPropertyList; -import org.w3c.dom.css.CSSStyleDeclaration; - /** - * CSS computed style which concatenate list of CSSComputedStyleImpl to manage - * styles coming from Condition Selector (ex : Label#MyId) and other selectors - * (ex : Label). + * Computed style merging the declarations of all rules that match an element, + * ordered by specificity and source position. */ -public class CSSComputedStyleImpl extends CSSStyleDeclarationImpl implements CSSStyleDeclaration { +public class CSSComputedStyleImpl extends CSSStyleDeclarationImpl { private final List styleRules; diff --git a/bundles/org.eclipse.e4.ui.css.core/src/org/eclipse/e4/ui/css/core/impl/dom/CSSStyleDeclarationImpl.java b/bundles/org.eclipse.e4.ui.css.core/src/org/eclipse/e4/ui/css/core/impl/dom/CSSStyleDeclarationImpl.java index 4f440d2b081..67301294d87 100644 --- a/bundles/org.eclipse.e4.ui.css.core/src/org/eclipse/e4/ui/css/core/impl/dom/CSSStyleDeclarationImpl.java +++ b/bundles/org.eclipse.e4.ui.css.core/src/org/eclipse/e4/ui/css/core/impl/dom/CSSStyleDeclarationImpl.java @@ -26,6 +26,11 @@ import org.w3c.dom.css.CSSStyleDeclaration; import org.w3c.dom.css.CSSValue; +/** + * W3C {@link CSSStyleDeclaration} view over the internal property list; part of + * the permanent compatibility facade returned by {@code IStylingEngine.getStyle} + * and {@code IThemeEngine.getStyle}. + */ public class CSSStyleDeclarationImpl implements CSSStyleDeclaration { private boolean readOnly; diff --git a/bundles/org.eclipse.e4.ui.css.core/src/org/eclipse/e4/ui/css/core/impl/dom/CSSValueImpl.java b/bundles/org.eclipse.e4.ui.css.core/src/org/eclipse/e4/ui/css/core/impl/dom/CSSValueImpl.java deleted file mode 100644 index 967244d15d9..00000000000 --- a/bundles/org.eclipse.e4.ui.css.core/src/org/eclipse/e4/ui/css/core/impl/dom/CSSValueImpl.java +++ /dev/null @@ -1,92 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008, 2015 Angelo Zerr and others. - * - * This program and the accompanying materials - * are made available under the terms of the Eclipse Public License 2.0 - * which accompanies this distribution, and is available at - * https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * Angelo Zerr - initial API and implementation - * IBM Corporation - ongoing development - *******************************************************************************/ - -package org.eclipse.e4.ui.css.core.impl.dom; - -import org.eclipse.e4.ui.css.core.exceptions.DOMExceptionImpl; -import org.w3c.dom.DOMException; -import org.w3c.dom.css.CSSPrimitiveValue; -import org.w3c.dom.css.CSSValue; -import org.w3c.dom.css.Counter; -import org.w3c.dom.css.RGBColor; -import org.w3c.dom.css.Rect; - -public abstract class CSSValueImpl implements CSSPrimitiveValue, CSSValue { - - private static final String NOT_YET_IMPLEMENTED = "NOT YET IMPLEMENTED"; //$NON-NLS-1$ - - // W3C CSSValue API methods - - @Override - public String getCssText() { - throw new UnsupportedOperationException(NOT_YET_IMPLEMENTED); - } - - @Override - public short getCssValueType() { - return CSS_PRIMITIVE_VALUE; - } - - @Override - public void setCssText(String cssText) throws DOMException { - throw new UnsupportedOperationException(NOT_YET_IMPLEMENTED); - } - - // W3C CSSPrimitiveValue API methods - - @Override - public short getPrimitiveType() { - throw new UnsupportedOperationException(NOT_YET_IMPLEMENTED); - } - - @Override - public Counter getCounterValue() throws DOMException { - throw new DOMExceptionImpl(DOMException.INVALID_ACCESS_ERR, DOMExceptionImpl.COUNTER_ERROR); - } - - @Override - public RGBColor getRGBColorValue() throws DOMException { - throw new DOMExceptionImpl(DOMException.INVALID_ACCESS_ERR, DOMExceptionImpl.RGBCOLOR_ERROR); - } - - @Override - public Rect getRectValue() throws DOMException { - throw new DOMExceptionImpl(DOMException.INVALID_ACCESS_ERR, DOMExceptionImpl.RECT_ERROR); - } - - @Override - public String getStringValue() throws DOMException { - throw new UnsupportedOperationException(NOT_YET_IMPLEMENTED); - } - - @Override - public void setFloatValue(short arg0, float arg1) throws DOMException { - throw new UnsupportedOperationException(NOT_YET_IMPLEMENTED); - } - - @Override - public void setStringValue(short arg0, String arg1) throws DOMException { - throw new UnsupportedOperationException(NOT_YET_IMPLEMENTED); - } - - // Additional methods - - @Override - public float getFloatValue(short valueType) throws DOMException { - throw new UnsupportedOperationException(NOT_YET_IMPLEMENTED); - } - - -} \ No newline at end of file diff --git a/bundles/org.eclipse.e4.ui.css.core/src/org/eclipse/e4/ui/css/core/impl/dom/CssValues.java b/bundles/org.eclipse.e4.ui.css.core/src/org/eclipse/e4/ui/css/core/impl/dom/CssValues.java index 2f4d2bb046d..a31160542ba 100644 --- a/bundles/org.eclipse.e4.ui.css.core/src/org/eclipse/e4/ui/css/core/impl/dom/CssValues.java +++ b/bundles/org.eclipse.e4.ui.css.core/src/org/eclipse/e4/ui/css/core/impl/dom/CssValues.java @@ -31,9 +31,10 @@ *

* Consumers pattern-match on the record variants ({@link CssNumber}, * {@link CssDimension}, {@link CssText}, {@link CssColor}, {@link CssList}) - * and read their components. The variants still implement the W3C DOM-CSS - * interfaces as a transitional bridge; the bridge goes away once the - * computed-style cascade is internal as well. + * and read their components. The variants also implement the W3C DOM-CSS value + * interfaces as a permanent compatibility facade: {@code IStylingEngine.getStyle} + * and {@code IThemeEngine.getStyle} return W3C types, and {@code propertyHandler} + * contributions receive values as W3C {@code CSSValue}, so the facade must stay. *

*/ public final class CssValues { From e481558a7cb14d0a19b06cff999dc4cd66e5d089 Mon Sep 17 00:00:00 2001 From: Lars Vogel Date: Fri, 3 Jul 2026 16:44:08 +0200 Subject: [PATCH 2/2] Drop the DOM exception message-key machinery After the parser and DOM-mirror rework only two of the 19 DOMExceptionImpl message keys were still referenced. Throw plain DOMException with the message inlined at the four remaining call sites and delete DOMExceptionImpl and its ExceptionResource bundle. --- .../css/core/exceptions/DOMExceptionImpl.java | 68 ------------------- .../core/exceptions/ExceptionResource.java | 50 -------------- .../impl/dom/CSSStyleDeclarationImpl.java | 13 ++-- .../CSSValueSWTColorConverterImpl.java | 5 +- 4 files changed, 8 insertions(+), 128 deletions(-) delete mode 100644 bundles/org.eclipse.e4.ui.css.core/src/org/eclipse/e4/ui/css/core/exceptions/DOMExceptionImpl.java delete mode 100644 bundles/org.eclipse.e4.ui.css.core/src/org/eclipse/e4/ui/css/core/exceptions/ExceptionResource.java diff --git a/bundles/org.eclipse.e4.ui.css.core/src/org/eclipse/e4/ui/css/core/exceptions/DOMExceptionImpl.java b/bundles/org.eclipse.e4.ui.css.core/src/org/eclipse/e4/ui/css/core/exceptions/DOMExceptionImpl.java deleted file mode 100644 index 574c21172ad..00000000000 --- a/bundles/org.eclipse.e4.ui.css.core/src/org/eclipse/e4/ui/css/core/exceptions/DOMExceptionImpl.java +++ /dev/null @@ -1,68 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008, 2013 Angelo Zerr and others. - * - * This program and the accompanying materials - * are made available under the terms of the Eclipse Public License 2.0 - * which accompanies this distribution, and is available at - * https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * Angelo Zerr - initial API and implementation\ - * IBM Corporation - ongoing development - *******************************************************************************/ -package org.eclipse.e4.ui.css.core.exceptions; - -import java.util.Locale; -import java.util.ResourceBundle; - -import org.w3c.dom.DOMException; - -/** - * DOM exception implementation. - */ -public class DOMExceptionImpl extends DOMException { - - private static final long serialVersionUID = 4001374962941459011L; - - public static final int SYNTAX_ERROR = 0; - public static final int ARRAY_OUT_OF_BOUNDS = 1; - public static final int READ_ONLY_STYLE_SHEET = 2; - public static final int EXPECTING_UNKNOWN_RULE = 3; - public static final int EXPECTING_STYLE_RULE = 4; - public static final int EXPECTING_CHARSET_RULE = 5; - public static final int EXPECTING_IMPORT_RULE = 6; - public static final int EXPECTING_MEDIA_RULE = 7; - public static final int EXPECTING_FONT_FACE_RULE = 8; - public static final int EXPECTING_PAGE_RULE = 9; - public static final int FLOAT_ERROR = 10; - public static final int STRING_ERROR = 11; - public static final int RGBCOLOR_ERROR = 14; - public static final int CHARSET_NOT_FIRST = 15; - public static final int CHARSET_NOT_UNIQUE = 16; - public static final int IMPORT_NOT_FIRST = 17; - public static final int NOT_FOUND = 18; - public static final int NOT_IMPLEMENTED = 19; - public static final int NO_MODIFICATION_ALLOWED_ERROR = 20; - - private static ResourceBundle exceptionResource = ResourceBundle.getBundle( - ExceptionResource.class.getName(), Locale.getDefault()); - - public DOMExceptionImpl(short code, int messageKey) { - super(code, exceptionResource.getString(keyString(messageKey))); - } - - public DOMExceptionImpl(int code, int messageKey) { - super((short) code, exceptionResource.getString(keyString(messageKey))); - } - - public DOMExceptionImpl(short code, int messageKey, String info) { - super(code, exceptionResource.getString(keyString(messageKey))); - } - - private static String keyString(int key) { - return "s" + key; - } - -} diff --git a/bundles/org.eclipse.e4.ui.css.core/src/org/eclipse/e4/ui/css/core/exceptions/ExceptionResource.java b/bundles/org.eclipse.e4.ui.css.core/src/org/eclipse/e4/ui/css/core/exceptions/ExceptionResource.java deleted file mode 100644 index 7dfdccc6e42..00000000000 --- a/bundles/org.eclipse.e4.ui.css.core/src/org/eclipse/e4/ui/css/core/exceptions/ExceptionResource.java +++ /dev/null @@ -1,50 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008, 2014 Angelo Zerr and others. - * - * This program and the accompanying materials - * are made available under the terms of the Eclipse Public License 2.0 - * which accompanies this distribution, and is available at - * https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * Angelo Zerr - initial API and implementation - * IBM Corporation - *******************************************************************************/ -package org.eclipse.e4.ui.css.core.exceptions; - -import java.util.ListResourceBundle; - -/** - * DOM Exception resource. - */ -public class ExceptionResource extends ListResourceBundle { - - @Override - public Object[][] getContents() { - return contents; - } - - static final Object[][] contents = { - {"s0", "Syntax error"}, - {"s1", "Array out of bounds error"}, - {"s2", "This style sheet is read only"}, - {"s3", "The text does not represent an unknown rule"}, - {"s4", "The text does not represent a style rule"}, - {"s5", "The text does not represent a charset rule"}, - {"s6", "The text does not represent an import rule"}, - {"s7", "The text does not represent a media rule"}, - {"s8", "The text does not represent a font face rule"}, - {"s9", "The text does not represent a page rule"}, - {"s10", "This isn't a Float type"}, - {"s11", "This isn't a String type"}, - {"s14", "This isn't an RGBColor type"}, - {"s15", "A charset rule must be the first rule"}, - {"s16", "A charset rule already exists"}, - {"s17", "An import rule must preceed all other rules"}, - {"s18", "The specified type was not found"}, - {"s19", "Not implemented"}, - {"s20", "Attempt to change a readonly object"} - }; -} diff --git a/bundles/org.eclipse.e4.ui.css.core/src/org/eclipse/e4/ui/css/core/impl/dom/CSSStyleDeclarationImpl.java b/bundles/org.eclipse.e4.ui.css.core/src/org/eclipse/e4/ui/css/core/impl/dom/CSSStyleDeclarationImpl.java index 67301294d87..d80d510a40f 100644 --- a/bundles/org.eclipse.e4.ui.css.core/src/org/eclipse/e4/ui/css/core/impl/dom/CSSStyleDeclarationImpl.java +++ b/bundles/org.eclipse.e4.ui.css.core/src/org/eclipse/e4/ui/css/core/impl/dom/CSSStyleDeclarationImpl.java @@ -20,7 +20,6 @@ import java.util.List; import org.eclipse.e4.ui.css.core.dom.CSSProperty; import org.eclipse.e4.ui.css.core.dom.CSSPropertyList; -import org.eclipse.e4.ui.css.core.exceptions.DOMExceptionImpl; import org.w3c.dom.DOMException; import org.w3c.dom.css.CSSRule; import org.w3c.dom.css.CSSStyleDeclaration; @@ -102,8 +101,8 @@ public String item(int index) { @Override public String removeProperty(String propertyName) throws DOMException { if (readOnly) { - throw new DOMExceptionImpl(DOMException.NO_MODIFICATION_ALLOWED_ERR, - DOMExceptionImpl.NO_MODIFICATION_ALLOWED_ERROR); + throw new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR, + "Attempt to change a readonly object"); //$NON-NLS-1$ } for (int i = 0; i < properties.size(); i++) { CSSProperty property = properties.get(i); @@ -118,8 +117,8 @@ public String removeProperty(String propertyName) throws DOMException { @Override public void setCssText(String cssText) throws DOMException { if (readOnly) { - throw new DOMExceptionImpl(DOMException.NO_MODIFICATION_ALLOWED_ERR, - DOMExceptionImpl.NO_MODIFICATION_ALLOWED_ERROR); + throw new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR, + "Attempt to change a readonly object"); //$NON-NLS-1$ } // TODO Auto-generated method stub // TODO throws SYNTAX_ERR if cssText is unparsable @@ -129,8 +128,8 @@ public void setCssText(String cssText) throws DOMException { @Override public void setProperty(String propertyName, String value, String priority) throws DOMException { if (readOnly) { - throw new DOMExceptionImpl(DOMException.NO_MODIFICATION_ALLOWED_ERR, - DOMExceptionImpl.NO_MODIFICATION_ALLOWED_ERROR); + throw new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR, + "Attempt to change a readonly object"); //$NON-NLS-1$ } // TODO Auto-generated method stub // TODO throws SYNTAX_ERR if value is unparsable diff --git a/bundles/org.eclipse.e4.ui.css.swt/src/org/eclipse/e4/ui/css/swt/properties/converters/CSSValueSWTColorConverterImpl.java b/bundles/org.eclipse.e4.ui.css.swt/src/org/eclipse/e4/ui/css/swt/properties/converters/CSSValueSWTColorConverterImpl.java index 4b197feab29..0c7d50c8e4d 100644 --- a/bundles/org.eclipse.e4.ui.css.swt/src/org/eclipse/e4/ui/css/swt/properties/converters/CSSValueSWTColorConverterImpl.java +++ b/bundles/org.eclipse.e4.ui.css.swt/src/org/eclipse/e4/ui/css/swt/properties/converters/CSSValueSWTColorConverterImpl.java @@ -19,7 +19,6 @@ import org.eclipse.e4.ui.css.core.dom.properties.converters.ICSSValueConverter; import org.eclipse.e4.ui.css.core.dom.properties.converters.ICSSValueConverterConfig; import org.eclipse.e4.ui.css.core.engine.CSSEngine; -import org.eclipse.e4.ui.css.core.exceptions.DOMExceptionImpl; import org.eclipse.e4.ui.css.swt.helpers.CSSSWTColorHelper; import org.eclipse.swt.graphics.Color; import org.eclipse.swt.widgets.Display; @@ -48,8 +47,8 @@ public Color convert(CSSValue value, CSSEngine engine, Object context) Display display = (Display) context; Color color = CSSSWTColorHelper.getSWTColor(value, display); if (color == null) { - throw new DOMExceptionImpl(DOMException.INVALID_ACCESS_ERR, - DOMExceptionImpl.RGBCOLOR_ERROR); + throw new DOMException(DOMException.INVALID_ACCESS_ERR, + "This isn't an RGBColor type"); } return color;