lewp_css/domain/selectors/
pseudo_element.rs

1// This file is part of css. It is subject to the license terms in the COPYRIGHT file found in the top-level directory of this distribution and at https://raw.githubusercontent.com/lemonrock/css/master/COPYRIGHT. No part of predicator, including this file, may be copied, modified, propagated, or distributed except according to the terms contained in the COPYRIGHT file.
2// Copyright © 2017 The developers of css. See the COPYRIGHT file in the top-level directory of this distribution and at https://raw.githubusercontent.com/lemonrock/css/master/COPYRIGHT.
3
4use {
5    super::VendorPrefixablePseudoElementName,
6    crate::{
7        domain::{
8            selectors::OurSelectorImpl,
9            VendorPrefix::{self, *},
10        },
11        parsers::OurSelectorParser,
12        CustomParseError,
13    },
14    cssparser::{CowRcStr, ParseError, Parser, ToCss},
15    std::{collections::HashMap, fmt},
16    PseudoElement::*,
17};
18
19//noinspection SpellCheckingInspection
20/// A pseudo-element, both public and private.
21/// Includes browser-specific pseudo-elements and pseudo-elements which, although named differently, map to near equivalency
22#[derive(Debug, Clone, Ord, PartialOrd, Eq, PartialEq, Hash)]
23#[allow(missing_docs)]
24pub enum PseudoElement {
25    after,
26    backdrop(Option<VendorPrefix>),
27    before,
28    cue,
29    file_selector_button,
30    first_letter,
31    first_line,
32    marker,
33    grammar_error,
34    placeholder(Option<VendorPrefix>),
35    selection(Option<VendorPrefix>),
36    spelling_error,
37
38    /// Not standardized but there are near equivalents amongst the various browsers under different names (we use the Mozilla name without the -moz- prefix)
39    progress_bar(Option<VendorPrefix>),
40
41    /// Not standardized but there are near equivalents amongst the various browsers under different names (we use the Mozilla name without the -moz- prefix)
42    range_progress(Option<VendorPrefix>),
43
44    /// Not standardized but there are near equivalents amongst the various browsers under different names (we use the Mozilla name without the -moz- prefix)
45    range_thumb(Option<VendorPrefix>),
46
47    /// Not standardized but there are near equivalents amongst the various browsers under different names (we use the Mozilla name without the -moz- prefix)
48    range_track(Option<VendorPrefix>),
49
50    /// -servo- and -moz- only
51    anonymous_block(Option<VendorPrefix>),
52
53    /// -servo- only
54    details_summary(Option<VendorPrefix>),
55
56    /// -servo- only
57    details_content(Option<VendorPrefix>),
58
59    /// -servo- only
60    text(Option<VendorPrefix>),
61
62    /// -servo- only
63    input_text(Option<VendorPrefix>),
64
65    /// -servo- only
66    table_wrapper(Option<VendorPrefix>),
67
68    /// -servo- only
69    anonymous_table_wrapper(Option<VendorPrefix>),
70
71    /// -servo- only
72    anonymous_table(Option<VendorPrefix>),
73
74    /// -servo- only
75    anonymous_table_row(Option<VendorPrefix>),
76
77    /// -servo- only
78    anonymous_table_cell(Option<VendorPrefix>),
79
80    /// -servo- only
81    inline_block_wrapper(Option<VendorPrefix>),
82
83    /// -servo- only
84    inline_absolute(Option<VendorPrefix>),
85
86    /// -ms- only
87    browse(Option<VendorPrefix>),
88
89    /// -ms- only
90    check(Option<VendorPrefix>),
91
92    /// -ms- only
93    clear(Option<VendorPrefix>),
94
95    /// -ms- only
96    expand(Option<VendorPrefix>),
97
98    /// -ms- only
99    fill_lower(Option<VendorPrefix>),
100
101    /// -ms- only
102    reveal(Option<VendorPrefix>),
103
104    /// -ms- only
105    value(Option<VendorPrefix>),
106
107    /// -moz- only
108    anonymous_positioned_block(Option<VendorPrefix>),
109
110    /// -moz- only
111    canvas(Option<VendorPrefix>),
112
113    /// -moz- only
114    cell_content(Option<VendorPrefix>),
115
116    /// -moz- only
117    focus_inner(Option<VendorPrefix>),
118
119    /// -moz- only
120    focus_outer(Option<VendorPrefix>),
121
122    /// -moz- only
123    inline_table(Option<VendorPrefix>),
124
125    /// -moz- only
126    list_bullet(Option<VendorPrefix>),
127
128    /// -moz- only
129    page(Option<VendorPrefix>),
130
131    /// -moz- only
132    page_sequence(Option<VendorPrefix>),
133
134    /// -moz- only
135    pagebreak(Option<VendorPrefix>),
136
137    /// -moz- only
138    pagecontent(Option<VendorPrefix>),
139
140    /// -moz- only
141    scrolled_canvas(Option<VendorPrefix>),
142
143    /// -moz- only
144    scrolled_content(Option<VendorPrefix>),
145
146    /// -moz- only
147    scrolled_page_sequence(Option<VendorPrefix>),
148
149    /// -moz- only
150    svg_foreign_content(Option<VendorPrefix>),
151
152    /// -moz- only
153    table(Option<VendorPrefix>),
154
155    /// -moz- only
156    table_cell(Option<VendorPrefix>),
157
158    /// -moz- only
159    table_column(Option<VendorPrefix>),
160
161    /// -moz- only
162    table_column_group(Option<VendorPrefix>),
163
164    /// -moz- only
165    table_outer(Option<VendorPrefix>),
166
167    /// -moz- only
168    table_row(Option<VendorPrefix>),
169
170    /// -moz- only
171    table_row_group(Option<VendorPrefix>),
172
173    /// -moz- only
174    viewport(Option<VendorPrefix>),
175
176    /// -moz- only
177    viewport_scroll(Option<VendorPrefix>),
178
179    /// -moz- only
180    xul_anonymous_block(Option<VendorPrefix>),
181
182    // -moz- only (but MDN incorrectly lists them as pseudo-classes)
183    tree_cell_text(Option<VendorPrefix>),
184
185    // -moz- only (but MDN incorrectly lists them as pseudo-classes)
186    tree_row(Option<VendorPrefix>),
187
188    /// -webkit- only
189    file_upload_button(Option<VendorPrefix>),
190
191    /// -webkit- only
192    inner_spin_button(Option<VendorPrefix>),
193
194    /// -webkit- only
195    meter_bar(Option<VendorPrefix>),
196
197    /// -webkit- only
198    meter_even_less_good_value(Option<VendorPrefix>),
199
200    /// -webkit- only
201    meter_inner_element(Option<VendorPrefix>),
202
203    /// -webkit- only
204    meter_optimum_value(Option<VendorPrefix>),
205
206    /// -webkit- only
207    meter_suboptimum_value(Option<VendorPrefix>),
208
209    /// -webkit- only
210    outer_spin_button(Option<VendorPrefix>),
211
212    /// -webkit- only
213    progress_inner_element(Option<VendorPrefix>),
214
215    /// -webkit- only
216    progress_value(Option<VendorPrefix>),
217
218    /// -webkit- only
219    search_cancel_button(Option<VendorPrefix>),
220
221    /// -webkit- only
222    search_results_button(Option<VendorPrefix>),
223
224    /// -webkit- only (not documented on MDN on 7th November 2017)
225    search_decoration(Option<VendorPrefix>),
226
227    /// -webkit- and -moz-
228    color_swatch_wrapper(Option<VendorPrefix>),
229
230    /// -webkit- and -moz-
231    color_swatch(Option<VendorPrefix>),
232
233    /// -webkit- only
234    calendar_picker_indicator(Option<VendorPrefix>),
235
236    /// -webkit- only
237    details_marker(Option<VendorPrefix>),
238}
239
240impl ToCss for self::PseudoElement {
241    //noinspection SpellCheckingInspection
242    fn to_css<W: fmt::Write>(&self, dest: &mut W) -> fmt::Result {
243        #[inline(always)]
244        fn write<W: fmt::Write>(
245            dest: &mut W,
246            classWithColonColon: &str,
247        ) -> fmt::Result {
248            dest.write_str(classWithColonColon)
249        }
250
251        #[inline(always)]
252        fn write_with_vendor_prefix<W: fmt::Write>(
253            dest: &mut W,
254            vendorPrefix: &Option<VendorPrefix>,
255            classWithoutColonColon: &str,
256        ) -> fmt::Result {
257            dest.write_str("::")?;
258            if let &Some(ref vendorPrefix) = vendorPrefix {
259                vendorPrefix.to_css(dest)?;
260            }
261            dest.write_str(classWithoutColonColon)
262        }
263
264        match *self {
265            after => write(dest, "::after"),
266
267            backdrop(ref vendorPrefix) => {
268                write_with_vendor_prefix(dest, vendorPrefix, "backdrop")
269            }
270
271            before => write(dest, "::before"),
272
273            cue => write(dest, "::cue"),
274
275            file_selector_button => write(dest, "::file-selector-button"),
276
277            first_letter => write(dest, "::first-letter"),
278
279            first_line => write(dest, "::first-line"),
280
281            grammar_error => write(dest, "::grammar-error"),
282
283            marker => write(dest, "::marker"),
284
285            placeholder(ref vendorPrefix) => match *vendorPrefix {
286                Some(webkit) => write(dest, "::-webkit-input-placeholder"),
287                Some(ms) => write(dest, "::-ms-input-placeholder"),
288                _ => {
289                    write_with_vendor_prefix(dest, vendorPrefix, "placeholder")
290                }
291            },
292
293            selection(ref vendorPrefix) => {
294                write_with_vendor_prefix(dest, vendorPrefix, "selection")
295            }
296
297            spelling_error => write(dest, "::spelling-error"),
298
299            progress_bar(ref vendorPrefix) => match *vendorPrefix {
300                Some(moz) => write(dest, "::-moz-progress-bar"),
301                Some(webkit) => write(dest, "::-webkit-progress-bar"),
302                Some(ms) => write(dest, "::-ms-fill"),
303                _ => {
304                    write_with_vendor_prefix(dest, vendorPrefix, "progress-bar")
305                } // almost certainly wrong
306            },
307
308            range_progress(ref vendorPrefix) => match *vendorPrefix {
309                Some(moz) => write(dest, "::-moz-range-progress"),
310                Some(ms) => write(dest, "::-ms-fill-upper"),
311                _ => write_with_vendor_prefix(
312                    dest,
313                    vendorPrefix,
314                    "range-progress",
315                ), // almost certainly wrong
316            },
317
318            range_thumb(ref vendorPrefix) => match *vendorPrefix {
319                Some(moz) => write(dest, "::-moz-range-thumb"),
320                Some(webkit) => write(dest, "::-webkit-slider-thumb"),
321                Some(ms) => write(dest, "::-ms-thumb"),
322                _ => {
323                    write_with_vendor_prefix(dest, vendorPrefix, "range-thumb")
324                } // almost certainly wrong
325            },
326
327            range_track(ref vendorPrefix) => match *vendorPrefix {
328                Some(moz) => write(dest, "::-moz-range-track"),
329                Some(webkit) => write(dest, "::-webkit-slider-runnable-track"),
330                Some(ms) => write(dest, "::-ms-track"),
331                _ => {
332                    write_with_vendor_prefix(dest, vendorPrefix, "range-track")
333                } // almost certainly wrong
334            },
335
336            details_summary(ref vendorPrefix) => {
337                write_with_vendor_prefix(dest, vendorPrefix, "details-summary")
338            }
339
340            details_content(ref vendorPrefix) => {
341                write_with_vendor_prefix(dest, vendorPrefix, "details-content")
342            }
343
344            text(ref vendorPrefix) => {
345                write_with_vendor_prefix(dest, vendorPrefix, "text")
346            }
347
348            input_text(ref vendorPrefix) => {
349                write_with_vendor_prefix(dest, vendorPrefix, "input-text")
350            }
351
352            table_wrapper(ref vendorPrefix) => {
353                write_with_vendor_prefix(dest, vendorPrefix, "table-wrapper")
354            }
355
356            anonymous_table_wrapper(ref vendorPrefix) => {
357                write_with_vendor_prefix(
358                    dest,
359                    vendorPrefix,
360                    "anonymous-table-wrapper",
361                )
362            }
363
364            anonymous_table(ref vendorPrefix) => {
365                write_with_vendor_prefix(dest, vendorPrefix, "anonymous-table")
366            }
367
368            anonymous_table_row(ref vendorPrefix) => write_with_vendor_prefix(
369                dest,
370                vendorPrefix,
371                "anonymous-table-row",
372            ),
373
374            anonymous_table_cell(ref vendorPrefix) => write_with_vendor_prefix(
375                dest,
376                vendorPrefix,
377                "anonymous-table-cell",
378            ),
379
380            anonymous_block(ref vendorPrefix) => {
381                write_with_vendor_prefix(dest, vendorPrefix, "anonymous-block")
382            }
383
384            inline_block_wrapper(ref vendorPrefix) => write_with_vendor_prefix(
385                dest,
386                vendorPrefix,
387                "inline-block-wrapper",
388            ),
389
390            inline_absolute(ref vendorPrefix) => {
391                write_with_vendor_prefix(dest, vendorPrefix, "inline-absolute")
392            }
393
394            browse(ref vendorPrefix) => {
395                write_with_vendor_prefix(dest, vendorPrefix, "browse")
396            }
397
398            check(ref vendorPrefix) => {
399                write_with_vendor_prefix(dest, vendorPrefix, "check")
400            }
401
402            clear(ref vendorPrefix) => {
403                write_with_vendor_prefix(dest, vendorPrefix, "clear")
404            }
405
406            expand(ref vendorPrefix) => {
407                write_with_vendor_prefix(dest, vendorPrefix, "expand")
408            }
409
410            fill_lower(ref vendorPrefix) => {
411                write_with_vendor_prefix(dest, vendorPrefix, "fill-lower")
412            }
413
414            reveal(ref vendorPrefix) => {
415                write_with_vendor_prefix(dest, vendorPrefix, "reveal")
416            }
417
418            value(ref vendorPrefix) => {
419                write_with_vendor_prefix(dest, vendorPrefix, "value")
420            }
421
422            anonymous_positioned_block(ref vendorPrefix) => {
423                write_with_vendor_prefix(
424                    dest,
425                    vendorPrefix,
426                    "anonymous-positioned-block",
427                )
428            }
429
430            canvas(ref vendorPrefix) => {
431                write_with_vendor_prefix(dest, vendorPrefix, "canvas")
432            }
433
434            cell_content(ref vendorPrefix) => {
435                write_with_vendor_prefix(dest, vendorPrefix, "cell-content")
436            }
437
438            focus_inner(ref vendorPrefix) => {
439                write_with_vendor_prefix(dest, vendorPrefix, "focus-inner")
440            }
441
442            focus_outer(ref vendorPrefix) => {
443                write_with_vendor_prefix(dest, vendorPrefix, "focus-outer")
444            }
445
446            inline_table(ref vendorPrefix) => {
447                write_with_vendor_prefix(dest, vendorPrefix, "inline-table")
448            }
449
450            list_bullet(ref vendorPrefix) => {
451                write_with_vendor_prefix(dest, vendorPrefix, "list-bullet")
452            }
453
454            page(ref vendorPrefix) => {
455                write_with_vendor_prefix(dest, vendorPrefix, "page")
456            }
457
458            page_sequence(ref vendorPrefix) => {
459                write_with_vendor_prefix(dest, vendorPrefix, "page-sequence")
460            }
461
462            pagebreak(ref vendorPrefix) => {
463                write_with_vendor_prefix(dest, vendorPrefix, "pagebreak")
464            }
465
466            pagecontent(ref vendorPrefix) => {
467                write_with_vendor_prefix(dest, vendorPrefix, "pagecontent")
468            }
469
470            scrolled_canvas(ref vendorPrefix) => {
471                write_with_vendor_prefix(dest, vendorPrefix, "scrolled-canvas")
472            }
473
474            scrolled_content(ref vendorPrefix) => {
475                write_with_vendor_prefix(dest, vendorPrefix, "scrolled-content")
476            }
477
478            scrolled_page_sequence(ref vendorPrefix) => {
479                write_with_vendor_prefix(
480                    dest,
481                    vendorPrefix,
482                    "scrolled-page-sequence",
483                )
484            }
485
486            svg_foreign_content(ref vendorPrefix) => write_with_vendor_prefix(
487                dest,
488                vendorPrefix,
489                "svg-foreign-content",
490            ),
491
492            table(ref vendorPrefix) => {
493                write_with_vendor_prefix(dest, vendorPrefix, "table")
494            }
495
496            table_cell(ref vendorPrefix) => {
497                write_with_vendor_prefix(dest, vendorPrefix, "table-cell")
498            }
499
500            table_column(ref vendorPrefix) => {
501                write_with_vendor_prefix(dest, vendorPrefix, "table-column")
502            }
503
504            table_column_group(ref vendorPrefix) => write_with_vendor_prefix(
505                dest,
506                vendorPrefix,
507                "table-column-group",
508            ),
509
510            table_outer(ref vendorPrefix) => {
511                write_with_vendor_prefix(dest, vendorPrefix, "table-outer")
512            }
513
514            table_row(ref vendorPrefix) => {
515                write_with_vendor_prefix(dest, vendorPrefix, "table-row")
516            }
517
518            table_row_group(ref vendorPrefix) => {
519                write_with_vendor_prefix(dest, vendorPrefix, "table-row-group")
520            }
521
522            viewport(ref vendorPrefix) => {
523                write_with_vendor_prefix(dest, vendorPrefix, "viewport")
524            }
525
526            viewport_scroll(ref vendorPrefix) => {
527                write_with_vendor_prefix(dest, vendorPrefix, "viewport-scroll")
528            }
529
530            xul_anonymous_block(ref vendorPrefix) => write_with_vendor_prefix(
531                dest,
532                vendorPrefix,
533                "xul-anonymous-block",
534            ),
535
536            tree_cell_text(ref vendorPrefix) => {
537                write_with_vendor_prefix(dest, vendorPrefix, "tree-cell-text")
538            }
539
540            tree_row(ref vendorPrefix) => {
541                write_with_vendor_prefix(dest, vendorPrefix, "tree-row")
542            }
543
544            file_upload_button(ref vendorPrefix) => write_with_vendor_prefix(
545                dest,
546                vendorPrefix,
547                "file-upload-button",
548            ),
549
550            inner_spin_button(ref vendorPrefix) => write_with_vendor_prefix(
551                dest,
552                vendorPrefix,
553                "inner-spin-button",
554            ),
555
556            meter_bar(ref vendorPrefix) => {
557                write_with_vendor_prefix(dest, vendorPrefix, "meter-bar")
558            }
559
560            meter_even_less_good_value(ref vendorPrefix) => {
561                write_with_vendor_prefix(
562                    dest,
563                    vendorPrefix,
564                    "meter-even-less-good-value",
565                )
566            }
567
568            meter_inner_element(ref vendorPrefix) => write_with_vendor_prefix(
569                dest,
570                vendorPrefix,
571                "meter-inner-element",
572            ),
573
574            meter_optimum_value(ref vendorPrefix) => write_with_vendor_prefix(
575                dest,
576                vendorPrefix,
577                "meter-optimum-value",
578            ),
579
580            meter_suboptimum_value(ref vendorPrefix) => {
581                write_with_vendor_prefix(
582                    dest,
583                    vendorPrefix,
584                    "meter-suboptimum-value",
585                )
586            }
587
588            outer_spin_button(ref vendorPrefix) => write_with_vendor_prefix(
589                dest,
590                vendorPrefix,
591                "outer-spin-button",
592            ),
593
594            progress_inner_element(ref vendorPrefix) => {
595                write_with_vendor_prefix(
596                    dest,
597                    vendorPrefix,
598                    "progress-inner-element",
599                )
600            }
601
602            progress_value(ref vendorPrefix) => {
603                write_with_vendor_prefix(dest, vendorPrefix, "progress-value")
604            }
605
606            search_cancel_button(ref vendorPrefix) => write_with_vendor_prefix(
607                dest,
608                vendorPrefix,
609                "search-cancel-button",
610            ),
611
612            search_results_button(ref vendorPrefix) => {
613                write_with_vendor_prefix(
614                    dest,
615                    vendorPrefix,
616                    "search-results-button",
617                )
618            }
619
620            search_decoration(ref vendorPrefix) => write_with_vendor_prefix(
621                dest,
622                vendorPrefix,
623                "search-decoration",
624            ),
625
626            color_swatch_wrapper(ref vendorPrefix) => write_with_vendor_prefix(
627                dest,
628                vendorPrefix,
629                "color-swatch-wrapper",
630            ),
631
632            color_swatch(ref vendorPrefix) => {
633                write_with_vendor_prefix(dest, vendorPrefix, "color-swatch")
634            }
635            calendar_picker_indicator(ref vendorPrefix) => {
636                write_with_vendor_prefix(
637                    dest,
638                    vendorPrefix,
639                    "calendar-picker-indicator",
640                )
641            }
642            details_marker(ref vendorPrefix) => {
643                write_with_vendor_prefix(dest, vendorPrefix, "details-marker")
644            }
645        }
646    }
647}
648
649impl selectors::parser::PseudoElement for PseudoElement {
650    type Impl = OurSelectorImpl;
651}
652
653impl PseudoElement {
654    /// Whether this pseudo-element supports user action selectors.
655    pub fn supports_user_action_state(&self) -> bool {
656        match *self {
657            after => false,
658            before => false,
659            backdrop(..) => false,
660            cue => false,
661            file_selector_button => false,
662            first_letter => false,
663            first_line => false,
664            progress_bar(..) => true,
665            range_track(..) => true,
666            range_progress(..) => true,
667            range_thumb(..) => true,
668            placeholder(..) => true,
669            _ => false,
670        }
671    }
672
673    #[inline(always)]
674    fn applyVendorPrefix(
675        pseudoElementName: VendorPrefixablePseudoElementName,
676        applyVendorPrefixToPseudoElements: &HashMap<
677            VendorPrefixablePseudoElementName,
678            VendorPrefix,
679        >,
680    ) -> Option<VendorPrefix> {
681        applyVendorPrefixToPseudoElements
682            .get(&pseudoElementName)
683            .cloned()
684    }
685
686    //noinspection SpellCheckingInspection
687    #[inline(always)]
688    pub(crate) fn parse_without_arguments<'i>(
689        applyVendorPrefixToPseudoElements: &HashMap<
690            VendorPrefixablePseudoElementName,
691            VendorPrefix,
692        >,
693        name: CowRcStr<'i>,
694    ) -> Result<Self, ParseError<'i, CustomParseError<'i>>> {
695        match_ignore_ascii_case! {
696            &name,
697
698            "after" => Ok(after),
699
700            "backdrop" => Ok(backdrop(Self::applyVendorPrefix(VendorPrefixablePseudoElementName::backdrop, applyVendorPrefixToPseudoElements))),
701
702            "-ms-backdrop" => Ok(backdrop(Some(ms))),
703
704            "-webkit-backdrop" => Ok(backdrop(Some(webkit))),
705
706            "before" => Ok(before),
707
708            "cue" => Ok(cue),
709
710            "file-selector-button" => Ok(file_selector_button),
711
712            "first-letter" => Ok(first_letter),
713
714            "first-line" => Ok(first_line),
715
716            "grammar-error" => Ok(grammar_error),
717
718            "marker" => Ok(marker),
719
720            "placeholder" => Ok(placeholder(Self::applyVendorPrefix(VendorPrefixablePseudoElementName::placeholder, applyVendorPrefixToPseudoElements))),
721
722            "-ms-placeholder" => Ok(placeholder(Some(ms))),
723
724            "-webkit-input-placeholder" => Ok(placeholder(Some(ms))),
725
726            "selection" => Ok(selection(Self::applyVendorPrefix(VendorPrefixablePseudoElementName::selection, applyVendorPrefixToPseudoElements))),
727
728            "-moz-selection" => Ok(selection(Some(moz))),
729
730            "spelling-error" => Ok(spelling_error),
731
732
733            // Nearly the same
734
735            "progress-bar" => Ok(progress_bar(Self::applyVendorPrefix(VendorPrefixablePseudoElementName::progress_bar, applyVendorPrefixToPseudoElements))),
736
737            "-moz-progress-bar" => Ok(progress_bar(Some(moz))),
738
739            "-webkit-progress-bar" => Ok(progress_bar(Some(webkit))),
740
741            "-ms-fill" => Ok(progress_bar(Some(ms))),
742
743
744            // Nearly the same
745
746            "range-progress" => Ok(range_progress(Self::applyVendorPrefix(VendorPrefixablePseudoElementName::range_progress, applyVendorPrefixToPseudoElements))),
747
748            "-moz-range-progress" => Ok(range_progress(Some(moz))),
749
750            "-ms-fill-upper" => Ok(range_progress(Some(ms))),
751
752
753            // Nearly the same
754
755            "range-thumb" => Ok(range_thumb(Self::applyVendorPrefix(VendorPrefixablePseudoElementName::range_thumb, applyVendorPrefixToPseudoElements))),
756
757            "-moz-range-thumb" => Ok(range_thumb(Some(moz))),
758
759            "-webkit-slider-thumb" => Ok(range_thumb(Some(webkit))),
760
761            "-ms-thumb" => Ok(range_thumb(Some(ms))),
762
763
764            // Nearly the same
765
766            "range-track" => Ok(range_track(Self::applyVendorPrefix(VendorPrefixablePseudoElementName::range_track, applyVendorPrefixToPseudoElements))),
767
768            "-moz-range-track" => Ok(range_track(Some(moz))),
769
770            "-webkit-slider-runnable-track" => Ok(range_track(Some(webkit))),
771
772            "-ms-track" => Ok(range_track(Some(ms))),
773
774
775            // -servo- and -moz- only
776
777            "-servo-anonymous-block" => Ok(anonymous_block(Some(servo))),
778
779            "-moz-anonymous-block" => Ok(anonymous_block(Some(moz))),
780
781
782            // -servo- only
783
784            "-servo-details-summary" => Ok(details_summary(Some(servo))),
785
786            "-servo-details-content" => Ok(details_content(Some(servo))),
787
788            "-servo-text" => Ok(text(Some(servo))),
789
790            "-servo-input-text" => Ok(input_text(Some(servo))),
791
792            "-servo-table-wrapper" => Ok(table_wrapper(Some(servo))),
793
794            "-servo-anonymous-table-wrapper" => Ok(anonymous_table_wrapper(Some(servo))),
795
796            "-servo-anonymous-table" => Ok(anonymous_table(Some(servo))),
797
798            "-servo-anonymous-table-row" => Ok(anonymous_table_row(Some(servo))),
799
800            "-servo-anonymous-table-cell" => Ok(anonymous_table_cell(Some(servo))),
801
802            "-servo-inline-block-wrapper" => Ok(inline_block_wrapper(Some(servo))),
803
804            "-servo-inline-absolute" => Ok(inline_absolute(Some(servo))),
805
806
807            // -ms- only
808
809            "-ms-browse" => Ok(browse(Some(ms))),
810
811            "-ms-check" => Ok(check(Some(ms))),
812
813            "-ms-clear" => Ok(clear(Some(ms))),
814
815            "-ms-expand" => Ok(expand(Some(ms))),
816
817            "-ms-fill-lower" => Ok(fill_lower(Some(ms))),
818
819            "-ms-reveal" => Ok(reveal(Some(ms))),
820
821            "-ms-value" => Ok(value(Some(ms))),
822
823
824            // -moz- only
825
826            "-moz-anonymous-positioned-block" => Ok(anonymous_positioned_block(Some(moz))),
827
828            "-moz-canvas" => Ok(canvas(Some(moz))),
829
830            "-moz-cell-content" => Ok(cell_content(Some(moz))),
831
832            "-moz-focus-inner" => Ok(focus_inner(Some(moz))),
833
834            "-moz-focus-outer" => Ok(focus_outer(Some(moz))),
835
836            "-moz-inline-table" => Ok(inline_table(Some(moz))),
837
838            "-moz-list-bullet" => Ok(list_bullet(Some(moz))),
839
840            "-moz-page" => Ok(page(Some(moz))),
841
842            "-moz-page-sequence" => Ok(page_sequence(Some(moz))),
843
844            "-moz-pagebreak" => Ok(pagebreak(Some(moz))),
845
846            "-moz-pagecontent" => Ok(pagecontent(Some(moz))),
847
848            "-moz-scrolled-canvas" => Ok(scrolled_canvas(Some(moz))),
849
850            "-moz-scrolled-content" => Ok(scrolled_content(Some(moz))),
851
852            "-moz-scrolled-page-sequence" => Ok(scrolled_page_sequence(Some(moz))),
853
854            "-moz-svg-foreign-content" => Ok(svg_foreign_content(Some(moz))),
855
856            "-moz-table" => Ok(table(Some(moz))),
857
858            "-moz-table-cell" => Ok(table_cell(Some(moz))),
859
860            "-moz-table-column" => Ok(table_column(Some(moz))),
861
862            "-moz-table-column-group" => Ok(table_column_group(Some(moz))),
863
864            "-moz-table-outer" => Ok(table_outer(Some(moz))),
865
866            "-moz-table-row" => Ok(table_row(Some(moz))),
867
868            "-moz-table-row-group" => Ok(table_row_group(Some(moz))),
869
870            "-moz-viewport" => Ok(viewport(Some(moz))),
871
872            "-moz-viewport-scroll" => Ok(viewport_scroll(Some(moz))),
873
874            "-moz-xul-anonymous-block" => Ok(xul_anonymous_block(Some(moz))),
875
876
877            // -moz- only (but MDN incorrectly lists them as pseudo-classes)
878
879            "-moz-tree-cell-text" => Ok(tree_cell_text(Some(moz))),
880
881            "-moz-tree-row" => Ok(tree_row(Some(moz))),
882
883            "-moz-color-swatch" => Ok(color_swatch(Some(moz))),
884
885
886            // -webkit- only
887
888            "-webkit-calendar-picker-indicator" => Ok(calendar_picker_indicator(Some(webkit))),
889
890            "-webkit-color-swatch-wrapper" => Ok(color_swatch_wrapper(Some(webkit))),
891
892            "-webkit-color-swatch" => Ok(color_swatch(Some(webkit))),
893
894            "-webkit-details-marker" => Ok(details_marker(Some(webkit))),
895
896            "-webkit-file-upload-button" => Ok(file_upload_button(Some(webkit))),
897
898            "-webkit-inner-spin-button" => Ok(inner_spin_button(Some(webkit))),
899
900            "-webkit-meter-bar" => Ok(meter_bar(Some(webkit))),
901
902            "-webkit-meter-even-less-good-value" => Ok(meter_even_less_good_value(Some(webkit))),
903
904            "-webkit-meter-inner-element" => Ok(meter_inner_element(Some(webkit))),
905
906            "-webkit-meter-optimum-value" => Ok(meter_optimum_value(Some(webkit))),
907
908            "-webkit-meter-suboptimum-value" => Ok(meter_suboptimum_value(Some(webkit))),
909
910            "-webkit-outer-spin-button" => Ok(outer_spin_button(Some(webkit))),
911
912            "-webkit-progress-inner-element" => Ok(progress_inner_element(Some(webkit))),
913
914            "-webkit-progress-value" => Ok(progress_value(Some(webkit))),
915
916            "-webkit-search-cancel-button" => Ok(search_cancel_button(Some(webkit))),
917
918            "-webkit-search-results-button" => Ok(search_results_button(Some(webkit))),
919
920            "-webkit-search-decoration" => Ok(search_decoration(Some(webkit))),
921
922
923            _ => Err(ParseError::from(CustomParseError::UnsupportedPseudoClassOrElement(name.to_string()))),
924        }
925    }
926
927    #[inline(always)]
928    pub(crate) fn parse_with_arguments<'i, 't>(
929        _applyVendorPrefixToPseudoElements: &HashMap<
930            VendorPrefixablePseudoElementName,
931            VendorPrefix,
932        >,
933        name: CowRcStr<'i>,
934        _arguments: &mut Parser<'i, 't>,
935        _ourSelectorParser: &OurSelectorParser,
936    ) -> Result<Self, ParseError<'i, CustomParseError<'i>>> {
937        Err(ParseError::from(
938            CustomParseError::UnsupportedPseudoClassOrElement(name.to_string()),
939        ))
940    }
941}