Closed Bug 58661 Opened 24 years ago Closed 23 years ago

Anchor scrolling does not happen until page has loaded

Categories

(Core :: Layout, defect, P3)

defect

Tracking

()

RESOLVED FIXED
mozilla0.9.5

People

(Reporter: andrew, Assigned: adamlock)

References

()

Details

Attachments

(2 files)

When linking to a large page with many anchors the page will take up to 30 - 40 seconds to go the correct anchour. Accessing the file via http or on the local file system shows no difference in speed. On tests with the above documents on my local file system IE is 5-6 times faster (~5 secs on IE 5.5 vs ~30 secs on Mozilla).
layout, seeing on new builds, probably a dupe though.
Assignee: asa → clayton
Status: UNCONFIRMED → NEW
Component: Browser-General → Layout
Ever confirmed: true
QA Contact: doronr → petersen
I think this is because we don't actually scroll to the anchor location until the whole page has loaded. We won't be fixing this for RTM, but we should revisit this soon. One solution suggested by jst was to have a timer that runs maybe one second intervals when we are loading a page and see if we could scroll already. Reassigning to Adam Lock for now.
Assignee: clayton → adamlock
Yes, the scrolling only happens once the page has entirely loaded. It would be possible to scroll in the next reflow after the referenced element appeared, but such an approach would not be infallible. For example, if the element was below a large image which hadn't loaded yet, or in the middle of some deeply nested tables then the scrolling would have to be updated as the element was moved around. Also we would have to be careful with this approach that we didn't annoy the user by continuously scrolling back to the anchor when they were trying to scroll the page themselves.
Changing summary, platforms
OS: Windows 2000 → All
Hardware: PC → All
Summary: Linking to a large page with many anchors is slow → Anchor scrolling does not happen until page has loaded
What do you mean until after the page is loaded? I can't get them to work at all! Specifically when I click on a link that is supposed to take me to an anchor on the same page I don't go to the anchor. I'm running M18 on Linux. I've seen this problem since M16 and I can't believe it hasn't been identified as a bug yet.
jks, does this problem occur on a specific page or any page with anchors? I took the opportunity when I was last at the code to fix a number of non-compliances with the HTML spec that may cause a few bad pages to break now. Otherwise, anchor scrolling seems to work as designed (except for waiting for the document complete to occur).
Target Milestone: --- → mozilla0.9
Nominating for nsbeta1 and nsdogfood. Even with the fast connections inside NS I find this a real pain in the butt, especially when trying to look something up with LXR (LXR pages are large, and it takes *forever* for the page load to finish and scrolling to happen).
Keywords: nsbeta1, nsdogfood
Heikki, can you suggest a strategy for implementing this? I looked at putting something into the HTML content sink so that when the named element appeared it could do a flush, reflow and scroll to it but it seemed nasty for the sink to have scrolling code, especially when there is stuff in the presshell for scrolling to anchors already.
Target Milestone: mozilla0.9 → mozilla0.9.1
Changing target milestone.
Heikki, would you be interested in taking this bug?
I am swamped for 0.9.1 :( Nisheeth, interested?
Blocks: 77421
kin, any thoughts here?
I'm swamped for 0.9.1, too. Sorry!
Target Milestone: mozilla0.9.1 → mozilla0.9.2
If you move a nsbeta1 nominated bug beyond 0.9.1, you HAVE to do something about the nomination.
Keywords: nsbeta1nsbeta1-
Target Milestone: mozilla0.9.2 → mozilla0.9.3
I have had the same problem as jks. It has happened on all anchoring-pages I've visited so far; for example, <a href="http://www.w3.org/TR/REC-html40">http://www.w3.org/TR/REC-html40</a> and <a href="http://www.debian.org/doc/FAQ/">http://www.debian.org/doc/FAQ/</a>. I am using M18.
Target Milestone: mozilla0.9.3 → mozilla0.9.4
-> 0.9.5 sorry, we can't be dealing w/ existing regressions at the moment.
Target Milestone: mozilla0.9.4 → mozilla0.9.5
I will just describe the change so everyone's clear what it does: 1. I have added code to HTMLContentSink::Notify that attempts to scroll to the named element the first time it is there to be scrolled to. 2. I have left the old anchor scrolling behaviour intact, so in addition to scrolling when the element is first found it also happens after page loading completes. 3. I have fixed some bustage in PresShell::GoToAnchor to stop it always returning a failure code because some pref called "layout.selectanchor" cannot be found. The net result of the change is that scrolling happens a lot sooner than it used to. Scrolling happens twice which might be slightly annoying if you're scrolling around in the meantime but it catches situations where the named element has shifted because of further page layout. Should I take out the second call? Is there a non-convoluted way to test if the user has scrolled the page in the meantime? Reviews and comments please
layout.selectanchor pref is my stuff, if that pref is set and you follow an anchor the link target will be selected. This is pretty much a must if you want to know where the link pointed to once I check in FIXptr which can select arbitrary ranges. But it probably makes sense to do the change you did. I would hate to see the page jump to the anchor a second time if I had started scrolling, but I think this would not be too common. And scrolling the first time as soon as we find the anchor is a GREAT improvement, so I could live with the second scroll to ref for a while. Best thing, of course, would be to detect if the user scrolled after the first ScrollToRef() and not jump in that case, but we would also need to detect if the content has shifted. I don't know how to detect the scroll, but I believe you can see if the content shifted by looking at the frame and view coordinates (that could have been affected by scroll, of course). Finally, a comment about the patch: it seems like the content sink would have several boolean member variables, please move them next to each other and make them PRPackedBool to save space.
I changed the "layout.selectanchor" pref stuff because that pref doesn't exist at all so GetBoolPref is returning an error that makes it look like the whole scroll operation has failed. I will submit an updated patch that bunches all the bools in HTMLContentSink together and turns them into PRPackedBools. I don't see any easy way to current scroll position from the presshell's associated with the document so I recommend we go with the two refresh thing for the moment.
Comment on attachment 52064 [details] [diff] [review] Second version with packed bools r=heikki I am ok with marking this bug as fixed with this, but I would like you to open a new bug to fix ScrollToRef() after user scrolled...
Attachment #52064 - Flags: review+
sounds good to me too. this will be a big improvement, but the double scroll seems nasty.
Comment on attachment 52064 [details] [diff] [review] Second version with packed bools sr=jst
Attachment #52064 - Flags: superreview+
Comment on attachment 52064 [details] [diff] [review] Second version with packed bools a=asa (on behalf of drivers) for checkin to 0.9.5.
Attachment #52064 - Flags: approval+
Fix is in. Bug 103279 opened up to deal with the second scroll op issue.
Status: NEW → RESOLVED
Closed: 23 years ago
Resolution: --- → FIXED
heikki, may I make a suggestion? Add the "layout.selectanchor" to all.js with a default value and a comment explaining what it does. This will: 1) Make that call not return an error value all the time (moot now) 2) Make it possible for people to actually figure out what the deal with that pref is without asking you.
Boris: will do, but it isn't really that important until FIXptr (or something similar) gets checked in (FIXptr maybe next week).
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: