From 1dbdacbc2f87c101158314adf0a862d30983bd3a Mon Sep 17 00:00:00 2001 From: "neil%parkwaycc.co.uk" Date: Sun, 24 Oct 2004 22:57:06 +0000 Subject: [PATCH] Deprecate window.title b=264102 r=jst sr=peterv --- dom/src/base/nsGlobalWindow.cpp | 31 +++++++++++++++++++++---------- dom/src/base/nsGlobalWindow.h | 2 -- 2 files changed, 21 insertions(+), 12 deletions(-) diff --git a/dom/src/base/nsGlobalWindow.cpp b/dom/src/base/nsGlobalWindow.cpp index 496630d1e0bc..ff68e4784bea 100644 --- a/dom/src/base/nsGlobalWindow.cpp +++ b/dom/src/base/nsGlobalWindow.cpp @@ -84,6 +84,7 @@ #include "nsIHTMLDocument.h" #include "nsIDOMCrypto.h" #include "nsIDOMDocument.h" +#include "nsIDOMNSDocument.h" #include "nsIDOMDocumentView.h" #include "nsIDOMElement.h" #include "nsIDOMDocumentEvent.h" @@ -5489,25 +5490,35 @@ NS_IMPL_RELEASE_INHERITED(nsGlobalChromeWindow, GlobalWindowImpl) // nsGlobalChromeWindow implementation +static void TitleConsoleWarning() +{ + nsCOMPtr console(do_GetService("@mozilla.org/consoleservice;1")); + if (console) + console->LogStringMessage(NS_LITERAL_STRING("Deprecated property window.title used. Please use document.title instead.").get()); +} + NS_IMETHODIMP nsGlobalChromeWindow::GetTitle(nsAString& aTitle) { - aTitle = mTitle; - return NS_OK; + NS_ERROR("nsIDOMChromeWindow::GetTitle is deprecated, use nsIDOMNSDocument instead"); + TitleConsoleWarning(); + + nsresult rv; + nsCOMPtr nsdoc(do_QueryInterface(mDocument, &rv)); + NS_ENSURE_SUCCESS(rv, rv); + return nsdoc->GetTitle(aTitle); } NS_IMETHODIMP nsGlobalChromeWindow::SetTitle(const nsAString& aTitle) { - mTitle = aTitle; - if(mDocShell) { - nsCOMPtr docShellAsWin(do_QueryInterface(mDocShell)); - if(docShellAsWin) { - docShellAsWin->SetTitle(PromiseFlatString(mTitle).get()); - } - } + NS_ERROR("nsIDOMChromeWindow::SetTitle is deprecated, use nsIDOMNSDocument instead"); + TitleConsoleWarning(); - return NS_OK; + nsresult rv; + nsCOMPtr nsdoc(do_QueryInterface(mDocument, &rv)); + NS_ENSURE_SUCCESS(rv, rv); + return nsdoc->SetTitle(aTitle); } NS_IMETHODIMP diff --git a/dom/src/base/nsGlobalWindow.h b/dom/src/base/nsGlobalWindow.h index ae3e64d778f4..7d2ed6264b3f 100644 --- a/dom/src/base/nsGlobalWindow.h +++ b/dom/src/base/nsGlobalWindow.h @@ -363,8 +363,6 @@ public: protected: nsresult GetMainWidget(nsIWidget** aMainWidget); - - nsString mTitle; }; /*