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 \
{ 0x0d4ea2a0, 0x9b68, 0x4ecd, \
{ 0xa2, 0xd6, 0xae, 0xde, 0xe2, 0x27, 0x8d, 0x48 } }
{ 0x26ef6218, 0xcd5e, 0x4953, \
{ 0xbb, 0x57, 0xb8, 0x50, 0x29, 0xa1, 0xae, 0x40 } }
// Flag for AddStyleSheet().
#define NS_STYLESHEET_FROM_CATALOG (1 << 0)
@ -1458,7 +1458,10 @@ public:
virtual void RegisterFileDataUri(const nsACString& aUri) = 0;
virtual void UnregisterFileDataUri(const nsACString& aUri) = 0;
virtual void SetScrollToRef(nsIURI *aDocumentURI) = 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

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

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

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

@ -293,8 +293,8 @@ nsContentSink::Init(nsIDocument* aDoc,
if (mDocShell) {
PRUint32 loadType = 0;
mDocShell->GetLoadType(&loadType);
mChangeScrollPosWhenScrollingToRef =
((loadType & nsIDocShell::LOAD_CMD_HISTORY) == 0);
mDocument->SetChangeScrollPosWhenScrollingToRef(
(loadType & nsIDocShell::LOAD_CMD_HISTORY) == 0);
}
// 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
ScrollToRefImpl();
ScrollToRef();
}
mScriptLoader->RemoveExecuteBlocker();
@ -1183,56 +1183,9 @@ nsContentSink::ProcessOfflineManifest(const nsAString& aManifestSpec)
}
void
nsContentSink::ScrollToRefImpl()
nsContentSink::ScrollToRef()
{
if (mScrollToRef.IsEmpty()) {
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;
}
}
mDocument->ScrollToRef();
}
void
@ -1282,7 +1235,7 @@ nsContentSink::StartLayout(PRBool aIgnorePendingSheets)
// If the document we are loading has a reference or it is a
// frameset document, disable the scroll bars on the views.
SetScrollToRef();
mDocument->SetScrollToRef(mDocumentURI);
}
void
@ -1344,7 +1297,7 @@ nsContentSink::Notify(nsITimer *timer)
// Now try and scroll to the reference
// XXX Should we scroll unconditionally for history loads??
ScrollToRefImpl();
ScrollToRef();
}
mNotificationTimer = nsnull;
@ -1402,7 +1355,7 @@ nsContentSink::WillInterruptImpl()
"run out time; backoff count: %d", mBackoffCount));
result = FlushTags();
if (mDroppedTimer) {
ScrollToRefImpl();
ScrollToRef();
mDroppedTimer = PR_FALSE;
}
} else if (!mNotificationTimer) {
@ -1667,7 +1620,7 @@ nsContentSink::WillBuildModelImpl()
mBeginLoadTime = PR_IntervalToMicroseconds(PR_IntervalNow());
}
mScrolledToRefAlready = PR_FALSE;
mDocument->ResetScrolledToRefAlready();
if (mProcessLinkHeaderEvent.get()) {
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
PRBool
IsAttrURI(nsIAtom *aName)

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

@ -260,10 +260,10 @@ public:
// element and calls the above method.
void ProcessOfflineManifest(nsIContent *aElement);
void ScrollToRefImpl();
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
// we still have stylesheet loads pending. Otherwise, we'll wait until the
@ -318,8 +318,6 @@ protected:
nsCOMArray<nsIScriptElement> mScriptElements;
nsCString mScrollToRef; // ScrollTo #ref
// back off timer notification after count
PRInt32 mBackoffCount;
@ -347,10 +345,7 @@ protected:
PRUint8 mIsDocumentObserver : 1;
// True if this is a fragment parser
PRUint8 mFragmentMode : 1;
PRUint8 mScrolledToRefAlready : 1;
PRUint8 mChangeScrollPosWhenScrollingToRef : 1;
//
// -- Can interrupt parsing members --
//

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

@ -6381,27 +6381,20 @@ nsDocument::CreateEventGroup(nsIDOMEventGroup **aInstancePtrResult)
return NS_OK;
}
already_AddRefed<nsIContentSink>
nsDocument::GetContentSink()
{
nsCOMPtr<nsIContentSink> sink;
if (mParser) {
sink = mParser->GetContentSink();
} else {
sink = do_QueryReferent(mWeakSink);
if (!sink) {
mWeakSink = nsnull;
}
}
return sink.forget();
}
void
nsDocument::FlushPendingNotifications(mozFlushType aType)
{
if ((!IsHTML() || aType > Flush_ContentAndNotify) &&
(mParser || mWeakSink)) {
nsCOMPtr<nsIContentSink> sink = GetContentSink();
nsCOMPtr<nsIContentSink> sink;
if (mParser) {
sink = mParser->GetContentSink();
} else {
sink = do_QueryReferent(mWeakSink);
if (!sink) {
mWeakSink = nsnull;
}
}
// Determine if it is safe to flush the sink notifications
// by determining if it safe to flush all the presshells.
if (sink && (aType == Flush_Content || IsSafeToFlush())) {
@ -7950,13 +7943,98 @@ nsDocument::UnregisterFileDataUri(const nsACString& 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
nsDocument::ScrollToRef()
{
nsCOMPtr<nsIContentSink> sink = GetContentSink();
if (sink) {
sink->ScrollToRef();
if (mScrolledToRefAlready) {
return;
}
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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

@ -187,9 +187,7 @@ class nsHtml5TreeOpExecutor : public nsContentSink,
* Returns the document.
*/
virtual nsISupports *GetTarget();
virtual void ScrollToRef() { ScrollToRefImpl(); }
// nsContentSink methods
virtual void UpdateChildCounts();
virtual nsresult FlushTags();

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

@ -56,9 +56,10 @@
class nsIParser;
// 57b395ad-4276-408c-9f98-7044b5025c3d
#define NS_ICONTENT_SINK_IID \
{ 0x46983927, 0x7ff5, 0x42cc, \
{ 0x9f, 0x57, 0xf2, 0xd6, 0xa8, 0x42, 0x52, 0x18 } }
{ 0x57b395ad, 0x4276, 0x408c, \
{ 0x9f, 0x98, 0x70, 0x44, 0xb5, 0x02, 0x5c, 0x3d } }
class nsIContentSink : public nsISupports {
public:
@ -153,13 +154,7 @@ public:
{
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)

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

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

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

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

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

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