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

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

Issue 190183003: Oilpan: move ImageBitmap to the oilpan heap. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Control image resource lifetimes in tests using explicit GCs 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
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 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 return IntSize(); 56 return IntSize();
57 } 57 }
58 58
59 static IntSize sizeFor(HTMLVideoElement* video) 59 static IntSize sizeFor(HTMLVideoElement* video)
60 { 60 {
61 if (MediaPlayer* player = video->player()) 61 if (MediaPlayer* player = video->player())
62 return player->naturalSize(); 62 return player->naturalSize();
63 return IntSize(); 63 return IntSize();
64 } 64 }
65 65
66 static ScriptPromise fulfillImageBitmap(ExecutionContext* context, PassRefPtr<Im ageBitmap> imageBitmap) 66 static ScriptPromise fulfillImageBitmap(ExecutionContext* context, PassRefPtrWil lBeRawPtr<ImageBitmap> 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);
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after
335 RefPtr<Image> image = BitmapImage::create(imageSkia); 335 RefPtr<Image> image = BitmapImage::create(imageSkia);
336 if (!image->width() || !image->height()) { 336 if (!image->width() || !image->height()) {
337 rejectPromise(); 337 rejectPromise();
338 return; 338 return;
339 } 339 }
340 if (!m_cropRect.width() && !m_cropRect.height()) { 340 if (!m_cropRect.width() && !m_cropRect.height()) {
341 // No cropping variant was called. 341 // No cropping variant was called.
342 m_cropRect = IntRect(IntPoint(), image->size()); 342 m_cropRect = IntRect(IntPoint(), image->size());
343 } 343 }
344 344
345 RefPtr<ImageBitmap> imageBitmap = ImageBitmap::create(image.get(), m_cropRec t); 345 RefPtrWillBeRawPtr<ImageBitmap> imageBitmap = ImageBitmap::create(image.get( ), m_cropRect);
346 ScriptScope scope(m_scriptState); 346 ScriptScope scope(m_scriptState);
347 m_resolver->resolve(imageBitmap.release()); 347 m_resolver->resolve(imageBitmap.release());
348 m_factory->didFinishLoading(this); 348 m_factory->didFinishLoading(this);
349 } 349 }
350 350
351 void ImageBitmapFactories::ImageBitmapLoader::didFail(FileError::ErrorCode) 351 void ImageBitmapFactories::ImageBitmapLoader::didFail(FileError::ErrorCode)
352 { 352 {
353 rejectPromise(); 353 rejectPromise();
354 } 354 }
355 355
356 ImageBitmapFactories& WorkerGlobalScopeImageBitmapFactories::fromInternal(Worker GlobalScope& object) 356 ImageBitmapFactories& WorkerGlobalScopeImageBitmapFactories::fromInternal(Worker GlobalScope& object)
357 { 357 {
358 WorkerGlobalScopeImageBitmapFactories* supplement = static_cast<WorkerGlobal ScopeImageBitmapFactories*>(WillBeHeapSupplement<WorkerGlobalScope>::from(object , ImageBitmapFactories::supplementName())); 358 WorkerGlobalScopeImageBitmapFactories* supplement = static_cast<WorkerGlobal ScopeImageBitmapFactories*>(WillBeHeapSupplement<WorkerGlobalScope>::from(object , ImageBitmapFactories::supplementName()));
359 if (!supplement) { 359 if (!supplement) {
360 supplement = new WorkerGlobalScopeImageBitmapFactories(); 360 supplement = new WorkerGlobalScopeImageBitmapFactories();
361 WillBeHeapSupplement<WorkerGlobalScope>::provideTo(object, ImageBitmapFa ctories::supplementName(), adoptPtrWillBeNoop(supplement)); 361 WillBeHeapSupplement<WorkerGlobalScope>::provideTo(object, ImageBitmapFa ctories::supplementName(), adoptPtrWillBeNoop(supplement));
362 } 362 }
363 return *supplement; 363 return *supplement;
364 } 364 }
365 365
366 void WorkerGlobalScopeImageBitmapFactories::trace(Visitor*) 366 void WorkerGlobalScopeImageBitmapFactories::trace(Visitor*)
367 { 367 {
368 } 368 }
369 369
370 } // namespace WebCore 370 } // namespace WebCore
OLDNEW
« Source/core/loader/ImageLoader.h ('K') | « Source/core/loader/ImageLoader.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698