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

Unified Diff: ash/common/devtools/ash_devtools_css_agent.cc

Issue 2526103002: Add live updates for AshDevToolsCSSAgent (Closed)
Patch Set: Created 4 years, 1 month 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 side-by-side diff with in-line comments
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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ash/common/devtools/ash_devtools_css_agent.cc
diff --git a/ash/common/devtools/ash_devtools_css_agent.cc b/ash/common/devtools/ash_devtools_css_agent.cc
index 295b53a3b35307921173814b2b0cca68196a8fe4..b7390fa563dfda71a4d4005f514a16adf38beeb5 100644
--- a/ash/common/devtools/ash_devtools_css_agent.cc
+++ b/ash/common/devtools/ash_devtools_css_agent.cc
@@ -59,10 +59,12 @@ std::unique_ptr<CSS::CSSStyle> BuildStyles(views::View* view) {
AshDevToolsCSSAgent::AshDevToolsCSSAgent(AshDevToolsDOMAgent* dom_agent)
: dom_agent_(dom_agent) {
DCHECK(dom_agent_);
+ dom_agent_->AddObserver(this);
}
AshDevToolsCSSAgent::~AshDevToolsCSSAgent() {}
+// 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.
ui::devtools::protocol::Response AshDevToolsCSSAgent::getMatchedStylesForNode(
int nodeId,
ui::devtools::protocol::Maybe<ui::devtools::protocol::CSS::CSSStyle>*
@@ -71,6 +73,49 @@ ui::devtools::protocol::Response AshDevToolsCSSAgent::getMatchedStylesForNode(
return ui::devtools::protocol::Response::OK();
}
+// AshDevToolsDOMAgentObserver implementation
+void AshDevToolsCSSAgent::OnWindowAdded(WmWindow* window) {
+ window->AddObserver(this);
+}
+
+void AshDevToolsCSSAgent::OnWindowRemoved(WmWindow* window) {
+ window->RemoveObserver(this);
+}
+
+void AshDevToolsCSSAgent::OnWidgetAdded(views::Widget* widget) {
+ widget->AddObserver(this);
+}
+
+void AshDevToolsCSSAgent::OnWidgetRemoved(views::Widget* widget) {
+ widget->RemoveObserver(this);
+}
+
+void AshDevToolsCSSAgent::OnViewAdded(views::View* view) {
+ view->AddObserver(this);
+}
+
+void AshDevToolsCSSAgent::OnViewRemoved(views::View* view) {
+ view->RemoveObserver(this);
+}
+
+// WmWindowObserver implementation
+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.
+ const gfx::Rect& old_bounds,
+ const gfx::Rect& new_bounds) {
+ InvalidateStyleSheet();
+}
+
+// views::WidgetObserver implementation
+void AshDevToolsCSSAgent::OnWidgetBoundsChanged(views::Widget* widget,
+ const gfx::Rect& new_bounds) {
+ InvalidateStyleSheet();
+}
+
+// views::ViewObserver implementation
+void AshDevToolsCSSAgent::OnViewBoundsChanged(views::View* view) {
+ InvalidateStyleSheet();
+}
+
std::unique_ptr<ui::devtools::protocol::CSS::CSSStyle>
AshDevToolsCSSAgent::GetStylesForNode(int nodeId) {
WmWindow* window = dom_agent_->GetWindowFromNodeId(nodeId);
@@ -89,5 +134,10 @@ AshDevToolsCSSAgent::GetStylesForNode(int nodeId) {
return nullptr;
}
+void AshDevToolsCSSAgent::InvalidateStyleSheet() {
+ // Pass in empty string just to invalidate all the styles on the frontend
+ 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
+}
+
} // namespace devtools
} // namespace ash
« 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