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