Fix for bug 820657 (Implement the NamedGetter functionality on HTMLDocument) - hook up document.all in the HTMLDocument NamedGetter. r=bz.

--HG--
extra : rebase_source : 07e96b798b87bc18b3f63d845c4023a7593d9f6b
This commit is contained in:
Peter Van der Beken 2013-03-27 18:15:37 +01:00
parent 5da8fbf5c2
commit 9d70d3f0d0
3 changed files with 22 additions and 5 deletions

View File

@ -106,6 +106,7 @@
#include "mozilla/dom/HTMLBodyElement.h"
#include "nsCharsetSource.h"
#include "nsIStringBundle.h"
#include "nsDOMClassInfo.h"
using namespace mozilla;
using namespace mozilla::dom;
@ -2361,6 +2362,10 @@ nsHTMLDocument::NamedGetter(JSContext* cx, const nsAString& aName, bool& aFound,
nsISupports* supp = ResolveName(aName, &cache);
if (!supp) {
aFound = false;
if (GetCompatibilityMode() == eCompatibility_NavQuirks &&
aName.EqualsLiteral("all")) {
rv = nsHTMLDocumentSH::TryResolveAll(cx, this, GetWrapper());
}
return nullptr;
}

View File

@ -7190,6 +7190,17 @@ ResolveAll(JSContext* cx, nsIDocument* doc, JSObject* obj)
return NS_OK;
}
nsresult
nsHTMLDocumentSH::TryResolveAll(JSContext* cx, nsHTMLDocument* doc,
JSObject* obj)
{
if (sDisableDocumentAllSupport) {
return NS_OK;
}
JSAutoCompartment ac(cx, obj);
return ResolveAll(cx, doc, obj);
}
NS_IMETHODIMP
nsHTMLDocumentSH::NewResolve(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
JSObject *obj, jsid id, uint32_t flags,
@ -7226,12 +7237,10 @@ nsHTMLDocumentSH::NewResolve(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
if (id == sAll_id && !sDisableDocumentAllSupport &&
!ObjectIsNativeWrapper(cx, obj)) {
nsIDocument *doc = static_cast<nsIDocument*>(wrapper->Native());
if (doc->GetCompatibilityMode() == eCompatibility_NavQuirks) {
return ResolveAll(cx, doc, obj);
if (doc->GetCompatibilityMode() != eCompatibility_NavQuirks) {
return NS_OK;
}
return NS_OK;
return ResolveAll(cx, doc, obj);
}
}

View File

@ -690,6 +690,9 @@ public:
NS_IMETHOD GetProperty(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
JSObject *obj, jsid id, jsval *vp, bool *_retval);
static nsresult TryResolveAll(JSContext* cx, nsHTMLDocument* doc,
JSObject* obj);
static nsIClassInfo *doCreate(nsDOMClassInfoData* aData)
{
return new nsHTMLDocumentSH(aData);