Truly independent web browser
Base: Give every control on Ladybird's pages a hover fill
Andreas Kling148457bcfbd5
diff --git a/Base/res/ladybird/about-pages/bookmarks.html b/Base/res/ladybird/about-pages/bookmarks.htmlindex 23c080b9ede..8eaf5fde0a4 100644--- a/Base/res/ladybird/about-pages/bookmarks.html+++ b/Base/res/ladybird/about-pages/bookmarks.html@@ -269,7 +269,7 @@<main><header><h2 id="folder-title">Bookmarks bar</h2>- <div class="search-container">+ <label class="search-container"><svgclass="search-icon"viewBox="0 0 16 16"@@ -288,7 +288,7 @@placeholder="Search bookmarks"aria-label="Search bookmarks"/>- </div>+ </label><button class="secondary-button" id="new-folder-button">New folder</button><div class="header-menu"><button class="menu-toggle" id="menu-toggle" aria-label="Bookmark options">diff --git a/Base/res/ladybird/about-pages/settings.html b/Base/res/ladybird/about-pages/settings.htmlindex 6fb5519b1de..621ce64726a 100644--- a/Base/res/ladybird/about-pages/settings.html+++ b/Base/res/ladybird/about-pages/settings.html@@ -37,22 +37,32 @@.input-reset-button {position: absolute;- right: 12px;+ right: 6px;top: 50%;transform: translateY(-50%);+ display: flex;+ align-items: center;+ justify-content: center;+ width: 20px;+ height: 20px;++ color: inherit;background: none;border: none;- padding: 0 4px;+ border-radius: 5px;+ padding: 0;font-size: 18px;+ line-height: 1;opacity: 0.4;cursor: pointer;}.input-reset-button:hover {+ background-color: var(--control);opacity: 0.8;}@@ -88,8 +98,59 @@margin-bottom: 0;}- .inline-container:has(> input[type="checkbox"]:disabled) > label {+ /* Every row whose label names a control acts as one control: a click anywhere on it reaches the control, as+ the label's hit area is stretched over the whole row, under the row's controls, and the row shows a+ rounded fill under the pointer. The fill reaches a little past the row's sides but stays clear of the+ lines between rows, and is held back while the pointer is over a button of its own beside the control,+ such as an Exceptions… button. A row whose control is disabled is dimmed and does nothing. */+ .card-group.inline-container {+ --row-fill-inset: 4px -10px;+ }++ .input-field-container {+ --row-fill-inset: -6px -10px;+ }++ :is(.inline-container, .input-field-container):has(> label[for]) {+ position: relative;+ isolation: isolate;+ }++ :is(.inline-container, .input-field-container) > label[for] {+ cursor: pointer;+ }++ :is(.inline-container, .input-field-container) > label[for]::after {+ content: "";+ position: absolute;+ inset: 0;+ }++ :is(.inline-container, .input-field-container):has(> label[for]) > :not(label) {+ position: relative;+ z-index: 1;+ }++ :is(.inline-container, .input-field-container):has(:is(input, select, textarea):disabled, > button:disabled)+ > label[for] {opacity: 0.5;+ cursor: default;+ }++ :is(.inline-container, .input-field-container):has(> label[for]):not(+ :has(+ :is(input, select, textarea):disabled,+ > button:disabled,+ .setting-controls > button:hover,+ .input-reset-button:hover+ )+ ):hover::before {+ content: "";+ position: absolute;+ inset: var(--row-fill-inset);+ z-index: -1;+ border-radius: 8px;+ background-color: var(--control);}.button-container {@@ -181,6 +242,10 @@outline: none;}+ textarea:where(:not(:disabled, :focus)):hover {+ background-color: var(--control-hover);+ }+input[type="number"].error,input[type="text"].error,input[type="url"].error {@@ -269,25 +334,42 @@font-weight: 600;}+ /* An icon button, filled under the pointer like the toolbar's buttons. */dialog .dialog-button {+ display: flex;+ align-items: center;+ justify-content: center;+ min-width: 28px;+ height: 28px;++ color: inherit;background: none;border: none;+ border-radius: 6px;outline: none;padding: 0;font-size: 22px;+ line-height: 1;opacity: 0.8;cursor: pointer;}- dialog .dialog-button:hover {+ /* NB: The close button's glyph keeps its place at the header's edge, with the fill reaching past it. */+ dialog .dialog-header .dialog-button {+ margin-right: -7px;+ }++ dialog .dialog-button:not(:disabled):hover {+ background-color: var(--control);opacity: 1;}dialog .dialog-button:disabled {opacity: 0.3;+ cursor: default;}dialog .dialog-list {@@ -310,10 +392,6 @@align-items: center;}- dialog .dialog-list-item:hover {- background-color: var(--control);- }-dialog .dialog-list-item-placeholder {padding: 10px;opacity: 0.6;@@ -403,6 +481,10 @@border-top: 1px solid var(--separator-soft);}+ .crash-mode:not(:has(input:checked)):hover {+ background: var(--control);+ }+.crash-mode:has(input:checked) {background: var(--choice-fill);}@@ -484,9 +566,18 @@}.expandable-list summary {+ width: fit-content;+ margin-left: -6px;+ padding: 2px 6px;+ border-radius: 5px;+cursor: pointer;}+ .expandable-list summary:hover {+ background-color: var(--control);+ }+.expandable-list[open] summary {margin-bottom: 20px;}@@ -525,6 +616,7 @@}.search-field {+ cursor: text;display: flex;align-items: center;gap: 8px;@@ -535,6 +627,10 @@background-color: var(--control);}+ .search-field:not(:focus-within):hover {+ background-color: var(--control-hover);+ }+.search-field:focus-within {background-color: var(--page);box-shadow:@@ -550,7 +646,8 @@}.search-field input,- .search-field input:focus {+ .search-field input:focus,+ .search-field input:hover {flex: 1;min-width: 0;height: auto;@@ -589,13 +686,14 @@opacity: 1;}+ /* The chosen section's fill is deeper than the faint hover fill, so a hovered section never looks chosen. */.tab-button:hover {- background-color: var(--control);+ background-color: var(--hover-faint);opacity: 1;}.tab-button.active {- background-color: var(--control);+ background-color: var(--control-pressed);}/* The focus ring appears only for keyboard focus, never after a click. */@@ -726,8 +824,13 @@cursor: pointer;}- button.link-button:hover {- text-decoration: underline;+ button.link-button:not(:disabled):hover {+ background-color: var(--control);+ }++ button.link-button:disabled {+ opacity: 0.5;+ cursor: default;}.engine-choice {@@ -740,6 +843,10 @@pointer-events: none;}+ .engine-choice:not(:has(input:checked)):hover {+ background: var(--control);+ }+.engine-choice:has(input:checked) {background: var(--choice-fill);}@@ -775,6 +882,33 @@visibility: visible;}+ /* The checkbox's label is stretched over the whole row, under the checkbox and the Remove button, so a click+ anywhere else on the row toggles the list, and the whole row is filled under the pointer, except while+ the pointer is over its Remove button. */+ .filter-list-row {+ position: relative;+ isolation: isolate;+ }++ .filter-list-row > label {+ cursor: pointer;+ }++ .filter-list-row > label::after {+ content: "";+ position: absolute;+ inset: 0;+ }++ .filter-list-row > :not(label) {+ position: relative;+ z-index: 1;+ }++ .filter-list-row:not(:has(button:hover)):hover {+ background: var(--control);+ }+.filter-list-row input[type="checkbox"] {flex-shrink: 0;margin: 0;@@ -1100,7 +1234,7 @@<div class="card-group inline-container"><label for="new-tab-page-url">New tab page URL</label><div class="input-with-reset">- <input id="new-tab-page-url" type="url" />+ <input id="new-tab-page-url" type="url" spellcheck="false" /><buttonid="new-tab-page-url-reset"class="input-reset-button hidden"@@ -1150,14 +1284,12 @@<div class="tab-panel" id="tab-privacy" data-title="Privacy and security"><div class="card"><div class="card-body">- <div class="card-group">- <div class="inline-container">- <label for="global-privacy-control-toggle">- Global Privacy Control- <p class="description">Tell websites not to sell or share your data.</p>- </label>- <input id="global-privacy-control-toggle" type="checkbox" switch />- </div>+ <div class="card-group inline-container">+ <label for="global-privacy-control-toggle">+ Global Privacy Control+ <p class="description">Tell websites not to sell or share your data.</p>+ </label>+ <input id="global-privacy-control-toggle" type="checkbox" switch /></div></div></div>@@ -1167,7 +1299,7 @@<div class="card-body"><p id="browsing-data-total-size" class="card-group"></p><div class="card-group inline-container">- <span>Clear browsing data</span>+ <label for="browsing-data-settings">Clear browsing data</label><button id="browsing-data-settings" class="secondary-button">Clear…</button></div></div>@@ -1309,6 +1441,7 @@id="custom-content-blocker-subscription-url"type="url"placeholder="Filter list URL"+ spellcheck="false"/><button id="add-content-blocker-subscription" class="secondary-button">Add</button></div>@@ -1389,7 +1522,7 @@<button id="review-crash-reports" class="secondary-button">Review reports</button></div><div class="card-group inline-container">- <p>Open the folder containing saved crash reports.</p>+ <label for="open-crash-reports">Open the folder containing saved crash reports.</label><button id="open-crash-reports" class="secondary-button">Open folder</button></div><p id="crash-reports-status" class="description" role="status" hidden></p>@@ -1427,18 +1560,18 @@</div><div class="card-group inline-container"><label for="dns-server">DNS server (IP or hostname)</label>- <input id="dns-server" type="text" />+ <input id="dns-server" type="text" spellcheck="false" /></div><div class="card-group inline-container"><label for="dns-port">Port</label>- <input id="dns-port" type="text" placeholder="53" />+ <input id="dns-port" type="text" placeholder="53" spellcheck="false" /></div></div></div></div><h3 class="card-title">Developer</h3>- <div class="search-container">+ <label class="search-container"><svgclass="search-icon"xmlns="http://www.w3.org/2000/svg"@@ -1455,8 +1588,9 @@type="search"class="search-input"placeholder="Filter configuration keys"+ spellcheck="false"/>- </div>+ </label><div class="card"><div class="card-body"><div id="config-list"></div>@@ -1501,7 +1635,12 @@Search URL<p class="description">Use %s as a placeholder for the search query</p></label>- <input id="search-custom-url" type="url" placeholder="https://example.com/search?q=%s" />+ <input+ id="search-custom-url"+ type="url"+ placeholder="https://example.com/search?q=%s"+ spellcheck="false"+ /></div><div class="form-group"><label for="search-custom-suggestions-url">@@ -1514,6 +1653,7 @@id="search-custom-suggestions-url"type="url"placeholder="https://example.com/suggest?q=%s"+ spellcheck="false"/></div><div class="dialog-controls">@@ -1531,7 +1671,7 @@<label>Site exceptions</label><div id="site-settings-list" class="dialog-list"></div><div class="dialog-controls">- <input id="site-settings-input" type="text" placeholder="https://example.com" />+ <input id="site-settings-input" type="text" placeholder="https://example.com" spellcheck="false" /><select id="site-settings-decision" aria-label="Site policy"></select><button id="site-settings-add" class="primary-button">Add site</button></div>@@ -1562,7 +1702,7 @@</div><div class="dialog-body" style="height: auto"><div class="input-field-container">- <p>Remove browsing data from:</p>+ <label for="clear-browsing-data-time-range">Remove browsing data from:</label><select id="clear-browsing-data-time-range"><option value="lastHour">Last hour</option><option value="last4Hours">Last 4 hours</option>@@ -1779,6 +1919,63 @@});});+ // A label names a field to type a new value into, so clicking it selects the field's text, and typing+ // replaces it.+ const TEXT_FIELD_SELECTOR = 'input:is([type="text"], [type="url"], [type="number"], [type="search"])';++ document.addEventListener("click", event => {+ const field = event.target.closest?.("label[for]")?.control;+ if (!field || field.disabled || !field.matches(TEXT_FIELD_SELECTOR)) {+ return;+ }++ event.preventDefault();+ field.focus();+ field.select();+ });++ // Enter commits a field's new value and leaves the field, and Escape restores the value the field had when it+ // took focus and leaves it. A search field holds no setting to restore, so Escape clears it, and leaves it once+ // it is empty. A field in a dialog keeps the dialog's keys instead, and a textarea keeps Enter for new lines+ // and keeps its text on Escape, as its changes are saved with a button of their own.+ const valueAtFocus = new WeakMap();++ document.addEventListener("focusin", event => {+ if (event.target.matches?.(TEXT_FIELD_SELECTOR)) {+ valueAtFocus.set(event.target, event.target.value);+ }+ });++ document.addEventListener("keydown", event => {+ if ((event.key !== "Enter" && event.key !== "Escape") || event.defaultPrevented) {+ return;+ }++ const field = event.target;+ if (field.closest?.("dialog")) {+ return;+ }++ if (field.matches?.(TEXT_FIELD_SELECTOR)) {+ const isSearch = field.type === "search";+ const restoredValue = isSearch ? "" : valueAtFocus.get(field);+ if (event.key === "Escape" && restoredValue !== undefined && field.value !== restoredValue) {+ field.value = restoredValue;+ // NB: Filters and the like follow the field as it is edited, so they learn of the new value.+ field.dispatchEvent(new Event("input", { bubbles: true }));+ if (isSearch) {+ event.preventDefault();+ return;+ }+ }+ } else if (!(event.key === "Escape" && field.matches?.("textarea"))) {+ return;+ }++ event.preventDefault();+ field.blur();+ });+document.addEventListener("WebUILoaded", () => {ladybird.sendMessage("loadFeatures");ladybird.sendMessage("loadCurrentSettings");diff --git a/Base/res/ladybird/about-pages/settings/advanced.js b/Base/res/ladybird/about-pages/settings/advanced.jsindex e778cc49b8c..ffb3bda06f5 100644--- a/Base/res/ladybird/about-pages/settings/advanced.js+++ b/Base/res/ladybird/about-pages/settings/advanced.js@@ -14,6 +14,8 @@ function createControl(variable) {const type = variable.type === "array" && variable.elementType === "string" ? "textarea" : "input";const input = document.createElement(type);input.id = variable.name;+ // NB: Configuration values are names, numbers and addresses, not words to check the spelling of.+ input.spellcheck = false;if (variable.type === "boolean") {input.type = "checkbox";diff --git a/Base/res/ladybird/about-pages/webui.css b/Base/res/ladybird/about-pages/webui.cssindex 3d69aca7001..e806940c138 100644--- a/Base/res/ladybird/about-pages/webui.css+++ b/Base/res/ladybird/about-pages/webui.css@@ -84,6 +84,13 @@ header h1 {border: none;border-radius: 7px;++ /* The whole field is the label of its input, so a click anywhere in it puts the caret in the input. */+ cursor: text;+}++.search-container:not(:focus-within):hover {+ background-color: var(--control-hover);}.search-container:focus-within {@@ -102,7 +109,8 @@ header h1 {.search-container .search-input,.search-container .search-input:focus,-.search-container .search-input:focus-visible {+.search-container .search-input:focus-visible,+.search-container .search-input:hover {background: none;color: inherit;diff --git a/Base/res/ladybird/ladybird.css b/Base/res/ladybird/ladybird.cssindex 5e857780597..33b967b0959 100644--- a/Base/res/ladybird/ladybird.css+++ b/Base/res/ladybird/ladybird.css@@ -55,6 +55,7 @@--control-hover: rgba(0, 0, 0, 0.075);--control-pressed: rgba(0, 0, 0, 0.09);--segment: #ffffff;+ --hover-faint: rgba(0, 0, 0, 0.04);--surface: #fbfbfc;--tile: #f3f3f5;--edge: rgba(0, 0, 0, 0.1);@@ -93,6 +94,7 @@--control-hover: rgba(255, 255, 255, 0.12);--control-pressed: rgba(255, 255, 255, 0.14);--segment: #48484e;+ --hover-faint: rgba(255, 255, 255, 0.04);--surface: #333336;--tile: #2c2c2f;--edge: rgba(255, 255, 255, 0.12);@@ -147,12 +149,19 @@--secondary-button-color: var(--control);--secondary-button-hover: var(--control-hover);--secondary-button-active: var(--control-pressed);++ /* A neutral fill laid over a colored control under the pointer, as the toolbar's hover fill takes on the tint of the+ surface below it. */+ --hover-overlay: linear-gradient(rgba(0, 0, 0, 0.08), rgba(0, 0, 0, 0.08));++ --checkbox-check: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath d='M2.5 6.2 4.9 8.6 9.5 3.6' fill='none' stroke='white' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");}@media (prefers-color-scheme: dark) {:root {--focus-edge: rgba(64, 140, 255, 0.75);--focus-ring: rgba(64, 140, 255, 0.16);+ --hover-overlay: linear-gradient(rgba(255, 255, 255, 0.1), rgba(255, 255, 255, 0.1));}}@@ -271,6 +280,20 @@ select:focus {outline: none;}+select:not(:disabled) {+ cursor: pointer;+}++/* Like the toolbar's controls, a field deepens a little under the pointer. The states are in :where() so that a field+ drawn by its container, such as a search field with an icon, can keep its own background with a plain :hover. */+input[type="number"]:where(:not(:disabled, :focus)):hover,+input[type="search"]:where(:not(:disabled, :focus)):hover,+input[type="text"]:where(:not(:disabled, :focus)):hover,+input[type="url"]:where(:not(:disabled, :focus)):hover,+select:where(:not(:disabled, :focus-visible)):hover {+ background-color: var(--control-hover);+}+input::placeholder {color: var(--muted);}@@ -291,7 +314,10 @@ input[type="checkbox"]:not([switch]) {background-color: transparent;background-position: center;background-repeat: no-repeat;- background-size: 12px 12px;+ /* The second size is for the hover fill that is laid under the check mark. */+ background-size:+ 12px 12px,+ 100% 100%;outline: none;cursor: pointer;@@ -299,10 +325,18 @@ input[type="checkbox"]:not([switch]) {input[type="checkbox"]:not([switch]):checked {background-color: var(--accent);- background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath d='M2.5 6.2 4.9 8.6 9.5 3.6' fill='none' stroke='white' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");+ background-image: var(--checkbox-check);box-shadow: none;}+input[type="checkbox"]:not([switch]):not(:checked, :disabled):hover {+ background-color: var(--control);+}++input[type="checkbox"]:not([switch]):checked:not(:disabled):hover {+ background-image: var(--checkbox-check), var(--hover-overlay);+}+input[type="checkbox"]:not([switch]):disabled {opacity: 0.5;cursor: default;@@ -346,6 +380,10 @@ input[type="checkbox"][switch]:checked {background-color: var(--accent);}+input[type="checkbox"][switch]:not(:disabled):hover {+ background-image: var(--hover-overlay);+}+input[type="checkbox"][switch]::before {background-color: white;border: 7px solid white;@@ -383,6 +421,11 @@ input[type="checkbox"][switch]:checked::before {pointer-events: none;}+/* A segment's hover fill is fainter than other controls' fills, so it never matches the raised chosen segment. */+.segmented label:not(:has(input:checked)):hover {+ background: var(--hover-faint);+}+.segmented label:has(input:checked) {background: var(--segment);box-shadow: 0 1px 2px rgba(0, 0, 0, 0.12);@@ -414,6 +457,10 @@ input[type="checkbox"][switch]:checked::before {cursor: pointer;}+.tab-option:not(:has(input:checked)):hover {+ background: var(--control);+}+.tab-option:has(input:checked) {background: var(--choice-fill);box-shadow: inset 0 0 0 1.5px var(--choice);@@ -549,6 +596,13 @@ input[type="checkbox"][switch]:checked::before {background: conic-gradient(#ff3b30, #ff9500, #ffcc00, #34c759, #00c7be, #007aff, #af52de, #ff2d55, #ff3b30);}+.color-swatch:not(:has(input:checked, input:focus-visible)):hover {+ box-shadow:+ inset 0 0 0 1px var(--edge),+ 0 0 0 2px var(--page),+ 0 0 0 4px var(--separator);+}+.color-swatch:has(input:checked) {box-shadow:0 0 0 2px var(--page),