summaryrefslogtreecommitdiffstats
path: root/ui
diff options
context:
space:
mode:
authorcalamity <calamity@chromium.org>2014-12-09 22:05:06 -0800
committerCommit bot <commit-bot@chromium.org>2014-12-10 06:05:26 +0000
commitbf55b442bb6b5c923249dd7870d6a107678bfbb6 (patch)
tree7f2a2274c1366031f081cfb993a91b8f1b95c152 /ui
parentbcd08dc292b63223a166e240d9afab172f1c586e (diff)
downloadchromium_src-bf55b442bb6b5c923249dd7870d6a107678bfbb6.zip
chromium_src-bf55b442bb6b5c923249dd7870d6a107678bfbb6.tar.gz
chromium_src-bf55b442bb6b5c923249dd7870d6a107678bfbb6.tar.bz2
Move layout of the app list search box widget into the contents view.
This CL moves the responsibility of positioning the search box widget via Layout() to the contents view rather than the app list view. This fixes a bug where launcherPage.show() would leave the search box in the start page's position. It also consolidates the responsibility of search box positioning at the ContentsView layer. BUG=439333 Review URL: https://codereview.chromium.org/774933012 Cr-Commit-Position: refs/heads/master@{#307649}
Diffstat (limited to 'ui')
-rw-r--r--ui/app_list/views/app_list_view.cc12
-rw-r--r--ui/app_list/views/app_list_view_unittest.cc6
-rw-r--r--ui/app_list/views/contents_view.cc10
3 files changed, 14 insertions, 14 deletions
diff --git a/ui/app_list/views/app_list_view.cc b/ui/app_list/views/app_list_view.cc
index cfd1c2a..cf2ceb8 100644
--- a/ui/app_list/views/app_list_view.cc
+++ b/ui/app_list/views/app_list_view.cc
@@ -398,7 +398,7 @@ void AppListView::InitChildWidgets() {
search_box_widget_->Init(search_box_widget_params);
search_box_widget_->SetContentsView(search_box_view_);
- Layout();
+ app_list_main_view_->contents_view()->Layout();
}
void AppListView::InitAsBubbleInternal(gfx::NativeView parent,
@@ -582,16 +582,6 @@ void AppListView::Layout() {
app_list_main_view_->SetBoundsRect(centered_bounds);
- // GetDefaultSearchBoxBounds() returns the bounds in |contents_view|'s
- // coordinate, therefore convert it to this coordinate.
- ContentsView* contents_view = app_list_main_view_->contents_view();
- gfx::Rect search_box_bounds = contents_view->GetSearchBoxBoundsForState(
- contents_view->GetActiveState());
- if (search_box_widget_) {
- search_box_widget_->SetBounds(
- contents_view->ConvertRectToWidget(search_box_bounds));
- }
-
if (speech_view_) {
gfx::Rect speech_bounds = centered_bounds;
int preferred_height = speech_view_->GetPreferredSize().height();
diff --git a/ui/app_list/views/app_list_view_unittest.cc b/ui/app_list/views/app_list_view_unittest.cc
index d4d664e..0585b44 100644
--- a/ui/app_list/views/app_list_view_unittest.cc
+++ b/ui/app_list/views/app_list_view_unittest.cc
@@ -623,7 +623,7 @@ void AppListViewTestContext::RunSearchResultsTest() {
// Check that the current search is using |search_text|.
EXPECT_EQ(search_text, delegate_->GetTestModel()->search_box()->text());
EXPECT_EQ(search_text, main_view->search_box_view()->search_box()->text());
- view_->Layout();
+ contents_view->Layout();
EXPECT_TRUE(
contents_view->IsStateActive(AppListModel::STATE_SEARCH_RESULTS));
EXPECT_TRUE(
@@ -631,7 +631,7 @@ void AppListViewTestContext::RunSearchResultsTest() {
// Check that typing into the search box triggers the search page.
EXPECT_TRUE(SetAppListState(AppListModel::STATE_APPS));
- view_->Layout();
+ contents_view->Layout();
EXPECT_EQ(default_contents_bounds,
contents_view->apps_container_view()->bounds());
EXPECT_TRUE(
@@ -644,7 +644,7 @@ void AppListViewTestContext::RunSearchResultsTest() {
EXPECT_EQ(new_search_text, delegate_->GetTestModel()->search_box()->text());
EXPECT_EQ(new_search_text,
main_view->search_box_view()->search_box()->text());
- view_->Layout();
+ contents_view->Layout();
EXPECT_TRUE(
contents_view->IsStateActive(AppListModel::STATE_SEARCH_RESULTS));
EXPECT_TRUE(
diff --git a/ui/app_list/views/contents_view.cc b/ui/app_list/views/contents_view.cc
index 948ffca..71b0145 100644
--- a/ui/app_list/views/contents_view.cc
+++ b/ui/app_list/views/contents_view.cc
@@ -25,6 +25,7 @@
#include "ui/resources/grit/ui_resources.h"
#include "ui/views/view_model.h"
#include "ui/views/view_model_utils.h"
+#include "ui/views/widget/widget.h"
namespace app_list {
@@ -461,6 +462,15 @@ gfx::Size ContentsView::GetPreferredSize() const {
}
void ContentsView::Layout() {
+ // The search box is contained in a widget so set the bounds of the widget
+ // rather than the SearchBoxView. In athena, the search box widget will be the
+ // same as the app list widget so don't move it.
+ views::Widget* search_box_widget = GetSearchBoxView()->GetWidget();
+ if (search_box_widget && search_box_widget != GetWidget()) {
+ search_box_widget->SetBounds(
+ ConvertRectToWidget(GetSearchBoxBoundsForState(GetActiveState())));
+ }
+
// Immediately finish all current animations.
pagination_model_.FinishAnimation();