Commit c1decfff authored by Illia Martyniuk's avatar Illia Martyniuk Committed by Commit Bot

DevTools: Refactoring UI Elements

Moving UI specific methods from UI Element to either Window, View
or Widget. Once we create common UIElement for UI and Viz it'll be
easier to follow changes since this refactor is done. Common
UIElement will not know about the functions moved in this CL, so I
think it's better to do this now.

Bug: 775348
Change-Id: Ife9d9150ad9de704272c62dc16c177064f4eccdb
Reviewed-on: https://chromium-review.googlesource.com/962356Reviewed-by: default avatarSadrul Chowdhury <sadrul@chromium.org>
Commit-Queue: Illia Martyniuk <illiam@google.com>
Cr-Commit-Position: refs/heads/master@{#543470}
parent 50678d17
...@@ -8,9 +8,6 @@ ...@@ -8,9 +8,6 @@
#include "components/ui_devtools/Protocol.h" #include "components/ui_devtools/Protocol.h"
#include "components/ui_devtools/views/ui_element_delegate.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 ui_devtools { namespace ui_devtools {
namespace { namespace {
...@@ -80,37 +77,6 @@ int UIElement::FindUIElementIdForBackendElement(T* element) const { ...@@ -80,37 +77,6 @@ int UIElement::FindUIElementIdForBackendElement(T* element) const {
return 0; return 0;
} }
template <>
int UIElement::FindUIElementIdForBackendElement<aura::Window>(
aura::Window* element) const {
if (type_ == UIElementType::WINDOW &&
UIElement::GetBackingElement<aura::Window, WindowElement>(this) ==
element) {
return node_id_;
}
for (auto* child : children_) {
int ui_element_id = child->FindUIElementIdForBackendElement(element);
if (ui_element_id)
return ui_element_id;
}
return 0;
}
template <>
int UIElement::FindUIElementIdForBackendElement<views::View>(
views::View* element) const {
if (type_ == UIElementType::VIEW &&
UIElement::GetBackingElement<views::View, ViewElement>(this) == element) {
return node_id_;
}
for (auto* child : children_) {
int ui_element_id = child->FindUIElementIdForBackendElement(element);
if (ui_element_id)
return ui_element_id;
}
return 0;
}
UIElement::UIElement(const UIElementType type, UIElement::UIElement(const UIElementType type,
UIElementDelegate* delegate, UIElementDelegate* delegate,
UIElement* parent) UIElement* parent)
......
...@@ -105,4 +105,19 @@ views::View* ViewElement::From(const UIElement* element) { ...@@ -105,4 +105,19 @@ views::View* ViewElement::From(const UIElement* element) {
return static_cast<const ViewElement*>(element)->view_; return static_cast<const ViewElement*>(element)->view_;
} }
template <>
int UIElement::FindUIElementIdForBackendElement<views::View>(
views::View* element) const {
if (type_ == UIElementType::VIEW &&
UIElement::GetBackingElement<views::View, ViewElement>(this) == element) {
return node_id_;
}
for (auto* child : children_) {
int ui_element_id = child->FindUIElementIdForBackendElement(element);
if (ui_element_id)
return ui_element_id;
}
return 0;
}
} // namespace ui_devtools } // namespace ui_devtools
...@@ -112,4 +112,20 @@ aura::Window* WindowElement::From(const UIElement* element) { ...@@ -112,4 +112,20 @@ aura::Window* WindowElement::From(const UIElement* element) {
return static_cast<const WindowElement*>(element)->window_; return static_cast<const WindowElement*>(element)->window_;
} }
template <>
int UIElement::FindUIElementIdForBackendElement<aura::Window>(
aura::Window* element) const {
if (type_ == UIElementType::WINDOW &&
UIElement::GetBackingElement<aura::Window, WindowElement>(this) ==
element) {
return node_id_;
}
for (auto* child : children_) {
int ui_element_id = child->FindUIElementIdForBackendElement(element);
if (ui_element_id)
return ui_element_id;
}
return 0;
}
} // namespace ui_devtools } // namespace ui_devtools
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