summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorestade <estade@chromium.org>2015-11-06 19:44:36 -0800
committerCommit bot <commit-bot@chromium.org>2015-11-07 03:45:29 +0000
commite40fbd0e0083b17c3e5c398a448fb7c70a1c8267 (patch)
tree1c9a8e12b738729e4669af890e3cef479533a77b
parent355f7958e61ea9859b6c7d8c0f01d6185a053ed5 (diff)
downloadchromium_src-e40fbd0e0083b17c3e5c398a448fb7c70a1c8267.zip
chromium_src-e40fbd0e0083b17c3e5c398a448fb7c70a1c8267.tar.gz
chromium_src-e40fbd0e0083b17c3e5c398a448fb7c70a1c8267.tar.bz2
[MD] Twiddle padding of omnibox chips
Separate out pre-MD from MD logic for the sake of my sanity. BUG=552562 Review URL: https://codereview.chromium.org/1419673017 Cr-Commit-Position: refs/heads/master@{#358510}
-rw-r--r--chrome/browser/ui/views/layout_constants.cc3
-rw-r--r--chrome/browser/ui/views/location_bar/icon_label_bubble_view.cc21
-rw-r--r--chrome/browser/ui/views/location_bar/icon_label_bubble_view.h7
3 files changed, 21 insertions, 10 deletions
diff --git a/chrome/browser/ui/views/layout_constants.cc b/chrome/browser/ui/views/layout_constants.cc
index de59375..c291e7a 100644
--- a/chrome/browser/ui/views/layout_constants.cc
+++ b/chrome/browser/ui/views/layout_constants.cc
@@ -9,7 +9,8 @@
int GetLayoutConstant(LayoutConstant constant) {
const int kFindBarVerticalOffset[] = {1, 6, 6};
- const int kIconLabelViewInternalPadding[] = {3, 2, 2};
+ // The -1 means the label and the icon will overlap by a pixel.
+ const int kIconLabelViewInternalPadding[] = {3, -1, -1};
const int kIconLabelViewTrailingPadding[] = {2, 8, 8};
const int kLocationBarBorderThickness[] = {2, 1, 1};
const int kLocationBarBubbleHorizontalPadding[] = {1, 4, 4};
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 12a9e1b..ca74f17 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
@@ -140,15 +140,22 @@ gfx::Size IconLabelBubbleView::GetSizeForLabelWidth(int width) const {
return size;
}
-int IconLabelBubbleView::GetBubbleOuterPadding(bool start) const {
- // When the image is empty, leading and trailing padding are equal.
- const int extra_padding =
- image_->GetPreferredSize().IsEmpty() || !start
- ? GetLayoutConstant(ICON_LABEL_VIEW_TRAILING_PADDING)
- : 0;
+int IconLabelBubbleView::GetBubbleOuterPadding(bool leading) const {
+ if (ui::MaterialDesignController::IsModeMaterial())
+ return GetBubbleOuterPaddingMd(leading);
+
return GetLayoutConstant(LOCATION_BAR_HORIZONTAL_PADDING) -
GetLayoutConstant(LOCATION_BAR_BUBBLE_HORIZONTAL_PADDING) +
- extra_padding;
+ (leading ? 0 : GetLayoutConstant(ICON_LABEL_VIEW_TRAILING_PADDING));
+}
+
+int IconLabelBubbleView::GetBubbleOuterPaddingMd(bool leading) const {
+ // When the image is empty, leading and trailing padding are equal.
+ if (image_->GetPreferredSize().IsEmpty() || !leading)
+ return GetLayoutConstant(ICON_LABEL_VIEW_TRAILING_PADDING);
+
+ // Leading padding is 2dp.
+ return 2;
}
void IconLabelBubbleView::SetLabelBackgroundColor(
diff --git a/chrome/browser/ui/views/location_bar/icon_label_bubble_view.h b/chrome/browser/ui/views/location_bar/icon_label_bubble_view.h
index 3f74609..7978cf9 100644
--- a/chrome/browser/ui/views/location_bar/icon_label_bubble_view.h
+++ b/chrome/browser/ui/views/location_bar/icon_label_bubble_view.h
@@ -78,10 +78,13 @@ class IconLabelBubbleView : public views::View {
gfx::Size GetSizeForLabelWidth(int width) const;
private:
- // Amount of padding at the edges of the bubble. If |start| is true, this
+ // Amount of padding at the edges of the bubble. If |leading| is true, this
// is the padding at the beginning of the bubble (left in LTR), otherwise it's
// the end padding.
- int GetBubbleOuterPadding(bool start) const;
+ int GetBubbleOuterPadding(bool leading) const;
+
+ // As above, but for Material Design. TODO(estade): remove/replace the above.
+ int GetBubbleOuterPaddingMd(bool leading) const;
// Sets a background color on |label_| based on |background_image_color| and
// |parent_background_color_|.