mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-01-13 07:24:47 +00:00
Bug 993688 - Mark Window.document StoreInSlot. r=bz.
--HG-- extra : rebase_source : 016a4cfc9945dd83b6f14d9ce6cc12e2cb5d6fe0
This commit is contained in:
parent
b2265fd931
commit
c5601a6449
@ -2324,6 +2324,9 @@ nsGlobalWindow::SetNewDocument(nsIDocument* aDocument,
|
||||
// having to *always* reach into the inner window to find the
|
||||
// document.
|
||||
mDoc = aDocument;
|
||||
if (IsInnerWindow() && IsDOMBinding()) {
|
||||
WindowBinding::ClearCachedDocumentValue(cx, this);
|
||||
}
|
||||
|
||||
// Take this opportunity to clear mSuspendedDoc. Our old inner window is now
|
||||
// responsible for unsuspending it.
|
||||
@ -2590,16 +2593,20 @@ nsGlobalWindow::SetNewDocument(nsIDocument* aDocument,
|
||||
if (newInnerWindow->mDoc != aDocument) {
|
||||
newInnerWindow->mDoc = aDocument;
|
||||
|
||||
// We're reusing the inner window for a new document. In this
|
||||
// case we don't clear the inner window's scope, but we must
|
||||
// make sure the cached document property gets updated.
|
||||
if (newInnerWindow->IsDOMBinding()) {
|
||||
WindowBinding::ClearCachedDocumentValue(cx, newInnerWindow);
|
||||
} else {
|
||||
// We're reusing the inner window for a new document. In this
|
||||
// case we don't clear the inner window's scope, but we must
|
||||
// make sure the cached document property gets updated.
|
||||
|
||||
// XXXmarkh - tell other languages about this?
|
||||
JS::Rooted<JSObject*> obj(cx, currentInner->GetWrapperPreserveColor());
|
||||
::JS_DeleteProperty(cx, obj, "document");
|
||||
JS::Rooted<JSObject*> obj(cx,
|
||||
currentInner->GetWrapperPreserveColor());
|
||||
::JS_DeleteProperty(cx, obj, "document");
|
||||
}
|
||||
}
|
||||
} else {
|
||||
newInnerWindow->InnerSetNewDocument(aDocument);
|
||||
newInnerWindow->InnerSetNewDocument(cx, aDocument);
|
||||
|
||||
// Initialize DOM classes etc on the inner window.
|
||||
JS::Rooted<JSObject*> obj(cx, newInnerGlobal);
|
||||
@ -2715,7 +2722,7 @@ nsGlobalWindow::ClearStatus()
|
||||
}
|
||||
|
||||
void
|
||||
nsGlobalWindow::InnerSetNewDocument(nsIDocument* aDocument)
|
||||
nsGlobalWindow::InnerSetNewDocument(JSContext* aCx, nsIDocument* aDocument)
|
||||
{
|
||||
NS_PRECONDITION(IsInnerWindow(), "Must only be called on inner windows");
|
||||
MOZ_ASSERT(aDocument);
|
||||
@ -2731,6 +2738,9 @@ nsGlobalWindow::InnerSetNewDocument(nsIDocument* aDocument)
|
||||
#endif
|
||||
|
||||
mDoc = aDocument;
|
||||
if (IsDOMBinding()) {
|
||||
WindowBinding::ClearCachedDocumentValue(aCx, this);
|
||||
}
|
||||
mFocusedNode = nullptr;
|
||||
mLocalStorage = nullptr;
|
||||
mSessionStorage = nullptr;
|
||||
@ -13628,6 +13638,17 @@ nsGlobalWindow::GetSidebar(OwningExternalOrWindowProxy& aResult,
|
||||
#endif
|
||||
}
|
||||
|
||||
/* static */
|
||||
bool
|
||||
nsGlobalWindow::WindowOnWebIDL(JSContext* aCx, JSObject* aObj)
|
||||
{
|
||||
DebugOnly<nsGlobalWindow*> win;
|
||||
MOZ_ASSERT_IF(IsDOMObject(aObj),
|
||||
NS_SUCCEEDED(UNWRAP_OBJECT(Window, aObj, win)));
|
||||
|
||||
return IsDOMObject(aObj);
|
||||
}
|
||||
|
||||
#ifdef MOZ_B2G
|
||||
void
|
||||
nsGlobalWindow::EnableNetworkEvent(uint32_t aType)
|
||||
|
@ -792,6 +792,8 @@ public:
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
static bool WindowOnWebIDL(JSContext* /* unused */, JSObject* aObj);
|
||||
|
||||
nsIDOMWindow* GetWindow(mozilla::ErrorResult& aError);
|
||||
nsIDOMWindow* GetSelf(mozilla::ErrorResult& aError);
|
||||
nsIDocument* GetDocument()
|
||||
@ -1056,7 +1058,7 @@ protected:
|
||||
|
||||
// Only to be called on an inner window.
|
||||
// aDocument must not be null.
|
||||
void InnerSetNewDocument(nsIDocument* aDocument);
|
||||
void InnerSetNewDocument(JSContext* aCx, nsIDocument* aDocument);
|
||||
|
||||
nsresult DefineArgumentsProperty(nsIArray *aArguments);
|
||||
|
||||
|
@ -2819,6 +2819,7 @@ class CGWrapGlobalMethod(CGAbstractMethod):
|
||||
aOptions,
|
||||
aPrincipal);
|
||||
|
||||
%s
|
||||
%s
|
||||
|
||||
// XXXkhuey can't do this yet until workers can lazy resolve.
|
||||
@ -2826,7 +2827,8 @@ class CGWrapGlobalMethod(CGAbstractMethod):
|
||||
|
||||
return obj;""" % (AssertInheritanceChain(self.descriptor),
|
||||
self.descriptor.nativeType,
|
||||
InitUnforgeableProperties(self.descriptor, self.properties))
|
||||
InitUnforgeableProperties(self.descriptor, self.properties),
|
||||
InitMemberSlots(self.descriptor, True))
|
||||
|
||||
|
||||
class CGUpdateMemberSlotsMethod(CGAbstractStaticMethod):
|
||||
@ -6706,7 +6708,9 @@ class CGSpecializedGetter(CGAbstractStaticMethod):
|
||||
nativeName = CGSpecializedGetter.makeNativeName(self.descriptor,
|
||||
self.attr)
|
||||
if self.attr.slotIndex is not None:
|
||||
if self.descriptor.hasXPConnectImpls:
|
||||
if (self.descriptor.hasXPConnectImpls and
|
||||
(self.descriptor.interface.identifier.name != 'Window' or
|
||||
self.attr.identifier.name != 'document')):
|
||||
raise TypeError("Interface '%s' has XPConnect impls, so we "
|
||||
"can't use our slot for property '%s'!" %
|
||||
(self.descriptor.interface.identifier.name,
|
||||
|
@ -31,7 +31,7 @@ typedef any Transferable;
|
||||
CrossOriginReadable] readonly attribute WindowProxy window;
|
||||
[Replaceable, Throws,
|
||||
CrossOriginReadable] readonly attribute WindowProxy self;
|
||||
//[Unforgeable] readonly attribute Document? document;
|
||||
[Unforgeable, StoreInSlot, Pure, Func="nsGlobalWindow::WindowOnWebIDL"] readonly attribute Document? document;
|
||||
[Throws] attribute DOMString name;
|
||||
[PutForwards=href, Unforgeable, Throws,
|
||||
CrossOriginReadable, CrossOriginWritable] readonly attribute Location? location;
|
||||
|
Loading…
x
Reference in New Issue
Block a user