CSS style declaration bytecode ============================== Format ------ [] is 32 bits wide: bits 18-13: value bits 10-17 : flags bits 0-9 : opcode The 8 bits of flag data are defined as follows: bits 2-7: MBZ bit 1 : value is inherit bit 0 : value is important The 14 bits of value are opcode-specific. Parameters are opcode-specific. Each parameter must begin on a 4 byte boundary. Datatype storage ---------------- All numeric values are stored in a 32bit wide field. This field contains a fixed point value with 22 bits assigned to the integer part and 10 bits assigned to the fractional part. Strings are stored as pairs, as per css_string. Pointer's width is the native width of a pointer on the platform. Length's width is the native width of a size_t on the platform. CSS dimensions are stored as two 32bit values: . Length is a 32bit numeric value (as described above) and unit is as follows: bit 8 clear => length unit bits 9-31: MBZ bits 0-7 : 00000000 => px 00000001 => ex 00000010 => em 00000011 => in 00000100 => cm 00000101 => mm 00000110 => pt 00000111 => pc bit 8 set => percentage unit bits 9-31: MBZ bits 0-7 : MBZ bit 9 set => angle unit bits 10-31: MBZ bit 8 : MBZ bits 0-7 : 00000000 => deg 00000001 => grad 00000010 => rad bit 10 set => time unit bits 11-31: MBZ bits 8-9 : MBZ bits 0-7 : 00000000 => ms 00000001 => s bit 11 set => frequency unit bits 12-31: MBZ bits 8-10 : MBZ bits 0-7 : 00000000 => Hz 00000001 => kHz CSS colours are stored as one 32bit value: bits 24-31: Red component bits 16-23: Green component bits 8-15 : Blue component bits 0-7 : Alpha component CSS shapes are stored as one 32bit value followed by n CSS dimensions: bits 1-31: MBZ bit 0 : clear => rect, 4 dimensions follow set => reserved for future expansion TODO: how to handle "auto"? Shorthand properties -------------------- The CSS shorthand properties are handled by decomposing them to their component parts, and then creating bytecode for these. For example, "background: red none no-repeat scroll left top !important;" would be decomposed to: background-color: red !important; background-image: none !important; background-repeat: no-repeat !important; background-attachment: scroll !important; background-position: left top !important; and bytecode generated for each of these properties. The full list of CSS 2.1 shorthand properties is: background border-color border-style border-{top,right,bottom,left} border-width border cue font list-style margin outline padding pause Opcodes ------- 00 - azimuth (14bits) : bits 8-13: MBZ bit 7 set => angle follows. bits 0-6: MBZ bit 6 set => relative movement: bit 7 : MBZ bits 1-5: MBZ bit 0 : set => rightwards, clear => leftwards bits 6 & 7 clear => keyword position: bit 5 : set => behind, clear => in front bits 0-4: 0000 => left-side 0001 => far-left 0010 => left 0011 => center-left 0100 => center 0101 => center-right 0110 => right 0111 => far-right 1000 => right-side other => Reserved for future expansion. 01 - background-attachment (14bits) : 0 => fixed 1 => scroll other => Reserved for future expansion. 02 - background-color (14bits) : bit 8-13: MBZ bit 7 set => colour follows. bits 0-6: MBZ bit 7 clear => keyword colour: bits 1-6: MBZ bit 0 : clear => transparent, set => rffe. 03 - background-image (14bits) : bits 8-13: MBZ bit 7 set => uri string follows. bits 0-6: MBZ bit 7 clear => keyword: bits 1-6: MBZ bit 0 : clear => none, set => rffe. 04 - background-position (14bits) : bits 8-13: MBZ bits 0-7 : bit 7: set => percentage or length unit follows bits 4-6: MBZ clear => keywords: bits 4-6: 000 => right 001 => center 010 => left other => rffe bit 3: set => percentage or length unit follows bits 0-2: MBZ clear => keywords: bits 0-2: 000 => bottom 001 => center 010 => top other => rffe 05 - background-repeat (14bits) : 0 => no-repeat 1 => repeat-x 2 => repeat-y 3 => repeat other => Reserved for future expansion. 06 - border-collapse (14bits) : 0 => separate 1 => collapse other => Reserved for future expansion. 07 - border-spacing (14bits) : bits 8-13: MBZ bits 0-7 : 00000000 => two lengths follow, other => Reserved for future expansion. 08 - border-{top,right,bottom,left}-color (14bits) : bits 10-13: MBZ bits 8-9 : 00 => top 01 => right 10 => bottom 11 => left bits 0-7 : 00000000 => colour follows, 00000001 => transparent, other => Reserved for future expansion. 09 - border-{top,right,bottom,left}-style (14bits) : bits 10-13: MBZ bits 8-9 : 00 => top 01 => right 10 => bottom 11 => left bits 0-7 : 00000000 => none, 00000001 => hidden, 00000010 => dotted, 00000011 => dashed, 00000100 => solid, 00000101 => double, 00000110 => groove, 00000111 => ridge, 00001000 => inset, 00001001 => outset, other => Reserved for future expansion. 0a - border-{top,right,bottom,left}-width (14bits) : bits 10-13: MBZ bits 8-9 : 00 => top 01 => right 10 => bottom 11 => left bits 0-7 : bit 7 set => length follows bits 0-6: MBZ bit 7 clear => keywords: bits 0-6: 0000000 => thin, 0000001 => medium, 0000010 => thick, other => rffe. 0b - bottom (14bits) : bits 8-13: MBZ bits 0-7: bit 7 set => length/percentage follows bits 0-6: MBZ bit 7 clear => keywords: bits 0-6: 0000000 => auto, other => rffe. 0c - caption-side (14bits) : 0 => top 1 => bottom other => Reserved for future expansion. 0d - clear (14bits) : 0 => none 1 => left 2 => right 3 => both other => Reserved for future expansion. 0e - clip (14bits) : bits 8-13: MBZ bits 0-7: bit 7 set => shape follows bits 0-6: MBZ bit 7 clear => keywords: bits 0-6: 0000000 => auto, other => rffe. 0f - color (14bits) : bits 8-13: MBZ bits 0-7: 00000000 => colour follows, other => Reserved for future expansion. 10 - content (14bits) : bits 8-13: MBZ bits 0-7 : bit 7 set => string follows bits 0-6: 0000000 => string, 0000001 => uri, 0000010 => counter, 0000011 => attr, other => rffe. bit 7 clear => keywords: bits 0-6: 0000000 => normal, 0000001 => none, 0000010 => open-quote, 0000011 => close-quote, 0000100 => no-open-quote, 0000101 => no-close-quote, other => rffe. If the value is not "normal", "none", or "inherit", then there is a parameter list. Each item is preceded by a word which declares the type of the next item. The list is terminated by a word with all bits set to zero (the encoding for "normal"). For example, content: open-quote url('http://example.com/') " : " attr(name) close-quote;" would result in the following bytecode: <00080010> <00000081> <00000013> "http://example.com/" <00> <00000080> <00000003> " : " <00> <00000083> <00000004> "name" <00000003> <00000000> 11 - counter-increment (14bits) : bits 8-13: MBZ bits 0-7 : bit 7 set => string or integer follows bits 0-6: 0000000 => string, 0000001 => integer, other => rffe. bit 7 clear => keywords: bits 0-6: 0000000 => none, other => rffe. If the value is not "none", or "inherit", then there is a parameter list. Each item is preceded by a word which declares the type of the next item. The list is terminated by a word with all bits set to zero (the encoding for "none"). 12 - counter-reset (14bits) : bits 8-13: MBZ bits 0-7 : bit 7 set => string or integer follows bits 0-6: 0000000 => string, 0000001 => integer, other => rffe. bit 7 clear => keywords: bits 0-6: 0000000 => none, other => rffe. If the value is not "none", or "inherit", then there is a parameter list. Each item is preceded by a word which declares the type of the next item. The list is terminated by a word with all bits set to zero (the encoding for "none"). 13 - cue-after (14bits) : bits 8-13: MBZ bits 0-7 : bit 7 set => uri follows bits 0-6: MBZ bit 7 clear => keywords: bits 0-6: 0000000 => none, other => rffe. 14 - cue-before (14bits) : bits 8-13: MBZ bits 0-7 : bit 7 set => uri follows bits 0-6: MBZ bit 7 clear => keywords: bits 0-6: 0000000 => none, other => rffe. 15 - cursor (14bits) : bits 8-13: MBZ bits 0-7 : bit 7 set => uri follows bits 0-6: MBZ bit 7 clear => keywords: bits 0-6: 0000000 => auto, 0000001 => crosshair, 0000010 => default, 0000011 => pointer, 0000100 => move, 0000101 => e-resize, 0000110 => ne-resize, 0000111 => nw-resize, 0001000 => n-resize, 0001001 => se-resize, 0001010 => sw-resize, 0001011 => s-resize, 0001100 => w-resize, 0001101 => text, 0001110 => wait, 0001111 => help, 0010000 => progress, other => rffe. If the value indicates that a uri is present, then there is a parameter list. Each item is preceded by a word which declares the type of the next item. The list is terminated by a word with bit 7 clear. 16 - direction (14bits) : 0 => ltr, 1 => rtl, other => Reserved for future expansion. 17 - display (14bits) : 0 => inline, 1 => block, 2 => list-item, 3 => run-in, 4 => inline-block, 5 => table, 6 => inline-table, 7 => table-row-group, 8 => table-header-group, 9 => table-footer-group, a => table-row, b => table-column-group, c => table-column, d => table-cell, e => table-caption, f => none, other => Reserved for future expansion. 18 - elevation (14bits) : bits 8-13: MBZ bits 0-7 : bit 7 set => angle follows bits 0-6: MBZ bit 7 clear => keywords: bits 0-6: 0000000 => below, 0000001 => level, 0000010 => above, 0000011 => higher, 0000100 => lower, other => rffe. 19 - empty-cells (14bits) : 0 => show, 1 => hide, other => Reserved for future expansion. 1a - float (14bits) : 0 => left, 1 => right, 2 => none, other => Reserved for future expansion. 1b - font-family (14bits) : bits 8-13: MBZ bits 0-7 : bit 7 set => string follows bits 0-6: MBZ bit 7 clear => keywords: bits 0-6: 0000000 => Reserved. 0000001 => serif, 0000010 => sans-serif, 0000011 => cursive, 0000100 => fantasy, 0000101 => monospace, other => rffe. If the value indicates that a string is present, then there is a parameter list. Each item is preceded by a word which declares the type of the next item. The list is terminated by a word with all bits clear. 1c - font-size (14bits) : bits 8-13: MBZ bits 0-7: bit 7 set => dimension follows bits 0-6: MBZ bit 7 clear => keywords: bits 0-6: 0000000 => xx-small, 0000001 => x-small, 0000010 => small, 0000011 => medium, 0000100 => large, 0000101 => x-large, 0000110 => xx-large, 0000111 => larger, 0001000 => smaller, other => rffe. 1d - font-style (14bits) : 0 => normal, 1 => italic, 2 => oblique, other => Reserved for future expansion. 1e - font-variant (14bits) : 0 => normal, 1 => small-caps, other => Reserved for future expansion. 1f - font-weight (14bits) : 0 => normal, 1 => bold, 2 => bolder, 3 => lighter, 4 => 100, 5 => 200, 6 => 300, 7 => 400, 8 => 500, 9 => 600, a => 700, b => 800, c => 900, other => Reserved for future expansion. 20 - height (14bits) : bits 8-13: MBZ bits 0-7 : bit 7 set => length or percentage follows bits 0-6: MBZ bit 7 clear => keywords: bits 0-6: 0000000 => auto, other => rffe. 21 - left (14bits) : bits 8-13: MBZ bits 0-7 : bit 7 set => length or percentage follows bits 0-6: MBZ bit 7 clear => keywords: bits 0-6: 0000000 => auto, other => rffe. 22 - letter-spacing (14bits) : bits 8-13: MBZ bits 0-7 : bit 7 set => length follows bits 0-6: MBZ bit 7 clear => keywords: bits 0-6: 0000000 => normal, other => rffe. 23 - line-height (14bits) : bits 8-13: MBZ bits 0-7 : bit 7 set => length/number/percentage follows bits 0-6: 0000000 => number, 0000001 => dimension, other => rffe. bit 7 clear => keywords: bits 0-6: 0000000 => normal, other => rffe. 24 - list-style-image (14bits) : bits 8-13: MBZ bits 0-7 : bit 7 set => string follows bits 0-6: MBZ bit 7 clear => keywords: bits 0-6: 0000000 => none, other => rffe. 25 - list-style-position (14bits) : 0 => inside, 1 => outside, other => Reserved for future expansion. 26 - list-style-type (14bits) : 0 => disc, 1 => circle, 2 => square, 3 => decimal, 4 => decimal-leading-zero, 5 => lower-roman, 6 => upper-roman, 7 => lower-greek, 8 => upper-greek, 9 => lower-latin, a => upper-latin, b => armenian, c => georgian, d => lower-alpha, e => upper-alpha, f => none, other => Reserved for future expansion. 27 - margin-{top,right,bottom,left} (14bits) : bits 10-13: MBZ bits 8-9 : 00 => top, 01 => right, 10 => bottom, 11 => left bits 0-7 : bit 7 set => length or percentage follows bits 0-6: MBZ bit 7 clear => keywords: bits 0-6: 0000000 => auto, other => rffe. 28 - max-height (14bits) : bits 8-13: MBZ bits 0-7 : bit 7 set => length or percentage follows bits 0-6: MBZ bit 7 clear => keywords: bits 0-6: 0000000 => none, other => rffe. 29 - max-width (14bits) : bits 8-13: MBZ bits 0-7 : bit 7 set => length or percentage follows bits 0-6: MBZ bit 7 clear => keywords: bits 0-6: 0000000 => none, other => rffe. 2a - min-height (14bits) : bits 8-13: MBZ bits 0-7 : 00000000 => length or percentage follows, other => Reserved for future expansion. 2b - min-width (14bits) : bits 8-13: MBZ bits 0-7 : 00000000 => length or percentage follows, other => Reserved for future expansion. 2c - orphans (14bits) : bits 8-13: MBZ bits 0-7 : 00000000 => integer follows, other => Reserved for future expansion. 2d - outline-color (14bits) : bits 8-13: MBZ bits 0-7 : bit 7 set => colour follows bits 0-6: MBZ bit 7 clear => keywords: bits 0-6: 0000000 => invert, other => rffe. 2e - outline-style (14bits) : bits 8-13: MBZ bits 0-7 : 00000000 => none, 00000001 => hidden, 00000010 => dotted, 00000011 => dashed, 00000100 => solid, 00000101 => double, 00000110 => groove, 00000111 => ridge, 00001000 => inset, 00001001 => outset, other => Reserved for future expansion. 2f - outline-width (14bits) : bits 8-13: MBZ bits 0-7 : bit 7 set => length follows bits 0-6: MBZ bit 7 clear => keywords: bits 0-6: 0000000 => thin, 0000001 => medium, 0000010 => thick, other => rffe. 30 - overflow (14bits) : 0 => visible, 1 => hidden, 2 => scroll, 3 => auto, other => Reserved for future expansion. 31 - padding-{top,right,bottom,left} (14bits) : bits 10-13: MBZ bits 8-9 : 00 => top, 01 => right, 10 => bottom, 11 => left bits 0-7 : 00000000 => length or percentage follows, other => Reserved for future expansion. 32 - page-break-after (14bits) : 0 => auto, 1 => always, 2 => avoid, 3 => left, 4 => right, other => Reserved for future expansion. 33 - page-break-before (14bits) : 0 => auto, 1 => always, 2 => avoid, 3 => left, 4 => right, other => Reserved for future expansion. 34 - page-break-inside (14bits) : 0 => avoid, 1 => auto, other => Reserved for future expansion. 35 - pause-after (14bits) : bits 8-13: MBZ bits 0-7 : 00000000 => time or percentage follows, other => Reserved for future expansion. 36 - pause-before (14bits) : bits 8-13: MBZ bits 0-7 : 00000000 => time or percentage follows, other => Reserved for future expansion. 37 - pitch-range (14bits) : bits 8-13: MBZ bits 0-7 : 00000000 => number follows, other => Reserved for future expansion. 38 - pitch (14bits) : bits 8-13: MBZ bits 0-7 : bit 7 set => frequency follows bits 0-6: MBZ bit 7 clear => keywords: bits 0-6: 0000000 => x-low, 0000001 => low, 0000010 => medium, 0000011 => high, 0000100 => x-high, other => rffe. 39 - play-during (14bits) : bits 8-13: MBZ bits 0-7 : bit 7 set => string follows bit 6: set => mix, clear => don't mix bit 5: set => repeat, clear => no repeat bits 0-4: MBZ bit 7 clear => keywords: bits 0-6: 0000000 => auto, 0000001 => none, other => rffe. 3a - position (14bits) : 0 => static, 1 => relative, 2 => absolute, 3 => fixed, other => Reserved for future expansion. 3b - quotes (14bits) : bits 8-13: MBZ bits 0-7 : bit 7 set => two strings follow bits 0-6: MBZ bit 7 clear => keywords: bits 0-6: 0000000 => none, other => rffe. If the value indicates that strings are present, then there is a parameter list. Each item is preceded by a word which declares the type of the next item. The list is terminated by a word with all bits clear (the encoding for "none"). 3c - richness (14bits) : bits 8-13: MBZ bits 0-7 : 00000000 => number follows, other => Reserved for future expansion. 3d - right (14bits) : bits 8-13: MBZ bits 0-7 : bit 7 set => length or percentage follows bits 0-6: MBZ bit 7 clear => keywords: bits 0-6: 0000000 => auto, other => rffe. 3e - speak-header (14bits) : 0 => once, 1 => always, other => Reserved for future expansion. 3f - speak-numeral (14bits) : 0 => digits, 1 => continuous, other => Reserved for future expansion. 40 - speak-punctuation (14bits) : 0 => code, 1 => none, other => Reserved for future expansion. 41 - speak (14bits) : 0 => normal, 1 => none, 2 => spell-out, other => Reserved for future expansion. 42 - speech-rate (14bits) : bits 8-13: MBZ bits 0-7 : bit 7 set => number follows bits 0-6: MBZ bit 7 clear => keywords: bits 0-6: 0000000 => x-slow, 0000001 => slow, 0000010 => medium, 0000011 => fast, 0000100 => x-fast, 0000101 => faster, 0000110 => slower, other => rffe. 43 - stress (14bits) : bits 8-13: MBZ bits 0-7 : 00000000 => number follows, other => Reserved for future expansion. 44 - table-layout (14bits) : 0 => auto, 1 => fixed, other => Reserved for future expansion. 45 - text-align (14bits) : 0 => left, 1 => right, 2 => center, 3 => justify, other => Reserved for future expansion. 46 - text-decoration (14bits) : bits 8-13: MBZ bits 0-7 : 00000000 => none otherwise: bits 4-7: MBZ bit 3: set => blink, clear => no blink bit 2: set => line-through, clear => no line-through bit 1: set => overline, clear => no overline bit 0: set => underline, clear => no underline 47 - text-indent (14bits) : bits 8-13: MBZ bits 0-7 : 00000000 => length or percentage follows, other => Reserved for future expansion. 48 - text-transform (14bits) : 0 => capitalize, 1 => uppercase, 2 => lowercase, 3 => none, other => Reserved for future expansion. 49 - top (14bits) : bits 8-13: MBZ bits 0-7 : bit 7 set => length or percentage follows bits 0-6: MBZ bit 7 clear => keywords: bits 0-6: 0000000 => auto, other => rffe. 4a - unicode-bidi (14bits) : 0 => normal, 1 => embed, 2 => bidi-override, other => Reserved for future expansion. 4b - vertical-align (14bits) : bits 8-13: MBZ bits 0-7 : bit 7 set => length or percentage follows bits 0-6: MBZ bit 7 clear => keywords: bits 0-6: 0000000 => baseline, 0000001 => sub, 0000010 => super, 0000011 => top, 0000100 => text-top, 0000101 => middle, 0000110 => bottom, 0000111 => text-bottom, other => rffe. 4c - visibility (14bits) : 0 => visible, 1 => hidden, 2 => collapse, other => Reserved for future expansion. 4d - voice-family (14bits) : bits 8-13: MBZ bits 0-7 : bit 7 set => string follows bits 0-6: MBZ bit 7 clear => keywords: bits 0-6: 0000000 => Reserved. 0000001 => male, 0000010 => female, 0000011 => child, other => rffe. If the value indicates that a string is present, then there is a parameter list. Each item is preceded by a word which declares the type of the next item. The list is terminated by a word with all bits clear. 4e - volume (14bits) : bits 8-13: MBZ bits 0-7 : bit 7 set => number/percentage follows bits 0-6: 0000000 => number, 0000001 => dimension, other => rffe. bit 7 clear => keywords: bits 0-6: 0000000 => silent, 0000001 => x-soft, 0000010 => soft, 0000011 => medium, 0000100 => loud, 0000101 => x-loud, other => rffe. 4f - white-space (14bits) : 0 => normal, 1 => pre, 2 => nowrap, 3 => pre-wrap, 4 => pre-line, other => Reserved for future expansion. 50 - widows (14bits) : bits 8-13: MBZ bits 0-7 : 00000000 => integer follows, other => Reserved for future expansion. 51 - width (14bits) : bits 8-13: MBZ bits 0-7 : bit 7 set => length or percentage follows bits 0-6: MBZ bit 7 clear => keywords: bits 0-6: 0000000 => auto, other => rffe. 52 - word-spacing (14bits) : bits 8-13: MBZ bits 0-7 : bit 7 set => length follows bits 0-6: MBZ bit 7 clear => keywords: bits 0-6: 0000000 => normal, other => rffe. 53 - z-index (14bits) : bits 8-13: MBZ bits 0-7 : bit 7 set => integer follows bits 0-6: MBZ bit 7 clear => keywords: bits 0-6: 0000000 => auto, other => rffe. 54-3ff - Reserved for future expansion.