| OLD | NEW |
| 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 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 WorkerGlobalScopeImageBitmapFactories::fromInternal(*toWorkerGlobalSc
ope(eventTarget.executionContext())); |
| 274 } | 274 } |
| 275 | 275 |
| 276 template <class T> | 276 ImageBitmapFactories& ImageBitmapFactories::fromInternal(DOMWindow& object) |
| 277 ImageBitmapFactories& ImageBitmapFactories::fromInternal(T& object) | |
| 278 { | 277 { |
| 279 ImageBitmapFactories* supplement = static_cast<ImageBitmapFactories*>(Supple
ment<T>::from(object, supplementName())); | 278 ImageBitmapFactories* supplement = static_cast<ImageBitmapFactories*>(Supple
ment<DOMWindow>::from(object, supplementName())); |
| 280 if (!supplement) { | 279 if (!supplement) { |
| 281 supplement = new ImageBitmapFactories(); | 280 supplement = new ImageBitmapFactories(); |
| 282 Supplement<T>::provideTo(object, supplementName(), adoptPtr(supplement))
; | 281 Supplement<DOMWindow>::provideTo(object, supplementName(), adoptPtr(supp
lement)); |
| 283 } | 282 } |
| 284 return *supplement; | 283 return *supplement; |
| 285 } | 284 } |
| 286 | 285 |
| 287 void ImageBitmapFactories::addLoader(PassRefPtr<ImageBitmapLoader> loader) | 286 void ImageBitmapFactories::addLoader(PassRefPtr<ImageBitmapLoader> loader) |
| 288 { | 287 { |
| 289 m_pendingLoaders.add(loader); | 288 m_pendingLoaders.add(loader); |
| 290 } | 289 } |
| 291 | 290 |
| 292 void ImageBitmapFactories::didFinishLoading(ImageBitmapLoader* loader) | 291 void ImageBitmapFactories::didFinishLoading(ImageBitmapLoader* loader) |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 347 ScriptScope scope(m_scriptState); | 346 ScriptScope scope(m_scriptState); |
| 348 m_resolver->resolve(imageBitmap.release()); | 347 m_resolver->resolve(imageBitmap.release()); |
| 349 m_factory->didFinishLoading(this); | 348 m_factory->didFinishLoading(this); |
| 350 } | 349 } |
| 351 | 350 |
| 352 void ImageBitmapFactories::ImageBitmapLoader::didFail(FileError::ErrorCode) | 351 void ImageBitmapFactories::ImageBitmapLoader::didFail(FileError::ErrorCode) |
| 353 { | 352 { |
| 354 rejectPromise(); | 353 rejectPromise(); |
| 355 } | 354 } |
| 356 | 355 |
| 356 ImageBitmapFactories& WorkerGlobalScopeImageBitmapFactories::fromInternal(Worker
GlobalScope& object) |
| 357 { |
| 358 WorkerGlobalScopeImageBitmapFactories* supplement = static_cast<WorkerGlobal
ScopeImageBitmapFactories*>(WillBeHeapSupplement<WorkerGlobalScope>::from(object
, ImageBitmapFactories::supplementName())); |
| 359 if (!supplement) { |
| 360 supplement = new WorkerGlobalScopeImageBitmapFactories(); |
| 361 WillBeHeapSupplement<WorkerGlobalScope>::provideTo(object, ImageBitmapFa
ctories::supplementName(), adoptPtrWillBeNoop(supplement)); |
| 362 } |
| 363 return *supplement; |
| 364 } |
| 365 |
| 366 void WorkerGlobalScopeImageBitmapFactories::trace(Visitor*) |
| 367 { |
| 368 } |
| 369 |
| 357 } // namespace WebCore | 370 } // namespace WebCore |
| OLD | NEW |