summaryrefslogtreecommitdiffstats
path: root/WebKit/chromium/src/WebBindings.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'WebKit/chromium/src/WebBindings.cpp')
-rw-r--r--WebKit/chromium/src/WebBindings.cpp91
1 files changed, 85 insertions, 6 deletions
diff --git a/WebKit/chromium/src/WebBindings.cpp b/WebKit/chromium/src/WebBindings.cpp
index 04f2f85..0882e38 100644
--- a/WebKit/chromium/src/WebBindings.cpp
+++ b/WebKit/chromium/src/WebBindings.cpp
@@ -34,9 +34,6 @@
#include "npruntime_impl.h"
#include "npruntime_priv.h"
-#include "../public/WebDragData.h"
-#include "../public/WebRange.h"
-
#if USE(V8)
#include "ChromiumDataObject.h"
#include "ClipboardChromium.h"
@@ -46,13 +43,19 @@
#include "Range.h"
#include "V8BindingState.h"
#include "V8DOMWrapper.h"
+#include "V8Element.h"
#include "V8Event.h"
#include "V8Helpers.h"
+#include "V8HiddenPropertyName.h"
+#include "V8NPUtils.h"
#include "V8Proxy.h"
#include "V8Range.h"
#elif USE(JSC)
#include "bridge/c/c_utility.h"
#endif
+#include "WebDragData.h"
+#include "WebElement.h"
+#include "WebRange.h"
#if USE(JAVASCRIPTCORE_BINDINGS)
using JSC::Bindings::PrivateIdentifier;
@@ -208,8 +211,7 @@ void WebBindings::extractIdentifierData(const NPIdentifier& identifier, const NP
static v8::Local<v8::Value> getEvent(const v8::Handle<v8::Context>& context)
{
- static v8::Persistent<v8::String> eventSymbol(v8::Persistent<v8::String>::New(v8::String::NewSymbol("event")));
- return context->Global()->GetHiddenValue(eventSymbol);
+ return context->Global()->GetHiddenValue(V8HiddenPropertyName::event());
}
static bool getDragDataImpl(NPObject* npobj, int* eventId, WebDragData* data)
@@ -284,7 +286,7 @@ static bool getRangeImpl(NPObject* npobj, WebRange* range)
{
V8NPObject* v8npobject = reinterpret_cast<V8NPObject*>(npobj);
v8::Handle<v8::Object> v8object(v8npobject->v8Object);
- if (V8ClassIndex::RANGE != V8DOMWrapper::domWrapperType(v8object))
+ if (!V8Range::info.equals(V8DOMWrapper::domWrapperType(v8object)))
return false;
Range* native = V8Range::toNative(v8object);
@@ -295,6 +297,43 @@ static bool getRangeImpl(NPObject* npobj, WebRange* range)
return true;
}
+static bool getElementImpl(NPObject* npObj, WebElement* webElement)
+{
+ if (!npObj || (npObj->_class != npScriptObjectClass))
+ return false;
+
+ V8NPObject* v8NPObject = reinterpret_cast<V8NPObject*>(npObj);
+ v8::Handle<v8::Object> v8Object(v8NPObject->v8Object);
+ Element* native = V8Element::toNative(v8Object);
+ if (!native)
+ return false;
+
+ *webElement = WebElement(native);
+ return true;
+}
+
+static NPObject* makeIntArrayImpl(const WebVector<int>& data)
+{
+ v8::HandleScope handleScope;
+ v8::Handle<v8::Array> result = v8::Array::New(data.size());
+ for (size_t i = 0; i < data.size(); i++)
+ result->Set(i, v8::Number::New(data[i]));
+
+ WebCore::DOMWindow* window = WebCore::V8Proxy::retrieveWindow(WebCore::V8Proxy::currentContext());
+ return npCreateV8ScriptObject(0, result, window);
+}
+
+static NPObject* makeStringArrayImpl(const WebVector<WebString>& data)
+{
+ v8::HandleScope handleScope;
+ v8::Handle<v8::Array> result = v8::Array::New(data.size());
+ for (size_t i = 0; i < data.size(); ++i)
+ result->Set(i, data[i].data() ? v8::String::New(reinterpret_cast<const uint16_t*>((data[i].data())), data[i].length()) : v8::String::New(""));
+
+ WebCore::DOMWindow* window = WebCore::V8Proxy::retrieveWindow(WebCore::V8Proxy::currentContext());
+ return npCreateV8ScriptObject(0, result, window);
+}
+
#endif
bool WebBindings::getDragData(NPObject* event, int* eventId, WebDragData* data)
@@ -323,4 +362,44 @@ bool WebBindings::getRange(NPObject* range, WebRange* webrange)
#endif
}
+bool WebBindings::getElement(NPObject* element, WebElement* webElement)
+{
+#if USE(V8)
+ return getElementImpl(element, webElement);
+#else
+ // Not supported on other ports (JSC, etc.).
+ return false;
+#endif
+}
+
+NPObject* WebBindings::makeIntArray(const WebVector<int> & data)
+{
+#if USE(V8)
+ return makeIntArrayImpl(data);
+#else
+ // Not supported on other ports (JSC, etc.).
+ return 0;
+#endif
+}
+
+NPObject* WebBindings::makeStringArray(const WebVector<WebString>& data)
+{
+#if USE(V8)
+ return makeStringArrayImpl(data);
+#else
+ // Not supported on other ports (JSC, etc.).
+ return 0;
+#endif
+}
+
+void WebBindings::pushExceptionHandler(ExceptionHandler handler, void* data)
+{
+ WebCore::pushExceptionHandler(handler, data);
+}
+
+void WebBindings::popExceptionHandler()
+{
+ WebCore::popExceptionHandler();
+}
+
} // namespace WebKit