Skip to content

Commit 481a0cb

Browse files
Merge pull request #20889 from calixteman/debugger_search_btns
(Debugger) Replace checkboxes in the search bar by toggle buttons
2 parents 109f6a9 + c783758 commit 481a0cb

4 files changed

Lines changed: 42 additions & 40 deletions

File tree

web/internal/canvas_context_details_view.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -228,15 +228,15 @@ class CanvasContextDetailsView {
228228

229229
const prevBtn = document.createElement("button");
230230
prevBtn.className = "gfx-state-stack-button";
231-
prevBtn.ariaLabel = "View older saved state";
231+
prevBtn.title = "View older saved state";
232232
prevBtn.textContent = "←";
233233

234234
const pos = document.createElement("span");
235235
pos.className = "gfx-state-stack-pos";
236236

237237
const nextBtn = document.createElement("button");
238238
nextBtn.className = "gfx-state-stack-button";
239-
nextBtn.ariaLabel = "View newer saved state";
239+
nextBtn.title = "View newer saved state";
240240
nextBtn.textContent = "→";
241241

242242
navContainer.append(prevBtn, pos, nextBtn);

web/internal/debugger.html

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -57,12 +57,12 @@ <h1>PDF.js — Debugging tools</h1>
5757
</div>
5858
<div id="canvas-panel">
5959
<div id="canvas-toolbar" role="toolbar" aria-label="Zoom controls">
60-
<button id="zoom-out-button" aria-label="Zoom out"></button>
60+
<button id="zoom-out-button" title="Zoom out"></button>
6161
<span id="zoom-level" aria-live="polite"></span>
62-
<button id="zoom-in-button" aria-label="Zoom in">+</button>
63-
<button id="redraw-button" aria-label="Redraw page">Redraw</button>
64-
<button id="step-button" aria-label="Step one instruction" disabled><u>S</u>tep</button>
65-
<button id="continue-button" aria-label="Continue to next breakpoint" disabled><u>C</u>ontinue</button>
62+
<button id="zoom-in-button" title="Zoom in">+</button>
63+
<button id="redraw-button" title="Redraw page">Redraw</button>
64+
<button id="step-button" title="Step one instruction" disabled><u>S</u>tep</button>
65+
<button id="continue-button" title="Continue to next breakpoint" disabled><u>C</u>ontinue</button>
6666
</div>
6767
<div id="canvas-scroll">
6868
<div id="canvas-wrapper">

web/internal/multiline_view.css

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -145,15 +145,6 @@
145145
white-space: nowrap;
146146
min-width: 4ch;
147147
}
148-
149-
.mlc-check-label {
150-
display: flex;
151-
align-items: center;
152-
gap: 3px;
153-
font-size: 0.85em;
154-
cursor: pointer;
155-
white-space: nowrap;
156-
}
157148
}
158149

159150
.mlc-num-item {

web/internal/multiline_view.js

Lines changed: 35 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -75,9 +75,9 @@ class MultilineView {
7575

7676
#matchInfo;
7777

78-
#ignoreCaseCb;
78+
#ignoreCaseBtn;
7979

80-
#regexCb;
80+
#regexBtn;
8181

8282
/**
8383
* @param {object} opts
@@ -362,32 +362,32 @@ class MultilineView {
362362
const prevButton = (this.#prevButton = document.createElement("button"));
363363
prevButton.className = "mlc-nav-button";
364364
prevButton.textContent = "↑";
365-
prevButton.ariaLabel = "Previous match";
365+
prevButton.title = "Previous match";
366366
prevButton.disabled = true;
367367

368368
const nextButton = (this.#nextButton = document.createElement("button"));
369369
nextButton.className = "mlc-nav-button";
370370
nextButton.textContent = "↓";
371-
nextButton.ariaLabel = "Next match";
371+
nextButton.title = "Next match";
372372
nextButton.disabled = true;
373373

374374
const matchInfo = (this.#matchInfo = document.createElement("span"));
375375
matchInfo.className = "mlc-match-info";
376376

377-
const { label: ignoreCaseLabel, cb: ignoreCaseCb } =
378-
this.#makeCheckboxLabel("Ignore case");
379-
const { label: regexLabel, cb: regexCb } = this.#makeCheckboxLabel("Regex");
380-
this.#ignoreCaseCb = ignoreCaseCb;
381-
this.#regexCb = regexCb;
377+
const ignoreCaseBtn = (this.#ignoreCaseBtn = this.#makeToggleButton(
378+
"Aa",
379+
"Ignore case"
380+
));
381+
const regexBtn = (this.#regexBtn = this.#makeToggleButton(".*", "Regex"));
382382

383383
searchGroup.append(
384384
searchInput,
385385
searchError,
386386
prevButton,
387387
nextButton,
388-
matchInfo,
389-
ignoreCaseLabel,
390-
regexLabel
388+
ignoreCaseBtn,
389+
regexBtn,
390+
matchInfo
391391
);
392392

393393
const gotoInput = document.createElement("input");
@@ -412,8 +412,16 @@ class MultilineView {
412412
});
413413
prevButton.addEventListener("click", () => this.#navigateMatch(-1));
414414
nextButton.addEventListener("click", () => this.#navigateMatch(1));
415-
this.#ignoreCaseCb.addEventListener("change", () => this.#runSearch());
416-
this.#regexCb.addEventListener("change", () => this.#runSearch());
415+
this.#ignoreCaseBtn.addEventListener("click", () => {
416+
this.#ignoreCaseBtn.ariaPressed =
417+
this.#ignoreCaseBtn.ariaPressed === "true" ? "false" : "true";
418+
this.#runSearch();
419+
});
420+
this.#regexBtn.addEventListener("click", () => {
421+
this.#regexBtn.ariaPressed =
422+
this.#regexBtn.ariaPressed === "true" ? "false" : "true";
423+
this.#runSearch();
424+
});
417425

418426
gotoInput.addEventListener("keydown", ({ key }) => {
419427
if (key !== "Enter") {
@@ -432,13 +440,13 @@ class MultilineView {
432440
return bar;
433441
}
434442

435-
#makeCheckboxLabel(text) {
436-
const label = document.createElement("label");
437-
label.className = "mlc-check-label";
438-
const cb = document.createElement("input");
439-
cb.type = "checkbox";
440-
label.append(cb, ` ${text}`);
441-
return { label, cb };
443+
#makeToggleButton(text, title) {
444+
const btn = document.createElement("button");
445+
btn.className = "mlc-nav-button";
446+
btn.textContent = text;
447+
btn.title = title;
448+
btn.ariaPressed = "false";
449+
return btn;
442450
}
443451

444452
#updateMatchInfo() {
@@ -466,9 +474,12 @@ class MultilineView {
466474
}
467475

468476
let test;
469-
if (this.#regexCb.checked) {
477+
if (this.#regexBtn.ariaPressed === "true") {
470478
try {
471-
const re = new RegExp(query, this.#ignoreCaseCb.checked ? "i" : "");
479+
const re = new RegExp(
480+
query,
481+
this.#ignoreCaseBtn.ariaPressed === "true" ? "i" : ""
482+
);
472483
test = str => re.test(str);
473484
this.#searchInput.removeAttribute("aria-invalid");
474485
this.#searchError.textContent = "";
@@ -479,7 +490,7 @@ class MultilineView {
479490
return false;
480491
}
481492
} else {
482-
const ignoreCase = this.#ignoreCaseCb.checked;
493+
const ignoreCase = this.#ignoreCaseBtn.ariaPressed === "true";
483494
const needle = ignoreCase ? query.toLowerCase() : query;
484495
test = str => (ignoreCase ? str.toLowerCase() : str).includes(needle);
485496
}

0 commit comments

Comments
 (0)