mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-29 07:42:04 +00:00
Bug 1155984. Improve the performance of the "self" getter in both window and workers. r=peterv,jorendorff
This commit is contained in:
parent
3e88d83106
commit
34d521e285
@ -2620,6 +2620,12 @@ nsGlobalWindow::SetNewDocument(nsIDocument* aDocument,
|
||||
NS_ERROR("can't create the 'window' property");
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
// And same thing for the "self" property.
|
||||
if (!JS_GetProperty(cx, newInnerGlobal, "self", &unused)) {
|
||||
NS_ERROR("can't create the 'self' property");
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -3533,11 +3539,9 @@ nsGlobalWindow::GetWindow(nsIDOMWindow** aWindow)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsIDOMWindow*
|
||||
nsGlobalWindow::GetSelf(ErrorResult& aError)
|
||||
nsGlobalWindow*
|
||||
nsGlobalWindow::Self()
|
||||
{
|
||||
FORWARD_TO_OUTER_OR_THROW(GetSelf, (aError), aError, nullptr);
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
@ -3545,10 +3549,12 @@ NS_IMETHODIMP
|
||||
nsGlobalWindow::GetSelf(nsIDOMWindow** aWindow)
|
||||
{
|
||||
ErrorResult rv;
|
||||
nsCOMPtr<nsIDOMWindow> window = GetSelf(rv);
|
||||
FORWARD_TO_OUTER_OR_THROW(GetSelf, (aWindow), rv, rv.StealNSResult());
|
||||
|
||||
nsCOMPtr<nsIDOMWindow> window = Self();
|
||||
window.forget(aWindow);
|
||||
|
||||
return rv.StealNSResult();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
Navigator*
|
||||
|
@ -838,7 +838,7 @@ public:
|
||||
CreateNamedPropertiesObject(JSContext *aCx, JS::Handle<JSObject*> aProto);
|
||||
|
||||
nsGlobalWindow* Window();
|
||||
nsIDOMWindow* GetSelf(mozilla::ErrorResult& aError);
|
||||
nsGlobalWindow* Self();
|
||||
nsIDocument* GetDocument()
|
||||
{
|
||||
return GetDoc();
|
||||
|
@ -3555,11 +3555,12 @@ class CGUpdateMemberSlotsMethod(CGAbstractStaticMethod):
|
||||
"JSJitGetterCallArgs args(&temp);\n")
|
||||
for m in self.descriptor.interface.members:
|
||||
if m.isAttr() and m.getExtendedAttribute("StoreInSlot"):
|
||||
# Skip doing this for the "window" attribute on the Window
|
||||
# interface, because that can't be gotten safely until we have
|
||||
# hooked it up correctly to the outer window.
|
||||
# Skip doing this for the "window" and "self" attributes on the
|
||||
# Window interface, because those can't be gotten safely until
|
||||
# we have hooked it up correctly to the outer window. The
|
||||
# window code handles doing the get itself.
|
||||
if (self.descriptor.interface.identifier.name == "Window" and
|
||||
m.identifier.name == "window"):
|
||||
(m.identifier.name == "window" or m.identifier.name == "self")):
|
||||
continue
|
||||
body += fill(
|
||||
"""
|
||||
|
@ -29,8 +29,8 @@ typedef any Transferable;
|
||||
// the current browsing context
|
||||
[Unforgeable, Constant, StoreInSlot,
|
||||
CrossOriginReadable] readonly attribute Window window;
|
||||
[Replaceable, Throws,
|
||||
CrossOriginReadable] readonly attribute WindowProxy self;
|
||||
[Replaceable, Constant, StoreInSlot,
|
||||
CrossOriginReadable] readonly attribute Window self;
|
||||
[Unforgeable, StoreInSlot, Pure] readonly attribute Document? document;
|
||||
[Throws] attribute DOMString name;
|
||||
[PutForwards=href, Unforgeable, Throws,
|
||||
|
@ -14,6 +14,7 @@
|
||||
|
||||
[Exposed=(Worker)]
|
||||
interface WorkerGlobalScope : EventTarget {
|
||||
[Constant, Cached]
|
||||
readonly attribute WorkerGlobalScope self;
|
||||
|
||||
[Replaceable]
|
||||
|
@ -80,10 +80,10 @@ public:
|
||||
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_INHERITED(WorkerGlobalScope,
|
||||
DOMEventTargetHelper)
|
||||
|
||||
already_AddRefed<WorkerGlobalScope>
|
||||
WorkerGlobalScope*
|
||||
Self()
|
||||
{
|
||||
return nsRefPtr<WorkerGlobalScope>(this).forget();
|
||||
return this;
|
||||
}
|
||||
|
||||
Console*
|
||||
|
@ -613,7 +613,7 @@ struct JSClass {
|
||||
// JSCLASS_GLOBAL_APPLICATION_SLOTS is the number of slots reserved at
|
||||
// the beginning of every global object's slots for use by the
|
||||
// application.
|
||||
#define JSCLASS_GLOBAL_APPLICATION_SLOTS 4
|
||||
#define JSCLASS_GLOBAL_APPLICATION_SLOTS 5
|
||||
#define JSCLASS_GLOBAL_SLOT_COUNT (JSCLASS_GLOBAL_APPLICATION_SLOTS + JSProto_LIMIT * 3 + 31)
|
||||
#define JSCLASS_GLOBAL_FLAGS_WITH_SLOTS(n) \
|
||||
(JSCLASS_IS_GLOBAL | JSCLASS_HAS_RESERVED_SLOTS(JSCLASS_GLOBAL_SLOT_COUNT + (n)))
|
||||
|
Loading…
Reference in New Issue
Block a user