Skip to content

Commit d8705c1

Browse files
Group and scope the findbar rules using CSS nesting
The findbar CSS rules predate the general availability of CSS nesting, which makes them more difficult to understand and change safely. The primary issues are that the findbar rules are spread all over the `viewer.css` file, they share blocks with non-findbar elements and the scope of the rules is sometimes bigger than necessary. This refactoring groups all findbar-related CSS rules together, scoped to the top-level `#findbar` element, for improved overview and isolation. Note that this patch only intends to move the existing rules around and not change any behavior yet, but it does lay the foundation for e.g. making the findbar respect the `browser.uidensity` preference in Firefox in follow-up work. Co-authored-by: Calixte Denizet <[email protected]>
1 parent af012c7 commit d8705c1

File tree

1 file changed

+140
-90
lines changed

1 file changed

+140
-90
lines changed

web/viewer.css

+140-90
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,7 @@ body {
333333
font: message-box;
334334
}
335335

336-
:is(.toolbar, .editorParamsToolbar, .findbar, #sidebarContainer)
336+
:is(.toolbar, .editorParamsToolbar, #sidebarContainer)
337337
:is(input, button, select),
338338
.secondaryToolbar :is(input, button, a, select) {
339339
outline: none;
@@ -362,7 +362,6 @@ body {
362362
}
363363

364364
#toolbarContainer,
365-
.findbar,
366365
.secondaryToolbar,
367366
.editorParamsToolbar {
368367
position: relative;
@@ -448,7 +447,6 @@ body {
448447
transition-duration: 0s;
449448
}
450449

451-
.findbar,
452450
.secondaryToolbar,
453451
.editorParamsToolbar {
454452
top: var(--toolbar-height);
@@ -464,64 +462,6 @@ body {
464462
cursor: default;
465463
}
466464

467-
.findbar {
468-
inset-inline-start: 64px;
469-
min-width: 300px;
470-
background-color: var(--toolbar-bg-color);
471-
}
472-
.findbar > div {
473-
height: var(--toolbar-height);
474-
}
475-
.findbar > div#findbarInputContainer {
476-
margin-inline-end: 4px;
477-
}
478-
.findbar.wrapContainers > div,
479-
.findbar.wrapContainers > div#findbarMessageContainer > * {
480-
clear: both;
481-
}
482-
.findbar.wrapContainers > div#findbarMessageContainer {
483-
height: auto;
484-
}
485-
486-
.findbar input[type="checkbox"] {
487-
pointer-events: none;
488-
}
489-
490-
.findbar label {
491-
user-select: none;
492-
}
493-
494-
.findbar label:hover,
495-
.findbar input:focus-visible + label {
496-
color: var(--toggled-btn-color);
497-
background-color: var(--button-hover-color);
498-
}
499-
500-
.findbar .toolbarField[type="checkbox"]:checked + .toolbarLabel {
501-
background-color: var(--toggled-btn-bg-color) !important;
502-
color: var(--toggled-btn-color);
503-
}
504-
505-
#findInput {
506-
width: 200px;
507-
508-
/*#if !MOZCENTRAL*/
509-
&::-webkit-input-placeholder {
510-
color: rgb(191 191 191);
511-
}
512-
/*#endif*/
513-
&::placeholder {
514-
font-style: normal;
515-
}
516-
.loadingInput:has(> &[data-status="pending"])::after {
517-
display: block;
518-
visibility: visible;
519-
}
520-
&[data-status="notFound"] {
521-
background-color: rgb(255 102 102);
522-
}
523-
}
524-
525465
.secondaryToolbar,
526466
.editorParamsToolbar {
527467
padding: 6px 0 10px;
@@ -654,22 +594,6 @@ body {
654594
margin-inline-end: -9px;
655595
}
656596

657-
#findResultsCount {
658-
background-color: rgb(217 217 217);
659-
color: rgb(82 82 82);
660-
text-align: center;
661-
padding: 4px 5px;
662-
margin: 5px;
663-
}
664-
665-
#findMsg[data-status="notFound"] {
666-
font-weight: bold;
667-
}
668-
669-
:is(#findResultsCount, #findMsg):empty {
670-
display: none;
671-
}
672-
673597
#toolbarViewerMiddle {
674598
position: absolute;
675599
left: 50%;
@@ -689,8 +613,7 @@ body {
689613
#toolbarViewerMiddle > *,
690614
#toolbarViewerRight > *,
691615
#toolbarSidebarLeft *,
692-
#toolbarSidebarRight *,
693-
.findbar * {
616+
#toolbarSidebarRight * {
694617
position: relative;
695618
float: var(--inline-start);
696619
}
@@ -895,14 +818,6 @@ body {
895818
transform: scaleX(var(--dir-factor));
896819
}
897820

898-
#findPrevious::before {
899-
mask-image: var(--findbarButton-previous-icon);
900-
}
901-
902-
#findNext::before {
903-
mask-image: var(--findbarButton-next-icon);
904-
}
905-
906821
#previous::before {
907822
mask-image: var(--toolbarButton-pageUp-icon);
908823
}
@@ -1430,6 +1345,144 @@ dialog :link {
14301345
z-index: 50000; /* should be higher than anything else in PDF.js! */
14311346
}
14321347

1348+
#findbar {
1349+
background-color: var(--toolbar-bg-color);
1350+
cursor: default;
1351+
font: message-box;
1352+
font-size: 12px;
1353+
height: auto;
1354+
inset-inline-start: 64px;
1355+
line-height: 14px;
1356+
margin: 4px 2px;
1357+
min-width: 300px;
1358+
padding: 0 4px;
1359+
position: absolute;
1360+
text-align: left;
1361+
top: var(--toolbar-height);
1362+
z-index: 30000;
1363+
1364+
* {
1365+
float: var(--inline-start);
1366+
position: relative;
1367+
}
1368+
1369+
> div {
1370+
height: var(--toolbar-height);
1371+
}
1372+
1373+
button {
1374+
font: message-box;
1375+
outline: none;
1376+
}
1377+
1378+
input {
1379+
font: message-box;
1380+
outline: none;
1381+
1382+
&:focus-visible + label {
1383+
background-color: var(--button-hover-color);
1384+
color: var(--toggled-btn-color);
1385+
}
1386+
1387+
&[type="checkbox"] {
1388+
pointer-events: none;
1389+
1390+
&:checked + .toolbarLabel {
1391+
background-color: var(--toggled-btn-bg-color) !important;
1392+
color: var(--toggled-btn-color);
1393+
}
1394+
}
1395+
}
1396+
1397+
label {
1398+
user-select: none;
1399+
1400+
&:hover {
1401+
background-color: var(--button-hover-color);
1402+
color: var(--toggled-btn-color);
1403+
}
1404+
}
1405+
1406+
#findbarInputContainer {
1407+
margin-inline-end: 4px;
1408+
1409+
#findInput {
1410+
width: 200px;
1411+
1412+
/*#if !MOZCENTRAL*/
1413+
&::-webkit-input-placeholder {
1414+
color: rgb(191 191 191);
1415+
}
1416+
/*#endif*/
1417+
1418+
&::placeholder {
1419+
font-style: normal;
1420+
}
1421+
1422+
.loadingInput:has(> &[data-status="pending"])::after {
1423+
display: block;
1424+
visibility: visible;
1425+
}
1426+
1427+
&[data-status="notFound"] {
1428+
background-color: rgb(255 102 102);
1429+
}
1430+
}
1431+
1432+
#findPrevious::before {
1433+
mask-image: var(--findbarButton-previous-icon);
1434+
}
1435+
1436+
#findNext::before {
1437+
mask-image: var(--findbarButton-next-icon);
1438+
}
1439+
}
1440+
1441+
#findbarMessageContainer {
1442+
#findResultsCount {
1443+
background-color: rgb(217 217 217);
1444+
color: rgb(82 82 82);
1445+
margin: 5px;
1446+
padding: 4px 5px;
1447+
text-align: center;
1448+
1449+
&:empty {
1450+
display: none;
1451+
}
1452+
}
1453+
1454+
#findMsg {
1455+
&[data-status="notFound"] {
1456+
font-weight: bold;
1457+
}
1458+
1459+
&:empty {
1460+
display: none;
1461+
}
1462+
}
1463+
}
1464+
1465+
&.wrapContainers {
1466+
> div {
1467+
clear: both;
1468+
}
1469+
1470+
> #findbarMessageContainer {
1471+
height: auto;
1472+
1473+
> * {
1474+
clear: both;
1475+
}
1476+
}
1477+
}
1478+
1479+
@media all and (max-width: 690px) {
1480+
& {
1481+
inset-inline-start: 34px;
1482+
}
1483+
}
1484+
}
1485+
14331486
@page {
14341487
margin: 0;
14351488
}
@@ -1531,9 +1584,6 @@ dialog :link {
15311584
.toolbarButtonSpacer {
15321585
width: 0;
15331586
}
1534-
.findbar {
1535-
inset-inline-start: 34px;
1536-
}
15371587
}
15381588

15391589
@media all and (max-width: 560px) {

0 commit comments

Comments
 (0)