summaryrefslogtreecommitdiffstats
path: root/src/3rdparty/libcroco/docs/design/sel-instr.txt
blob: 6b19389951fde82f8ca8ab2ac3145a2f0da1e6bf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
Draft of the libcroco selector internal instruction set.
*********************************************************

READERS SHOULD READ THE CHAPTER 5 of THE CSS2 CSS2 SPEC INTITLED
"Selectors" FIRST.

I) Introduction
''''''''''''''''''''
This is the instructions set understood by the libcroco
sel-eng.c module (Selection engine).

The purpose of the selection engine is to basically to say whether if a given
xml node is matched by a given css2 selector or not.

II) Rationale
''''''''''''''''''''
For the sake of performance (mostly processing speed) each CSS2
selector is compiled into a sequences of atomic selection instructions
that are easily executable by the selection engine.

III) Selection instruction set overview
''''''''''''''''''''''''''''''''''''''''

Each selection instruction returns a boolean value (TRUE or FALSE).
The execution of a sequence of selection instruction stops at the
first instruction that returns a FALSE value and the selection engine
returns returns the value FALSE to say that the current xml node
is matched by the CSS2 selection expression being evaluated.

Note that during the evaluation of a CSS2 selection expression,
all the contextual information are stored into an evaluation context.
For example, the context will hold a pointer to the xml node the
selection engine is trying to match.

III.1) The instruction set.
'''''''''''''''''''''''''''

set-cur-node 'a_node'
----------------------
a_node: an xml node
Sets the current xml node (in the context) to a_node.

match-n-ancestor 'a_n' 'a_parent' 
----------------------------------
a_parent: a string.
a_n: a number. The depth of the ancestor

Returns true if the current xml node has an ancestor
located at a depth 'n' (going upward from the current node)
and named 'a_parent'. An ancestor located at depth '0' designates
the current xml node. An ancesstor located at depth '1' designates
the parent of the current xml node etc ...

match-any
---------
Always returns true.

match-first-child 'a_name'
--------------------------
Returns true if the current xml element's name equal 'a_name' and
if the current xml element is the first child of its parent.

TODO: continue reading the chapter 5 of the css2 spec and finish
the design of this instruction set.