Add docCharsetIsForced member to nsIDomWindowUtils. Bug 391631, r+sr=bz, a=jst

This commit is contained in:
smontagu@smontagu.org 2007-08-11 11:37:16 -07:00
Родитель 3668405b4d
Коммит 19b3a3893e
4 изменённых файлов: 27 добавлений и 1 удалений

Просмотреть файл

@ -3663,6 +3663,7 @@ nsHTMLDocument::CreateAndAddWyciwygChannel(void)
// Note: we want to treat this like a "previous document" hint so that,
// e.g. a <meta> tag in the document.write content can override it.
SetDocumentCharacterSetSource(kCharsetFromHintPrevDoc);
mWyciwygChannel->SetCharsetAndSource(kCharsetFromHintPrevDoc,
GetDocumentCharacterSet());

Просмотреть файл

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

Просмотреть файл

@ -83,6 +83,7 @@ REQUIRES = xpcom \
xultmpl \
jar \
storage \
htmlparser \
$(NULL)
ifdef NS_TRACE_MALLOC

Просмотреть файл

@ -52,6 +52,7 @@
#include "nsIFrame.h"
#include "nsIWidget.h"
#include "nsGUIEvent.h"
#include "nsIParser.h"
#ifdef MOZ_ENABLE_GTK2
#include <gdk/gdkx.h>
@ -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<nsIDocument> doc(do_QueryInterface(mWindow->GetExtantDocument()));
*aIsForced = doc &&
doc->GetDocumentCharacterSetSource() >= kCharsetFromParentForced;
}
return NS_OK;
}
NS_IMETHODIMP
nsDOMWindowUtils::GetDocumentMetadata(const nsAString& aName,
nsAString& aValue)