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 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
121 exceptionState.throwDOMException(IndexSizeError, "The input data byte le ngth is not equal to (4 * width * height)."); | 121 exceptionState.throwDOMException(IndexSizeError, "The input data byte le ngth is not equal to (4 * width * height)."); |
122 return nullptr; | 122 return nullptr; |
123 } | 123 } |
124 | 124 |
125 return adoptRefWillBeNoop(new ImageData(IntSize(width, height), data)); | 125 return adoptRefWillBeNoop(new ImageData(IntSize(width, height), data)); |
126 } | 126 } |
127 | 127 |
128 v8::Handle<v8::Object> ImageData::wrap(v8::Handle<v8::Object> creationContext, v 8::Isolate* isolate) | 128 v8::Handle<v8::Object> ImageData::wrap(v8::Handle<v8::Object> creationContext, v 8::Isolate* isolate) |
129 { | 129 { |
130 v8::Handle<v8::Object> wrapper = ScriptWrappable::wrap(creationContext, isol ate); | 130 v8::Handle<v8::Object> wrapper = ScriptWrappable::wrap(creationContext, isol ate); |
131 return associateWithWrapperInternal(wrapper, creationContext, isolate); | |
132 } | |
133 | |
134 v8::Handle<v8::Object> ImageData::associateWithWrapper(const WrapperTypeInfo* wr apperType, v8::Handle<v8::Object> wrapper, v8::Isolate* isolate) | |
135 { | |
136 ScriptWrappable::associateWithWrapper(wrapperType, wrapper, isolate); | |
137 return associateWithWrapperInternal(wrapper, wrapper, isolate); | |
haraken
2014/09/05 16:41:39
Ditto. I guess associateWithWrapperInternal should
Yuki
2014/09/08 07:56:05
Done.
| |
138 } | |
139 | |
140 v8::Handle<v8::Object> ImageData::associateWithWrapperInternal(v8::Handle<v8::Ob ject> wrapper, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate) | |
141 { | |
131 if (!wrapper.IsEmpty()) { | 142 if (!wrapper.IsEmpty()) { |
132 // Create a V8 Uint8ClampedArray object. | 143 // Create a V8 Uint8ClampedArray object. |
133 v8::Handle<v8::Value> pixelArray = toV8(data(), creationContext, isolate ); | 144 v8::Handle<v8::Value> pixelArray = toV8(data(), creationContext, isolate ); |
134 // Set the "data" property of the ImageData object to | 145 // Set the "data" property of the ImageData object to |
135 // the created v8 object, eliminating the C++ callback | 146 // the created v8 object, eliminating the C++ callback |
136 // when accessing the "data" property. | 147 // when accessing the "data" property. |
137 if (!pixelArray.IsEmpty()) | 148 if (!pixelArray.IsEmpty()) |
138 wrapper->ForceSet(v8AtomicString(isolate, "data"), pixelArray, v8::R eadOnly); | 149 wrapper->ForceSet(v8AtomicString(isolate, "data"), pixelArray, v8::R eadOnly); |
139 } | 150 } |
140 return wrapper; | 151 return wrapper; |
141 } | 152 } |
142 | 153 |
143 ImageData::ImageData(const IntSize& size) | 154 ImageData::ImageData(const IntSize& size) |
144 : m_size(size) | 155 : m_size(size) |
145 , m_data(Uint8ClampedArray::create(size.width() * size.height() * 4)) | 156 , m_data(Uint8ClampedArray::create(size.width() * size.height() * 4)) |
146 { | 157 { |
147 ScriptWrappable::init(this); | 158 ScriptWrappable::init(this); |
148 } | 159 } |
149 | 160 |
150 ImageData::ImageData(const IntSize& size, PassRefPtr<Uint8ClampedArray> byteArra y) | 161 ImageData::ImageData(const IntSize& size, PassRefPtr<Uint8ClampedArray> byteArra y) |
151 : m_size(size) | 162 : m_size(size) |
152 , m_data(byteArray) | 163 , m_data(byteArray) |
153 { | 164 { |
154 ASSERT_WITH_SECURITY_IMPLICATION(static_cast<unsigned>(size.width() * size.h eight() * 4) <= m_data->length()); | 165 ASSERT_WITH_SECURITY_IMPLICATION(static_cast<unsigned>(size.width() * size.h eight() * 4) <= m_data->length()); |
155 ScriptWrappable::init(this); | 166 ScriptWrappable::init(this); |
156 } | 167 } |
157 | 168 |
158 } | 169 } |
OLD | NEW |