| 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 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 149 ScriptPromise ImageData::createImageBitmap(ScriptState* scriptState, EventTarget
& eventTarget, int sx, int sy, int sw, int sh, const ImageBitmapOptions& options
, ExceptionState& exceptionState) | 149 ScriptPromise ImageData::createImageBitmap(ScriptState* scriptState, EventTarget
& eventTarget, int sx, int sy, int sw, int sh, const ImageBitmapOptions& options
, ExceptionState& exceptionState) |
| 150 { | 150 { |
| 151 if (!sw || !sh) { | 151 if (!sw || !sh) { |
| 152 exceptionState.throwDOMException(IndexSizeError, String::format("The sou
rce %s provided is 0.", sw ? "height" : "width")); | 152 exceptionState.throwDOMException(IndexSizeError, String::format("The sou
rce %s provided is 0.", sw ? "height" : "width")); |
| 153 return ScriptPromise(); | 153 return ScriptPromise(); |
| 154 } | 154 } |
| 155 if (data()->bufferBase()->isNeutered()) { | 155 if (data()->bufferBase()->isNeutered()) { |
| 156 exceptionState.throwDOMException(InvalidStateError, "The source data has
been neutered."); | 156 exceptionState.throwDOMException(InvalidStateError, "The source data has
been neutered."); |
| 157 return ScriptPromise(); | 157 return ScriptPromise(); |
| 158 } | 158 } |
| 159 if ((options.hasResizeWidth() && options.resizeWidth() <= 0) || (options.has
ResizeHeight() && options.resizeHeight() <= 0)) { |
| 160 exceptionState.throwDOMException(InvalidStateError, "The resizeWidth or/
and resizeHeight is less than or equals to 0."); |
| 161 return ScriptPromise(); |
| 162 } |
| 159 return ImageBitmapSource::fulfillImageBitmap(scriptState, ImageBitmap::creat
e(this, IntRect(sx, sy, sw, sh), options)); | 163 return ImageBitmapSource::fulfillImageBitmap(scriptState, ImageBitmap::creat
e(this, IntRect(sx, sy, sw, sh), options)); |
| 160 } | 164 } |
| 161 | 165 |
| 162 v8::Local<v8::Object> ImageData::associateWithWrapper(v8::Isolate* isolate, cons
t WrapperTypeInfo* wrapperType, v8::Local<v8::Object> wrapper) | 166 v8::Local<v8::Object> ImageData::associateWithWrapper(v8::Isolate* isolate, cons
t WrapperTypeInfo* wrapperType, v8::Local<v8::Object> wrapper) |
| 163 { | 167 { |
| 164 wrapper = ScriptWrappable::associateWithWrapper(isolate, wrapperType, wrappe
r); | 168 wrapper = ScriptWrappable::associateWithWrapper(isolate, wrapperType, wrappe
r); |
| 165 | 169 |
| 166 if (!wrapper.IsEmpty() && m_data.get()) { | 170 if (!wrapper.IsEmpty() && m_data.get()) { |
| 167 // Create a V8 Uint8ClampedArray object and set the "data" property | 171 // Create a V8 Uint8ClampedArray object and set the "data" property |
| 168 // of the ImageData object to the created v8 object, eliminating the | 172 // of the ImageData object to the created v8 object, eliminating the |
| 169 // C++ callback when accessing the "data" property. | 173 // C++ callback when accessing the "data" property. |
| 170 v8::Local<v8::Value> pixelArray = toV8(m_data.get(), wrapper, isolate); | 174 v8::Local<v8::Value> pixelArray = toV8(m_data.get(), wrapper, isolate); |
| 171 if (pixelArray.IsEmpty() || !v8CallBoolean(wrapper->DefineOwnProperty(is
olate->GetCurrentContext(), v8AtomicString(isolate, "data"), pixelArray, v8::Rea
dOnly))) | 175 if (pixelArray.IsEmpty() || !v8CallBoolean(wrapper->DefineOwnProperty(is
olate->GetCurrentContext(), v8AtomicString(isolate, "data"), pixelArray, v8::Rea
dOnly))) |
| 172 return v8::Local<v8::Object>(); | 176 return v8::Local<v8::Object>(); |
| 173 } | 177 } |
| 174 return wrapper; | 178 return wrapper; |
| 175 } | 179 } |
| 176 | 180 |
| 177 ImageData::ImageData(const IntSize& size, DOMUint8ClampedArray* byteArray) | 181 ImageData::ImageData(const IntSize& size, DOMUint8ClampedArray* byteArray) |
| 178 : m_size(size) | 182 : m_size(size) |
| 179 , m_data(byteArray) | 183 , m_data(byteArray) |
| 180 { | 184 { |
| 181 ASSERT(size.width() >= 0 && size.height() >= 0); | 185 ASSERT(size.width() >= 0 && size.height() >= 0); |
| 182 ASSERT_WITH_SECURITY_IMPLICATION(static_cast<unsigned>(size.width() * size.h
eight() * 4) <= m_data->length()); | 186 ASSERT_WITH_SECURITY_IMPLICATION(static_cast<unsigned>(size.width() * size.h
eight() * 4) <= m_data->length()); |
| 183 } | 187 } |
| 184 | 188 |
| 185 } // namespace blink | 189 } // namespace blink |
| OLD | NEW |