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

Side by Side Diff: ash/common/devtools/ash_devtools_css_agent.cc

Issue 2526103002: Add live updates for AshDevToolsCSSAgent (Closed)
Patch Set: Created 4 years 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
« no previous file with comments | « ash/common/devtools/ash_devtools_css_agent.h ('k') | components/ui_devtools/protocol.json » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "ash/common/devtools/ash_devtools_css_agent.h" 5 #include "ash/common/devtools/ash_devtools_css_agent.h"
6 6
7 #include "ash/common/wm_window.h" 7 #include "ash/common/wm_window.h"
8 8
9 namespace ash { 9 namespace ash {
10 namespace devtools { 10 namespace devtools {
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 52
53 std::unique_ptr<CSS::CSSStyle> BuildStyles(views::View* view) { 53 std::unique_ptr<CSS::CSSStyle> BuildStyles(views::View* view) {
54 return BuildCSSStyleForBounds(view->bounds()); 54 return BuildCSSStyleForBounds(view->bounds());
55 } 55 }
56 56
57 } // namespace 57 } // namespace
58 58
59 AshDevToolsCSSAgent::AshDevToolsCSSAgent(AshDevToolsDOMAgent* dom_agent) 59 AshDevToolsCSSAgent::AshDevToolsCSSAgent(AshDevToolsDOMAgent* dom_agent)
60 : dom_agent_(dom_agent) { 60 : dom_agent_(dom_agent) {
61 DCHECK(dom_agent_); 61 DCHECK(dom_agent_);
62 dom_agent_->AddObserver(this);
62 } 63 }
63 64
64 AshDevToolsCSSAgent::~AshDevToolsCSSAgent() {} 65 AshDevToolsCSSAgent::~AshDevToolsCSSAgent() {}
65 66
67 // CSS:Backend implementation
sadrul 2016/11/25 18:39:23 Remove comment. (from the following sections too)
Sarmad Hashmi 2016/11/26 01:44:37 Done.
66 ui::devtools::protocol::Response AshDevToolsCSSAgent::getMatchedStylesForNode( 68 ui::devtools::protocol::Response AshDevToolsCSSAgent::getMatchedStylesForNode(
67 int nodeId, 69 int nodeId,
68 ui::devtools::protocol::Maybe<ui::devtools::protocol::CSS::CSSStyle>* 70 ui::devtools::protocol::Maybe<ui::devtools::protocol::CSS::CSSStyle>*
69 inlineStyle) { 71 inlineStyle) {
70 *inlineStyle = GetStylesForNode(nodeId); 72 *inlineStyle = GetStylesForNode(nodeId);
71 return ui::devtools::protocol::Response::OK(); 73 return ui::devtools::protocol::Response::OK();
72 } 74 }
73 75
76 // AshDevToolsDOMAgentObserver implementation
77 void AshDevToolsCSSAgent::OnWindowAdded(WmWindow* window) {
78 window->AddObserver(this);
79 }
80
81 void AshDevToolsCSSAgent::OnWindowRemoved(WmWindow* window) {
82 window->RemoveObserver(this);
83 }
84
85 void AshDevToolsCSSAgent::OnWidgetAdded(views::Widget* widget) {
86 widget->AddObserver(this);
87 }
88
89 void AshDevToolsCSSAgent::OnWidgetRemoved(views::Widget* widget) {
90 widget->RemoveObserver(this);
91 }
92
93 void AshDevToolsCSSAgent::OnViewAdded(views::View* view) {
94 view->AddObserver(this);
95 }
96
97 void AshDevToolsCSSAgent::OnViewRemoved(views::View* view) {
98 view->RemoveObserver(this);
99 }
100
101 // WmWindowObserver implementation
102 void AshDevToolsCSSAgent::OnWindowBoundsChanged(WmWindow* window,
sadrul 2016/11/25 18:39:23 Can we get these updates from the dom-agent as wel
Sarmad Hashmi 2016/11/26 01:44:37 It's possible yes. It would definitely make the co
sadrul 2016/11/29 02:02:58 I think I still prefer for only the DOMAgent to in
Sarmad Hashmi 2016/11/29 23:16:24 Done.
103 const gfx::Rect& old_bounds,
104 const gfx::Rect& new_bounds) {
105 InvalidateStyleSheet();
106 }
107
108 // views::WidgetObserver implementation
109 void AshDevToolsCSSAgent::OnWidgetBoundsChanged(views::Widget* widget,
110 const gfx::Rect& new_bounds) {
111 InvalidateStyleSheet();
112 }
113
114 // views::ViewObserver implementation
115 void AshDevToolsCSSAgent::OnViewBoundsChanged(views::View* view) {
116 InvalidateStyleSheet();
117 }
118
74 std::unique_ptr<ui::devtools::protocol::CSS::CSSStyle> 119 std::unique_ptr<ui::devtools::protocol::CSS::CSSStyle>
75 AshDevToolsCSSAgent::GetStylesForNode(int nodeId) { 120 AshDevToolsCSSAgent::GetStylesForNode(int nodeId) {
76 WmWindow* window = dom_agent_->GetWindowFromNodeId(nodeId); 121 WmWindow* window = dom_agent_->GetWindowFromNodeId(nodeId);
77 if (window) 122 if (window)
78 return BuildStyles(window); 123 return BuildStyles(window);
79 124
80 views::Widget* widget = dom_agent_->GetWidgetFromNodeId(nodeId); 125 views::Widget* widget = dom_agent_->GetWidgetFromNodeId(nodeId);
81 if (widget) 126 if (widget)
82 return BuildStyles(widget); 127 return BuildStyles(widget);
83 128
84 views::View* view = dom_agent_->GetViewFromNodeId(nodeId); 129 views::View* view = dom_agent_->GetViewFromNodeId(nodeId);
85 if (view) 130 if (view)
86 return BuildStyles(view); 131 return BuildStyles(view);
87 132
88 NOTREACHED(); 133 NOTREACHED();
89 return nullptr; 134 return nullptr;
90 } 135 }
91 136
137 void AshDevToolsCSSAgent::InvalidateStyleSheet() {
138 // Pass in empty string just to invalidate all the styles on the frontend
139 frontend()->styleSheetChanged("");
sadrul 2016/11/25 18:39:23 std::string() instead of "" When you invalidate t
Sarmad Hashmi 2016/11/26 01:44:37 Done. We only build CSS props when a node is sele
sadrul 2016/11/29 02:02:58 Is it possible to invalidate the cache for only th
Sarmad Hashmi 2016/11/29 23:16:24 Assigned node_id as stylesheetid to each node as d
140 }
141
92 } // namespace devtools 142 } // namespace devtools
93 } // namespace ash 143 } // namespace ash
OLDNEW
« no previous file with comments | « ash/common/devtools/ash_devtools_css_agent.h ('k') | components/ui_devtools/protocol.json » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698