Bug 433789 - [CSS] Rethink how the RegistryCSSElementProvider gets elements
Summary: [CSS] Rethink how the RegistryCSSElementProvider gets elements
Status: RESOLVED WONTFIX
Alias: None
Product: Platform
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 4.4   Edit
Hardware: All All
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Platform UI Triaged CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-04-29 14:24 EDT by Brian de Alwis CLA
Modified: 2020-06-15 04:44 EDT (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Brian de Alwis CLA 2014-04-29 14:24:33 EDT
CSS Engines are expected to return the DOM node corresponding to an element via their #getElement(Object) method.  Ideally an engine should return null for objects that it doesn't support (e.g., the CSSSWTEngine should return null for an AWT/Swing component).  The default implementation, AbstractCSSEngine#getElement(), defers to a configurable IElementProvider instance.  We have an RegistryCSSElementProvider that looks up an element from the extension registry from the "org.eclipse.e4.ui.css.core.elementProvider" extension point.

The problem is that the RegistryCSSElementProvider has no way to know whether an element mapping is appropriate for a given engine.  Thus if you have two different CSS engines that both use a RegistryCSSElementProvider, then it's entirely possible the SWT engine would obtain Swing elements and vice-versa.  I've had this happen with the Modelled Workbench CSS engine, that manipulates the EMF model definition: the SWT engine was handling model objects and the model engine was handling SWT widgets. 

One solution would be to have CSS engines that use the RegistryCSSElementProvider to override their #getElement() method to only handle known object types (e.g., "object instanceof Widget").  But the CSS SWT Engine (AbstractCSSSWTEngineImpl) has some difficulty here as the Eclipse UI Theme bridging support currently requires that the SWT engine be able to handle non-widget elements such as org.eclipse.ui.internal.themes.ThemeDefinitionElement and org.eclipse.core.runtime.preferences.IEclipsePreferences instances so as to propagate color and font definitions.  The CSS SWT engine manages how the properties are applied (i.e., on the SWT thread).

It's probably best that rather than have a single extension point shared amongst all engines to provide object -> element mappings, each engine type have its own extension point.
Comment 1 Lars Vogel CLA 2019-12-04 15:58:50 EST
Please reopen if you plan to work on this.