#include "chrome/browser/ui/view_ids.h"
#include "chrome/browser/ui/views/find_bar_host.h"
#include "chrome/browser/ui/views/frame/browser_view.h"
-#include "grit/generated_resources.h"
+#include "chrome/grit/generated_resources.h"
#include "grit/theme_resources.h"
-#include "grit/ui_resources.h"
#include "third_party/skia/include/core/SkPaint.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/base/resource/resource_bundle.h"
#include "ui/base/theme_provider.h"
#include "ui/events/event.h"
#include "ui/gfx/canvas.h"
+#include "ui/resources/grit/ui_resources.h"
#include "ui/views/border.h"
#include "ui/views/controls/button/image_button.h"
#include "ui/views/controls/label.h"
namespace {
-// The margins around the search field, match count label, and the close button.
+// The margins around the UI controls, derived from assets and design specs.
const int kMarginLeftOfCloseButton = 3;
const int kMarginRightOfCloseButton = 7;
-const int kMarginLeftOfMatchCountLabel = 2;
+const int kMarginLeftOfMatchCountLabel = 3;
const int kMarginRightOfMatchCountLabel = 1;
const int kMarginLeftOfFindTextfield = 12;
+const int kMarginVerticalFindTextfield = 6;
// The margins around the match count label (We add extra space so that the
// background highlight extends beyond just the text).
// of breathing room (margins around the text).
sz.Enlarge(kMatchCountExtraWidth, 0);
sz.SetToMax(gfx::Size(kMatchCountMinWidth, 0));
- int match_count_x =
+ const int match_count_x =
find_previous_button_->x() - kMarginRightOfMatchCountLabel - sz.width();
- int find_text_y = (height() - find_text_->GetPreferredSize().height()) / 2;
+ const int find_text_y = kMarginVerticalFindTextfield;
+ const gfx::Insets find_text_insets(find_text_->GetInsets());
match_count_text_->SetBounds(match_count_x,
- find_text_y + find_text_->GetBaseline() -
+ find_text_y - find_text_insets.top() +
+ find_text_->GetBaseline() -
match_count_text_->GetBaseline(),
sz.width(), sz.height());
- // And whatever space is left in between, gets filled up by the find edit box.
- int find_text_width = std::max(0, match_count_x -
- kMarginLeftOfMatchCountLabel - kMarginLeftOfFindTextfield);
- find_text_->SetBounds(kMarginLeftOfFindTextfield, find_text_y,
- find_text_width, find_text_->GetPreferredSize().height());
+ // Fill the remaining width and available height with the textfield.
+ const int left_margin = kMarginLeftOfFindTextfield - find_text_insets.left();
+ const int find_text_width = std::max(0, match_count_x - left_margin -
+ kMarginLeftOfMatchCountLabel + find_text_insets.right());
+ find_text_->SetBounds(left_margin, find_text_y, find_text_width,
+ height() - 2 * kMarginVerticalFindTextfield);
// The focus forwarder view is a hidden view that should cover the area
// between the find text box and the find button so that when the user clicks
// in that area we focus on the find text box.
- int find_text_edge = find_text_->x() + find_text_->width();
+ const int find_text_edge = find_text_->x() + find_text_->width();
focus_forwarder_view_->SetBounds(
find_text_edge, find_previous_button_->y(),
find_previous_button_->x() - find_text_edge,
// Add up all the preferred sizes and margins of the rest of the controls.
prefsize.Enlarge(kMarginLeftOfCloseButton + kMarginRightOfCloseButton +
- kMarginLeftOfFindTextfield,
+ kMarginLeftOfFindTextfield -
+ find_text_->GetInsets().width(),
0);
prefsize.Enlarge(find_previous_button_->GetPreferredSize().width(), 0);
prefsize.Enlarge(find_next_button_->GetPreferredSize().width(), 0);