Upstream version 7.36.149.0
[platform/framework/web/crosswalk.git] / src / chrome / browser / ui / views / find_bar_view.cc
index 127aa27..1698820 100644 (file)
 
 namespace {
 
-// The amount of whitespace to have before the find button.
-const int kWhiteSpaceAfterMatchCountLabel = 1;
-
-// The margins around the search field and the close button.
+// The margins around the search field, match count label, and the close button.
 const int kMarginLeftOfCloseButton = 3;
 const int kMarginRightOfCloseButton = 7;
+const int kMarginLeftOfMatchCountLabel = 2;
+const int kMarginRightOfMatchCountLabel = 1;
 const int kMarginLeftOfFindTextfield = 12;
 
 // The margins around the match count label (We add extra space so that the
@@ -79,7 +78,6 @@ FindBarView::FindBarView(FindBarHost* host)
       find_previous_button_(NULL),
       find_next_button_(NULL),
       close_button_(NULL) {
-  set_id(VIEW_ID_FIND_IN_PAGE);
   ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance();
 
   find_text_ = new views::Textfield;
@@ -254,7 +252,10 @@ void FindBarView::OnPaint(gfx::Canvas* canvas) {
   paint.setStyle(SkPaint::kFill_Style);
   paint.setColor(find_text_->GetBackgroundColor());
   canvas->DrawRoundRect(background_bounds, kBorderCornerRadius, paint);
+  canvas->Save();
+  canvas->ClipRect(gfx::Rect(0, 0, find_previous_button_->x(), height()));
   views::Painter::PaintPainterAt(canvas, find_text_border_.get(), text_bounds);
+  canvas->Restore();
 
   // Draw the background of the match text. We want to make sure the red
   // "no-match" background almost completely fills up the amount of vertical
@@ -313,7 +314,7 @@ void FindBarView::Layout() {
   sz.Enlarge(kMatchCountExtraWidth, 0);
   sz.SetToMax(gfx::Size(kMatchCountMinWidth, 0));
   int match_count_x =
-      find_previous_button_->x() - kWhiteSpaceAfterMatchCountLabel - sz.width();
+      find_previous_button_->x() - kMarginRightOfMatchCountLabel - sz.width();
   int find_text_y = (height() - find_text_->GetPreferredSize().height()) / 2;
   match_count_text_->SetBounds(match_count_x,
                                find_text_y + find_text_->GetBaseline() -
@@ -321,10 +322,10 @@ void FindBarView::Layout() {
                                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 - kMarginLeftOfFindTextfield);
-  find_text_->SetBounds(std::max(0, match_count_x - find_text_width),
-                        find_text_y, find_text_width,
-                        find_text_->GetPreferredSize().height());
+  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());
 
   // 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