mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-10-22 15:17:29 +09:00
Issue #2490 - Part 3: Give CSS rules a PreCreate hook so we can safely wrappercache them.
This commit is contained in:
parent
5bb39ec403
commit
e510cc84af
2 changed files with 84 additions and 16 deletions
|
|
@ -189,14 +189,18 @@ static nsDOMClassInfoData sClassInfoData[] = {
|
||||||
// Misc Core related classes
|
// Misc Core related classes
|
||||||
|
|
||||||
// CSS classes
|
// CSS classes
|
||||||
NS_DEFINE_CLASSINFO_DATA(CSSStyleRule, nsDOMGenericSH,
|
NS_DEFINE_CLASSINFO_DATA(CSSStyleRule, nsCSSRuleSH,
|
||||||
DOM_DEFAULT_SCRIPTABLE_FLAGS)
|
DOM_DEFAULT_SCRIPTABLE_FLAGS |
|
||||||
NS_DEFINE_CLASSINFO_DATA(CSSImportRule, nsDOMGenericSH,
|
nsIXPCScriptable::WANT_PRECREATE)
|
||||||
DOM_DEFAULT_SCRIPTABLE_FLAGS)
|
NS_DEFINE_CLASSINFO_DATA(CSSImportRule, nsCSSRuleSH,
|
||||||
NS_DEFINE_CLASSINFO_DATA(CSSMediaRule, nsDOMGenericSH,
|
DOM_DEFAULT_SCRIPTABLE_FLAGS |
|
||||||
DOM_DEFAULT_SCRIPTABLE_FLAGS)
|
nsIXPCScriptable::WANT_PRECREATE)
|
||||||
NS_DEFINE_CLASSINFO_DATA(CSSNameSpaceRule, nsDOMGenericSH,
|
NS_DEFINE_CLASSINFO_DATA(CSSMediaRule, nsCSSRuleSH,
|
||||||
DOM_DEFAULT_SCRIPTABLE_FLAGS)
|
DOM_DEFAULT_SCRIPTABLE_FLAGS |
|
||||||
|
nsIXPCScriptable::WANT_PRECREATE)
|
||||||
|
NS_DEFINE_CLASSINFO_DATA(CSSNameSpaceRule, nsCSSRuleSH,
|
||||||
|
DOM_DEFAULT_SCRIPTABLE_FLAGS |
|
||||||
|
nsIXPCScriptable::WANT_PRECREATE)
|
||||||
|
|
||||||
// XUL classes
|
// XUL classes
|
||||||
#ifdef MOZ_XUL
|
#ifdef MOZ_XUL
|
||||||
|
|
@ -221,13 +225,16 @@ static nsDOMClassInfoData sClassInfoData[] = {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
NS_DEFINE_CLASSINFO_DATA(CSSMozDocumentRule, nsDOMGenericSH,
|
NS_DEFINE_CLASSINFO_DATA(CSSMozDocumentRule, nsDOMGenericSH,
|
||||||
DOM_DEFAULT_SCRIPTABLE_FLAGS)
|
DOM_DEFAULT_SCRIPTABLE_FLAGS |
|
||||||
|
nsIXPCScriptable::WANT_PRECREATE)
|
||||||
|
|
||||||
NS_DEFINE_CLASSINFO_DATA(CSSSupportsRule, nsDOMGenericSH,
|
NS_DEFINE_CLASSINFO_DATA(CSSSupportsRule, nsDOMGenericSH,
|
||||||
DOM_DEFAULT_SCRIPTABLE_FLAGS)
|
DOM_DEFAULT_SCRIPTABLE_FLAGS |
|
||||||
|
nsIXPCScriptable::WANT_PRECREATE)
|
||||||
|
|
||||||
NS_DEFINE_CLASSINFO_DATA(CSSFontFaceRule, nsDOMGenericSH,
|
NS_DEFINE_CLASSINFO_DATA(CSSFontFaceRule, nsDOMGenericSH,
|
||||||
DOM_DEFAULT_SCRIPTABLE_FLAGS)
|
DOM_DEFAULT_SCRIPTABLE_FLAGS |
|
||||||
|
nsIXPCScriptable::WANT_PRECREATE)
|
||||||
|
|
||||||
NS_DEFINE_CHROME_ONLY_CLASSINFO_DATA(ContentFrameMessageManager,
|
NS_DEFINE_CHROME_ONLY_CLASSINFO_DATA(ContentFrameMessageManager,
|
||||||
nsMessageManagerSH<nsEventTargetSH>,
|
nsMessageManagerSH<nsEventTargetSH>,
|
||||||
|
|
@ -246,18 +253,23 @@ static nsDOMClassInfoData sClassInfoData[] = {
|
||||||
|
|
||||||
|
|
||||||
NS_DEFINE_CLASSINFO_DATA(CSSKeyframeRule, nsDOMGenericSH,
|
NS_DEFINE_CLASSINFO_DATA(CSSKeyframeRule, nsDOMGenericSH,
|
||||||
DOM_DEFAULT_SCRIPTABLE_FLAGS)
|
DOM_DEFAULT_SCRIPTABLE_FLAGS |
|
||||||
|
nsIXPCScriptable::WANT_PRECREATE)
|
||||||
NS_DEFINE_CLASSINFO_DATA(CSSKeyframesRule, nsDOMGenericSH,
|
NS_DEFINE_CLASSINFO_DATA(CSSKeyframesRule, nsDOMGenericSH,
|
||||||
DOM_DEFAULT_SCRIPTABLE_FLAGS)
|
DOM_DEFAULT_SCRIPTABLE_FLAGS |
|
||||||
|
nsIXPCScriptable::WANT_PRECREATE)
|
||||||
|
|
||||||
NS_DEFINE_CLASSINFO_DATA(CSSCounterStyleRule, nsDOMGenericSH,
|
NS_DEFINE_CLASSINFO_DATA(CSSCounterStyleRule, nsDOMGenericSH,
|
||||||
DOM_DEFAULT_SCRIPTABLE_FLAGS)
|
DOM_DEFAULT_SCRIPTABLE_FLAGS |
|
||||||
|
nsIXPCScriptable::WANT_PRECREATE)
|
||||||
|
|
||||||
NS_DEFINE_CLASSINFO_DATA(CSSPageRule, nsDOMGenericSH,
|
NS_DEFINE_CLASSINFO_DATA(CSSPageRule, nsDOMGenericSH,
|
||||||
DOM_DEFAULT_SCRIPTABLE_FLAGS)
|
DOM_DEFAULT_SCRIPTABLE_FLAGS |
|
||||||
|
nsIXPCScriptable::WANT_PRECREATE)
|
||||||
|
|
||||||
NS_DEFINE_CLASSINFO_DATA(CSSFontFeatureValuesRule, nsDOMGenericSH,
|
NS_DEFINE_CLASSINFO_DATA(CSSFontFeatureValuesRule, nsDOMGenericSH,
|
||||||
DOM_DEFAULT_SCRIPTABLE_FLAGS)
|
DOM_DEFAULT_SCRIPTABLE_FLAGS |
|
||||||
|
nsIXPCScriptable::WANT_PRECREATE)
|
||||||
|
|
||||||
NS_DEFINE_CHROME_XBL_CLASSINFO_DATA(XULControlElement, nsDOMGenericSH,
|
NS_DEFINE_CHROME_XBL_CLASSINFO_DATA(XULControlElement, nsDOMGenericSH,
|
||||||
DOM_DEFAULT_SCRIPTABLE_FLAGS)
|
DOM_DEFAULT_SCRIPTABLE_FLAGS)
|
||||||
|
|
@ -1982,6 +1994,39 @@ nsEventTargetSH::PreserveWrapper(nsISupports *aNative)
|
||||||
target->PreserveWrapper(aNative);
|
target->PreserveWrapper(aNative);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// CSS rule helper
|
||||||
|
NS_IMETHODIMP
|
||||||
|
nsCSSRuleSH::PreCreate(nsISupports *nativeObj, JSContext *cx,
|
||||||
|
JSObject *aGlobalObj, JSObject **parentObj)
|
||||||
|
{
|
||||||
|
JS::Rooted<JSObject*> globalObj(cx, aGlobalObj);
|
||||||
|
nsCOMPtr<nsIDOMCSSRule> rule = do_QueryInterface(nativeObj);
|
||||||
|
if (!rule) {
|
||||||
|
return NS_ERROR_UNEXPECTED;
|
||||||
|
}
|
||||||
|
css::Rule* cssRule = rule->GetCSSRule();
|
||||||
|
if (!cssRule) {
|
||||||
|
// A DOMCSSStyleRule whose actual underlying rule has gone away. There
|
||||||
|
// isn't much a caller can do with this thing anyway, and only chrome code
|
||||||
|
// can get its hands on it to start with, so just wrap in the current
|
||||||
|
// global.
|
||||||
|
*parentObj = globalObj;
|
||||||
|
return NS_OK;
|
||||||
|
}
|
||||||
|
nsIDocument* doc = cssRule->GetDocument();
|
||||||
|
if (!doc) {
|
||||||
|
*parentObj = globalObj;
|
||||||
|
return NS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
nsIGlobalObject* global = doc->GetScopeObject();
|
||||||
|
if (!global) {
|
||||||
|
return NS_ERROR_UNEXPECTED;
|
||||||
|
}
|
||||||
|
*parentObj = global->GetGlobalJSObject();
|
||||||
|
return *parentObj ? NS_OK : NS_ERROR_FAILURE;
|
||||||
|
}
|
||||||
|
|
||||||
// nsIDOMEventListener::HandleEvent() 'this' converter helper
|
// nsIDOMEventListener::HandleEvent() 'this' converter helper
|
||||||
|
|
||||||
NS_INTERFACE_MAP_BEGIN(nsEventListenerThisTranslator)
|
NS_INTERFACE_MAP_BEGIN(nsEventListenerThisTranslator)
|
||||||
|
|
|
||||||
|
|
@ -172,6 +172,29 @@ public:
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// Makes sure that we always create our wrapper in the right global, so we won't
|
||||||
|
// cache one from the wrong global.
|
||||||
|
class nsCSSRuleSH : public nsDOMGenericSH
|
||||||
|
{
|
||||||
|
protected:
|
||||||
|
explicit nsCSSRuleSH(nsDOMClassInfoData* aData) : nsDOMGenericSH(aData)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual ~nsCSSRuleSH()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
public:
|
||||||
|
NS_IMETHOD PreCreate(nsISupports *nativeObj, JSContext *cx,
|
||||||
|
JSObject *globalObj, JSObject **parentObj) override;
|
||||||
|
|
||||||
|
static nsIClassInfo *doCreate(nsDOMClassInfoData* aData)
|
||||||
|
{
|
||||||
|
return new nsCSSRuleSH(aData);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
// A place to hang some static methods that we should really consider
|
// A place to hang some static methods that we should really consider
|
||||||
// moving to be nsGlobalWindow member methods. See bug 1062418.
|
// moving to be nsGlobalWindow member methods. See bug 1062418.
|
||||||
class nsWindowSH
|
class nsWindowSH
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue