| OLD | NEW |
| 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 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 133 } | 133 } |
| 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 // TODO(bashi): Use CreateDataProperty() instead of ForceSet(). |
| 144 // http://crbug.com/475206 |
| 143 v8::Local<v8::Value> pixelArray = toV8(m_data.get(), wrapper, isolate); | 145 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))) | 146 if (pixelArray.IsEmpty() || !v8CallBoolean(wrapper->ForceSet(isolate->Ge
tCurrentContext(), v8AtomicString(isolate, "data"), pixelArray, v8::ReadOnly))) |
| 145 return v8::Local<v8::Object>(); | 147 return v8::Local<v8::Object>(); |
| 146 } | 148 } |
| 147 return wrapper; | 149 return wrapper; |
| 148 } | 150 } |
| 149 | 151 |
| 150 ImageData::ImageData(const IntSize& size) | 152 ImageData::ImageData(const IntSize& size) |
| 151 : m_size(size) | 153 : m_size(size) |
| 152 , m_data(DOMUint8ClampedArray::create(size.width() * size.height() * 4)) | 154 , m_data(DOMUint8ClampedArray::create(size.width() * size.height() * 4)) |
| 153 { | 155 { |
| 154 } | 156 } |
| 155 | 157 |
| 156 ImageData::ImageData(const IntSize& size, PassRefPtr<DOMUint8ClampedArray> byteA
rray) | 158 ImageData::ImageData(const IntSize& size, PassRefPtr<DOMUint8ClampedArray> byteA
rray) |
| 157 : m_size(size) | 159 : m_size(size) |
| 158 , m_data(byteArray) | 160 , m_data(byteArray) |
| 159 { | 161 { |
| 160 ASSERT_WITH_SECURITY_IMPLICATION(static_cast<unsigned>(size.width() * size.h
eight() * 4) <= m_data->length()); | 162 ASSERT_WITH_SECURITY_IMPLICATION(static_cast<unsigned>(size.width() * size.h
eight() * 4) <= m_data->length()); |
| 161 } | 163 } |
| 162 | 164 |
| 163 void ImageData::dispose() | 165 void ImageData::dispose() |
| 164 { | 166 { |
| 165 m_data.clear(); | 167 m_data.clear(); |
| 166 } | 168 } |
| 167 | 169 |
| 168 } // namespace blink | 170 } // namespace blink |
| OLD | NEW |