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

Side by Side Diff: chrome/browser/ui/views/location_bar/icon_label_bubble_view.cc

Issue 2480813003: Reduce views::Border creation verbosity by promoting factory functions (Closed)
Patch Set: fix bad merge Created 4 years, 1 month 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
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/location_bar/icon_label_bubble_view.h" 5 #include "chrome/browser/ui/views/location_bar/icon_label_bubble_view.h"
6 6
7 #include "chrome/browser/ui/layout_constants.h" 7 #include "chrome/browser/ui/layout_constants.h"
8 #include "ui/gfx/canvas.h" 8 #include "ui/gfx/canvas.h"
9 #include "ui/gfx/color_utils.h" 9 #include "ui/gfx/color_utils.h"
10 #include "ui/gfx/scoped_canvas.h" 10 #include "ui/gfx/scoped_canvas.h"
(...skipping 22 matching lines...) Expand all
33 label_->SetHorizontalAlignment(gfx::ALIGN_LEFT); 33 label_->SetHorizontalAlignment(gfx::ALIGN_LEFT);
34 34
35 if (elide_in_middle) 35 if (elide_in_middle)
36 label_->SetElideBehavior(gfx::ELIDE_MIDDLE); 36 label_->SetElideBehavior(gfx::ELIDE_MIDDLE);
37 AddChildView(label_); 37 AddChildView(label_);
38 38
39 // Bubbles are given the full internal height of the location bar so that all 39 // Bubbles are given the full internal height of the location bar so that all
40 // child views in the location bar have the same height. The visible height of 40 // child views in the location bar have the same height. The visible height of
41 // the bubble should be smaller, so use an empty border to shrink down the 41 // the bubble should be smaller, so use an empty border to shrink down the
42 // content bounds so the background gets painted correctly. 42 // content bounds so the background gets painted correctly.
43 SetBorder(views::Border::CreateEmptyBorder( 43 SetBorder(views::CreateEmptyBorder(
44 gfx::Insets(GetLayoutConstant(LOCATION_BAR_BUBBLE_VERTICAL_PADDING), 0))); 44 gfx::Insets(GetLayoutConstant(LOCATION_BAR_BUBBLE_VERTICAL_PADDING), 0)));
45 45
46 // Flip the canvas in RTL so the separator is drawn on the correct side. 46 // Flip the canvas in RTL so the separator is drawn on the correct side.
47 EnableCanvasFlippingForRTLUI(true); 47 EnableCanvasFlippingForRTLUI(true);
48 } 48 }
49 49
50 IconLabelBubbleView::~IconLabelBubbleView() { 50 IconLabelBubbleView::~IconLabelBubbleView() {
51 } 51 }
52 52
53 void IconLabelBubbleView::SetLabel(const base::string16& label) { 53 void IconLabelBubbleView::SetLabel(const base::string16& label) {
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after
237 237
238 // Draw the 1 px separator. 238 // Draw the 1 px separator.
239 gfx::ScopedCanvas scoped_canvas(canvas); 239 gfx::ScopedCanvas scoped_canvas(canvas);
240 const float scale = canvas->UndoDeviceScaleFactor(); 240 const float scale = canvas->UndoDeviceScaleFactor();
241 // Keep the separator aligned on a pixel center. 241 // Keep the separator aligned on a pixel center.
242 const gfx::RectF pixel_aligned_bounds = 242 const gfx::RectF pixel_aligned_bounds =
243 gfx::ScaleRect(gfx::RectF(bounds), scale) - gfx::Vector2dF(0.5f, 0); 243 gfx::ScaleRect(gfx::RectF(bounds), scale) - gfx::Vector2dF(0.5f, 0);
244 canvas->DrawLine(pixel_aligned_bounds.top_right(), 244 canvas->DrawLine(pixel_aligned_bounds.top_right(),
245 pixel_aligned_bounds.bottom_right(), separator_color); 245 pixel_aligned_bounds.bottom_right(), separator_color);
246 } 246 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/intent_picker_bubble_view.cc ('k') | chrome/browser/ui/views/location_bar/keyword_hint_view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698