| 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/widget.h" | 5 #include "ui/views/widget/widget.h" |
| 6 | 6 |
| 7 #include "base/auto_reset.h" |
| 7 #include "base/logging.h" | 8 #include "base/logging.h" |
| 8 #include "base/macros.h" | 9 #include "base/macros.h" |
| 9 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
| 10 #include "base/strings/utf_string_conversions.h" | 11 #include "base/strings/utf_string_conversions.h" |
| 11 #include "base/trace_event/trace_event.h" | 12 #include "base/trace_event/trace_event.h" |
| 12 #include "ui/base/cursor/cursor.h" | 13 #include "ui/base/cursor/cursor.h" |
| 13 #include "ui/base/default_style.h" | 14 #include "ui/base/default_style.h" |
| 14 #include "ui/base/default_theme_provider.h" | 15 #include "ui/base/default_theme_provider.h" |
| 15 #include "ui/base/hit_test.h" | 16 #include "ui/base/hit_test.h" |
| 16 #include "ui/base/ime/input_method.h" | 17 #include "ui/base/ime/input_method.h" |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 158 focus_on_creation_(true), | 159 focus_on_creation_(true), |
| 159 is_top_level_(false), | 160 is_top_level_(false), |
| 160 native_widget_initialized_(false), | 161 native_widget_initialized_(false), |
| 161 native_widget_destroyed_(false), | 162 native_widget_destroyed_(false), |
| 162 is_mouse_button_pressed_(false), | 163 is_mouse_button_pressed_(false), |
| 163 ignore_capture_loss_(false), | 164 ignore_capture_loss_(false), |
| 164 last_mouse_event_was_move_(false), | 165 last_mouse_event_was_move_(false), |
| 165 auto_release_capture_(true), | 166 auto_release_capture_(true), |
| 166 root_layers_dirty_(false), | 167 root_layers_dirty_(false), |
| 167 movement_disabled_(false), | 168 movement_disabled_(false), |
| 168 observer_manager_(this) { | 169 observer_manager_(this), |
| 170 processing_theme_changed_(false) { |
| 169 } | 171 } |
| 170 | 172 |
| 171 Widget::~Widget() { | 173 Widget::~Widget() { |
| 172 DestroyRootView(); | 174 DestroyRootView(); |
| 173 if (ownership_ == InitParams::WIDGET_OWNS_NATIVE_WIDGET) { | 175 if (ownership_ == InitParams::WIDGET_OWNS_NATIVE_WIDGET) { |
| 174 delete native_widget_; | 176 delete native_widget_; |
| 175 } else { | 177 } else { |
| 176 DCHECK(native_widget_destroyed_) | 178 DCHECK(native_widget_destroyed_) |
| 177 << "Destroying a widget with a live native widget. " | 179 << "Destroying a widget with a live native widget. " |
| 178 << "Widget probably should use WIDGET_OWNS_NATIVE_WIDGET ownership."; | 180 << "Widget probably should use WIDGET_OWNS_NATIVE_WIDGET ownership."; |
| (...skipping 713 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 892 frame_type_ = ShouldUseNativeFrame() ? FRAME_TYPE_FORCE_CUSTOM : | 894 frame_type_ = ShouldUseNativeFrame() ? FRAME_TYPE_FORCE_CUSTOM : |
| 893 FRAME_TYPE_FORCE_NATIVE; | 895 FRAME_TYPE_FORCE_NATIVE; |
| 894 } else { | 896 } else { |
| 895 frame_type_ = frame_type_ == FRAME_TYPE_FORCE_CUSTOM ? | 897 frame_type_ = frame_type_ == FRAME_TYPE_FORCE_CUSTOM ? |
| 896 FRAME_TYPE_FORCE_NATIVE : FRAME_TYPE_FORCE_CUSTOM; | 898 FRAME_TYPE_FORCE_NATIVE : FRAME_TYPE_FORCE_CUSTOM; |
| 897 } | 899 } |
| 898 FrameTypeChanged(); | 900 FrameTypeChanged(); |
| 899 } | 901 } |
| 900 | 902 |
| 901 void Widget::FrameTypeChanged() { | 903 void Widget::FrameTypeChanged() { |
| 904 if (processing_theme_changed_) |
| 905 return; |
| 902 native_widget_->FrameTypeChanged(); | 906 native_widget_->FrameTypeChanged(); |
| 903 } | 907 } |
| 904 | 908 |
| 905 const ui::Compositor* Widget::GetCompositor() const { | 909 const ui::Compositor* Widget::GetCompositor() const { |
| 906 return native_widget_->GetCompositor(); | 910 return native_widget_->GetCompositor(); |
| 907 } | 911 } |
| 908 | 912 |
| 909 const ui::Layer* Widget::GetLayer() const { | 913 const ui::Layer* Widget::GetLayer() const { |
| 910 return native_widget_->GetLayer(); | 914 return native_widget_->GetLayer(); |
| 911 } | 915 } |
| (...skipping 443 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1355 | 1359 |
| 1356 void Widget::OnNativeThemeUpdated(ui::NativeTheme* observed_theme) { | 1360 void Widget::OnNativeThemeUpdated(ui::NativeTheme* observed_theme) { |
| 1357 DCHECK(observer_manager_.IsObserving(observed_theme)); | 1361 DCHECK(observer_manager_.IsObserving(observed_theme)); |
| 1358 | 1362 |
| 1359 ui::NativeTheme* current_native_theme = GetNativeTheme(); | 1363 ui::NativeTheme* current_native_theme = GetNativeTheme(); |
| 1360 if (!observer_manager_.IsObserving(current_native_theme)) { | 1364 if (!observer_manager_.IsObserving(current_native_theme)) { |
| 1361 observer_manager_.RemoveAll(); | 1365 observer_manager_.RemoveAll(); |
| 1362 observer_manager_.Add(current_native_theme); | 1366 observer_manager_.Add(current_native_theme); |
| 1363 } | 1367 } |
| 1364 | 1368 |
| 1369 DCHECK_EQ(processing_theme_changed_, false); |
| 1370 |
| 1371 base::AutoReset<bool> auto_theme_changed_recursion_break( |
| 1372 &processing_theme_changed_, true); |
| 1365 root_view_->PropagateNativeThemeChanged(current_native_theme); | 1373 root_view_->PropagateNativeThemeChanged(current_native_theme); |
| 1366 } | 1374 } |
| 1367 | 1375 |
| 1368 //////////////////////////////////////////////////////////////////////////////// | 1376 //////////////////////////////////////////////////////////////////////////////// |
| 1369 // Widget, protected: | 1377 // Widget, protected: |
| 1370 | 1378 |
| 1371 internal::RootView* Widget::CreateRootView() { | 1379 internal::RootView* Widget::CreateRootView() { |
| 1372 return new internal::RootView(this); | 1380 return new internal::RootView(this); |
| 1373 } | 1381 } |
| 1374 | 1382 |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1496 | 1504 |
| 1497 //////////////////////////////////////////////////////////////////////////////// | 1505 //////////////////////////////////////////////////////////////////////////////// |
| 1498 // internal::NativeWidgetPrivate, NativeWidget implementation: | 1506 // internal::NativeWidgetPrivate, NativeWidget implementation: |
| 1499 | 1507 |
| 1500 internal::NativeWidgetPrivate* NativeWidgetPrivate::AsNativeWidgetPrivate() { | 1508 internal::NativeWidgetPrivate* NativeWidgetPrivate::AsNativeWidgetPrivate() { |
| 1501 return this; | 1509 return this; |
| 1502 } | 1510 } |
| 1503 | 1511 |
| 1504 } // namespace internal | 1512 } // namespace internal |
| 1505 } // namespace views | 1513 } // namespace views |
| OLD | NEW |