Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(248)

Side by Side Diff: chrome/browser/ui/views/autofill/autofill_popup_base_view.cc

Issue 1018393002: [autofill] Ingore mouse move on Windows for the first 50ms. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Use timeGetTime() for more uniform deltas. Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « chrome/browser/ui/views/autofill/autofill_popup_base_view.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/message_loop/message_loop.h" 9 #include "base/message_loop/message_loop.h"
10 #include "chrome/browser/ui/autofill/popup_constants.h" 10 #include "chrome/browser/ui/autofill/popup_constants.h"
11 #include "ui/views/border.h" 11 #include "ui/views/border.h"
12 #include "ui/views/focus/focus_manager.h" 12 #include "ui/views/focus/focus_manager.h"
13 #include "ui/views/widget/widget.h" 13 #include "ui/views/widget/widget.h"
14 14
15 #if defined(OS_WIN)
16 #include <mmsystem.h>
Evan Stade 2015/03/20 19:27:52 ewww can you use TimeTicks or something?
please use gerrit instead 2015/03/20 20:55:53 event.time_stamp() is comparable to GetTickCount()
spang 2015/03/22 17:14:03 Please don't put this kind of workaround here with
17 #endif
18
15 namespace autofill { 19 namespace autofill {
16 20
17 const SkColor AutofillPopupBaseView::kBorderColor = 21 const SkColor AutofillPopupBaseView::kBorderColor =
18 SkColorSetARGB(0xFF, 0xC7, 0xCA, 0xCE); 22 SkColorSetARGB(0xFF, 0xC7, 0xCA, 0xCE);
19 const SkColor AutofillPopupBaseView::kHoveredBackgroundColor = 23 const SkColor AutofillPopupBaseView::kHoveredBackgroundColor =
20 SkColorSetARGB(0xFF, 0xCD, 0xCD, 0xCD); 24 SkColorSetARGB(0xFF, 0xCD, 0xCD, 0xCD);
21 const SkColor AutofillPopupBaseView::kItemTextColor = 25 const SkColor AutofillPopupBaseView::kItemTextColor =
22 SkColorSetARGB(0xFF, 0x7F, 0x7F, 0x7F); 26 SkColorSetARGB(0xFF, 0x7F, 0x7F, 0x7F);
23 const SkColor AutofillPopupBaseView::kPopupBackground = 27 const SkColor AutofillPopupBaseView::kPopupBackground =
24 SkColorSetARGB(0xFF, 0xFF, 0xFF, 0xFF); 28 SkColorSetARGB(0xFF, 0xFF, 0xFF, 0xFF);
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 // deletion. 63 // deletion.
60 views::Widget* widget = new views::Widget; 64 views::Widget* widget = new views::Widget;
61 views::Widget::InitParams params(views::Widget::InitParams::TYPE_POPUP); 65 views::Widget::InitParams params(views::Widget::InitParams::TYPE_POPUP);
62 params.delegate = this; 66 params.delegate = this;
63 params.parent = container_view(); 67 params.parent = container_view();
64 widget->Init(params); 68 widget->Init(params);
65 widget->SetContentsView(this); 69 widget->SetContentsView(this);
66 70
67 // No animation for popup appearance (too distracting). 71 // No animation for popup appearance (too distracting).
68 widget->SetVisibilityAnimationTransition(views::Widget::ANIMATE_HIDE); 72 widget->SetVisibilityAnimationTransition(views::Widget::ANIMATE_HIDE);
73
74 #if defined(OS_WIN)
75 show_time_ = base::TimeDelta::FromMilliseconds(timeGetTime());
76 #endif
69 } 77 }
70 78
71 SetBorder(views::Border::CreateSolidBorder(kPopupBorderThickness, 79 SetBorder(views::Border::CreateSolidBorder(kPopupBorderThickness,
72 kBorderColor)); 80 kBorderColor));
73 81
74 DoUpdateBoundsAndRedrawPopup(); 82 DoUpdateBoundsAndRedrawPopup();
75 GetWidget()->Show(); 83 GetWidget()->Show();
76 84
77 // Showing the widget can change native focus (which would result in an 85 // Showing the widget can change native focus (which would result in an
78 // immediate hiding of the popup). Only start observing after shown. 86 // immediate hiding of the popup). Only start observing after shown.
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
136 // via AcceleratorPressed, so we need to let that run first. 144 // via AcceleratorPressed, so we need to let that run first.
137 base::MessageLoop::current()->PostTask( 145 base::MessageLoop::current()->PostTask(
138 FROM_HERE, 146 FROM_HERE,
139 base::Bind(&AutofillPopupBaseView::ClearSelection, 147 base::Bind(&AutofillPopupBaseView::ClearSelection,
140 weak_ptr_factory_.GetWeakPtr())); 148 weak_ptr_factory_.GetWeakPtr()));
141 } 149 }
142 150
143 void AutofillPopupBaseView::OnMouseMoved(const ui::MouseEvent& event) { 151 void AutofillPopupBaseView::OnMouseMoved(const ui::MouseEvent& event) {
144 // A synthesized mouse move will be sent when the popup is first shown. 152 // A synthesized mouse move will be sent when the popup is first shown.
145 // Don't preview a suggestion if the mouse happens to be hovering there. 153 // Don't preview a suggestion if the mouse happens to be hovering there.
154 #if defined(OS_WIN)
155 if (event.time_stamp() - show_time_ <= base::TimeDelta::FromMilliseconds(50))
156 return;
157 #else
146 if (event.flags() & ui::EF_IS_SYNTHESIZED) 158 if (event.flags() & ui::EF_IS_SYNTHESIZED)
147 return; 159 return;
160 #endif
148 161
149 if (HitTestPoint(event.location())) 162 if (HitTestPoint(event.location()))
150 SetSelection(event.location()); 163 SetSelection(event.location());
151 else 164 else
152 ClearSelection(); 165 ClearSelection();
153 } 166 }
154 167
155 bool AutofillPopupBaseView::OnMousePressed(const ui::MouseEvent& event) { 168 bool AutofillPopupBaseView::OnMousePressed(const ui::MouseEvent& event) {
156 return event.GetClickCount() == 1; 169 return event.GetClickCount() == 1;
157 } 170 }
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
226 void AutofillPopupBaseView::HideController() { 239 void AutofillPopupBaseView::HideController() {
227 if (delegate_) 240 if (delegate_)
228 delegate_->Hide(); 241 delegate_->Hide();
229 } 242 }
230 243
231 gfx::NativeView AutofillPopupBaseView::container_view() { 244 gfx::NativeView AutofillPopupBaseView::container_view() {
232 return delegate_->container_view(); 245 return delegate_->container_view();
233 } 246 }
234 247
235 } // namespace autofill 248 } // namespace autofill
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/autofill/autofill_popup_base_view.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698