summaryrefslogtreecommitdiffstats
path: root/WebCore/platform/android
diff options
context:
space:
mode:
authorAndrei Popescu <andreip@google.com>2010-01-13 18:43:00 +0000
committerAndrei Popescu <andreip@google.com>2010-01-25 11:52:07 +0000
commitdcb9f821994a3c585bc51d6f1a6a356a6034de5b (patch)
treef5399e101de0bee8dacf8c808d70b10aae9c3982 /WebCore/platform/android
parentb621c75b275a6b7ac0fd99772749aaadb3548815 (diff)
downloadexternal_webkit-dcb9f821994a3c585bc51d6f1a6a356a6034de5b.zip
external_webkit-dcb9f821994a3c585bc51d6f1a6a356a6034de5b.tar.gz
external_webkit-dcb9f821994a3c585bc51d6f1a6a356a6034de5b.tar.bz2
Prepare NPV8Object.h/cpp for upstreaming:
- remove #include bindings/npruntime.h from NPV8Object.cpp since that's also included in the NPV8Object.h - add ARRAYSIZE_UNSAFE macro - remove some TODOS This will be checked in after the corresponding webkit bug gets landed. See https://bugs.webkit.org/show_bug.cgi?id=33608
Diffstat (limited to 'WebCore/platform/android')
-rw-r--r--WebCore/platform/android/PlatformBridge.h49
1 files changed, 49 insertions, 0 deletions
diff --git a/WebCore/platform/android/PlatformBridge.h b/WebCore/platform/android/PlatformBridge.h
index 8b08490..cf9f561 100644
--- a/WebCore/platform/android/PlatformBridge.h
+++ b/WebCore/platform/android/PlatformBridge.h
@@ -27,10 +27,56 @@
#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 {
@@ -59,6 +105,9 @@ public:
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,