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 #ifndef HEADLESS_PUBLIC_UTIL_DOM_TREE_EXTRACTOR_H_ | 5 #ifndef HEADLESS_PUBLIC_UTIL_DOM_TREE_EXTRACTOR_H_ |
6 #define HEADLESS_PUBLIC_UTIL_DOM_TREE_EXTRACTOR_H_ | 6 #define HEADLESS_PUBLIC_UTIL_DOM_TREE_EXTRACTOR_H_ |
7 | 7 |
8 #include <unordered_map> | 8 #include <unordered_map> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
11 #include "base/macros.h" | 11 #include "base/macros.h" |
12 #include "headless/public/devtools/domains/css.h" | 12 #include "headless/public/devtools/domains/css.h" |
13 #include "headless/public/devtools/domains/dom.h" | 13 #include "headless/public/devtools/domains/dom.h" |
| 14 #include "headless/public/headless_export.h" |
14 | 15 |
15 namespace headless { | 16 namespace headless { |
16 class HeadlessDevToolsClient; | 17 class HeadlessDevToolsClient; |
17 | 18 |
18 // A utility class for extracting information from the DOM via DevTools. In | 19 // A utility class for extracting information from the DOM via DevTools. In |
19 // addition, it also extracts details of bounding boxes and layout text (NB the | 20 // addition, it also extracts details of bounding boxes and layout text (NB the |
20 // exact layout should not be regarded as stable, it's subject to change without | 21 // exact layout should not be regarded as stable, it's subject to change without |
21 // notice). | 22 // notice). |
22 class FlatDomTreeExtractor { | 23 class HEADLESS_EXPORT FlatDomTreeExtractor { |
23 public: | 24 public: |
24 explicit FlatDomTreeExtractor(HeadlessDevToolsClient* devtools_client); | 25 explicit FlatDomTreeExtractor(HeadlessDevToolsClient* devtools_client); |
25 ~FlatDomTreeExtractor(); | 26 ~FlatDomTreeExtractor(); |
26 | 27 |
27 using NodeId = int; | 28 using NodeId = int; |
28 using Index = size_t; | 29 using Index = size_t; |
29 | 30 |
30 class DomTree { | 31 class HEADLESS_EXPORT DomTree { |
31 public: | 32 public: |
32 DomTree(); | 33 DomTree(); |
33 DomTree(DomTree&& other); | 34 DomTree(DomTree&& other); |
34 ~DomTree(); | 35 ~DomTree(); |
35 | 36 |
36 // Flattened dom tree. The root node is always the first entry. | 37 // Flattened dom tree. The root node is always the first entry. |
37 std::vector<const dom::Node*> dom_nodes_; | 38 std::vector<const dom::Node*> dom_nodes_; |
38 | 39 |
39 // Map of node IDs to indexes into |dom_nodes_|. | 40 // Map of node IDs to indexes into |dom_nodes_|. |
40 std::unordered_map<NodeId, Index> node_id_to_index_; | 41 std::unordered_map<NodeId, Index> node_id_to_index_; |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
80 bool work_in_progress_; | 81 bool work_in_progress_; |
81 HeadlessDevToolsClient* devtools_client_; // NOT OWNED | 82 HeadlessDevToolsClient* devtools_client_; // NOT OWNED |
82 base::WeakPtrFactory<FlatDomTreeExtractor> weak_factory_; | 83 base::WeakPtrFactory<FlatDomTreeExtractor> weak_factory_; |
83 | 84 |
84 DISALLOW_COPY_AND_ASSIGN(FlatDomTreeExtractor); | 85 DISALLOW_COPY_AND_ASSIGN(FlatDomTreeExtractor); |
85 }; | 86 }; |
86 | 87 |
87 } // namespace headless | 88 } // namespace headless |
88 | 89 |
89 #endif // HEADLESS_PUBLIC_UTIL_DOM_TREE_EXTRACTOR_H_ | 90 #endif // HEADLESS_PUBLIC_UTIL_DOM_TREE_EXTRACTOR_H_ |
OLD | NEW |