-
Notifications
You must be signed in to change notification settings - Fork 0
Representation of computed style
In WebKit, the computed style is represented by a RenderStyle
object. Most of RenderStyle
consists of two large bitfields: InheritedFlags
and NonInheritedFlags
.
InheritedFlags
consists of:
- empty cells
caption-side
-
list-style-type
,list-style-position
visibility
-
text-align
,text-transform
,text-decoration
cursor-style
text-direction
border-collapse
white-space
box-direction
writing-mode
- … as well as some random non-inherited flags, presumably thrown in here to pack bitfields.
NonInheritedFlags
consists of:
display
-
overflow-x
,overflow-y
vertical-align
-
clear
,float
position
There are also pointers to five reference-counted non-inherited sub-structs (presumably reference counted so that they can be shared): StyleBoxData
, StyleVisualData
, StyleBackgroundData
, StyleSurroundData
, and StyleRareNonInheritedData
(and also optionally SVGRenderStyle
). Additionally, there are two pointers to inherited sub-structs, also reference counted: StyleRareInheritedData
and StyleInheritedData
.
In general the strategy seems to be: pack into a bitfield where possible, otherwise throw into a reference-counted side struct. Bitfields and structs are generally separated into inherited and non-inherited fields.
In Servo we would like to perform CSS selector matching in parallel, which means that style structs are going to need to be thread-safe. We may be forced to do atomic reference counting for the sub-structs, which is unfortunate. Assuming we find a solution to that, it seems that WebKit's bitfield approach would probably work for Servo.