summaryrefslogtreecommitdiffstats
path: root/webkit/port
diff options
context:
space:
mode:
authorager@google.com <ager@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-10-10 12:00:30 +0000
committerager@google.com <ager@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-10-10 12:00:30 +0000
commit0300ffbf62c1c0130ff6ac2f1d6a6e7d2f34cf24 (patch)
treefe346d1f45f7b012124bd2923dd61f28140912ca /webkit/port
parentf74283009db4c858557f93fea0aa909fd0ccfbf2 (diff)
downloadchromium_src-0300ffbf62c1c0130ff6ac2f1d6a6e7d2f34cf24.zip
chromium_src-0300ffbf62c1c0130ff6ac2f1d6a6e7d2f34cf24.tar.gz
chromium_src-0300ffbf62c1c0130ff6ac2f1d6a6e7d2f34cf24.tar.bz2
Unfork Clipboard.idl and implement the remaining custom methods.
Review URL: http://codereview.chromium.org/7227 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@3213 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/port')
-rw-r--r--webkit/port/bindings/v8/v8_custom.cpp106
-rw-r--r--webkit/port/bindings/v8/v8_custom.h4
-rw-r--r--webkit/port/dom/Clipboard.idl32
3 files changed, 93 insertions, 49 deletions
diff --git a/webkit/port/bindings/v8/v8_custom.cpp b/webkit/port/bindings/v8/v8_custom.cpp
index e3df7d1..c064246 100644
--- a/webkit/port/bindings/v8/v8_custom.cpp
+++ b/webkit/port/bindings/v8/v8_custom.cpp
@@ -2270,16 +2270,47 @@ CALLBACK_FUNC_DECL(ConsoleWarn) {
// Clipboard -------------------------------------------------------------------
+
+ACCESSOR_GETTER(ClipboardTypes) {
+ INC_STATS(L"DOM.Clipboard.types()");
+ Clipboard* imp =
+ V8Proxy::ToNativeObject<Clipboard>(V8ClassIndex::CLIPBOARD,
+ info.Holder());
+
+ HashSet<String> types = imp->types();
+ if (types.isEmpty())
+ return v8::Null();
+
+ v8::Local<v8::Array> result = v8::Array::New(types.size());
+ HashSet<String>::const_iterator end = types.end();
+ int index = 0;
+ for (HashSet<String>::const_iterator it = types.begin();
+ it != end;
+ ++it, ++index) {
+ result->Set(v8::Integer::New(index), v8String(*it));
+ }
+ return result;
+}
+
+
CALLBACK_FUNC_DECL(ClipboardClearData) {
INC_STATS(L"DOM.Clipboard.clearData()");
Clipboard* imp = V8Proxy::ToNativeObject<Clipboard>(
V8ClassIndex::CLIPBOARD, args.Holder());
+
if (args.Length() == 0) {
imp->clearAllData();
- } else {
+ return v8::Undefined();
+ }
+
+ if (args.Length() == 1) {
String v = ToWebCoreString(args[0]);
imp->clearData(v);
+ return v8::Undefined();
}
+
+ V8Proxy::ThrowError(V8Proxy::SYNTAX_ERROR,
+ "clearData: Invalid number of arguments");
return v8::Undefined();
}
@@ -2288,17 +2319,17 @@ CALLBACK_FUNC_DECL(ClipboardGetData) {
INC_STATS(L"DOM.Clipboard.getData()");
Clipboard* imp = V8Proxy::ToNativeObject<Clipboard>(
V8ClassIndex::CLIPBOARD, args.Holder());
- if (args.Length() == 1) {
- bool success;
- String v = ToWebCoreString(args[0]);
- String result = imp->getData(v, success);
- if (success) return v8String(result);
+
+ if (args.Length() != 1) {
+ V8Proxy::ThrowError(V8Proxy::SYNTAX_ERROR,
+ "getData: Invalid number of arguments");
return v8::Undefined();
}
- V8Proxy::ThrowError(V8Proxy::SYNTAX_ERROR,
- "getData: Invalid number of arguments");
-
+ bool success;
+ String v = ToWebCoreString(args[0]);
+ String result = imp->getData(v, success);
+ if (success) return v8String(result);
return v8::Undefined();
}
@@ -2306,15 +2337,58 @@ CALLBACK_FUNC_DECL(ClipboardSetData) {
INC_STATS(L"DOM.Clipboard.setData()");
Clipboard* imp = V8Proxy::ToNativeObject<Clipboard>(
V8ClassIndex::CLIPBOARD, args.Holder());
- if (args.Length() == 2) {
- String type = ToWebCoreString(args[0]);
- String data = ToWebCoreString(args[1]);
- bool result = imp->setData(type, data);
- return result?v8::True():v8::False();
+
+ if (args.Length() != 2) {
+ V8Proxy::ThrowError(V8Proxy::SYNTAX_ERROR,
+ "setData: Invalid number of arguments");
+ return v8::Undefined();
}
- V8Proxy::ThrowError(V8Proxy::SYNTAX_ERROR,
- "setData: Invalid number of arguments");
+ String type = ToWebCoreString(args[0]);
+ String data = ToWebCoreString(args[1]);
+ bool result = imp->setData(type, data);
+ return result ? v8::True() : v8::False();
+}
+
+
+CALLBACK_FUNC_DECL(ClipboardSetDragImage) {
+ INC_STATS(L"DOM.Clipboard.setDragImage()");
+ Clipboard* imp = V8Proxy::ToNativeObject<Clipboard>(
+ V8ClassIndex::CLIPBOARD, args.Holder());
+
+ if (!imp->isForDragging())
+ return v8::Undefined();
+
+ if (args.Length() != 3) {
+ V8Proxy::ThrowError(V8Proxy::SYNTAX_ERROR,
+ "setDragImage: Invalid number of arguments");
+ return v8::Undefined();
+ }
+
+ int x = ToInt32(args[1]);
+ int y = ToInt32(args[2]);
+
+ Node* node = 0;
+ if (V8Node::HasInstance(args[0]))
+ node = V8Proxy::DOMWrapperToNode<Node>(args[0]);
+ if (!node) {
+ V8Proxy::ThrowError(V8Proxy::TYPE_ERROR,
+ "setDragImageFromElement: Invalid first argument");
+ return v8::Undefined();
+ }
+
+ if (!node->isElementNode()) {
+ V8Proxy::ThrowError(V8Proxy::SYNTAX_ERROR,
+ "setDragImageFromElement: Invalid first argument");
+ return v8::Undefined();
+ }
+
+ if (static_cast<Element*>(node)->hasLocalName(HTMLNames::imgTag) &&
+ !node->inDocument())
+ imp->setDragImage(static_cast<HTMLImageElement*>(node)->cachedImage(),
+ IntPoint(x, y));
+ else
+ imp->setDragImageElement(node, IntPoint(x, y));
return v8::Undefined();
}
diff --git a/webkit/port/bindings/v8/v8_custom.h b/webkit/port/bindings/v8/v8_custom.h
index 776f6fd..a73ec55 100644
--- a/webkit/port/bindings/v8/v8_custom.h
+++ b/webkit/port/bindings/v8/v8_custom.h
@@ -259,10 +259,12 @@ DECLARE_CALLBACK(ConsoleProfileEnd)
DECLARE_CALLBACK(ConsoleTimeEnd)
DECLARE_CALLBACK(ConsoleWarn)
-// Implementation of Clipboard methods.
+// Implementation of Clipboard attributes and methods.
+DECLARE_PROPERTY_ACCESSOR_GETTER(ClipboardTypes)
DECLARE_CALLBACK(ClipboardClearData)
DECLARE_CALLBACK(ClipboardGetData)
DECLARE_CALLBACK(ClipboardSetData)
+DECLARE_CALLBACK(ClipboardSetDragImage);
// Implementation of Element methods.
DECLARE_CALLBACK(ElementQuerySelector)
diff --git a/webkit/port/dom/Clipboard.idl b/webkit/port/dom/Clipboard.idl
deleted file mode 100644
index faed199..0000000
--- a/webkit/port/dom/Clipboard.idl
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * Copyright (C) 2007 Google Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public License
- * along with this library; see the file COPYING.LIB. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- */
-
-module core {
- interface Clipboard {
- attribute [ConvertNullStringTo=Undefined] DOMString dropEffect;
- attribute [ConvertNullStringTo=Undefined] DOMString effectAllowed;
- // TODO: Implement.
- // readonly attribute DOMArray types;
- [Custom] void clearData(in [Optional] DOMString type);
- [Custom] DOMString getData(in DOMString type);
- [Custom] boolean setData(in DOMString type, in DOMString data);
- // TODO: Implement.
- // [Custom] void setDragImage(in Node node, in long x, in long y);
- };
-}