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

Unified Diff: Source/core/html/ImageData.cpp

Issue 478243002: bindings: Adds virtual ScriptWrappable::wrap method. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Synced. Created 6 years, 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/core/html/ImageData.h ('k') | Source/core/html/MediaController.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/html/ImageData.cpp
diff --git a/Source/core/html/ImageData.cpp b/Source/core/html/ImageData.cpp
index a1f8e2e5fa936dd2c183dfa65c01ec0a738eb079..47210e9334dfc11919cc6f91dbc233b93d299402 100644
--- a/Source/core/html/ImageData.cpp
+++ b/Source/core/html/ImageData.cpp
@@ -30,6 +30,7 @@
#include "core/html/ImageData.h"
#include "bindings/core/v8/ExceptionState.h"
+#include "bindings/core/v8/custom/V8Uint8ClampedArrayCustom.h"
#include "core/dom/ExceptionCode.h"
#include "platform/RuntimeEnabledFeatures.h"
@@ -124,6 +125,21 @@ PassRefPtrWillBeRawPtr<ImageData> ImageData::create(Uint8ClampedArray* data, uns
return adoptRefWillBeNoop(new ImageData(IntSize(width, height), data));
}
+v8::Handle<v8::Object> ImageData::wrap(v8::Handle<v8::Object> creationContext, v8::Isolate* isolate)
+{
+ v8::Handle<v8::Object> wrapper = ScriptWrappable::wrap(creationContext, isolate);
+ if (!wrapper.IsEmpty()) {
+ // Create a V8 Uint8ClampedArray object.
+ v8::Handle<v8::Value> pixelArray = toV8(data(), creationContext, isolate);
+ // Set the "data" property of the ImageData object to
+ // the created v8 object, eliminating the C++ callback
+ // when accessing the "data" property.
+ if (!pixelArray.IsEmpty())
+ wrapper->ForceSet(v8AtomicString(isolate, "data"), pixelArray, v8::ReadOnly);
+ }
+ return wrapper;
+}
+
ImageData::ImageData(const IntSize& size)
: m_size(size)
, m_data(Uint8ClampedArray::create(size.width() * size.height() * 4))
@@ -140,4 +156,3 @@ ImageData::ImageData(const IntSize& size, PassRefPtr<Uint8ClampedArray> byteArra
}
}
-
« no previous file with comments | « Source/core/html/ImageData.h ('k') | Source/core/html/MediaController.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698