зеркало из https://github.com/mozilla/gecko-dev.git
Keep track of whether a title has been set in the document, not in the sink.
This way we can notice all ways of setting it. Bug 271996, r=sicking, sr=neil
This commit is contained in:
Родитель
9866f848c5
Коммит
8b54631a06
|
@ -733,7 +733,7 @@ void
|
|||
nsDocument::ResetToURI(nsIURI *aURI, nsILoadGroup *aLoadGroup)
|
||||
{
|
||||
NS_PRECONDITION(aURI, "Null URI passed to ResetToURI");
|
||||
mDocumentTitle.Truncate();
|
||||
mDocumentTitle.SetIsVoid(PR_TRUE);
|
||||
|
||||
mPrincipal = nsnull;
|
||||
mSecurityInfo = nsnull;
|
||||
|
@ -2820,6 +2820,9 @@ NS_IMETHODIMP
|
|||
nsDocument::GetTitle(nsAString& aTitle)
|
||||
{
|
||||
aTitle.Assign(mDocumentTitle);
|
||||
// Make sure not to return null from this method even if
|
||||
// mDocumentTitle is void.
|
||||
aTitle.SetIsVoid(PR_FALSE);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
|
|
@ -68,7 +68,8 @@
|
|||
|
||||
#include "nsIDOMText.h"
|
||||
#include "nsIDOMComment.h"
|
||||
#include "nsIDOMHTMLDocument.h"
|
||||
#include "nsIDOMDocument.h"
|
||||
#include "nsIDOMNSDocument.h"
|
||||
#include "nsIDOMDOMImplementation.h"
|
||||
#include "nsIDOMDocumentType.h"
|
||||
#include "nsIDOMHTMLScriptElement.h"
|
||||
|
@ -338,9 +339,6 @@ protected:
|
|||
nsIHTMLContent* mFrameset;
|
||||
nsIHTMLContent* mHead;
|
||||
|
||||
// This will be void until a <title> is found
|
||||
nsXPIDLString mTitle;
|
||||
|
||||
nsString mSkippedContent;
|
||||
|
||||
// Do we notify based on time?
|
||||
|
@ -2275,10 +2273,9 @@ HTMLContentSink::DidBuildModel(void)
|
|||
mNotificationTimer = 0;
|
||||
}
|
||||
|
||||
if (mTitle.IsVoid()) {
|
||||
nsCOMPtr<nsIDOMHTMLDocument> domDoc(do_QueryInterface(mHTMLDocument));
|
||||
if (domDoc)
|
||||
domDoc->SetTitle(mTitle);
|
||||
if (mDocument->GetDocumentTitle().IsVoid()) {
|
||||
nsCOMPtr<nsIDOMNSDocument> domDoc(do_QueryInterface(mDocument));
|
||||
domDoc->SetTitle(EmptyString());
|
||||
}
|
||||
|
||||
// Reflow the last batch of content
|
||||
|
@ -3140,23 +3137,20 @@ HTMLContentSink::SetDocumentTitle(const nsAString& aTitle)
|
|||
MOZ_TIMER_START(mWatch);
|
||||
NS_ASSERTION(mCurrentContext == mHeadContext, "title not in head");
|
||||
|
||||
if (!mTitle.IsVoid()) {
|
||||
if (!mDocument->GetDocumentTitle().IsVoid()) {
|
||||
// If the title was already set then don't try to overwrite it
|
||||
// when a new title is encountered - For backwards compatiblity
|
||||
//*mTitle = aValue;
|
||||
MOZ_TIMER_DEBUGLOG(("Stop: nsHTMLContentSink::SetDocumentTitle()\n"));
|
||||
MOZ_TIMER_STOP(mWatch);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
mTitle.Assign(aTitle);
|
||||
mTitle.CompressWhitespace(PR_TRUE, PR_TRUE);
|
||||
nsAutoString title(aTitle);
|
||||
title.CompressWhitespace(PR_TRUE, PR_TRUE);
|
||||
|
||||
nsCOMPtr<nsIDOMHTMLDocument> domDoc(do_QueryInterface(mHTMLDocument));
|
||||
if (domDoc) {
|
||||
domDoc->SetTitle(mTitle);
|
||||
}
|
||||
nsCOMPtr<nsIDOMNSDocument> domDoc(do_QueryInterface(mDocument));
|
||||
domDoc->SetTitle(title);
|
||||
|
||||
nsCOMPtr<nsINodeInfo> nodeInfo;
|
||||
nsresult rv = mNodeInfoManager->GetNodeInfo(nsHTMLAtoms::title, nsnull,
|
||||
|
@ -3173,7 +3167,7 @@ HTMLContentSink::SetDocumentTitle(const nsAString& aTitle)
|
|||
rv = NS_NewTextNode(getter_AddRefs(text));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
text->SetText(mTitle, PR_TRUE);
|
||||
text->SetText(title, PR_TRUE);
|
||||
|
||||
it->AppendChildTo(text, PR_FALSE, PR_FALSE);
|
||||
text->SetDocument(mDocument, PR_FALSE, PR_TRUE);
|
||||
|
|
|
@ -233,11 +233,9 @@ nsXMLContentSink::MaybePrettyPrint()
|
|||
NS_IMETHODIMP
|
||||
nsXMLContentSink::DidBuildModel()
|
||||
{
|
||||
if (mTitleText.IsEmpty()) {
|
||||
if (mDocument->GetDocumentTitle().IsVoid()) {
|
||||
nsCOMPtr<nsIDOMNSDocument> dom_doc(do_QueryInterface(mDocument));
|
||||
if (dom_doc) {
|
||||
dom_doc->SetTitle(EmptyString());
|
||||
}
|
||||
dom_doc->SetTitle(EmptyString());
|
||||
}
|
||||
|
||||
if (mXSLTProcessor) {
|
||||
|
@ -446,7 +444,7 @@ nsXMLContentSink::CreateElement(const PRUnichar** aAtts, PRUint32 aAttsCount,
|
|||
}
|
||||
|
||||
if (aNodeInfo->Equals(nsHTMLAtoms::title, kNameSpaceID_XHTML)) {
|
||||
if (mTitleText.IsEmpty()) {
|
||||
if (mDocument->GetDocumentTitle().IsVoid()) {
|
||||
mInTitle = PR_TRUE; // The first title wins
|
||||
}
|
||||
}
|
||||
|
@ -530,10 +528,8 @@ nsXMLContentSink::CloseElement(nsIContent* aContent, PRBool* aAppendContent)
|
|||
mInTitle) {
|
||||
// The first title wins
|
||||
nsCOMPtr<nsIDOMNSDocument> dom_doc(do_QueryInterface(mDocument));
|
||||
if (dom_doc) {
|
||||
mTitleText.CompressWhitespace();
|
||||
dom_doc->SetTitle(mTitleText);
|
||||
}
|
||||
mTitleText.CompressWhitespace();
|
||||
dom_doc->SetTitle(mTitleText);
|
||||
mInTitle = PR_FALSE;
|
||||
}
|
||||
else if (nodeInfo->Equals(nsHTMLAtoms::base, kNameSpaceID_XHTML) &&
|
||||
|
|
|
@ -531,7 +531,7 @@ nsXULDocument::StartDocumentLoad(const char* aCommand, nsIChannel* aChannel,
|
|||
{
|
||||
mDocumentLoadGroup = do_GetWeakReference(aLoadGroup);
|
||||
|
||||
mDocumentTitle.Truncate();
|
||||
mDocumentTitle.SetIsVoid(PR_TRUE);
|
||||
|
||||
nsresult rv = aChannel->GetOriginalURI(getter_AddRefs(mDocumentURI));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
|
Загрузка…
Ссылка в новой задаче