зеркало из https://github.com/mozilla/gecko-dev.git
Hoist the ref-scrolling stuff up to nsContentSink. Bug 369015, r+sr=sicking
This commit is contained in:
Родитель
e418e1d430
Коммит
0b8624e346
|
@ -287,6 +287,12 @@ nsContentSink::Init(nsIDocument* aDoc,
|
|||
mDocumentURI = aURI;
|
||||
mDocumentBaseURI = aURI;
|
||||
mDocShell = do_QueryInterface(aContainer);
|
||||
if (mDocShell) {
|
||||
PRUint32 loadType = 0;
|
||||
mDocShell->GetLoadType(&loadType);
|
||||
mChangeScrollPosWhenScrollingToRef =
|
||||
((loadType & nsIDocShell::LOAD_CMD_HISTORY) == 0);
|
||||
}
|
||||
|
||||
// use this to avoid a circular reference sink->document->scriptloader->sink
|
||||
nsCOMPtr<nsIScriptLoaderObserver> proxy =
|
||||
|
@ -886,18 +892,18 @@ nsContentSink::PrefetchHref(const nsAString &aHref, PRBool aExplicit)
|
|||
}
|
||||
|
||||
|
||||
PRBool
|
||||
nsContentSink::ScrollToRef(PRBool aReallyScroll)
|
||||
void
|
||||
nsContentSink::ScrollToRef()
|
||||
{
|
||||
if (mRef.IsEmpty()) {
|
||||
return PR_FALSE;
|
||||
return;
|
||||
}
|
||||
|
||||
PRBool didScroll = PR_FALSE;
|
||||
|
||||
char* tmpstr = ToNewCString(mRef);
|
||||
if (!tmpstr) {
|
||||
return PR_FALSE;
|
||||
return;
|
||||
}
|
||||
|
||||
nsUnescape(tmpstr);
|
||||
|
@ -917,7 +923,7 @@ nsContentSink::ScrollToRef(PRBool aReallyScroll)
|
|||
// Check an empty string which might be caused by the UTF-8 conversion
|
||||
if (!ref.IsEmpty()) {
|
||||
// Note that GoToAnchor will handle flushing layout as needed.
|
||||
rv = shell->GoToAnchor(ref, aReallyScroll);
|
||||
rv = shell->GoToAnchor(ref, mChangeScrollPosWhenScrollingToRef);
|
||||
} else {
|
||||
rv = NS_ERROR_FAILURE;
|
||||
}
|
||||
|
@ -931,15 +937,13 @@ nsContentSink::ScrollToRef(PRBool aReallyScroll)
|
|||
rv = nsContentUtils::ConvertStringFromCharset(docCharset, unescapedRef, ref);
|
||||
|
||||
if (NS_SUCCEEDED(rv) && !ref.IsEmpty())
|
||||
rv = shell->GoToAnchor(ref, aReallyScroll);
|
||||
rv = shell->GoToAnchor(ref, mChangeScrollPosWhenScrollingToRef);
|
||||
}
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
didScroll = PR_TRUE;
|
||||
mScrolledToRefAlready = PR_TRUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return didScroll;
|
||||
}
|
||||
|
||||
nsresult
|
||||
|
@ -1032,6 +1036,20 @@ nsContentSink::StartLayout(PRBool aIsFrameset)
|
|||
}
|
||||
}
|
||||
|
||||
void
|
||||
nsContentSink::TryToScrollToRef()
|
||||
{
|
||||
if (mRef.IsEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (mScrolledToRefAlready) {
|
||||
return;
|
||||
}
|
||||
|
||||
ScrollToRef();
|
||||
}
|
||||
|
||||
void
|
||||
nsContentSink::NotifyAppend(nsIContent* aContainer, PRUint32 aStartIndex)
|
||||
{
|
||||
|
|
|
@ -169,7 +169,7 @@ protected:
|
|||
|
||||
void PrefetchHref(const nsAString &aHref, PRBool aExplicit);
|
||||
|
||||
PRBool ScrollToRef(PRBool aReallyScroll);
|
||||
void ScrollToRef();
|
||||
nsresult RefreshIfEnabled(nsIViewManager* vm);
|
||||
void StartLayout(PRBool aIsFrameset);
|
||||
|
||||
|
@ -202,9 +202,7 @@ protected:
|
|||
|
||||
virtual nsresult FlushTags() = 0;
|
||||
|
||||
virtual void TryToScrollToRef()
|
||||
{
|
||||
}
|
||||
void TryToScrollToRef();
|
||||
|
||||
// CanInterrupt parsing related routines
|
||||
nsresult AddDummyParserRequest(void);
|
||||
|
@ -257,7 +255,7 @@ protected:
|
|||
PRUint8 mParsing : 1;
|
||||
PRUint8 mDroppedTimer : 1;
|
||||
PRUint8 mInTitle : 1;
|
||||
PRUint8 unused : 2; // bits available if someone needs one
|
||||
PRUint8 mChangeScrollPosWhenScrollingToRef : 1;
|
||||
|
||||
// -- Can interrupt parsing members --
|
||||
PRUint32 mDelayTimerStart;
|
||||
|
|
|
@ -283,8 +283,6 @@ protected:
|
|||
|
||||
void StartLayout();
|
||||
|
||||
void TryToScrollToRef();
|
||||
|
||||
/**
|
||||
* AddBaseTagInfo adds the "current" base URI and target to the content node
|
||||
* in the form of bogo-attributes. This MUST be called before attributes are
|
||||
|
@ -1847,14 +1845,7 @@ HTMLContentSink::DidBuildModel(void)
|
|||
}
|
||||
}
|
||||
|
||||
if (mDocShell) {
|
||||
PRUint32 LoadType = 0;
|
||||
mDocShell->GetLoadType(&LoadType);
|
||||
|
||||
if (ScrollToRef(!(LoadType & nsIDocShell::LOAD_CMD_HISTORY))) {
|
||||
mScrolledToRefAlready = PR_TRUE;
|
||||
}
|
||||
}
|
||||
ScrollToRef();
|
||||
|
||||
nsScriptLoader *loader = mDocument->GetScriptLoader();
|
||||
if (loader) {
|
||||
|
@ -2826,22 +2817,6 @@ HTMLContentSink::StartLayout()
|
|||
nsContentSink::StartLayout(mFrameset != nsnull);
|
||||
}
|
||||
|
||||
void
|
||||
HTMLContentSink::TryToScrollToRef()
|
||||
{
|
||||
if (mRef.IsEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (mScrolledToRefAlready) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (ScrollToRef(PR_TRUE)) {
|
||||
mScrolledToRefAlready = PR_TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
HTMLContentSink::AddBaseTagInfo(nsIContent* aContent)
|
||||
{
|
||||
|
|
|
@ -347,16 +347,7 @@ nsXMLContentSink::DidBuildModel()
|
|||
|
||||
StartLayout();
|
||||
|
||||
#if 0 /* Disable until this works for XML */
|
||||
// Scroll to Anchor only if the document was *not* loaded through history means.
|
||||
if (mDocShell) {
|
||||
PRUint32 documentLoadType = 0;
|
||||
mDocShell->GetLoadType(&documentLoadType);
|
||||
ScrollToRef(!(documentLoadType & nsIDocShell::LOAD_CMD_HISTORY));
|
||||
}
|
||||
#else
|
||||
ScrollToRef(PR_TRUE);
|
||||
#endif
|
||||
ScrollToRef();
|
||||
|
||||
mDocument->RemoveObserver(this);
|
||||
|
||||
|
@ -437,14 +428,7 @@ nsXMLContentSink::OnTransformDone(nsresult aResult,
|
|||
// Start the layout process
|
||||
StartLayout();
|
||||
|
||||
#if 0 /* Disable until this works for XML */
|
||||
// Scroll to Anchor only if the document was *not* loaded through history means.
|
||||
PRUint32 documentLoadType = 0;
|
||||
docShell->GetLoadType(&documentLoadType);
|
||||
ScrollToRef(!(documentLoadType & nsIDocShell::LOAD_CMD_HISTORY));
|
||||
#else
|
||||
ScrollToRef(PR_TRUE);
|
||||
#endif
|
||||
ScrollToRef();
|
||||
|
||||
originalDocument->EndLoad();
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче