author | Boris Zbarsky <bzbarsky@mit.edu> |
Wed, 21 Mar 2018 23:13:28 -0400 | |
changeset 409437 | e75da32a2992ca10092e328f81af0d1ca7ddd08b |
parent 409436 | 5900a3a5a232a63ef9f437952df49a0ca6443e48 |
child 409438 | 20d2f8bbd902d08511b4473290bce7a53b40d155 |
push id | 33687 |
push user | apavel@mozilla.com |
push date | Thu, 22 Mar 2018 09:31:48 +0000 |
treeherder | mozilla-central@7771df14ea18 [default view] [failures only] |
perfherder | [talos] [build metrics] [platform microbench] (compared to previous push) |
reviewers | peterv |
bugs | 1442039 |
milestone | 61.0a1 |
first release with | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
last release without | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
dom/base/nsDOMClassInfo.cpp | file | annotate | diff | comparison | revisions | |
dom/base/nsScriptNameSpaceManager.h | file | annotate | diff | comparison | revisions |
--- a/dom/base/nsDOMClassInfo.cpp +++ b/dom/base/nsDOMClassInfo.cpp @@ -976,19 +976,17 @@ nsDOMConstructor::HasInstance(nsIXPConne if (name_struct == class_name_struct) { *bp = true; return NS_OK; } const nsIID *class_iid; - if (class_name_struct->mType == nsGlobalNameStruct::eTypeClassProto) { - class_iid = &class_name_struct->mIID; - } else if (class_name_struct->mType == nsGlobalNameStruct::eTypeClassConstructor) { + if (class_name_struct->mType == nsGlobalNameStruct::eTypeClassConstructor) { class_iid = sClassInfoData[class_name_struct->mDOMClassInfoID].mProtoChainInterface; } else { *bp = false; return NS_OK; } @@ -1039,19 +1037,17 @@ nsDOMConstructor::HasInstance(nsIXPConne nsresult nsDOMConstructor::ResolveInterfaceConstants(JSContext *cx, JS::Handle<JSObject*> obj) { const nsGlobalNameStruct *class_name_struct = GetNameStruct(); if (!class_name_struct) return NS_ERROR_UNEXPECTED; const nsIID *class_iid; - if (class_name_struct->mType == nsGlobalNameStruct::eTypeClassProto) { - class_iid = &class_name_struct->mIID; - } else if (class_name_struct->mType == nsGlobalNameStruct::eTypeClassConstructor) { + if (class_name_struct->mType == nsGlobalNameStruct::eTypeClassConstructor) { class_iid = sClassInfoData[class_name_struct->mDOMClassInfoID].mProtoChainInterface; } else { return NS_OK; } nsresult rv = DefineInterfaceConstants(cx, obj, class_iid); NS_ENSURE_SUCCESS(rv, rv); @@ -1088,32 +1084,28 @@ GetXPCProto(nsIXPConnect *aXPConnect, JS nsresult rv = aXPConnect->GetWrappedNativePrototype(cx, aWin->GetGlobalJSObject(), ci, aProto.address()); NS_ENSURE_SUCCESS(rv, rv); return JS_WrapObject(cx, aProto) ? NS_OK : NS_ERROR_FAILURE; } -// Either ci_data must be non-null or name_struct must be non-null and of type -// eTypeClassProto. +// ci_data must be non-null static nsresult ResolvePrototype(nsIXPConnect *aXPConnect, nsGlobalWindowInner *aWin, JSContext *cx, JS::Handle<JSObject*> obj, const char16_t *name, const nsDOMClassInfoData *ci_data, const nsGlobalNameStruct *name_struct, nsScriptNameSpaceManager *nameSpaceManager, JSObject* aDot_prototype, JS::MutableHandle<JS::PropertyDescriptor> ctorDesc) { JS::Rooted<JSObject*> dot_prototype(cx, aDot_prototype); - NS_ASSERTION(ci_data || - (name_struct && - name_struct->mType == nsGlobalNameStruct::eTypeClassProto), - "Wrong type or missing ci_data!"); + NS_ASSERTION(ci_data, "Missing ci_data!"); RefPtr<nsDOMConstructor> constructor; nsresult rv = nsDOMConstructor::Create(name, name_struct, aWin->AsInner(), getter_AddRefs(constructor)); NS_ENSURE_SUCCESS(rv, rv); JS::Rooted<JS::Value> v(cx); @@ -1130,20 +1122,17 @@ ResolvePrototype(nsIXPConnect *aXPConnec if (!JS_WrapValue(cx, ctorDesc.value())) { return NS_ERROR_UNEXPECTED; } JS::Rooted<JSObject*> class_obj(cx, &v.toObject()); const nsIID *primary_iid = &NS_GET_IID(nsISupports); - if (!ci_data) { - primary_iid = &name_struct->mIID; - } - else if (ci_data->mProtoChainInterface) { + if (ci_data->mProtoChainInterface) { primary_iid = ci_data->mProtoChainInterface; } nsCOMPtr<nsIInterfaceInfo> if_info; nsCOMPtr<nsIInterfaceInfo> parent; const char *class_parent_name = nullptr; if (!primary_iid->Equals(NS_GET_IID(nsISupports))) { @@ -1156,28 +1145,28 @@ ResolvePrototype(nsIXPConnect *aXPConnec iim(do_GetService(NS_INTERFACEINFOMANAGER_SERVICE_CONTRACTID)); NS_ENSURE_TRUE(iim, NS_ERROR_NOT_AVAILABLE); iim->GetInfoForIID(primary_iid, getter_AddRefs(if_info)); NS_ENSURE_TRUE(if_info, NS_ERROR_UNEXPECTED); const nsIID *iid = nullptr; - if (ci_data && !ci_data->mHasClassInterface) { + if (!ci_data->mHasClassInterface) { if_info->GetIIDShared(&iid); } else { if_info->GetParent(getter_AddRefs(parent)); NS_ENSURE_TRUE(parent, NS_ERROR_UNEXPECTED); parent->GetIIDShared(&iid); } if (iid) { if (!iid->Equals(NS_GET_IID(nsISupports))) { - if (ci_data && !ci_data->mHasClassInterface) { + if (!ci_data->mHasClassInterface) { // If the class doesn't have a class interface the primary // interface is the interface that should be // constructor.prototype.__proto__. if_info->GetNameShared(&class_parent_name); } else { // If the class does have a class interface (or there's no // real class for this name) then the parent of the @@ -1372,24 +1361,16 @@ nsWindowSH::GlobalResolve(nsGlobalWindow // prototype. return ResolvePrototype(nsDOMClassInfo::sXPConnect, aWin, cx, obj, class_name, &sClassInfoData[name_struct->mDOMClassInfoID], name_struct, nameSpaceManager, dot_prototype, desc); } - if (name_struct->mType == nsGlobalNameStruct::eTypeClassProto) { - // We don't have a XPConnect prototype object, let ResolvePrototype create - // one. - return ResolvePrototype(nsDOMClassInfo::sXPConnect, aWin, cx, obj, - class_name, nullptr, - name_struct, nameSpaceManager, nullptr, desc); - } - if (name_struct->mType == nsGlobalNameStruct::eTypeProperty) { // Before defining a global property, check for a named subframe of the // same name. If it exists, we don't want to shadow it. if (nsCOMPtr<nsPIDOMWindowOuter> childWin = aWin->GetChildWindow(name)) { return NS_OK; } nsCOMPtr<nsISupports> native(do_CreateInstance(name_struct->mCID, &rv));
--- a/dom/base/nsScriptNameSpaceManager.h +++ b/dom/base/nsScriptNameSpaceManager.h @@ -20,23 +20,21 @@ #include "xpcpublic.h" struct nsGlobalNameStruct { enum nametype { eTypeNotInitialized, eTypeProperty, eTypeClassConstructor, - eTypeClassProto, } mType; union { int32_t mDOMClassInfoID; // eTypeClassConstructor - nsIID mIID; // eTypeClassProto - nsCID mCID; // All other types + nsCID mCID; // eTypeProperty }; }; class GlobalNameMapEntry : public PLDHashEntryHdr { public: // Our hash table ops don't care about the order of these members. nsString mKey;