thorium-mirror/other/thorium-2024-ui.patch

363 lines
15 KiB
Diff
Raw Normal View History

2024-08-12 10:53:10 -04:00
diff --git a/chrome/browser/ui/layout_constants.cc b/chrome/browser/ui/layout_constants.cc
2024-08-16 23:32:34 -04:00
index bba403a7e5068..29773d6aca5ad 100644
2024-08-12 10:53:10 -04:00
--- a/chrome/browser/ui/layout_constants.cc
+++ b/chrome/browser/ui/layout_constants.cc
2024-08-14 23:30:11 -04:00
@@ -1,12 +1,14 @@
2024-08-12 10:53:10 -04:00
-// Copyright 2015 The Chromium Authors
+// Copyright 2024 The Chromium Authors and Alex313031
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/browser/ui/layout_constants.h"
+#include "base/command_line.h"
#include "base/feature_list.h"
#include "base/notreached.h"
#include "build/build_config.h"
2024-08-14 23:30:11 -04:00
+#include "chrome/browser/ui/thorium_2024.h"
#include "chrome/browser/ui/ui_features.h"
#include "components/omnibox/common/omnibox_features.h"
#include "ui/base/pointer/touch_ui_controller.h"
2024-08-16 23:32:34 -04:00
@@ -27,8 +29,7 @@ int GetLayoutConstant(LayoutConstant constant) {
2024-08-12 10:53:10 -04:00
case BOOKMARK_BAR_HEIGHT: {
// The fixed margin ensures the bookmark buttons appear centered relative
// to the white space above and below.
- const int bookmark_bar_attached_vertical_margin =
- features::IsChromeRefresh2023() ? 6 : 4;
2024-08-16 23:32:34 -04:00
+ const int bookmark_bar_attached_vertical_margin = Th24State() ? 4 : 6;
2024-08-12 10:53:10 -04:00
return GetLayoutConstant(BOOKMARK_BAR_BUTTON_HEIGHT) +
bookmark_bar_attached_vertical_margin;
}
2024-08-16 23:32:34 -04:00
@@ -97,7 +98,11 @@ int GetLayoutConstant(LayoutConstant constant) {
2024-08-12 10:53:10 -04:00
return GetLayoutConstant(TAB_HEIGHT) +
GetLayoutConstant(TAB_STRIP_PADDING);
case TAB_STRIP_PADDING:
- return features::IsChromeRefresh2023() ? 6 : 0;
2024-08-16 23:32:34 -04:00
+ return Th24State() ? 0 : 6;
+ case TAB_MARGIN:
+ return Th24State() ? 6 : 0;
+ case TAB_INACTIVE_PADDING:
+ return Th24State() ? 2 : 6;
2024-08-12 10:53:10 -04:00
case TAB_SEPARATOR_HEIGHT:
// TODO (crbug.com/1451400): ChromeRefresh2023 needs different values for
// this constant.
2024-08-16 23:32:34 -04:00
@@ -117,7 +122,7 @@ int GetLayoutConstant(LayoutConstant constant) {
return 0;
return 1;
case TOOLBAR_BUTTON_HEIGHT:
- if (features::IsChromeRefresh2023()) {
+ if (features::IsChromeRefresh2023() && !Th24State()) {
return touch_ui ? 48 : 34;
} else {
return touch_ui ? 48 : 28;
@@ -133,21 +138,29 @@ int GetLayoutConstant(LayoutConstant constant) {
case TOOLBAR_ELEMENT_PADDING:
return touch_ui ? 0 : 4;
case TOOLBAR_ICON_DEFAULT_MARGIN:
- if (features::IsChromeRefresh2023()) {
+ if (features::IsChromeRefresh2023() && !Th24State()) {
return touch_ui ? 0 : 2;
} else {
return GetLayoutConstant(TOOLBAR_ELEMENT_PADDING);
}
case TOOLBAR_STANDARD_SPACING:
- if (features::IsChromeRefresh2023()) {
+ if (features::IsChromeRefresh2023() && !Th24State()) {
return touch_ui ? 12 : 9;
} else {
return touch_ui ? 12 : 8;
}
case PAGE_INFO_ICON_SIZE:
- return features::IsChromeRefresh2023() ? 20 : 16;
+ if (features::IsChromeRefresh2023() && !Th24State()) {
+ return 20;
+ } else {
+ return 16;
+ }
case DOWNLOAD_ICON_SIZE:
- return features::IsChromeRefresh2023() ? 20 : 16;
+ if (features::IsChromeRefresh2023() && !Th24State()) {
+ return 20;
+ } else {
+ return 16;
+ }
case TOOLBAR_CORNER_RADIUS:
return 8;
default:
2024-08-14 23:30:11 -04:00
diff --git a/chrome/browser/ui/layout_constants.h b/chrome/browser/ui/layout_constants.h
2024-08-16 23:32:34 -04:00
index d26bc737d3177..b19c42b774986 100644
2024-08-14 23:30:11 -04:00
--- a/chrome/browser/ui/layout_constants.h
+++ b/chrome/browser/ui/layout_constants.h
2024-08-16 23:32:34 -04:00
@@ -119,6 +119,12 @@ enum LayoutConstant {
2024-08-14 23:30:11 -04:00
// detached tab, and on all sides of the controls padding.
TAB_STRIP_PADDING,
2024-08-16 23:32:34 -04:00
+ // For the tab margins
+ TAB_MARGIN,
+
+ // For inactive tab padding
+ TAB_INACTIVE_PADDING,
2024-08-14 23:30:11 -04:00
+
// The height of a separator in the tabstrip.
TAB_SEPARATOR_HEIGHT,
2024-08-12 10:53:10 -04:00
diff --git a/chrome/browser/ui/tabs/tab_style.cc b/chrome/browser/ui/tabs/tab_style.cc
2024-08-16 23:32:34 -04:00
index aa9cd30374311..daab857dd0263 100644
2024-08-12 10:53:10 -04:00
--- a/chrome/browser/ui/tabs/tab_style.cc
+++ b/chrome/browser/ui/tabs/tab_style.cc
2024-08-16 23:32:34 -04:00
@@ -1,26 +1,30 @@
2024-08-12 10:53:10 -04:00
-// Copyright 2019 The Chromium Authors
+// Copyright 2024 The Chromium Authors and Alex313031
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
2024-08-14 23:30:11 -04:00
#include "chrome/browser/ui/tabs/tab_style.h"
#include "chrome/browser/ui/layout_constants.h"
2024-08-16 23:32:34 -04:00
+#include "chrome/browser/ui/thorium_2024.h"
2024-08-14 23:30:11 -04:00
#include "chrome/browser/ui/ui_features.h"
#include "ui/base/ui_base_features.h"
2024-08-16 23:32:34 -04:00
#include "ui/color/color_provider.h"
2024-08-14 23:30:11 -04:00
#include "ui/views/layout/layout_provider.h"
namespace {
-
// Thickness in DIPs of the separator painted on the left and right edges of
2024-08-12 10:53:10 -04:00
// the tab.
constexpr int kGM2SeparatorThickness = 1;
2024-08-14 23:30:11 -04:00
+constexpr int kThoriumSeparatorThickness = 2;
2024-08-12 10:53:10 -04:00
constexpr int kChromeRefreshSeparatorThickness = 2;
2024-08-14 23:30:11 -04:00
+constexpr int kThoriumSeparatorHorizontalMargin = 1;
constexpr int kChromeRefreshSeparatorHorizontalMargin = 2;
2024-08-12 10:53:10 -04:00
// TODO (crbug.com/1451400): This constant should be in LayoutConstants.
2024-08-14 23:30:11 -04:00
+constexpr int kThoriumSeparatorHeight = 20;
constexpr int kChromeRefreshSeparatorHeight = 16;
2024-08-12 10:53:10 -04:00
// The padding from the top of the tab to the content area.
2024-08-14 23:30:11 -04:00
+constexpr int kThoriumTabVerticalPadding = 9;
constexpr int kChromeRefreshTabVerticalPadding = 6;
2024-08-12 10:53:10 -04:00
constexpr int kChromeRefreshTabHorizontalPadding = 8;
2024-08-16 23:32:34 -04:00
@@ -197,11 +201,19 @@ float GM2TabStyle::GetSelectedTabOpacity() const {
2024-08-14 23:30:11 -04:00
}
int ChromeRefresh2023TabStyle::GetTopCornerRadius() const {
- return 10;
2024-08-16 23:32:34 -04:00
+ if (Th24State()) {
2024-08-14 23:30:11 -04:00
+ return 8;
+ } else {
+ return 10;
+ }
}
int ChromeRefresh2023TabStyle::GetBottomCornerRadius() const {
- return 12;
2024-08-16 23:32:34 -04:00
+ if (Th24State()) {
+ return 8;
2024-08-14 23:30:11 -04:00
+ } else {
+ return 12;
+ }
}
int ChromeRefresh2023TabStyle::GetTabOverlap() const {
2024-08-16 23:32:34 -04:00
@@ -213,23 +225,43 @@ int ChromeRefresh2023TabStyle::GetTabOverlap() const {
2024-08-14 23:30:11 -04:00
}
gfx::Size ChromeRefresh2023TabStyle::GetSeparatorSize() const {
- return gfx::Size(kChromeRefreshSeparatorThickness,
- kChromeRefreshSeparatorHeight);
2024-08-16 23:32:34 -04:00
+ if (Th24State()) {
2024-08-14 23:30:11 -04:00
+ return gfx::Size(kThoriumSeparatorThickness,
+ kThoriumSeparatorHeight);
+ } else {
+ return gfx::Size(kChromeRefreshSeparatorThickness,
+ kChromeRefreshSeparatorHeight);
+ }
}
gfx::Insets ChromeRefresh2023TabStyle::GetContentsInsets() const {
- return gfx::Insets::TLBR(
- kChromeRefreshTabVerticalPadding + GetLayoutConstant(TAB_STRIP_PADDING),
- GetBottomCornerRadius() + kChromeRefreshTabHorizontalPadding,
- kChromeRefreshTabVerticalPadding + GetLayoutConstant(TAB_STRIP_PADDING),
- GetBottomCornerRadius() + kChromeRefreshTabHorizontalPadding);
2024-08-16 23:32:34 -04:00
+ if (Th24State()) {
2024-08-14 23:30:11 -04:00
+ return gfx::Insets::TLBR(
+ kThoriumTabVerticalPadding + GetLayoutConstant(TAB_STRIP_PADDING),
+ GetBottomCornerRadius() + kChromeRefreshTabHorizontalPadding,
+ kThoriumTabVerticalPadding + GetLayoutConstant(TAB_STRIP_PADDING),
+ GetBottomCornerRadius() + kChromeRefreshTabHorizontalPadding);
+ } else {
+ return gfx::Insets::TLBR(
+ kChromeRefreshTabVerticalPadding + GetLayoutConstant(TAB_STRIP_PADDING),
+ GetBottomCornerRadius() + kChromeRefreshTabHorizontalPadding,
+ kChromeRefreshTabVerticalPadding + GetLayoutConstant(TAB_STRIP_PADDING),
+ GetBottomCornerRadius() + kChromeRefreshTabHorizontalPadding);
+ }
}
gfx::Insets ChromeRefresh2023TabStyle::GetSeparatorMargins() const {
- return gfx::Insets::TLBR(GetLayoutConstant(TAB_STRIP_PADDING),
- kChromeRefreshSeparatorHorizontalMargin,
- GetLayoutConstant(TAB_STRIP_PADDING),
- kChromeRefreshSeparatorHorizontalMargin);
2024-08-16 23:32:34 -04:00
+ if (Th24State()) {
+ return gfx::Insets::TLBR(GetLayoutConstant(TAB_INACTIVE_PADDING),
2024-08-14 23:30:11 -04:00
+ kThoriumSeparatorHorizontalMargin,
2024-08-16 23:32:34 -04:00
+ GetLayoutConstant(TAB_INACTIVE_PADDING),
2024-08-14 23:30:11 -04:00
+ kThoriumSeparatorHorizontalMargin);
+ } else {
+ return gfx::Insets::TLBR(GetLayoutConstant(TAB_STRIP_PADDING),
+ kChromeRefreshSeparatorHorizontalMargin,
+ GetLayoutConstant(TAB_STRIP_PADDING),
+ kChromeRefreshSeparatorHorizontalMargin);
+ }
}
int ChromeRefresh2023TabStyle::GetSeparatorCornerRadius() const {
diff --git a/chrome/browser/ui/views/frame/browser_frame_view_win.cc b/chrome/browser/ui/views/frame/browser_frame_view_win.cc
2024-08-16 23:32:34 -04:00
index 779aa88afb0fa..9404ec1e04e3e 100644
2024-08-14 23:30:11 -04:00
--- a/chrome/browser/ui/views/frame/browser_frame_view_win.cc
+++ b/chrome/browser/ui/views/frame/browser_frame_view_win.cc
2024-08-16 23:32:34 -04:00
@@ -17,6 +17,7 @@
#include "chrome/browser/themes/theme_properties.h"
#include "chrome/browser/ui/color/chrome_color_id.h"
#include "chrome/browser/ui/layout_constants.h"
+#include "chrome/browser/ui/thorium_2024.h"
#include "chrome/browser/ui/ui_features.h"
#include "chrome/browser/ui/view_ids.h"
#include "chrome/browser/ui/views/frame/browser_caption_button_container_win.h"
@@ -318,9 +319,9 @@ int BrowserFrameViewWin::NonClientHitTest(const gfx::Point& point) {
2024-08-14 23:30:11 -04:00
// pixels at the end of the top and bottom edges trigger diagonal resizing.
constexpr int kResizeCornerWidth = 16;
- const int top_border_thickness = features::IsChromeRefresh2023()
- ? GetLayoutConstant(TAB_STRIP_PADDING)
- : FrameTopBorderThickness(false);
2024-08-16 23:32:34 -04:00
+ const int top_border_thickness = Th24State()
2024-08-14 23:30:11 -04:00
+ ? FrameTopBorderThickness(false);
2024-08-16 23:32:34 -04:00
+ : GetLayoutConstant(TAB_STRIP_PADDING);
2024-08-14 23:30:11 -04:00
int window_component = GetHTComponentForFrame(
point, gfx::Insets::TLBR(top_border_thickness, 0, 0, 0),
diff --git a/chrome/browser/ui/views/frame/tab_strip_region_view.cc b/chrome/browser/ui/views/frame/tab_strip_region_view.cc
2024-08-16 23:32:34 -04:00
index f534d7e925b86..29928bb858259 100644
2024-08-14 23:30:11 -04:00
--- a/chrome/browser/ui/views/frame/tab_strip_region_view.cc
+++ b/chrome/browser/ui/views/frame/tab_strip_region_view.cc
2024-08-16 23:32:34 -04:00
@@ -372,7 +372,7 @@ void TabStripRegionView::Layout(PassKey) {
2024-08-14 23:30:11 -04:00
gfx::Point new_tab_button_new_position =
gfx::Point(tab_strip_container_->bounds().right() -
TabStyle::Get()->GetBottomCornerRadius() +
- GetLayoutConstant(TAB_STRIP_PADDING),
2024-08-16 23:32:34 -04:00
+ GetLayoutConstant(TAB_MARGIN),
0);
2024-08-14 23:30:11 -04:00
gfx::Rect new_tab_button_new_bounds =
2024-08-16 23:32:34 -04:00
diff --git a/chrome/browser/ui/views/tabs/tab_style_views.cc b/chrome/browser/ui/views/tabs/tab_style_views.cc
index f59e9c5bc9fe6..e7aa9b960282a 100644
--- a/chrome/browser/ui/views/tabs/tab_style_views.cc
+++ b/chrome/browser/ui/views/tabs/tab_style_views.cc
@@ -1157,7 +1157,7 @@ SkPath ChromeRefresh2023TabStyleViews::GetPath(
// this. Detached tab shapes do not need to respect this.
if (path_type != TabStyle::PathType::kInteriorClip &&
path_type != TabStyle::PathType::kHitTest) {
- tab_height -= GetLayoutConstant(TAB_STRIP_PADDING) * scale;
+ tab_height -= GetLayoutConstant(TAB_MARGIN) * scale;
tab_height -= GetLayoutConstant(TABSTRIP_TOOLBAR_OVERLAP) * scale;
}
@@ -1167,7 +1167,7 @@ SkPath ChromeRefresh2023TabStyleViews::GetPath(
}
int left = aligned_bounds.x() + extension_corner_radius;
- int top = aligned_bounds.y() + GetLayoutConstant(TAB_STRIP_PADDING) * scale;
+ int top = aligned_bounds.y() + GetLayoutConstant(TAB_INACTIVE_PADDING) * scale;
int right = aligned_bounds.right() - extension_corner_radius;
const int bottom = top + tab_height;
2024-08-14 23:30:11 -04:00
diff --git a/ui/views/controls/menu/menu_config.cc b/ui/views/controls/menu/menu_config.cc
2024-08-16 23:32:34 -04:00
index 83c7f06f1b236..576150ff56af4 100644
2024-08-14 23:30:11 -04:00
--- a/ui/views/controls/menu/menu_config.cc
+++ b/ui/views/controls/menu/menu_config.cc
2024-08-16 23:32:34 -04:00
@@ -1,10 +1,11 @@
2024-08-14 23:30:11 -04:00
-// Copyright 2012 The Chromium Authors
+// Copyright 2024 The Chromium Authors and Alex313031
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "ui/views/controls/menu/menu_config.h"
#include "base/no_destructor.h"
2024-08-16 23:32:34 -04:00
+#include "chrome/browser/ui/thorium_2024.h"
2024-08-14 23:30:11 -04:00
#include "ui/base/ui_base_features.h"
#include "ui/views/controls/menu/menu_controller.h"
2024-08-16 23:32:34 -04:00
#include "ui/views/controls/menu/menu_item_view.h"
@@ -55,12 +56,12 @@ void MenuConfig::InitCommon() {
2024-08-14 23:30:11 -04:00
reserve_dedicated_arrow_column = false;
menu_horizontal_border_size = 0;
submenu_horizontal_overlap = 0;
- item_vertical_margin = 6;
2024-08-16 23:32:34 -04:00
+ item_vertical_margin = Th24State() ? 4 : 6;
2024-08-14 23:30:11 -04:00
item_horizontal_border_padding = 12;
arrow_size = 16;
- separator_height = 17;
- separator_spacing_height = 4;
- use_outer_border = false;
2024-08-16 23:32:34 -04:00
+ separator_height = Th24State() ? 11 : 17;
+ separator_spacing_height = Th24State() ? 3 : 4;
+ use_outer_border = Th24State() ? true : false;
2024-08-14 23:30:11 -04:00
}
// static
2024-08-12 10:53:10 -04:00
diff --git a/ui/views/layout/layout_provider.cc b/ui/views/layout/layout_provider.cc
2024-08-16 23:32:34 -04:00
index 3684e27766834..74e7cb7a004a7 100644
2024-08-12 10:53:10 -04:00
--- a/ui/views/layout/layout_provider.cc
+++ b/ui/views/layout/layout_provider.cc
@@ -1,4 +1,4 @@
-// Copyright 2017 The Chromium Authors
+// Copyright 2024 The Chromium Authors and Alex313031
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
2024-08-16 23:32:34 -04:00
@@ -8,6 +8,7 @@
2024-08-12 10:53:10 -04:00
#include "base/containers/fixed_flat_map.h"
#include "base/logging.h"
2024-08-16 23:32:34 -04:00
+#include "chrome/browser/ui/thorium_2024.h"
2024-08-12 10:53:10 -04:00
#include "ui/base/ui_base_features.h"
2024-08-16 23:32:34 -04:00
#include "ui/gfx/font_list.h"
#include "ui/views/controls/focus_ring.h"
@@ -234,6 +235,32 @@ int LayoutProvider::GetCornerRadiusMetric(ShapeContextTokens id,
2024-08-12 10:53:10 -04:00
}
}
2024-08-16 23:32:34 -04:00
+ if (Th24State()) {
2024-08-12 10:53:10 -04:00
+ switch (id) {
2024-08-16 23:32:34 -04:00
+ case ShapeContextTokens::kBadgeRadius:
+ return 3;
+ case ShapeContextTokens::kButtonRadius:
+ return GetCornerRadiusMetric(Emphasis::kMedium, size);
+ case ShapeContextTokens::kComboboxRadius:
+ case ShapeContextTokens::kDialogRadius:
+ case ShapeContextTokens::kFindBarViewRadius:
+ return GetCornerRadiusMetric(Emphasis::kMedium, size);
2024-08-12 10:53:10 -04:00
+ case ShapeContextTokens::kMenuRadius:
2024-08-16 23:32:34 -04:00
+ case ShapeContextTokens::kMenuAuxRadius:
2024-08-14 23:30:11 -04:00
+ return GetCornerRadiusMetric(Emphasis::kNone);
2024-08-16 23:32:34 -04:00
+ case ShapeContextTokens::kMenuTouchRadius:
2024-08-14 23:30:11 -04:00
+ return GetCornerRadiusMetric(Emphasis::kHigh);
2024-08-16 23:32:34 -04:00
+ case ShapeContextTokens::kOmniboxExpandedRadius:
+ return 16;
+ case ShapeContextTokens::kTextfieldRadius:
+ return FocusRing::kDefaultCornerRadiusDp;
+ case ShapeContextTokens::kSidePanelContentRadius:
+ return GetCornerRadiusMetric(Emphasis::kMedium);
+ default:
+ return 0;
2024-08-12 10:53:10 -04:00
+ }
+ }
2024-08-16 23:32:34 -04:00
+
2024-08-12 10:53:10 -04:00
ShapeSysTokens token = GetShapeSysToken(id);
DCHECK_NE(token, ShapeSysTokens::kDefault)
2024-08-16 23:32:34 -04:00
<< "kDefault token means there is a missing mapping between shape tokens";