#include "NPV8Object.h"
-#if PLATFORM(CHROMIUM)
-// TODO(andreip): upstream
-#include "ChromiumBridge.h"
-#endif
+#include "PlatformBridge.h"
#include "DOMWindow.h"
#include "Frame.h"
#include "OwnArrayPtr.h"
#include "V8Helpers.h"
#include "V8NPUtils.h"
#include "V8Proxy.h"
-#if PLATFORM(CHROMIUM)
-#include "bindings/npruntime.h"
-#else
-#include "bridge/npruntime.h"
-#endif
#include "npruntime_impl.h"
#include "npruntime_priv.h"
bool _NPN_Evaluate(NPP npp, NPObject* npObject, NPString* npScript, NPVariant* result)
{
-#if PLATFORM(CHROMIUM)
- bool popupsAllowed = WebCore::ChromiumBridge::popupsAllowed(npp);
-#else
- // TODO(andreip): Some of the binding code is specific to Chromium
- // and we don't want it to Android. What is the preferred way to handle this?
- bool popupsAllowed = false;
-#endif
+ bool popupsAllowed = WebCore::PlatformBridge::popupsAllowed(npp);
return _NPN_EvaluateHelper(npp, popupsAllowed, npObject, npScript, result);
}
v8::Handle<v8::Value> enumeratorObj = script->Run();
v8::Handle<v8::Function> enumerator = v8::Handle<v8::Function>::Cast(enumeratorObj);
v8::Handle<v8::Value> argv[] = { obj };
-#if PLATFORM(ANDROID)
-// TODO(benm): implement an arry size function on android
- v8::Local<v8::Value> propsObj = enumerator->Call(v8::Handle<v8::Object>::Cast(enumeratorObj), 1, argv);
-#else
v8::Local<v8::Value> propsObj = enumerator->Call(v8::Handle<v8::Object>::Cast(enumeratorObj), ARRAYSIZE_UNSAFE(argv), argv);
-#endif
if (propsObj.IsEmpty())
return false;
#define NPV8Object_h
#if PLATFORM(CHROMIUM)
-// TODO(andreip): diff and consolidate
+// FIXME: Chromium uses a different npruntime.h, which is in
+// the Chromium source repository under third_party/npapi/bindings.
+// The Google-specific changes in that file should probably be
+// moved into bridge/npruntime.h, guarded by an #if PlATFORM(CHROMIUM).
#include "bindings/npruntime.h"
#else
-#include "bridge/npruntime.h" // use WebCore version
+#include "bridge/npruntime.h" // Use WebCore version for Android and other ports.
#endif
#include <v8.h>
#define PlatformBridge_h
#include "KURL.h"
+#include "npapi.h"
#include "PlatformString.h"
#include <wtf/Vector.h>
+// V8 bindings use the ARRAYSIZE_UNSAFE macro. This macro was copied
+// from http://src.chromium.org/viewvc/chrome/trunk/src/base/basictypes.h
+//
+// ARRAYSIZE_UNSAFE performs essentially the same calculation as arraysize,
+// but can be used on anonymous types or types defined inside
+// functions. It's less safe than arraysize as it accepts some
+// (although not all) pointers. Therefore, you should use arraysize
+// whenever possible.
+//
+// The expression ARRAYSIZE_UNSAFE(a) is a compile-time constant of type
+// size_t.
+//
+// ARRAYSIZE_UNSAFE catches a few type errors. If you see a compiler error
+//
+// "warning: division by zero in ..."
+//
+// when using ARRAYSIZE_UNSAFE, you are (wrongfully) giving it a pointer.
+// You should only use ARRAYSIZE_UNSAFE on statically allocated arrays.
+//
+// The following comments are on the implementation details, and can
+// be ignored by the users.
+//
+// ARRAYSIZE_UNSAFE(arr) works by inspecting sizeof(arr) (the # of bytes in
+// the array) and sizeof(*(arr)) (the # of bytes in one array
+// element). If the former is divisible by the latter, perhaps arr is
+// indeed an array, in which case the division result is the # of
+// elements in the array. Otherwise, arr cannot possibly be an array,
+// and we generate a compiler error to prevent the code from
+// compiling.
+//
+// Since the size of bool is implementation-defined, we need to cast
+// !(sizeof(a) & sizeof(*(a))) to size_t in order to ensure the final
+// result has type size_t.
+//
+// This macro is not perfect as it wrongfully accepts certain
+// pointers, namely where the pointer size is divisible by the pointee
+// size. Since all our code has to go through a 32-bit compiler,
+// where a pointer is 4 bytes, this means all pointers to a type whose
+// size is 3 or greater than 4 will be (righteously) rejected.
+
+#define ARRAYSIZE_UNSAFE(a) \
+ ((sizeof(a) / sizeof(*(a))) / \
+ static_cast<size_t>(!(sizeof(a) % sizeof(*(a)))))
+
+
class NPObject;
namespace WebCore {
static bool cookiesEnabled();
// Plugin
static NPObject* pluginScriptableObject(Widget*);
+ // Popups
+ static bool popupsAllowed(NPP);
+
// These ids need to be in sync with the constants in BrowserFrame.java
enum rawResId {
NoDomain = 1,