Skip to content

Truly independent web browser

UI/Qt: Tidy up the toolbar and the frame around the page

Andreas Kling46dc00eb55c8
diff --git a/UI/Qt/ChromeStyle.cpp b/UI/Qt/ChromeStyle.cpp
index fdf917b9eb7..a15ee56298b 100644
--- a/UI/Qt/ChromeStyle.cpp
+++ b/UI/Qt/ChromeStyle.cpp
@@ -647,8 +647,9 @@ QString location_edit_style_sheet(QPalette const& palette)
auto hover_color = mix(surface_color, chrome_background(palette), 0.35);
auto focus_color = dark ? mix(surface_color, QColor(255, 255, 255), 0.035) : surface_color;
- auto border_color = location_edit_border(palette);
- auto hover_border_color = border_color;
+ // NB: In dark mode, the field is set apart from the toolbar by its darker fill alone, so its border takes its fill.
+ auto border_color = dark ? surface_color : location_edit_border(palette);
+ auto hover_border_color = dark ? hover_color : border_color;
auto focus_border_color = location_edit_focus_border(palette);
auto surface = style_sheet_color(surface_color);
diff --git a/UI/Qt/LocationEdit.cpp b/UI/Qt/LocationEdit.cpp
index 4a6a609ec44..b4e51b9d6de 100644
--- a/UI/Qt/LocationEdit.cpp
+++ b/UI/Qt/LocationEdit.cpp
@@ -788,8 +788,9 @@ void LocationEdit::highlight_location()
auto url = ak_string_from_qstring(text());
QList<QInputMethodEvent::Attribute> attributes;
+ // The parts of the URL around the domain are secondary, but should not look disabled.
auto darkened_text_color = ChromeStyle::chrome_text(palette());
- darkened_text_color.setAlpha(127);
+ darkened_text_color.setAlpha(ChromeStyle::is_dark(palette()) ? 178 : 148);
QTextCharFormat dark_attributes;
dark_attributes.setForeground(darkened_text_color);
diff --git a/UI/Qt/Tab.cpp b/UI/Qt/Tab.cpp
index c6eeb7c9c2e..f636de796a5 100644
--- a/UI/Qt/Tab.cpp
+++ b/UI/Qt/Tab.cpp
@@ -362,9 +362,13 @@ QToolButton* Tab::create_navigation_history_toolbar_button(QWidget& parent, QAct
static constexpr int TOOLBAR_HORIZONTAL_MARGIN = 12;
#ifdef AK_OS_MACOS
-static constexpr int WEB_VIEW_INSET = 6;
+static constexpr int WEB_VIEW_INSET = 5;
+// The sidebar has its own padding, so a narrower frame of the toolbar's color sets the page apart from it.
+static constexpr int WEB_VIEW_SIDEBAR_INSET = 4;
#endif
static constexpr int TOOLBAR_VERTICAL_MARGIN = 2;
+// NB: The location field gets a point more room below it than above it, where the page begins.
+static constexpr int TOOLBAR_BOTTOM_MARGIN = TOOLBAR_VERTICAL_MARGIN + 1;
static constexpr int TOOLBAR_WINDOW_CONTROLS_RIGHT_MARGIN = 4;
static constexpr int DOWNLOADS_POPOVER_WIDTH = 380;
static constexpr int DOWNLOADS_POPOVER_MAX_HEIGHT = 360;
@@ -733,7 +737,7 @@ void Tab::initialize(Optional<WebView::CanonicalTraversable&> traversable)
auto* toolbar_layout = new QHBoxLayout(m_toolbar);
toolbar_layout->setSpacing(6);
- toolbar_layout->setContentsMargins(TOOLBAR_HORIZONTAL_MARGIN, TOOLBAR_VERTICAL_MARGIN, TOOLBAR_HORIZONTAL_MARGIN, TOOLBAR_VERTICAL_MARGIN);
+ toolbar_layout->setContentsMargins(TOOLBAR_HORIZONTAL_MARGIN, TOOLBAR_VERTICAL_MARGIN, TOOLBAR_HORIZONTAL_MARGIN, TOOLBAR_BOTTOM_MARGIN);
m_location_edit = new LocationEdit(this, m_window->is_private());
m_loading_animation_timer = new QTimer(this);
@@ -1591,10 +1595,9 @@ void Tab::update_web_view_frame(bool chrome_visible, Optional<WebView::VerticalT
return;
}
- // Keep the web view's rounded corners clear of the window edges. The sidebar has its own padding, so a narrower frame
- // of the toolbar's color sets the page apart from it.
- auto left = sidebar_position == WebView::VerticalTabsPosition::Left ? WEB_VIEW_INSET / 2 : WEB_VIEW_INSET;
- auto right = sidebar_position == WebView::VerticalTabsPosition::Right ? WEB_VIEW_INSET / 2 : WEB_VIEW_INSET;
+ // Keep the web view's rounded corners clear of the window edges.
+ auto left = sidebar_position == WebView::VerticalTabsPosition::Left ? WEB_VIEW_SIDEBAR_INSET : WEB_VIEW_INSET;
+ auto right = sidebar_position == WebView::VerticalTabsPosition::Right ? WEB_VIEW_SIDEBAR_INSET : WEB_VIEW_INSET;
m_view_layout->setContentsMargins(left, 0, right, WEB_VIEW_INSET);
m_view->set_has_rounded_corners(true);
}
@@ -1629,7 +1632,7 @@ static int toolbar_extra_top_margin(bool window_controls_visible)
int Tab::toolbar_height(bool window_controls_visible)
{
- return browser_chrome_layout_policy().toolbar_height + toolbar_extra_top_margin(window_controls_visible);
+ return browser_chrome_layout_policy().toolbar_height + toolbar_extra_top_margin(window_controls_visible) + (TOOLBAR_BOTTOM_MARGIN - TOOLBAR_VERTICAL_MARGIN);
}
void Tab::set_toolbar_window_controls_visible(bool visible)
@@ -1644,7 +1647,7 @@ void Tab::set_toolbar_window_controls_visible(bool visible)
m_toolbar_window_controls_separator->setVisible(has_custom_window_controls);
m_toolbar_window_controls->setVisible(has_native_window_controls || has_custom_window_controls);
m_toolbar->setFixedHeight(toolbar_height(visible));
- m_toolbar->layout()->setContentsMargins(TOOLBAR_HORIZONTAL_MARGIN, TOOLBAR_VERTICAL_MARGIN + toolbar_extra_top_margin(visible), has_custom_window_controls ? TOOLBAR_WINDOW_CONTROLS_RIGHT_MARGIN : TOOLBAR_HORIZONTAL_MARGIN, TOOLBAR_VERTICAL_MARGIN);
+ m_toolbar->layout()->setContentsMargins(TOOLBAR_HORIZONTAL_MARGIN, TOOLBAR_VERTICAL_MARGIN + toolbar_extra_top_margin(visible), has_custom_window_controls ? TOOLBAR_WINDOW_CONTROLS_RIGHT_MARGIN : TOOLBAR_HORIZONTAL_MARGIN, TOOLBAR_BOTTOM_MARGIN);
m_toolbar->layout()->invalidate();
}
@@ -1866,7 +1869,7 @@ void Tab::paintEvent(QPaintEvent*)
// inset bends around that corner rather than meeting the sidebar in a square corner. At the top, the inset joins
// the toolbar instead.
// NB: The curve meets the sidebar's edge and the window's bottom edge in a tangent.
- auto radius = m_view->viewport_corner_radius() + (WEB_VIEW_INSET / 2.0);
+ auto radius = m_view->viewport_corner_radius() + WEB_VIEW_SIDEBAR_INSET;
auto left = *m_web_view_sidebar_position == WebView::VerticalTabsPosition::Right ? width() - radius : 0.0;
auto curve_left = *m_web_view_sidebar_position == WebView::VerticalTabsPosition::Right ? width() - (2 * radius) : 0.0;
diff --git a/UI/Qt/WebContentViewMac.mm b/UI/Qt/WebContentViewMac.mm
index bf1c148e1ce..ea660ea1bc2 100644
--- a/UI/Qt/WebContentViewMac.mm
+++ b/UI/Qt/WebContentViewMac.mm
@@ -144,13 +144,14 @@ void WebContentView::update_iosurface_layer_background_color()
CGColorRelease(background_color);
}
-// The rounded page is outlined like the location field, so that it stands apart from chrome of a similar color.
+// The rounded page is outlined like the location field, so that it stands apart from chrome of a similar color. In dark
+// mode, the page stands apart from the chrome around it without one, like the location field does.
void WebContentView::update_iosurface_layer_border()
{
if (!m_iosurface_layer)
return;
auto* layer = as_layer(m_iosurface_layer);
- if (viewport_corner_radius() <= 0) {
+ if (viewport_corner_radius() <= 0 || ChromeStyle::is_dark(window()->palette())) {
layer.borderWidth = 0;
return;
}