| 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" |
| 9 #include "core/frame/ImageBitmap.h" | 10 #include "core/frame/ImageBitmap.h" |
| 10 #include "core/frame/LocalFrame.h" | 11 #include "core/frame/LocalFrame.h" |
| 11 #include "core/geometry/DOMRect.h" | 12 #include "core/geometry/DOMRect.h" |
| 12 #include "core/html/HTMLImageElement.h" | 13 #include "core/html/HTMLImageElement.h" |
| 13 #include "core/html/HTMLVideoElement.h" | 14 #include "core/html/HTMLVideoElement.h" |
| 14 #include "core/html/ImageData.h" | 15 #include "core/html/ImageData.h" |
| 15 #include "core/loader/resource/ImageResourceContent.h" | 16 #include "core/loader/resource/ImageResourceContent.h" |
| 16 #include "platform/graphics/Image.h" | 17 #include "platform/graphics/Image.h" |
| 17 #include "platform/wtf/CheckedNumeric.h" | 18 #include "platform/wtf/CheckedNumeric.h" |
| 18 #include "third_party/skia/include/core/SkImage.h" | 19 #include "third_party/skia/include/core/SkImage.h" |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 70 } else if (image_source.isOffscreenCanvas()) { | 71 } else if (image_source.isOffscreenCanvas()) { |
| 71 canvas_image_source = image_source.getAsOffscreenCanvas(); | 72 canvas_image_source = image_source.getAsOffscreenCanvas(); |
| 72 } else { | 73 } else { |
| 73 NOTREACHED() << "Unsupported CanvasImageSource"; | 74 NOTREACHED() << "Unsupported CanvasImageSource"; |
| 74 resolver->Reject( | 75 resolver->Reject( |
| 75 DOMException::Create(kNotSupportedError, "Unsupported source.")); | 76 DOMException::Create(kNotSupportedError, "Unsupported source.")); |
| 76 return promise; | 77 return promise; |
| 77 } | 78 } |
| 78 | 79 |
| 79 if (canvas_image_source->WouldTaintOrigin( | 80 if (canvas_image_source->WouldTaintOrigin( |
| 80 script_state->GetExecutionContext()->GetSecurityOrigin())) { | 81 ExecutionContext::From(script_state)->GetSecurityOrigin())) { |
| 81 resolver->Reject( | 82 resolver->Reject( |
| 82 DOMException::Create(kSecurityError, "Source would taint origin.")); | 83 DOMException::Create(kSecurityError, "Source would taint origin.")); |
| 83 return promise; | 84 return promise; |
| 84 } | 85 } |
| 85 | 86 |
| 86 if (image_source.isHTMLImageElement()) { | 87 if (image_source.isHTMLImageElement()) { |
| 87 return DetectShapesOnImageElement(resolver, | 88 return DetectShapesOnImageElement(resolver, |
| 88 image_source.getAsHTMLImageElement()); | 89 image_source.getAsHTMLImageElement()); |
| 89 } | 90 } |
| 90 | 91 |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 230 kInvalidStateError, | 231 kInvalidStateError, |
| 231 "Failed to read pixels: Unable to decompress or unsupported format.")); | 232 "Failed to read pixels: Unable to decompress or unsupported format.")); |
| 232 return promise; | 233 return promise; |
| 233 } | 234 } |
| 234 | 235 |
| 235 return DoDetect(resolver, std::move(shared_buffer_handle), | 236 return DoDetect(resolver, std::move(shared_buffer_handle), |
| 236 img->naturalWidth(), img->naturalHeight()); | 237 img->naturalWidth(), img->naturalHeight()); |
| 237 } | 238 } |
| 238 | 239 |
| 239 } // namespace blink | 240 } // namespace blink |
| OLD | NEW |