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

Side by Side Diff: Source/core/html/ImageData.cpp

Issue 1153613007: bindings: Use CreateDataProperty() instead of ForceSet() (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Fix uninitialized error Created 5 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
« no previous file with comments | « Source/bindings/tests/results/modules/V8TestInterfacePartial.cpp ('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) 2008 Apple Inc. All rights reserved. 2 * Copyright (C) 2008 Apple 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 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 7 *
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. 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 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
134 134
135 v8::Local<v8::Object> ImageData::associateWithWrapper(v8::Isolate* isolate, cons t WrapperTypeInfo* wrapperType, v8::Local<v8::Object> wrapper) 135 v8::Local<v8::Object> ImageData::associateWithWrapper(v8::Isolate* isolate, cons t WrapperTypeInfo* wrapperType, v8::Local<v8::Object> wrapper)
136 { 136 {
137 ScriptWrappable::associateWithWrapper(isolate, wrapperType, wrapper); 137 ScriptWrappable::associateWithWrapper(isolate, wrapperType, wrapper);
138 138
139 if (!wrapper.IsEmpty() && m_data.get()) { 139 if (!wrapper.IsEmpty() && m_data.get()) {
140 // Create a V8 Uint8ClampedArray object and set the "data" property 140 // Create a V8 Uint8ClampedArray object and set the "data" property
141 // of the ImageData object to the created v8 object, eliminating the 141 // of the ImageData object to the created v8 object, eliminating the
142 // C++ callback when accessing the "data" property. 142 // C++ callback when accessing the "data" property.
143 v8::Local<v8::Value> pixelArray = toV8(m_data.get(), wrapper, isolate); 143 v8::Local<v8::Value> pixelArray = toV8(m_data.get(), wrapper, isolate);
144 if (pixelArray.IsEmpty() || !v8CallBoolean(wrapper->ForceSet(isolate->Ge tCurrentContext(), v8AtomicString(isolate, "data"), pixelArray, v8::ReadOnly))) 144 if (pixelArray.IsEmpty() || !v8CallBoolean(wrapper->DefineOwnProperty(is olate->GetCurrentContext(), v8AtomicString(isolate, "data"), pixelArray, v8::Rea dOnly)))
145 return v8::Local<v8::Object>(); 145 return v8::Local<v8::Object>();
146 } 146 }
147 return wrapper; 147 return wrapper;
148 } 148 }
149 149
150 ImageData::ImageData(const IntSize& size) 150 ImageData::ImageData(const IntSize& size)
151 : m_size(size) 151 : m_size(size)
152 , m_data(DOMUint8ClampedArray::create(size.width() * size.height() * 4)) 152 , m_data(DOMUint8ClampedArray::create(size.width() * size.height() * 4))
153 { 153 {
154 } 154 }
155 155
156 ImageData::ImageData(const IntSize& size, PassRefPtr<DOMUint8ClampedArray> byteA rray) 156 ImageData::ImageData(const IntSize& size, PassRefPtr<DOMUint8ClampedArray> byteA rray)
157 : m_size(size) 157 : m_size(size)
158 , m_data(byteArray) 158 , m_data(byteArray)
159 { 159 {
160 ASSERT_WITH_SECURITY_IMPLICATION(static_cast<unsigned>(size.width() * size.h eight() * 4) <= m_data->length()); 160 ASSERT_WITH_SECURITY_IMPLICATION(static_cast<unsigned>(size.width() * size.h eight() * 4) <= m_data->length());
161 } 161 }
162 162
163 void ImageData::dispose() 163 void ImageData::dispose()
164 { 164 {
165 m_data.clear(); 165 m_data.clear();
166 } 166 }
167 167
168 } // namespace blink 168 } // namespace blink
OLDNEW
« no previous file with comments | « Source/bindings/tests/results/modules/V8TestInterfacePartial.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698