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/controls/scrollbar/native_scroll_bar.h" | 5 #include "ui/views/controls/scrollbar/native_scroll_bar.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
50 | 50 |
51 void NativeScrollBar::Layout() { | 51 void NativeScrollBar::Layout() { |
52 if (native_wrapper_) { | 52 if (native_wrapper_) { |
53 native_wrapper_->GetView()->SetBounds(0, 0, width(), height()); | 53 native_wrapper_->GetView()->SetBounds(0, 0, width(), height()); |
54 native_wrapper_->GetView()->Layout(); | 54 native_wrapper_->GetView()->Layout(); |
55 } | 55 } |
56 } | 56 } |
57 | 57 |
58 void NativeScrollBar::ViewHierarchyChanged( | 58 void NativeScrollBar::ViewHierarchyChanged( |
59 const ViewHierarchyChangedDetails& details) { | 59 const ViewHierarchyChangedDetails& details) { |
60 Widget* widget; | 60 if (details.is_add && !native_wrapper_ && GetWidget()) { |
61 if (details.is_add && !native_wrapper_ && (widget = GetWidget())) { | |
62 native_wrapper_ = NativeScrollBarWrapper::CreateWrapper(this); | 61 native_wrapper_ = NativeScrollBarWrapper::CreateWrapper(this); |
63 AddChildView(native_wrapper_->GetView()); | 62 AddChildView(native_wrapper_->GetView()); |
64 } | 63 } |
65 } | 64 } |
66 | 65 |
67 const char* NativeScrollBar::GetClassName() const { | 66 const char* NativeScrollBar::GetClassName() const { |
68 return kViewClassName; | 67 return kViewClassName; |
69 } | 68 } |
70 | 69 |
71 // Overridden from View for keyboard UI. | 70 // Overridden from View for keyboard UI. |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
105 } | 104 } |
106 | 105 |
107 int NativeScrollBar::GetPosition() const { | 106 int NativeScrollBar::GetPosition() const { |
108 if (!native_wrapper_) | 107 if (!native_wrapper_) |
109 return 0; | 108 return 0; |
110 return native_wrapper_->GetPosition(); | 109 return native_wrapper_->GetPosition(); |
111 } | 110 } |
112 | 111 |
113 } // namespace views | 112 } // namespace views |
114 | 113 |
OLD | NEW |