OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "ui/views/widget/root_view.h" | 5 #include "ui/views/widget/root_view.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
11 #include "ui/accessibility/ax_view_state.h" | 11 #include "ui/accessibility/ax_view_state.h" |
12 #include "ui/base/cursor/cursor.h" | 12 #include "ui/base/cursor/cursor.h" |
13 #include "ui/base/dragdrop/drag_drop_types.h" | 13 #include "ui/base/dragdrop/drag_drop_types.h" |
14 #include "ui/compositor/layer.h" | 14 #include "ui/compositor/layer.h" |
15 #include "ui/events/event.h" | 15 #include "ui/events/event.h" |
16 #include "ui/events/keycodes/keyboard_codes.h" | 16 #include "ui/events/keycodes/keyboard_codes.h" |
17 #include "ui/gfx/canvas.h" | 17 #include "ui/gfx/canvas.h" |
18 #include "ui/native_theme/native_theme.h" | |
18 #include "ui/views/focus/view_storage.h" | 19 #include "ui/views/focus/view_storage.h" |
19 #include "ui/views/layout/fill_layout.h" | 20 #include "ui/views/layout/fill_layout.h" |
20 #include "ui/views/view_targeter.h" | 21 #include "ui/views/view_targeter.h" |
21 #include "ui/views/views_switches.h" | 22 #include "ui/views/views_switches.h" |
22 #include "ui/views/widget/widget.h" | 23 #include "ui/views/widget/widget.h" |
23 #include "ui/views/widget/widget_delegate.h" | 24 #include "ui/views/widget/widget_delegate.h" |
24 | 25 |
25 typedef ui::EventDispatchDetails DispatchDetails; | 26 typedef ui::EventDispatchDetails DispatchDetails; |
26 | 27 |
27 namespace views { | 28 namespace views { |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
112 gesture_handler_(NULL), | 113 gesture_handler_(NULL), |
113 scroll_gesture_handler_(NULL), | 114 scroll_gesture_handler_(NULL), |
114 pre_dispatch_handler_(new internal::PreEventDispatchHandler(this)), | 115 pre_dispatch_handler_(new internal::PreEventDispatchHandler(this)), |
115 focus_search_(this, false, false), | 116 focus_search_(this, false, false), |
116 focus_traversable_parent_(NULL), | 117 focus_traversable_parent_(NULL), |
117 focus_traversable_parent_view_(NULL), | 118 focus_traversable_parent_view_(NULL), |
118 event_dispatch_target_(NULL), | 119 event_dispatch_target_(NULL), |
119 old_dispatch_target_(NULL) { | 120 old_dispatch_target_(NULL) { |
120 AddPreTargetHandler(pre_dispatch_handler_.get()); | 121 AddPreTargetHandler(pre_dispatch_handler_.get()); |
121 SetEventTargeter(scoped_ptr<ui::EventTargeter>(new ViewTargeter())); | 122 SetEventTargeter(scoped_ptr<ui::EventTargeter>(new ViewTargeter())); |
123 GetNativeTheme()->AddObserver(this); | |
Evan Stade
2014/04/22 17:43:44
ScopedObserver?
msw
2014/04/22 19:48:58
Eh, it doesn't seem worthwhile to add a class memb
Evan Stade
2014/04/22 21:09:18
I always prefer scoping variables over doing stuff
msw
2014/04/23 00:34:04
Done (in Widget).
| |
122 } | 124 } |
123 | 125 |
124 RootView::~RootView() { | 126 RootView::~RootView() { |
127 GetNativeTheme()->RemoveObserver(this); | |
125 // If we have children remove them explicitly so to make sure a remove | 128 // If we have children remove them explicitly so to make sure a remove |
126 // notification is sent for each one of them. | 129 // notification is sent for each one of them. |
127 if (has_children()) | 130 if (has_children()) |
128 RemoveAllChildViews(true); | 131 RemoveAllChildViews(true); |
129 } | 132 } |
130 | 133 |
131 // Tree operations ------------------------------------------------------------- | 134 // Tree operations ------------------------------------------------------------- |
132 | 135 |
133 void RootView::SetContentsView(View* contents_view) { | 136 void RootView::SetContentsView(View* contents_view) { |
134 DCHECK(contents_view && GetWidget()->native_widget()) << | 137 DCHECK(contents_view && GetWidget()->native_widget()) << |
(...skipping 360 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
495 void RootView::GetAccessibleState(ui::AXViewState* state) { | 498 void RootView::GetAccessibleState(ui::AXViewState* state) { |
496 state->name = widget_->widget_delegate()->GetAccessibleWindowTitle(); | 499 state->name = widget_->widget_delegate()->GetAccessibleWindowTitle(); |
497 state->role = widget_->widget_delegate()->GetAccessibleWindowRole(); | 500 state->role = widget_->widget_delegate()->GetAccessibleWindowRole(); |
498 } | 501 } |
499 | 502 |
500 void RootView::UpdateParentLayer() { | 503 void RootView::UpdateParentLayer() { |
501 if (layer()) | 504 if (layer()) |
502 ReparentLayer(gfx::Vector2d(GetMirroredX(), y()), widget_->GetLayer()); | 505 ReparentLayer(gfx::Vector2d(GetMirroredX(), y()), widget_->GetLayer()); |
503 } | 506 } |
504 | 507 |
508 void RootView::OnNativeThemeChange() { | |
509 PropagateNativeThemeChanged(GetNativeTheme()); | |
510 } | |
511 | |
505 //////////////////////////////////////////////////////////////////////////////// | 512 //////////////////////////////////////////////////////////////////////////////// |
506 // RootView, protected: | 513 // RootView, protected: |
507 | 514 |
508 void RootView::DispatchGestureEvent(ui::GestureEvent* event) { | 515 void RootView::DispatchGestureEvent(ui::GestureEvent* event) { |
509 if (gesture_handler_) { | 516 if (gesture_handler_) { |
510 // |gesture_handler_| (or |scroll_gesture_handler_|) can be deleted during | 517 // |gesture_handler_| (or |scroll_gesture_handler_|) can be deleted during |
511 // processing. | 518 // processing. |
512 View* handler = scroll_gesture_handler_ && | 519 View* handler = scroll_gesture_handler_ && |
513 (event->IsScrollGestureEvent() || event->IsFlingScrollEvent()) ? | 520 (event->IsScrollGestureEvent() || event->IsFlingScrollEvent()) ? |
514 scroll_gesture_handler_ : gesture_handler_; | 521 scroll_gesture_handler_ : gesture_handler_; |
(...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
776 | 783 |
777 #ifndef NDEBUG | 784 #ifndef NDEBUG |
778 DCHECK(!event_dispatch_target_ || Contains(event_dispatch_target_)); | 785 DCHECK(!event_dispatch_target_ || Contains(event_dispatch_target_)); |
779 #endif | 786 #endif |
780 | 787 |
781 return details; | 788 return details; |
782 } | 789 } |
783 | 790 |
784 } // namespace internal | 791 } // namespace internal |
785 } // namespace views | 792 } // namespace views |
OLD | NEW |