| 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 "chrome/browser/ui/views/omnibox/omnibox_popup_contents_view.h" | 5 #include "chrome/browser/ui/views/omnibox/omnibox_popup_contents_view.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "chrome/browser/search/search.h" | 9 #include "chrome/browser/search/search.h" |
| 10 #include "chrome/browser/themes/theme_properties.h" | 10 #include "chrome/browser/themes/theme_properties.h" |
| (...skipping 316 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 327 NEW_BACKGROUND_TAB); | 327 NEW_BACKGROUND_TAB); |
| 328 } | 328 } |
| 329 } | 329 } |
| 330 | 330 |
| 331 void OmniboxPopupContentsView::OnMouseCaptureLost() { | 331 void OmniboxPopupContentsView::OnMouseCaptureLost() { |
| 332 ignore_mouse_drag_ = false; | 332 ignore_mouse_drag_ = false; |
| 333 } | 333 } |
| 334 | 334 |
| 335 void OmniboxPopupContentsView::OnMouseMoved( | 335 void OmniboxPopupContentsView::OnMouseMoved( |
| 336 const ui::MouseEvent& event) { | 336 const ui::MouseEvent& event) { |
| 337 model_->SetHoveredLine(GetIndexForPoint(event.location())); | 337 model_->SetHoveredLine( |
| 338 GetIndexForPoint(gfx::ToFlooredPoint(event.location()))); |
| 338 } | 339 } |
| 339 | 340 |
| 340 void OmniboxPopupContentsView::OnMouseEntered( | 341 void OmniboxPopupContentsView::OnMouseEntered( |
| 341 const ui::MouseEvent& event) { | 342 const ui::MouseEvent& event) { |
| 342 model_->SetHoveredLine(GetIndexForPoint(event.location())); | 343 model_->SetHoveredLine( |
| 344 GetIndexForPoint(gfx::ToFlooredPoint(event.location()))); |
| 343 } | 345 } |
| 344 | 346 |
| 345 void OmniboxPopupContentsView::OnMouseExited( | 347 void OmniboxPopupContentsView::OnMouseExited( |
| 346 const ui::MouseEvent& event) { | 348 const ui::MouseEvent& event) { |
| 347 model_->SetHoveredLine(OmniboxPopupModel::kNoMatch); | 349 model_->SetHoveredLine(OmniboxPopupModel::kNoMatch); |
| 348 } | 350 } |
| 349 | 351 |
| 350 void OmniboxPopupContentsView::OnGestureEvent(ui::GestureEvent* event) { | 352 void OmniboxPopupContentsView::OnGestureEvent(ui::GestureEvent* event) { |
| 351 switch (event->type()) { | 353 switch (event->type()) { |
| 352 case ui::ET_GESTURE_TAP_DOWN: | 354 case ui::ET_GESTURE_TAP_DOWN: |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 473 View::ConvertPointToTarget(this, child, &point_in_child_coords); | 475 View::ConvertPointToTarget(this, child, &point_in_child_coords); |
| 474 if (child->visible() && child->HitTestPoint(point_in_child_coords)) | 476 if (child->visible() && child->HitTestPoint(point_in_child_coords)) |
| 475 return i; | 477 return i; |
| 476 } | 478 } |
| 477 return OmniboxPopupModel::kNoMatch; | 479 return OmniboxPopupModel::kNoMatch; |
| 478 } | 480 } |
| 479 | 481 |
| 480 void OmniboxPopupContentsView::UpdateLineEvent( | 482 void OmniboxPopupContentsView::UpdateLineEvent( |
| 481 const ui::LocatedEvent& event, | 483 const ui::LocatedEvent& event, |
| 482 bool should_set_selected_line) { | 484 bool should_set_selected_line) { |
| 483 size_t index = GetIndexForPoint(event.location()); | 485 size_t index = GetIndexForPoint(gfx::ToFlooredPoint(event.location())); |
| 484 model_->SetHoveredLine(index); | 486 model_->SetHoveredLine(index); |
| 485 if (HasMatchAt(index) && should_set_selected_line) | 487 if (HasMatchAt(index) && should_set_selected_line) |
| 486 model_->SetSelectedLine(index, false, false); | 488 model_->SetSelectedLine(index, false, false); |
| 487 } | 489 } |
| 488 | 490 |
| 489 void OmniboxPopupContentsView::OpenSelectedLine( | 491 void OmniboxPopupContentsView::OpenSelectedLine( |
| 490 const ui::LocatedEvent& event, | 492 const ui::LocatedEvent& event, |
| 491 WindowOpenDisposition disposition) { | 493 WindowOpenDisposition disposition) { |
| 492 size_t index = GetIndexForPoint(event.location()); | 494 size_t index = GetIndexForPoint(gfx::ToFlooredPoint(event.location())); |
| 493 if (!HasMatchAt(index)) | 495 if (!HasMatchAt(index)) |
| 494 return; | 496 return; |
| 495 omnibox_view_->OpenMatch(model_->result().match_at(index), disposition, | 497 omnibox_view_->OpenMatch(model_->result().match_at(index), disposition, |
| 496 GURL(), base::string16(), index); | 498 GURL(), base::string16(), index); |
| 497 } | 499 } |
| 498 | 500 |
| 499 OmniboxResultView* OmniboxPopupContentsView::result_view_at(size_t i) { | 501 OmniboxResultView* OmniboxPopupContentsView::result_view_at(size_t i) { |
| 500 return static_cast<OmniboxResultView*>(child_at(static_cast<int>(i))); | 502 return static_cast<OmniboxResultView*>(child_at(static_cast<int>(i))); |
| 501 } | 503 } |
| OLD | NEW |