From 18d8f09c5b5875a37761b997f039148e243fa580 Mon Sep 17 00:00:00 2001 From: Michael Brennan Date: Sat, 25 May 2013 16:09:30 +0200 Subject: [PATCH] Bug 829603 - Change charsets to strings in nsIDocShell. r=hsivonen --- content/html/document/src/MediaDocument.cpp | 8 ++----- content/html/document/src/nsHTMLDocument.cpp | 17 ++++++--------- docshell/base/nsDocShell.cpp | 23 +++++++++----------- docshell/base/nsDocShell.h | 4 ++-- docshell/base/nsIDocShell.idl | 4 ++-- toolkit/content/widgets/browser.xml | 2 +- 6 files changed, 24 insertions(+), 34 deletions(-) diff --git a/content/html/document/src/MediaDocument.cpp b/content/html/document/src/MediaDocument.cpp index 26210f5a210..17bb5596fff 100644 --- a/content/html/document/src/MediaDocument.cpp +++ b/content/html/document/src/MediaDocument.cpp @@ -166,12 +166,8 @@ MediaDocument::StartDocumentLoad(const char* aCommand, NS_ENSURE_TRUE(docShell, NS_OK); nsAutoCString charset; - - nsCOMPtr csAtom; - docShell->GetParentCharset(getter_AddRefs(csAtom)); - if (csAtom) { // opening in a new tab - csAtom->ToUTF8String(charset); - } + // opening in a new tab + docShell->GetParentCharset(charset); if (charset.IsEmpty() || charset.Equals("UTF-8")) { nsCOMPtr cv; diff --git a/content/html/document/src/nsHTMLDocument.cpp b/content/html/document/src/nsHTMLDocument.cpp index 16e1391b880..5b7abea02f9 100644 --- a/content/html/document/src/nsHTMLDocument.cpp +++ b/content/html/document/src/nsHTMLDocument.cpp @@ -352,17 +352,16 @@ nsHTMLDocument::TryUserForcedCharset(nsIMarkupDocumentViewer* aMarkupDV, if (aDocShell) { // This is the Character Encoding menu code path in Firefox - nsCOMPtr csAtom; - aDocShell->GetForcedCharset(getter_AddRefs(csAtom)); - if (csAtom) { - nsAutoCString charset; - csAtom->ToUTF8String(charset); + nsAutoCString charset; + rv = aDocShell->GetForcedCharset(charset); + + if (NS_SUCCEEDED(rv) && !charset.IsEmpty()) { if (!EncodingUtils::IsAsciiCompatible(charset)) { return; } aCharset = charset; aCharsetSource = kCharsetFromUserForced; - aDocShell->SetForcedCharset(nullptr); + aDocShell->SetForcedCharset(NS_LITERAL_CSTRING("")); } } } @@ -418,15 +417,13 @@ nsHTMLDocument::TryParentCharset(nsIDocShell* aDocShell, return; } - nsCOMPtr csAtom; int32_t parentSource; nsAutoCString parentCharset; - aDocShell->GetParentCharset(getter_AddRefs(csAtom)); - if (!csAtom) { + aDocShell->GetParentCharset(parentCharset); + if (parentCharset.IsEmpty()) { return; } aDocShell->GetParentCharsetSource(&parentSource); - csAtom->ToUTF8String(parentCharset); if (kCharsetFromParentForced == parentSource || kCharsetFromUserForced == parentSource) { if (WillIgnoreCharsetOverride() || diff --git a/docshell/base/nsDocShell.cpp b/docshell/base/nsDocShell.cpp index 12cb3c102b6..c04bb4410e2 100644 --- a/docshell/base/nsDocShell.cpp +++ b/docshell/base/nsDocShell.cpp @@ -1969,35 +1969,33 @@ nsDocShell::SetCharset(const char* aCharset) } // set the charset override - nsCOMPtr csAtom = do_GetAtom(aCharset); - SetForcedCharset(csAtom); + nsCString charset(aCharset); + SetForcedCharset(charset); return NS_OK; -} +} -NS_IMETHODIMP nsDocShell::SetForcedCharset(nsIAtom * aCharset) +NS_IMETHODIMP nsDocShell::SetForcedCharset(const nsACString& aCharset) { mForcedCharset = aCharset; return NS_OK; } -NS_IMETHODIMP nsDocShell::GetForcedCharset(nsIAtom ** aResult) +NS_IMETHODIMP nsDocShell::GetForcedCharset(nsACString& aResult) { - *aResult = mForcedCharset; - if (mForcedCharset) NS_ADDREF(*aResult); + aResult = mForcedCharset; return NS_OK; } -NS_IMETHODIMP nsDocShell::SetParentCharset(nsIAtom * aCharset) +NS_IMETHODIMP nsDocShell::SetParentCharset(const nsACString& aCharset) { mParentCharset = aCharset; return NS_OK; } -NS_IMETHODIMP nsDocShell::GetParentCharset(nsIAtom ** aResult) +NS_IMETHODIMP nsDocShell::GetParentCharset(nsACString& aResult) { - *aResult = mParentCharset; - if (mParentCharset) NS_ADDREF(*aResult); + aResult = mParentCharset; return NS_OK; } @@ -3497,8 +3495,7 @@ nsDocShell::AddChild(nsIDocShellTreeItem * aChild) // expose here. // set the child's parentCharset - nsCOMPtr parentCSAtom(do_GetAtom(parentCS)); - res = childAsDocShell->SetParentCharset(parentCSAtom); + res = childAsDocShell->SetParentCharset(parentCS); if (NS_FAILED(res)) return NS_OK; diff --git a/docshell/base/nsDocShell.h b/docshell/base/nsDocShell.h index bd030815d88..55f0c3d8fa0 100644 --- a/docshell/base/nsDocShell.h +++ b/docshell/base/nsDocShell.h @@ -869,8 +869,8 @@ protected: uint32_t mOwnOrContainingAppId; private: - nsCOMPtr mForcedCharset; - nsCOMPtr mParentCharset; + nsCString mForcedCharset; + nsCString mParentCharset; nsTObserverArray mPrivacyObservers; int32_t mParentCharsetSource; nsCString mOriginalUriString; diff --git a/docshell/base/nsIDocShell.idl b/docshell/base/nsIDocShell.idl index d2faf3443ac..29b5f858e0e 100644 --- a/docshell/base/nsIDocShell.idl +++ b/docshell/base/nsIDocShell.idl @@ -597,12 +597,12 @@ interface nsIDocShell : nsIDocShellTreeItem * * XXX Could this be replaced by a boolean? */ - attribute nsIAtom forcedCharset; + attribute ACString forcedCharset; /** * In a child docshell, this is the charset of the parent docshell */ - attribute nsIAtom parentCharset; + attribute ACString parentCharset; /* * In a child docshell, this is the source of parentCharset diff --git a/toolkit/content/widgets/browser.xml b/toolkit/content/widgets/browser.xml index 4c49c9377d8..4d78f324039 100644 --- a/toolkit/content/widgets/browser.xml +++ b/toolkit/content/widgets/browser.xml @@ -143,7 +143,7 @@ if (aCharset) { try { - this.docShell.parentCharset = this.mAtomService.getAtom(aCharset); + this.docShell.parentCharset = aCharset; } catch (e) { }