| 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 283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 294 | 294 |
| 295 void ImageBitmapFactories::ImageBitmapLoader::didFinishLoading() | 295 void ImageBitmapFactories::ImageBitmapLoader::didFinishLoading() |
| 296 { | 296 { |
| 297 if (!m_loader.arrayBufferResult()) { | 297 if (!m_loader.arrayBufferResult()) { |
| 298 rejectPromise(); | 298 rejectPromise(); |
| 299 return; | 299 return; |
| 300 } | 300 } |
| 301 RefPtr<SharedBuffer> sharedBuffer = SharedBuffer::create((char*)m_loader.arr
ayBufferResult()->data(), m_loader.arrayBufferResult()->byteLength()); | 301 RefPtr<SharedBuffer> sharedBuffer = SharedBuffer::create((char*)m_loader.arr
ayBufferResult()->data(), m_loader.arrayBufferResult()->byteLength()); |
| 302 | 302 |
| 303 OwnPtr<ImageSource> source = adoptPtr(new ImageSource()); | 303 OwnPtr<ImageSource> source = adoptPtr(new ImageSource()); |
| 304 source->setData(sharedBuffer.get(), true); | 304 source->setData(*sharedBuffer, true); |
| 305 RefPtr<NativeImageSkia> imageSkia = source->createFrameAtIndex(0); | 305 RefPtr<NativeImageSkia> imageSkia = source->createFrameAtIndex(0); |
| 306 if (!imageSkia) { | 306 if (!imageSkia) { |
| 307 rejectPromise(); | 307 rejectPromise(); |
| 308 return; | 308 return; |
| 309 } | 309 } |
| 310 | 310 |
| 311 RefPtr<Image> image = BitmapImage::create(imageSkia); | 311 RefPtr<Image> image = BitmapImage::create(imageSkia); |
| 312 if (!image->width() || !image->height()) { | 312 if (!image->width() || !image->height()) { |
| 313 rejectPromise(); | 313 rejectPromise(); |
| 314 return; | 314 return; |
| 315 } | 315 } |
| 316 if (!m_cropRect.width() && !m_cropRect.height()) { | 316 if (!m_cropRect.width() && !m_cropRect.height()) { |
| 317 // No cropping variant was called. | 317 // No cropping variant was called. |
| 318 m_cropRect = IntRect(IntPoint(), image->size()); | 318 m_cropRect = IntRect(IntPoint(), image->size()); |
| 319 } | 319 } |
| 320 | 320 |
| 321 RefPtrWillBeRawPtr<ImageBitmap> imageBitmap = ImageBitmap::create(image.get(
), m_cropRect); | 321 RefPtrWillBeRawPtr<ImageBitmap> imageBitmap = ImageBitmap::create(image.get(
), m_cropRect); |
| 322 m_resolver->resolve(imageBitmap.release()); | 322 m_resolver->resolve(imageBitmap.release()); |
| 323 m_factory->didFinishLoading(this); | 323 m_factory->didFinishLoading(this); |
| 324 } | 324 } |
| 325 | 325 |
| 326 void ImageBitmapFactories::ImageBitmapLoader::didFail(FileError::ErrorCode) | 326 void ImageBitmapFactories::ImageBitmapLoader::didFail(FileError::ErrorCode) |
| 327 { | 327 { |
| 328 rejectPromise(); | 328 rejectPromise(); |
| 329 } | 329 } |
| 330 | 330 |
| 331 } // namespace WebCore | 331 } // namespace WebCore |
| OLD | NEW |