OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2013, Google Inc. All rights reserved. | 2 * Copyright (c) 2013, Google 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 are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * 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 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
76 LayoutSize s = sizeFor(image); | 76 LayoutSize s = sizeFor(image); |
77 return createImageBitmap(eventTarget, image, 0, 0, s.width(), s.height(), ex
ceptionState); | 77 return createImageBitmap(eventTarget, image, 0, 0, s.width(), s.height(), ex
ceptionState); |
78 } | 78 } |
79 | 79 |
80 ScriptPromise ImageBitmapFactories::createImageBitmap(EventTarget* eventTarget,
HTMLImageElement* image, int sx, int sy, int sw, int sh, ExceptionState& excepti
onState) | 80 ScriptPromise ImageBitmapFactories::createImageBitmap(EventTarget* eventTarget,
HTMLImageElement* image, int sx, int sy, int sw, int sh, ExceptionState& excepti
onState) |
81 { | 81 { |
82 // This variant does not work in worker threads. | 82 // This variant does not work in worker threads. |
83 ASSERT(eventTarget->toDOMWindow()); | 83 ASSERT(eventTarget->toDOMWindow()); |
84 | 84 |
85 if (!image) { | 85 if (!image) { |
86 exceptionState.throwUninformativeAndGenericTypeError(); | 86 exceptionState.throwTypeError("The image element provided is invalid."); |
87 return ScriptPromise(); | 87 return ScriptPromise(); |
88 } | 88 } |
89 if (!image->cachedImage()) { | 89 if (!image->cachedImage()) { |
90 exceptionState.throwUninformativeAndGenericDOMException(InvalidStateErro
r); | 90 exceptionState.throwUninformativeAndGenericDOMException(InvalidStateErro
r); |
91 return ScriptPromise(); | 91 return ScriptPromise(); |
92 } | 92 } |
93 if (image->cachedImage()->image()->isSVGImage()) { | 93 if (image->cachedImage()->image()->isSVGImage()) { |
94 exceptionState.throwUninformativeAndGenericDOMException(InvalidStateErro
r); | 94 exceptionState.throwUninformativeAndGenericDOMException(InvalidStateErro
r); |
95 return ScriptPromise(); | 95 return ScriptPromise(); |
96 } | 96 } |
(...skipping 19 matching lines...) Expand all Loading... |
116 IntSize s = sizeFor(video); | 116 IntSize s = sizeFor(video); |
117 return createImageBitmap(eventTarget, video, 0, 0, s.width(), s.height(), ex
ceptionState); | 117 return createImageBitmap(eventTarget, video, 0, 0, s.width(), s.height(), ex
ceptionState); |
118 } | 118 } |
119 | 119 |
120 ScriptPromise ImageBitmapFactories::createImageBitmap(EventTarget* eventTarget,
HTMLVideoElement* video, int sx, int sy, int sw, int sh, ExceptionState& excepti
onState) | 120 ScriptPromise ImageBitmapFactories::createImageBitmap(EventTarget* eventTarget,
HTMLVideoElement* video, int sx, int sy, int sw, int sh, ExceptionState& excepti
onState) |
121 { | 121 { |
122 // This variant does not work in worker threads. | 122 // This variant does not work in worker threads. |
123 ASSERT(eventTarget->toDOMWindow()); | 123 ASSERT(eventTarget->toDOMWindow()); |
124 | 124 |
125 if (!video) { | 125 if (!video) { |
126 exceptionState.throwUninformativeAndGenericTypeError(); | 126 exceptionState.throwTypeError("The video element provided is invalid."); |
127 return ScriptPromise(); | 127 return ScriptPromise(); |
128 } | 128 } |
129 if (!video->player()) { | 129 if (!video->player()) { |
130 exceptionState.throwUninformativeAndGenericDOMException(InvalidStateErro
r); | 130 exceptionState.throwUninformativeAndGenericDOMException(InvalidStateErro
r); |
131 return ScriptPromise(); | 131 return ScriptPromise(); |
132 } | 132 } |
133 if (video->networkState() == HTMLMediaElement::NETWORK_EMPTY) { | 133 if (video->networkState() == HTMLMediaElement::NETWORK_EMPTY) { |
134 exceptionState.throwUninformativeAndGenericDOMException(InvalidStateErro
r); | 134 exceptionState.throwUninformativeAndGenericDOMException(InvalidStateErro
r); |
135 return ScriptPromise(); | 135 return ScriptPromise(); |
136 } | 136 } |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
168 { | 168 { |
169 return createImageBitmap(eventTarget, canvas, 0, 0, canvas->width(), canvas-
>height(), exceptionState); | 169 return createImageBitmap(eventTarget, canvas, 0, 0, canvas->width(), canvas-
>height(), exceptionState); |
170 } | 170 } |
171 | 171 |
172 ScriptPromise ImageBitmapFactories::createImageBitmap(EventTarget* eventTarget,
HTMLCanvasElement* canvas, int sx, int sy, int sw, int sh, ExceptionState& excep
tionState) | 172 ScriptPromise ImageBitmapFactories::createImageBitmap(EventTarget* eventTarget,
HTMLCanvasElement* canvas, int sx, int sy, int sw, int sh, ExceptionState& excep
tionState) |
173 { | 173 { |
174 // This variant does not work in worker threads. | 174 // This variant does not work in worker threads. |
175 ASSERT(eventTarget->toDOMWindow()); | 175 ASSERT(eventTarget->toDOMWindow()); |
176 | 176 |
177 if (!canvas) { | 177 if (!canvas) { |
178 exceptionState.throwUninformativeAndGenericTypeError(); | 178 exceptionState.throwTypeError("The canvas element provided is invalid.")
; |
179 return ScriptPromise(); | 179 return ScriptPromise(); |
180 } | 180 } |
181 if (!canvas->originClean()) { | 181 if (!canvas->originClean()) { |
182 exceptionState.throwUninformativeAndGenericDOMException(InvalidStateErro
r); | 182 exceptionState.throwUninformativeAndGenericDOMException(InvalidStateErro
r); |
183 return ScriptPromise(); | 183 return ScriptPromise(); |
184 } | 184 } |
185 if (!sw || !sh) { | 185 if (!sw || !sh) { |
186 exceptionState.throwUninformativeAndGenericDOMException(IndexSizeError); | 186 exceptionState.throwUninformativeAndGenericDOMException(IndexSizeError); |
187 return ScriptPromise(); | 187 return ScriptPromise(); |
188 } | 188 } |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
223 } | 223 } |
224 | 224 |
225 ScriptPromise ImageBitmapFactories::createImageBitmap(EventTarget* eventTarget,
ImageData* data, ExceptionState& exceptionState) | 225 ScriptPromise ImageBitmapFactories::createImageBitmap(EventTarget* eventTarget,
ImageData* data, ExceptionState& exceptionState) |
226 { | 226 { |
227 return createImageBitmap(eventTarget, data, 0, 0, data->width(), data->heigh
t(), exceptionState); | 227 return createImageBitmap(eventTarget, data, 0, 0, data->width(), data->heigh
t(), exceptionState); |
228 } | 228 } |
229 | 229 |
230 ScriptPromise ImageBitmapFactories::createImageBitmap(EventTarget* eventTarget,
ImageData* data, int sx, int sy, int sw, int sh, ExceptionState& exceptionState) | 230 ScriptPromise ImageBitmapFactories::createImageBitmap(EventTarget* eventTarget,
ImageData* data, int sx, int sy, int sw, int sh, ExceptionState& exceptionState) |
231 { | 231 { |
232 if (!data) { | 232 if (!data) { |
233 exceptionState.throwUninformativeAndGenericTypeError(); | 233 exceptionState.throwTypeError("The ImageData provided is invalid."); |
234 return ScriptPromise(); | 234 return ScriptPromise(); |
235 } | 235 } |
236 if (!sw || !sh) { | 236 if (!sw || !sh) { |
237 exceptionState.throwUninformativeAndGenericDOMException(IndexSizeError); | 237 exceptionState.throwUninformativeAndGenericDOMException(IndexSizeError); |
238 return ScriptPromise(); | 238 return ScriptPromise(); |
239 } | 239 } |
240 // FIXME: make ImageBitmap creation asynchronous crbug.com/258082 | 240 // FIXME: make ImageBitmap creation asynchronous crbug.com/258082 |
241 return fulfillImageBitmap(eventTarget->executionContext(), ImageBitmap::crea
te(data, IntRect(sx, sy, sw, sh))); | 241 return fulfillImageBitmap(eventTarget->executionContext(), ImageBitmap::crea
te(data, IntRect(sx, sy, sw, sh))); |
242 } | 242 } |
243 | 243 |
244 ScriptPromise ImageBitmapFactories::createImageBitmap(EventTarget* eventTarget,
ImageBitmap* bitmap, ExceptionState& exceptionState) | 244 ScriptPromise ImageBitmapFactories::createImageBitmap(EventTarget* eventTarget,
ImageBitmap* bitmap, ExceptionState& exceptionState) |
245 { | 245 { |
246 return createImageBitmap(eventTarget, bitmap, 0, 0, bitmap->width(), bitmap-
>height(), exceptionState); | 246 return createImageBitmap(eventTarget, bitmap, 0, 0, bitmap->width(), bitmap-
>height(), exceptionState); |
247 } | 247 } |
248 | 248 |
249 ScriptPromise ImageBitmapFactories::createImageBitmap(EventTarget* eventTarget,
ImageBitmap* bitmap, int sx, int sy, int sw, int sh, ExceptionState& exceptionSt
ate) | 249 ScriptPromise ImageBitmapFactories::createImageBitmap(EventTarget* eventTarget,
ImageBitmap* bitmap, int sx, int sy, int sw, int sh, ExceptionState& exceptionSt
ate) |
250 { | 250 { |
251 if (!bitmap) { | 251 if (!bitmap) { |
252 exceptionState.throwUninformativeAndGenericTypeError(); | 252 exceptionState.throwTypeError("The ImageBitmap provided is invalid."); |
253 return ScriptPromise(); | 253 return ScriptPromise(); |
254 } | 254 } |
255 if (!sw || !sh) { | 255 if (!sw || !sh) { |
256 exceptionState.throwUninformativeAndGenericDOMException(IndexSizeError); | 256 exceptionState.throwUninformativeAndGenericDOMException(IndexSizeError); |
257 return ScriptPromise(); | 257 return ScriptPromise(); |
258 } | 258 } |
259 // FIXME: make ImageBitmap creation asynchronous crbug.com/258082 | 259 // FIXME: make ImageBitmap creation asynchronous crbug.com/258082 |
260 return fulfillImageBitmap(eventTarget->executionContext(), ImageBitmap::crea
te(bitmap, IntRect(sx, sy, sw, sh))); | 260 return fulfillImageBitmap(eventTarget->executionContext(), ImageBitmap::crea
te(bitmap, IntRect(sx, sy, sw, sh))); |
261 } | 261 } |
262 | 262 |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
349 m_resolver->resolve(imageBitmap.release()); | 349 m_resolver->resolve(imageBitmap.release()); |
350 m_factory->didFinishLoading(this); | 350 m_factory->didFinishLoading(this); |
351 } | 351 } |
352 | 352 |
353 void ImageBitmapFactories::ImageBitmapLoader::didFail(FileError::ErrorCode) | 353 void ImageBitmapFactories::ImageBitmapLoader::didFail(FileError::ErrorCode) |
354 { | 354 { |
355 rejectPromise(); | 355 rejectPromise(); |
356 } | 356 } |
357 | 357 |
358 } // namespace WebCore | 358 } // namespace WebCore |
OLD | NEW |