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

Side by Side Diff: third_party/WebKit/Source/core/inspector/InspectorDOMSnapshotAgent.h

Issue 2882193002: [devtools] Add DOMSnapshot domain for dom+layout+style snapshots. (Closed)
Patch Set: back to DOMSnapshot domain, with custom node types + traversal. Created 3 years, 6 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef InspectorDOMSnapshotAgent_h
6 #define InspectorDOMSnapshotAgent_h
7
8 #include "core/CSSPropertyNames.h"
9 #include "core/inspector/InspectorBaseAgent.h"
10 #include "core/inspector/protocol/DOMSnapshot.h"
11 #include "platform/wtf/HashMap.h"
12 #include "platform/wtf/Vector.h"
13
14 namespace blink {
15
16 class Element;
17 class InspectedFrames;
18 class Node;
19
20 class CORE_EXPORT InspectorDOMSnapshotAgent final
21 : public InspectorBaseAgent<protocol::DOMSnapshot::Metainfo> {
22 WTF_MAKE_NONCOPYABLE(InspectorDOMSnapshotAgent);
23
24 public:
25 static InspectorDOMSnapshotAgent* Create(InspectedFrames* inspected_frames) {
26 return new InspectorDOMSnapshotAgent(inspected_frames);
27 }
28
29 ~InspectorDOMSnapshotAgent() override;
30 DECLARE_VIRTUAL_TRACE();
31
32 protocol::Response getSnapshot(
33 std::unique_ptr<protocol::Array<String>> style_whitelist,
34 protocol::Maybe<int> depth,
35 protocol::Maybe<bool> pierce,
36 std::unique_ptr<protocol::Array<protocol::DOMSnapshot::DOMNode>>*
37 dom_nodes,
38 std::unique_ptr<protocol::Array<protocol::DOMSnapshot::LayoutTreeNode>>*
39 layout_tree_nodes,
40 std::unique_ptr<protocol::Array<protocol::DOMSnapshot::ComputedStyle>>*
41 computed_styles) override;
42
43 private:
44 explicit InspectorDOMSnapshotAgent(InspectedFrames*);
45
46 // Adds a DOMNode for the given Node to |dom_nodes_| and returns its index.
47 int VisitNode(Node*, int depth);
48 std::unique_ptr<protocol::Array<int>> VisitContainerChildren(Node* container,
49 int depth);
50 std::unique_ptr<protocol::Array<int>> VisitPseudoElements(Element* parent,
51 int depth);
52 std::unique_ptr<protocol::Array<protocol::DOMSnapshot::Attribute>>
53 BuildArrayForElementAttributes(Element*);
54
55 // Adds a LayoutTreeNode for the LayoutObject of the given Node to
56 // |layout_tree_nodes_| and returns its index. Returns -1 if the Node has no
57 // associated LayoutObject.
58 int VisitLayoutTreeNode(Node*, int node_index);
59
60 // Returns the index of the ComputedStyle in |computed_styles_| for the given
61 // Node. Adds a new ComputedStyle if necessary, but ensures no duplicates are
62 // added to |computed_styles_|. Returns -1 if the node has no values for
63 // styles in |style_whitelist_|.
64 int GetStyleIndexForNode(Node*);
65
66 struct VectorStringHashTraits;
67 using ComputedStylesMap = WTF::HashMap<Vector<String>,
68 int,
69 VectorStringHashTraits,
70 VectorStringHashTraits>;
71 using CSSPropertyWhitelist = Vector<std::pair<String, CSSPropertyID>>;
72
73 // State of current snapshot.
74 std::unique_ptr<protocol::Array<protocol::DOMSnapshot::DOMNode>> dom_nodes_;
75 std::unique_ptr<protocol::Array<protocol::DOMSnapshot::LayoutTreeNode>>
76 layout_tree_nodes_;
77 std::unique_ptr<protocol::Array<protocol::DOMSnapshot::ComputedStyle>>
78 computed_styles_;
79 bool pierce_ = false;
80 // Maps a style string vector to an index in |computed_styles_|. Used to avoid
81 // duplicate entries in |computed_styles_|.
82 std::unique_ptr<ComputedStylesMap> computed_styles_map_;
83 std::unique_ptr<Vector<std::pair<String, CSSPropertyID>>>
84 css_property_whitelist_;
85
86 Member<InspectedFrames> inspected_frames_;
87 };
88
89 } // namespace blink
90
91 #endif // !defined(InspectorDOMSnapshotAgent_h)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698