OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "modules/shapedetection/ShapeDetector.h" | 5 #include "modules/shapedetection/ShapeDetector.h" |
6 | 6 |
7 #include "core/dom/DOMException.h" | 7 #include "core/dom/DOMException.h" |
8 #include "core/dom/Document.h" | 8 #include "core/dom/Document.h" |
9 #include "core/dom/ExecutionContext.h" | |
10 #include "core/frame/ImageBitmap.h" | 9 #include "core/frame/ImageBitmap.h" |
11 #include "core/frame/LocalFrame.h" | 10 #include "core/frame/LocalFrame.h" |
12 #include "core/geometry/DOMRect.h" | 11 #include "core/geometry/DOMRect.h" |
13 #include "core/html/HTMLImageElement.h" | 12 #include "core/html/HTMLImageElement.h" |
14 #include "core/html/HTMLVideoElement.h" | 13 #include "core/html/HTMLVideoElement.h" |
15 #include "core/html/ImageData.h" | 14 #include "core/html/ImageData.h" |
16 #include "core/loader/resource/ImageResourceContent.h" | 15 #include "core/loader/resource/ImageResourceContent.h" |
17 #include "platform/graphics/Image.h" | 16 #include "platform/graphics/Image.h" |
18 #include "platform/wtf/CheckedNumeric.h" | 17 #include "platform/wtf/CheckedNumeric.h" |
19 #include "third_party/skia/include/core/SkImage.h" | 18 #include "third_party/skia/include/core/SkImage.h" |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
71 } else if (image_source.isOffscreenCanvas()) { | 70 } else if (image_source.isOffscreenCanvas()) { |
72 canvas_image_source = image_source.getAsOffscreenCanvas(); | 71 canvas_image_source = image_source.getAsOffscreenCanvas(); |
73 } else { | 72 } else { |
74 NOTREACHED() << "Unsupported CanvasImageSource"; | 73 NOTREACHED() << "Unsupported CanvasImageSource"; |
75 resolver->Reject( | 74 resolver->Reject( |
76 DOMException::Create(kNotSupportedError, "Unsupported source.")); | 75 DOMException::Create(kNotSupportedError, "Unsupported source.")); |
77 return promise; | 76 return promise; |
78 } | 77 } |
79 | 78 |
80 if (canvas_image_source->WouldTaintOrigin( | 79 if (canvas_image_source->WouldTaintOrigin( |
81 ExecutionContext::From(script_state)->GetSecurityOrigin())) { | 80 script_state->GetExecutionContext()->GetSecurityOrigin())) { |
82 resolver->Reject( | 81 resolver->Reject( |
83 DOMException::Create(kSecurityError, "Source would taint origin.")); | 82 DOMException::Create(kSecurityError, "Source would taint origin.")); |
84 return promise; | 83 return promise; |
85 } | 84 } |
86 | 85 |
87 if (image_source.isHTMLImageElement()) { | 86 if (image_source.isHTMLImageElement()) { |
88 return DetectShapesOnImageElement(resolver, | 87 return DetectShapesOnImageElement(resolver, |
89 image_source.getAsHTMLImageElement()); | 88 image_source.getAsHTMLImageElement()); |
90 } | 89 } |
91 | 90 |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
231 kInvalidStateError, | 230 kInvalidStateError, |
232 "Failed to read pixels: Unable to decompress or unsupported format.")); | 231 "Failed to read pixels: Unable to decompress or unsupported format.")); |
233 return promise; | 232 return promise; |
234 } | 233 } |
235 | 234 |
236 return DoDetect(resolver, std::move(shared_buffer_handle), | 235 return DoDetect(resolver, std::move(shared_buffer_handle), |
237 img->naturalWidth(), img->naturalHeight()); | 236 img->naturalWidth(), img->naturalHeight()); |
238 } | 237 } |
239 | 238 |
240 } // namespace blink | 239 } // namespace blink |
OLD | NEW |