mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-12-12 17:22:04 +00:00
Checkin makes scrolling to anchors faster by attempting to scroll to the named element from the content sink's timer routine rather than waiting until page loading completes. b=58661 r=heikki@netscape.com sr=jst@netscape.com a=asa@mozilla.org
This commit is contained in:
parent
501b5033c4
commit
a1ba71769c
@ -370,7 +370,6 @@ public:
|
||||
nsIWebShell* mWebShell;
|
||||
nsIParser* mParser;
|
||||
|
||||
PRBool mNotifyOnTimer; // Do we notify based on time?
|
||||
PRInt32 mBackoffCount; // back off timer notification after count
|
||||
PRInt32 mNotificationInterval; // Notification interval in microseconds
|
||||
PRTime mLastNotificationTime; // Time of last notification
|
||||
@ -385,8 +384,11 @@ public:
|
||||
nsString* mTitle;
|
||||
nsString mUnicodeXferBuf;
|
||||
|
||||
PRPackedBool mNotifyOnTimer; // Do we notify based on time?
|
||||
PRPackedBool mLayoutStarted;
|
||||
PRPackedBool mIsDemotingContainer;
|
||||
PRPackedBool mScrolledToRefAlready;
|
||||
PRPackedBool mNeedToBlockParser;
|
||||
|
||||
PRInt32 mInScript;
|
||||
PRInt32 mInNotification;
|
||||
@ -398,7 +400,6 @@ public:
|
||||
SinkContext* mHeadContext;
|
||||
PRInt32 mNumOpenIFRAMES;
|
||||
nsSupportsArray mScriptElements;
|
||||
PRBool mNeedToBlockParser;
|
||||
nsCOMPtr<nsIRequest> mDummyParserRequest;
|
||||
|
||||
nsCString mRef;
|
||||
@ -423,6 +424,7 @@ public:
|
||||
void StartLayout();
|
||||
|
||||
void ScrollToRef();
|
||||
void TryToScrollToRef();
|
||||
|
||||
void AddBaseTagInfo(nsIHTMLContent* aContent);
|
||||
|
||||
@ -2357,6 +2359,7 @@ HTMLContentSink::HTMLContentSink() {
|
||||
mNeedToBlockParser = PR_FALSE;
|
||||
mDummyParserRequest = nsnull;
|
||||
mBeginLoadTime = 0;
|
||||
mScrolledToRefAlready = PR_FALSE;
|
||||
}
|
||||
|
||||
HTMLContentSink::~HTMLContentSink()
|
||||
@ -2536,7 +2539,9 @@ HTMLContentSink::Init(nsIDocument* aDoc,
|
||||
|
||||
mNotifyOnTimer = PR_TRUE;
|
||||
if (prefs) {
|
||||
prefs->GetBoolPref("content.notify.ontimer", &mNotifyOnTimer);
|
||||
PRBool result = mNotifyOnTimer;
|
||||
prefs->GetBoolPref("content.notify.ontimer", &result);
|
||||
mNotifyOnTimer = result;
|
||||
}
|
||||
|
||||
mBackoffCount = -1; // never
|
||||
@ -2677,6 +2682,7 @@ HTMLContentSink::WillBuildModel(void)
|
||||
}
|
||||
mBeginLoadTime = PR_IntervalToMicroseconds(PR_IntervalNow());
|
||||
}
|
||||
mScrolledToRefAlready = PR_FALSE;
|
||||
// Notify document that the load is beginning
|
||||
mDocument->BeginLoad();
|
||||
return NS_OK;
|
||||
@ -2793,6 +2799,10 @@ HTMLContentSink::Notify(nsITimer *timer)
|
||||
if (mCurrentContext) {
|
||||
mCurrentContext->FlushTags(PR_TRUE);
|
||||
}
|
||||
|
||||
// Now try and scroll to the reference
|
||||
TryToScrollToRef();
|
||||
|
||||
mNotificationTimer = 0;
|
||||
MOZ_TIMER_DEBUGLOG(("Stop: nsHTMLContentSink::Notify()\n"));
|
||||
MOZ_TIMER_STOP(mWatch);
|
||||
@ -3996,6 +4006,20 @@ nsresult CharsetConvRef(const nsString& aDocCharset, const nsCString& aRefInDocC
|
||||
return rv;
|
||||
}
|
||||
|
||||
void
|
||||
HTMLContentSink::TryToScrollToRef()
|
||||
{
|
||||
if (mRef.IsEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (mScrolledToRefAlready) {
|
||||
return;
|
||||
}
|
||||
|
||||
ScrollToRef();
|
||||
}
|
||||
|
||||
void
|
||||
HTMLContentSink::ScrollToRef()
|
||||
{
|
||||
@ -4043,6 +4067,10 @@ HTMLContentSink::ScrollToRef()
|
||||
rv = shell->GoToAnchor(ref);
|
||||
}
|
||||
}
|
||||
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
mScrolledToRefAlready = PR_TRUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -3905,8 +3905,9 @@ PresShell::GoToAnchor(const nsString& aAnchorName)
|
||||
nsCOMPtr<nsIPref> prefs(do_GetService(kPrefServiceCID,&rv));
|
||||
if (NS_SUCCEEDED(rv) && prefs) {
|
||||
PRBool selectAnchor;
|
||||
rv = prefs->GetBoolPref("layout.selectanchor",&selectAnchor);
|
||||
if (NS_SUCCEEDED(rv) && selectAnchor) {
|
||||
nsresult rvPref;
|
||||
rvPref = prefs->GetBoolPref("layout.selectanchor",&selectAnchor);
|
||||
if (NS_SUCCEEDED(rvPref) && selectAnchor) {
|
||||
rv = SelectContent(content);
|
||||
}
|
||||
}
|
||||
|
@ -3905,8 +3905,9 @@ PresShell::GoToAnchor(const nsString& aAnchorName)
|
||||
nsCOMPtr<nsIPref> prefs(do_GetService(kPrefServiceCID,&rv));
|
||||
if (NS_SUCCEEDED(rv) && prefs) {
|
||||
PRBool selectAnchor;
|
||||
rv = prefs->GetBoolPref("layout.selectanchor",&selectAnchor);
|
||||
if (NS_SUCCEEDED(rv) && selectAnchor) {
|
||||
nsresult rvPref;
|
||||
rvPref = prefs->GetBoolPref("layout.selectanchor",&selectAnchor);
|
||||
if (NS_SUCCEEDED(rvPref) && selectAnchor) {
|
||||
rv = SelectContent(content);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user