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

Side by Side Diff: ash/devtools/widget_element.cc

Issue 2852733002: Duplicate -Move DevTools out of ash and turn it to a component. (Closed)
Patch Set: move unittest to ui/views Created 3 years, 7 months 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/devtools/widget_element.h ('k') | ash/devtools/window_element.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2017 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "ash/devtools/widget_element.h"
6
7 #include "ash/devtools/ui_element_delegate.h"
8
9 namespace ash {
10 namespace devtools {
11
12 WidgetElement::WidgetElement(views::Widget* widget,
13 UIElementDelegate* ui_element_delegate,
14 UIElement* parent)
15 : UIElement(UIElementType::WIDGET, ui_element_delegate, parent),
16 widget_(widget) {
17 widget_->AddRemovalsObserver(this);
18 }
19
20 WidgetElement::~WidgetElement() {
21 widget_->RemoveRemovalsObserver(this);
22 }
23
24 void WidgetElement::OnWillRemoveView(views::Widget* widget, views::View* view) {
25 if (view != widget->GetRootView())
26 return;
27 DCHECK_EQ(1u, children().size());
28 UIElement* child = children()[0];
29 RemoveChild(child);
30 child->Destroy();
31 }
32
33 void WidgetElement::OnWidgetBoundsChanged(views::Widget* widget,
34 const gfx::Rect& new_bounds) {
35 DCHECK_EQ(widget, widget_);
36 delegate()->OnUIElementBoundsChanged(this);
37 }
38
39 void WidgetElement::Destroy() {
40 delete this;
41 }
42
43 void WidgetElement::GetBounds(gfx::Rect* bounds) const {
44 *bounds = widget_->GetRestoredBounds();
45 }
46
47 void WidgetElement::SetBounds(const gfx::Rect& bounds) {
48 widget_->SetBounds(bounds);
49 }
50
51 void WidgetElement::GetVisible(bool* visible) const {
52 *visible = widget_->IsVisible();
53 }
54
55 void WidgetElement::SetVisible(bool visible) {
56 if (visible == widget_->IsVisible())
57 return;
58 if (visible)
59 widget_->Show();
60 else
61 widget_->Hide();
62 }
63
64 std::pair<aura::Window*, gfx::Rect> WidgetElement::GetNodeWindowAndBounds()
65 const {
66 return std::make_pair(widget_->GetNativeWindow(),
67 widget_->GetWindowBoundsInScreen());
68 }
69
70 // static
71 views::Widget* WidgetElement::From(UIElement* element) {
72 DCHECK_EQ(UIElementType::WIDGET, element->type());
73 return static_cast<WidgetElement*>(element)->widget_;
74 }
75
76 } // namespace devtools
77 } // namespace ash
OLDNEW
« no previous file with comments | « ash/devtools/widget_element.h ('k') | ash/devtools/window_element.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698