|
|
Created:
7 years, 10 months ago by msw Modified:
7 years, 10 months ago Reviewers:
Peter Kasting CC:
chromium-reviews, tfarina, James Su, oshima Base URL:
svn://svn.chromium.org/chrome/trunk/src Visibility:
Public. |
DescriptionConsolidate Omnibox ViewState and AutocompleteEditState, rename.
Simple cleanup while I'm working on solving the related issues.
BUG=134701, 176708
R=pkasting@chromium.org
TEST=None; no behavior changes.
NOTRY=true
Manual commit note: http://crrev.com/183198
Patch Set 1 #Patch Set 2 : Sync and rebase. #Patch Set 3 : Sync and rebase #Messages
Total messages: 10 (0 generated)
Hey Peter, please take a look; thanks!
LGTM
CQ is trying da patch. Follow status at https://chromium-status.appspot.com/cq/msw@chromium.org/12299002/4001
Failed to apply patch for chrome/browser/ui/views/omnibox/omnibox_view_views.cc: While running patch -p1 --forward --force --no-backup-if-mismatch; patching file chrome/browser/ui/views/omnibox/omnibox_view_views.cc Hunk #3 succeeded at 359 (offset -83 lines). Hunk #4 FAILED at 454. Hunk #5 FAILED at 471. 2 out of 5 hunks FAILED -- saving rejects to file chrome/browser/ui/views/omnibox/omnibox_view_views.cc.rej Patch: chrome/browser/ui/views/omnibox/omnibox_view_views.cc Index: chrome/browser/ui/views/omnibox/omnibox_view_views.cc diff --git a/chrome/browser/ui/views/omnibox/omnibox_view_views.cc b/chrome/browser/ui/views/omnibox/omnibox_view_views.cc index 2a8b73ffdd58bc9dff75de8c5970948449d6de99..ff2101fc643223f1920fd3f8475033f6bfe35953 100644 --- a/chrome/browser/ui/views/omnibox/omnibox_view_views.cc +++ b/chrome/browser/ui/views/omnibox/omnibox_view_views.cc @@ -39,7 +39,7 @@ #include "ui/base/resource/resource_bundle.h" #include "ui/gfx/canvas.h" #include "ui/gfx/font.h" -#include "ui/gfx/render_text.h" +#include "ui/gfx/selection_model.h" #include "ui/views/border.h" #include "ui/views/controls/textfield/textfield.h" #include "ui/views/ime/input_method.h" @@ -53,33 +53,30 @@ #include "ui/compositor/layer.h" #endif -using content::WebContents; - namespace { // Stores omnibox state for each tab. -struct ViewState { - explicit ViewState(const gfx::SelectionModel& selection_model) - : selection_model(selection_model) { - } +struct OmniboxState : public base::SupportsUserData::Data { + static const char kKey[]; + + OmniboxState(const OmniboxEditModel::State& model_state, + const gfx::SelectionModel& selection_model); + virtual ~OmniboxState(); - // SelectionModel of selected text. - gfx::SelectionModel selection_model; + const OmniboxEditModel::State model_state; + const gfx::SelectionModel selection_model; }; -const char kAutocompleteEditStateKey[] = "AutocompleteEditState"; +// static +const char OmniboxState::kKey[] = "OmniboxState"; -struct AutocompleteEditState : public base::SupportsUserData::Data { - AutocompleteEditState(const OmniboxEditModel::State& model_state, - const ViewState& view_state) - : model_state(model_state), - view_state(view_state) { - } - virtual ~AutocompleteEditState() {} +OmniboxState::OmniboxState(const OmniboxEditModel::State& model_state, + const gfx::SelectionModel& selection_model) + : model_state(model_state), + selection_model(selection_model) { +} - const OmniboxEditModel::State model_state; - const ViewState view_state; -}; +OmniboxState::~OmniboxState() {} // The following const value is the same as in browser_defaults. const int kAutocompleteEditFontPixelSize = 15; @@ -445,7 +442,7 @@ void OmniboxViewViews::OnBoundsChanged(const gfx::Rect& previous_bounds) { //////////////////////////////////////////////////////////////////////////////// // OmniboxViewViews, OmniboxView implementation: -void OmniboxViewViews::SaveStateToTab(WebContents* tab) { +void OmniboxViewViews::SaveStateToTab(content::WebContents* tab) { DCHECK(tab); // We don't want to keep the IME status, so force quit the current @@ -457,15 +454,13 @@ void OmniboxViewViews::SaveStateToTab(WebContents* tab) { } // NOTE: GetStateForTabSwitch may affect GetSelection, so order is important. - OmniboxEditModel::State model_state = model()->GetStateForTabSwitch(); + OmniboxEditModel::State state = model()->GetStateForTabSwitch(); gfx::SelectionModel selection; textfield_->GetSelectionModel(&selection); - tab->SetUserData( - kAutocompleteEditStateKey, - new AutocompleteEditState(model_state, ViewState(selection))); + tab->SetUserData(OmniboxState::kKey, new OmniboxState(state, selection)); } -void OmniboxViewViews::Update(const WebContents* contents) { +void OmniboxViewViews::Update(const content::WebContents* contents) { // NOTE: We're getting the URL text here from the ToolbarModel. bool visibly_changed_permanent_text = model()->UpdatePermanentText(toolbar_model()->GetText(true)); @@ -474,21 +469,16 @@ void OmniboxViewViews::Update(const WebContents* contents) { bool changed_security_level = (security_level != security_level_); security_level_ = security_level; - // TODO(oshima): Copied from gtk implementation which is - // slightly different from WIN impl. Find out the correct implementation - // for views-implementation. + // TODO(msw|oshima): Copied from GTK, determine correct Win/CrOS behavior. if (contents) { RevertAll(); - const AutocompleteEditState* state = static_cast<AutocompleteEditState*>( - contents->GetUserData(&kAutocompleteEditStateKey)); + const OmniboxState* state = static_cast<OmniboxState*>( + contents->GetUserData(&OmniboxState::kKey)); if (state) { + // Restore the saved state and selection. model()->RestoreState(state->model_state); - - // Move the marks for the cursor and the other end of the selection to - // the previously-saved offsets (but preserve PRIMARY). - textfield_->SelectSelectionModel(state->view_state.selection_model); - // We do not carry over the current edit history to another tab. - // TODO(oshima): consider saving/restoring edit history. + textfield_->SelectSelectionModel(state->selection_model); + // TODO(oshima): Consider saving/restoring edit history. textfield_->ClearEditHistory(); } } else if (visibly_changed_permanent_text) {
CQ is trying da patch. Follow status at https://chromium-status.appspot.com/cq/msw@chromium.org/12299002/9004
Sorry for I got bad news for ya. Compile failed with a clobber build on mac. http://build.chromium.org/p/tryserver.chromium/buildstatus?builder=mac&number... Your code is likely broken or HEAD is junk. Please ensure your code is not broken then alert the build sheriffs. Look at the try server FAQ for more details.
Landing with NOTRY=true to ignore mac errors that everyone is hitting; see: http://build.chromium.org/p/tryserver.chromium/builders/mac/builds/29169 ... http://build.chromium.org/p/tryserver.chromium/builders/mac/builds/29188 I actually fixed that unrelated failure for brettw with http://crrev.com/183188
CQ is trying da patch. Follow status at https://chromium-status.appspot.com/cq/msw@chromium.org/12299002/9004
Failed to apply patch for chrome/browser/ui/views/omnibox/omnibox_view_views.cc: While running patch -p1 --forward --force --no-backup-if-mismatch; patching file chrome/browser/ui/views/omnibox/omnibox_view_views.cc Hunk #1 FAILED at 39. Hunk #2 FAILED at 53. Hunk #3 FAILED at 362. Hunk #4 FAILED at 374. Hunk #5 FAILED at 391. 5 out of 5 hunks FAILED -- saving rejects to file chrome/browser/ui/views/omnibox/omnibox_view_views.cc.rej Patch: chrome/browser/ui/views/omnibox/omnibox_view_views.cc Index: chrome/browser/ui/views/omnibox/omnibox_view_views.cc diff --git a/chrome/browser/ui/views/omnibox/omnibox_view_views.cc b/chrome/browser/ui/views/omnibox/omnibox_view_views.cc index 9fa1eeb345334e9a026966e9bf8f05d7bd8d8e35..1730885babb75390c611eabb097774b8adbe7de1 100644 --- a/chrome/browser/ui/views/omnibox/omnibox_view_views.cc +++ b/chrome/browser/ui/views/omnibox/omnibox_view_views.cc @@ -39,7 +39,7 @@ #include "ui/base/resource/resource_bundle.h" #include "ui/gfx/canvas.h" #include "ui/gfx/font.h" -#include "ui/gfx/render_text.h" +#include "ui/gfx/selection_model.h" #include "ui/views/border.h" #include "ui/views/controls/textfield/textfield.h" #include "ui/views/ime/input_method.h" @@ -53,33 +53,30 @@ #include "ui/compositor/layer.h" #endif -using content::WebContents; - namespace { // Stores omnibox state for each tab. -struct ViewState { - explicit ViewState(const gfx::SelectionModel& selection_model) - : selection_model(selection_model) { - } +struct OmniboxState : public base::SupportsUserData::Data { + static const char kKey[]; + + OmniboxState(const OmniboxEditModel::State& model_state, + const gfx::SelectionModel& selection_model); + virtual ~OmniboxState(); - // SelectionModel of selected text. - gfx::SelectionModel selection_model; + const OmniboxEditModel::State model_state; + const gfx::SelectionModel selection_model; }; -const char kAutocompleteEditStateKey[] = "AutocompleteEditState"; +// static +const char OmniboxState::kKey[] = "OmniboxState"; -struct AutocompleteEditState : public base::SupportsUserData::Data { - AutocompleteEditState(const OmniboxEditModel::State& model_state, - const ViewState& view_state) - : model_state(model_state), - view_state(view_state) { - } - virtual ~AutocompleteEditState() {} +OmniboxState::OmniboxState(const OmniboxEditModel::State& model_state, + const gfx::SelectionModel& selection_model) + : model_state(model_state), + selection_model(selection_model) { +} - const OmniboxEditModel::State model_state; - const ViewState view_state; -}; +OmniboxState::~OmniboxState() {} // The following const value is the same as in browser_defaults. const int kAutocompleteEditFontPixelSize = 15; @@ -362,7 +359,7 @@ void OmniboxViewViews::OnBlur() { //////////////////////////////////////////////////////////////////////////////// // OmniboxViewViews, OmniboxView implementation: -void OmniboxViewViews::SaveStateToTab(WebContents* tab) { +void OmniboxViewViews::SaveStateToTab(content::WebContents* tab) { DCHECK(tab); // We don't want to keep the IME status, so force quit the current @@ -374,15 +371,13 @@ void OmniboxViewViews::SaveStateToTab(WebContents* tab) { } // NOTE: GetStateForTabSwitch may affect GetSelection, so order is important. - OmniboxEditModel::State model_state = model()->GetStateForTabSwitch(); + OmniboxEditModel::State state = model()->GetStateForTabSwitch(); gfx::SelectionModel selection; GetSelectionModel(&selection); - tab->SetUserData( - kAutocompleteEditStateKey, - new AutocompleteEditState(model_state, ViewState(selection))); + tab->SetUserData(OmniboxState::kKey, new OmniboxState(state, selection)); } -void OmniboxViewViews::Update(const WebContents* contents) { +void OmniboxViewViews::Update(const content::WebContents* contents) { // NOTE: We're getting the URL text here from the ToolbarModel. bool visibly_changed_permanent_text = model()->UpdatePermanentText(toolbar_model()->GetText(true)); @@ -391,21 +386,16 @@ void OmniboxViewViews::Update(const WebContents* contents) { bool changed_security_level = (security_level != security_level_); security_level_ = security_level; - // TODO(oshima): Copied from gtk implementation which is - // slightly different from WIN impl. Find out the correct implementation - // for views-implementation. + // TODO(msw|oshima): Copied from GTK, determine correct Win/CrOS behavior. if (contents) { RevertAll(); - const AutocompleteEditState* state = static_cast<AutocompleteEditState*>( - contents->GetUserData(&kAutocompleteEditStateKey)); + const OmniboxState* state = static_cast<OmniboxState*>( + contents->GetUserData(&OmniboxState::kKey)); if (state) { + // Restore the saved state and selection. model()->RestoreState(state->model_state); - - // Move the marks for the cursor and the other end of the selection to - // the previously-saved offsets (but preserve PRIMARY). - SelectSelectionModel(state->view_state.selection_model); - // We do not carry over the current edit history to another tab. - // TODO(oshima): consider saving/restoring edit history. + SelectSelectionModel(state->selection_model); + // TODO(oshima): Consider saving/restoring edit history. ClearEditHistory(); } } else if (visibly_changed_permanent_text) {
Message was sent while issue was closed.
This was actually committed with http://crrev.com/183198, closing. |