Re: [CSS21] Overflow and scroll bar behavior

Andrew Fedoniouk wrote:
> Original Message from: "Mikko Rantalainen (by way of Bert Bos
> <bert@w3.org>)"
>
>> Andrew Fedoniouk wrote:
>> > As you know straightforward implementation of overflow:auto when
>> > size of content is close to the size of viewport is potentially
>> > oscillating function. And could not be implemented without use of
>> > heuristics limiting the number of oscillations. (Size of viewport
>> > is changing when scrollbars appear). If you will move scrollbars
>> > out of the viewport calculation become stable two step process.
>>
>> How about following algorithm:
>> 1) Try to fit content without scroll bars
>> 2) If 1 fails, add vertical scroll bar and try again
>> 3) If 2 fails, remove vertical scroll bar, add horizontal
>>    scroll bar and try again
>> 4) If 3 fails, add both vertical and horizontal scroll bars
>>    and render the content.
>
> Ideal sequence of actions (my guess) looks like this:

Why do you think that is any closer to perfect than the one I
 suggested?

> Your solution is a sort of heuristic which means will possibly
> show scrollbars when they don't needed or otherwise - will not
> show them when they needed. Especially when content width/height
> is close to container width/height +/- scrollbar size. Seems like
> this is what Mozilla uses.

I don't agree with this claim. Either something fits in the viewport
or it doesn't. That is not a heuristic. Let's check my algorithm again:

1) if the content fits the viewport without scroll bar we have no
    problem (seems OK to me)
2) if the content fits with just the vertical scroll bar we have no
    problem. It might be possible to fit the content with just the
    horizontal scroll bar instead of vertical scroll bar but usually
    the end user expect to see vertical scroll bar so there's no
    reason to default to horizontal scroll bar instead. If you don't
    agree, just swap 2) and 3) in my algorithm. (OK)
3) Same as above. Though, it isn't possible that the content could
    fit with just vertical scroll bar so if it fits with only
    horizontal scroll bar, it's the perfect choice. (OK)
4) The content cannot be flowed so that it could fit the viewport
    without both horizontal and vertical scroll bars. So content must
    be rendered with with both scroll bars. (OK)

The problems you see in Mozilla isn't because of some (pseudorandom)
heuristic but because of bugs in implementation of "does it fit?".
If you can't have reliable answer to that question, you have no way
to fit anything perfectly.


A more interesting scroll bar problem would be following:

if the viewport has width of 200px and height of 200px and we have
following document

<root><div></div></root>

combined with following style

* { margin: 0; padding: 0; border: 0; }
div { float: right; width: 300px; height: 10px; }

how should the div be positioned? Should the viewport have
scrollbars? What's the computed width of the root element?

Does the following ASCII image match with the expected rendering?

  +------+----------+ <-- DIV
  +------+----------+

         |          | <-- viewport

         +----------+

--
Mikko

Received on Monday, 22 November 2004 10:42:34 UTC