sizeToContent fails if all of the body's block-level elements have no defined width values

RESOLVED INVALID

Status

()

Core
DOM: Core & HTML
RESOLVED INVALID
16 years ago
13 years ago

People

(Reporter: Gérard Talbot, Unassigned)

Tracking

({dom0, testcase})

Trunk
x86
Windows XP
dom0, testcase
Points:
---

Firefox Tracking Flags

(Not tracked)

Details

Attachments

(2 attachments)

(Reporter)

Description

16 years ago
User-Agent:       Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.3b) Gecko/20030104
Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.3b) Gecko/20030104

When the body element of a window has only block-level elements with the default
css declaration width:auto or width:100%, then sizeToContent fails miserably.
Such window will be enlarged to screen.availWidth value. SizeToContent() method
appears only to work (or work as intended) when the body has an element with a
defined absolute [computable] value.

Reproducible: Always

Steps to Reproduce:
1. Load the document (parent window) of the upcoming reduced test case
2. Open up the popup window with the button
3. Click the button to call the sizeToContent method
Actual Results:  
- The popup window is enlarged to a point where its innerWidth value is equal to
the screen.availWidth value. Only the width of the popup window is increased.
- The vertical scrollbar it had before calling the sizeToContent method is still
there after calling sizeToContent
- The height of the window is reduced
- more explanations along with upload of reduced test case

Expected Results:  
- The popup window width *_and_* height should increased until both scrollbars
(if present) in the starting window situation are no longer needed and are no
longer rendered.

The primary main goal of using the sizeToContent() method for a web designer
would be to size the window accordingly so that scrollbars would not be
necessary, needed nor rendered. Failing to achieve that, then the
sizeToContent() method is useless, worthless.
(Reporter)

Comment 1

16 years ago
Created attachment 110724 [details]
Popup window for testing sizeToContent() method

Load the parent-opener instead which is upcoming next
(Reporter)

Comment 2

16 years ago
Created attachment 110727 [details]
Opener for testing sizeToContent() on popup

Load this file, open up the popup window then sizeToContent() the popup window.
The popup window will be enlarged to the value of screen.availWidth, the height
of the window will be reduced and the vertical scrollbar it had before calling
sizeToContent will still be there.

Note that other bugs will be present in this testcase:
- part of the content of the popup will be off the screen (bug 176342)
- calling again sizeToContent will furthermore reduce the height of the popup
window: that might be bug 90276 or another bug where miscalculation happens
but these other bugs are fairly independent, distinct of this bug and their
manifestations should be ignored
(Reporter)

Comment 3

16 years ago
Some references:
----------------
CSS2
10.2 Content width: the 'width'
propertyhttp://www.w3.org/TR/CSS2/visudet.html#propdef-width

10.3.3 Block-level, non-replaced elements in normal flow
http://www.w3.org/TR/CSS2/visudet.html#q6

sizeToContent():
http://www.mozilla.org/docs/dom/domref/dom_window_ref117.html#1021468

Keywords: dom0
(Reporter)

Updated

16 years ago
Keywords: testcase
Mass-reassigning bugs to dom_bugs@netscape.com
Assignee: jst → dom_bugs

Comment 5

14 years ago
Verified with Moz 1.7.3 on WinXP. There are other similar bugs (search for
sizeToContent in the bug summary), but am not sure if this one is a dup of any
others or not. Marking NEW.
Status: UNCONFIRMED → NEW
Ever confirmed: true
sizeToContent sizes to the preferred size of the content.  The preferred size of
the block is "as wide as I can get, then as tall as I need to be".

So this is invalid.  sizeToContent() is doing the best it can given the CSS box
model.  In a different box model (eg XUL's constraint-based one) it can do a
much better job, of course.
Status: NEW → RESOLVED
Last Resolved: 13 years ago
Resolution: --- → INVALID
You need to log in before you can comment on or make changes to this bug.