| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 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 | 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/view.h" | 5 #include "ui/views/view.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/debug/trace_event.h" | 9 #include "base/debug/trace_event.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 310 } | 310 } |
| 311 | 311 |
| 312 gfx::Insets View::GetInsets() const { | 312 gfx::Insets View::GetInsets() const { |
| 313 gfx::Insets insets; | 313 gfx::Insets insets; |
| 314 if (border_.get()) | 314 if (border_.get()) |
| 315 border_->GetInsets(&insets); | 315 border_->GetInsets(&insets); |
| 316 return insets; | 316 return insets; |
| 317 } | 317 } |
| 318 | 318 |
| 319 gfx::Rect View::GetVisibleBounds() const { | 319 gfx::Rect View::GetVisibleBounds() const { |
| 320 if (!IsVisibleInRootView()) | 320 if (!IsDrawn()) |
| 321 return gfx::Rect(); | 321 return gfx::Rect(); |
| 322 gfx::Rect vis_bounds(0, 0, width(), height()); | 322 gfx::Rect vis_bounds(0, 0, width(), height()); |
| 323 gfx::Rect ancestor_bounds; | 323 gfx::Rect ancestor_bounds; |
| 324 const View* view = this; | 324 const View* view = this; |
| 325 ui::Transform transform; | 325 ui::Transform transform; |
| 326 | 326 |
| 327 while (view != NULL && !vis_bounds.IsEmpty()) { | 327 while (view != NULL && !vis_bounds.IsEmpty()) { |
| 328 transform.ConcatTransform(view->GetTransform()); | 328 transform.ConcatTransform(view->GetTransform()); |
| 329 transform.ConcatTranslate(static_cast<float>(view->GetMirroredX()), | 329 transform.ConcatTranslate(static_cast<float>(view->GetMirroredX()), |
| 330 static_cast<float>(view->y())); | 330 static_cast<float>(view->y())); |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 391 // This notifies all sub-views recursively. | 391 // This notifies all sub-views recursively. |
| 392 PropagateVisibilityNotifications(this, visible_); | 392 PropagateVisibilityNotifications(this, visible_); |
| 393 UpdateLayerVisibility(); | 393 UpdateLayerVisibility(); |
| 394 | 394 |
| 395 // If we are newly visible, schedule paint. | 395 // If we are newly visible, schedule paint. |
| 396 if (visible_) | 396 if (visible_) |
| 397 SchedulePaint(); | 397 SchedulePaint(); |
| 398 } | 398 } |
| 399 } | 399 } |
| 400 | 400 |
| 401 bool View::IsVisibleInRootView() const { | 401 bool View::IsDrawn() const { |
| 402 return visible_ && parent_ ? parent_->IsVisibleInRootView() : false; | 402 return visible_ && parent_ ? parent_->IsDrawn() : false; |
| 403 } | 403 } |
| 404 | 404 |
| 405 void View::SetEnabled(bool enabled) { | 405 void View::SetEnabled(bool enabled) { |
| 406 if (enabled != enabled_) { | 406 if (enabled != enabled_) { |
| 407 enabled_ = enabled; | 407 enabled_ = enabled; |
| 408 OnEnabledChanged(); | 408 OnEnabledChanged(); |
| 409 } | 409 } |
| 410 } | 410 } |
| 411 | 411 |
| 412 void View::OnEnabledChanged() { | 412 void View::OnEnabledChanged() { |
| (...skipping 475 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 888 View* View::GetPreviousFocusableView() { | 888 View* View::GetPreviousFocusableView() { |
| 889 return previous_focusable_view_; | 889 return previous_focusable_view_; |
| 890 } | 890 } |
| 891 | 891 |
| 892 void View::SetNextFocusableView(View* view) { | 892 void View::SetNextFocusableView(View* view) { |
| 893 view->previous_focusable_view_ = this; | 893 view->previous_focusable_view_ = this; |
| 894 next_focusable_view_ = view; | 894 next_focusable_view_ = view; |
| 895 } | 895 } |
| 896 | 896 |
| 897 bool View::IsFocusableInRootView() const { | 897 bool View::IsFocusableInRootView() const { |
| 898 return IsFocusable() && IsVisibleInRootView(); | 898 return IsFocusable() && IsDrawn(); |
| 899 } | 899 } |
| 900 | 900 |
| 901 bool View::IsAccessibilityFocusableInRootView() const { | 901 bool View::IsAccessibilityFocusableInRootView() const { |
| 902 return (focusable_ || accessibility_focusable_) && enabled_ && | 902 return (focusable_ || accessibility_focusable_) && enabled_ && IsDrawn(); |
| 903 IsVisibleInRootView(); | |
| 904 } | 903 } |
| 905 | 904 |
| 906 FocusManager* View::GetFocusManager() { | 905 FocusManager* View::GetFocusManager() { |
| 907 Widget* widget = GetWidget(); | 906 Widget* widget = GetWidget(); |
| 908 return widget ? widget->GetFocusManager() : NULL; | 907 return widget ? widget->GetFocusManager() : NULL; |
| 909 } | 908 } |
| 910 | 909 |
| 911 const FocusManager* View::GetFocusManager() const { | 910 const FocusManager* View::GetFocusManager() const { |
| 912 const Widget* widget = GetWidget(); | 911 const Widget* widget = GetWidget(); |
| 913 return widget ? widget->GetFocusManager() : NULL; | 912 return widget ? widget->GetFocusManager() : NULL; |
| (...skipping 1014 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1928 // TODO(jcampan): This fails for a view under NativeWidgetGtk with | 1927 // TODO(jcampan): This fails for a view under NativeWidgetGtk with |
| 1929 // TYPE_CHILD. (see http://crbug.com/21335) reenable | 1928 // TYPE_CHILD. (see http://crbug.com/21335) reenable |
| 1930 // NOTREACHED assertion and verify accelerators works as | 1929 // NOTREACHED assertion and verify accelerators works as |
| 1931 // expected. | 1930 // expected. |
| 1932 #if defined(OS_WIN) | 1931 #if defined(OS_WIN) |
| 1933 NOTREACHED(); | 1932 NOTREACHED(); |
| 1934 #endif | 1933 #endif |
| 1935 return; | 1934 return; |
| 1936 } | 1935 } |
| 1937 // Only register accelerators if we are visible. | 1936 // Only register accelerators if we are visible. |
| 1938 if (!IsVisibleInRootView() || !GetWidget()->IsVisible()) | 1937 if (!IsDrawn() || !GetWidget()->IsVisible()) |
| 1939 return; | 1938 return; |
| 1940 for (std::vector<ui::Accelerator>::const_iterator i( | 1939 for (std::vector<ui::Accelerator>::const_iterator i( |
| 1941 accelerators_->begin() + registered_accelerator_count_); | 1940 accelerators_->begin() + registered_accelerator_count_); |
| 1942 i != accelerators_->end(); ++i) { | 1941 i != accelerators_->end(); ++i) { |
| 1943 accelerator_focus_manager_->RegisterAccelerator(*i, this); | 1942 accelerator_focus_manager_->RegisterAccelerator(*i, this); |
| 1944 } | 1943 } |
| 1945 registered_accelerator_count_ = accelerators_->size(); | 1944 registered_accelerator_count_ = accelerators_->size(); |
| 1946 } | 1945 } |
| 1947 | 1946 |
| 1948 void View::UnregisterAccelerators(bool leave_data_intact) { | 1947 void View::UnregisterAccelerators(bool leave_data_intact) { |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2043 | 2042 |
| 2044 OSExchangeData data; | 2043 OSExchangeData data; |
| 2045 WriteDragData(press_pt, &data); | 2044 WriteDragData(press_pt, &data); |
| 2046 | 2045 |
| 2047 // Message the RootView to do the drag and drop. That way if we're removed | 2046 // Message the RootView to do the drag and drop. That way if we're removed |
| 2048 // the RootView can detect it and avoid calling us back. | 2047 // the RootView can detect it and avoid calling us back. |
| 2049 GetWidget()->RunShellDrag(this, data, drag_operations); | 2048 GetWidget()->RunShellDrag(this, data, drag_operations); |
| 2050 } | 2049 } |
| 2051 | 2050 |
| 2052 } // namespace views | 2051 } // namespace views |
| OLD | NEW |