Move nsIDocumentCharsetInfo out of intl/chardet into nsIDocShell, Bug 713825, r=bz, mbrubeck
This commit is contained in:
@@ -90,7 +90,6 @@
|
||||
#include "nsIScriptSecurityManager.h"
|
||||
#include "nsIJSContextStack.h"
|
||||
#include "nsIScriptObjectPrincipal.h"
|
||||
#include "nsDocumentCharsetInfoCID.h"
|
||||
#include "nsIScrollableFrame.h"
|
||||
#include "nsContentPolicyUtils.h" // NS_CheckContentLoadPolicy(...)
|
||||
#include "nsICategoryManager.h"
|
||||
@@ -756,10 +755,11 @@ nsDocShell::nsDocShell():
|
||||
mIsBeingDestroyed(false),
|
||||
mIsExecutingOnLoadHandler(false),
|
||||
mIsPrintingOrPP(false),
|
||||
mSavingOldViewer(false)
|
||||
mSavingOldViewer(false),
|
||||
#ifdef DEBUG
|
||||
, mInEnsureScriptEnv(false)
|
||||
mInEnsureScriptEnv(false),
|
||||
#endif
|
||||
mParentCharsetSource(0)
|
||||
{
|
||||
mHistoryID = ++gDocshellIDCounter;
|
||||
if (gDocShellCount++ == 0) {
|
||||
@@ -1877,41 +1877,60 @@ nsDocShell::SetCharset(const char* aCharset)
|
||||
}
|
||||
|
||||
// set the charset override
|
||||
nsCOMPtr<nsIDocumentCharsetInfo> dcInfo;
|
||||
GetDocumentCharsetInfo(getter_AddRefs(dcInfo));
|
||||
if (dcInfo) {
|
||||
nsCOMPtr<nsIAtom> csAtom;
|
||||
csAtom = do_GetAtom(aCharset);
|
||||
dcInfo->SetForcedCharset(csAtom);
|
||||
}
|
||||
nsCOMPtr<nsIAtom> csAtom = do_GetAtom(aCharset);
|
||||
SetForcedCharset(csAtom);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDocShell::GetDocumentCharsetInfo(nsIDocumentCharsetInfo **
|
||||
aDocumentCharsetInfo)
|
||||
NS_IMETHODIMP nsDocShell::SetForcedCharset(nsIAtom * aCharset)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aDocumentCharsetInfo);
|
||||
|
||||
// if the mDocumentCharsetInfo does not exist already, we create it now
|
||||
if (!mDocumentCharsetInfo) {
|
||||
mDocumentCharsetInfo = do_CreateInstance(NS_DOCUMENTCHARSETINFO_CONTRACTID);
|
||||
if (!mDocumentCharsetInfo)
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
*aDocumentCharsetInfo = mDocumentCharsetInfo;
|
||||
NS_IF_ADDREF(*aDocumentCharsetInfo);
|
||||
return NS_OK;
|
||||
mForcedCharset = aCharset;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDocShell::SetDocumentCharsetInfo(nsIDocumentCharsetInfo *
|
||||
aDocumentCharsetInfo)
|
||||
NS_IMETHODIMP nsDocShell::GetForcedCharset(nsIAtom ** aResult)
|
||||
{
|
||||
mDocumentCharsetInfo = aDocumentCharsetInfo;
|
||||
return NS_OK;
|
||||
*aResult = mForcedCharset;
|
||||
if (mForcedCharset) NS_ADDREF(*aResult);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsDocShell::SetForcedDetector(bool aForced)
|
||||
{
|
||||
// XXX write me
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsDocShell::GetForcedDetector(bool * aResult)
|
||||
{
|
||||
// XXX write me
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsDocShell::SetParentCharset(nsIAtom * aCharset)
|
||||
{
|
||||
mParentCharset = aCharset;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsDocShell::GetParentCharset(nsIAtom ** aResult)
|
||||
{
|
||||
*aResult = mParentCharset;
|
||||
if (mParentCharset) NS_ADDREF(*aResult);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsDocShell::SetParentCharsetSource(PRInt32 aCharsetSource)
|
||||
{
|
||||
mParentCharsetSource = aCharsetSource;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsDocShell::GetParentCharsetSource(PRInt32 * aParentCharsetSource)
|
||||
{
|
||||
*aParentCharsetSource = mParentCharsetSource;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
@@ -3184,9 +3203,9 @@ nsDocShell::AddChild(nsIDocShellTreeItem * aChild)
|
||||
|
||||
// charset, style-disabling, and zoom will be inherited in SetupNewViewer()
|
||||
|
||||
// Now take this document's charset and set the parentCharset field of the
|
||||
// child's DocumentCharsetInfo to it. We'll later use that field, in the
|
||||
// loading process, for the charset choosing algorithm.
|
||||
// Now take this document's charset and set the child's parentCharset field
|
||||
// to it. We'll later use that field, in the loading process, for the
|
||||
// charset choosing algorithm.
|
||||
// If we fail, at any point, we just return NS_OK.
|
||||
// This code has some performance impact. But this will be reduced when
|
||||
// the current charset will finally be stored as an Atom, avoiding the
|
||||
@@ -3196,12 +3215,6 @@ nsDocShell::AddChild(nsIDocShellTreeItem * aChild)
|
||||
if (mItemType == nsIDocShellTreeItem::typeChrome)
|
||||
return NS_OK;
|
||||
|
||||
// get the child's docCSInfo object
|
||||
nsCOMPtr<nsIDocumentCharsetInfo> dcInfo = NULL;
|
||||
res = childAsDocShell->GetDocumentCharsetInfo(getter_AddRefs(dcInfo));
|
||||
if (NS_FAILED(res) || (!dcInfo))
|
||||
return NS_OK;
|
||||
|
||||
// get the parent's current charset
|
||||
if (!mContentViewer)
|
||||
return NS_OK;
|
||||
@@ -3225,14 +3238,14 @@ nsDocShell::AddChild(nsIDocShellTreeItem * aChild)
|
||||
|
||||
// set the child's parentCharset
|
||||
nsCOMPtr<nsIAtom> parentCSAtom(do_GetAtom(parentCS));
|
||||
res = dcInfo->SetParentCharset(parentCSAtom);
|
||||
res = childAsDocShell->SetParentCharset(parentCSAtom);
|
||||
if (NS_FAILED(res))
|
||||
return NS_OK;
|
||||
|
||||
PRInt32 charsetSource = doc->GetDocumentCharacterSetSource();
|
||||
|
||||
// set the child's parentCharset
|
||||
res = dcInfo->SetParentCharsetSource(charsetSource);
|
||||
res = childAsDocShell->SetParentCharsetSource(charsetSource);
|
||||
if (NS_FAILED(res))
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user