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

Side by Side Diff: chrome/browser/ui/views/find_bar_view.cc

Issue 2399033004: Fix corners of find bar view by using BubbleBackground instead of a (Closed)
Patch Set: iwyu Created 4 years, 2 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 unified diff | Download patch
« no previous file with comments | « chrome/browser/ui/views/find_bar_view.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/ui/views/find_bar_view.h" 5 #include "chrome/browser/ui/views/find_bar_view.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/i18n/number_formatting.h" 9 #include "base/i18n/number_formatting.h"
10 #include "base/macros.h" 10 #include "base/macros.h"
11 #include "base/memory/ptr_util.h" 11 #include "base/memory/ptr_util.h"
12 #include "base/strings/string_util.h" 12 #include "base/strings/string_util.h"
13 #include "chrome/browser/profiles/profile.h" 13 #include "chrome/browser/profiles/profile.h"
14 #include "chrome/browser/themes/theme_properties.h" 14 #include "chrome/browser/themes/theme_properties.h"
15 #include "chrome/browser/ui/find_bar/find_bar_controller.h" 15 #include "chrome/browser/ui/find_bar/find_bar_controller.h"
16 #include "chrome/browser/ui/find_bar/find_bar_state.h" 16 #include "chrome/browser/ui/find_bar/find_bar_state.h"
17 #include "chrome/browser/ui/find_bar/find_bar_state_factory.h" 17 #include "chrome/browser/ui/find_bar/find_bar_state_factory.h"
18 #include "chrome/browser/ui/find_bar/find_notification_details.h" 18 #include "chrome/browser/ui/find_bar/find_notification_details.h"
19 #include "chrome/browser/ui/find_bar/find_tab_helper.h" 19 #include "chrome/browser/ui/find_bar/find_tab_helper.h"
20 #include "chrome/browser/ui/view_ids.h" 20 #include "chrome/browser/ui/view_ids.h"
21 #include "chrome/browser/ui/views/find_bar_host.h" 21 #include "chrome/browser/ui/views/find_bar_host.h"
22 #include "chrome/browser/ui/views/frame/browser_view.h" 22 #include "chrome/browser/ui/views/frame/browser_view.h"
23 #include "chrome/grit/generated_resources.h" 23 #include "chrome/grit/generated_resources.h"
24 #include "components/strings/grit/components_strings.h" 24 #include "components/strings/grit/components_strings.h"
25 #include "ui/base/ime/input_method.h" 25 #include "ui/base/ime/input_method.h"
26 #include "ui/base/ime/text_input_flags.h" 26 #include "ui/base/ime/text_input_flags.h"
27 #include "ui/base/l10n/l10n_util.h" 27 #include "ui/base/l10n/l10n_util.h"
28 #include "ui/base/theme_provider.h" 28 #include "ui/base/theme_provider.h"
29 #include "ui/events/event.h" 29 #include "ui/events/event.h"
30 #include "ui/gfx/canvas.h"
31 #include "ui/gfx/color_palette.h" 30 #include "ui/gfx/color_palette.h"
32 #include "ui/gfx/paint_vector_icon.h" 31 #include "ui/gfx/paint_vector_icon.h"
33 #include "ui/gfx/vector_icons_public.h" 32 #include "ui/gfx/vector_icons_public.h"
34 #include "ui/native_theme/native_theme.h" 33 #include "ui/native_theme/native_theme.h"
35 #include "ui/views/background.h" 34 #include "ui/views/background.h"
36 #include "ui/views/border.h" 35 #include "ui/views/border.h"
37 #include "ui/views/bubble/bubble_border.h" 36 #include "ui/views/bubble/bubble_border.h"
38 #include "ui/views/controls/button/image_button.h" 37 #include "ui/views/controls/button/image_button.h"
39 #include "ui/views/controls/button/vector_icon_button.h" 38 #include "ui/views/controls/button/vector_icon_button.h"
40 #include "ui/views/controls/label.h" 39 #include "ui/views/controls/label.h"
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
153 l10n_util::GetStringUTF16(IDS_FIND_IN_PAGE_CLOSE_TOOLTIP)); 152 l10n_util::GetStringUTF16(IDS_FIND_IN_PAGE_CLOSE_TOOLTIP));
154 close_button_->SetAccessibleName( 153 close_button_->SetAccessibleName(
155 l10n_util::GetStringUTF16(IDS_ACCNAME_CLOSE)); 154 l10n_util::GetStringUTF16(IDS_ACCNAME_CLOSE));
156 close_button_->SetAnimationDuration(0); 155 close_button_->SetAnimationDuration(0);
157 AddChildView(close_button_); 156 AddChildView(close_button_);
158 157
159 AddChildView(focus_forwarder_view_); 158 AddChildView(focus_forwarder_view_);
160 159
161 EnableCanvasFlippingForRTLUI(true); 160 EnableCanvasFlippingForRTLUI(true);
162 161
163 // The background color is not used since there's no arrow.
164 SetBorder(base::MakeUnique<views::BubbleBorder>(
165 views::BubbleBorder::NONE, views::BubbleBorder::SMALL_SHADOW,
166 gfx::kPlaceholderColor));
167
168 match_count_text_->SetEventTargeter( 162 match_count_text_->SetEventTargeter(
169 base::MakeUnique<views::ViewTargeter>(this)); 163 base::MakeUnique<views::ViewTargeter>(this));
170 AddChildViewAt(match_count_text_, 1); 164 AddChildViewAt(match_count_text_, 1);
171 165
172 separator_->SetBorder(views::Border::CreateEmptyBorder( 166 separator_->SetBorder(views::Border::CreateEmptyBorder(
173 0, kSeparatorLeftSpacing, 0, kSeparatorRightSpacing)); 167 0, kSeparatorLeftSpacing, 0, kSeparatorRightSpacing));
174 AddChildViewAt(separator_, 2); 168 AddChildViewAt(separator_, 2);
175 169
176 find_text_->SetBorder(views::Border::NullBorder()); 170 find_text_->SetBorder(views::Border::NullBorder());
177 171
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
252 void FindBarView::SetFocusAndSelection(bool select_all) { 246 void FindBarView::SetFocusAndSelection(bool select_all) {
253 find_text_->RequestFocus(); 247 find_text_->RequestFocus();
254 GetWidget()->GetInputMethod()->ShowImeIfNeeded(); 248 GetWidget()->GetInputMethod()->ShowImeIfNeeded();
255 if (select_all && !find_text_->text().empty()) 249 if (select_all && !find_text_->text().empty())
256 find_text_->SelectAll(true); 250 find_text_->SelectAll(true);
257 } 251 }
258 252
259 /////////////////////////////////////////////////////////////////////////////// 253 ///////////////////////////////////////////////////////////////////////////////
260 // FindBarView, views::View overrides: 254 // FindBarView, views::View overrides:
261 255
262 void FindBarView::OnPaintBackground(gfx::Canvas* canvas) {
263 // Draw within the lines.
264 canvas->Save();
265 gfx::Rect bounds = GetLocalBounds();
266 bounds.Inset(border()->GetInsets());
267 canvas->ClipRect(bounds);
268 views::View::OnPaintBackground(canvas);
269 canvas->Restore();
270 }
271
272 void FindBarView::Layout() { 256 void FindBarView::Layout() {
273 views::View::Layout(); 257 views::View::Layout();
274 258
275 // The focus forwarder view is a hidden view that should cover the area 259 // The focus forwarder view is a hidden view that should cover the area
276 // between the find text box and the find button so that when the user clicks 260 // between the find text box and the find button so that when the user clicks
277 // in that area we focus on the find text box. 261 // in that area we focus on the find text box.
278 const int find_text_edge = find_text_->x() + find_text_->width(); 262 const int find_text_edge = find_text_->x() + find_text_->width();
279 focus_forwarder_view_->SetBounds( 263 focus_forwarder_view_->SetBounds(
280 find_text_edge, find_previous_button_->y(), 264 find_text_edge, find_previous_button_->y(),
281 find_previous_button_->x() - find_text_edge, 265 find_previous_button_->x() - find_text_edge,
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
420 return static_cast<FindBarHost*>(host()); 404 return static_cast<FindBarHost*>(host());
421 } 405 }
422 406
423 const char* FindBarView::GetClassName() const { 407 const char* FindBarView::GetClassName() const {
424 return "FindBarView"; 408 return "FindBarView";
425 } 409 }
426 410
427 void FindBarView::OnNativeThemeChanged(const ui::NativeTheme* theme) { 411 void FindBarView::OnNativeThemeChanged(const ui::NativeTheme* theme) {
428 SkColor bg_color = theme->GetSystemColor( 412 SkColor bg_color = theme->GetSystemColor(
429 ui::NativeTheme::kColorId_TextfieldDefaultBackground); 413 ui::NativeTheme::kColorId_TextfieldDefaultBackground);
430 set_background(views::Background::CreateSolidBackground(bg_color)); 414 auto border = base::MakeUnique<views::BubbleBorder>(
415 views::BubbleBorder::NONE, views::BubbleBorder::SMALL_SHADOW,
416 bg_color);
417 set_background(new views::BubbleBackground(border.get()));
418 SetBorder(std::move(border));
419
431 match_count_text_->SetBackgroundColor(bg_color); 420 match_count_text_->SetBackgroundColor(bg_color);
432
433 SkColor text_color = 421 SkColor text_color =
434 theme->GetSystemColor(ui::NativeTheme::kColorId_TextfieldDefaultColor); 422 theme->GetSystemColor(ui::NativeTheme::kColorId_TextfieldDefaultColor);
435 match_count_text_->SetEnabledColor(SkColorSetA(text_color, 0x69)); 423 match_count_text_->SetEnabledColor(SkColorSetA(text_color, 0x69));
436 separator_->SetColor(SkColorSetA(text_color, 0x26)); 424 separator_->SetColor(SkColorSetA(text_color, 0x26));
437 } 425 }
438 426
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/find_bar_view.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698