Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(521)

Side by Side Diff: third_party/WebKit/WebCore/bindings/v8/custom/V8ClipboardCustom.cpp

Issue 27217: Yet more scrubbins. Navigator, Clipboard, Document, and Node. (Closed) Base URL: svn://chrome-svn.corp.google.com/chrome/trunk/src/
Patch Set: '' Created 11 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | third_party/WebKit/WebCore/bindings/v8/custom/V8DocumentCustom.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Property Changes:
Added: svn:eol-style
+ LF
OLDNEW
(Empty)
1 /*
2 * Copyright (C) 2007-2009 Google Inc. All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above
11 * copyright notice, this list of conditions and the following disclaimer
12 * in the documentation and/or other materials provided with the
13 * distribution.
14 * * Neither the name of Google Inc. nor the names of its
15 * contributors may be used to endorse or promote products derived from
16 * this software without specific prior written permission.
17 *
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 * "AS IS" AND ANY EXPRESS OR clipboardLIED WARRANTIES, INCLUDING, BUT NOT
20 * LIMITED TO, THE clipboardLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */
30
31 #include "config.h"
32 #include "Clipboard.h"
33
34 #include "HTMLImageElement.h"
35 #include "HTMLNames.h"
36 #include "IntPoint.h"
37 #include "Node.h"
38 #include "Element.h"
39
40 #include "V8Binding.h"
41 #include "V8CustomBinding.h"
42 #include "V8Node.h"
43 #include "V8Proxy.h"
44
45 namespace WebCore {
46
47 ACCESSOR_GETTER(ClipboardTypes)
48 {
49 INC_STATS("DOM.Clipboard.types()");
50 Clipboard* clipboard = V8Proxy::ToNativeObject<Clipboard>(V8ClassIndex::CLIP BOARD, info.Holder());
51
52 HashSet<String> types = clipboard->types();
53 if (types.isEmpty())
54 return v8::Null();
55
56 v8::Local<v8::Array> result = v8::Array::New(types.size());
57 HashSet<String>::const_iterator end = types.end();
58 int index = 0;
59 for (HashSet<String>::const_iterator it = types.begin(); it != end; ++it, ++ index)
60 result->Set(v8::Integer::New(index), v8String(*it));
61
62 return result;
63 }
64
65 CALLBACK_FUNC_DECL(ClipboardClearData)
66 {
67 INC_STATS("DOM.Clipboard.clearData()");
68 Clipboard* clipboard = V8Proxy::ToNativeObject<Clipboard>(V8ClassIndex::CLIP BOARD, args.Holder());
69
70 if (!args.Length()) {
71 clipboard->clearAllData();
72 return v8::Undefined();
73 }
74
75 if (args.Length() != 1)
76 return throwError("clearData: Invalid number of arguments", V8Proxy::SYN TAX_ERROR);
77
78 String type = toWebCoreString(args[0]);
79 clipboard->clearData(type);
80 return v8::Undefined();
81 }
82
83 CALLBACK_FUNC_DECL(ClipboardGetData)
84 {
85 INC_STATS("DOM.Clipboard.getData()");
86 Clipboard* clipboard = V8Proxy::ToNativeObject<Clipboard>(V8ClassIndex::CLIP BOARD, args.Holder());
87
88 if (args.Length() != 1)
89 return throwError("getData: Invalid number of arguments", V8Proxy::SYNTA X_ERROR);
90
91 bool success;
92 String result = clipboard->getData(toWebCoreString(args[0]), success);
93 if (success)
94 return v8String(result);
95
96 return v8::Undefined();
97 }
98
99 CALLBACK_FUNC_DECL(ClipboardSetData)
100 {
101 INC_STATS("DOM.Clipboard.setData()");
102 Clipboard* clipboard = V8Proxy::ToNativeObject<Clipboard>(V8ClassIndex::CLIP BOARD, args.Holder());
103
104 if (args.Length() != 2)
105 return throwError("setData: Invalid number of arguments", V8Proxy::SYNTA X_ERROR);
106
107 String type = toWebCoreString(args[0]);
108 String data = toWebCoreString(args[1]);
109 return v8Boolean(clipboard->setData(type, data));
110 }
111
112 CALLBACK_FUNC_DECL(ClipboardSetDragImage)
113 {
114 INC_STATS("DOM.Clipboard.setDragImage()");
115 Clipboard* clipboard = V8Proxy::ToNativeObject<Clipboard>(V8ClassIndex::CLIP BOARD, args.Holder());
116
117 if (!clipboard->isForDragging())
118 return v8::Undefined();
119
120 if (args.Length() != 3)
121 return throwError("setDragImage: Invalid number of arguments", V8Proxy:: SYNTAX_ERROR);
122
123 int x = toInt32(args[1]);
124 int y = toInt32(args[2]);
125
126 Node* node = 0;
127 if (V8Node::HasInstance(args[0]))
128 node = V8Proxy::DOMWrapperToNode<Node>(args[0]);
129
130 if (!node || !node->isElementNode())
131 return throwError("setDragImageFromElement: Invalid first argument");
132
133 if (static_cast<Element*>(node)->hasLocalName(HTMLNames::imgTag) && !node->i nDocument())
134 clipboard->setDragImage(static_cast<HTMLImageElement*>(node)->cachedImag e(), IntPoint(x, y));
135 else
136 clipboard->setDragImageElement(node, IntPoint(x, y));
137
138 return v8::Undefined();
139 }
140
141 } // namespace WebCore
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/WebCore/bindings/v8/custom/V8DocumentCustom.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698