commit 8f3244276e1f3d464239d2fe6ee44ea4a2c7f672 Author: Boris Zbarsky bzbarsky@mit.edu Date: Mon Feb 10 14:07:26 2014 -0800
Bug 894448 part 1. Move IsChromeOrXBL to xpcpublic.h. r=bholley --- content/base/public/nsINode.h | 6 ------ content/base/src/nsINode.cpp | 9 --------- dom/bindings/Codegen.py | 3 +-- dom/webidl/Node.webidl | 4 ++-- js/xpconnect/src/nsXPConnect.cpp | 13 +++++++++++++ js/xpconnect/src/xpcpublic.h | 6 ++++++ 6 files changed, 22 insertions(+), 19 deletions(-)
diff --git a/content/base/public/nsINode.h b/content/base/public/nsINode.h index 8d725a5..2c0b0b5 100644 --- a/content/base/public/nsINode.h +++ b/content/base/public/nsINode.h @@ -1120,12 +1120,6 @@ public: return NS_OK; }
- /** - * Control if GetUserData and SetUserData methods will be exposed to - * unprivileged content. - */ - static bool IsChromeOrXBL(JSContext* aCx, JSObject* /* unused */); - void LookupPrefix(const nsAString& aNamespace, nsAString& aResult); bool IsDefaultNamespace(const nsAString& aNamespaceURI) { diff --git a/content/base/src/nsINode.cpp b/content/base/src/nsINode.cpp index bc93f7e..297d519 100644 --- a/content/base/src/nsINode.cpp +++ b/content/base/src/nsINode.cpp @@ -735,15 +735,6 @@ nsINode::GetUserData(JSContext* aCx, const nsAString& aKey, ErrorResult& aError) return result; }
-//static -bool -nsINode::IsChromeOrXBL(JSContext* aCx, JSObject* /* unused */) -{ - JSCompartment* compartment = js::GetContextCompartment(aCx); - return xpc::AccessCheck::isChrome(compartment) || - xpc::IsXBLScope(compartment); -} - uint16_t nsINode::CompareDocumentPosition(nsINode& aOtherNode) const { diff --git a/dom/bindings/Codegen.py b/dom/bindings/Codegen.py index a8f277f..88892d7 100644 --- a/dom/bindings/Codegen.py +++ b/dom/bindings/Codegen.py @@ -1479,8 +1479,7 @@ class MethodDefiner(PropertyDefiner): "length": 1, "flags": "0", "condition": - MemberCondition(None, - "nsINode::IsChromeOrXBL") }) + MemberCondition(None, "IsChromeOrXBL") })
if not static: stringifier = descriptor.operations['Stringifier'] diff --git a/dom/webidl/Node.webidl b/dom/webidl/Node.webidl index c6084de..2002d64 100644 --- a/dom/webidl/Node.webidl +++ b/dom/webidl/Node.webidl @@ -96,9 +96,9 @@ interface Node : EventTarget { readonly attribute DOMString? localName;
boolean hasAttributes(); - [Throws, Func="nsINode::IsChromeOrXBL"] + [Throws, Func="IsChromeOrXBL"] any setUserData(DOMString key, any data, UserDataHandler? handler); - [Throws, Func="nsINode::IsChromeOrXBL"] + [Throws, Func="IsChromeOrXBL"] any getUserData(DOMString key); [ChromeOnly] readonly attribute Principal nodePrincipal; diff --git a/js/xpconnect/src/nsXPConnect.cpp b/js/xpconnect/src/nsXPConnect.cpp index 9c6f74b..12a8fd0 100644 --- a/js/xpconnect/src/nsXPConnect.cpp +++ b/js/xpconnect/src/nsXPConnect.cpp @@ -1707,3 +1707,16 @@ IsXrayWrapper(JSObject *obj)
} // namespace xpc
+namespace mozilla { +namespace dom { + +bool +IsChromeOrXBL(JSContext* cx, JSObject* /* unused */) +{ + JSCompartment* compartment = js::GetContextCompartment(cx); + return AccessCheck::isChrome(compartment) || + IsXBLScope(compartment); +} + +} // namespace dom +} // namespace mozilla diff --git a/js/xpconnect/src/xpcpublic.h b/js/xpconnect/src/xpcpublic.h index 9398f24..365f1ba5 100644 --- a/js/xpconnect/src/xpcpublic.h +++ b/js/xpconnect/src/xpcpublic.h @@ -498,6 +498,12 @@ DefineStaticJSVals(JSContext *cx); void Register(nsScriptNameSpaceManager* aNameSpaceManager);
+/** + * A test for whether WebIDL methods that should only be visible to + * chrome or XBL scopes should be exposed. + */ +bool IsChromeOrXBL(JSContext* cx, JSObject* /* unused */); + } // namespace dom } // namespace mozilla
tbb-commits@lists.torproject.org