Menu

#530 CSS lexer update

Completed
closed
Scintilla (391)
4
2009-04-28
2008-09-22
Jason Oster
No

This is a fairly large patch for the CSS lexer, and I'm looking for suggestions or guidance for it. I'm focusing on new features and syntax changes introduced with CSS3. Though still incomplete, I believe starting on CSS3 support will be advantageous for every web developer who uses Scintilla in some way.

The most notable change is the addition of several new keyword lists. In API order, the keywords supported are:

* CSS1 properties
* Pseudo-classes
* CSS2 properties
* CSS3 properties
* Pseudo-elements
* Vendor-specific CSS properties
* Vendor-specific pseudo-classes
* Vendor-specific pseudo-elements

That's an addition of 5 new lists. This might seem a bit extreme, but considering the nature of CSS's evolution and track record for browser support, it is recommended to continue separating the different CSS levels visually.

The extra vendor-specific lists are important for (for example) Firefox extension and theme developers, who may frequently be using the -moz-* properties, pseudo-classes, and pseudo-elements. Of course, editor authors using this lexer can also add Opera, IE, and Webkit vendor-specific keywords to just these three lists.

Some other changes include:

* Asterisks are now treated (styled) as valid tag characters.
* The vertical pipe | and tilde ~ are now treated as selector characters. (CSS namespace selector, and preceding element selector, respectively.)
* Pseudo-classes can be extended with additional simple selectors. (Not sure if extending pseudo-elements in the same way is necessary. The CSS specs don't seem to indicate this kind of usage with pseudo-elements.) Useful for pseudo-classes like :not() and [to lesser extent] :lang(), but also for some vendor-specific pseudo-classes.

A good example of the last point is with the following CSS:

a:-moz-system-metric(windows-default-theme) {
color: red;
}

With two vendor-specific pseudo-classes (-moz-system-metric and windows-default-theme) they will both be styled appropriately. According to Mozilla's own documentation for their vendor-specific extensions to CSS (http://developer.mozilla.org/en/CSS_Reference/Mozilla_Extensions), there are several more usable values for the -moz-system-metric pseudo-class.

That covers the major changes. Patch and patched files included.

Discussion

  • Jason Oster

    Jason Oster - 2008-09-22
     
  • Neil Hodgson

    Neil Hodgson - 2008-09-24
    • labels: --> Scintilla
    • priority: 5 --> 4
    • assigned_to: nobody --> nyamatongwe
     
  • Neil Hodgson

    Neil Hodgson - 2008-09-24

    Suggestions/guidance are more likely on the mailing list. I haven't worked much on HTML/CSS for a while so can't help much. The code compiles cleanly on all three compilers.

     
  • Neil Hodgson

    Neil Hodgson - 2008-10-09

    Since no one said anything on the list this is committed as is.

     
  • Neil Hodgson

    Neil Hodgson - 2009-04-28

    Released in 1.78.

     
  • Neil Hodgson

    Neil Hodgson - 2009-04-28
    • milestone: --> Completed
    • status: open --> closed
     

Log in to post a comment.