Re: [libcroco-list] Inheritance & Initial value



On Wed, 2004-03-17 at 02:43, Benjamin Dauvergne wrote:
> In the css spec all properties have an initial value but some inherit it
> and some don't. But in cr-style.c we have only one function to set the
> initial value of the style, that is cr_style_set_props_to_defaults, but
> it sets the default value of each property to their initial value. 
> In fact should'nt the default value be INHERIT when the property is not
> part of the root style and the property is of the inherited type?

Yes, CRStyle fields of scalar types (like enums) should be assigned to
the value INHERIT (or something like that) when the matching property is
set to the 'inherit' value in the input css.
 
Fields of CRStyle of Composite types, like CRRgb, or CRNum etc ... could
have a "boolean is_inherited" field (or something like that) and that
boolean should be set to TRUE when the matching property is set to the
'inherit' value in the input css.

> 
> I think their should be two functions:
> cr_root_style_set_props_to_defaults, where all props are set to their
> 'initial value' and cr_style_set_props_to_defaults where props that are
> of the inherited type are set to INHERIT, and other props are set to
> their initial value.

Well, I am not sure to understand you correctly here, so let me write
what I think should be done.

When the CRStyle is instanciated using cr_style_new (), you don't know
if the style is to be associated to the root xml element or not.
However, that CRStyle needs to be initialized to something. In
cr_style_new (), we (should) call cr_style_set_props_to_default () to
initialize all the properties to :
- either an initial value, if they can have one
- or to the value "inherited" for those values that are to be inherited.

The actual css properties defined in the CSS get "compiled" into the
CRStyle structure *later*. (I will use the term "css property
compilation" to refer to the process of transforming the css properties
declarations from their CSSOM form (CRDeclaration) to the strongly typed
CRStyle structure form).

So, at the CSS properties compilation time, 4 (exclusive) things can
happen to each property:

	- an inherited property that is explicitely set to an "initial value"
(read something different from the value 'inherited') in the input CSS
gets compiled into a CRStyle field assigned to something different from
the 'INHERITED' value.
	- an inherited property that is not explicitely set in the input CSS
just get compiled into a CRStyle field assigned to the INHERITED value.
	- a non inherited property that is explicitely set to an initial value
in the input CSS gets compiled into a CRStyle field assigned to a value
different from the INHERITED value.
	- a non inherited property that is not explicitely set to an initial
value in the input CSS gets compiled into a CRStyle field assigned to a
'default value'.


> Another problem is where should be done the propagating of inherited
> properties from the parent style to their children? Some is done in
> cr-style.c when the 'inherit' value is read from the stylesheet, some
> other is done directly in sewfox. So should-it be staticaly propagated
> somewhere in libcroco ? dynamicaly in sewfox ?

Yes, true. Today, inheritance handly is messy and buggy.
The computing of the style "computed values" being done in the layout
engine (in function layout_box (), the call to
speficied_2_computed_value ().), I would suggest to call a function that
that resolves the inheritance right after the call to the
specified_2_computed_value () function.

Regards,

Dodji.





[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]