diff options
author | tony@chromium.org <tony@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-03-19 07:27:24 +0000 |
---|---|---|
committer | tony@chromium.org <tony@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-03-19 07:27:24 +0000 |
commit | bd239ad62a831d9d82e419e420f01114a677e67b (patch) | |
tree | 2400ebc1d4aeba17834befe2ac85666d5f01f783 | |
parent | 08977cda717b5dd0cc8f79ef18910902e773abe6 (diff) | |
download | chromium_src-bd239ad62a831d9d82e419e420f01114a677e67b.zip chromium_src-bd239ad62a831d9d82e419e420f01114a677e67b.tar.gz chromium_src-bd239ad62a831d9d82e419e420f01114a677e67b.tar.bz2 |
Honor select-all on tab-away when omnibar is empty (gtk)
Also added a browser test for this case.
The bug is an ordering error, possibly because the
programmer was unaware that GetStateForTabSwitch
can actually mutate the selection state, for the
odd case outlined in bug 38385.
BUG=38385
TEST=Delete URL from omnibar. Create tab, delete tab. URL should be reverted and selected.
Patch by Matthew Willis <appamatto@gmail.com>
Review URL: http://codereview.chromium.org/1047004
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@42085 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | AUTHORS | 1 | ||||
-rw-r--r-- | chrome/browser/autocomplete/autocomplete_browsertest.cc | 21 | ||||
-rw-r--r-- | chrome/browser/autocomplete/autocomplete_edit_view_gtk.cc | 10 |
3 files changed, 27 insertions, 5 deletions
@@ -70,3 +70,4 @@ Paul Kehrer <paul.l.kehrer@gmail.com> Chamal De Silva <chamal.desilva@gmail.com> Jay Soffian <jaysoffian@gmail.com> Brian G. Merrell <bgmerrell@gmail.com> +Matthew Willis <appamatto@gmail.com> diff --git a/chrome/browser/autocomplete/autocomplete_browsertest.cc b/chrome/browser/autocomplete/autocomplete_browsertest.cc index 4776f64..29a9b30 100644 --- a/chrome/browser/autocomplete/autocomplete_browsertest.cc +++ b/chrome/browser/autocomplete/autocomplete_browsertest.cc @@ -11,6 +11,7 @@ #include "chrome/browser/history/history.h" #include "chrome/browser/location_bar.h" #include "chrome/browser/profile.h" +#include "chrome/browser/tab_contents/tab_contents.h" #include "chrome/common/notification_registrar.h" #include "chrome/common/notification_service.h" #include "chrome/common/notification_type.h" @@ -138,3 +139,23 @@ IN_PROC_BROWSER_TEST_F(AutocompleteBrowserTest, Autocomplete) { EXPECT_TRUE(result.empty()) << AutocompleteResultAsString(result); } } + +IN_PROC_BROWSER_TEST_F(AutocompleteBrowserTest, TabAwayRevertSelect) { + // http://code.google.com/p/chromium/issues/detail?id=38385 + // Make sure that tabbing away from an empty omnibar causes a revert + // and select all. + LocationBar* location_bar = GetLocationBar(); + EXPECT_EQ(UTF8ToWide(chrome::kAboutBlankURL), + location_bar->location_entry()->GetText()); + location_bar->location_entry()->SetUserText(L""); + browser()->AddTabWithURL(GURL(chrome::kAboutBlankURL), GURL(), + PageTransition::START_PAGE, true, -1, false, NULL); + ui_test_utils::WaitForNavigation( + &browser()->GetSelectedTabContents()->controller()); + EXPECT_EQ(UTF8ToWide(chrome::kAboutBlankURL), + location_bar->location_entry()->GetText()); + browser()->CloseTab(); + EXPECT_EQ(UTF8ToWide(chrome::kAboutBlankURL), + location_bar->location_entry()->GetText()); + EXPECT_TRUE(location_bar->location_entry()->IsSelectAll()); +} diff --git a/chrome/browser/autocomplete/autocomplete_edit_view_gtk.cc b/chrome/browser/autocomplete/autocomplete_edit_view_gtk.cc index 73bd8fc..1c72a2c 100644 --- a/chrome/browser/autocomplete/autocomplete_edit_view_gtk.cc +++ b/chrome/browser/autocomplete/autocomplete_edit_view_gtk.cc @@ -313,16 +313,16 @@ int AutocompleteEditViewGtk::TextWidth() { void AutocompleteEditViewGtk::SaveStateToTab(TabContents* tab) { DCHECK(tab); - GetStateAccessor()->SetProperty( - tab->property_bag(), - AutocompleteEditState(model_->GetStateForTabSwitch(), - ViewState(GetSelection()))); - // If any text has been selected, register it as the PRIMARY selection so it // can still be pasted via middle-click after the text view is cleared. if (!selected_text_.empty()) { SavePrimarySelection(selected_text_); } + // NOTE: GetStateForTabSwitch may affect GetSelection, so order is important. + AutocompleteEditModel::State model_state = model_->GetStateForTabSwitch(); + GetStateAccessor()->SetProperty( + tab->property_bag(), + AutocompleteEditState(model_state, ViewState(GetSelection()))); } void AutocompleteEditViewGtk::Update(const TabContents* contents) { |