Community
Participate
Working Groups
Whenever a CSS theme uses the 'inherit' keyword for a property: eg. #org-eclipse-ui-views-ContentOutline.MToolBar { background-color: inherit; } an IllegalStateException is thrown while building the theme as plugin and, in some cases, when the theme is selected as current theme for the IDE, the exception is also reported in the Console when the user runs his projects not related with the css theme. Note that the 'inherit' property is applied correctly and works despite the exceptions thrown. Here is one of the stacktraces that are reported on Console: at org.apache.batik.css.parser.CSSLexicalUnit.getFloatValue(Unknown Source) at org.eclipse.e4.ui.css.core.impl.dom.Measure.getFloatValue(Measure.java:38) at org.eclipse.e4.ui.css.swt.helpers.CSSSWTFontHelper.getFontData(CSSSWTFontHelper.java:153) at org.eclipse.e4.ui.css.swt.properties.converters.CSSValueSWTFontDataConverterImpl.convert(CSSValueSWTFontDataConverterImpl.java:72) at org.eclipse.e4.ui.css.swt.properties.converters.CSSValueSWTFontConverterImpl.convert(CSSValueSWTFontConverterImpl.java:33) at org.eclipse.e4.ui.css.core.impl.engine.AbstractCSSEngine.convert(AbstractCSSEngine.java:1125) at org.eclipse.e4.ui.css.swt.properties.css2.CSSPropertyFontSWTHandler$FontSelectionListener.applyStyles(CSSPropertyFontSWTHandler.java:298) at org.eclipse.e4.ui.css.swt.properties.css2.CSSPropertyFontSWTHandler$FontSelectionListener.styleUnselected(CSSPropertyFontSWTHandler.java:321) at org.eclipse.e4.ui.css.swt.properties.css2.CSSPropertyFontSWTHandler$FontSelectionListener.handleEvent(CSSPropertyFontSWTHandler.java:367) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84) at org.eclipse.swt.widgets.Display.sendEvent(Display.java:4166) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1466) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1489) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1474) at org.eclipse.swt.widgets.Control.drawWidget(Control.java:1244) at org.eclipse.swt.widgets.Widget.drawRect(Widget.java:749) at org.eclipse.swt.widgets.Display.windowProc(Display.java:5534) at org.eclipse.swt.internal.cocoa.OS.objc_msgSendSuper(Native Method) at org.eclipse.swt.widgets.Display.applicationNextEventMatchingMask(Display.java:4918) at org.eclipse.swt.widgets.Display.applicationProc(Display.java:5296) at org.eclipse.swt.internal.cocoa.OS.objc_msgSend(Native Method) at org.eclipse.swt.internal.cocoa.NSApplication.nextEventMatchingMask(NSApplication.java:94) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3645) at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$9.run(PartRenderingEngine.java:1113) at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332) at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:997) at org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:138) at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:610) at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332) at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:567) at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:150) at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:124) at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196) at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110) at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79) at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:354) at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:181) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:636) at org.eclipse.equinox.launcher.Main.basicRun(Main.java:591) at org.eclipse.equinox.launcher.Main.run(Main.java:1450)
It seems that currently we don't support the 'inherit' property value. However the similar effect you should get by skipping the 'background-color' property. The parent property should be taken into account in such case Let me take a look at it closer, Daniel
Thanks Daniel, it seems that the property value is inherited also without setting the keyword 'inherit'. I noticed that sometimes CSS styles are not applied smoothly (like if the drawing buffer is not correctly refreshed), this may happen when a widget is re-positioned (eg. when resizing a .MPartStack widget). By setting a property to 'inherit' will throw the exception and seems to trigger a refresh, this was giving the 'illusion' that the inherit keyword was working.. :).
Leaving the property empty is only a partial workaround. If a broader CSS rule has already set a background-color property then a more specific rule can't unset that property using inherit. This is mostly a problem with gradients.
Stefan, are you taking that Bug?
Submitted patch to gerrit: https://git.eclipse.org/r/24321 I have implemented handling of 'inherit' especially for 'background-color' in org.eclipse.e4.ui.css.swt.properties.css2.CSSPropertyBackgroundSWTHandler.applyCSSPropertyBackgroundColor() It might be too specific there. On the other hand, I have considered generally mapping 'inherit' to 'null' by overriding org.eclipse.e4.ui.css.core.impl.engine.AbstractCSSEngine.convert(), e.g. in org.eclipse.e4.ui.css.swt.engine.AbstractCSSSWTEngineImpl. But there are some implementations which already check for CSSEngine.convert returning null (e.g., org.eclipse.e4.ui.css.swt.properties.css2.CSSPropertyTextSWTHandler.applyCSSPropertyColor() - line 61 - so it seemed too risky to implement a general inherit -> null mapping.
Released to master as: http://git.eclipse.org/c/platform/eclipse.platform.ui.git/commit/?id=ae6f557d5fc2cdc25f04602a0a5fde45839653e2 Thanks Stefan for patch, Daniel
(In reply to Daniel Rolka from comment #6) > Released to master as: > http://git.eclipse.org/c/platform/eclipse.platform.ui.git/commit/?id=ae6f557d5fc2cdc25f04602a0a5fde45839653e2 > > > Thanks Stefan for patch, > Daniel This caused a compile warning in our official build: 1. WARNING in /src/org/eclipse/e4/ui/tests/css/core/parser/InheritTest.java (at line 36) @SuppressWarnings("restriction") Unnecessary @SuppressWarnings("restriction") I've fixed this with http://git.eclipse.org/c/platform/eclipse.platform.ui.git/commit/?id=6e426eb5e2538c69f5ae8746908d8890d12ba6db and also fixed other warnings and updated the bundle version.
Verified in I20141208-2000 Daniel
I just gave the "inherit" CSS value a try like that: Composite { background-color: black; color: orange; } Composite Label { color: inherit; } When a added this CSS to a sample app with just a label on an MPart the text on this Label did not change to orange. After debugging I found out that the parents actual value is still #4c4c4c event though the parent of the Label is a CompositeElement. Only after I added the .MPart CSS class it worked as desired: .MPart, Composite { background-color: black; color: orange; } Composite Label { color: inherit; } In my opinion the first CSS example should also be applied to the Label. If you agree with me, I'll open a new Bug.
Maybe this behavior is a consequence of what Brian said in Gerrit: > Patch Set 5: > Two problems that I see: (1) not all properties support "inherit", but they will now. > (2) If the parent's value changes, we won't be notified unless the change was applied > to all children. I don't know how important these two issues are. Maybe (2) is effective here and the child gets its color before the parent? Otherwise, I have noticed some oddities and inconsistencies regarding SWT and the reported background color. Anyways, we should investigate and find ways to fix this either in the CSS support or in SWT, whichever is responsible. So, please go ahead and open a new bug.
Thanks for the reply Stefan. Here is the bug: https://bugs.eclipse.org/bugs/show_bug.cgi?id=456504