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

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

Issue 171333003: Pass implementation object to supplemental classes by reference (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Rebase Created 6 years, 10 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 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
64 } 64 }
65 65
66 static ScriptPromise fulfillImageBitmap(ExecutionContext* context, PassRefPtr<Im ageBitmap> imageBitmap) 66 static ScriptPromise fulfillImageBitmap(ExecutionContext* context, PassRefPtr<Im ageBitmap> imageBitmap)
67 { 67 {
68 ScriptPromise promise = ScriptPromise::createPending(context); 68 ScriptPromise promise = ScriptPromise::createPending(context);
69 RefPtr<ScriptPromiseResolver> resolver = ScriptPromiseResolver::create(promi se, context); 69 RefPtr<ScriptPromiseResolver> resolver = ScriptPromiseResolver::create(promi se, context);
70 resolver->resolve(imageBitmap); 70 resolver->resolve(imageBitmap);
71 return promise; 71 return promise;
72 } 72 }
73 73
74 ScriptPromise ImageBitmapFactories::createImageBitmap(EventTarget* eventTarget, HTMLImageElement* image, ExceptionState& exceptionState) 74 ScriptPromise ImageBitmapFactories::createImageBitmap(EventTarget& eventTarget, HTMLImageElement* image, ExceptionState& exceptionState)
75 { 75 {
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.throwTypeError("The image element provided is invalid."); 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.throwDOMException(InvalidStateError, "No image can be ret rieved from the provided element."); 90 exceptionState.throwDOMException(InvalidStateError, "No image can be ret rieved from the provided element.");
91 return ScriptPromise(); 91 return ScriptPromise();
92 } 92 }
93 if (image->cachedImage()->image()->isSVGImage()) { 93 if (image->cachedImage()->image()->isSVGImage()) {
94 exceptionState.throwDOMException(InvalidStateError, "The image element c ontains an SVG image, which is unsupported."); 94 exceptionState.throwDOMException(InvalidStateError, "The image element c ontains an SVG image, which is unsupported.");
95 return ScriptPromise(); 95 return ScriptPromise();
96 } 96 }
97 if (!sw || !sh) { 97 if (!sw || !sh) {
98 exceptionState.throwDOMException(IndexSizeError, String::format("The sou rce %s provided is 0.", sw ? "height" : "width")); 98 exceptionState.throwDOMException(IndexSizeError, String::format("The sou rce %s provided is 0.", sw ? "height" : "width"));
99 return ScriptPromise(); 99 return ScriptPromise();
100 } 100 }
101 if (!image->cachedImage()->image()->currentFrameHasSingleSecurityOrigin()) { 101 if (!image->cachedImage()->image()->currentFrameHasSingleSecurityOrigin()) {
102 exceptionState.throwSecurityError("The source image contains image data from multiple origins."); 102 exceptionState.throwSecurityError("The source image contains image data from multiple origins.");
103 return ScriptPromise(); 103 return ScriptPromise();
104 } 104 }
105 if (!image->cachedImage()->passesAccessControlCheck(eventTarget->toDOMWindow ()->document()->securityOrigin()) && eventTarget->toDOMWindow()->document()->sec urityOrigin()->taintsCanvas(image->src())) { 105 if (!image->cachedImage()->passesAccessControlCheck(eventTarget.toDOMWindow( )->document()->securityOrigin()) && eventTarget.toDOMWindow()->document()->secur ityOrigin()->taintsCanvas(image->src())) {
106 exceptionState.throwSecurityError("Cross-origin access to the source ima ge is denied."); 106 exceptionState.throwSecurityError("Cross-origin access to the source ima ge is denied.");
107 return ScriptPromise(); 107 return ScriptPromise();
108 } 108 }
109 // FIXME: make ImageBitmap creation asynchronous crbug.com/258082 109 // FIXME: make ImageBitmap creation asynchronous crbug.com/258082
110 return fulfillImageBitmap(eventTarget->executionContext(), ImageBitmap::crea te(image, IntRect(sx, sy, sw, sh))); 110 return fulfillImageBitmap(eventTarget.executionContext(), ImageBitmap::creat e(image, IntRect(sx, sy, sw, sh)));
111 } 111 }
112 112
113 ScriptPromise ImageBitmapFactories::createImageBitmap(EventTarget* eventTarget, HTMLVideoElement* video, ExceptionState& exceptionState) 113 ScriptPromise ImageBitmapFactories::createImageBitmap(EventTarget& eventTarget, HTMLVideoElement* video, ExceptionState& exceptionState)
114 { 114 {
115 IntSize s = sizeFor(video); 115 IntSize s = sizeFor(video);
116 return createImageBitmap(eventTarget, video, 0, 0, s.width(), s.height(), ex ceptionState); 116 return createImageBitmap(eventTarget, video, 0, 0, s.width(), s.height(), ex ceptionState);
117 } 117 }
118 118
119 ScriptPromise ImageBitmapFactories::createImageBitmap(EventTarget* eventTarget, HTMLVideoElement* video, int sx, int sy, int sw, int sh, ExceptionState& excepti onState) 119 ScriptPromise ImageBitmapFactories::createImageBitmap(EventTarget& eventTarget, HTMLVideoElement* video, int sx, int sy, int sw, int sh, ExceptionState& excepti onState)
120 { 120 {
121 // This variant does not work in worker threads. 121 // This variant does not work in worker threads.
122 ASSERT(eventTarget->toDOMWindow()); 122 ASSERT(eventTarget.toDOMWindow());
123 123
124 if (!video) { 124 if (!video) {
125 exceptionState.throwTypeError("The video element provided is invalid."); 125 exceptionState.throwTypeError("The video element provided is invalid.");
126 return ScriptPromise(); 126 return ScriptPromise();
127 } 127 }
128 if (!video->player()) { 128 if (!video->player()) {
129 exceptionState.throwDOMException(InvalidStateError, "No player can be re trieved from the provided video element."); 129 exceptionState.throwDOMException(InvalidStateError, "No player can be re trieved from the provided video element.");
130 return ScriptPromise(); 130 return ScriptPromise();
131 } 131 }
132 if (video->networkState() == HTMLMediaElement::NETWORK_EMPTY) { 132 if (video->networkState() == HTMLMediaElement::NETWORK_EMPTY) {
133 exceptionState.throwDOMException(InvalidStateError, "The provided elemen t has not retrieved data."); 133 exceptionState.throwDOMException(InvalidStateError, "The provided elemen t has not retrieved data.");
134 return ScriptPromise(); 134 return ScriptPromise();
135 } 135 }
136 if (video->player()->readyState() <= MediaPlayer::HaveMetadata) { 136 if (video->player()->readyState() <= MediaPlayer::HaveMetadata) {
137 exceptionState.throwDOMException(InvalidStateError, "The provided elemen t's player has no current data."); 137 exceptionState.throwDOMException(InvalidStateError, "The provided elemen t's player has no current data.");
138 return ScriptPromise(); 138 return ScriptPromise();
139 } 139 }
140 if (!sw || !sh) { 140 if (!sw || !sh) {
141 exceptionState.throwDOMException(IndexSizeError, String::format("The sou rce %s provided is 0.", sw ? "height" : "width")); 141 exceptionState.throwDOMException(IndexSizeError, String::format("The sou rce %s provided is 0.", sw ? "height" : "width"));
142 return ScriptPromise(); 142 return ScriptPromise();
143 } 143 }
144 if (!video->hasSingleSecurityOrigin()) { 144 if (!video->hasSingleSecurityOrigin()) {
145 exceptionState.throwSecurityError("The source video contains image data from multiple origins."); 145 exceptionState.throwSecurityError("The source video contains image data from multiple origins.");
146 return ScriptPromise(); 146 return ScriptPromise();
147 } 147 }
148 if (!video->player()->didPassCORSAccessCheck() && eventTarget->toDOMWindow() ->document()->securityOrigin()->taintsCanvas(video->currentSrc())) { 148 if (!video->player()->didPassCORSAccessCheck() && eventTarget.toDOMWindow()- >document()->securityOrigin()->taintsCanvas(video->currentSrc())) {
149 exceptionState.throwSecurityError("Cross-origin access to the source vid eo is denied."); 149 exceptionState.throwSecurityError("Cross-origin access to the source vid eo is denied.");
150 return ScriptPromise(); 150 return ScriptPromise();
151 } 151 }
152 // FIXME: make ImageBitmap creation asynchronous crbug.com/258082 152 // FIXME: make ImageBitmap creation asynchronous crbug.com/258082
153 return fulfillImageBitmap(eventTarget->executionContext(), ImageBitmap::crea te(video, IntRect(sx, sy, sw, sh))); 153 return fulfillImageBitmap(eventTarget.executionContext(), ImageBitmap::creat e(video, IntRect(sx, sy, sw, sh)));
154 } 154 }
155 155
156 ScriptPromise ImageBitmapFactories::createImageBitmap(EventTarget* eventTarget, CanvasRenderingContext2D* context, ExceptionState& exceptionState) 156 ScriptPromise ImageBitmapFactories::createImageBitmap(EventTarget& eventTarget, CanvasRenderingContext2D* context, ExceptionState& exceptionState)
157 { 157 {
158 return createImageBitmap(eventTarget, context->canvas(), exceptionState); 158 return createImageBitmap(eventTarget, context->canvas(), exceptionState);
159 } 159 }
160 160
161 ScriptPromise ImageBitmapFactories::createImageBitmap(EventTarget* eventTarget, CanvasRenderingContext2D* context, int sx, int sy, int sw, int sh, ExceptionStat e& exceptionState) 161 ScriptPromise ImageBitmapFactories::createImageBitmap(EventTarget& eventTarget, CanvasRenderingContext2D* context, int sx, int sy, int sw, int sh, ExceptionStat e& exceptionState)
162 { 162 {
163 return createImageBitmap(eventTarget, context->canvas(), sx, sy, sw, sh, exc eptionState); 163 return createImageBitmap(eventTarget, context->canvas(), sx, sy, sw, sh, exc eptionState);
164 } 164 }
165 165
166 ScriptPromise ImageBitmapFactories::createImageBitmap(EventTarget* eventTarget, HTMLCanvasElement* canvas, ExceptionState& exceptionState) 166 ScriptPromise ImageBitmapFactories::createImageBitmap(EventTarget& eventTarget, HTMLCanvasElement* canvas, ExceptionState& exceptionState)
167 { 167 {
168 return createImageBitmap(eventTarget, canvas, 0, 0, canvas->width(), canvas- >height(), exceptionState); 168 return createImageBitmap(eventTarget, canvas, 0, 0, canvas->width(), canvas- >height(), exceptionState);
169 } 169 }
170 170
171 ScriptPromise ImageBitmapFactories::createImageBitmap(EventTarget* eventTarget, HTMLCanvasElement* canvas, int sx, int sy, int sw, int sh, ExceptionState& excep tionState) 171 ScriptPromise ImageBitmapFactories::createImageBitmap(EventTarget& eventTarget, HTMLCanvasElement* canvas, int sx, int sy, int sw, int sh, ExceptionState& excep tionState)
172 { 172 {
173 // This variant does not work in worker threads. 173 // This variant does not work in worker threads.
174 ASSERT(eventTarget->toDOMWindow()); 174 ASSERT(eventTarget.toDOMWindow());
175 175
176 if (!canvas) { 176 if (!canvas) {
177 exceptionState.throwTypeError("The canvas element provided is invalid.") ; 177 exceptionState.throwTypeError("The canvas element provided is invalid.") ;
178 return ScriptPromise(); 178 return ScriptPromise();
179 } 179 }
180 if (!canvas->originClean()) { 180 if (!canvas->originClean()) {
181 exceptionState.throwSecurityError("The canvas element provided is tainte d with cross-origin data."); 181 exceptionState.throwSecurityError("The canvas element provided is tainte d with cross-origin data.");
182 return ScriptPromise(); 182 return ScriptPromise();
183 } 183 }
184 if (!sw || !sh) { 184 if (!sw || !sh) {
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::crea te(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.throwDOMException(TypeError, "The blob provided is invali d.");
196 return ScriptPromise(); 196 return ScriptPromise();
197 } 197 }
198 ScriptPromise promise = ScriptPromise::createPending(eventTarget->executionC ontext()); 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.throwDOMException(TypeError, "The blob provided is invali d.");
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->executionC ontext()); 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);
220 loader->loadBlobAsync(eventTarget->executionContext(), blob); 220 loader->loadBlobAsync(eventTarget.executionContext(), blob);
221 return promise; 221 return promise;
222 } 222 }
223 223
224 ScriptPromise ImageBitmapFactories::createImageBitmap(EventTarget* eventTarget, ImageData* data, ExceptionState& exceptionState) 224 ScriptPromise ImageBitmapFactories::createImageBitmap(EventTarget& eventTarget, ImageData* data, ExceptionState& exceptionState)
225 { 225 {
226 return createImageBitmap(eventTarget, data, 0, 0, data->width(), data->heigh t(), exceptionState); 226 return createImageBitmap(eventTarget, data, 0, 0, data->width(), data->heigh t(), exceptionState);
227 } 227 }
228 228
229 ScriptPromise ImageBitmapFactories::createImageBitmap(EventTarget* eventTarget, ImageData* data, int sx, int sy, int sw, int sh, ExceptionState& exceptionState) 229 ScriptPromise ImageBitmapFactories::createImageBitmap(EventTarget& eventTarget, ImageData* data, int sx, int sy, int sw, int sh, ExceptionState& exceptionState)
230 { 230 {
231 if (!data) { 231 if (!data) {
232 exceptionState.throwTypeError("The ImageData provided is invalid."); 232 exceptionState.throwTypeError("The ImageData provided is invalid.");
233 return ScriptPromise(); 233 return ScriptPromise();
234 } 234 }
235 if (!sw || !sh) { 235 if (!sw || !sh) {
236 exceptionState.throwDOMException(IndexSizeError, String::format("The sou rce %s provided is 0.", sw ? "height" : "width")); 236 exceptionState.throwDOMException(IndexSizeError, String::format("The sou rce %s provided is 0.", sw ? "height" : "width"));
237 return ScriptPromise(); 237 return ScriptPromise();
238 } 238 }
239 // FIXME: make ImageBitmap creation asynchronous crbug.com/258082 239 // FIXME: make ImageBitmap creation asynchronous crbug.com/258082
240 return fulfillImageBitmap(eventTarget->executionContext(), ImageBitmap::crea te(data, IntRect(sx, sy, sw, sh))); 240 return fulfillImageBitmap(eventTarget.executionContext(), ImageBitmap::creat e(data, IntRect(sx, sy, sw, sh)));
241 } 241 }
242 242
243 ScriptPromise ImageBitmapFactories::createImageBitmap(EventTarget* eventTarget, ImageBitmap* bitmap, ExceptionState& exceptionState) 243 ScriptPromise ImageBitmapFactories::createImageBitmap(EventTarget& eventTarget, ImageBitmap* bitmap, ExceptionState& exceptionState)
244 { 244 {
245 return createImageBitmap(eventTarget, bitmap, 0, 0, bitmap->width(), bitmap- >height(), exceptionState); 245 return createImageBitmap(eventTarget, bitmap, 0, 0, bitmap->width(), bitmap- >height(), exceptionState);
246 } 246 }
247 247
248 ScriptPromise ImageBitmapFactories::createImageBitmap(EventTarget* eventTarget, ImageBitmap* bitmap, int sx, int sy, int sw, int sh, ExceptionState& exceptionSt ate) 248 ScriptPromise ImageBitmapFactories::createImageBitmap(EventTarget& eventTarget, ImageBitmap* bitmap, int sx, int sy, int sw, int sh, ExceptionState& exceptionSt ate)
249 { 249 {
250 if (!bitmap) { 250 if (!bitmap) {
251 exceptionState.throwTypeError("The ImageBitmap provided is invalid."); 251 exceptionState.throwTypeError("The ImageBitmap provided is invalid.");
252 return ScriptPromise(); 252 return ScriptPromise();
253 } 253 }
254 if (!sw || !sh) { 254 if (!sw || !sh) {
255 exceptionState.throwDOMException(IndexSizeError, String::format("The sou rce %s provided is 0.", sw ? "height" : "width")); 255 exceptionState.throwDOMException(IndexSizeError, String::format("The sou rce %s provided is 0.", sw ? "height" : "width"));
256 return ScriptPromise(); 256 return ScriptPromise();
257 } 257 }
258 // FIXME: make ImageBitmap creation asynchronous crbug.com/258082 258 // FIXME: make ImageBitmap creation asynchronous crbug.com/258082
259 return fulfillImageBitmap(eventTarget->executionContext(), ImageBitmap::crea te(bitmap, IntRect(sx, sy, sw, sh))); 259 return fulfillImageBitmap(eventTarget.executionContext(), ImageBitmap::creat e(bitmap, IntRect(sx, sy, sw, sh)));
260 } 260 }
261 261
262 const char* ImageBitmapFactories::supplementName() 262 const char* ImageBitmapFactories::supplementName()
263 { 263 {
264 return "ImageBitmapFactories"; 264 return "ImageBitmapFactories";
265 } 265 }
266 266
267 ImageBitmapFactories* ImageBitmapFactories::from(EventTarget* eventTarget) 267 ImageBitmapFactories& ImageBitmapFactories::from(EventTarget& eventTarget)
268 { 268 {
269 if (DOMWindow* window = eventTarget->toDOMWindow()) 269 if (DOMWindow* window = eventTarget.toDOMWindow())
270 return fromInternal(window); 270 return fromInternal(*window);
271 271
272 ASSERT(eventTarget->executionContext()->isWorkerGlobalScope()); 272 ASSERT(eventTarget.executionContext()->isWorkerGlobalScope());
273 return fromInternal(toWorkerGlobalScope(eventTarget->executionContext())); 273 return fromInternal(*toWorkerGlobalScope(eventTarget.executionContext()));
274 } 274 }
275 275
276 template <class T> 276 template <class T>
277 ImageBitmapFactories* ImageBitmapFactories::fromInternal(T* object) 277 ImageBitmapFactories& ImageBitmapFactories::fromInternal(T& object)
278 { 278 {
279 ImageBitmapFactories* supplement = static_cast<ImageBitmapFactories*>(Supple ment<T>::from(object, supplementName())); 279 ImageBitmapFactories* supplement = static_cast<ImageBitmapFactories*>(Supple ment<T>::from(object, supplementName()));
280 if (!supplement) { 280 if (!supplement) {
281 supplement = new ImageBitmapFactories(); 281 supplement = new ImageBitmapFactories();
282 Supplement<T>::provideTo(object, supplementName(), adoptPtr(supplement)) ; 282 Supplement<T>::provideTo(object, supplementName(), adoptPtr(supplement)) ;
283 } 283 }
284 return supplement; 284 return *supplement;
285 } 285 }
286 286
287 void ImageBitmapFactories::addLoader(PassRefPtr<ImageBitmapLoader> loader) 287 void ImageBitmapFactories::addLoader(PassRefPtr<ImageBitmapLoader> loader)
288 { 288 {
289 m_pendingLoaders.add(loader); 289 m_pendingLoaders.add(loader);
290 } 290 }
291 291
292 void ImageBitmapFactories::didFinishLoading(ImageBitmapLoader* loader) 292 void ImageBitmapFactories::didFinishLoading(ImageBitmapLoader* loader)
293 { 293 {
294 ASSERT(m_pendingLoaders.contains(loader)); 294 ASSERT(m_pendingLoaders.contains(loader));
295 m_pendingLoaders.remove(loader); 295 m_pendingLoaders.remove(loader);
296 } 296 }
297 297
298 ImageBitmapFactories::ImageBitmapLoader::ImageBitmapLoader(ImageBitmapFactories* factory, PassRefPtr<ScriptPromiseResolver> resolver, const IntRect& cropRect) 298 ImageBitmapFactories::ImageBitmapLoader::ImageBitmapLoader(ImageBitmapFactories& factory, PassRefPtr<ScriptPromiseResolver> resolver, const IntRect& cropRect)
299 : m_scriptState(ScriptState::current()) 299 : m_scriptState(ScriptState::current())
300 , m_loader(FileReaderLoader::ReadAsArrayBuffer, this) 300 , m_loader(FileReaderLoader::ReadAsArrayBuffer, this)
301 , m_factory(factory) 301 , m_factory(&factory)
302 , m_resolver(resolver) 302 , m_resolver(resolver)
303 , m_cropRect(cropRect) 303 , m_cropRect(cropRect)
304 { 304 {
305 } 305 }
306 306
307 void ImageBitmapFactories::ImageBitmapLoader::loadBlobAsync(ExecutionContext* co ntext, Blob* blob) 307 void ImageBitmapFactories::ImageBitmapLoader::loadBlobAsync(ExecutionContext* co ntext, Blob* blob)
308 { 308 {
309 m_loader.start(context, blob->blobDataHandle()); 309 m_loader.start(context, blob->blobDataHandle());
310 } 310 }
311 311
(...skipping 36 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

Powered by Google App Engine
This is Rietveld 408576698