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

Side by Side Diff: Source/web/WebBindings.cpp

Issue 449683002: Blink API to convert v8::Object to WebNode (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 4 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 | public/web/WebBindings.h » ('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 236 matching lines...) Expand 10 before | Expand all | Expand 10 after
247 if (v8Object.IsEmpty()) 247 if (v8Object.IsEmpty())
248 return false; 248 return false;
249 Node* native = V8Node::hasInstance(v8Object, isolate) ? V8Node::toNative(v8O bject) : 0; 249 Node* native = V8Node::hasInstance(v8Object, isolate) ? V8Node::toNative(v8O bject) : 0;
250 if (!native) 250 if (!native)
251 return false; 251 return false;
252 252
253 *webNode = WebNode(native); 253 *webNode = WebNode(native);
254 return true; 254 return true;
255 } 255 }
256 256
257 static bool getNodeFromV8ObjectImpl(v8::Handle<v8::Object> obj, blink::WebNode* node)
258 {
259 if (obj.IsEmpty())
260 return false;
261
262 v8::Isolate* isolate = v8::Isolate::GetCurrent();
263 Element* native = V8Element::hasInstance(obj, isolate) ? V8Element::toNative (obj) : 0;
264 if (!native)
265 return false;
266
267 *node = WebNode(native);
268 return true;
269 }
270
257 static bool getElementImpl(NPObject* object, WebElement* webElement, v8::Isolate * isolate) 271 static bool getElementImpl(NPObject* object, WebElement* webElement, v8::Isolate * isolate)
258 { 272 {
259 if (!object) 273 if (!object)
260 return false; 274 return false;
261 275
262 V8NPObject* v8NPObject = npObjectToV8NPObject(object); 276 V8NPObject* v8NPObject = npObjectToV8NPObject(object);
263 if (!v8NPObject) 277 if (!v8NPObject)
264 return false; 278 return false;
265 279
266 v8::HandleScope handleScope(isolate); 280 v8::HandleScope handleScope(isolate);
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
352 bool WebBindings::getArrayBufferView(NPObject* arrayBufferView, WebArrayBufferVi ew* webArrayBufferView) 366 bool WebBindings::getArrayBufferView(NPObject* arrayBufferView, WebArrayBufferVi ew* webArrayBufferView)
353 { 367 {
354 return getArrayBufferViewImpl(arrayBufferView, webArrayBufferView, v8::Isola te::GetCurrent()); 368 return getArrayBufferViewImpl(arrayBufferView, webArrayBufferView, v8::Isola te::GetCurrent());
355 } 369 }
356 370
357 bool WebBindings::getNode(NPObject* node, WebNode* webNode) 371 bool WebBindings::getNode(NPObject* node, WebNode* webNode)
358 { 372 {
359 return getNodeImpl(node, webNode, v8::Isolate::GetCurrent()); 373 return getNodeImpl(node, webNode, v8::Isolate::GetCurrent());
360 } 374 }
361 375
376 bool WebBindings::getNodeFromV8Object(v8::Handle<v8::Object> obj, WebNode* webNo de)
377 {
378 return getNodeFromV8ObjectImpl(obj, webNode);
379 }
380
362 bool WebBindings::getElement(NPObject* element, WebElement* webElement) 381 bool WebBindings::getElement(NPObject* element, WebElement* webElement)
363 { 382 {
364 return getElementImpl(element, webElement, v8::Isolate::GetCurrent()); 383 return getElementImpl(element, webElement, v8::Isolate::GetCurrent());
365 } 384 }
366 385
367 NPObject* WebBindings::makeIntArray(const WebVector<int>& data) 386 NPObject* WebBindings::makeIntArray(const WebVector<int>& data)
368 { 387 {
369 return makeIntArrayImpl(data, v8::Isolate::GetCurrent()); 388 return makeIntArrayImpl(data, v8::Isolate::GetCurrent());
370 } 389 }
371 390
(...skipping 26 matching lines...) Expand all
398 if (!v8Object) 417 if (!v8Object)
399 return v8::Undefined(isolate); 418 return v8::Undefined(isolate);
400 return convertNPVariantToV8Object(variant, v8Object->rootObject->frame() ->script().windowScriptNPObject(), isolate); 419 return convertNPVariantToV8Object(variant, v8Object->rootObject->frame() ->script().windowScriptNPObject(), isolate);
401 } 420 }
402 // Safe to pass 0 since we have checked the script object class to make sure the 421 // Safe to pass 0 since we have checked the script object class to make sure the
403 // argument is a primitive v8 type. 422 // argument is a primitive v8 type.
404 return convertNPVariantToV8Object(variant, 0, isolate); 423 return convertNPVariantToV8Object(variant, 0, isolate);
405 } 424 }
406 425
407 } // namespace blink 426 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | public/web/WebBindings.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698