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

Side by Side Diff: Source/modules/imagebitmap/ImageBitmapFactories.cpp

Issue 24469004: Amusingly deprecate the generic version of 'ExceptionState::throwDOMException'. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 7 years, 2 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 | Annotate | Revision Log
« no previous file with comments | « Source/modules/filesystem/DOMFileSystemSync.cpp ('k') | Source/modules/indexeddb/IDBCursor.cpp » ('j') | 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) 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 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 ScriptPromise ImageBitmapFactories::createImageBitmap(EventTarget* eventTarget, HTMLImageElement* image, int sx, int sy, int sw, int sh, ExceptionState& es) 83 ScriptPromise ImageBitmapFactories::createImageBitmap(EventTarget* eventTarget, HTMLImageElement* image, int sx, int sy, int sw, int sh, ExceptionState& es)
84 { 84 {
85 // This variant does not work in worker threads. 85 // This variant does not work in worker threads.
86 ASSERT(eventTarget->toDOMWindow()); 86 ASSERT(eventTarget->toDOMWindow());
87 87
88 if (!image) { 88 if (!image) {
89 es.throwTypeError(); 89 es.throwTypeError();
90 return ScriptPromise(); 90 return ScriptPromise();
91 } 91 }
92 if (!image->cachedImage()) { 92 if (!image->cachedImage()) {
93 es.throwDOMException(InvalidStateError); 93 es.throwUninformativeAndGenericDOMException(InvalidStateError);
94 return ScriptPromise(); 94 return ScriptPromise();
95 } 95 }
96 if (image->cachedImage()->image()->isSVGImage()) { 96 if (image->cachedImage()->image()->isSVGImage()) {
97 es.throwDOMException(InvalidStateError); 97 es.throwUninformativeAndGenericDOMException(InvalidStateError);
98 return ScriptPromise(); 98 return ScriptPromise();
99 } 99 }
100 if (!sw || !sh) { 100 if (!sw || !sh) {
101 es.throwDOMException(IndexSizeError); 101 es.throwUninformativeAndGenericDOMException(IndexSizeError);
102 return ScriptPromise(); 102 return ScriptPromise();
103 } 103 }
104 if (!image->cachedImage()->image()->currentFrameHasSingleSecurityOrigin()) { 104 if (!image->cachedImage()->image()->currentFrameHasSingleSecurityOrigin()) {
105 es.throwSecurityError(ExceptionMessages::failedToExecute("createImageBit map", "ImageBitmapFactories", "the source image contains cross-origin image data .")); 105 es.throwSecurityError(ExceptionMessages::failedToExecute("createImageBit map", "ImageBitmapFactories", "the source image contains cross-origin image data ."));
106 return ScriptPromise(); 106 return ScriptPromise();
107 } 107 }
108 if (!image->cachedImage()->passesAccessControlCheck(eventTarget->toDOMWindow ()->document()->securityOrigin()) 108 if (!image->cachedImage()->passesAccessControlCheck(eventTarget->toDOMWindow ()->document()->securityOrigin())
109 && eventTarget->toDOMWindow()->document()->securityOrigin()->taintsCanvas(im age->src())) { 109 && eventTarget->toDOMWindow()->document()->securityOrigin()->taintsCanvas(im age->src())) {
110 es.throwSecurityError(ExceptionMessages::failedToExecute("createImageBit map", "ImageBitmapFactories", "cross-origin access to the source image is denied .")); 110 es.throwSecurityError(ExceptionMessages::failedToExecute("createImageBit map", "ImageBitmapFactories", "cross-origin access to the source image is denied ."));
111 return ScriptPromise(); 111 return ScriptPromise();
(...skipping 11 matching lines...) Expand all
123 ScriptPromise ImageBitmapFactories::createImageBitmap(EventTarget* eventTarget, HTMLVideoElement* video, int sx, int sy, int sw, int sh, ExceptionState& es) 123 ScriptPromise ImageBitmapFactories::createImageBitmap(EventTarget* eventTarget, HTMLVideoElement* video, int sx, int sy, int sw, int sh, ExceptionState& es)
124 { 124 {
125 // This variant does not work in worker threads. 125 // This variant does not work in worker threads.
126 ASSERT(eventTarget->toDOMWindow()); 126 ASSERT(eventTarget->toDOMWindow());
127 127
128 if (!video) { 128 if (!video) {
129 es.throwTypeError(); 129 es.throwTypeError();
130 return ScriptPromise(); 130 return ScriptPromise();
131 } 131 }
132 if (!video->player()) { 132 if (!video->player()) {
133 es.throwDOMException(InvalidStateError); 133 es.throwUninformativeAndGenericDOMException(InvalidStateError);
134 return ScriptPromise(); 134 return ScriptPromise();
135 } 135 }
136 if (video->networkState() == HTMLMediaElement::NETWORK_EMPTY) { 136 if (video->networkState() == HTMLMediaElement::NETWORK_EMPTY) {
137 es.throwDOMException(InvalidStateError); 137 es.throwUninformativeAndGenericDOMException(InvalidStateError);
138 return ScriptPromise(); 138 return ScriptPromise();
139 } 139 }
140 if (video->player()->readyState() <= MediaPlayer::HaveMetadata) { 140 if (video->player()->readyState() <= MediaPlayer::HaveMetadata) {
141 es.throwDOMException(InvalidStateError); 141 es.throwUninformativeAndGenericDOMException(InvalidStateError);
142 return ScriptPromise(); 142 return ScriptPromise();
143 } 143 }
144 if (!sw || !sh) { 144 if (!sw || !sh) {
145 es.throwDOMException(IndexSizeError); 145 es.throwUninformativeAndGenericDOMException(IndexSizeError);
146 return ScriptPromise(); 146 return ScriptPromise();
147 } 147 }
148 if (!video->hasSingleSecurityOrigin()) { 148 if (!video->hasSingleSecurityOrigin()) {
149 es.throwSecurityError(ExceptionMessages::failedToExecute("createImageBit map", "ImageBitmapFactories", "the source video contains cross-origin image data .")); 149 es.throwSecurityError(ExceptionMessages::failedToExecute("createImageBit map", "ImageBitmapFactories", "the source video contains cross-origin image data ."));
150 return ScriptPromise(); 150 return ScriptPromise();
151 } 151 }
152 if (!video->player()->didPassCORSAccessCheck() && eventTarget->toDOMWindow() ->document()->securityOrigin()->taintsCanvas(video->currentSrc())) { 152 if (!video->player()->didPassCORSAccessCheck() && eventTarget->toDOMWindow() ->document()->securityOrigin()->taintsCanvas(video->currentSrc())) {
153 es.throwSecurityError(ExceptionMessages::failedToExecute("createImageBit map", "ImageBitmapFactories", "cross-origin access to the source video is denied .")); 153 es.throwSecurityError(ExceptionMessages::failedToExecute("createImageBit map", "ImageBitmapFactories", "cross-origin access to the source video is denied ."));
154 return ScriptPromise(); 154 return ScriptPromise();
155 } 155 }
(...skipping 19 matching lines...) Expand all
175 ScriptPromise ImageBitmapFactories::createImageBitmap(EventTarget* eventTarget, HTMLCanvasElement* canvas, int sx, int sy, int sw, int sh, ExceptionState& es) 175 ScriptPromise ImageBitmapFactories::createImageBitmap(EventTarget* eventTarget, HTMLCanvasElement* canvas, int sx, int sy, int sw, int sh, ExceptionState& es)
176 { 176 {
177 // This variant does not work in worker threads. 177 // This variant does not work in worker threads.
178 ASSERT(eventTarget->toDOMWindow()); 178 ASSERT(eventTarget->toDOMWindow());
179 179
180 if (!canvas) { 180 if (!canvas) {
181 es.throwTypeError(); 181 es.throwTypeError();
182 return ScriptPromise(); 182 return ScriptPromise();
183 } 183 }
184 if (!canvas->originClean()) { 184 if (!canvas->originClean()) {
185 es.throwDOMException(InvalidStateError); 185 es.throwUninformativeAndGenericDOMException(InvalidStateError);
186 return ScriptPromise(); 186 return ScriptPromise();
187 } 187 }
188 if (!sw || !sh) { 188 if (!sw || !sh) {
189 es.throwDOMException(IndexSizeError); 189 es.throwUninformativeAndGenericDOMException(IndexSizeError);
190 return ScriptPromise(); 190 return ScriptPromise();
191 } 191 }
192 // FIXME: make ImageBitmap creation asynchronous crbug.com/258082 192 // FIXME: make ImageBitmap creation asynchronous crbug.com/258082
193 return fulfillImageBitmap(eventTarget->scriptExecutionContext(), ImageBitmap ::create(canvas, IntRect(sx, sy, sw, sh))); 193 return fulfillImageBitmap(eventTarget->scriptExecutionContext(), ImageBitmap ::create(canvas, IntRect(sx, sy, sw, sh)));
194 } 194 }
195 195
196 ScriptPromise ImageBitmapFactories::createImageBitmap(EventTarget* eventTarget, Blob* blob, ExceptionState& es) 196 ScriptPromise ImageBitmapFactories::createImageBitmap(EventTarget* eventTarget, Blob* blob, ExceptionState& es)
197 { 197 {
198 // Promises must be enabled. 198 // Promises must be enabled.
199 ASSERT(RuntimeEnabledFeatures::promiseEnabled()); 199 ASSERT(RuntimeEnabledFeatures::promiseEnabled());
200 200
201 if (!blob) { 201 if (!blob) {
202 es.throwDOMException(TypeError); 202 es.throwUninformativeAndGenericDOMException(TypeError);
203 return ScriptPromise(); 203 return ScriptPromise();
204 } 204 }
205 RefPtr<ScriptPromiseResolver> resolver = ScriptPromiseResolver::create(event Target->scriptExecutionContext()); 205 RefPtr<ScriptPromiseResolver> resolver = ScriptPromiseResolver::create(event Target->scriptExecutionContext());
206 RefPtr<ImageBitmapLoader> loader = ImageBitmapFactories::ImageBitmapLoader:: create(from(eventTarget), resolver, IntRect()); 206 RefPtr<ImageBitmapLoader> loader = ImageBitmapFactories::ImageBitmapLoader:: create(from(eventTarget), resolver, IntRect());
207 from(eventTarget)->addLoader(loader); 207 from(eventTarget)->addLoader(loader);
208 loader->loadBlobAsync(eventTarget->scriptExecutionContext(), blob); 208 loader->loadBlobAsync(eventTarget->scriptExecutionContext(), blob);
209 return resolver->promise(); 209 return resolver->promise();
210 } 210 }
211 211
212 ScriptPromise ImageBitmapFactories::createImageBitmap(EventTarget* eventTarget, Blob* blob, int sx, int sy, int sw, int sh, ExceptionState& es) 212 ScriptPromise ImageBitmapFactories::createImageBitmap(EventTarget* eventTarget, Blob* blob, int sx, int sy, int sw, int sh, ExceptionState& es)
213 { 213 {
214 // Promises must be enabled. 214 // Promises must be enabled.
215 ASSERT(RuntimeEnabledFeatures::promiseEnabled()); 215 ASSERT(RuntimeEnabledFeatures::promiseEnabled());
216 216
217 if (!blob) { 217 if (!blob) {
218 es.throwDOMException(TypeError); 218 es.throwUninformativeAndGenericDOMException(TypeError);
219 return ScriptPromise(); 219 return ScriptPromise();
220 } 220 }
221 if (!sw || !sh) { 221 if (!sw || !sh) {
222 es.throwDOMException(IndexSizeError); 222 es.throwUninformativeAndGenericDOMException(IndexSizeError);
223 return ScriptPromise(); 223 return ScriptPromise();
224 } 224 }
225 RefPtr<ScriptPromiseResolver> resolver = ScriptPromiseResolver::create(event Target->scriptExecutionContext()); 225 RefPtr<ScriptPromiseResolver> resolver = ScriptPromiseResolver::create(event Target->scriptExecutionContext());
226 RefPtr<ImageBitmapLoader> loader = ImageBitmapFactories::ImageBitmapLoader:: create(from(eventTarget), resolver, IntRect(sx, sy, sw, sh)); 226 RefPtr<ImageBitmapLoader> loader = ImageBitmapFactories::ImageBitmapLoader:: create(from(eventTarget), resolver, IntRect(sx, sy, sw, sh));
227 from(eventTarget)->addLoader(loader); 227 from(eventTarget)->addLoader(loader);
228 loader->loadBlobAsync(eventTarget->scriptExecutionContext(), blob); 228 loader->loadBlobAsync(eventTarget->scriptExecutionContext(), blob);
229 return resolver->promise(); 229 return resolver->promise();
230 } 230 }
231 231
232 ScriptPromise ImageBitmapFactories::createImageBitmap(EventTarget* eventTarget, ImageData* data, ExceptionState& es) 232 ScriptPromise ImageBitmapFactories::createImageBitmap(EventTarget* eventTarget, ImageData* data, ExceptionState& es)
233 { 233 {
234 return createImageBitmap(eventTarget, data, 0, 0, data->width(), data->heigh t(), es); 234 return createImageBitmap(eventTarget, data, 0, 0, data->width(), data->heigh t(), es);
235 } 235 }
236 236
237 ScriptPromise ImageBitmapFactories::createImageBitmap(EventTarget* eventTarget, ImageData* data, int sx, int sy, int sw, int sh, ExceptionState& es) 237 ScriptPromise ImageBitmapFactories::createImageBitmap(EventTarget* eventTarget, ImageData* data, int sx, int sy, int sw, int sh, ExceptionState& es)
238 { 238 {
239 if (!data) { 239 if (!data) {
240 es.throwTypeError(); 240 es.throwTypeError();
241 return ScriptPromise(); 241 return ScriptPromise();
242 } 242 }
243 if (!sw || !sh) { 243 if (!sw || !sh) {
244 es.throwDOMException(IndexSizeError); 244 es.throwUninformativeAndGenericDOMException(IndexSizeError);
245 return ScriptPromise(); 245 return ScriptPromise();
246 } 246 }
247 // FIXME: make ImageBitmap creation asynchronous crbug.com/258082 247 // FIXME: make ImageBitmap creation asynchronous crbug.com/258082
248 return fulfillImageBitmap(eventTarget->scriptExecutionContext(), ImageBitmap ::create(data, IntRect(sx, sy, sw, sh))); 248 return fulfillImageBitmap(eventTarget->scriptExecutionContext(), ImageBitmap ::create(data, IntRect(sx, sy, sw, sh)));
249 } 249 }
250 250
251 ScriptPromise ImageBitmapFactories::createImageBitmap(EventTarget* eventTarget, ImageBitmap* bitmap, ExceptionState& es) 251 ScriptPromise ImageBitmapFactories::createImageBitmap(EventTarget* eventTarget, ImageBitmap* bitmap, ExceptionState& es)
252 { 252 {
253 return createImageBitmap(eventTarget, bitmap, 0, 0, bitmap->width(), bitmap- >height(), es); 253 return createImageBitmap(eventTarget, bitmap, 0, 0, bitmap->width(), bitmap- >height(), es);
254 } 254 }
255 255
256 ScriptPromise ImageBitmapFactories::createImageBitmap(EventTarget* eventTarget, ImageBitmap* bitmap, int sx, int sy, int sw, int sh, ExceptionState& es) 256 ScriptPromise ImageBitmapFactories::createImageBitmap(EventTarget* eventTarget, ImageBitmap* bitmap, int sx, int sy, int sw, int sh, ExceptionState& es)
257 { 257 {
258 if (!bitmap) { 258 if (!bitmap) {
259 es.throwTypeError(); 259 es.throwTypeError();
260 return ScriptPromise(); 260 return ScriptPromise();
261 } 261 }
262 if (!sw || !sh) { 262 if (!sw || !sh) {
263 es.throwDOMException(IndexSizeError); 263 es.throwUninformativeAndGenericDOMException(IndexSizeError);
264 return ScriptPromise(); 264 return ScriptPromise();
265 } 265 }
266 // FIXME: make ImageBitmap creation asynchronous crbug.com/258082 266 // FIXME: make ImageBitmap creation asynchronous crbug.com/258082
267 return fulfillImageBitmap(eventTarget->scriptExecutionContext(), ImageBitmap ::create(bitmap, IntRect(sx, sy, sw, sh))); 267 return fulfillImageBitmap(eventTarget->scriptExecutionContext(), ImageBitmap ::create(bitmap, IntRect(sx, sy, sw, sh)));
268 } 268 }
269 269
270 const char* ImageBitmapFactories::supplementName() 270 const char* ImageBitmapFactories::supplementName()
271 { 271 {
272 return "ImageBitmapFactories"; 272 return "ImageBitmapFactories";
273 } 273 }
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
356 m_resolver->fulfill(imageBitmap.release()); 356 m_resolver->fulfill(imageBitmap.release());
357 m_factory->didFinishLoading(this); 357 m_factory->didFinishLoading(this);
358 } 358 }
359 359
360 void ImageBitmapFactories::ImageBitmapLoader::didFail(FileError::ErrorCode) 360 void ImageBitmapFactories::ImageBitmapLoader::didFail(FileError::ErrorCode)
361 { 361 {
362 rejectPromise(); 362 rejectPromise();
363 } 363 }
364 364
365 } // namespace WebCore 365 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/modules/filesystem/DOMFileSystemSync.cpp ('k') | Source/modules/indexeddb/IDBCursor.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698