Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "chrome/browser/ui/views/autofill/autofill_popup_base_view.h" | 5 #include "chrome/browser/ui/views/autofill/autofill_popup_base_view.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/location.h" | 8 #include "base/location.h" |
| 9 #include "base/single_thread_task_runner.h" | 9 #include "base/single_thread_task_runner.h" |
| 10 #include "base/threading/thread_task_runner_handle.h" | 10 #include "base/threading/thread_task_runner_handle.h" |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 54 params.delegate = this; | 54 params.delegate = this; |
| 55 params.parent = parent_widget_->GetNativeView(); | 55 params.parent = parent_widget_->GetNativeView(); |
| 56 widget->Init(params); | 56 widget->Init(params); |
| 57 | 57 |
| 58 // No animation for popup appearance (too distracting). | 58 // No animation for popup appearance (too distracting). |
| 59 widget->SetVisibilityAnimationTransition(views::Widget::ANIMATE_HIDE); | 59 widget->SetVisibilityAnimationTransition(views::Widget::ANIMATE_HIDE); |
| 60 | 60 |
| 61 show_time_ = base::Time::Now(); | 61 show_time_ = base::Time::Now(); |
| 62 } | 62 } |
| 63 | 63 |
| 64 // TODO(crbug.com/676164): Show different border color when focused/unfocused | |
| 65 SetBorder(views::CreateSolidBorder( | |
| 66 kPopupBorderThickness, | |
| 67 GetNativeTheme()->GetSystemColor( | |
| 68 ui::NativeTheme::kColorId_UnfocusedBorderColor))); | |
| 69 | |
| 70 DoUpdateBoundsAndRedrawPopup(); | 64 DoUpdateBoundsAndRedrawPopup(); |
| 71 GetWidget()->Show(); | 65 GetWidget()->Show(); |
| 72 | 66 |
| 73 // Showing the widget can change native focus (which would result in an | 67 // Showing the widget can change native focus (which would result in an |
| 74 // immediate hiding of the popup). Only start observing after shown. | 68 // immediate hiding of the popup). Only start observing after shown. |
| 75 if (initialize_widget) | 69 if (initialize_widget) |
| 76 views::WidgetFocusManager::GetInstance()->AddFocusChangeListener(this); | 70 views::WidgetFocusManager::GetInstance()->AddFocusChangeListener(this); |
| 77 } | 71 } |
| 78 | 72 |
| 79 void AutofillPopupBaseView::DoHide() { | 73 void AutofillPopupBaseView::DoHide() { |
| (...skipping 20 matching lines...) Expand all Loading... | |
| 100 } | 94 } |
| 101 | 95 |
| 102 void AutofillPopupBaseView::RemoveObserver() { | 96 void AutofillPopupBaseView::RemoveObserver() { |
| 103 parent_widget_->GetFocusManager()->UnregisterAccelerators(this); | 97 parent_widget_->GetFocusManager()->UnregisterAccelerators(this); |
| 104 parent_widget_->RemoveObserver(this); | 98 parent_widget_->RemoveObserver(this); |
| 105 views::WidgetFocusManager::GetInstance()->RemoveFocusChangeListener(this); | 99 views::WidgetFocusManager::GetInstance()->RemoveFocusChangeListener(this); |
| 106 } | 100 } |
| 107 | 101 |
| 108 void AutofillPopupBaseView::DoUpdateBoundsAndRedrawPopup() { | 102 void AutofillPopupBaseView::DoUpdateBoundsAndRedrawPopup() { |
| 109 GetWidget()->SetBounds(delegate_->popup_bounds()); | 103 GetWidget()->SetBounds(delegate_->popup_bounds()); |
| 104 | |
| 105 // We update the border whenever bounds are updated. Due to rounding when | |
| 106 // calculating the actual view size (bounds()) from the requested view size | |
| 107 // (delegate_.popup_bounds()), we may end up with extra space at the bottom | |
| 108 // and right of the view. We fill this with extra border pixels. | |
|
Peter Kasting
2017/02/16 00:30:26
Rob, can you comment here?
It seems like the issu
| |
| 109 int extra_border_thickness_x = | |
| 110 bounds().width() - delegate_->popup_bounds().width(); | |
| 111 int extra_border_thickness_y = | |
| 112 bounds().height() - delegate_->popup_bounds().height(); | |
| 113 | |
| 114 // TODO(crbug.com/676164): Show different border color when focused/unfocused | |
| 115 SetBorder(views::CreateSolidSidedBorder( | |
| 116 kPopupBorderThickness, kPopupBorderThickness, | |
| 117 kPopupBorderThickness + extra_border_thickness_y, | |
| 118 kPopupBorderThickness + extra_border_thickness_x, | |
| 119 GetNativeTheme()->GetSystemColor( | |
| 120 ui::NativeTheme::kColorId_UnfocusedBorderColor))); | |
| 121 | |
| 110 SchedulePaint(); | 122 SchedulePaint(); |
| 111 } | 123 } |
| 112 | 124 |
| 125 gfx::Rect AutofillPopupBaseView::GetPopupBounds() const { | |
| 126 return delegate_->popup_bounds(); | |
| 127 } | |
| 128 | |
| 113 void AutofillPopupBaseView::OnNativeFocusChanged(gfx::NativeView focused_now) { | 129 void AutofillPopupBaseView::OnNativeFocusChanged(gfx::NativeView focused_now) { |
| 114 if (GetWidget() && GetWidget()->GetNativeView() != focused_now) | 130 if (GetWidget() && GetWidget()->GetNativeView() != focused_now) |
| 115 HideController(); | 131 HideController(); |
| 116 } | 132 } |
| 117 | 133 |
| 118 void AutofillPopupBaseView::OnMouseCaptureLost() { | 134 void AutofillPopupBaseView::OnMouseCaptureLost() { |
| 119 ClearSelection(); | 135 ClearSelection(); |
| 120 } | 136 } |
| 121 | 137 |
| 122 bool AutofillPopupBaseView::OnMouseDragged(const ui::MouseEvent& event) { | 138 bool AutofillPopupBaseView::OnMouseDragged(const ui::MouseEvent& event) { |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 235 void AutofillPopupBaseView::HideController() { | 251 void AutofillPopupBaseView::HideController() { |
| 236 if (delegate_) | 252 if (delegate_) |
| 237 delegate_->Hide(); | 253 delegate_->Hide(); |
| 238 } | 254 } |
| 239 | 255 |
| 240 gfx::NativeView AutofillPopupBaseView::container_view() { | 256 gfx::NativeView AutofillPopupBaseView::container_view() { |
| 241 return delegate_->container_view(); | 257 return delegate_->container_view(); |
| 242 } | 258 } |
| 243 | 259 |
| 244 } // namespace autofill | 260 } // namespace autofill |
| OLD | NEW |