On Tue, 2009-07-21 at 15:14 +0930, Christopher Martin wrote:
> Dear NetSurf Developers,
> 
> Please find attached a small diff file showing alterations to
> <render/layout.c> to work around a problem with
> <http://www.v3.co.uk/vnunet/news/2228123/ai-gets-step-closer> that
> causes NetSurf to crash. The alteration causes NetSurf to default to
> behaviour consistent with CSS_DIRECTION_LTR in all cases in which
> CSS_DIRECTION_RTL has not been specified. This avoids an assert-caused
> crash when box->parent->style->direction is not specified or is some
> value other than one of {CSS_DIRECTION_LTR, CSS_DIRECTION_RTL}.

I'm not convinced by this change. Firstly, there are only two valid
values for the direction property -- LTR or RTL. It should not be any
other value. If it is, that's a bug. Secondly, see below.

> Index: render/layout.c
> ===================================================================
> --- render/layout.c     (revision 8638)
> +++ render/layout.c     (working copy)
> @@ -3493,18 +3493,13 @@
>         else {
>                 /* over constrained => examine direction property
>                  * of containing block */
> -               if (containing_block->style) {
> -                       if (box->parent->style->direction ==
> -                                       CSS_DIRECTION_LTR)
> -                               /* left wins */
> -                               right = -left;
> -                       else if (box->parent->style->direction ==
> -                                       CSS_DIRECTION_RTL)
> +               if (containing_block->style && (box->parent->style->direction 
> ==
> +                                       CSS_DIRECTION_RTL)) {
>                                 /* right wins */
>                                 left = -right;

There is no guarantee that box->parent is the containing block.
Therefore, this is consulting entirely the wrong style struct, anyway.
It should be looking at containing_block->style->direction.

This is fixed on the libcss branch, fwiw.


J.


Reply via email to