Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adjusted location bar's icon radius, highlight path (uplift to 1.62.x) #21548

Merged
merged 2 commits into from
Jan 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions browser/ui/brave_layout_constants.cc
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ absl::optional<int> GetBraveLayoutConstant(LayoutConstant constant) {
}
case LOCATION_BAR_HEIGHT:
return touch ? 36 : 34;
case LOCATION_BAR_ELEMENT_PADDING:
return 4;
default:
break;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)) { \
Expand All @@ -26,6 +38,7 @@
#undef ChromeOmniboxClient
#undef OmniboxViewViews
#undef BRAVE_LAYOUT_TRAILING_DECORATIONS
#undef BRAVE_LAYOUT_LEADING_DECORATIONS

std::vector<views::View*> LocationBarView::GetTrailingViews() {
return std::vector<views::View*>();
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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_
Original file line number Diff line number Diff line change
@@ -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() {
}
};

Expand Down