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

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

Issue 297513008: Decrease call sites of ScriptState::current() (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 7 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
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 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
179 exceptionState.throwDOMException(IndexSizeError, String::format("The sou rce %s provided is 0.", sw ? "height" : "width")); 179 exceptionState.throwDOMException(IndexSizeError, String::format("The sou rce %s provided is 0.", sw ? "height" : "width"));
180 return ScriptPromise(); 180 return ScriptPromise();
181 } 181 }
182 182
183 // FIXME: make ImageBitmap creation asynchronous crbug.com/258082 183 // FIXME: make ImageBitmap creation asynchronous crbug.com/258082
184 return fulfillImageBitmap(scriptState, canvas->buffer() ? ImageBitmap::creat e(canvas, IntRect(sx, sy, sw, sh)) : nullptr); 184 return fulfillImageBitmap(scriptState, canvas->buffer() ? ImageBitmap::creat e(canvas, IntRect(sx, sy, sw, sh)) : nullptr);
185 } 185 }
186 186
187 ScriptPromise ImageBitmapFactories::createImageBitmap(ScriptState* scriptState, EventTarget& eventTarget, Blob* blob, ExceptionState& exceptionState) 187 ScriptPromise ImageBitmapFactories::createImageBitmap(ScriptState* scriptState, EventTarget& eventTarget, Blob* blob, ExceptionState& exceptionState)
188 { 188 {
189 RefPtrWillBeRawPtr<ImageBitmapLoader> loader = ImageBitmapFactories::ImageBi tmapLoader::create(from(eventTarget), eventTarget.executionContext(), IntRect()) ; 189 RefPtrWillBeRawPtr<ImageBitmapLoader> loader = ImageBitmapFactories::ImageBi tmapLoader::create(from(eventTarget), IntRect(), scriptState);
190 ScriptPromise promise = loader->promise(); 190 ScriptPromise promise = loader->promise();
191 from(eventTarget).addLoader(loader); 191 from(eventTarget).addLoader(loader);
192 loader->loadBlobAsync(eventTarget.executionContext(), blob); 192 loader->loadBlobAsync(eventTarget.executionContext(), blob);
193 return promise; 193 return promise;
194 } 194 }
195 195
196 ScriptPromise ImageBitmapFactories::createImageBitmap(ScriptState* scriptState, EventTarget& eventTarget, Blob* blob, int sx, int sy, int sw, int sh, ExceptionS tate& exceptionState) 196 ScriptPromise ImageBitmapFactories::createImageBitmap(ScriptState* scriptState, EventTarget& eventTarget, Blob* blob, int sx, int sy, int sw, int sh, ExceptionS tate& exceptionState)
197 { 197 {
198 if (!sw || !sh) { 198 if (!sw || !sh) {
199 exceptionState.throwDOMException(IndexSizeError, String::format("The sou rce %s provided is 0.", sw ? "height" : "width")); 199 exceptionState.throwDOMException(IndexSizeError, String::format("The sou rce %s provided is 0.", sw ? "height" : "width"));
200 return ScriptPromise(); 200 return ScriptPromise();
201 } 201 }
202 RefPtrWillBeRawPtr<ImageBitmapLoader> loader = ImageBitmapFactories::ImageBi tmapLoader::create(from(eventTarget), eventTarget.executionContext(), IntRect(sx , sy, sw, sh)); 202 RefPtrWillBeRawPtr<ImageBitmapLoader> loader = ImageBitmapFactories::ImageBi tmapLoader::create(from(eventTarget), IntRect(sx, sy, sw, sh), scriptState);
203 ScriptPromise promise = loader->promise(); 203 ScriptPromise promise = loader->promise();
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(ScriptState* scriptState, EventTarget& eventTarget, ImageData* data, ExceptionState& exceptionState) 209 ScriptPromise ImageBitmapFactories::createImageBitmap(ScriptState* scriptState, EventTarget& eventTarget, ImageData* data, ExceptionState& exceptionState)
210 { 210 {
211 return createImageBitmap(scriptState, eventTarget, data, 0, 0, data->width() , data->height(), exceptionState); 211 return createImageBitmap(scriptState, eventTarget, data, 0, 0, data->width() , data->height(), exceptionState);
212 } 212 }
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
265 { 265 {
266 m_pendingLoaders.add(loader); 266 m_pendingLoaders.add(loader);
267 } 267 }
268 268
269 void ImageBitmapFactories::didFinishLoading(ImageBitmapLoader* loader) 269 void ImageBitmapFactories::didFinishLoading(ImageBitmapLoader* loader)
270 { 270 {
271 ASSERT(m_pendingLoaders.contains(loader)); 271 ASSERT(m_pendingLoaders.contains(loader));
272 m_pendingLoaders.remove(loader); 272 m_pendingLoaders.remove(loader);
273 } 273 }
274 274
275 ImageBitmapFactories::ImageBitmapLoader::ImageBitmapLoader(ImageBitmapFactories& factory, ExecutionContext* context, const IntRect& cropRect) 275 ImageBitmapFactories::ImageBitmapLoader::ImageBitmapLoader(ImageBitmapFactories& factory, const IntRect& cropRect, ScriptState* scriptState)
276 : m_loader(FileReaderLoader::ReadAsArrayBuffer, this) 276 : m_loader(FileReaderLoader::ReadAsArrayBuffer, this)
277 , m_factory(&factory) 277 , m_factory(&factory)
278 , m_resolver(ScriptPromiseResolverWithContext::create(ScriptState::current(t oIsolate(context)))) 278 , m_resolver(ScriptPromiseResolverWithContext::create(scriptState))
279 , m_cropRect(cropRect) 279 , m_cropRect(cropRect)
280 { 280 {
281 } 281 }
282 282
283 void ImageBitmapFactories::ImageBitmapLoader::loadBlobAsync(ExecutionContext* co ntext, Blob* blob) 283 void ImageBitmapFactories::ImageBitmapLoader::loadBlobAsync(ExecutionContext* co ntext, Blob* blob)
284 { 284 {
285 m_loader.start(context, blob->blobDataHandle()); 285 m_loader.start(context, blob->blobDataHandle());
286 } 286 }
287 287
288 void ImageBitmapFactories::trace(Visitor* visitor) 288 void ImageBitmapFactories::trace(Visitor* visitor)
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
333 { 333 {
334 rejectPromise(); 334 rejectPromise();
335 } 335 }
336 336
337 void ImageBitmapFactories::ImageBitmapLoader::trace(Visitor* visitor) 337 void ImageBitmapFactories::ImageBitmapLoader::trace(Visitor* visitor)
338 { 338 {
339 visitor->trace(m_factory); 339 visitor->trace(m_factory);
340 } 340 }
341 341
342 } // namespace WebCore 342 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/modules/imagebitmap/ImageBitmapFactories.h ('k') | Source/modules/push_messaging/PushManager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698