diff --git a/browser/ui/brave_layout_constants.cc b/browser/ui/brave_layout_constants.cc index 68d40b86dad1..b8b45177c1da 100644 --- a/browser/ui/brave_layout_constants.cc +++ b/browser/ui/brave_layout_constants.cc @@ -38,6 +38,8 @@ absl::optional GetBraveLayoutConstant(LayoutConstant constant) { } case LOCATION_BAR_HEIGHT: return touch ? 36 : 34; + case LOCATION_BAR_ELEMENT_PADDING: + return 4; default: break; } diff --git a/chromium_src/chrome/browser/ui/views/location_bar/icon_label_bubble_view.cc b/chromium_src/chrome/browser/ui/views/location_bar/icon_label_bubble_view.cc index da9c6ac8a511..167d7fd150db 100644 --- a/chromium_src/chrome/browser/ui/views/location_bar/icon_label_bubble_view.cc +++ b/chromium_src/chrome/browser/ui/views/location_bar/icon_label_bubble_view.cc @@ -3,16 +3,14 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this file, * You can obtain one at http://mozilla.org/MPL/2.0/. */ -#define BRAVE_ICON_LABEL_BUBBLE_VIEW_GET_HIGHLIGHT_PATH \ - if (!ShouldShowSeparator()) \ - highlight_bounds.Inset(gfx::Insets::TLBR(0, 0, 1, 0)); \ - const auto* layout_provider = GetLayoutProvider(); \ - auto layout_radius = corner_radius; \ - if (layout_provider) { \ - layout_radius = \ - layout_provider->GetCornerRadiusMetric(views::Emphasis::kMaximum); \ - } \ - const SkRect new_rect = RectToSkRect(highlight_bounds); \ +#define BRAVE_ICON_LABEL_BUBBLE_VIEW_GET_HIGHLIGHT_PATH \ + const auto* layout_provider = GetLayoutProvider(); \ + auto layout_radius = corner_radius; \ + if (layout_provider) { \ + layout_radius = \ + layout_provider->GetCornerRadiusMetric(views::Emphasis::kHigh); \ + } \ + const SkRect new_rect = RectToSkRect(highlight_bounds); \ return SkPath().addRoundRect(new_rect, layout_radius, layout_radius); #include "src/chrome/browser/ui/views/location_bar/icon_label_bubble_view.cc" diff --git a/chromium_src/chrome/browser/ui/views/location_bar/location_bar_view.cc b/chromium_src/chrome/browser/ui/views/location_bar/location_bar_view.cc index 0a7f24daf2c8..822d6769074c 100644 --- a/chromium_src/chrome/browser/ui/views/location_bar/location_bar_view.cc +++ b/chromium_src/chrome/browser/ui/views/location_bar/location_bar_view.cc @@ -9,6 +9,18 @@ #include "brave/browser/ui/views/page_action/brave_page_action_icon_container_view.h" #include "chrome/browser/ui/views/omnibox/omnibox_view_views.h" +// |icon_left| - Padding between left border of location bar and first +// decoration. Use fixed 4px always. +// |text_left| - Padding between omnibox view and last leading decoration. +// If last decoration has label, it has sufficient padding inside. +// If custom padding is provided(text_left is not null), respect +// it. Otherwise, set our design value - 5px. +#define BRAVE_LAYOUT_LEADING_DECORATIONS \ + icon_left = 4; \ + if (text_left == 0 && !location_icon_view_->ShouldShowLabel()) { \ + text_left = 5; \ + } + #define BRAVE_LAYOUT_TRAILING_DECORATIONS \ auto right_most = GetTrailingViews(); \ for (auto* item : base::Reversed(right_most)) { \ @@ -26,6 +38,7 @@ #undef ChromeOmniboxClient #undef OmniboxViewViews #undef BRAVE_LAYOUT_TRAILING_DECORATIONS +#undef BRAVE_LAYOUT_LEADING_DECORATIONS std::vector LocationBarView::GetTrailingViews() { return std::vector(); diff --git a/chromium_src/chrome/browser/ui/views/location_bar/omnibox_chip_button.cc b/chromium_src/chrome/browser/ui/views/location_bar/omnibox_chip_button.cc new file mode 100644 index 000000000000..ec92c338fe51 --- /dev/null +++ b/chromium_src/chrome/browser/ui/views/location_bar/omnibox_chip_button.cc @@ -0,0 +1,27 @@ +/* Copyright (c) 2024 The Brave Authors. All rights reserved. + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this file, + * You can obtain one at https://mozilla.org/MPL/2.0/. */ + +#include "chrome/browser/ui/views/location_bar/omnibox_chip_button.h" + +#define OmniboxChipButton OmniboxChipButton_ChromiumImpl +#include "src/chrome/browser/ui/views/location_bar/omnibox_chip_button.cc" +#undef OmniboxChipButton + +OmniboxChipButton::OmniboxChipButton(PressedCallback callback) + : OmniboxChipButton_ChromiumImpl(std::move(callback)) { + // Overridden method(GetCornerRadius()) is not used in base class' ctor. + // Set radius again. + SetCornerRadius(GetCornerRadius()); +} + +int OmniboxChipButton::GetCornerRadius() const { + if (const auto* layout_provider = GetLayoutProvider()) { + return layout_provider->GetCornerRadiusMetric(views::Emphasis::kHigh); + } + return 4; +} + +BEGIN_METADATA(OmniboxChipButton, OmniboxChipButton_ChromiumImpl) +END_METADATA diff --git a/chromium_src/chrome/browser/ui/views/location_bar/omnibox_chip_button.h b/chromium_src/chrome/browser/ui/views/location_bar/omnibox_chip_button.h new file mode 100644 index 000000000000..8f9369cf0353 --- /dev/null +++ b/chromium_src/chrome/browser/ui/views/location_bar/omnibox_chip_button.h @@ -0,0 +1,30 @@ +/* Copyright (c) 2024 The Brave Authors. All rights reserved. + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this file, + * You can obtain one at https://mozilla.org/MPL/2.0/. */ + +#ifndef BRAVE_CHROMIUM_SRC_CHROME_BROWSER_UI_VIEWS_LOCATION_BAR_OMNIBOX_CHIP_BUTTON_H_ +#define BRAVE_CHROMIUM_SRC_CHROME_BROWSER_UI_VIEWS_LOCATION_BAR_OMNIBOX_CHIP_BUTTON_H_ + +// Prevent GetCornerRadius redefinition from multiple (in)direct headers. +#include "ui/views/controls/button/md_text_button.h" +#include "ui/views/window/dialog_delegate.h" + +#define GetCornerRadius virtual GetCornerRadius +#define OmniboxChipButton OmniboxChipButton_ChromiumImpl + +#include "src/chrome/browser/ui/views/location_bar/omnibox_chip_button.h" // IWYU pragma: export + +#undef OmniboxChipButton +#undef GetCornerRadius + +class OmniboxChipButton : public OmniboxChipButton_ChromiumImpl { + public: + METADATA_HEADER(OmniboxChipButton); + explicit OmniboxChipButton(PressedCallback callback); + + // OmniboxChipButton_ChromiumImpl overrides: + int GetCornerRadius() const override; +}; + +#endif // BRAVE_CHROMIUM_SRC_CHROME_BROWSER_UI_VIEWS_LOCATION_BAR_OMNIBOX_CHIP_BUTTON_H_ diff --git a/patches/chrome-browser-ui-views-location_bar-location_bar_view.cc.patch b/patches/chrome-browser-ui-views-location_bar-location_bar_view.cc.patch index 2e36ead3d90e..841a9686458e 100644 --- a/patches/chrome-browser-ui-views-location_bar-location_bar_view.cc.patch +++ b/patches/chrome-browser-ui-views-location_bar-location_bar_view.cc.patch @@ -1,8 +1,16 @@ diff --git a/chrome/browser/ui/views/location_bar/location_bar_view.cc b/chrome/browser/ui/views/location_bar/location_bar_view.cc -index 6cdefe6a0d1487b32cbf6447ecd585caf3810b91..d9e8f0bfd850ca9cc423b8d688dd679dba4b9270 100644 +index 6cdefe6a0d1487b32cbf6447ecd585caf3810b91..8f155fd9752c134152845019aa89b5750297373d 100644 --- a/chrome/browser/ui/views/location_bar/location_bar_view.cc +++ b/chrome/browser/ui/views/location_bar/location_bar_view.cc -@@ -757,6 +757,7 @@ void LocationBarView::Layout() { +@@ -685,6 +685,7 @@ void LocationBarView::Layout() { + if (show_overriding_permission_chip) + text_left += text_overriding_permission_chip_indent; + ++ BRAVE_LAYOUT_LEADING_DECORATIONS + LocationBarLayout leading_decorations(LocationBarLayout::Position::kLeftEdge, + text_left); + LocationBarLayout trailing_decorations( +@@ -757,6 +758,7 @@ void LocationBarView::Layout() { } };