mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-13 21:35:39 +00:00
Bug 868929 - Convert ImageDocument to WebIDL, consolidate PostCreateWrapper call into nsIDocument::WrapObject. r=bz.
--HG-- rename : content/html/document/src/ImageDocument.cpp => content/html/document/src/ImageDocument.h extra : rebase_source : 79780765f9e6be8846774344e0218631903478d4
This commit is contained in:
parent
a340410615
commit
70530ae566
@ -113,8 +113,8 @@ typedef CallbackObjectHolder<NodeFilter, nsIDOMNodeFilter> NodeFilterHolder;
|
||||
} // namespace mozilla
|
||||
|
||||
#define NS_IDOCUMENT_IID \
|
||||
{ 0x4be4a58d, 0x7fce, 0x4315, \
|
||||
{ 0x9d, 0x6c, 0x8e, 0x9f, 0xc7, 0x2e, 0x51, 0xb } };
|
||||
{ 0x308f8444, 0x7679, 0x445a, \
|
||||
{ 0xa6, 0xcc, 0xb9, 0x5c, 0x61, 0xff, 0xe2, 0x66 } }
|
||||
|
||||
// Flag for AddStyleSheet().
|
||||
#define NS_STYLESHEET_FROM_CATALOG (1 << 0)
|
||||
@ -2098,6 +2098,9 @@ public:
|
||||
|
||||
virtual nsHTMLDocument* AsHTMLDocument() { return nullptr; }
|
||||
|
||||
virtual JSObject* WrapObject(JSContext *aCx,
|
||||
JS::Handle<JSObject*> aScope) MOZ_OVERRIDE;
|
||||
|
||||
private:
|
||||
uint64_t mWarnedAbout;
|
||||
|
||||
@ -2139,10 +2142,6 @@ protected:
|
||||
return mContentType;
|
||||
}
|
||||
|
||||
// All document WrapNode implementations MUST call this method. A
|
||||
// false return value means an exception was thrown.
|
||||
bool PostCreateWrapper(JSContext* aCx, JS::Handle<JSObject*> aNewObject);
|
||||
|
||||
nsCString mReferrer;
|
||||
nsString mLastModified;
|
||||
|
||||
|
@ -11230,43 +11230,53 @@ nsIDocument::Evaluate(const nsAString& aExpression, nsINode* aContextNode,
|
||||
|
||||
// This is just a hack around the fact that window.document is not
|
||||
// [Unforgeable] yet.
|
||||
bool
|
||||
nsIDocument::PostCreateWrapper(JSContext* aCx, JS::Handle<JSObject*> aNewObject)
|
||||
JSObject*
|
||||
nsIDocument::WrapObject(JSContext *aCx, JS::Handle<JSObject*> aScope)
|
||||
{
|
||||
MOZ_ASSERT(IsDOMBinding());
|
||||
|
||||
JS::Rooted<JSObject*> obj(aCx, nsINode::WrapObject(aCx, aScope));
|
||||
if (!obj) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsPIDOMWindow> win = do_QueryInterface(GetScriptGlobalObject());
|
||||
if (!win) {
|
||||
// No window, nothing else to do here
|
||||
return true;
|
||||
return obj;
|
||||
}
|
||||
|
||||
if (this != win->GetExtantDoc()) {
|
||||
// We're not the current document; we're also done here
|
||||
return true;
|
||||
return obj;
|
||||
}
|
||||
|
||||
JSAutoCompartment ac(aCx, aNewObject);
|
||||
JSAutoCompartment ac(aCx, obj);
|
||||
|
||||
JS::Rooted<JS::Value> winVal(aCx);
|
||||
nsCOMPtr<nsIXPConnectJSObjectHolder> holder;
|
||||
nsresult rv = nsContentUtils::WrapNative(aCx, aNewObject, win,
|
||||
nsresult rv = nsContentUtils::WrapNative(aCx, obj, win,
|
||||
&NS_GET_IID(nsIDOMWindow),
|
||||
winVal.address(),
|
||||
getter_AddRefs(holder),
|
||||
false);
|
||||
if (NS_FAILED(rv)) {
|
||||
return Throw<true>(aCx, rv);
|
||||
Throw<true>(aCx, rv);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
NS_NAMED_LITERAL_STRING(doc_str, "document");
|
||||
|
||||
return JS_DefineUCProperty(aCx, JSVAL_TO_OBJECT(winVal),
|
||||
reinterpret_cast<const jschar *>
|
||||
(doc_str.get()),
|
||||
doc_str.Length(), JS::ObjectValue(*aNewObject),
|
||||
JS_PropertyStub, JS_StrictPropertyStub,
|
||||
JSPROP_READONLY | JSPROP_ENUMERATE);
|
||||
if (!JS_DefineUCProperty(aCx, JSVAL_TO_OBJECT(winVal),
|
||||
reinterpret_cast<const jschar *>
|
||||
(doc_str.get()),
|
||||
doc_str.Length(), JS::ObjectValue(*obj),
|
||||
JS_PropertyStub, JS_StrictPropertyStub,
|
||||
JSPROP_READONLY | JSPROP_ENUMERATE)) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return obj;
|
||||
}
|
||||
|
||||
bool
|
||||
|
@ -175,11 +175,7 @@ ImageDocument::Init()
|
||||
JSObject*
|
||||
ImageDocument::WrapNode(JSContext* aCx, JS::Handle<JSObject*> aScope)
|
||||
{
|
||||
JS::Rooted<JSObject*> obj(aCx, ImageDocumentBinding::Wrap(aCx, aScope, this));
|
||||
if (obj && !PostCreateWrapper(aCx, obj)) {
|
||||
return nullptr;
|
||||
}
|
||||
return obj;
|
||||
return ImageDocumentBinding::Wrap(aCx, aScope, this);
|
||||
}
|
||||
|
||||
nsresult
|
||||
|
@ -258,11 +258,7 @@ NS_INTERFACE_MAP_END_INHERITING(nsDocument)
|
||||
JSObject*
|
||||
nsHTMLDocument::WrapNode(JSContext* aCx, JS::Handle<JSObject*> aScope)
|
||||
{
|
||||
JS::Rooted<JSObject*> obj(aCx, HTMLDocumentBinding::Wrap(aCx, aScope, this));
|
||||
if (obj && !PostCreateWrapper(aCx, obj)) {
|
||||
return nullptr;
|
||||
}
|
||||
return obj;
|
||||
return HTMLDocumentBinding::Wrap(aCx, aScope, this);
|
||||
}
|
||||
|
||||
nsresult
|
||||
|
@ -104,11 +104,7 @@ SVGDocument::Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const
|
||||
JSObject*
|
||||
SVGDocument::WrapNode(JSContext *aCx, JS::Handle<JSObject*> aScope)
|
||||
{
|
||||
JS::Rooted<JSObject*> obj(aCx, SVGDocumentBinding::Wrap(aCx, aScope, this));
|
||||
if (obj && !PostCreateWrapper(aCx, obj)) {
|
||||
return nullptr;
|
||||
}
|
||||
return obj;
|
||||
return SVGDocumentBinding::Wrap(aCx, aScope, this);
|
||||
}
|
||||
|
||||
} // namespace dom
|
||||
|
@ -629,11 +629,7 @@ XMLDocument::Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const
|
||||
JSObject*
|
||||
XMLDocument::WrapNode(JSContext *aCx, JS::Handle<JSObject*> aScope)
|
||||
{
|
||||
JS::Rooted<JSObject*> obj(aCx, XMLDocumentBinding::Wrap(aCx, aScope, this));
|
||||
if (obj && !PostCreateWrapper(aCx, obj)) {
|
||||
return nullptr;
|
||||
}
|
||||
return obj;
|
||||
return XMLDocumentBinding::Wrap(aCx, aScope, this);
|
||||
}
|
||||
|
||||
} // namespace dom
|
||||
|
@ -4762,11 +4762,7 @@ XULDocument::GetBoxObjectFor(nsIDOMElement* aElement, nsIBoxObject** aResult)
|
||||
JSObject*
|
||||
XULDocument::WrapNode(JSContext *aCx, JS::Handle<JSObject*> aScope)
|
||||
{
|
||||
JS::Rooted<JSObject*> obj(aCx, XULDocumentBinding::Wrap(aCx, aScope, this));
|
||||
if (obj && !PostCreateWrapper(aCx, obj)) {
|
||||
return nullptr;
|
||||
}
|
||||
return obj;
|
||||
return XULDocumentBinding::Wrap(aCx, aScope, this);
|
||||
}
|
||||
|
||||
} // namespace dom
|
||||
|
Loading…
Reference in New Issue
Block a user