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

Side by Side Diff: third_party/WebKit/Source/core/imagebitmap/ImageBitmapFactories.cpp

Issue 2802813002: Adds SVGImageElement as a ImageBitmapSource (Closed)
Patch Set: merge Created 3 years, 8 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 27 matching lines...) Expand all
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"
58 59
59 namespace blink { 60 namespace blink {
60 61
61 static inline ImageBitmapSource* ToImageBitmapSourceInternal( 62 static inline ImageBitmapSource* ToImageBitmapSourceInternal(
62 const ImageBitmapSourceUnion& value, 63 const ImageBitmapSourceUnion& value,
63 ExceptionState& exception_state, 64 ExceptionState& exception_state,
64 const ImageBitmapOptions& options, 65 const ImageBitmapOptions& options,
65 bool has_crop_rect) { 66 bool has_crop_rect) {
67 HTMLAndSVGImageElementSource* image_element = nullptr;
66 if (value.isHTMLImageElement()) { 68 if (value.isHTMLImageElement()) {
67 HTMLImageElement* image_element = value.getAsHTMLImageElement(); 69 if (!(image_element = value.getAsHTMLImageElement()))
68 if (!image_element || !image_element->CachedImage()) { 70 return nullptr;
71 } else if (value.isSVGImageElement()) {
72 if (!(image_element = value.getAsSVGImageElement()))
73 return nullptr;
74 }
75 if (image_element) {
76 if (!image_element->CachedImage()) {
69 exception_state.ThrowDOMException( 77 exception_state.ThrowDOMException(
70 kInvalidStateError, 78 kInvalidStateError,
71 "No image can be retrieved from the provided element."); 79 "No image can be retrieved from the provided element.");
72 return nullptr; 80 return nullptr;
73 } 81 }
74 if (image_element->CachedImage()->GetImage()->IsSVGImage()) { 82 if (image_element->CachedImage()->GetImage()->IsSVGImage()) {
75 SVGImage* image = ToSVGImage(image_element->CachedImage()->GetImage()); 83 SVGImage* image = ToSVGImage(image_element->CachedImage()->GetImage());
76 if (!image->HasIntrinsicDimensions() && 84 if (!image->HasIntrinsicDimensions() &&
77 (!has_crop_rect && 85 (!has_crop_rect &&
78 (!options.hasResizeWidth() || !options.hasResizeHeight()))) { 86 (!options.hasResizeWidth() || !options.hasResizeHeight()))) {
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after
313 } 321 }
314 factory_->DidFinishLoading(this); 322 factory_->DidFinishLoading(this);
315 } 323 }
316 324
317 DEFINE_TRACE(ImageBitmapFactories::ImageBitmapLoader) { 325 DEFINE_TRACE(ImageBitmapFactories::ImageBitmapLoader) {
318 visitor->Trace(factory_); 326 visitor->Trace(factory_);
319 visitor->Trace(resolver_); 327 visitor->Trace(resolver_);
320 } 328 }
321 329
322 } // namespace blink 330 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698