Bug 829603 - Change charsets to strings in nsIDocShell. r=hsivonen

This commit is contained in:
Michael Brennan 2013-05-25 16:09:30 +02:00
parent c2761ad140
commit 1eaf301952
6 changed files with 24 additions and 34 deletions

View File

@ -166,12 +166,8 @@ MediaDocument::StartDocumentLoad(const char* aCommand,
NS_ENSURE_TRUE(docShell, NS_OK);
nsAutoCString charset;
nsCOMPtr<nsIAtom> 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<nsIContentViewer> cv;

View File

@ -352,17 +352,16 @@ nsHTMLDocument::TryUserForcedCharset(nsIMarkupDocumentViewer* aMarkupDV,
if (aDocShell) {
// This is the Character Encoding menu code path in Firefox
nsCOMPtr<nsIAtom> 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<nsIAtom> 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() ||

View File

@ -1969,35 +1969,33 @@ nsDocShell::SetCharset(const char* aCharset)
}
// set the charset override
nsCOMPtr<nsIAtom> 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<nsIAtom> parentCSAtom(do_GetAtom(parentCS));
res = childAsDocShell->SetParentCharset(parentCSAtom);
res = childAsDocShell->SetParentCharset(parentCS);
if (NS_FAILED(res))
return NS_OK;

View File

@ -869,8 +869,8 @@ protected:
uint32_t mOwnOrContainingAppId;
private:
nsCOMPtr<nsIAtom> mForcedCharset;
nsCOMPtr<nsIAtom> mParentCharset;
nsCString mForcedCharset;
nsCString mParentCharset;
nsTObserverArray<nsWeakPtr> mPrivacyObservers;
int32_t mParentCharsetSource;
nsCString mOriginalUriString;

View File

@ -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

View File

@ -143,7 +143,7 @@
if (aCharset) {
try {
this.docShell.parentCharset = this.mAtomService.getAtom(aCharset);
this.docShell.parentCharset = aCharset;
}
catch (e) {
}