Skip to content

Truly independent web browser

LibWebView: Move the content blocking descriptions inside their label

Timothy Flynn2831cfc1e6bc
diff --git a/Base/res/ladybird/about-pages/settings.html b/Base/res/ladybird/about-pages/settings.html
index 7fa8b8b2cd6..e73e6817b44 100644
--- a/Base/res/ladybird/about-pages/settings.html
+++ b/Base/res/ladybird/about-pages/settings.html
@@ -648,16 +648,20 @@
<div class="tab-panel" id="tab-blocking">
<div class="card card-body">
<div class="inline-container">
- <label for="enable-content-blocking">Enable ad blocking</label>
+ <label for="enable-content-blocking">
+ Enable ad blocking
+ <p class="description">Use filter lists to block ads, trackers, and other unwanted content.</p>
+ </label>
<input id="enable-content-blocking" type="checkbox" switch />
</div>
- <p class="description">Use filter lists to block ads, trackers, and other unwanted content.</p>
</div>
<template id="filter-list-row">
<div class="card-group inline-container filter-list-row">
<div>
- <label></label>
- <p class="description"></p>
+ <label>
+ <span class="label"></span>
+ <p class="description"></p>
+ </label>
<p class="description filter-list-metadata"></p>
</div>
<div class="input-field-container">
diff --git a/Base/res/ladybird/about-pages/settings/blocking.js b/Base/res/ladybird/about-pages/settings/blocking.js
index c0f93c065d5..69bd05cdfed 100644
--- a/Base/res/ladybird/about-pages/settings/blocking.js
+++ b/Base/res/ladybird/about-pages/settings/blocking.js
@@ -26,24 +26,33 @@ function listStatus(list) {
function createListRow(list, removable = false) {
const row = document.querySelector("#filter-list-row").content.firstElementChild.cloneNode(true);
- const label = row.querySelector("label");
const toggle = row.querySelector("input");
+ const label = row.querySelector("label");
+ const labelText = row.querySelector(".label");
const details = row.querySelector(".description");
const metadata = row.querySelector(".filter-list-metadata");
+
+ const id = `content-blocker-list-${list.identifier}`;
const name = list.name ?? list.url;
- label.textContent = name;
- label.htmlFor = toggle.id = `content-blocker-list-${list.identifier}`;
+
+ toggle.id = id;
+ label.htmlFor = id;
+ labelText.textContent = name;
+
details.id = `${toggle.id}-description`;
details.textContent = list.description ?? "";
+
metadata.id = `${toggle.id}-metadata`;
metadata.textContent = [list.url ? new URL(list.url).host : "Local file", list.url && listStatus(list)]
.filter(Boolean)
.join(" · ");
+
toggle.setAttribute("aria-describedby", `${details.id} ${metadata.id}`);
toggle.checked = list.enabled;
toggle.addEventListener("change", () => {
ladybird.sendMessage("setContentBlockerListEnabled", { identifier: list.identifier, enabled: toggle.checked });
});
+
const remove = row.querySelector("button");
if (removable) {
remove.setAttribute("aria-label", `Remove ${name}`);
@@ -51,6 +60,7 @@ function createListRow(list, removable = false) {
} else {
remove.remove();
}
+
return row;
}