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

Side by Side Diff: views/widget/native_widget_view.cc

Issue 8598024: Now that we are doing a hard-cut-over to Aura, remove a bunch of *Views based classes that are ob... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « views/widget/native_widget_view.h ('k') | views/widget/native_widget_views.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 (c) 2011 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 "views/widget/native_widget_view.h"
6
7 #include "ui/gfx/canvas.h"
8 #include "ui/gfx/compositor/layer.h"
9 #include "ui/gfx/native_widget_types.h"
10
11 namespace views {
12 namespace internal {
13
14 ////////////////////////////////////////////////////////////////////////////////
15 // NativeWidgetView, public:
16
17 // static
18 const char NativeWidgetView::kViewClassName[] = "views/NativeWidgetView";
19
20 NativeWidgetView::NativeWidgetView(NativeWidgetViews* native_widget)
21 : native_widget_(native_widget),
22 sent_create_(false),
23 delete_native_widget_(true),
24 cursor_(gfx::kNullCursor) {
25 }
26
27 NativeWidgetView::~NativeWidgetView() {
28 // Don't let NativeWidgetViews delete this again. This must be outside
29 // the |delete_native_widget_| clause so it gets invoked for
30 // WIDGET_OWNS_NATIVE_WIDGET. It is safe because |native_widget_| will
31 // still exist in both ways NativeWidgetView can be destroyed: by view
32 // hierarchy teardown and from the NativeWidgetViews destructor.
33 native_widget_->set_delete_native_view(false);
34 if (delete_native_widget_)
35 delete native_widget_;
36 }
37
38 Widget* NativeWidgetView::GetAssociatedWidget() {
39 return native_widget_->delegate()->AsWidget();
40 }
41
42 ////////////////////////////////////////////////////////////////////////////////
43 // NativeWidgetView, View overrides:
44
45 void NativeWidgetView::CalculateOffsetToAncestorWithLayer(
46 gfx::Point* offset,
47 ui::Layer** layer_parent) {
48 View::CalculateOffsetToAncestorWithLayer(offset, layer_parent);
49 }
50
51 void NativeWidgetView::ReorderLayers() {
52 View::ReorderLayers();
53 }
54
55 #if !defined(NDEBUG)
56 std::string NativeWidgetView::PrintViewGraph(bool first) {
57 return DoPrintViewGraph(first, GetAssociatedWidget()->GetRootView());
58 }
59 #endif
60
61 void NativeWidgetView::ViewHierarchyChanged(bool is_add,
62 View* parent,
63 View* child) {
64 if (is_add && child == this) {
65 GetAssociatedWidget()->GetRootView()->UpdateParentLayers();
66 if (!sent_create_) {
67 sent_create_ = true;
68 delegate()->OnNativeWidgetCreated();
69 }
70 }
71 }
72
73 void NativeWidgetView::OnBoundsChanged(const gfx::Rect& previous_bounds) {
74 native_widget_->OnBoundsChanged(bounds(), previous_bounds);
75 }
76
77 void NativeWidgetView::OnPaint(gfx::Canvas* canvas) {
78 delegate()->OnNativeWidgetPaint(canvas);
79 }
80
81 gfx::NativeCursor NativeWidgetView::GetCursor(const MouseEvent& event) {
82 return cursor_;
83 }
84
85 bool NativeWidgetView::OnMousePressed(const MouseEvent& event) {
86 return native_widget_->OnMouseEvent(event);
87 }
88
89 bool NativeWidgetView::OnMouseDragged(const MouseEvent& event) {
90 return native_widget_->OnMouseEvent(event);
91 }
92
93 void NativeWidgetView::OnMouseReleased(const MouseEvent& event) {
94 native_widget_->OnMouseEvent(event);
95 }
96
97 void NativeWidgetView::OnMouseCaptureLost() {
98 delegate()->OnMouseCaptureLost();
99 }
100
101 void NativeWidgetView::OnMouseMoved(const MouseEvent& event) {
102 native_widget_->OnMouseEvent(event);
103 }
104
105 void NativeWidgetView::OnMouseEntered(const MouseEvent& event) {
106 native_widget_->OnMouseEvent(event);
107 }
108
109 void NativeWidgetView::OnMouseExited(const MouseEvent& event) {
110 native_widget_->OnMouseEvent(event);
111 }
112
113 ui::TouchStatus NativeWidgetView::OnTouchEvent(const TouchEvent& event) {
114 return delegate()->OnTouchEvent(event);
115 }
116
117 bool NativeWidgetView::OnKeyPressed(const KeyEvent& event) {
118 return delegate()->OnKeyEvent(event);
119 }
120
121 bool NativeWidgetView::OnKeyReleased(const KeyEvent& event) {
122 return delegate()->OnKeyEvent(event);
123 }
124
125 bool NativeWidgetView::OnMouseWheel(const MouseWheelEvent& event) {
126 return native_widget_->OnMouseEvent(event);
127 }
128
129 void NativeWidgetView::VisibilityChanged(View* starting_from,
130 bool visible) {
131 delegate()->OnNativeWidgetVisibilityChanged(visible);
132 }
133
134 void NativeWidgetView::OnFocus() {
135 // TODO(beng): check if we have to do this.
136 //delegate()->OnNativeFocus(NULL);
137 }
138
139 void NativeWidgetView::OnBlur() {
140 // TODO(beng): check if we have to do this.
141 //delegate()->OnNativeBlur(NULL);
142 }
143
144 std::string NativeWidgetView::GetClassName() const {
145 return kViewClassName;
146 }
147
148 void NativeWidgetView::MoveLayerToParent(ui::Layer* parent_layer,
149 const gfx::Point& point) {
150 View::MoveLayerToParent(parent_layer, point);
151 if (!layer() || parent_layer == layer()) {
152 gfx::Point new_offset(point);
153 if (layer() != parent_layer)
154 new_offset.Offset(x(), y());
155 GetAssociatedWidget()->GetRootView()->MoveLayerToParent(
156 parent_layer, new_offset);
157 }
158 }
159
160 void NativeWidgetView::UpdateChildLayerBounds(const gfx::Point& offset) {
161 View::UpdateChildLayerBounds(offset);
162 if (!layer()) {
163 const gfx::Rect& bounds = GetAssociatedWidget()->GetRootView()->bounds();
164 gfx::Point new_offset(offset.x() + bounds.x(), offset.y() + bounds.y());
165 GetAssociatedWidget()->GetRootView()->UpdateChildLayerBounds(new_offset);
166 }
167 }
168
169 void NativeWidgetView::ReorderChildLayers(ui::Layer* parent_layer) {
170 if (layer()) {
171 View::ReorderChildLayers(parent_layer);
172 } else {
173 GetAssociatedWidget()->GetRootView()->ReorderChildLayers(parent_layer);
174 }
175 }
176
177 } // namespace internal
178 } // namespace views
OLDNEW
« no previous file with comments | « views/widget/native_widget_view.h ('k') | views/widget/native_widget_views.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698