Backed out changeset ed867467d35b (bug 645075) because it doesn't build.

This commit is contained in:
Timothy Nikkel 2011-05-12 11:07:42 -05:00
Родитель e377180628
Коммит 1e77346e37
17 изменённых файлов: 129 добавлений и 140 удалений

Просмотреть файл

@ -124,8 +124,8 @@ class Element;
#define NS_IDOCUMENT_IID \ #define NS_IDOCUMENT_IID \
{ 0x0d4ea2a0, 0x9b68, 0x4ecd, \ { 0x26ef6218, 0xcd5e, 0x4953, \
{ 0xa2, 0xd6, 0xae, 0xde, 0xe2, 0x27, 0x8d, 0x48 } } { 0xbb, 0x57, 0xb8, 0x50, 0x29, 0xa1, 0xae, 0x40 } }
// Flag for AddStyleSheet(). // Flag for AddStyleSheet().
#define NS_STYLESHEET_FROM_CATALOG (1 << 0) #define NS_STYLESHEET_FROM_CATALOG (1 << 0)
@ -1458,7 +1458,10 @@ public:
virtual void RegisterFileDataUri(const nsACString& aUri) = 0; virtual void RegisterFileDataUri(const nsACString& aUri) = 0;
virtual void UnregisterFileDataUri(const nsACString& aUri) = 0; virtual void UnregisterFileDataUri(const nsACString& aUri) = 0;
virtual void SetScrollToRef(nsIURI *aDocumentURI) = 0;
virtual void ScrollToRef() = 0; virtual void ScrollToRef() = 0;
virtual void ResetScrolledToRefAlready() = 0;
virtual void SetChangeScrollPosWhenScrollingToRef(PRBool aValue) = 0;
/** /**
* This method is similar to GetElementById() from nsIDOMDocument but it * This method is similar to GetElementById() from nsIDOMDocument but it

Просмотреть файл

@ -114,7 +114,6 @@ public:
virtual void FlushPendingNotifications(mozFlushType aType) { } virtual void FlushPendingNotifications(mozFlushType aType) { }
NS_IMETHOD SetDocumentCharset(nsACString& aCharset); NS_IMETHOD SetDocumentCharset(nsACString& aCharset);
virtual nsISupports *GetTarget() { return nsnull; } virtual nsISupports *GetTarget() { return nsnull; }
virtual void ScrollToRef() { }
// nsIHTMLContentSink // nsIHTMLContentSink
NS_IMETHOD OpenHead(); NS_IMETHOD OpenHead();

Просмотреть файл

@ -293,8 +293,8 @@ nsContentSink::Init(nsIDocument* aDoc,
if (mDocShell) { if (mDocShell) {
PRUint32 loadType = 0; PRUint32 loadType = 0;
mDocShell->GetLoadType(&loadType); mDocShell->GetLoadType(&loadType);
mChangeScrollPosWhenScrollingToRef = mDocument->SetChangeScrollPosWhenScrollingToRef(
((loadType & nsIDocShell::LOAD_CMD_HISTORY) == 0); (loadType & nsIDocShell::LOAD_CMD_HISTORY) == 0);
} }
// use this to avoid a circular reference sink->document->scriptloader->sink // use this to avoid a circular reference sink->document->scriptloader->sink
@ -350,7 +350,7 @@ nsContentSink::StyleSheetLoaded(nsCSSStyleSheet* aSheet,
} }
// Go ahead and try to scroll to our ref if we have one // Go ahead and try to scroll to our ref if we have one
ScrollToRefImpl(); ScrollToRef();
} }
mScriptLoader->RemoveExecuteBlocker(); mScriptLoader->RemoveExecuteBlocker();
@ -1183,56 +1183,9 @@ nsContentSink::ProcessOfflineManifest(const nsAString& aManifestSpec)
} }
void void
nsContentSink::ScrollToRefImpl() nsContentSink::ScrollToRef()
{ {
if (mScrollToRef.IsEmpty()) { mDocument->ScrollToRef();
return;
}
if (mScrolledToRefAlready) {
return;
}
char* tmpstr = ToNewCString(mScrollToRef);
if (!tmpstr) {
return;
}
nsUnescape(tmpstr);
nsCAutoString unescapedRef;
unescapedRef.Assign(tmpstr);
nsMemory::Free(tmpstr);
nsresult rv = NS_ERROR_FAILURE;
// We assume that the bytes are in UTF-8, as it says in the spec:
// http://www.w3.org/TR/html4/appendix/notes.html#h-B.2.1
NS_ConvertUTF8toUTF16 ref(unescapedRef);
nsCOMPtr<nsIPresShell> shell = mDocument->GetShell();
if (shell) {
// 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, mChangeScrollPosWhenScrollingToRef);
} else {
rv = NS_ERROR_FAILURE;
}
// If UTF-8 URI failed then try to assume the string as a
// document's charset.
if (NS_FAILED(rv)) {
const nsACString &docCharset = mDocument->GetDocumentCharacterSet();
rv = nsContentUtils::ConvertStringFromCharset(docCharset, unescapedRef, ref);
if (NS_SUCCEEDED(rv) && !ref.IsEmpty())
rv = shell->GoToAnchor(ref, mChangeScrollPosWhenScrollingToRef);
}
if (NS_SUCCEEDED(rv)) {
mScrolledToRefAlready = PR_TRUE;
}
}
} }
void void
@ -1282,7 +1235,7 @@ nsContentSink::StartLayout(PRBool aIgnorePendingSheets)
// If the document we are loading has a reference or it is a // If the document we are loading has a reference or it is a
// frameset document, disable the scroll bars on the views. // frameset document, disable the scroll bars on the views.
SetScrollToRef(); mDocument->SetScrollToRef(mDocumentURI);
} }
void void
@ -1344,7 +1297,7 @@ nsContentSink::Notify(nsITimer *timer)
// Now try and scroll to the reference // Now try and scroll to the reference
// XXX Should we scroll unconditionally for history loads?? // XXX Should we scroll unconditionally for history loads??
ScrollToRefImpl(); ScrollToRef();
} }
mNotificationTimer = nsnull; mNotificationTimer = nsnull;
@ -1402,7 +1355,7 @@ nsContentSink::WillInterruptImpl()
"run out time; backoff count: %d", mBackoffCount)); "run out time; backoff count: %d", mBackoffCount));
result = FlushTags(); result = FlushTags();
if (mDroppedTimer) { if (mDroppedTimer) {
ScrollToRefImpl(); ScrollToRef();
mDroppedTimer = PR_FALSE; mDroppedTimer = PR_FALSE;
} }
} else if (!mNotificationTimer) { } else if (!mNotificationTimer) {
@ -1667,7 +1620,7 @@ nsContentSink::WillBuildModelImpl()
mBeginLoadTime = PR_IntervalToMicroseconds(PR_IntervalNow()); mBeginLoadTime = PR_IntervalToMicroseconds(PR_IntervalNow());
} }
mScrolledToRefAlready = PR_FALSE; mDocument->ResetScrolledToRefAlready();
if (mProcessLinkHeaderEvent.get()) { if (mProcessLinkHeaderEvent.get()) {
mProcessLinkHeaderEvent.Revoke(); mProcessLinkHeaderEvent.Revoke();
@ -1709,31 +1662,6 @@ nsContentSink::NotifyDocElementCreated(nsIDocument* aDoc)
} }
} }
void
nsContentSink::SetScrollToRef() {
if (mDocumentURI) {
nsCAutoString ref;
// Since all URI's that pass through here aren't URL's we can't
// rely on the nsIURI implementation for providing a way for
// finding the 'ref' part of the URI, we'll haveto revert to
// string routines for finding the data past '#'
mDocumentURI->GetSpec(ref);
nsReadingIterator<char> start, end;
ref.BeginReading(start);
ref.EndReading(end);
if (FindCharInReadable('#', start, end)) {
++start; // Skip over the '#'
mScrollToRef = Substring(start, end);
}
}
}
// URIs: action, href, src, longdesc, usemap, cite // URIs: action, href, src, longdesc, usemap, cite
PRBool PRBool
IsAttrURI(nsIAtom *aName) IsAttrURI(nsIAtom *aName)

Просмотреть файл

@ -260,10 +260,10 @@ public:
// element and calls the above method. // element and calls the above method.
void ProcessOfflineManifest(nsIContent *aElement); void ProcessOfflineManifest(nsIContent *aElement);
void ScrollToRefImpl();
protected: protected:
void SetScrollToRef(); // Tries to scroll to the URI's named anchor. Once we've successfully
// done that, further calls to this method will be ignored.
void ScrollToRef();
// Start layout. If aIgnorePendingSheets is true, this will happen even if // Start layout. If aIgnorePendingSheets is true, this will happen even if
// we still have stylesheet loads pending. Otherwise, we'll wait until the // we still have stylesheet loads pending. Otherwise, we'll wait until the
@ -318,8 +318,6 @@ protected:
nsCOMArray<nsIScriptElement> mScriptElements; nsCOMArray<nsIScriptElement> mScriptElements;
nsCString mScrollToRef; // ScrollTo #ref
// back off timer notification after count // back off timer notification after count
PRInt32 mBackoffCount; PRInt32 mBackoffCount;
@ -348,9 +346,6 @@ protected:
// True if this is a fragment parser // True if this is a fragment parser
PRUint8 mFragmentMode : 1; PRUint8 mFragmentMode : 1;
PRUint8 mScrolledToRefAlready : 1;
PRUint8 mChangeScrollPosWhenScrollingToRef : 1;
// //
// -- Can interrupt parsing members -- // -- Can interrupt parsing members --
// //

Просмотреть файл

@ -6381,9 +6381,11 @@ nsDocument::CreateEventGroup(nsIDOMEventGroup **aInstancePtrResult)
return NS_OK; return NS_OK;
} }
already_AddRefed<nsIContentSink> void
nsDocument::GetContentSink() nsDocument::FlushPendingNotifications(mozFlushType aType)
{ {
if ((!IsHTML() || aType > Flush_ContentAndNotify) &&
(mParser || mWeakSink)) {
nsCOMPtr<nsIContentSink> sink; nsCOMPtr<nsIContentSink> sink;
if (mParser) { if (mParser) {
sink = mParser->GetContentSink(); sink = mParser->GetContentSink();
@ -6393,15 +6395,6 @@ nsDocument::GetContentSink()
mWeakSink = nsnull; mWeakSink = nsnull;
} }
} }
return sink.forget();
}
void
nsDocument::FlushPendingNotifications(mozFlushType aType)
{
if ((!IsHTML() || aType > Flush_ContentAndNotify) &&
(mParser || mWeakSink)) {
nsCOMPtr<nsIContentSink> sink = GetContentSink();
// Determine if it is safe to flush the sink notifications // Determine if it is safe to flush the sink notifications
// by determining if it safe to flush all the presshells. // by determining if it safe to flush all the presshells.
if (sink && (aType == Flush_Content || IsSafeToFlush())) { if (sink && (aType == Flush_Content || IsSafeToFlush())) {
@ -7950,13 +7943,98 @@ nsDocument::UnregisterFileDataUri(const nsACString& aUri)
mFileDataUris.RemoveElement(aUri); mFileDataUris.RemoveElement(aUri);
} }
void
nsDocument::SetScrollToRef(nsIURI *aDocumentURI)
{
if (!aDocumentURI) {
return;
}
nsCAutoString ref;
// Since all URI's that pass through here aren't URL's we can't
// rely on the nsIURI implementation for providing a way for
// finding the 'ref' part of the URI, we'll haveto revert to
// string routines for finding the data past '#'
aDocumentURI->GetSpec(ref);
nsReadingIterator<char> start, end;
ref.BeginReading(start);
ref.EndReading(end);
if (FindCharInReadable('#', start, end)) {
++start; // Skip over the '#'
mScrollToRef = Substring(start, end);
}
}
void void
nsDocument::ScrollToRef() nsDocument::ScrollToRef()
{ {
nsCOMPtr<nsIContentSink> sink = GetContentSink(); if (mScrolledToRefAlready) {
if (sink) { return;
sink->ScrollToRef();
} }
if (mScrollToRef.IsEmpty()) {
return;
}
char* tmpstr = ToNewCString(mScrollToRef);
if (!tmpstr) {
return;
}
nsUnescape(tmpstr);
nsCAutoString unescapedRef;
unescapedRef.Assign(tmpstr);
nsMemory::Free(tmpstr);
nsresult rv = NS_ERROR_FAILURE;
// We assume that the bytes are in UTF-8, as it says in the spec:
// http://www.w3.org/TR/html4/appendix/notes.html#h-B.2.1
NS_ConvertUTF8toUTF16 ref(unescapedRef);
nsCOMPtr<nsIPresShell> shell = GetShell();
if (shell) {
// 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, mChangeScrollPosWhenScrollingToRef);
} else {
rv = NS_ERROR_FAILURE;
}
// If UTF-8 URI failed then try to assume the string as a
// document's charset.
if (NS_FAILED(rv)) {
const nsACString &docCharset = GetDocumentCharacterSet();
rv = nsContentUtils::ConvertStringFromCharset(docCharset, unescapedRef, ref);
if (NS_SUCCEEDED(rv) && !ref.IsEmpty()) {
rv = shell->GoToAnchor(ref, mChangeScrollPosWhenScrollingToRef);
}
}
if (NS_SUCCEEDED(rv)) {
mScrolledToRefAlready = PR_TRUE;
}
}
}
void
nsDocument::ResetScrolledToRefAlready()
{
mScrolledToRefAlready = PR_FALSE;
}
void
nsDocument::SetChangeScrollPosWhenScrollingToRef(PRBool aValue)
{
mChangeScrollPosWhenScrollingToRef = aValue;
} }
void void

Просмотреть файл

@ -958,7 +958,10 @@ public:
// Only BlockOnload should call this! // Only BlockOnload should call this!
void AsyncBlockOnload(); void AsyncBlockOnload();
virtual void SetScrollToRef(nsIURI *aDocumentURI);
virtual void ScrollToRef(); virtual void ScrollToRef();
virtual void ResetScrolledToRefAlready();
virtual void SetChangeScrollPosWhenScrollingToRef(PRBool aValue);
already_AddRefed<nsContentList> already_AddRefed<nsContentList>
GetElementsByTagName(const nsAString& aTagName) { GetElementsByTagName(const nsAString& aTagName) {
@ -1197,8 +1200,6 @@ private:
// Reschedule any notifications we need to handle mozRequestAnimationFrame // Reschedule any notifications we need to handle mozRequestAnimationFrame
void RescheduleAnimationFrameNotifications(); void RescheduleAnimationFrameNotifications();
already_AddRefed<nsIContentSink> GetContentSink();
// These are not implemented and not supported. // These are not implemented and not supported.
nsDocument(const nsDocument& aOther); nsDocument(const nsDocument& aOther);
nsDocument& operator=(const nsDocument& aOther); nsDocument& operator=(const nsDocument& aOther);
@ -1244,6 +1245,10 @@ private:
nsCOMPtr<nsIDOMDOMImplementation> mDOMImplementation; nsCOMPtr<nsIDOMDOMImplementation> mDOMImplementation;
nsCString mScrollToRef;
PRUint8 mScrolledToRefAlready : 1;
PRUint8 mChangeScrollPosWhenScrollingToRef : 1;
// Tracking for images in the document. // Tracking for images in the document.
nsDataHashtable< nsPtrHashKey<imgIRequest>, PRUint32> mImageTracker; nsDataHashtable< nsPtrHashKey<imgIRequest>, PRUint32> mImageTracker;

Просмотреть файл

@ -114,7 +114,6 @@ public:
virtual void FlushPendingNotifications(mozFlushType aType) { } virtual void FlushPendingNotifications(mozFlushType aType) { }
NS_IMETHOD SetDocumentCharset(nsACString& aCharset) { return NS_OK; } NS_IMETHOD SetDocumentCharset(nsACString& aCharset) { return NS_OK; }
virtual nsISupports *GetTarget() { return nsnull; } virtual nsISupports *GetTarget() { return nsnull; }
virtual void ScrollToRef() { }
// nsIHTMLContentSink // nsIHTMLContentSink
NS_IMETHOD OpenHead(); NS_IMETHOD OpenHead();

Просмотреть файл

@ -198,7 +198,6 @@ public:
NS_IMETHOD SetDocumentCharset(nsACString& aCharset); NS_IMETHOD SetDocumentCharset(nsACString& aCharset);
virtual nsISupports *GetTarget(); virtual nsISupports *GetTarget();
virtual PRBool IsScriptExecuting(); virtual PRBool IsScriptExecuting();
virtual void ScrollToRef() { ScrollToRefImpl(); }
// nsIHTMLContentSink // nsIHTMLContentSink
NS_IMETHOD OpenContainer(const nsIParserNode& aNode); NS_IMETHOD OpenContainer(const nsIParserNode& aNode);

Просмотреть файл

@ -112,7 +112,6 @@ public:
virtual void FlushPendingNotifications(mozFlushType aType) { } virtual void FlushPendingNotifications(mozFlushType aType) { }
NS_IMETHOD SetDocumentCharset(nsACString& aCharset) { return NS_OK; } NS_IMETHOD SetDocumentCharset(nsACString& aCharset) { return NS_OK; }
virtual nsISupports *GetTarget() { return mTargetDocument; } virtual nsISupports *GetTarget() { return mTargetDocument; }
virtual void ScrollToRef() { }
// nsIHTMLContentSink // nsIHTMLContentSink
NS_IMETHOD BeginContext(PRInt32 aID); NS_IMETHOD BeginContext(PRInt32 aID);

Просмотреть файл

@ -102,7 +102,6 @@ public:
NS_IMETHOD SetDocumentCharset(nsACString& aCharset); NS_IMETHOD SetDocumentCharset(nsACString& aCharset);
virtual nsISupports *GetTarget(); virtual nsISupports *GetTarget();
virtual PRBool IsScriptExecuting(); virtual PRBool IsScriptExecuting();
virtual void ScrollToRef() { ScrollToRefImpl(); }
// nsITransformObserver // nsITransformObserver
NS_IMETHOD OnDocumentCreated(nsIDocument *aResultDocument); NS_IMETHOD OnDocumentCreated(nsIDocument *aResultDocument);

Просмотреть файл

@ -119,7 +119,6 @@ public:
virtual void FlushPendingNotifications(mozFlushType aType) { } virtual void FlushPendingNotifications(mozFlushType aType) { }
NS_IMETHOD SetDocumentCharset(nsACString& aCharset) { return NS_OK; } NS_IMETHOD SetDocumentCharset(nsACString& aCharset) { return NS_OK; }
virtual nsISupports *GetTarget() { return nsnull; } virtual nsISupports *GetTarget() { return nsnull; }
virtual void ScrollToRef() { }
private: private:
nsRefPtr<txStylesheetCompiler> mCompiler; nsRefPtr<txStylesheetCompiler> mCompiler;

Просмотреть файл

@ -78,7 +78,6 @@ public:
virtual void FlushPendingNotifications(mozFlushType aType) { } virtual void FlushPendingNotifications(mozFlushType aType) { }
NS_IMETHOD SetDocumentCharset(nsACString& aCharset); NS_IMETHOD SetDocumentCharset(nsACString& aCharset);
virtual nsISupports *GetTarget(); virtual nsISupports *GetTarget();
virtual void ScrollToRef() { }
/** /**
* Initialize the content sink, giving it an nsIDocument object * Initialize the content sink, giving it an nsIDocument object

Просмотреть файл

@ -188,8 +188,6 @@ class nsHtml5TreeOpExecutor : public nsContentSink,
*/ */
virtual nsISupports *GetTarget(); virtual nsISupports *GetTarget();
virtual void ScrollToRef() { ScrollToRefImpl(); }
// nsContentSink methods // nsContentSink methods
virtual void UpdateChildCounts(); virtual void UpdateChildCounts();
virtual nsresult FlushTags(); virtual nsresult FlushTags();

Просмотреть файл

@ -56,9 +56,10 @@
class nsIParser; class nsIParser;
// 57b395ad-4276-408c-9f98-7044b5025c3d
#define NS_ICONTENT_SINK_IID \ #define NS_ICONTENT_SINK_IID \
{ 0x46983927, 0x7ff5, 0x42cc, \ { 0x57b395ad, 0x4276, 0x408c, \
{ 0x9f, 0x57, 0xf2, 0xd6, 0xa8, 0x42, 0x52, 0x18 } } { 0x9f, 0x98, 0x70, 0x44, 0xb5, 0x02, 0x5c, 0x3d } }
class nsIContentSink : public nsISupports { class nsIContentSink : public nsISupports {
public: public:
@ -154,12 +155,6 @@ public:
return PR_FALSE; return PR_FALSE;
} }
/**
* Tries to scroll to the URI's named anchor. Once we've successfully
* done that, further calls to this method will be ignored.
*/
virtual void ScrollToRef() = 0;
}; };
NS_DEFINE_STATIC_IID_ACCESSOR(nsIContentSink, NS_ICONTENT_SINK_IID) NS_DEFINE_STATIC_IID_ACCESSOR(nsIContentSink, NS_ICONTENT_SINK_IID)

Просмотреть файл

@ -53,8 +53,8 @@
#define NS_SAXXMLREADER_CONTRACTID "@mozilla.org/saxparser/xmlreader;1" #define NS_SAXXMLREADER_CONTRACTID "@mozilla.org/saxparser/xmlreader;1"
#define NS_SAXXMLREADER_CLASSNAME "SAX XML Reader" #define NS_SAXXMLREADER_CLASSNAME "SAX XML Reader"
#define NS_SAXXMLREADER_CID \ #define NS_SAXXMLREADER_CID \
{ 0x1ab57b84, 0xb4dd, 0x4a03, \ { 0xab1da296, 0x6125, 0x40ba, \
{ 0x8f, 0xa9, 0x80, 0xd9, 0x24, 0x62, 0xf9, 0x49 } } { 0x96, 0xd0, 0x47, 0xa8, 0x28, 0x2a, 0xe3, 0xdb} }
class nsSAXXMLReader : public nsISAXXMLReader, class nsSAXXMLReader : public nsISAXXMLReader,
public nsIExtendedExpatSink, public nsIExtendedExpatSink,
@ -105,10 +105,6 @@ public:
return nsnull; return nsnull;
} }
virtual void ScrollToRef()
{
}
private: private:
nsCOMPtr<nsISAXContentHandler> mContentHandler; nsCOMPtr<nsISAXContentHandler> mContentHandler;
nsCOMPtr<nsISAXDTDHandler> mDTDHandler; nsCOMPtr<nsISAXDTDHandler> mDTDHandler;

Просмотреть файл

@ -169,7 +169,6 @@ public:
virtual void FlushPendingNotifications(mozFlushType aType) { } virtual void FlushPendingNotifications(mozFlushType aType) { }
NS_IMETHOD SetDocumentCharset(nsACString& aCharset) { return NS_OK; } NS_IMETHOD SetDocumentCharset(nsACString& aCharset) { return NS_OK; }
virtual nsISupports *GetTarget() { return nsnull; } virtual nsISupports *GetTarget() { return nsnull; }
virtual void ScrollToRef() { }
// nsIRDFContentSink // nsIRDFContentSink
NS_IMETHOD Init(nsIURI* aURL); NS_IMETHOD Init(nsIURI* aURL);

Просмотреть файл

@ -363,7 +363,6 @@ public:
virtual void FlushPendingNotifications(mozFlushType aType) { } virtual void FlushPendingNotifications(mozFlushType aType) { }
NS_IMETHOD SetDocumentCharset(nsACString& aCharset) { return NS_OK; } NS_IMETHOD SetDocumentCharset(nsACString& aCharset) { return NS_OK; }
virtual nsISupports *GetTarget() { return nsnull; } virtual nsISupports *GetTarget() { return nsnull; }
virtual void ScrollToRef() { }
// nsIHTMLContentSink // nsIHTMLContentSink
NS_IMETHOD OpenHead() { return NS_OK; } NS_IMETHOD OpenHead() { return NS_OK; }