Index: chrome/browser/ui/views/location_bar/icon_label_bubble_view.cc |
diff --git a/chrome/browser/ui/views/location_bar/icon_label_bubble_view.cc b/chrome/browser/ui/views/location_bar/icon_label_bubble_view.cc |
index 691c093e157a0614e61e881391133873c47b99a3..10c152641fd7add72f7e4942fd43e28849672621 100644 |
--- a/chrome/browser/ui/views/location_bar/icon_label_bubble_view.cc |
+++ b/chrome/browser/ui/views/location_bar/icon_label_bubble_view.cc |
@@ -11,6 +11,7 @@ |
#include "ui/base/resource/resource_bundle.h" |
#include "ui/gfx/canvas.h" |
#include "ui/gfx/color_utils.h" |
+#include "ui/gfx/image/image_util.h" |
#include "ui/native_theme/native_theme.h" |
#include "ui/views/animation/ink_drop_hover.h" |
#include "ui/views/border.h" |
@@ -37,6 +38,8 @@ IconLabelBubbleView::IconLabelBubbleView(int contained_image, |
: background_painter_(nullptr), |
image_(new views::ImageView()), |
label_(new views::Label(base::string16(), font_list)), |
+ builtin_leading_padding_(0), |
+ builtin_trailing_padding_(0), |
is_extension_icon_(false), |
parent_background_color_(parent_background_color) { |
if (contained_image) { |
@@ -95,6 +98,13 @@ void IconLabelBubbleView::SetLabel(const base::string16& label) { |
void IconLabelBubbleView::SetImage(const gfx::ImageSkia& image_skia) { |
image_->SetImage(image_skia); |
+ |
+ if (ui::MaterialDesignController::IsModeMaterial()) { |
+ gfx::GetVisibleMargins(image_skia, &builtin_leading_padding_, |
varkha
2016/03/30 04:35:09
gfx::VisibleMargins?
|
+ &builtin_trailing_padding_); |
+ if (base::i18n::IsRTL()) |
+ std::swap(builtin_leading_padding_, builtin_trailing_padding_); |
+ } |
} |
bool IconLabelBubbleView::ShouldShowBackground() const { |
@@ -109,11 +119,6 @@ bool IconLabelBubbleView::IsShrinking() const { |
return false; |
} |
-int IconLabelBubbleView::GetImageAndPaddingWidth() const { |
- const int image_width = image_->GetPreferredSize().width(); |
- return image_width ? (image_width + GetInternalSpacing()) : 0; |
-} |
- |
gfx::Size IconLabelBubbleView::GetPreferredSize() const { |
// Height will be ignored by the LocationBarView. |
return GetSizeForLabelWidth(label_->GetPreferredSize().width()); |
@@ -158,7 +163,8 @@ void IconLabelBubbleView::Layout() { |
// accounting for the preferred image width and padding amounts. Note that if |
// the label has zero size it doesn't actually matter what we compute its X |
// value to be, since it won't be visible. |
- const int label_x = image_x + GetImageAndPaddingWidth(); |
+ const int label_x = |
+ image_x + image_width + (image_width ? GetInternalSpacing() : 0); |
const int label_width = |
std::max(0, width() - label_x - bubble_trailing_padding); |
label_->SetBounds(label_x, 0, label_width, height()); |
@@ -235,7 +241,8 @@ gfx::Size IconLabelBubbleView::GetSizeForLabelWidth(int label_width) const { |
int IconLabelBubbleView::GetOuterPadding(bool leading) const { |
if (ui::MaterialDesignController::IsModeMaterial()) { |
// Leading and trailing padding are equal. |
- return GetLayoutConstant(ICON_LABEL_VIEW_TRAILING_PADDING); |
+ return GetLayoutConstant(ICON_LABEL_VIEW_TRAILING_PADDING) - |
+ (leading ? builtin_leading_padding_ : 0); |
} |
return GetLayoutConstant(LOCATION_BAR_HORIZONTAL_PADDING) - |
@@ -258,7 +265,8 @@ void IconLabelBubbleView::SetLabelBackgroundColor( |
} |
int IconLabelBubbleView::GetInternalSpacing() const { |
- return GetLayoutConstant(ICON_LABEL_VIEW_INTERNAL_SPACING); |
+ return GetLayoutConstant(ICON_LABEL_VIEW_INTERNAL_SPACING) - |
+ builtin_trailing_padding_; |
} |
const char* IconLabelBubbleView::GetClassName() const { |