Chromium Code Reviews| 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 27 matching lines...) Expand all Loading... | |
| 38 #include "core/fileapi/Blob.h" | 38 #include "core/fileapi/Blob.h" |
| 39 #include "core/frame/ImageBitmap.h" | 39 #include "core/frame/ImageBitmap.h" |
| 40 #include "core/frame/LocalDOMWindow.h" | 40 #include "core/frame/LocalDOMWindow.h" |
| 41 #include "core/frame/UseCounter.h" | 41 #include "core/frame/UseCounter.h" |
| 42 #include "core/html/HTMLCanvasElement.h" | 42 #include "core/html/HTMLCanvasElement.h" |
| 43 #include "core/html/HTMLImageElement.h" | 43 #include "core/html/HTMLImageElement.h" |
| 44 #include "core/html/HTMLVideoElement.h" | 44 #include "core/html/HTMLVideoElement.h" |
| 45 #include "core/html/ImageData.h" | 45 #include "core/html/ImageData.h" |
| 46 #include "core/imagebitmap/ImageBitmapOptions.h" | 46 #include "core/imagebitmap/ImageBitmapOptions.h" |
| 47 #include "core/offscreencanvas/OffscreenCanvas.h" | 47 #include "core/offscreencanvas/OffscreenCanvas.h" |
| 48 #include "core/svg/SVGImageElement.h" | |
| 48 #include "core/svg/graphics/SVGImage.h" | 49 #include "core/svg/graphics/SVGImage.h" |
| 49 #include "core/workers/WorkerGlobalScope.h" | 50 #include "core/workers/WorkerGlobalScope.h" |
| 50 #include "platform/CrossThreadFunctional.h" | 51 #include "platform/CrossThreadFunctional.h" |
| 51 #include "platform/SharedBuffer.h" | 52 #include "platform/SharedBuffer.h" |
| 52 #include "platform/image-decoders/ImageDecoder.h" | 53 #include "platform/image-decoders/ImageDecoder.h" |
| 53 #include "platform/threading/BackgroundTaskRunner.h" | 54 #include "platform/threading/BackgroundTaskRunner.h" |
| 54 #include "public/platform/Platform.h" | 55 #include "public/platform/Platform.h" |
| 55 #include "public/platform/WebThread.h" | 56 #include "public/platform/WebThread.h" |
| 56 #include "public/platform/WebTraceLocation.h" | 57 #include "public/platform/WebTraceLocation.h" |
| 57 #include "v8/include/v8.h" | 58 #include "v8/include/v8.h" |
| (...skipping 20 matching lines...) Expand all Loading... | |
| 78 (!options.hasResizeWidth() || !options.hasResizeHeight()))) { | 79 (!options.hasResizeWidth() || !options.hasResizeHeight()))) { |
| 79 exceptionState.throwDOMException( | 80 exceptionState.throwDOMException( |
| 80 InvalidStateError, | 81 InvalidStateError, |
| 81 "The image element contains an SVG image without intrinsic " | 82 "The image element contains an SVG image without intrinsic " |
| 82 "dimensions, and no resize options or crop region are specified."); | 83 "dimensions, and no resize options or crop region are specified."); |
| 83 return nullptr; | 84 return nullptr; |
| 84 } | 85 } |
| 85 } | 86 } |
| 86 return imageElement; | 87 return imageElement; |
| 87 } | 88 } |
| 89 if (value.isSVGImageElement()) { | |
| 90 SVGImageElement* imageElement = value.getAsSVGImageElement(); | |
| 91 if (!imageElement || !imageElement->cachedImage()) { | |
|
fs
2017/04/06 16:48:12
This sequence of code also looks very similar to t
fserb
2017/04/06 20:06:16
done
| |
| 92 exceptionState.throwDOMException( | |
| 93 InvalidStateError, | |
| 94 "No image can be retrieved from the provided element."); | |
| 95 return nullptr; | |
| 96 } | |
| 97 if (imageElement->cachedImage()->getImage()->isSVGImage()) { | |
| 98 SVGImage* image = toSVGImage(imageElement->cachedImage()->getImage()); | |
| 99 if (!image->hasIntrinsicDimensions() && | |
| 100 (!hasCropRect && | |
| 101 (!options.hasResizeWidth() || !options.hasResizeHeight()))) { | |
| 102 exceptionState.throwDOMException( | |
| 103 InvalidStateError, | |
| 104 "The image element contains an SVG image without intrinsic " | |
| 105 "dimensions, and no resize options or crop region are specified."); | |
| 106 return nullptr; | |
| 107 } | |
| 108 } | |
| 109 return imageElement; | |
| 110 } | |
| 88 if (value.isHTMLVideoElement()) | 111 if (value.isHTMLVideoElement()) |
| 89 return value.getAsHTMLVideoElement(); | 112 return value.getAsHTMLVideoElement(); |
| 90 if (value.isHTMLCanvasElement()) | 113 if (value.isHTMLCanvasElement()) |
| 91 return value.getAsHTMLCanvasElement(); | 114 return value.getAsHTMLCanvasElement(); |
| 92 if (value.isBlob()) | 115 if (value.isBlob()) |
| 93 return value.getAsBlob(); | 116 return value.getAsBlob(); |
| 94 if (value.isImageData()) | 117 if (value.isImageData()) |
| 95 return value.getAsImageData(); | 118 return value.getAsImageData(); |
| 96 if (value.isImageBitmap()) | 119 if (value.isImageBitmap()) |
| 97 return value.getAsImageBitmap(); | 120 return value.getAsImageBitmap(); |
| (...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 313 } | 336 } |
| 314 m_factory->didFinishLoading(this); | 337 m_factory->didFinishLoading(this); |
| 315 } | 338 } |
| 316 | 339 |
| 317 DEFINE_TRACE(ImageBitmapFactories::ImageBitmapLoader) { | 340 DEFINE_TRACE(ImageBitmapFactories::ImageBitmapLoader) { |
| 318 visitor->trace(m_factory); | 341 visitor->trace(m_factory); |
| 319 visitor->trace(m_resolver); | 342 visitor->trace(m_resolver); |
| 320 } | 343 } |
| 321 | 344 |
| 322 } // namespace blink | 345 } // namespace blink |
| OLD | NEW |