Closed Bug 361049 Opened 18 years ago Closed 18 years ago

Zooming to fit contents fails miserably

Categories

(Camino Graveyard :: General, defect)

PowerPC
macOS
defect
Not set
normal

Tracking

(Not tracked)

RESOLVED FIXED
Camino1.5

People

(Reporter: mozbugs, Assigned: torben)

References

()

Details

(Keywords: fixed1.8.1.1)

Attachments

(2 files, 1 obsolete file)

User-Agent:       Mozilla/5.0 (Macintosh; U; PPC Mac OS X Mach-O; en-US; rv:1.8.1) Gecko/20061115 Camino/1.1a1+
Build Identifier: Mozilla/5.0 (Macintosh; U; PPC Mac OS X Mach-O; en-US; rv:1.8.1) Gecko/20061115 Camino/1.1a1+

On www.pcworld.co.uk, clicking the green button to zoom to fit contents results in a normal-width but approx 10px-high content area.

Reproducible: Always

Steps to Reproduce:
1. Go to www.pcworld.co.uk
2. Click green button at top of window to fit window to contents (in branch build 20061115)

Actual Results:  
As described above

Expected Results:  
Resizes to fit contents like Safari does.
Attached file Reduced testcase
Attached testcase with fairly minimal content; hopefully someone can see what the problem is.
Yeah, that is the same problem I was talking about in bug 360880.
Document in Quirksmode.
All content in an absolute positioned div.

(Thanks for the testcase, btw)
Let's dupe it, then.

*** This bug has been marked as a duplicate of 360880 ***
Status: UNCONFIRMED → RESOLVED
Closed: 18 years ago
Resolution: --- → DUPLICATE
Reopening, this is not bug 360880, the symptoms are opposite.
Status: VERIFIED → UNCONFIRMED
Resolution: DUPLICATE → ---
Status: UNCONFIRMED → NEW
Ever confirmed: true
OS: Mac System 9.x → Mac OS X 10.2
Target Milestone: --- → Camino1.1
Component: Toolbars & Menus → General
QA Contact: toolbars → general
Does anyone have more real world examples where this happens? I think the best short term solution is to err[*] if we get a height less than a reasonable minimum. A real fix depends on bug 360765.

[*] ATM this means maximizing to screen, I'm experiencing with other alternatives
    (for bug 360880)
Attached patch Min allowed height is now 20 px (obsolete) — Splinter Review
Made us enter error state if we get a height that is less than 20. To not get problems with scrollbars, it uses innerWidth rather than clientWidth in these situations. This also changes the error-catching code to only maximize in the direction that fail. I've rearranged some of the code to make it somewhat cleaner therefor this patch also contains the changes suggested for bug 360878.
Assignee: nobody → torben
Status: NEW → ASSIGNED
Attachment #248497 - Flags: review?(stuart.morgan)
As Smokey said in the other bug since a2 will be the first time we ship with zoom, it'd be nice to get some of these zoom bugs fixed instead of shipping a partially busted impl.  
Flags: camino1.1a2?
Comment on attachment 248497 [details] [diff] [review]
Min allowed height is now 20 px

> I've rearranged some of the code to make it somewhat
> cleaner therefor this patch also contains the changes suggested for bug 360878.

If this replaces the patch in bug 360878, you should remove the review requests over there; we don't want two conflicting patches in the queue at the same time.

> +  // Get the current size of the window and the content and the new size of the content.
> +  NSRect stdFrame     = [[self window] frame];
> +  NSSize curFrameSize = [[mBrowserView getBrowserView] frame].size;

The comment is inaccurate (it's the size of the content area, not the window) and the name |curFrameSize| needs to be less vague (and ideally not abbreviated).

>+    // Change the window size, but don't let it be to narrow

s/to/too/

>+    stdFrame.size.width = MAX([[self window] minSize].width, stdFrame.size.width + widthChange);

I know this is not new code, but where is MAX defined (and why are we using it instead of something like fmaxf)?

>+  // Now the height.
>+  if (contentHeight <= 0) {
>+    // something went wrong, use the screen's maximal height and return.
>+    stdFrame.size.height = defaultFrame.size.height;
>+    stdFrame.origin.y    = defaultFrame.origin.y;
>+    [self setZoomState:stdFrame defaultFrame:defaultFrame];
>+    return stdFrame;
>+  }

Why does this case need to trigger an early return, rather than just setting the change to something that will maximize and then keep going?

>+  // Hackish workaround for bug 361049
>+  const PRInt32 kMinSaneHeight = 20;
>+  if (*outHeight < kMinSaneHeight) {
>+    domWindow->GetInnerWidth(outWidth);
>+    *outHeight = 0;
>+  }

I think this hack should be in the zoom code (checking the height against kMinSaneHeight instead of 0 when deciding whether to trust it), rather than making this function lie about the intrinsic size.
Attachment #248497 - Flags: review?(stuart.morgan) → review-
I'll be busy with RL for a week or two but IMHO this is what really needs to be done for a2, the behavior change for errors can probably wait.
Attachment #248497 - Attachment is obsolete: true
Attachment #248689 - Flags: review?(stuart.morgan)
(In reply to comment #8)
This might as well be done in bug 360880 but putting it here so it don't get lost.
> > +  // Get the current size of the window and the content and the new size 
> >       of the content.
> > +  NSRect stdFrame     = [[self window] frame];
> > +  NSSize curFrameSize = [[mBrowserView getBrowserView] frame].size;
> 
> The comment is inaccurate (it's the size of the content area, not the window)
> and the name |curFrameSize| needs to be less vague (and ideally not
> abbreviated).

The first line ( [[self window] frame] ) is the size of the window but, yeah, 
the comment could be clearer.

> >+    stdFrame.size.width = MAX([[self window] minSize].width, 
> >                               stdFrame.size.width + widthChange);
> 
> I know this is not new code, but where is MAX defined (and why are we using 
> it instead of something like fmaxf)?

I have no idea, I originally used PR_MAX but Håkan wanted MAX (bug 155956 
comment 96).

> >+  // Now the height.
> >+  if (contentHeight <= 0) {
> >+    // something went wrong, use the screen's maximal height and return.
> >+    stdFrame.size.height = defaultFrame.size.height;
> >+    stdFrame.origin.y    = defaultFrame.origin.y;
> >+    [self setZoomState:stdFrame defaultFrame:defaultFrame];
> >+    return stdFrame;
> >+  }
> 
> Why does this case need to trigger an early return, rather than just setting
> the change to something that will maximize and then keep going?

It doesn't need to return early but the rest of the code won't do anything 
either. However, an else-clause is probably cleaner though.
 
> >+  // Hackish workaround for bug 361049
> >+  const PRInt32 kMinSaneHeight = 20;
> >+  if (*outHeight < kMinSaneHeight) {
> >+    domWindow->GetInnerWidth(outWidth);
> >+    *outHeight = 0;
> >+  }
> 
> I think this hack should be in the zoom code (checking the height against
> kMinSaneHeight instead of 0 when deciding whether to trust it), rather than
> making this function lie about the intrinsic size.

The problem is that we need to change outWidth too and I didn't want to 
declare kMinSaneHeight twice. I'll see what I can do.
Comment on attachment 248689 [details] [diff] [review]
Minimum fix, for this bug and bug 360878.

r=me, but we need to point  the previous patch in bug 360880 so it's not lost.
Attachment #248689 - Flags: superreview?(mikepinkerton)
Attachment #248689 - Flags: review?(stuart.morgan)
Attachment #248689 - Flags: review+
Comment on attachment 248689 [details] [diff] [review]
Minimum fix, for this bug and bug 360878.

rs=pink
Attachment #248689 - Flags: superreview?(mikepinkerton) → superreview+
Checked in on trunk and MOZILLA_1_8_BRANCH.
Status: ASSIGNED → RESOLVED
Closed: 18 years ago18 years ago
Flags: camino1.1a2? → camino1.1a2+
Keywords: fixed1.8.1.1
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: