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

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

Issue 183253003: Consistently use ExceptionState::throwTypeError(). (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 9 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
« no previous file with comments | « Source/core/xml/XMLSerializer.cpp ('k') | Source/modules/webmidi/MIDIOutput.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 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
185 exceptionState.throwDOMException(IndexSizeError, String::format("The sou rce %s provided is 0.", sw ? "height" : "width")); 185 exceptionState.throwDOMException(IndexSizeError, String::format("The sou rce %s provided is 0.", sw ? "height" : "width"));
186 return ScriptPromise(); 186 return ScriptPromise();
187 } 187 }
188 // FIXME: make ImageBitmap creation asynchronous crbug.com/258082 188 // FIXME: make ImageBitmap creation asynchronous crbug.com/258082
189 return fulfillImageBitmap(eventTarget.executionContext(), ImageBitmap::creat e(canvas, IntRect(sx, sy, sw, sh))); 189 return fulfillImageBitmap(eventTarget.executionContext(), ImageBitmap::creat e(canvas, IntRect(sx, sy, sw, sh)));
190 } 190 }
191 191
192 ScriptPromise ImageBitmapFactories::createImageBitmap(EventTarget& eventTarget, Blob* blob, ExceptionState& exceptionState) 192 ScriptPromise ImageBitmapFactories::createImageBitmap(EventTarget& eventTarget, Blob* blob, ExceptionState& exceptionState)
193 { 193 {
194 if (!blob) { 194 if (!blob) {
195 exceptionState.throwDOMException(TypeError, "The blob provided is invali d."); 195 exceptionState.throwTypeError("The blob provided is invalid.");
196 return ScriptPromise(); 196 return ScriptPromise();
197 } 197 }
198 ScriptPromise promise = ScriptPromise::createPending(eventTarget.executionCo ntext()); 198 ScriptPromise promise = ScriptPromise::createPending(eventTarget.executionCo ntext());
199 RefPtr<ScriptPromiseResolver> resolver = ScriptPromiseResolver::create(promi se, eventTarget.executionContext()); 199 RefPtr<ScriptPromiseResolver> resolver = ScriptPromiseResolver::create(promi se, eventTarget.executionContext());
200 RefPtr<ImageBitmapLoader> loader = ImageBitmapFactories::ImageBitmapLoader:: create(from(eventTarget), resolver, IntRect()); 200 RefPtr<ImageBitmapLoader> loader = ImageBitmapFactories::ImageBitmapLoader:: create(from(eventTarget), resolver, IntRect());
201 from(eventTarget).addLoader(loader); 201 from(eventTarget).addLoader(loader);
202 loader->loadBlobAsync(eventTarget.executionContext(), blob); 202 loader->loadBlobAsync(eventTarget.executionContext(), blob);
203 return promise; 203 return promise;
204 } 204 }
205 205
206 ScriptPromise ImageBitmapFactories::createImageBitmap(EventTarget& eventTarget, Blob* blob, int sx, int sy, int sw, int sh, ExceptionState& exceptionState) 206 ScriptPromise ImageBitmapFactories::createImageBitmap(EventTarget& eventTarget, Blob* blob, int sx, int sy, int sw, int sh, ExceptionState& exceptionState)
207 { 207 {
208 if (!blob) { 208 if (!blob) {
209 exceptionState.throwDOMException(TypeError, "The blob provided is invali d."); 209 exceptionState.throwTypeError("The blob provided is invalid.");
210 return ScriptPromise(); 210 return ScriptPromise();
211 } 211 }
212 if (!sw || !sh) { 212 if (!sw || !sh) {
213 exceptionState.throwDOMException(IndexSizeError, String::format("The sou rce %s provided is 0.", sw ? "height" : "width")); 213 exceptionState.throwDOMException(IndexSizeError, String::format("The sou rce %s provided is 0.", sw ? "height" : "width"));
214 return ScriptPromise(); 214 return ScriptPromise();
215 } 215 }
216 ScriptPromise promise = ScriptPromise::createPending(eventTarget.executionCo ntext()); 216 ScriptPromise promise = ScriptPromise::createPending(eventTarget.executionCo ntext());
217 RefPtr<ScriptPromiseResolver> resolver = ScriptPromiseResolver::create(promi se, eventTarget.executionContext()); 217 RefPtr<ScriptPromiseResolver> resolver = ScriptPromiseResolver::create(promi se, eventTarget.executionContext());
218 RefPtr<ImageBitmapLoader> loader = ImageBitmapFactories::ImageBitmapLoader:: create(from(eventTarget), resolver, IntRect(sx, sy, sw, sh)); 218 RefPtr<ImageBitmapLoader> loader = ImageBitmapFactories::ImageBitmapLoader:: create(from(eventTarget), resolver, IntRect(sx, sy, sw, sh));
219 from(eventTarget).addLoader(loader); 219 from(eventTarget).addLoader(loader);
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
348 m_resolver->resolve(imageBitmap.release()); 348 m_resolver->resolve(imageBitmap.release());
349 m_factory->didFinishLoading(this); 349 m_factory->didFinishLoading(this);
350 } 350 }
351 351
352 void ImageBitmapFactories::ImageBitmapLoader::didFail(FileError::ErrorCode) 352 void ImageBitmapFactories::ImageBitmapLoader::didFail(FileError::ErrorCode)
353 { 353 {
354 rejectPromise(); 354 rejectPromise();
355 } 355 }
356 356
357 } // namespace WebCore 357 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/core/xml/XMLSerializer.cpp ('k') | Source/modules/webmidi/MIDIOutput.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698