Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4981)

Unified Diff: chrome/renderer/searchbox/searchbox.cc

Issue 12047107: Change the SearchBox API from using the start/end margins of the location bar to using the start ma… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Added test Created 7 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/renderer/searchbox/searchbox.cc
diff --git a/chrome/renderer/searchbox/searchbox.cc b/chrome/renderer/searchbox/searchbox.cc
index 223c320df5a7b08552eb2b2c6ca7a22ba55eb3cb..3665ae1fe1ac668ca8f1ecadead45a7a42a29532 100644
--- a/chrome/renderer/searchbox/searchbox.cc
+++ b/chrome/renderer/searchbox/searchbox.cc
@@ -17,7 +17,7 @@ SearchBox::SearchBox(content::RenderView* render_view)
selection_end_(0),
results_base_(0),
start_margin_(0),
- end_margin_(0),
+ width_(0),
last_results_base_(0),
is_key_capture_enabled_(false),
theme_area_height_(0),
@@ -70,8 +70,10 @@ int SearchBox::GetStartMargin() const {
return static_cast<int>(start_margin_ / GetZoom());
}
-int SearchBox::GetEndMargin() const {
- return static_cast<int>(end_margin_ / GetZoom());
+int SearchBox::GetWidth() const {
+ // Width set by a margin-change event takes precedence over the popup width.
+ return static_cast<int>(
+ (width_ ? width_ : popup_bounds_.width()) / GetZoom());
}
gfx::Rect SearchBox::GetPopupBounds() const {
@@ -191,9 +193,9 @@ void SearchBox::OnPopupResize(const gfx::Rect& bounds) {
}
}
-void SearchBox::OnMarginChange(int start, int end) {
- start_margin_ = start;
- end_margin_ = end;
+void SearchBox::OnMarginChange(int margin, int width) {
+ start_margin_ = margin;
+ width_ = width;
if (render_view()->GetWebView() && render_view()->GetWebView()->mainFrame()) {
extensions_v8::SearchBoxExtension::DispatchMarginChange(
render_view()->GetWebView()->mainFrame());
@@ -292,7 +294,7 @@ void SearchBox::Reset() {
results_base_ = 0;
popup_bounds_ = gfx::Rect();
start_margin_ = 0;
- end_margin_ = 0;
+ width_ = 0;
autocomplete_results_.clear();
is_key_capture_enabled_ = false;
mode_ = chrome::search::Mode();

Powered by Google App Engine
This is Rietveld 408576698