OLD | NEW |
1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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/TextDetector.h" | 5 #include "modules/shapedetection/TextDetector.h" |
6 | 6 |
7 #include "core/dom/DOMException.h" | 7 #include "core/dom/DOMException.h" |
8 #include "core/dom/DOMRect.h" | 8 #include "core/dom/DOMRect.h" |
9 #include "core/frame/LocalFrame.h" | 9 #include "core/frame/LocalFrame.h" |
10 #include "core/html/canvas/CanvasImageSource.h" | 10 #include "core/html/canvas/CanvasImageSource.h" |
(...skipping 26 matching lines...) Expand all Loading... |
37 m_textServiceRequests.add(resolver); | 37 m_textServiceRequests.add(resolver); |
38 m_textService->Detect(std::move(sharedBufferHandle), imageWidth, imageHeight, | 38 m_textService->Detect(std::move(sharedBufferHandle), imageWidth, imageHeight, |
39 convertToBaseCallback(WTF::bind( | 39 convertToBaseCallback(WTF::bind( |
40 &TextDetector::onDetectText, wrapPersistent(this), | 40 &TextDetector::onDetectText, wrapPersistent(this), |
41 wrapPersistent(resolver)))); | 41 wrapPersistent(resolver)))); |
42 return promise; | 42 return promise; |
43 } | 43 } |
44 | 44 |
45 void TextDetector::onDetectText( | 45 void TextDetector::onDetectText( |
46 ScriptPromiseResolver* resolver, | 46 ScriptPromiseResolver* resolver, |
47 Vector<mojom::blink::TextDetectionResultPtr> textDetectionResults) { | 47 Vector<shape_detection::mojom::blink::TextDetectionResultPtr> |
| 48 textDetectionResults) { |
48 DCHECK(m_textServiceRequests.contains(resolver)); | 49 DCHECK(m_textServiceRequests.contains(resolver)); |
49 m_textServiceRequests.remove(resolver); | 50 m_textServiceRequests.remove(resolver); |
50 | 51 |
51 HeapVector<Member<DetectedText>> detectedText; | 52 HeapVector<Member<DetectedText>> detectedText; |
52 for (const auto& text : textDetectionResults) { | 53 for (const auto& text : textDetectionResults) { |
53 detectedText.append(DetectedText::create( | 54 detectedText.append(DetectedText::create( |
54 text->raw_value, | 55 text->raw_value, |
55 DOMRect::create(text->bounding_box->x, text->bounding_box->y, | 56 DOMRect::create(text->bounding_box->x, text->bounding_box->y, |
56 text->bounding_box->width, | 57 text->bounding_box->width, |
57 text->bounding_box->height))); | 58 text->bounding_box->height))); |
(...skipping 10 matching lines...) Expand all Loading... |
68 m_textServiceRequests.clear(); | 69 m_textServiceRequests.clear(); |
69 m_textService.reset(); | 70 m_textService.reset(); |
70 } | 71 } |
71 | 72 |
72 DEFINE_TRACE(TextDetector) { | 73 DEFINE_TRACE(TextDetector) { |
73 ShapeDetector::trace(visitor); | 74 ShapeDetector::trace(visitor); |
74 visitor->trace(m_textServiceRequests); | 75 visitor->trace(m_textServiceRequests); |
75 } | 76 } |
76 | 77 |
77 } // namespace blink | 78 } // namespace blink |
OLD | NEW |