Bug 836301 - Hoist enter() into BaseProxyHandler. r=mrbkap
authorBobby Holley <bobbyholley@gmail.com>
Fri, 22 Feb 2013 08:14:33 -0800
changeset 122666 b5992ec030e3f3506cb6683d11680c320626f5e5
parent 122665 240174280d5258b0601c77398b4e18e48ef8b067
child 122667 f2fa2d0bb5e6bb1db92006a8f51eec1f54e927ec
push id24356
push usergszorc@mozilla.com
push dateSun, 24 Feb 2013 01:00:12 +0000
treeherdermozilla-central@195e706140d1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmrbkap
bugs836301
milestone22.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 836301 - Hoist enter() into BaseProxyHandler. r=mrbkap
js/src/jsproxy.cpp
js/src/jsproxy.h
js/src/jswrapper.cpp
js/src/jswrapper.h
--- a/js/src/jsproxy.cpp
+++ b/js/src/jsproxy.cpp
@@ -56,16 +56,24 @@ BaseProxyHandler::BaseProxyHandler(void 
 {
 }
 
 BaseProxyHandler::~BaseProxyHandler()
 {
 }
 
 bool
+BaseProxyHandler::enter(JSContext *cx, JSObject *wrapper, jsid id, Action act,
+                        bool *bp)
+{
+    *bp = true;
+    return true;
+}
+
+bool
 BaseProxyHandler::has(JSContext *cx, JSObject *proxy_, jsid id_, bool *bp)
 {
     RootedObject proxy(cx, proxy_);
     RootedId id(cx, id_);
     AutoPropertyDescriptorRooter desc(cx);
     if (!getPropertyDescriptor(cx, proxy, id, &desc, 0))
         return false;
     *bp = !!desc.obj;
--- a/js/src/jsproxy.h
+++ b/js/src/jsproxy.h
@@ -72,16 +72,32 @@ class JS_FRIEND_API(BaseProxyHandler) {
     inline void *family() {
         return mFamily;
     }
 
     virtual bool isOuterWindow() {
         return false;
     }
 
+    /* Policy enforcement traps.
+     *
+     * enter() allows the policy to specify whether the caller may perform |act|
+     * on the proxy's |id| property. In the case when |act| is CALL, |id| is
+     * generally JSID_VOID.
+     *
+     * The |act| parameter to enter() specifies the action being performed.
+     */
+    enum Action {
+        GET,
+        SET,
+        CALL
+    };
+    virtual bool enter(JSContext *cx, JSObject *wrapper, jsid id, Action act,
+                       bool *bp);
+
     /* ES5 Harmony fundamental proxy traps. */
     virtual bool getPropertyDescriptor(JSContext *cx, JSObject *proxy, jsid id,
                                        PropertyDescriptor *desc, unsigned flags) = 0;
     virtual bool getOwnPropertyDescriptor(JSContext *cx, JSObject *proxy,
                                           jsid id, PropertyDescriptor *desc, unsigned flags) = 0;
     virtual bool defineProperty(JSContext *cx, JSObject *proxy, jsid id,
                                 PropertyDescriptor *desc) = 0;
     virtual bool getOwnPropertyNames(JSContext *cx, JSObject *proxy,
--- a/js/src/jswrapper.cpp
+++ b/js/src/jswrapper.cpp
@@ -65,23 +65,16 @@ Wrapper::wrapperHandler(RawObject wrappe
 
 JSObject *
 Wrapper::wrappedObject(RawObject wrapper)
 {
     JS_ASSERT(wrapper->isWrapper());
     return GetProxyTargetObject(wrapper);
 }
 
-bool
-Wrapper::enter(JSContext *cx, JSObject *wrapper, jsid id, Action act, bool *bp)
-{
-    *bp = true;
-    return true;
-}
-
 JS_FRIEND_API(JSObject *)
 js::UnwrapObject(JSObject *wrapped, bool stopAtOuter, unsigned *flagsp)
 {
     unsigned flags = 0;
     while (wrapped->isWrapper() &&
            !JS_UNLIKELY(stopAtOuter && wrapped->getClass()->ext.innerObject)) {
         flags |= Wrapper::wrapperHandler(wrapped)->flags();
         wrapped = GetProxyPrivate(wrapped).toObjectOrNull();
--- a/js/src/jswrapper.h
+++ b/js/src/jswrapper.h
@@ -27,21 +27,17 @@ class DummyFrameGuard;
  * should be careful to avoid unwrapping security wrappers in the wrong context.
  */
 class JS_FRIEND_API(Wrapper) : public DirectProxyHandler
 {
     unsigned mFlags;
     bool mSafeToUnwrap;
 
   public:
-    enum Action {
-        GET,
-        SET,
-        CALL
-    };
+    using BaseProxyHandler::Action;
 
     enum Flags {
         CROSS_COMPARTMENT = 1 << 0,
         LAST_USED_FLAG = CROSS_COMPARTMENT
     };
 
     /*
      * Wrappers can explicitly specify that they are unsafe to unwrap from a
@@ -60,27 +56,16 @@ class JS_FRIEND_API(Wrapper) : public Di
     static Wrapper *wrapperHandler(RawObject wrapper);
 
     static JSObject *wrappedObject(RawObject wrapper);
 
     unsigned flags() const {
         return mFlags;
     }
 
-    /* Policy enforcement traps.
-     *
-     * enter() allows the policy to specify whether the caller may perform |act|
-     * on the underlying object's |id| property. In the case when |act| is CALL,
-     * |id| is generally JSID_VOID.
-     *
-     * The |act| parameter to enter() specifies the action being performed.
-     */
-    virtual bool enter(JSContext *cx, JSObject *wrapper, jsid id, Action act,
-                       bool *bp);
-
     explicit Wrapper(unsigned flags, bool hasPrototype = false);
 
     virtual ~Wrapper();
 
     /* ES5 Harmony fundamental wrapper traps. */
     virtual bool getPropertyDescriptor(JSContext *cx, JSObject *wrapper,
                                        jsid id, PropertyDescriptor *desc,
                                        unsigned flags) MOZ_OVERRIDE;