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/inline_omnibox_popup_view.h" | 5 #include "chrome/browser/ui/views/omnibox/inline_omnibox_popup_view.h" |
6 | 6 |
7 #include "base/compiler_specific.h" | 7 #include "base/compiler_specific.h" |
8 #include "base/utf_string_conversions.h" | 8 #include "base/utf_string_conversions.h" |
9 #include "chrome/browser/profiles/profile.h" | 9 #include "chrome/browser/profiles/profile.h" |
10 #include "chrome/browser/ui/omnibox/omnibox_view.h" | 10 #include "chrome/browser/ui/omnibox/omnibox_view.h" |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
91 size_animation_.GetCurrentValue() * total_height_delta - 0.5); | 91 size_animation_.GetCurrentValue() * total_height_delta - 0.5); |
92 current_frame_bounds.set_height( | 92 current_frame_bounds.set_height( |
93 current_frame_bounds.height() + current_height_delta); | 93 current_frame_bounds.height() + current_height_delta); |
94 return current_frame_bounds; | 94 return current_frame_bounds; |
95 } | 95 } |
96 | 96 |
97 void InlineOmniboxPopupView::LayoutChildren() { | 97 void InlineOmniboxPopupView::LayoutChildren() { |
98 // Make the children line up with the LocationBar. | 98 // Make the children line up with the LocationBar. |
99 gfx::Point content_origin; | 99 gfx::Point content_origin; |
100 // TODO(sky): this won't work correctly with LocationBarContainer. | 100 // TODO(sky): this won't work correctly with LocationBarContainer. |
101 views::View::ConvertPointToView(location_bar_, this, &content_origin); | 101 views::View::ConvertPointToTarget(location_bar_, this, &content_origin); |
102 int x = content_origin.x(); | 102 int x = content_origin.x(); |
103 int width = location_bar_->width(); | 103 int width = location_bar_->width(); |
104 gfx::Rect contents_rect = GetContentsBounds(); | 104 gfx::Rect contents_rect = GetContentsBounds(); |
105 int top = contents_rect.y(); | 105 int top = contents_rect.y(); |
106 for (int i = 0; i < child_count(); ++i) { | 106 for (int i = 0; i < child_count(); ++i) { |
107 View* v = child_at(i); | 107 View* v = child_at(i); |
108 if (v->visible()) { | 108 if (v->visible()) { |
109 v->SetBounds(x, top, width, v->GetPreferredSize().height()); | 109 v->SetBounds(x, top, width, v->GetPreferredSize().height()); |
110 top = v->bounds().bottom(); | 110 top = v->bounds().bottom(); |
111 } | 111 } |
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
360 | 360 |
361 size_t InlineOmniboxPopupView::GetIndexForPoint(const gfx::Point& point) { | 361 size_t InlineOmniboxPopupView::GetIndexForPoint(const gfx::Point& point) { |
362 if (!HitTestPoint(point)) | 362 if (!HitTestPoint(point)) |
363 return OmniboxPopupModel::kNoMatch; | 363 return OmniboxPopupModel::kNoMatch; |
364 | 364 |
365 int nb_match = model_->result().size(); | 365 int nb_match = model_->result().size(); |
366 DCHECK(nb_match <= child_count()); | 366 DCHECK(nb_match <= child_count()); |
367 for (int i = 0; i < nb_match; ++i) { | 367 for (int i = 0; i < nb_match; ++i) { |
368 views::View* child = child_at(i); | 368 views::View* child = child_at(i); |
369 gfx::Point point_in_child_coords(point); | 369 gfx::Point point_in_child_coords(point); |
370 View::ConvertPointToView(this, child, &point_in_child_coords); | 370 View::ConvertPointToTarget(this, child, &point_in_child_coords); |
371 if (child->HitTestPoint(point_in_child_coords)) | 371 if (child->HitTestPoint(point_in_child_coords)) |
372 return i; | 372 return i; |
373 } | 373 } |
374 return OmniboxPopupModel::kNoMatch; | 374 return OmniboxPopupModel::kNoMatch; |
375 } | 375 } |
376 | 376 |
377 gfx::Rect InlineOmniboxPopupView::CalculateTargetBounds(int h) { | 377 gfx::Rect InlineOmniboxPopupView::CalculateTargetBounds(int h) { |
378 return gfx::Rect(0, 0, 1, h); | 378 return gfx::Rect(0, 0, 1, h); |
379 } | 379 } |
380 | 380 |
381 void InlineOmniboxPopupView::UpdateLineEvent( | 381 void InlineOmniboxPopupView::UpdateLineEvent( |
382 const views::LocatedEvent& event, | 382 const ui::LocatedEvent& event, |
383 bool should_set_selected_line) { | 383 bool should_set_selected_line) { |
384 size_t index = GetIndexForPoint(event.location()); | 384 size_t index = GetIndexForPoint(event.location()); |
385 model_->SetHoveredLine(index); | 385 model_->SetHoveredLine(index); |
386 if (HasMatchAt(index) && should_set_selected_line) | 386 if (HasMatchAt(index) && should_set_selected_line) |
387 model_->SetSelectedLine(index, false, false); | 387 model_->SetSelectedLine(index, false, false); |
388 } | 388 } |
389 | 389 |
390 void InlineOmniboxPopupView::OpenSelectedLine( | 390 void InlineOmniboxPopupView::OpenSelectedLine( |
391 const views::LocatedEvent& event, | 391 const ui::LocatedEvent& event, |
392 WindowOpenDisposition disposition) { | 392 WindowOpenDisposition disposition) { |
393 size_t index = GetIndexForPoint(event.location()); | 393 size_t index = GetIndexForPoint(event.location()); |
394 OpenIndex(index, disposition); | 394 OpenIndex(index, disposition); |
395 } | 395 } |
OLD | NEW |