Skip to content

Split vs combined CSS rules produce different results #3565

@marhuo

Description

@marhuo

I’ve been experimenting with CSS in Eclipse RCP and noticed that writing equivalent CSS in a different way causes different results. I’ve managed to pinpoint a simple example where splitting a CSS rule for the same selector produces a different outcome.

Split rules (expected: dark tabs with light text):

CTabItem{
	background-color: #313131;
}
CTabItem{
	color: #b3b0b0;
}
Image

Combined rule (actual: black text on dark background, when tabs control is active it shows black text on light background, last one is not visible in screenshot):

CTabItem{
	background-color: #313131;
	color: #b3b0b0;
}
Image

Code:

CTabFolder cTabFolder = new CTabFolder(grid, SWT.BORDER);
cTabFolder.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1));
		cTabFolder.setSelectionBackground(Display.getCurrent().getSystemColor(SWT.COLOR_TITLE_INACTIVE_BACKGROUND_GRADIENT));

// CTab 1
CTabItem cTabItem1 = new CTabItem(cTabFolder, SWT.NONE);
cTabItem1.setText("Tab 1");

Composite cTab1Content = new Composite(cTabFolder, SWT.NONE);
cTab1Content.setLayout(new GridLayout(1, false));
cTabItem1.setControl(cTab1Content);
		
Label cTab1Text = new Label(cTab1Content, SWT.WRAP);
cTab1Text.setText("Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula eget dolor. Aenean massa. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Donec quam felis, ultricies nec, pellentesque eu, pretium quis, sem. Nulla consequat massa quis enim. Donec pede justo, fringilla vel, aliquet nec, vulputate eget, arcu. In enim justo, rhoncus ut, imperdiet a, venenatis vitae, justo. Nullam dictum felis eu pede mollis pretium. Integer tincidunt. Cras dapibus. Vivamus elementum semper nisi. Aenean vulputate eleifend tellus. Aenean leo ligula, portt");
		
GridData cTab1TextGridData = new GridData(SWT.FILL, SWT.TOP, true, false);
cTab1TextGridData.widthHint = 500;
cTab1Text.setLayoutData(cTab1TextGridData);
		
//CTab 2
CTabItem cTabItem2 = new CTabItem(cTabFolder, SWT.NONE);
cTabItem2.setText("Tab 2");

CTabItem cTabItem3 = new CTabItem(cTabFolder, SWT.NONE);
cTabItem3.setText("Tab 3");
		
cTabFolder.setSelection(cTabItem1);

In standard CSS these two forms are equivalent, but in Eclipse RCP they produce completely different results.
Question: What is the logic in the Eclipse CSS engine that makes these behave differently?

org.eclipse.swt 3.131.0.v20250820-1556
org.eclipse.e4.ui.css.core 0.14.500.v20240606-0949
org.eclipse.e4.ui.css.swt 0.15.600.v20250409-1135

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions