Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [eclipse-incubator-e4-dev] CSS namespaces


> Hi,
>
> Angelo brought up CSS namespaces, I think this is an important topic
> that hasn't been discussed here yet.


Sigh... yes.

> The question is how to specify
> custom widget types in CSS. With SWT, the widget names are unambiguous,
> but custom widgets can involve name collisions.
>
> Using CSS namespaces would be an option, although I would then opt for
> using a default namespace for SWT to avoid clutter. The CSS could look
> like this:
>
>    @namespace "org.eclipse.swt.widgets";
>    @namespace my "my.name.space";
>
>    Label {
>      color;red;
>    }
>
>    my|Label {
>      color;red;
>    }
>
> On the other hand, some frequently used SWT widgets live in
> "org.eclipse.swt.custom" (CLabel, CCombo, CTabFolder, ...), so those
> would have to be prefixed as well (which I somehow dislike):
>
>    swtcustom|CLabel {
>      color: blue;
>    }

Agree, I dislike it too. It's annoying to clutter the typical case (SWT widgets, regardless of whether they are custom or not).

> Moreover, CSS 3 is not yet widely adopted and the available parsers do
> not support it out-of-the-box.

Good point.
 
> An alternative to CSS namespaces could be some kind of mapping between
> widget classes and CSS element names.

I think this is a reasonable approach. Extended widgets outside of SWT would need some form of qualified name, not so much to prevent clashing with SWT since presumably everyone avoids that, but to prevent clashing with each other.  The element names can be whatever we want them to be, since its our code that'll do the mapping from CSS to widget method calls.  So we could solve it without resorting to CSS name spaces, for example by requiring that extended widgets register their names with us in some qualified fashion (e.g. NebulaGallery).  Kinda hacky but would work.

Kevin

Back to the top