CSS Object Model Api
The stylesheet seen as an in memory tree.
The CSSOM api allows the application to parse the stylesheet and
build an in-memory representation (aka object model) of the
stylesheet. That in-memory representation is actually a tree.
What does the tree looks like ?
Basically, a CSS stylesheet is a list of statements.
So the CSSOM tree is actually a list of statment nodes.
A statement can be of several types:
-
ruleset
example:
P, H {color: black ; display: block} -
@import rule
example:
@import url (http://chezmoi.org/mafeuille.css) - etc ...
So, a statement node (remember, we are in a tree) of type ruleset, for example, will have children nodes. One child node for the selector list of the rulesets and another one for the list of property declarations...
At this point, the best thing to do to see what the nodes in the CSSOM tree look like is to have a look at the api documentation automatically extracted from the source code comments.
Some code examples
-
cssom-example-1.c is a small program that parses a CSS document using the CSSOM api and prints it back to the screen.
Please, read it, try to compile it (some hints about how to compile it are given in the comments at the beginning of the file) and launch it.
