diff --git a/mozilla/content/html/document/src/nsHTMLDocument.cpp b/mozilla/content/html/document/src/nsHTMLDocument.cpp index 97d8c4c5e17..6c45e6bfeed 100644 --- a/mozilla/content/html/document/src/nsHTMLDocument.cpp +++ b/mozilla/content/html/document/src/nsHTMLDocument.cpp @@ -3663,6 +3663,7 @@ nsHTMLDocument::CreateAndAddWyciwygChannel(void) // Note: we want to treat this like a "previous document" hint so that, // e.g. a tag in the document.write content can override it. + SetDocumentCharacterSetSource(kCharsetFromHintPrevDoc); mWyciwygChannel->SetCharsetAndSource(kCharsetFromHintPrevDoc, GetDocumentCharacterSet()); diff --git a/mozilla/dom/public/idl/base/nsIDOMWindowUtils.idl b/mozilla/dom/public/idl/base/nsIDOMWindowUtils.idl index 18792cd4895..8eeeb06eec5 100644 --- a/mozilla/dom/public/idl/base/nsIDOMWindowUtils.idl +++ b/mozilla/dom/public/idl/base/nsIDOMWindowUtils.idl @@ -47,7 +47,7 @@ interface nsIDOMElement; -[scriptable, uuid(1F313394-73AB-41BF-8307-9FC5DA8A481E)] +[scriptable, uuid(25f55fb2-a6f8-4f7f-93c3-3adafd5166bc)] interface nsIDOMWindowUtils : nsISupports { /** @@ -69,6 +69,12 @@ interface nsIDOMWindowUtils : nsISupports { */ attribute unsigned short imageAnimationMode; + /** + * Whether the charset of the window's current document has been forced by + * the user + */ + readonly attribute boolean docCharsetIsForced; + /** * Function to get metadata associated with the window's current document * @param aName the name of the metadata. This should be all lowercase. diff --git a/mozilla/dom/src/base/Makefile.in b/mozilla/dom/src/base/Makefile.in index 329f353a7d9..17ffabe81ca 100644 --- a/mozilla/dom/src/base/Makefile.in +++ b/mozilla/dom/src/base/Makefile.in @@ -83,6 +83,7 @@ REQUIRES = xpcom \ xultmpl \ jar \ storage \ + htmlparser \ $(NULL) ifdef NS_TRACE_MALLOC diff --git a/mozilla/dom/src/base/nsDOMWindowUtils.cpp b/mozilla/dom/src/base/nsDOMWindowUtils.cpp index 27959fd5ebf..0124bd1c644 100644 --- a/mozilla/dom/src/base/nsDOMWindowUtils.cpp +++ b/mozilla/dom/src/base/nsDOMWindowUtils.cpp @@ -52,6 +52,7 @@ #include "nsIFrame.h" #include "nsIWidget.h" #include "nsGUIEvent.h" +#include "nsIParser.h" #ifdef MOZ_ENABLE_GTK2 #include @@ -112,6 +113,23 @@ nsDOMWindowUtils::SetImageAnimationMode(PRUint16 aMode) return NS_ERROR_NOT_AVAILABLE; } +NS_IMETHODIMP +nsDOMWindowUtils::GetDocCharsetIsForced(PRBool *aIsForced) +{ + *aIsForced = PR_FALSE; + + PRBool hasCap = PR_FALSE; + if (NS_FAILED(nsContentUtils::GetSecurityManager()->IsCapabilityEnabled("UniversalXPConnect", &hasCap)) || !hasCap) + return NS_ERROR_DOM_SECURITY_ERR; + + if (mWindow) { + nsCOMPtr doc(do_QueryInterface(mWindow->GetExtantDocument())); + *aIsForced = doc && + doc->GetDocumentCharacterSetSource() >= kCharsetFromParentForced; + } + return NS_OK; +} + NS_IMETHODIMP nsDOMWindowUtils::GetDocumentMetadata(const nsAString& aName, nsAString& aValue)