Wednesday, 19 June 2013

Re: Add support for parsing writing-mode property v1

In article <DA20EE2B-0DB9-4C88-9389-A14C8695F5C7@defpixel.com>,
Caitlin Potter <snowball@defpixel.com> wrote:

> I just realized I've forgotten to attach the current version of the
> writing-mode property patch, so here :>


Thanks for the patch.

I've attached a new version. The changes are:

+ Whitespace fixes

+ Added the writing-mode property handler to the handler table
(The /src/parse/properties/properties.c change)

+ Moved the WRITING_MODE propstring, so the property propstrings are
in alphabetical order.

+ Added the computed style accessor for writing-mode
(The /include/libcss/computed.h and /src/select/computed.c changes)

+ Added parser tests for the writing-mode property's bytecode
(The /test/data/parse/properties.dat change)

+ Added some illegal value handling tests for writing-mode property
(The /test/data/parse2/illegal-values.dat change)

+ Updated the test code to dump writing-mode property
(The /test/dump.h and /test/dump_computed.h changes)

+ Updated the select test data for writing-mode.

This currently fails on a test that doesn't set writing-mode, but the
default value in the expected and test result don't match.

The test data expects "writing-mode: inherit" but gets
"writing-mode: vertical-rl".

Seems to be something to do with uncommon property defaults.

> I could use some guidance writing parse/select tests for the property
> because even after studying the test programs and data files, it's not
> really obvious what the system is

The parse ones are quite simple. A rule is set in the #data section.
Then in the #expected section, you write the bytecode you expect. So
for

writing-mode: vertical-lr ! important

>From docs/Bytecode:

<opcode+flags+value> is 32 bits wide:
bits 18-31: value
bits 10-17 : flags
bits 0-9 : opcode

The 8 bits of flag data are defined as follows:
bits 2-7: Must Be Zero (MBZ)
bit 1 : value is inherit
bit 0 : value is important

...

6f - writing-mode
<value> (14bits) :
bits 8-13: MBZ
bits 0-7 :
00000000 => horizontal-tb,
00000001 => vertical-rl,
00000010 => vertical-lr,
other => Reserved for future expansion.

The opcode for writing-mode is 6f, we have important set, so bit 0 of
flags is set, and for value we have vertical-lr, so 0b00000010.

The expected result is those components stitched together and expressed in
hex:

0x0008046f

--

Michael Drake (tlsa) http://www.netsurf-browser.org/

No comments:

Post a Comment