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

Side by Side Diff: Source/bindings/v8/V8Binding.cpp

Issue 47073007: Bindings: Remove special cases for DOMStringList (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Rebased Created 7 years, 1 month 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 | Annotate | Revision Log
« no previous file with comments | « Source/bindings/v8/V8Binding.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2006, 2007, 2008, 2009 Google Inc. All rights reserved. 2 * Copyright (C) 2006, 2007, 2008, 2009 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 13 matching lines...) Expand all
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 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. 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */ 29 */
30 30
31 #include "config.h" 31 #include "config.h"
32 #include "bindings/v8/V8Binding.h" 32 #include "bindings/v8/V8Binding.h"
33 33
34 #include "V8DOMStringList.h"
35 #include "V8Element.h" 34 #include "V8Element.h"
36 #include "V8NodeFilter.h" 35 #include "V8NodeFilter.h"
37 #include "V8Window.h" 36 #include "V8Window.h"
38 #include "V8WorkerGlobalScope.h" 37 #include "V8WorkerGlobalScope.h"
39 #include "V8XPathNSResolver.h" 38 #include "V8XPathNSResolver.h"
40 #include "bindings/v8/ScriptController.h" 39 #include "bindings/v8/ScriptController.h"
41 #include "bindings/v8/V8NodeFilterCondition.h" 40 #include "bindings/v8/V8NodeFilterCondition.h"
42 #include "bindings/v8/V8ObjectConstructor.h" 41 #include "bindings/v8/V8ObjectConstructor.h"
43 #include "bindings/v8/V8WindowShell.h" 42 #include "bindings/v8/V8WindowShell.h"
44 #include "bindings/v8/WorkerScriptController.h" 43 #include "bindings/v8/WorkerScriptController.h"
45 #include "bindings/v8/custom/V8CustomXPathNSResolver.h" 44 #include "bindings/v8/custom/V8CustomXPathNSResolver.h"
46 #include "core/dom/DOMStringList.h"
47 #include "core/dom/Element.h" 45 #include "core/dom/Element.h"
48 #include "core/dom/NodeFilter.h" 46 #include "core/dom/NodeFilter.h"
49 #include "core/dom/QualifiedName.h" 47 #include "core/dom/QualifiedName.h"
50 #include "core/inspector/BindingVisitors.h" 48 #include "core/inspector/BindingVisitors.h"
51 #include "core/loader/FrameLoader.h" 49 #include "core/loader/FrameLoader.h"
52 #include "core/loader/FrameLoaderClient.h" 50 #include "core/loader/FrameLoaderClient.h"
53 #include "core/frame/Frame.h" 51 #include "core/frame/Frame.h"
54 #include "core/page/Settings.h" 52 #include "core/page/Settings.h"
55 #include "core/workers/WorkerGlobalScope.h" 53 #include "core/workers/WorkerGlobalScope.h"
56 #include "core/xml/XPathNSResolver.h" 54 #include "core/xml/XPathNSResolver.h"
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 WTF::ArrayBufferContents::freeMemory(data, size); 115 WTF::ArrayBufferContents::freeMemory(data, size);
118 } 116 }
119 }; 117 };
120 118
121 v8::ArrayBuffer::Allocator* v8ArrayBufferAllocator() 119 v8::ArrayBuffer::Allocator* v8ArrayBufferAllocator()
122 { 120 {
123 DEFINE_STATIC_LOCAL(ArrayBufferAllocator, arrayBufferAllocator, ()); 121 DEFINE_STATIC_LOCAL(ArrayBufferAllocator, arrayBufferAllocator, ());
124 return &arrayBufferAllocator; 122 return &arrayBufferAllocator;
125 } 123 }
126 124
127
128 v8::Handle<v8::Value> v8Array(PassRefPtr<DOMStringList> stringList, v8::Isolate* isolate)
129 {
130 if (!stringList)
131 return v8::Array::New();
132 v8::Local<v8::Array> result = v8::Array::New(stringList->length());
133 for (unsigned i = 0; i < stringList->length(); ++i)
134 result->Set(v8::Integer::New(i, isolate), v8String(stringList->item(i), isolate));
135 return result;
136 }
137
138 Vector<v8::Handle<v8::Value> > toVectorOfArguments(const v8::FunctionCallbackInf o<v8::Value>& info) 125 Vector<v8::Handle<v8::Value> > toVectorOfArguments(const v8::FunctionCallbackInf o<v8::Value>& info)
139 { 126 {
140 Vector<v8::Handle<v8::Value> > result; 127 Vector<v8::Handle<v8::Value> > result;
141 size_t length = info.Length(); 128 size_t length = info.Length();
142 for (size_t i = 0; i < length; ++i) 129 for (size_t i = 0; i < length; ++i)
143 result.append(info[i]); 130 result.append(info[i]);
144 return result; 131 return result;
145 } 132 }
146 133
147 PassRefPtr<NodeFilter> toNodeFilter(v8::Handle<v8::Value> callback, v8::Isolate* isolate) 134 PassRefPtr<NodeFilter> toNodeFilter(v8::Handle<v8::Value> callback, v8::Isolate* isolate)
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after
378 return integer; 365 return integer;
379 } 366 }
380 367
381 v8::Handle<v8::FunctionTemplate> createRawTemplate(v8::Isolate* isolate) 368 v8::Handle<v8::FunctionTemplate> createRawTemplate(v8::Isolate* isolate)
382 { 369 {
383 v8::HandleScope scope(isolate); 370 v8::HandleScope scope(isolate);
384 v8::Local<v8::FunctionTemplate> result = v8::FunctionTemplate::New(V8ObjectC onstructor::isValidConstructorMode); 371 v8::Local<v8::FunctionTemplate> result = v8::FunctionTemplate::New(V8ObjectC onstructor::isValidConstructorMode);
385 return scope.Close(result); 372 return scope.Close(result);
386 } 373 }
387 374
388 PassRefPtr<DOMStringList> toDOMStringList(v8::Handle<v8::Value> value, v8::Isola te* isolate)
389 {
390 v8::Local<v8::Value> v8Value(v8::Local<v8::Value>::New(isolate, value));
391
392 if (V8DOMStringList::HasInstance(v8Value, isolate, worldType(isolate))) {
393 RefPtr<DOMStringList> ret = V8DOMStringList::toNative(v8::Handle<v8::Obj ect>::Cast(v8Value));
394 return ret.release();
395 }
396
397 if (!v8Value->IsArray())
398 return 0;
399
400 RefPtr<DOMStringList> ret = DOMStringList::create();
401 v8::Local<v8::Array> v8Array = v8::Local<v8::Array>::Cast(v8Value);
402 for (size_t i = 0; i < v8Array->Length(); ++i) {
403 v8::Local<v8::Value> indexedValue = v8Array->Get(v8::Integer::New(i, iso late));
404 V8TRYCATCH_FOR_V8STRINGRESOURCE_RETURN(V8StringResource<>, stringValue, indexedValue, 0);
405 ret->append(stringValue);
406 }
407 return ret.release();
408 }
409
410 PassRefPtr<XPathNSResolver> toXPathNSResolver(v8::Handle<v8::Value> value, v8::I solate* isolate) 375 PassRefPtr<XPathNSResolver> toXPathNSResolver(v8::Handle<v8::Value> value, v8::I solate* isolate)
411 { 376 {
412 RefPtr<XPathNSResolver> resolver; 377 RefPtr<XPathNSResolver> resolver;
413 if (V8XPathNSResolver::HasInstance(value, isolate, worldType(isolate))) 378 if (V8XPathNSResolver::HasInstance(value, isolate, worldType(isolate)))
414 resolver = V8XPathNSResolver::toNative(v8::Handle<v8::Object>::Cast(valu e)); 379 resolver = V8XPathNSResolver::toNative(v8::Handle<v8::Object>::Cast(valu e));
415 else if (value->IsObject()) 380 else if (value->IsObject())
416 resolver = V8CustomXPathNSResolver::create(value->ToObject(), isolate); 381 resolver = V8CustomXPathNSResolver::create(value->ToObject(), isolate);
417 return resolver; 382 return resolver;
418 } 383 }
419 384
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after
603 return mainThreadIsolate(); 568 return mainThreadIsolate();
604 return v8::Isolate::GetCurrent(); 569 return v8::Isolate::GetCurrent();
605 } 570 }
606 571
607 v8::Isolate* toIsolate(Frame* frame) 572 v8::Isolate* toIsolate(Frame* frame)
608 { 573 {
609 return frame->script().isolate(); 574 return frame->script().isolate();
610 } 575 }
611 576
612 } // namespace WebCore 577 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/bindings/v8/V8Binding.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698