Commit 3f396851 authored by thanhph's avatar thanhph Committed by Commit Bot

Move DevTools out of ash and turn it to a component. AshTestbase

dependency will be removed and replaced by ViewTestBase. Appropriate
UIElement trees are also created to test DevTools.

BUG=701835

Review-Url: https://codereview.chromium.org/2899783002
Cr-Commit-Position: refs/heads/master@{#481047}
parent 3db9563b
......@@ -79,19 +79,6 @@ component("ash") {
"default_accessibility_delegate.h",
"default_wallpaper_delegate.cc",
"default_wallpaper_delegate.h",
"devtools/ash_devtools_css_agent.cc",
"devtools/ash_devtools_css_agent.h",
"devtools/ash_devtools_dom_agent.cc",
"devtools/ash_devtools_dom_agent.h",
"devtools/ui_element.cc",
"devtools/ui_element.h",
"devtools/ui_element_delegate.h",
"devtools/view_element.cc",
"devtools/view_element.h",
"devtools/widget_element.cc",
"devtools/widget_element.h",
"devtools/window_element.cc",
"devtools/window_element.h",
"display/ash_display_controller.cc",
"display/ash_display_controller.h",
"display/cursor_window_controller.cc",
......@@ -856,6 +843,7 @@ component("ash") {
"//components/session_manager:base",
"//components/signin/core/account_id",
"//components/ui_devtools",
"//components/ui_devtools/views",
"//components/user_manager",
"//components/vector_icons",
"//components/wallpaper",
......@@ -1166,7 +1154,6 @@ source_set("common_unittests") {
"accelerators/spoken_feedback_toggler_unittest.cc",
"ash_touch_exploration_manager_chromeos_unittest.cc",
"autoclick/autoclick_unittest.cc",
"devtools/ash_devtools_unittest.cc",
"display/display_configuration_controller_unittest.cc",
"drag_drop/drag_image_view_unittest.cc",
"first_run/first_run_helper_unittest.cc",
......
......@@ -20,8 +20,6 @@
#include "ash/aura/shell_port_classic.h"
#include "ash/autoclick/autoclick_controller.h"
#include "ash/cast_config_controller.h"
#include "ash/devtools/ash_devtools_css_agent.h"
#include "ash/devtools/ash_devtools_dom_agent.h"
#include "ash/display/ash_display_controller.h"
#include "ash/display/cursor_window_controller.h"
#include "ash/display/display_color_manager_chromeos.h"
......@@ -133,6 +131,8 @@
#include "components/prefs/pref_registry_simple.h"
#include "components/prefs/pref_service.h"
#include "components/ui_devtools/devtools_server.h"
#include "components/ui_devtools/views/ui_devtools_css_agent.h"
#include "components/ui_devtools/views/ui_devtools_dom_agent.h"
#include "services/preferences/public/cpp/pref_service_factory.h"
#include "services/preferences/public/interfaces/preferences.mojom.h"
#include "services/service_manager/public/cpp/connector.h"
......@@ -856,12 +856,12 @@ void Shell::Init(const ShellInitParams& init_params) {
wallpaper_controller_ = base::MakeUnique<WallpaperController>();
// Start devtools server
devtools_server_ = ui::devtools::UiDevToolsServer::Create(nullptr);
devtools_server_ = ui_devtools::UiDevToolsServer::Create(nullptr);
if (devtools_server_) {
auto dom_backend = base::MakeUnique<devtools::AshDevToolsDOMAgent>();
auto dom_backend = base::MakeUnique<ui_devtools::UIDevToolsDOMAgent>();
auto css_backend =
base::MakeUnique<devtools::AshDevToolsCSSAgent>(dom_backend.get());
auto devtools_client = base::MakeUnique<ui::devtools::UiDevToolsClient>(
base::MakeUnique<ui_devtools::UIDevToolsCSSAgent>(dom_backend.get());
auto devtools_client = base::MakeUnique<ui_devtools::UiDevToolsClient>(
"Ash", devtools_server_.get());
devtools_client->AddAgent(std::move(dom_backend));
devtools_client->AddAgent(std::move(css_backend));
......
......@@ -60,9 +60,10 @@ class Insets;
namespace ui {
class UserActivityDetector;
class UserActivityPowerManagerNotifier;
namespace devtools {
class UiDevToolsServer;
}
namespace ui_devtools {
class UiDevToolsServer;
}
namespace views {
......@@ -718,7 +719,7 @@ class ASH_EXPORT Shell : public SessionObserver,
std::unique_ptr<::wm::WindowModalityController> window_modality_controller_;
std::unique_ptr<app_list::AppList> app_list_;
std::unique_ptr<::PrefService> pref_service_;
std::unique_ptr<ui::devtools::UiDevToolsServer> devtools_server_;
std::unique_ptr<ui_devtools::UiDevToolsServer> devtools_server_;
std::unique_ptr<views::corewm::TooltipController> tooltip_controller_;
LinkHandlerModelFactory* link_handler_model_factory_;
std::unique_ptr<PowerButtonController> power_button_controller_;
......
......@@ -2726,9 +2726,9 @@ const FeatureEntry kFeatureEntries[] = {
#endif // OS_ANDROID
#if defined(OS_CHROMEOS)
{ui::devtools::kEnableUiDevTools, flag_descriptions::kUiDevToolsName,
{ui_devtools::kEnableUiDevTools, flag_descriptions::kUiDevToolsName,
flag_descriptions::kUiDevToolsDescription, kOsCrOS,
SINGLE_VALUE_TYPE(ui::devtools::kEnableUiDevTools)},
SINGLE_VALUE_TYPE(ui_devtools::kEnableUiDevTools)},
#endif // defined(OS_CHROMEOS)
{"enable-autofill-credit-card-last-used-date-display",
......@@ -3146,7 +3146,7 @@ bool SkipConditionalFeatureEntry(const FeatureEntry& entry) {
}
// enable-ui-devtools is only available on for non Stable channels.
if (!strcmp(ui::devtools::kEnableUiDevTools, entry.internal_name) &&
if (!strcmp(ui_devtools::kEnableUiDevTools, entry.internal_name) &&
channel == version_info::Channel::STABLE) {
return true;
}
......
......@@ -68,7 +68,7 @@ const char kIsAdditionalField[] = "isAdditional";
void GetUiDevToolsTargets(base::ListValue& targets) {
for (const auto& client_pair :
ui::devtools::UiDevToolsServer::GetClientNamesAndUrls()) {
ui_devtools::UiDevToolsServer::GetClientNamesAndUrls()) {
auto target_data = base::MakeUnique<base::DictionaryValue>();
target_data->SetString(kNameField, client_pair.first);
target_data->SetString(kUrlField, client_pair.second);
......
......@@ -157,6 +157,10 @@ test("components_unittests") {
"//components/webdata/common:unit_tests",
]
if (toolkit_views && use_aura) {
deps += [ "//components/ui_devtools/views:unit_tests" ]
}
if (enable_nacl) {
deps += [ "//components/nacl/browser:unit_tests" ]
}
......
......@@ -52,7 +52,7 @@ inspector_protocol_generate("protocol_generated_sources") {
outputs = _protocol_generated
}
source_set("ui_devtools") {
component("ui_devtools") {
sources = rebase_path(_protocol_generated, ".", target_gen_dir)
sources += [
"devtools_base_agent.h",
......
# Inspecting Chrome Native UI with DevTools.
https://www.chromium.org/developers/how-tos/inspecting-ash
......@@ -7,8 +7,7 @@
#include "components/ui_devtools/Protocol.h"
namespace ui {
namespace devtools {
namespace ui_devtools {
class UiDevToolsAgent {
public:
......@@ -39,12 +38,12 @@ class UiDevToolsBaseAgent : public UiDevToolsAgent,
// Common methods between all generated Backends, subclasses may
// choose to override them (but not necessary).
ui::devtools::protocol::Response enable() override {
return ui::devtools::protocol::Response::OK();
ui_devtools::protocol::Response enable() override {
return ui_devtools::protocol::Response::OK();
};
ui::devtools::protocol::Response disable() override {
return ui::devtools::protocol::Response::OK();
ui_devtools::protocol::Response disable() override {
return ui_devtools::protocol::Response::OK();
};
protected:
......@@ -59,7 +58,6 @@ class UiDevToolsBaseAgent : public UiDevToolsAgent,
DISALLOW_COPY_AND_ASSIGN(UiDevToolsBaseAgent);
};
} // namespace devtools
} // namespace ui
} // namespace ui_devtools
#endif // COMPONENTS_UI_DEVTOOLS_DEVTOOLS_BASE_AGENT_H_
......@@ -6,8 +6,7 @@
#include "components/ui_devtools/devtools_server.h"
namespace ui {
namespace devtools {
namespace ui_devtools {
UiDevToolsClient::UiDevToolsClient(const std::string& name,
UiDevToolsServer* server)
......@@ -68,5 +67,4 @@ void UiDevToolsClient::flushProtocolNotifications() {
NOTIMPLEMENTED();
}
} // namespace devtools
} // namespace ui
} // namespace ui_devtools
......@@ -11,9 +11,9 @@
#include "components/ui_devtools/Forward.h"
#include "components/ui_devtools/Protocol.h"
#include "components/ui_devtools/devtools_base_agent.h"
#include "components/ui_devtools/devtools_export.h"
namespace ui {
namespace devtools {
namespace ui_devtools {
class UiDevToolsServer;
......@@ -21,7 +21,7 @@ class UiDevToolsServer;
// this class and attach the corresponding backends/frontends (i.e: DOM, CSS,
// etc). This client is then attached to the UiDevToolsServer and all messages
// from this client are sent over the web socket owned by the server.
class UiDevToolsClient : public protocol::FrontendChannel {
class UI_DEVTOOLS_EXPORT UiDevToolsClient : public protocol::FrontendChannel {
public:
static const int kNotConnected = -1;
......@@ -57,7 +57,6 @@ class UiDevToolsClient : public protocol::FrontendChannel {
DISALLOW_COPY_AND_ASSIGN(UiDevToolsClient);
};
} // namespace devtools
} // namespace ui
} // namespace ui_devtools
#endif // COMPONENTS_UI_DEVTOOLS_DEVTOOLS_CLIENT_H_
......@@ -21,8 +21,7 @@
#include "net/socket/server_socket.h"
#include "net/socket/tcp_server_socket.h"
namespace ui {
namespace devtools {
namespace ui_devtools {
namespace {
const char kChromeDeveloperToolsPrefix[] =
......@@ -182,5 +181,4 @@ void UiDevToolsServer::OnClose(int connection_id) {
connections_.erase(it);
}
} // namespace devtools
} // namespace ui
} // namespace ui_devtools
......@@ -14,13 +14,14 @@
#include "components/ui_devtools/Forward.h"
#include "components/ui_devtools/Protocol.h"
#include "components/ui_devtools/devtools_client.h"
#include "components/ui_devtools/devtools_export.h"
#include "components/ui_devtools/string_util.h"
#include "net/server/http_server.h"
namespace ui {
namespace devtools {
namespace ui_devtools {
class UiDevToolsServer : public net::HttpServer::Delegate {
class UI_DEVTOOLS_EXPORT UiDevToolsServer
: public NON_EXPORTED_BASE(net::HttpServer::Delegate) {
public:
~UiDevToolsServer() override;
......@@ -68,7 +69,6 @@ class UiDevToolsServer : public net::HttpServer::Delegate {
DISALLOW_COPY_AND_ASSIGN(UiDevToolsServer);
};
} // namespace devtools
} // namespace ui
} // namespace ui_devtools
#endif // COMPONENTS_UI_DEVTOOLS_DEVTOOLS_SERVER_H_
......@@ -3,7 +3,7 @@
"path": "protocol.json",
"package": "components/ui_devtools",
"output": "",
"namespace": ["ui", "devtools", "protocol"],
"namespace": ["ui_devtools", "protocol"],
"export_macro": "UI_DEVTOOLS_EXPORT",
"export_header": "components/ui_devtools/devtools_export.h"
},
......
......@@ -7,8 +7,7 @@
#include "base/strings/string_util.h"
#include "components/ui_devtools/Protocol.h"
namespace ui {
namespace devtools {
namespace ui_devtools {
namespace protocol {
// static
......@@ -20,5 +19,4 @@ std::unique_ptr<Value> StringUtil::parseJSON(const String& string) {
};
} // namespace protocol
} // namespace ws
} // namespace ui
} // namespace ui_devtools
......@@ -10,8 +10,7 @@
#include "base/json/json_reader.h"
#include "base/strings/string_number_conversions.h"
namespace ui {
namespace devtools {
namespace ui_devtools {
using String = std::string;
......@@ -28,9 +27,7 @@ class CustomStringBuilder {
void reserveCapacity(std::size_t size) { s_.reserve(size); }
void append(const String& s) { s_ += s; }
void append(char c) { s_ += c; }
void append(const char* data, unsigned int length) {
s_.append(data, length);
}
void append(const char* data, size_t length) { s_.append(data, length); }
String toString() { return s_; }
};
......@@ -76,7 +73,6 @@ class StringUtil {
};
} // namespace protocol
} // namespace devtools
} // namespace ui
} // namespace ui_devtools
#endif // COMPONENTS_UI_DEVTOOLS_STRING_UTIL_H_
......@@ -4,12 +4,10 @@
#include "components/ui_devtools/switches.h"
namespace ui {
namespace devtools {
namespace ui_devtools {
// Enables DevTools server for UI (mus, ash, etc). Value should be the port the
// server is started on. Default port is 9332.
const char kEnableUiDevTools[] = "enable-ui-devtools";
} // namespace devtools
} // namespace ui
} // namespace ui_devtools
......@@ -7,12 +7,10 @@
#include "components/ui_devtools/devtools_export.h"
namespace ui {
namespace devtools {
namespace ui_devtools {
extern UI_DEVTOOLS_EXPORT const char kEnableUiDevTools[];
} // namespace devtools
} // namespace ui
} // namespace ui_devtools
#endif // COMPONENTS_UI_DEVTOOLS_SWITCHES_H_
# Copyright 2016 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
import("//build/config/ui.gni")
source_set("views") {
cflags = []
if (is_win) {
cflags += [ "/wd4800" ] # Value forced to bool.
}
sources = [
"ui_devtools_css_agent.cc",
"ui_devtools_css_agent.h",
"ui_devtools_dom_agent.cc",
"ui_devtools_dom_agent.h",
"ui_element.cc",
"ui_element.h",
"ui_element_delegate.h",
"view_element.cc",
"view_element.h",
"widget_element.cc",
"widget_element.h",
"window_element.cc",
"window_element.h",
]
deps = [
"//components/ui_devtools",
"//skia",
"//ui/aura",
"//ui/views",
"//ui/wm:wm",
]
}
source_set("unit_tests") {
testonly = true
cflags = []
if (is_win) {
cflags += [ "/wd4800" ] # Value forced to bool.
}
sources = [
"ui_devtools_unittest.cc",
]
deps = [
":views",
"//components/ui_devtools",
"//skia",
"//testing/gtest",
"//ui/aura",
"//ui/views",
"//ui/views:test_support",
"//ui/wm:wm",
]
configs += [ "//build/config:precompiled_headers" ]
}
include_rules = [
"+third_party/skia/include/core",
"+ui"
]
......@@ -2,18 +2,17 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "ash/devtools/ash_devtools_css_agent.h"
#include "components/ui_devtools/views/ui_devtools_css_agent.h"
#include "ash/devtools/ui_element.h"
#include "base/strings/string_split.h"
#include "base/strings/string_util.h"
#include "components/ui_devtools/views/ui_element.h"
#include "ui/aura/window.h"
namespace ash {
namespace devtools {
namespace ui_devtools {
namespace {
using namespace ui::devtools::protocol;
using namespace ui_devtools::protocol;
const char kHeight[] = "height";
const char kWidth[] = "width";
......@@ -66,8 +65,8 @@ std::unique_ptr<CSS::CSSStyle> BuildCSSStyle(int node_id,
.build();
}
ui::devtools::protocol::Response NodeNotFoundError(int node_id) {
return ui::devtools::protocol::Response::Error(
ui_devtools::protocol::Response NodeNotFoundError(int node_id) {
return ui_devtools::protocol::Response::Error(
"Node with id=" + std::to_string(node_id) + " not found");
}
......@@ -100,57 +99,57 @@ Response ParseProperties(const std::string& style_text,
} // namespace
AshDevToolsCSSAgent::AshDevToolsCSSAgent(AshDevToolsDOMAgent* dom_agent)
UIDevToolsCSSAgent::UIDevToolsCSSAgent(UIDevToolsDOMAgent* dom_agent)
: dom_agent_(dom_agent) {
DCHECK(dom_agent_);
}
AshDevToolsCSSAgent::~AshDevToolsCSSAgent() {
UIDevToolsCSSAgent::~UIDevToolsCSSAgent() {
disable();
}
ui::devtools::protocol::Response AshDevToolsCSSAgent::enable() {
ui_devtools::protocol::Response UIDevToolsCSSAgent::enable() {
dom_agent_->AddObserver(this);
return ui::devtools::protocol::Response::OK();
return ui_devtools::protocol::Response::OK();
}
ui::devtools::protocol::Response AshDevToolsCSSAgent::disable() {
ui_devtools::protocol::Response UIDevToolsCSSAgent::disable() {
dom_agent_->RemoveObserver(this);
return ui::devtools::protocol::Response::OK();
return ui_devtools::protocol::Response::OK();
}
ui::devtools::protocol::Response AshDevToolsCSSAgent::getMatchedStylesForNode(
ui_devtools::protocol::Response UIDevToolsCSSAgent::getMatchedStylesForNode(
int node_id,
ui::devtools::protocol::Maybe<ui::devtools::protocol::CSS::CSSStyle>*
ui_devtools::protocol::Maybe<ui_devtools::protocol::CSS::CSSStyle>*
inline_style) {
*inline_style = GetStylesForNode(node_id);
if (!inline_style)
return NodeNotFoundError(node_id);
return ui::devtools::protocol::Response::OK();
return ui_devtools::protocol::Response::OK();
}
ui::devtools::protocol::Response AshDevToolsCSSAgent::setStyleTexts(
std::unique_ptr<ui::devtools::protocol::Array<
ui::devtools::protocol::CSS::StyleDeclarationEdit>> edits,
ui_devtools::protocol::Response UIDevToolsCSSAgent::setStyleTexts(
std::unique_ptr<ui_devtools::protocol::Array<
ui_devtools::protocol::CSS::StyleDeclarationEdit>> edits,
std::unique_ptr<
ui::devtools::protocol::Array<ui::devtools::protocol::CSS::CSSStyle>>*
ui_devtools::protocol::Array<ui_devtools::protocol::CSS::CSSStyle>>*
result) {
std::unique_ptr<
ui::devtools::protocol::Array<ui::devtools::protocol::CSS::CSSStyle>>
updated_styles = ui::devtools::protocol::Array<
ui::devtools::protocol::CSS::CSSStyle>::create();
ui_devtools::protocol::Array<ui_devtools::protocol::CSS::CSSStyle>>
updated_styles = ui_devtools::protocol::Array<
ui_devtools::protocol::CSS::CSSStyle>::create();
for (size_t i = 0; i < edits->length(); i++) {
auto* edit = edits->get(i);
int node_id;
if (!base::StringToInt(edit->getStyleSheetId(), &node_id))
return ui::devtools::protocol::Response::Error("Invalid node id");
return ui_devtools::protocol::Response::Error("Invalid node id");
gfx::Rect updated_bounds;
bool visible = false;
if (!GetPropertiesForNodeId(node_id, &updated_bounds, &visible))
return NodeNotFoundError(node_id);
ui::devtools::protocol::Response response(
ui_devtools::protocol::Response response(
ParseProperties(edit->getText(), &updated_bounds, &visible));
if (!response.isSuccess())
return response;
......@@ -161,15 +160,15 @@ ui::devtools::protocol::Response AshDevToolsCSSAgent::setStyleTexts(
return NodeNotFoundError(node_id);
}
*result = std::move(updated_styles);
return ui::devtools::protocol::Response::OK();
return ui_devtools::protocol::Response::OK();
}
void AshDevToolsCSSAgent::OnNodeBoundsChanged(int node_id) {
void UIDevToolsCSSAgent::OnNodeBoundsChanged(int node_id) {
InvalidateStyleSheet(node_id);
}
std::unique_ptr<ui::devtools::protocol::CSS::CSSStyle>
AshDevToolsCSSAgent::GetStylesForNode(int node_id) {
std::unique_ptr<ui_devtools::protocol::CSS::CSSStyle>
UIDevToolsCSSAgent::GetStylesForNode(int node_id) {
gfx::Rect bounds;
bool visible = false;
return GetPropertiesForNodeId(node_id, &bounds, &visible)
......@@ -177,14 +176,14 @@ AshDevToolsCSSAgent::GetStylesForNode(int node_id) {
: nullptr;
}
void AshDevToolsCSSAgent::InvalidateStyleSheet(int node_id) {
void UIDevToolsCSSAgent::InvalidateStyleSheet(int node_id) {
// The stylesheetId for each node is equivalent to its node_id (as a string).
frontend()->styleSheetChanged(base::IntToString(node_id));
}
bool AshDevToolsCSSAgent::GetPropertiesForNodeId(int node_id,
gfx::Rect* bounds,
bool* visible) {
bool UIDevToolsCSSAgent::GetPropertiesForNodeId(int node_id,
gfx::Rect* bounds,
bool* visible) {
UIElement* ui_element = dom_agent_->GetElementFromNodeId(node_id);
if (ui_element) {
ui_element->GetBounds(bounds);
......@@ -194,9 +193,9 @@ bool AshDevToolsCSSAgent::GetPropertiesForNodeId(int node_id,
return false;
}
bool AshDevToolsCSSAgent::SetPropertiesForNodeId(int node_id,
const gfx::Rect& bounds,
bool visible) {
bool UIDevToolsCSSAgent::SetPropertiesForNodeId(int node_id,
const gfx::Rect& bounds,
bool visible) {
UIElement* ui_element = dom_agent_->GetElementFromNodeId(node_id);
if (ui_element) {
ui_element->SetBounds(bounds);
......@@ -206,5 +205,4 @@ bool AshDevToolsCSSAgent::SetPropertiesForNodeId(int node_id,
return false;
}
} // namespace devtools
} // namespace ash
} // namespace ui_devtools
......@@ -2,56 +2,52 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef ASH_DEVTOOLS_ASH_DEVTOOLS_CSS_AGENT_H_
#define ASH_DEVTOOLS_ASH_DEVTOOLS_CSS_AGENT_H_
#ifndef COMPONENTS_UI_DEVTOOLS_VIEWS_UI_DEVTOOLS_CSS_AGENT_H_
#define COMPONENTS_UI_DEVTOOLS_VIEWS_UI_DEVTOOLS_CSS_AGENT_H_
#include "ash/ash_export.h"
#include "ash/devtools/ash_devtools_dom_agent.h"
#include "base/macros.h"
#include "components/ui_devtools/CSS.h"
#include "components/ui_devtools/views/ui_devtools_dom_agent.h"
namespace ash {
namespace devtools {
namespace ui_devtools {
class ASH_EXPORT AshDevToolsCSSAgent
: public NON_EXPORTED_BASE(ui::devtools::UiDevToolsBaseAgent<
ui::devtools::protocol::CSS::Metainfo>),
public AshDevToolsDOMAgentObserver {
class UIDevToolsCSSAgent : public ui_devtools::UiDevToolsBaseAgent<
ui_devtools::protocol::CSS::Metainfo>,
public UIDevToolsDOMAgentObserver {
public:
explicit AshDevToolsCSSAgent(AshDevToolsDOMAgent* dom_agent);
~AshDevToolsCSSAgent() override;
explicit UIDevToolsCSSAgent(UIDevToolsDOMAgent* dom_agent);
~UIDevToolsCSSAgent() override;
// CSS::Backend:
ui::devtools::protocol::Response enable() override;
ui::devtools::protocol::Response disable() override;
ui::devtools::protocol::Response getMatchedStylesForNode(
ui_devtools::protocol::Response enable() override;
ui_devtools::protocol::Response disable() override;
ui_devtools::protocol::Response getMatchedStylesForNode(
int node_id,
ui::devtools::protocol::Maybe<ui::devtools::protocol::CSS::CSSStyle>*
ui_devtools::protocol::Maybe<ui_devtools::protocol::CSS::CSSStyle>*
inline_style) override;
ui::devtools::protocol::Response setStyleTexts(
std::unique_ptr<ui::devtools::protocol::Array<
ui::devtools::protocol::CSS::StyleDeclarationEdit>> edits,
ui_devtools::protocol::Response setStyleTexts(
std::unique_ptr<ui_devtools::protocol::Array<
ui_devtools::protocol::CSS::StyleDeclarationEdit>> edits,
std::unique_ptr<
ui::devtools::protocol::Array<ui::devtools::protocol::CSS::CSSStyle>>*
ui_devtools::protocol::Array<ui_devtools::protocol::CSS::CSSStyle>>*
result) override;
// AshDevToolsDOMAgentObserver:
// UIDevToolsDOMAgentObserver:
void OnNodeBoundsChanged(int node_id) override;
private:
std::unique_ptr<ui::devtools::protocol::CSS::CSSStyle> GetStylesForNode(
std::unique_ptr<ui_devtools::protocol::CSS::CSSStyle> GetStylesForNode(
int node_id);
void InvalidateStyleSheet(int node_id);
bool GetPropertiesForNodeId(int node_id, gfx::Rect* bounds, bool* visible);
bool SetPropertiesForNodeId(int node_id,
const gfx::Rect& bounds,
bool visible);
AshDevToolsDOMAgent* dom_agent_;
UIDevToolsDOMAgent* dom_agent_;
DISALLOW_COPY_AND_ASSIGN(AshDevToolsCSSAgent);
DISALLOW_COPY_AND_ASSIGN(UIDevToolsCSSAgent);
};
} // namespace devtools
} // namespace ash
} // namespace ui_devtools
#endif // ASH_DEVTOOLS_ASH_DEVTOOLS_CSS_AGENT_H_
#endif // COMPONENTS_UI_DEVTOOLS_VIEWS_UI_DEVTOOLS_CSS_AGENT_H_
......@@ -2,14 +2,12 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef ASH_DEVTOOLS_ASH_DEVTOOLS_DOM_AGENT_H_
#define ASH_DEVTOOLS_ASH_DEVTOOLS_DOM_AGENT_H_
#ifndef COMPONENTS_UI_DEVTOOLS_VIEWS_UI_DEVTOOLS_DOM_AGENT_H_
#define COMPONENTS_UI_DEVTOOLS_VIEWS_UI_DEVTOOLS_DOM_AGENT_H_
#include "ash/ash_export.h"
#include "ash/devtools/ui_element_delegate.h"
#include "base/macros.h"
#include "components/ui_devtools/DOM.h"
#include "components/ui_devtools/devtools_base_agent.h"
#include "components/ui_devtools/views/ui_element_delegate.h"
#include "ui/aura/env_observer.h"
#include "ui/views/view.h"
#include "ui/views/widget/widget.h"
......@@ -18,35 +16,33 @@ namespace aura {
class Window;
}
namespace ash {
namespace devtools {
namespace ui_devtools {
class UIElement;
class ASH_EXPORT AshDevToolsDOMAgentObserver {
class UIDevToolsDOMAgentObserver {
public:
// TODO(thanhph): Use UIElement* as input argument instead.
virtual void OnNodeBoundsChanged(int node_id) = 0;
};
class ASH_EXPORT AshDevToolsDOMAgent
: public NON_EXPORTED_BASE(ui::devtools::UiDevToolsBaseAgent<
ui::devtools::protocol::DOM::Metainfo>),
public UIElementDelegate,
public aura::EnvObserver {
class UIDevToolsDOMAgent : public ui_devtools::UiDevToolsBaseAgent<
ui_devtools::protocol::DOM::Metainfo>,
public UIElementDelegate,
public aura::EnvObserver {
public:
AshDevToolsDOMAgent();
~AshDevToolsDOMAgent() override;
UIDevToolsDOMAgent();
~UIDevToolsDOMAgent() override;
// DOM::Backend:
ui::devtools::protocol::Response disable() override;
ui::devtools::protocol::Response getDocument(
std::unique_ptr<ui::devtools::protocol::DOM::Node>* out_root) override;
ui::devtools::protocol::Response highlightNode(
std::unique_ptr<ui::devtools::protocol::DOM::HighlightConfig>
ui_devtools::protocol::Response disable() override;
ui_devtools::protocol::Response getDocument(
std::unique_ptr<ui_devtools::protocol::DOM::Node>* out_root) override;
ui_devtools::protocol::Response highlightNode(
std::unique_ptr<ui_devtools::protocol::DOM::HighlightConfig>
highlight_config,
ui::devtools::protocol::Maybe<int> node_id) override;
ui::devtools::protocol::Response hideHighlight() override;
ui_devtools::protocol::Maybe<int> node_id) override;
ui_devtools::protocol::Response hideHighlight() override;
// UIElementDelegate:
void OnUIElementAdded(UIElement* parent, UIElement* child) override;
......@@ -55,8 +51,8 @@ class ASH_EXPORT AshDevToolsDOMAgent
void OnUIElementBoundsChanged(UIElement* ui_element) override;
bool IsHighlightingWindow(aura::Window* window) override;
void AddObserver(AshDevToolsDOMAgentObserver* observer);
void RemoveObserver(AshDevToolsDOMAgentObserver* observer);
void AddObserver(UIDevToolsDOMAgentObserver* observer);
void RemoveObserver(UIDevToolsDOMAgentObserver* observer);
UIElement* GetElementFromNodeId(int node_id);
UIElement* window_element_root() const { return window_element_root_.get(); };
const std::vector<aura::Window*>& root_windows() const {
......@@ -69,16 +65,16 @@ class ASH_EXPORT AshDevToolsDOMAgent
void OnHostInitialized(aura::WindowTreeHost* host) override;
void OnNodeBoundsChanged(int node_id);
std::unique_ptr<ui::devtools::protocol::DOM::Node> BuildInitialTree();
std::unique_ptr<ui::devtools::protocol::DOM::Node> BuildTreeForUIElement(
std::unique_ptr<ui_devtools::protocol::DOM::Node> BuildInitialTree();
std::unique_ptr<ui_devtools::protocol::DOM::Node> BuildTreeForUIElement(
UIElement* ui_element);
std::unique_ptr<ui::devtools::protocol::DOM::Node> BuildTreeForWindow(
std::unique_ptr<ui_devtools::protocol::DOM::Node> BuildTreeForWindow(
UIElement* window_element_root,
aura::Window* window);
std::unique_ptr<ui::devtools::protocol::DOM::Node> BuildTreeForRootWidget(
std::unique_ptr<ui_devtools::protocol::DOM::Node> BuildTreeForRootWidget(
UIElement* widget_element,
views::Widget* widget);
std::unique_ptr<ui::devtools::protocol::DOM::Node> BuildTreeForView(
std::unique_ptr<ui_devtools::protocol::DOM::Node> BuildTreeForView(
UIElement* view_element,
views::View* view);
void RemoveDomNode(UIElement* ui_element);
......@@ -88,8 +84,8 @@ class ASH_EXPORT AshDevToolsDOMAgent
const std::pair<aura::Window*, gfx::Rect>& window_and_bounds,
SkColor background,
SkColor border);
ui::devtools::protocol::Response HighlightNode(
std::unique_ptr<ui::devtools::protocol::DOM::HighlightConfig>
ui_devtools::protocol::Response HighlightNode(
std::unique_ptr<ui_devtools::protocol::DOM::HighlightConfig>
highlight_config,
int node_id);
......@@ -98,12 +94,11 @@ class ASH_EXPORT AshDevToolsDOMAgent
std::unordered_map<int, UIElement*> node_id_to_ui_element_;
std::unique_ptr<views::Widget> widget_for_highlighting_;
std::vector<aura::Window*> root_windows_;
base::ObserverList<AshDevToolsDOMAgentObserver> observers_;
base::ObserverList<UIDevToolsDOMAgentObserver> observers_;
DISALLOW_COPY_AND_ASSIGN(AshDevToolsDOMAgent);
DISALLOW_COPY_AND_ASSIGN(UIDevToolsDOMAgent);
};
} // namespace devtools
} // namespace ash
} // namespace ui_devtools
#endif // ASH_DEVTOOLS_ASH_DEVTOOLS_DOM_AGENT_H_
#endif // COMPONENTS_UI_DEVTOOLS_VIEWS_UI_DEVTOOLS_DOM_AGENT_H_
......@@ -2,17 +2,16 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "ash/devtools/ui_element.h"
#include "components/ui_devtools/views/ui_element.h"
#include <algorithm>
#include "ash/devtools/ui_element_delegate.h"
#include "ash/devtools/view_element.h"
#include "ash/devtools/widget_element.h"
#include "ash/devtools/window_element.h"
#include "components/ui_devtools/views/ui_element_delegate.h"
#include "components/ui_devtools/views/view_element.h"
#include "components/ui_devtools/views/widget_element.h"
#include "components/ui_devtools/views/window_element.h"
namespace ash {
namespace devtools {
namespace ui_devtools {
namespace {
static int node_ids = 0;
......@@ -63,7 +62,7 @@ void UIElement::ReorderChild(UIElement* child, int new_index) {
children_.erase(iter);
// Move child to new position |new_index| in vector |children_|.
new_index = std::min(children_.size() - 1, static_cast<size_t>(new_index));
new_index = std::min(static_cast<int>(children_.size()) - 1, new_index);
iter = children_.begin() + new_index;
children_.insert(iter, child);
delegate()->OnUIElementReordered(child->parent(), child);
......@@ -76,5 +75,4 @@ UIElement::UIElement(const UIElementType type,
delegate_->OnUIElementAdded(0, this);
}
} // namespace devtools
} // namespace ash
} // namespace ui_devtools
......@@ -2,26 +2,24 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef ASH_DEVTOOLS_UI_ELEMENT_H_
#define ASH_DEVTOOLS_UI_ELEMENT_H_
#ifndef COMPONENTS_UI_DEVTOOLS_VIEWS_UI_ELEMENT_H_
#define COMPONENTS_UI_DEVTOOLS_VIEWS_UI_ELEMENT_H_
#include <vector>
#include "ash/ash_export.h"
#include "base/macros.h"
#include "ui/aura/window.h"
#include "ui/gfx/geometry/rect.h"
#include "ui/views/view.h"
namespace ash {
namespace devtools {
namespace ui_devtools {
class UIElementDelegate;
// UIElement type.
enum UIElementType { WINDOW, WIDGET, VIEW };
class ASH_EXPORT UIElement {
class UIElement {
public:
virtual ~UIElement();
int node_id() const { return node_id_; };
......@@ -72,7 +70,6 @@ class ASH_EXPORT UIElement {
DISALLOW_COPY_AND_ASSIGN(UIElement);
};
} // namespace devtools
} // namespace ash
} // namespace ui_devtools
#endif // ASH_DEVTOOLS_UI_ELEMENT_H_
#endif // COMPONENTS_UI_DEVTOOLS_VIEWS_UI_ELEMENT_H_
......@@ -2,21 +2,19 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef ASH_DEVTOOLS_UI_ELEMENT_DELEGATE_H_
#define ASH_DEVTOOLS_UI_ELEMENT_DELEGATE_H_
#ifndef COMPONENTS_UI_DEVTOOLS_VIEWS_UI_ELEMENT_DELEGATE_H_
#define COMPONENTS_UI_DEVTOOLS_VIEWS_UI_ELEMENT_DELEGATE_H_
#include <vector>
#include "ash/ash_export.h"
#include "base/macros.h"
#include "ui/aura/window.h"
namespace ash {
namespace devtools {
namespace ui_devtools {
class UIElement;
class ASH_EXPORT UIElementDelegate {
class UIElementDelegate {
public:
UIElementDelegate(){};
virtual ~UIElementDelegate(){};
......@@ -38,7 +36,6 @@ class ASH_EXPORT UIElementDelegate {
DISALLOW_COPY_AND_ASSIGN(UIElementDelegate);
};
} // namespace devtools
} // namespace ash
} // namespace ui_devtools
#endif // ASH_DEVTOOLS_UI_ELEMENT_DELEGATE_H_
#endif // COMPONENTS_UI_DEVTOOLS_VIEWS_UI_ELEMENT_DELEGATE_H_
......@@ -2,13 +2,12 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "ash/devtools/view_element.h"
#include "components/ui_devtools/views/view_element.h"
#include "ash/devtools/ui_element_delegate.h"
#include "components/ui_devtools/views/ui_element_delegate.h"
#include "ui/views/widget/widget.h"
namespace ash {
namespace devtools {
namespace ui_devtools {
ViewElement::ViewElement(views::View* view,
UIElementDelegate* ui_element_delegate,
......@@ -85,5 +84,4 @@ views::View* ViewElement::From(UIElement* element) {
return static_cast<ViewElement*>(element)->view_;
}
} // namespace devtools
} // namespace ash
} // namespace ui_devtools
......@@ -2,23 +2,21 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef ASH_DEVTOOLS_VIEW_ELEMENT_H_
#define ASH_DEVTOOLS_VIEW_ELEMENT_H_
#ifndef COMPONENTS_UI_DEVTOOLS_VIEWS_VIEW_ELEMENT_H_
#define COMPONENTS_UI_DEVTOOLS_VIEWS_VIEW_ELEMENT_H_
#include "ash/ash_export.h"
#include "ash/devtools/ui_element.h"
#include "base/macros.h"
#include "components/ui_devtools/views/ui_element.h"
#include "ui/aura/window.h"
#include "ui/gfx/geometry/rect.h"
#include "ui/views/view.h"
#include "ui/views/view_observer.h"
namespace ash {
namespace devtools {
namespace ui_devtools {
class UIElementDelegate;
class ASH_EXPORT ViewElement : public views::ViewObserver, public UIElement {
class ViewElement : public views::ViewObserver, public UIElement {
public:
ViewElement(views::View* view,
UIElementDelegate* ui_element_delegate,
......@@ -46,7 +44,6 @@ class ASH_EXPORT ViewElement : public views::ViewObserver, public UIElement {
DISALLOW_COPY_AND_ASSIGN(ViewElement);
};
} // namespace devtools
} // namespace ash
} // namespace ui_devtools
#endif // ASH_DEVTOOLS_VIEW_ELEMENT_H_
#endif // COMPONENTS_UI_DEVTOOLS_VIEWS_VIEW_ELEMENT_H_
......@@ -2,12 +2,11 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "ash/devtools/widget_element.h"
#include "components/ui_devtools/views/widget_element.h"
#include "ash/devtools/ui_element_delegate.h"
#include "components/ui_devtools/views/ui_element_delegate.h"
namespace ash {
namespace devtools {
namespace ui_devtools {
WidgetElement::WidgetElement(views::Widget* widget,
UIElementDelegate* ui_element_delegate,
......@@ -69,5 +68,4 @@ views::Widget* WidgetElement::From(UIElement* element) {
return static_cast<WidgetElement*>(element)->widget_;
}
} // namespace devtools
} // namespace ash
} // namespace ui_devtools
......@@ -2,26 +2,24 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef ASH_DEVTOOLS_WIDGET_ELEMENT_H_
#define ASH_DEVTOOLS_WIDGET_ELEMENT_H_
#ifndef COMPONENTS_UI_DEVTOOLS_VIEWS_WIDGET_ELEMENT_H_
#define COMPONENTS_UI_DEVTOOLS_VIEWS_WIDGET_ELEMENT_H_
#include "ash/ash_export.h"
#include "ash/devtools/ui_element.h"
#include "base/macros.h"
#include "components/ui_devtools/views/ui_element.h"
#include "ui/aura/window.h"
#include "ui/gfx/geometry/rect.h"
#include "ui/views/widget/widget.h"
#include "ui/views/widget/widget_observer.h"
#include "ui/views/widget/widget_removals_observer.h"
namespace ash {
namespace devtools {
namespace ui_devtools {
class UIElementDelegate;
class ASH_EXPORT WidgetElement : public views::WidgetRemovalsObserver,
public views::WidgetObserver,
public UIElement {
class WidgetElement : public views::WidgetRemovalsObserver,
public views::WidgetObserver,
public UIElement {
public:
WidgetElement(views::Widget* widget,
UIElementDelegate* ui_element_delegate,
......@@ -51,7 +49,6 @@ class ASH_EXPORT WidgetElement : public views::WidgetRemovalsObserver,
DISALLOW_COPY_AND_ASSIGN(WidgetElement);
};
} // namespace devtools
} // namespace ash
} // namespace ui_devtools
#endif // ASH_DEVTOOLS_WIDGET_ELEMENT_H_
#endif // COMPONENTS_UI_DEVTOOLS_VIEWS_WIDGET_ELEMENT_H_
......@@ -2,13 +2,12 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "ash/devtools/window_element.h"
#include "components/ui_devtools/views/window_element.h"
#include "ash/devtools/ui_element_delegate.h"
#include "components/ui_devtools/views/ui_element_delegate.h"
#include "ui/aura/window.h"
namespace ash {
namespace devtools {
namespace ui_devtools {
namespace {
int GetIndexOfChildInParent(aura::Window* window) {
......@@ -96,5 +95,4 @@ aura::Window* WindowElement::From(UIElement* element) {
return static_cast<WindowElement*>(element)->window_;
}
} // namespace devtools
} // namespace ash
} // namespace ui_devtools
......@@ -2,20 +2,18 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef ASH_DEVTOOLS_WINDOW_ELEMENT_H_
#define ASH_DEVTOOLS_WINDOW_ELEMENT_H_
#ifndef COMPONENTS_UI_DEVTOOLS_VIEWS_WINDOW_ELEMENT_H_
#define COMPONENTS_UI_DEVTOOLS_VIEWS_WINDOW_ELEMENT_H_
#include "ash/ash_export.h"
#include "ash/devtools/ui_element.h"
#include "base/macros.h"
#include "components/ui_devtools/views/ui_element.h"
#include "ui/aura/window.h"
#include "ui/aura/window_observer.h"
#include "ui/gfx/geometry/rect.h"
namespace ash {
namespace devtools {
namespace ui_devtools {
class ASH_EXPORT WindowElement : public aura::WindowObserver, public UIElement {
class WindowElement : public aura::WindowObserver, public UIElement {
public:
WindowElement(aura::Window* window,
UIElementDelegate* ui_element_delegate,
......@@ -48,7 +46,6 @@ class ASH_EXPORT WindowElement : public aura::WindowObserver, public UIElement {
DISALLOW_COPY_AND_ASSIGN(WindowElement);
};
} // namespace devtools
} // namespace ash
} // namespace ui_devtools
#endif // ASH_DEVTOOLS_WINDOW_ELEMENT_H_
#endif // COMPONENTS_UI_DEVTOOLS_VIEWS_WINDOW_ELEMENT_H_
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment