diff --git a/mozilla/dom/src/base/nsGlobalWindow.cpp b/mozilla/dom/src/base/nsGlobalWindow.cpp index f45b9398d19..c482982a42a 100644 --- a/mozilla/dom/src/base/nsGlobalWindow.cpp +++ b/mozilla/dom/src/base/nsGlobalWindow.cpp @@ -1056,54 +1056,26 @@ GlobalWindowImpl::SetLocation(jsval aLocation) NS_IMETHODIMP GlobalWindowImpl::GetTitle(nsAWritableString& aTitle) { - aTitle.Truncate(); - - nsCOMPtr docShellAsItem(do_QueryInterface(mDocShell)); - if (docShellAsItem) { - // See if we're a chrome shell. - PRInt32 type; - docShellAsItem->GetItemType(&type); - if(type == nsIDocShellTreeItem::typeChrome) { - nsCOMPtr treeOwner; - GetTreeOwner(getter_AddRefs(treeOwner)); - if (treeOwner) { - nsCOMPtr primaryContent; - treeOwner->GetPrimaryContentShell(getter_AddRefs(primaryContent)); - nsCOMPtr docShellAsWin(do_QueryInterface(primaryContent)); - if (docShellAsWin) { - nsXPIDLString title; - docShellAsWin->GetTitle(getter_Copies(title)); - aTitle.Assign(title); - } - } - } - } - + aTitle = mTitle; return NS_OK; } NS_IMETHODIMP GlobalWindowImpl::SetTitle(const nsAReadableString& aTitle) { - nsCOMPtr docShellAsItem(do_QueryInterface(mDocShell)); - if(docShellAsItem) { + mTitle = aTitle; + if(mDocShell) { // See if we're a chrome shell. PRInt32 type; + nsCOMPtr docShellAsItem(do_QueryInterface(mDocShell)); docShellAsItem->GetItemType(&type); if(type == nsIDocShellTreeItem::typeChrome) { - nsCOMPtr treeOwner; - GetTreeOwner(getter_AddRefs(treeOwner)); - if (treeOwner) { - nsCOMPtr primaryContent; - treeOwner->GetPrimaryContentShell(getter_AddRefs(primaryContent)); - nsCOMPtr docShellAsWin(do_QueryInterface(primaryContent)); - if (docShellAsWin) { - docShellAsWin->SetTitle(nsPromiseFlatString(aTitle).get()); - } + nsCOMPtr docShellAsWin(do_QueryInterface(mDocShell)); + if(docShellAsWin) { + docShellAsWin->SetTitle(nsPromiseFlatString(mTitle)); } } } - return NS_OK; } diff --git a/mozilla/dom/src/base/nsGlobalWindow.h b/mozilla/dom/src/base/nsGlobalWindow.h index aef5b7cc9ad..8361db6b91d 100644 --- a/mozilla/dom/src/base/nsGlobalWindow.h +++ b/mozilla/dom/src/base/nsGlobalWindow.h @@ -248,6 +248,7 @@ protected: PRBool mFirstDocumentLoad; nsString mStatus; nsString mDefaultStatus; + nsString mTitle; nsIScriptGlobalObjectOwner* mGlobalObjectOwner; // Weak Reference nsIDocShell* mDocShell; // Weak Reference