- From: Christian Biesinger <cbiesinger@google.com>
- Date: Thu, 25 Apr 2013 12:10:54 -0700
- Cc: whatwg@lists.whatwg.org
On Thu, Apr 25, 2013 at 11:05 AM, Boris Zbarsky <bzbarsky@mit.edu> wrote: > On 4/25/13 1:58 PM, Christian Biesinger wrote: >>> >>> Gecko puts the baseline of the button at the baseline of the button's >>> text, >>> and if the button is not auto-height the extra height is added (or >>> removed) >>> equally from above and below the text. >> >> >> Hm, but I don't think that's completely correct, because then the >> positioning should stay the same when I start entering text in the >> button, right? Or does adding text make the text run have height, >> affecting where the extra height gets added? > > > If I recall exactly how this code works, if there is no text then the > baseline goes at the bottom of the (empty) content box and then the extra > height is added on both sides. Once you have text the baseline goes on the > baseline of the text, which is slightly above the bottom of the content box > to allow for descenders. Ah... I see. So my formula below is not quite correct in that text_ascent is only added if there is text. >> I think what you are saying is: in Gecko, baseline of a button is >> (content_box_height - text_height) / 2 + text_ascent > > > Mm.... Measured from where? >From the top of the content box? Maybe I'm using the term wrong - I mean the border-box minus borders and padding, which is a slightly different definition than you used above. >> (BTW, where is that code located? I tried and failed to find it :( ) > > > http://hg.mozilla.org/mozilla-central/file/690b5e0f6562/layout/forms/nsHTMLButtonControlFrame.cpp#l308 > (see the GetBaseline() call and the adjustment by "yoff", where "yoff" is > half of the extra height we have. This is computing the ascent of the box; > the baseline position in the box is then considered to be "ascent" from the > top. Ah, I see. It's not entirely clear to me what ASK_FOR_BASELINE means and what ascent is initialized to when it's not set to that value, but perhaps those details are not so important right now. That said, what if there is no child? I guess this discussion doesn't really belong on this mailing list. -christian
Received on Thursday, 25 April 2013 19:11:21 UTC