Re: Clarification on getBBox() with shapes of zero width

On Thu, Aug 9, 2012 at 6:09 AM, Dirk Schulze <dschulze@adobe.com> wrote:

>
> On Aug 9, 2012, at 4:37 AM, "Robert Longson" <longsonr@gmail.com> wrote:
>
> >> getBBox() "Returns the tight bounding box in current user space"
> >> therefore is independent of any rasterizers, Cairo or anything like
> that.
> >
> > Getting the bounding box of a path with cubic/quadratic besziers is
> > non-trivial. Cairo does this for us.
>
> More important is rect, circle, ellipse. At webkit we learned to do simple
> math without the graphic library. Especially Cairo graphics used to be not
> very fast.
> I am not so sure about path so. Even if it should give the bbox as well,
> it might be difficult on webkit as well.
>

It's not too hard to find a tight bounding box of a bezier:
http://processingjs.nihongoresources.com/bezierinfo/

Alternatively, you can just subdivide the bezier into line segments as
usual and calculate the bounds that way.


>
>
> >
> >>
> >> Robert, I very much doubt the code in FF is reaching down into Cairo
> >> to get the boudning box unless you are doing some weird reverse
> transform
> >> that I did at one time and found it couldn't follow the getBBox
> implementation
> >> rules and tests.
> >
> >
> http://mxr.mozilla.org/mozilla-central/source/layout/svg/base/src/nsSVGPathGeometryFrame.cpp#354
> .
>
>
> >
> >>
> >> So no doubt (0,100) is correct.
> >>
> >> Similarly, display:none has no effect on the user space co-ordinate
> system
> >> and should return the same values.
> >
> > If you want this included then set the visibility to hidden. Its very
> > hard for Firefox to meet the svg specification requirements on
> > display:none as we're constrained by html implementation performance
> > e.g. having things such as markers render when they are set to
> > display:none.
>
> Same occurs to webkit. We would not support it for display:none. Looks
> like ie has problems with it as well.
>
> >
> >>
> >> Philip is correct, Opera is the only implementation in the tested group
> >> that does the correct thing.
> >>
> >> Returning a value of (0,0) for display:none is wrong - the calculation
> >> should be done in user space where the element exists and whether it
> >> gets rendered or not is immaterial in regard to its actual geometry.
> >>
> >
> > I suspect we'll just continue to be wrong then in what to me, are edge
> > cases which can be worked around by authors anyway .
>
> At least for display:none the same occurs to webkit. And possibly ie.
>
> Greetings,
> Dirk
>
> >
> > Best regards
> >
> > Robert.
>
>

Received on Thursday, 9 August 2012 20:37:48 UTC