 Chromium Code Reviews
 Chromium Code Reviews Issue 11359198:
  Implement the Instant extended API startMargin, endMargin, and rtl properties and the onmarginchang…  (Closed) 
  Base URL: svn://svn.chromium.org/chrome/trunk/src
    
  
    Issue 11359198:
  Implement the Instant extended API startMargin, endMargin, and rtl properties and the onmarginchang…  (Closed) 
  Base URL: svn://svn.chromium.org/chrome/trunk/src| Index: chrome/browser/ui/omnibox/omnibox_edit_model.cc | 
| diff --git a/chrome/browser/ui/omnibox/omnibox_edit_model.cc b/chrome/browser/ui/omnibox/omnibox_edit_model.cc | 
| index 02eb0f1102c50386d8ad588f590a9878967eb2f1..8ae2fc2209cab39de3fe750ff2c520fc629ab8a9 100644 | 
| --- a/chrome/browser/ui/omnibox/omnibox_edit_model.cc | 
| +++ b/chrome/browser/ui/omnibox/omnibox_edit_model.cc | 
| @@ -4,9 +4,11 @@ | 
| #include "chrome/browser/ui/omnibox/omnibox_edit_model.h" | 
| +#include <algorithm> | 
| #include <string> | 
| #include "base/format_macros.h" | 
| +#include "base/i18n/rtl.h" | 
| #include "base/metrics/histogram.h" | 
| #include "base/string_util.h" | 
| #include "base/stringprintf.h" | 
| @@ -998,9 +1000,21 @@ bool OmniboxEditModel::OnAfterPossibleChange(const string16& old_text, | 
| MaybeAcceptKeywordBySpace(user_text_)); | 
| } | 
| -void OmniboxEditModel::PopupBoundsChangedTo(const gfx::Rect& bounds) { | 
| +void OmniboxEditModel::OnPopupBoundsChanged(const gfx::Rect& bounds) { | 
| if (InstantController* instant = controller_->GetInstant()) | 
| - instant->SetOmniboxBounds(bounds); | 
| + instant->SetPopupBounds(bounds); | 
| +} | 
| + | 
| +void OmniboxEditModel::OnOmniboxBoundsChanged(const gfx::Rect& omnibox_bounds, | 
| 
sky
2012/11/28 22:29:02
Passing bounds like this strikes me as specific to
 
melevin
2012/11/30 23:37:09
Done.
 | 
| + const gfx::Rect& parent_bounds) { | 
| + if (InstantController* instant = controller_->GetInstant()) { | 
| + int start = omnibox_bounds.x(); | 
| + int end = parent_bounds.x() + parent_bounds.width() - | 
| + omnibox_bounds.width() - start; | 
| + if (base::i18n::IsRTL()) | 
| + std::swap(start, end); | 
| + instant->SetMarginSize(start, end); | 
| + } | 
| } | 
| void OmniboxEditModel::OnResultChanged(bool default_match_changed) { | 
| @@ -1037,14 +1051,14 @@ void OmniboxEditModel::OnResultChanged(bool default_match_changed) { | 
| } | 
| if (popup_->IsOpen()) { | 
| - PopupBoundsChangedTo(popup_->view()->GetTargetBounds()); | 
| + OnPopupBoundsChanged(popup_->view()->GetTargetBounds()); | 
| } else if (was_open) { | 
| // Accepts the temporary text as the user text, because it makes little | 
| // sense to have temporary text when the popup is closed. | 
| InternalSetUserText(UserTextFromDisplayText(view_->GetText())); | 
| has_temporary_text_ = false; | 
| is_temporary_text_set_by_instant_ = false; | 
| - PopupBoundsChangedTo(gfx::Rect()); | 
| + OnPopupBoundsChanged(gfx::Rect()); | 
| NotifySearchTabHelper(); | 
| } |