Skip to content

Commit

Permalink
Fix bug where CSS styles are requested after node is destroyed
Browse files Browse the repository at this point in the history
There's a bug which causes a crash when a node is highlighted in the
inspector and the corresponding object is destroyed in Ash. This somehow
triggers the frontend to request the styles for that node again, so
instead of NOTREACHED(), we simply return an error.

BUG=648701

Review-Url: https://codereview.chromium.org/2524863004
Cr-Commit-Position: refs/heads/master@{#434563}
  • Loading branch information
mhashmi authored and Commit bot committed Nov 26, 2016
1 parent 33e6986 commit dd0bb09
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions ash/common/devtools/ash_devtools_css_agent.cc
Original file line number Diff line number Diff line change
Expand Up @@ -64,28 +64,31 @@ AshDevToolsCSSAgent::AshDevToolsCSSAgent(AshDevToolsDOMAgent* dom_agent)
AshDevToolsCSSAgent::~AshDevToolsCSSAgent() {}

ui::devtools::protocol::Response AshDevToolsCSSAgent::getMatchedStylesForNode(
int nodeId,
int node_id,
ui::devtools::protocol::Maybe<ui::devtools::protocol::CSS::CSSStyle>*
inlineStyle) {
*inlineStyle = GetStylesForNode(nodeId);
*inlineStyle = GetStylesForNode(node_id);
if (!inlineStyle) {
return ui::devtools::protocol::Response::Error(
"Node with that id not found");
}
return ui::devtools::protocol::Response::OK();
}

std::unique_ptr<ui::devtools::protocol::CSS::CSSStyle>
AshDevToolsCSSAgent::GetStylesForNode(int nodeId) {
WmWindow* window = dom_agent_->GetWindowFromNodeId(nodeId);
AshDevToolsCSSAgent::GetStylesForNode(int node_id) {
WmWindow* window = dom_agent_->GetWindowFromNodeId(node_id);
if (window)
return BuildStyles(window);

views::Widget* widget = dom_agent_->GetWidgetFromNodeId(nodeId);
views::Widget* widget = dom_agent_->GetWidgetFromNodeId(node_id);
if (widget)
return BuildStyles(widget);

views::View* view = dom_agent_->GetViewFromNodeId(nodeId);
views::View* view = dom_agent_->GetViewFromNodeId(node_id);
if (view)
return BuildStyles(view);

NOTREACHED();
return nullptr;
}

Expand Down

0 comments on commit dd0bb09

Please sign in to comment.