[Webkit-unassigned] [Bug 16662] CSS3: Implement calc()

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Thu Jan 28 02:23:36 PST 2010


https://bugs.webkit.org/show_bug.cgi?id=16662





--- Comment #4 from Shinichiro Hamaji <hamaji at chromium.org>  2010-01-28 02:23:33 PST ---
Let me explain this patch. First of all, this patch is not small. I'm happy to
split this into several chunks, but I'd like to post this patch first and get a
chance to receive high level suggestions.

This patch implements CSS3's calc function
(http://www.w3.org/TR/2006/WD-css3-values-20060919/#calc). For now, it is
enabled only for width and height and the name of function is -webkit-calc, not
calc.

For the lexer, I added dimident because ident accepts '-' and for 10px-5px, the
current lexer considers "px-5px" is the dimension of "10".

As for parser, I didn't reuse the current parser for other functions and added
calc_function target because the kinds of arguments calc functions take are
different from other functions.

Changes for Length class would be the most tricky part of this patch. Because
Length objects have only 32bits (a single integer) and we don't want to
increase the size of this objects, I embedded the ID of a calc length in the
Length object. The ID starts from 0, increase to 0x0fffffff (4bits are for type
of length), and return to 0 and increase again. The actual data of calc length
can be obtained via hashmap whose key is the ID and value is the pointer to the
data. As Length is copied by value, the data of calc length is
reference-counted so we can delete them when the length becomes unnecessary.

This patch will be complained by check-webkit-style in CSSParser.cpp. I'm not
sure if I should fix this. I guess check-webkit-style is too strict here.

If high level design of this patch sounds, I'll start creating some patches
which refactor code needed to implement calc. Any kind of comments will be
really appreciated.

Thanks David for your work. Your patch gave me a good start point.

-- 
Configure bugmail: https://bugs.webkit.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.



More information about the webkit-unassigned mailing list