Bug 31036 - need a height equivalent of RenderBox::minPrefWidth()
Summary: need a height equivalent of RenderBox::minPrefWidth()
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Layout and Rendering (show other bugs)
Version: 528+ (Nightly build)
Hardware: All All
: P2 Enhancement
Assignee: Aaron Boodman
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-11-02 17:16 PST by Erik Kay
Modified: 2009-11-18 18:04 PST (History)
4 users (show)

See Also:


Attachments
patch (2.69 KB, patch)
2009-11-13 16:09 PST, Aaron Boodman
no flags Details | Formatted Diff | Diff
tabs to spaces (2.70 KB, patch)
2009-11-13 16:11 PST, Aaron Boodman
eric: review+
aa: commit-queue-
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Erik Kay 2009-11-02 17:16:16 PST
(apologies if an API like this already exists, but I haven't been able to find it)

For Chrome's extension system, we let the extension create a popup widget using HTML.  This popup widget's size is (mostly) unconstrained externally.  The idea is to let the developer take advantage of some dynamic layout so that they don't have to worry about issues like system font sizes and localization.  Obviously, the developer needs to put some constraints in (whitespace: nowrap,  , an explicit width or height on an element, etc.).

I can get pretty close to my goal by using RenderBox::minPrefWidth() (on RenderView) and using contentHeight() for the height and resizing the RenderView to match.  Unfortunately, with this technique, the height will never shrink.  There doesn't seem to be a way to ask for the "intrinsic height" of the view at its current width.  I'm assuming this must be known somewhere in order to calculate the overflow if any, but it looks like this value isn't saved or exposed.
Comment 1 Dave Hyatt 2009-11-04 17:53:01 PST
Just size the height of the view to 0 and then get the lowestPosition.
Comment 2 Erik Kay 2009-11-05 07:49:21 PST
Thanks for replying Dave.  I'm not sure if your suggestion will work for me.  There are two issues.  The first issue is that since there's no real way to know when layout is "done", there's not a good point for me to know when size it back to the correct height so that it can draw.  When I have the view sized to a zero height, I can't draw it, so this affects the responsiveness of the UI (how long it takes for me to be able to display the widget initially).  

The second (related) issue is that given that I want to display the widget as quickly as possible, I really need to be able to respond to size changes dynamically and resize the view accordingly.  This would put me in a position of having to toggle back and forth between a zero height and the desired height after each layout, just to be able to see if the height changed.  I'm concerned that it may be difficult to do that without introducing some serious flicker.
Comment 3 Aaron Boodman 2009-11-06 15:46:32 PST
Dave, do you know where the correct state might live in WebCore so that we could add plumbing to make it more accessible to a WebKit host?
Comment 4 Aaron Boodman 2009-11-13 16:09:45 PST
Created attachment 43209 [details]
patch

This isn't a complete solution because it doesn't work in quirks mode. I will create a separate bug to fix that, harder problem.
Comment 5 Aaron Boodman 2009-11-13 16:11:27 PST
Created attachment 43210 [details]
tabs to spaces
Comment 6 Eric Seidel (no email) 2009-11-13 16:26:25 PST
I do not know if this is the height value you want.  The patch is certainly non-harmful however, so I'm happy to r+ it.  But, I think you should seek confirmation from other web experts as to if document.scrolleHeight will be sufficient.
Comment 7 Aaron Boodman 2009-11-13 16:40:17 PST
Thanks.

Erik Kay requested that I add to this bug what I found with fixing quirks
mode in case someone else wants to pick it up:

The important routine is RenderBox::calcHeight(). At the end of that method, if
the document is in quirks mode, the calculated height is overwritten with a
different one that is computed a different way (look for the comment that
starts with "WinIE").

I think that in order to get what we want in quirks mode, we would need to
store that first, unquriked value from calcHeight(), and then add a new method
like scrollHeightWithoutQuirks() or some such that uses the non-quirked height.

(It could probably be factored nicer).
Comment 8 Aaron Boodman 2009-11-13 17:03:28 PST
Comment on attachment 43210 [details]
tabs to spaces

Rejecting patch 43210 from commit-queue.

Found no modified ChangeLogs, cannot create a commit message.
All changes require a ChangeLog.  See:
http://webkit.org/coding/contributing.html
Comment 9 Aaron Boodman 2009-11-13 17:04:41 PST
Comment on attachment 43210 [details]
tabs to spaces

Rejecting patch 43210 from commit-queue.

Found no modified ChangeLogs, cannot create a commit message.
All changes require a ChangeLog.  See:
http://webkit.org/coding/contributing.html
Comment 10 Eric Seidel (no email) 2009-11-18 17:53:33 PST
Aaron, looks like this never quite made it in.  Would you like me to cq+ it?  The commit-queue is back up and running fine now.
Comment 11 Aaron Boodman 2009-11-18 17:58:52 PST
It did make it, I'm afraid:
http://trac.webkit.org/changeset/50983

When I was trying to repeat the steps you showed me to workaround the problem we encountered with bugzilla-tool, I accidentally submitted this with my git change description, which was not very informative.
Comment 12 Eric Seidel (no email) 2009-11-18 18:04:24 PST
Thanks for the update!  Doing your first commit on a new machine is always a bit tricky.  Sorry our process isn't simpler. :(