Legend and fieldset layout

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Legend and fieldset layout

Boris Zbarsky
How much of the current weirdness in the way we lay out legend and fieldset do
we want to preserve?  The current algorithm is basically as follows:

1)  Find the preferred width of the legend.
2)  Set the available space to the max of available space and legend prefwidth
3)  Reflow the contents.
4)  Set our desired size to the content width.

Note that this means the following:

   * "Too-small" CSS widths are ignored.
   * Legend text never wraps
   * Fieldsets "expand out" to be at least the width of the legend (with no
     wrapping)

All of this applies to both block and inline fieldsets.

How much of this do we need to preserve?  What do other browsers do?

Also, in the new world if a block overrides its desired width so it's not equal
to the computed width (the way fieldsets do now), does that still work wrt
auto-margin centering, etc?

-Boris
_______________________________________________
dev-tech-layout mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-tech-layout
Reply | Threaded
Open this post in threaded view
|

Re: Legend and fieldset layout

Boris Zbarsky
Boris Zbarsky wrote:
> How much of this do we need to preserve?  What do other browsers do?

I've thought about it a bit, and I'm going to preserve as much as I can for the
time being.  If we decide to make changes later (after reflow branch lands), we
can...

-Boris
_______________________________________________
dev-tech-layout mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-tech-layout
Reply | Threaded
Open this post in threaded view
|

Re: Legend and fieldset layout

Boris Zbarsky
So about this business of ignoring the CSS specified width...
nsLayoutUtils::IntrinsicForContainer really doesn't like that.  I'm ending up
with the fieldset spilling out of the table in the following testcase:

   <table border="1">
     <tr> <td>
       <fieldset style="width: 5px;">
         <legend>Some long legend</legend>
         Some actual text goes here.
       </fieldset>
     </td> </tr>
   </table>

How are we handling this for tables, which also override the CSS-specified width?

-Boris
_______________________________________________
dev-tech-layout mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-tech-layout
Reply | Threaded
Open this post in threaded view
|

Re: Legend and fieldset layout

L. David Baron
On Friday 2006-04-28 12:18 -0500, Boris Zbarsky wrote:

> So about this business of ignoring the CSS specified width...
> nsLayoutUtils::IntrinsicForContainer really doesn't like that.  I'm ending
> up with the fieldset spilling out of the table in the following testcase:
>
>   <table border="1">
>     <tr> <td>
>       <fieldset style="width: 5px;">
>         <legend>Some long legend</legend>
>         Some actual text goes here.
>       </fieldset>
>     </td> </tr>
>   </table>
>
> How are we handling this for tables, which also override the CSS-specified
> width?
For tables it's handled in nsTableOuterFrame::GetPrefWidth and
GetMinWidth.  Maybe we need something more general.

-David

--
L. David Baron                                <URL: http://dbaron.org/ >
           Technical Lead, Layout & CSS, Mozilla Corporation

_______________________________________________
dev-tech-layout mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-tech-layout

attachment0 (196 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Legend and fieldset layout

Boris Zbarsky
In reply to this post by Boris Zbarsky
L. David Baron wrote:
>> So about this business of ignoring the CSS specified width...
>> nsLayoutUtils::IntrinsicForContainer really doesn't like that.  I'm ending

> For tables it's handled in nsTableOuterFrame::GetPrefWidth and
> GetMinWidth.  Maybe we need something more general.

Well, the problem is that GetPrefWidth/GetMinWidth are never called from
nsLayoutUtils::IntrinsicForContainer when a width is specified...

I do think we need something more general.  The way I ran into this is testing a
fieldset with a specified width and auto margins:

   <fieldset style="width: 5px; margin: auto">
     <legend style="width: 50px">This is a test of the fieldset centering code, I
                                 believe</legend>
     Some actual text goes here.
   </fieldset>

But tables have a similar issue:

   <table style="width: 10px; margin: auto" border="1">
     <tr><td>
       ThisIsALongWordThisIsALongWordThisIsALongWordThisIsALongWord
     </td></tr>
   </table>

It seems to me that what we need to do for these frames is to allow them to
override the mComputedWidth (either via some hook or by hardcoding checks in the
reflow state) in ComputeBlockBoxData...  Come to think of it, this is where your
XXX comment about tables is, right?  So perhaps for table and fieldset we should
simply set the computed min-width to the intrinsic min-width (with appropriate
song-and-dance to handle box-sizing)?

-Boris
_______________________________________________
dev-tech-layout mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-tech-layout