Closed Bug 143815 Opened 23 years ago Closed 23 years ago

[FIXr]clicking link on page with body{overflow:auto} scrolls to top

Categories

(Core :: Layout, defect, P1)

defect

Tracking

()

RESOLVED FIXED
mozilla1.3alpha

People

(Reporter: jruderman, Assigned: bzbarsky)

References

()

Details

(Keywords: access, regression, testcase)

Attachments

(5 files, 1 obsolete file)

http://tantek.com/favelets/ uses "body { overflow:auto }". When I click a link in the page, Mozilla scrolls to the top of the page and doesn't follow the link as a result. I have no idea why Tantek uses body { overflow:auto } for his page. It breaks panning in Internet Explorer and causes two scrollbars to appear when I increase the font size in Mozilla, but it doesn't affect the appearance of the page.
Attached file testcase
Even right-clicking does this. It appears that ScrollFrameIntoView is broken here somehow... Also, this completely breaks tabbing to the lower anchors on the page -- we never scroll to them.
OS: Windows 98 → All
Hardware: PC → All
Did some investigating. Trunk linux builds, this works correctly in the 2001-11-17-21 build and is broken in the 2001-11-18-06 build. I suspect the checkin for bug 65236 is responsible (that regressed some other situations of this sort as well).
oops, I meant "bug 62536". I should learn to copy/paste
Attached file another testcase
So.. the problem is that PresShell::ScrollFrameIntoView now seems to assume that no frame is taller than screen-height... In this case the <body> is scrollable. We scroll it so that the link is visible in the <body>. Then we scroll the viewport so that the <body> is visible in the viewport, but that just scrolls to top since the <body> is already visible. This is very obvious in this testcase if you window height is below 600px or so -- the body has a height of 800px, so the scrollbars should show up... if they do not, zoom the font up a bit.
Changing QA Contact
QA Contact: petersen → amar
adding the testcase keyword and setting the priority to P1 since this is a regression.
Severity: normal → critical
Keywords: testcase
Priority: -- → P1
nsbeta1-. body { overflow:auto } is not commonly used.
Keywords: nsbeta1nsbeta1-
I'd just like to point out that this will be a problem with any overflow:auto or overflow:scroll element that is taller than the viewport. This is by no means limited to <body> -- the impact is much more widespread. Renominating, and my apologies to the ADT for not being clearer the first time around.
Keywords: nsbeta1-nsbeta1
tabbing to the third link does not work, nor does clicking on it. It cannot be followed.
> Tabbing to the third link does not work, nor does clicking on it. It cannot be followed. You can follow the link by pressing enter after clicking on it, but very few users would figure that out. To most mouse users and most keyboard users, the link seems to be impossible to follow.
Assignee: attinasi → alexsavulov
Reassigning to Alex.
Reassigning to jst since this bug seems to be caused by the fix for bug 62536
Assignee: alexsavulov → jst
*** Bug 146770 has been marked as a duplicate of this bug. ***
*** Bug 178148 has been marked as a duplicate of this bug. ***
taking; I have a working fix that I just need to clean up.
Assignee: jst → bzbarsky
Target Milestone: --- → mozilla1.3alpha
Attached patch fix (obsolete) — Splinter Review
Summary: clicking link on page with body{overflow:auto} scrolls to top → [FIX]clicking link on page with body{overflow:auto} scrolls to top
+ if (aRect.YMost() < visibleRect.y) { ... + } else if (aRect.y > visibleRect.YMost()) { ... + if (aRect.XMost() < visibleRect.x) { ... + } else if (aRect.x > visibleRect.XMost()) { I know you're just copying and pasting code, but these should be fixed to include a "fuzz factor" so that a 1-twip overlap doesn't count as "visible". Maybe you could call aScrollingView->GetLineHeight to get an appropriate epsilon? + nscoord frameAlignY = aRect.y + (aRect.height * aVPercent) / 100; + scrollOffsetY = frameAlignY - (visibleRect.height * aVPercent) / 100; ... + nscoord frameAlignX = aRect.x + (aRect.width * aHPercent) / 100; + scrollOffsetX = frameAlignX - (visibleRect.width * aHPercent) / 100; Again you're just copying code, but the multiplication could overflow for a frame that's only about a million pixels high. How about doing the arithmetic using double? Other than that, looks great.
Comment on attachment 105074 [details] [diff] [review] fix - In PresShell::ScrollFrameIntoView() + nsIScrollableView* scrollingView = nsnull; + +#ifdef DEBUG + if (closestView) { + CallQueryInterface(closestView, &scrollingView); + NS_ASSERTION(!scrollingView, + "What happened to the scrolled view? " + "The frame should not be directly in the scrolling view!"); + } +#endif ... Don't set variables defined outside #ifdef DEBUG in code that's inside #ifdef DEBUG, the debug code could affect how the code outside the #ifdef DEBUG works and make optimized code not work the same way debug code does. Declare a new nsIScrollableView inside the #ifdef DEBUG block and use that in the debug-only code. sr=jst with that change.
Attachment #105074 - Flags: superreview+
The only users of SCROLL_IF_NOT_VISIBLE are form control frames (that's what they do when focus() is called on the control). The only one of these for which that _may_ make sense (instead of just doing SCROLL_ANYWHERE) is <textarea> -- with a large textarea the end of which is visible, focus() shouldn't scroll to the top of the textarea,,,,
I'll talk to jkeiser about the form control's bizarre use of SCROLL_IF_NOT_VISIBLE...
Attachment #105074 - Attachment is obsolete: true
*** Bug 115505 has been marked as a duplicate of this bug. ***
Comment on attachment 105566 [details] [diff] [review] fix the review comments sr=roc+moz
Attachment #105566 - Flags: superreview+
Summary: [FIX]clicking link on page with body{overflow:auto} scrolls to top → [FIXr]clicking link on page with body{overflow:auto} scrolls to top
checked in, r=roc+moz (permission to switch the sr to r via email), sr=jst
Status: NEW → RESOLVED
Closed: 23 years ago
Resolution: --- → FIXED
*** Bug 179883 has been marked as a duplicate of this bug. ***
*** Bug 182199 has been marked as a duplicate of this bug. ***
*** Bug 184473 has been marked as a duplicate of this bug. ***
*** Bug 188863 has been marked as a duplicate of this bug. ***
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: