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

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

Issue 72363002: Rename es => exceptionState in other than bindings/ (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Retry Created 7 years, 1 month 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
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 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 } 66 }
67 67
68 static ScriptPromise fulfillImageBitmap(ExecutionContext* context, PassRefPtr<Im ageBitmap> imageBitmap) 68 static ScriptPromise fulfillImageBitmap(ExecutionContext* context, PassRefPtr<Im ageBitmap> imageBitmap)
69 { 69 {
70 ScriptPromise promise = ScriptPromise::createPending(context); 70 ScriptPromise promise = ScriptPromise::createPending(context);
71 RefPtr<ScriptPromiseResolver> resolver = ScriptPromiseResolver::create(promi se, context); 71 RefPtr<ScriptPromiseResolver> resolver = ScriptPromiseResolver::create(promi se, context);
72 resolver->resolve(imageBitmap); 72 resolver->resolve(imageBitmap);
73 return promise; 73 return promise;
74 } 74 }
75 75
76 ScriptPromise ImageBitmapFactories::createImageBitmap(EventTarget* eventTarget, HTMLImageElement* image, ExceptionState& es) 76 ScriptPromise ImageBitmapFactories::createImageBitmap(EventTarget* eventTarget, HTMLImageElement* image, ExceptionState& exceptionState)
77 { 77 {
78 LayoutSize s = sizeFor(image); 78 LayoutSize s = sizeFor(image);
79 return createImageBitmap(eventTarget, image, 0, 0, s.width(), s.height(), es ); 79 return createImageBitmap(eventTarget, image, 0, 0, s.width(), s.height(), ex ceptionState);
80 } 80 }
81 81
82 ScriptPromise ImageBitmapFactories::createImageBitmap(EventTarget* eventTarget, HTMLImageElement* image, int sx, int sy, int sw, int sh, ExceptionState& es) 82 ScriptPromise ImageBitmapFactories::createImageBitmap(EventTarget* eventTarget, HTMLImageElement* image, int sx, int sy, int sw, int sh, ExceptionState& excepti onState)
83 { 83 {
84 // This variant does not work in worker threads. 84 // This variant does not work in worker threads.
85 ASSERT(eventTarget->toDOMWindow()); 85 ASSERT(eventTarget->toDOMWindow());
86 86
87 if (!image) { 87 if (!image) {
88 es.throwUninformativeAndGenericTypeError(); 88 exceptionState.throwUninformativeAndGenericTypeError();
89 return ScriptPromise(); 89 return ScriptPromise();
90 } 90 }
91 if (!image->cachedImage()) { 91 if (!image->cachedImage()) {
92 es.throwUninformativeAndGenericDOMException(InvalidStateError); 92 exceptionState.throwUninformativeAndGenericDOMException(InvalidStateErro r);
93 return ScriptPromise(); 93 return ScriptPromise();
94 } 94 }
95 if (image->cachedImage()->image()->isSVGImage()) { 95 if (image->cachedImage()->image()->isSVGImage()) {
96 es.throwUninformativeAndGenericDOMException(InvalidStateError); 96 exceptionState.throwUninformativeAndGenericDOMException(InvalidStateErro r);
97 return ScriptPromise(); 97 return ScriptPromise();
98 } 98 }
99 if (!sw || !sh) { 99 if (!sw || !sh) {
100 es.throwUninformativeAndGenericDOMException(IndexSizeError); 100 exceptionState.throwUninformativeAndGenericDOMException(IndexSizeError);
101 return ScriptPromise(); 101 return ScriptPromise();
102 } 102 }
103 if (!image->cachedImage()->image()->currentFrameHasSingleSecurityOrigin()) { 103 if (!image->cachedImage()->image()->currentFrameHasSingleSecurityOrigin()) {
104 es.throwSecurityError(ExceptionMessages::failedToExecute("createImageBit map", "ImageBitmapFactories", "the source image contains cross-origin image data .")); 104 exceptionState.throwSecurityError(ExceptionMessages::failedToExecute("cr eateImageBitmap", "ImageBitmapFactories", "the source image contains cross-origi n image data."));
105 return ScriptPromise(); 105 return ScriptPromise();
106 } 106 }
107 if (!image->cachedImage()->passesAccessControlCheck(eventTarget->toDOMWindow ()->document()->securityOrigin()) 107 if (!image->cachedImage()->passesAccessControlCheck(eventTarget->toDOMWindow ()->document()->securityOrigin())
108 && eventTarget->toDOMWindow()->document()->securityOrigin()->taintsCanvas(im age->src())) { 108 && eventTarget->toDOMWindow()->document()->securityOrigin()->taintsCanvas(im age->src())) {
109 es.throwSecurityError(ExceptionMessages::failedToExecute("createImageBit map", "ImageBitmapFactories", "cross-origin access to the source image is denied .")); 109 exceptionState.throwSecurityError(ExceptionMessages::failedToExecute("cr eateImageBitmap", "ImageBitmapFactories", "cross-origin access to the source ima ge is denied."));
110 return ScriptPromise(); 110 return ScriptPromise();
111 } 111 }
112 // FIXME: make ImageBitmap creation asynchronous crbug.com/258082 112 // FIXME: make ImageBitmap creation asynchronous crbug.com/258082
113 return fulfillImageBitmap(eventTarget->executionContext(), ImageBitmap::crea te(image, IntRect(sx, sy, sw, sh))); 113 return fulfillImageBitmap(eventTarget->executionContext(), ImageBitmap::crea te(image, IntRect(sx, sy, sw, sh)));
114 } 114 }
115 115
116 ScriptPromise ImageBitmapFactories::createImageBitmap(EventTarget* eventTarget, HTMLVideoElement* video, ExceptionState& es) 116 ScriptPromise ImageBitmapFactories::createImageBitmap(EventTarget* eventTarget, HTMLVideoElement* video, ExceptionState& exceptionState)
117 { 117 {
118 IntSize s = sizeFor(video); 118 IntSize s = sizeFor(video);
119 return createImageBitmap(eventTarget, video, 0, 0, s.width(), s.height(), es ); 119 return createImageBitmap(eventTarget, video, 0, 0, s.width(), s.height(), ex ceptionState);
120 } 120 }
121 121
122 ScriptPromise ImageBitmapFactories::createImageBitmap(EventTarget* eventTarget, HTMLVideoElement* video, int sx, int sy, int sw, int sh, ExceptionState& es) 122 ScriptPromise ImageBitmapFactories::createImageBitmap(EventTarget* eventTarget, HTMLVideoElement* video, int sx, int sy, int sw, int sh, ExceptionState& excepti onState)
123 { 123 {
124 // This variant does not work in worker threads. 124 // This variant does not work in worker threads.
125 ASSERT(eventTarget->toDOMWindow()); 125 ASSERT(eventTarget->toDOMWindow());
126 126
127 if (!video) { 127 if (!video) {
128 es.throwUninformativeAndGenericTypeError(); 128 exceptionState.throwUninformativeAndGenericTypeError();
129 return ScriptPromise(); 129 return ScriptPromise();
130 } 130 }
131 if (!video->player()) { 131 if (!video->player()) {
132 es.throwUninformativeAndGenericDOMException(InvalidStateError); 132 exceptionState.throwUninformativeAndGenericDOMException(InvalidStateErro r);
133 return ScriptPromise(); 133 return ScriptPromise();
134 } 134 }
135 if (video->networkState() == HTMLMediaElement::NETWORK_EMPTY) { 135 if (video->networkState() == HTMLMediaElement::NETWORK_EMPTY) {
136 es.throwUninformativeAndGenericDOMException(InvalidStateError); 136 exceptionState.throwUninformativeAndGenericDOMException(InvalidStateErro r);
137 return ScriptPromise(); 137 return ScriptPromise();
138 } 138 }
139 if (video->player()->readyState() <= MediaPlayer::HaveMetadata) { 139 if (video->player()->readyState() <= MediaPlayer::HaveMetadata) {
140 es.throwUninformativeAndGenericDOMException(InvalidStateError); 140 exceptionState.throwUninformativeAndGenericDOMException(InvalidStateErro r);
141 return ScriptPromise(); 141 return ScriptPromise();
142 } 142 }
143 if (!sw || !sh) { 143 if (!sw || !sh) {
144 es.throwUninformativeAndGenericDOMException(IndexSizeError); 144 exceptionState.throwUninformativeAndGenericDOMException(IndexSizeError);
145 return ScriptPromise(); 145 return ScriptPromise();
146 } 146 }
147 if (!video->hasSingleSecurityOrigin()) { 147 if (!video->hasSingleSecurityOrigin()) {
148 es.throwSecurityError(ExceptionMessages::failedToExecute("createImageBit map", "ImageBitmapFactories", "the source video contains cross-origin image data .")); 148 exceptionState.throwSecurityError(ExceptionMessages::failedToExecute("cr eateImageBitmap", "ImageBitmapFactories", "the source video contains cross-origi n image data."));
149 return ScriptPromise(); 149 return ScriptPromise();
150 } 150 }
151 if (!video->player()->didPassCORSAccessCheck() && eventTarget->toDOMWindow() ->document()->securityOrigin()->taintsCanvas(video->currentSrc())) { 151 if (!video->player()->didPassCORSAccessCheck() && eventTarget->toDOMWindow() ->document()->securityOrigin()->taintsCanvas(video->currentSrc())) {
152 es.throwSecurityError(ExceptionMessages::failedToExecute("createImageBit map", "ImageBitmapFactories", "cross-origin access to the source video is denied .")); 152 exceptionState.throwSecurityError(ExceptionMessages::failedToExecute("cr eateImageBitmap", "ImageBitmapFactories", "cross-origin access to the source vid eo is denied."));
153 return ScriptPromise(); 153 return ScriptPromise();
154 } 154 }
155 // FIXME: make ImageBitmap creation asynchronous crbug.com/258082 155 // FIXME: make ImageBitmap creation asynchronous crbug.com/258082
156 return fulfillImageBitmap(eventTarget->executionContext(), ImageBitmap::crea te(video, IntRect(sx, sy, sw, sh))); 156 return fulfillImageBitmap(eventTarget->executionContext(), ImageBitmap::crea te(video, IntRect(sx, sy, sw, sh)));
157 } 157 }
158 158
159 ScriptPromise ImageBitmapFactories::createImageBitmap(EventTarget* eventTarget, CanvasRenderingContext2D* context, ExceptionState& es) 159 ScriptPromise ImageBitmapFactories::createImageBitmap(EventTarget* eventTarget, CanvasRenderingContext2D* context, ExceptionState& exceptionState)
160 { 160 {
161 return createImageBitmap(eventTarget, context->canvas(), es); 161 return createImageBitmap(eventTarget, context->canvas(), exceptionState);
162 } 162 }
163 163
164 ScriptPromise ImageBitmapFactories::createImageBitmap(EventTarget* eventTarget, CanvasRenderingContext2D* context, int sx, int sy, int sw, int sh, ExceptionStat e& es) 164 ScriptPromise ImageBitmapFactories::createImageBitmap(EventTarget* eventTarget, CanvasRenderingContext2D* context, int sx, int sy, int sw, int sh, ExceptionStat e& exceptionState)
165 { 165 {
166 return createImageBitmap(eventTarget, context->canvas(), sx, sy, sw, sh, es) ; 166 return createImageBitmap(eventTarget, context->canvas(), sx, sy, sw, sh, exc eptionState);
167 } 167 }
168 168
169 ScriptPromise ImageBitmapFactories::createImageBitmap(EventTarget* eventTarget, HTMLCanvasElement* canvas, ExceptionState& es) 169 ScriptPromise ImageBitmapFactories::createImageBitmap(EventTarget* eventTarget, HTMLCanvasElement* canvas, ExceptionState& exceptionState)
170 { 170 {
171 return createImageBitmap(eventTarget, canvas, 0, 0, canvas->width(), canvas- >height(), es); 171 return createImageBitmap(eventTarget, canvas, 0, 0, canvas->width(), canvas- >height(), exceptionState);
172 } 172 }
173 173
174 ScriptPromise ImageBitmapFactories::createImageBitmap(EventTarget* eventTarget, HTMLCanvasElement* canvas, int sx, int sy, int sw, int sh, ExceptionState& es) 174 ScriptPromise ImageBitmapFactories::createImageBitmap(EventTarget* eventTarget, HTMLCanvasElement* canvas, int sx, int sy, int sw, int sh, ExceptionState& excep tionState)
175 { 175 {
176 // This variant does not work in worker threads. 176 // This variant does not work in worker threads.
177 ASSERT(eventTarget->toDOMWindow()); 177 ASSERT(eventTarget->toDOMWindow());
178 178
179 if (!canvas) { 179 if (!canvas) {
180 es.throwUninformativeAndGenericTypeError(); 180 exceptionState.throwUninformativeAndGenericTypeError();
181 return ScriptPromise(); 181 return ScriptPromise();
182 } 182 }
183 if (!canvas->originClean()) { 183 if (!canvas->originClean()) {
184 es.throwUninformativeAndGenericDOMException(InvalidStateError); 184 exceptionState.throwUninformativeAndGenericDOMException(InvalidStateErro r);
185 return ScriptPromise(); 185 return ScriptPromise();
186 } 186 }
187 if (!sw || !sh) { 187 if (!sw || !sh) {
188 es.throwUninformativeAndGenericDOMException(IndexSizeError); 188 exceptionState.throwUninformativeAndGenericDOMException(IndexSizeError);
189 return ScriptPromise(); 189 return ScriptPromise();
190 } 190 }
191 // FIXME: make ImageBitmap creation asynchronous crbug.com/258082 191 // FIXME: make ImageBitmap creation asynchronous crbug.com/258082
192 return fulfillImageBitmap(eventTarget->executionContext(), ImageBitmap::crea te(canvas, IntRect(sx, sy, sw, sh))); 192 return fulfillImageBitmap(eventTarget->executionContext(), ImageBitmap::crea te(canvas, IntRect(sx, sy, sw, sh)));
193 } 193 }
194 194
195 ScriptPromise ImageBitmapFactories::createImageBitmap(EventTarget* eventTarget, Blob* blob, ExceptionState& es) 195 ScriptPromise ImageBitmapFactories::createImageBitmap(EventTarget* eventTarget, Blob* blob, ExceptionState& exceptionState)
196 { 196 {
197 if (!blob) { 197 if (!blob) {
198 es.throwUninformativeAndGenericDOMException(TypeError); 198 exceptionState.throwUninformativeAndGenericDOMException(TypeError);
199 return ScriptPromise(); 199 return ScriptPromise();
200 } 200 }
201 ScriptPromise promise = ScriptPromise::createPending(eventTarget->executionC ontext()); 201 ScriptPromise promise = ScriptPromise::createPending(eventTarget->executionC ontext());
202 RefPtr<ScriptPromiseResolver> resolver = ScriptPromiseResolver::create(promi se, eventTarget->executionContext()); 202 RefPtr<ScriptPromiseResolver> resolver = ScriptPromiseResolver::create(promi se, eventTarget->executionContext());
203 RefPtr<ImageBitmapLoader> loader = ImageBitmapFactories::ImageBitmapLoader:: create(from(eventTarget), resolver, IntRect()); 203 RefPtr<ImageBitmapLoader> loader = ImageBitmapFactories::ImageBitmapLoader:: create(from(eventTarget), resolver, IntRect());
204 from(eventTarget)->addLoader(loader); 204 from(eventTarget)->addLoader(loader);
205 loader->loadBlobAsync(eventTarget->executionContext(), blob); 205 loader->loadBlobAsync(eventTarget->executionContext(), blob);
206 return promise; 206 return promise;
207 } 207 }
208 208
209 ScriptPromise ImageBitmapFactories::createImageBitmap(EventTarget* eventTarget, Blob* blob, int sx, int sy, int sw, int sh, ExceptionState& es) 209 ScriptPromise ImageBitmapFactories::createImageBitmap(EventTarget* eventTarget, Blob* blob, int sx, int sy, int sw, int sh, ExceptionState& exceptionState)
210 { 210 {
211 if (!blob) { 211 if (!blob) {
212 es.throwUninformativeAndGenericDOMException(TypeError); 212 exceptionState.throwUninformativeAndGenericDOMException(TypeError);
213 return ScriptPromise(); 213 return ScriptPromise();
214 } 214 }
215 if (!sw || !sh) { 215 if (!sw || !sh) {
216 es.throwUninformativeAndGenericDOMException(IndexSizeError); 216 exceptionState.throwUninformativeAndGenericDOMException(IndexSizeError);
217 return ScriptPromise(); 217 return ScriptPromise();
218 } 218 }
219 ScriptPromise promise = ScriptPromise::createPending(eventTarget->executionC ontext()); 219 ScriptPromise promise = ScriptPromise::createPending(eventTarget->executionC ontext());
220 RefPtr<ScriptPromiseResolver> resolver = ScriptPromiseResolver::create(promi se, eventTarget->executionContext()); 220 RefPtr<ScriptPromiseResolver> resolver = ScriptPromiseResolver::create(promi se, eventTarget->executionContext());
221 RefPtr<ImageBitmapLoader> loader = ImageBitmapFactories::ImageBitmapLoader:: create(from(eventTarget), resolver, IntRect(sx, sy, sw, sh)); 221 RefPtr<ImageBitmapLoader> loader = ImageBitmapFactories::ImageBitmapLoader:: create(from(eventTarget), resolver, IntRect(sx, sy, sw, sh));
222 from(eventTarget)->addLoader(loader); 222 from(eventTarget)->addLoader(loader);
223 loader->loadBlobAsync(eventTarget->executionContext(), blob); 223 loader->loadBlobAsync(eventTarget->executionContext(), blob);
224 return promise; 224 return promise;
225 } 225 }
226 226
227 ScriptPromise ImageBitmapFactories::createImageBitmap(EventTarget* eventTarget, ImageData* data, ExceptionState& es) 227 ScriptPromise ImageBitmapFactories::createImageBitmap(EventTarget* eventTarget, ImageData* data, ExceptionState& exceptionState)
228 { 228 {
229 return createImageBitmap(eventTarget, data, 0, 0, data->width(), data->heigh t(), es); 229 return createImageBitmap(eventTarget, data, 0, 0, data->width(), data->heigh t(), exceptionState);
230 } 230 }
231 231
232 ScriptPromise ImageBitmapFactories::createImageBitmap(EventTarget* eventTarget, ImageData* data, int sx, int sy, int sw, int sh, ExceptionState& es) 232 ScriptPromise ImageBitmapFactories::createImageBitmap(EventTarget* eventTarget, ImageData* data, int sx, int sy, int sw, int sh, ExceptionState& exceptionState)
233 { 233 {
234 if (!data) { 234 if (!data) {
235 es.throwUninformativeAndGenericTypeError(); 235 exceptionState.throwUninformativeAndGenericTypeError();
236 return ScriptPromise(); 236 return ScriptPromise();
237 } 237 }
238 if (!sw || !sh) { 238 if (!sw || !sh) {
239 es.throwUninformativeAndGenericDOMException(IndexSizeError); 239 exceptionState.throwUninformativeAndGenericDOMException(IndexSizeError);
240 return ScriptPromise(); 240 return ScriptPromise();
241 } 241 }
242 // FIXME: make ImageBitmap creation asynchronous crbug.com/258082 242 // FIXME: make ImageBitmap creation asynchronous crbug.com/258082
243 return fulfillImageBitmap(eventTarget->executionContext(), ImageBitmap::crea te(data, IntRect(sx, sy, sw, sh))); 243 return fulfillImageBitmap(eventTarget->executionContext(), ImageBitmap::crea te(data, IntRect(sx, sy, sw, sh)));
244 } 244 }
245 245
246 ScriptPromise ImageBitmapFactories::createImageBitmap(EventTarget* eventTarget, ImageBitmap* bitmap, ExceptionState& es) 246 ScriptPromise ImageBitmapFactories::createImageBitmap(EventTarget* eventTarget, ImageBitmap* bitmap, ExceptionState& exceptionState)
247 { 247 {
248 return createImageBitmap(eventTarget, bitmap, 0, 0, bitmap->width(), bitmap- >height(), es); 248 return createImageBitmap(eventTarget, bitmap, 0, 0, bitmap->width(), bitmap- >height(), exceptionState);
249 } 249 }
250 250
251 ScriptPromise ImageBitmapFactories::createImageBitmap(EventTarget* eventTarget, ImageBitmap* bitmap, int sx, int sy, int sw, int sh, ExceptionState& es) 251 ScriptPromise ImageBitmapFactories::createImageBitmap(EventTarget* eventTarget, ImageBitmap* bitmap, int sx, int sy, int sw, int sh, ExceptionState& exceptionSt ate)
252 { 252 {
253 if (!bitmap) { 253 if (!bitmap) {
254 es.throwUninformativeAndGenericTypeError(); 254 exceptionState.throwUninformativeAndGenericTypeError();
255 return ScriptPromise(); 255 return ScriptPromise();
256 } 256 }
257 if (!sw || !sh) { 257 if (!sw || !sh) {
258 es.throwUninformativeAndGenericDOMException(IndexSizeError); 258 exceptionState.throwUninformativeAndGenericDOMException(IndexSizeError);
259 return ScriptPromise(); 259 return ScriptPromise();
260 } 260 }
261 // FIXME: make ImageBitmap creation asynchronous crbug.com/258082 261 // FIXME: make ImageBitmap creation asynchronous crbug.com/258082
262 return fulfillImageBitmap(eventTarget->executionContext(), ImageBitmap::crea te(bitmap, IntRect(sx, sy, sw, sh))); 262 return fulfillImageBitmap(eventTarget->executionContext(), ImageBitmap::crea te(bitmap, IntRect(sx, sy, sw, sh)));
263 } 263 }
264 264
265 const char* ImageBitmapFactories::supplementName() 265 const char* ImageBitmapFactories::supplementName()
266 { 266 {
267 return "ImageBitmapFactories"; 267 return "ImageBitmapFactories";
268 } 268 }
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
351 m_resolver->resolve(imageBitmap.release()); 351 m_resolver->resolve(imageBitmap.release());
352 m_factory->didFinishLoading(this); 352 m_factory->didFinishLoading(this);
353 } 353 }
354 354
355 void ImageBitmapFactories::ImageBitmapLoader::didFail(FileError::ErrorCode) 355 void ImageBitmapFactories::ImageBitmapLoader::didFail(FileError::ErrorCode)
356 { 356 {
357 rejectPromise(); 357 rejectPromise();
358 } 358 }
359 359
360 } // namespace WebCore 360 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/modules/filesystem/WorkerGlobalScopeFileSystem.cpp ('k') | Source/modules/indexeddb/IDBCursor.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698