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

Side by Side Diff: Source/WebKit/chromium/src/WebBindings.cpp

Issue 15806014: Reduce usage of WebString::data (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 7 years, 6 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | Source/WebKit/chromium/src/WorkerFileSystemCallbacksBridge.cpp » ('j') | 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) 2009 Google Inc. All rights reserved. 2 * Copyright (C) 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 271 matching lines...) Expand 10 before | Expand all | Expand 10 after
282 v8::Handle<v8::Array> result = v8::Array::New(data.size()); 282 v8::Handle<v8::Array> result = v8::Array::New(data.size());
283 for (size_t i = 0; i < data.size(); ++i) 283 for (size_t i = 0; i < data.size(); ++i)
284 result->Set(i, v8::Number::New(data[i])); 284 result->Set(i, v8::Number::New(data[i]));
285 285
286 DOMWindow* window = toDOMWindow(v8::Context::GetCurrent()); 286 DOMWindow* window = toDOMWindow(v8::Context::GetCurrent());
287 return npCreateV8ScriptObject(0, result, window); 287 return npCreateV8ScriptObject(0, result, window);
288 } 288 }
289 289
290 static NPObject* makeStringArrayImpl(const WebVector<WebString>& data) 290 static NPObject* makeStringArrayImpl(const WebVector<WebString>& data)
291 { 291 {
292 v8::Isolate* isolate = v8::Isolate::GetCurrent();
292 v8::HandleScope handleScope; 293 v8::HandleScope handleScope;
293 v8::Handle<v8::Array> result = v8::Array::New(data.size()); 294 v8::Handle<v8::Array> result = v8::Array::New(data.size());
294 for (size_t i = 0; i < data.size(); ++i) 295 for (size_t i = 0; i < data.size(); ++i)
295 result->Set(i, data[i].data() ? v8::String::New(reinterpret_cast<const u int16_t*>((data[i].data())), data[i].length()) : v8::String::New("")); 296 result->Set(i, v8String(data[i], isolate));
296 297
297 DOMWindow* window = toDOMWindow(v8::Context::GetCurrent()); 298 DOMWindow* window = toDOMWindow(v8::Context::GetCurrent());
298 return npCreateV8ScriptObject(0, result, window); 299 return npCreateV8ScriptObject(0, result, window);
299 } 300 }
300 301
301 bool WebBindings::getRange(NPObject* range, WebRange* webRange) 302 bool WebBindings::getRange(NPObject* range, WebRange* webRange)
302 { 303 {
303 return getRangeImpl(range, webRange, v8::Isolate::GetCurrent()); 304 return getRangeImpl(range, webRange, v8::Isolate::GetCurrent());
304 } 305 }
305 306
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
357 return v8::Undefined(); 358 return v8::Undefined();
358 V8NPObject* v8Object = reinterpret_cast<V8NPObject*>(object); 359 V8NPObject* v8Object = reinterpret_cast<V8NPObject*>(object);
359 return convertNPVariantToV8Object(variant, v8Object->rootObject->frame() ->script()->windowScriptNPObject(), isolate); 360 return convertNPVariantToV8Object(variant, v8Object->rootObject->frame() ->script()->windowScriptNPObject(), isolate);
360 } 361 }
361 // Safe to pass 0 since we have checked the script object class to make sure the 362 // Safe to pass 0 since we have checked the script object class to make sure the
362 // argument is a primitive v8 type. 363 // argument is a primitive v8 type.
363 return convertNPVariantToV8Object(variant, 0, isolate); 364 return convertNPVariantToV8Object(variant, 0, isolate);
364 } 365 }
365 366
366 } // namespace WebKit 367 } // namespace WebKit
OLDNEW
« no previous file with comments | « no previous file | Source/WebKit/chromium/src/WorkerFileSystemCallbacksBridge.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698