css 0.0.22

A crate that uses the cssparser and selectors crates to provide a domain model for CSS Stylesheets. Intended to allow effective minification of CSS and CSS transformations such as autoprefixing and removal by other crates
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
// 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.
// 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.


//noinspection SpellCheckingInspection
/// A non tree-structural pseudo-class.
/// See https://drafts.csswg.org/selectors-4/#structural-pseudos
#[derive(Clone, Debug, Eq, PartialEq)]
#[allow(missing_docs)]
pub enum NonTreeStructuralPseudoClass
{
	active,
	any(Option<VendorPrefix>, DeduplicatedSelectors),
	any_link(Option<VendorPrefix>),
	checked,
	default,
	dir(Option<VendorPrefix>, TextDirectionality),
	disabled,
	enabled,
	/// Only valid in @page
	first,
	focus,
	focus_within,
	in_range,
	invalid,
	fullscreen(Option<VendorPrefix>),
	hover,
	indeterminate,
	lang(LanguageRanges),
	/// Only valid in @page
	left,
	link,
	optional,
	out_of_range,
	/// The obsolete (as of Firefox 51) `:-moz-placeholder` is re-written when parsed as this.
	placeholder_shown(Option<VendorPrefix>),
	read_only(Option<VendorPrefix>),
	read_write(Option<VendorPrefix>),
	required,
	/// Only valid in @page
	right,
	target,
	valid,
	visited,
	
	/// -servo- only
	case_sensitive_type_attr(Option<VendorPrefix>, Atom),
	
	/// -servo- only
	non_zero_border(Option<VendorPrefix>),

	/// -moz- only
	broken(Option<VendorPrefix>),
	
	/// -moz- only
	drag_over(Option<VendorPrefix>),
	
	/// -moz- only
	first_node(Option<VendorPrefix>),
	
	/// -moz- only
	focusring(Option<VendorPrefix>),
	
	/// -moz- only
	full_screen_ancestor(Option<VendorPrefix>),
	
	/// -moz- only
	handler_blocked(Option<VendorPrefix>),
	
	/// -moz- only
	handler_crashed(Option<VendorPrefix>),
	
	/// -moz- only
	handler_disabled(Option<VendorPrefix>),
	
	/// -moz- only
	last_node(Option<VendorPrefix>),
	
	/// -moz- only
	list_bullet(Option<VendorPrefix>),
	
	/// -moz- only
	list_number(Option<VendorPrefix>),
	
	/// -moz- only
	loading(Option<VendorPrefix>),
	
	//  -moz- only
	locale_dir(Option<VendorPrefix>, TextDirectionality),
	
	/// -moz- only
	lwtheme(Option<VendorPrefix>),
	
	/// -moz- only
	lwtheme_brighttext(Option<VendorPrefix>),
	
	/// -moz- only
	lwtheme_darktext(Option<VendorPrefix>),
	
	/// -moz- only
	native_anonymous(Option<VendorPrefix>),
	
	/// -moz- only
	only_whitespace(Option<VendorPrefix>),
	
	/// -moz- only
	submit_invalid(Option<VendorPrefix>),
	
	/// -moz- only
	suppressed(Option<VendorPrefix>),
	
	/// -moz- only (not listed with other pseudo-classes)
	system_metric(Option<VendorPrefix>, SystemMetric),
	
	/// -moz- only
	tree_cell(Option<VendorPrefix>),
	
	/// -moz- only.
	// A psuedo-class function with one value, hover
	tree_cell_text(Option<VendorPrefix>, TreeHover),
	
	/// -moz- only
	tree_checkbox(Option<VendorPrefix>),
	
	/// -moz- only
	tree_column(Option<VendorPrefix>),
	
	/// -moz- only
	tree_drop_feedback(Option<VendorPrefix>),
	
	/// -moz- only
	tree_image(Option<VendorPrefix>),
	
	/// -moz- only
	tree_indentation(Option<VendorPrefix>),
	
	/// -moz- only
	tree_line(Option<VendorPrefix>),
	
	/// -moz- only
	tree_progressmeter(Option<VendorPrefix>),
	
	/// -moz- only.
	// A psuedo-class function with one value, hover
	tree_row(Option<VendorPrefix>, TreeHover),
	
	/// -moz- only
	tree_separator(Option<VendorPrefix>),
	
	/// -moz- only
	tree_twisty(Option<VendorPrefix>),
	
	/// -moz- only
	ui_invalid(Option<VendorPrefix>),
	
	/// -moz- only
	ui_valid(Option<VendorPrefix>),
	
	/// -moz- only
	user_disabled(Option<VendorPrefix>),
	
	/// -moz- only
	window_inactive(Option<VendorPrefix>),
	
	/// -webkit- only, with potential Mozilla support coming.
	autofill(Option<VendorPrefix>),
}

impl ToCss for NonTreeStructuralPseudoClass
{
	//noinspection SpellCheckingInspection
	fn to_css<W: fmt::Write>(&self, dest: &mut W) -> fmt::Result
	{
		#[inline(always)]
		fn write<W: fmt::Write>(dest: &mut W, classWithColon: &str) -> fmt::Result
		{
			dest.write_str(classWithColon)
		}
		
		#[inline(always)]
		fn write_with_vendor_prefix<W: fmt::Write>(dest: &mut W, vendorPrefix: &Option<VendorPrefix>, classWithoutColon: &str) -> fmt::Result
		{
			dest.write_char(':')?;
			if let &Some(ref vendorPrefix) = vendorPrefix
			{
				vendorPrefix.to_css(dest)?;
			}
			dest.write_str(classWithoutColon)
		}
		
		#[inline(always)]
		fn write_with_vendor_prefix_value<W: fmt::Write, T: ToCss>(dest: &mut W, vendorPrefix: &Option<VendorPrefix>, classWithoutColon: &str, value: &T) -> fmt::Result
		{
			dest.write_char(':')?;
			if let &Some(ref vendorPrefix) = vendorPrefix
			{
				vendorPrefix.to_css(dest)?;
			}
			dest.write_str(classWithoutColon)?;
			dest.write_char('(')?;
			value.to_css(dest)?;
			dest.write_char(')')
		}
		
		use self::NonTreeStructuralPseudoClass::*;
		use self::VendorPrefix::*;
		
		match *self
		{
			active => write(dest, ":active"),
			
			any(ref vendorPrefix, ref value) => write_with_vendor_prefix_value(dest, vendorPrefix, "any", value),
			
			any_link(ref vendorPrefix) => write_with_vendor_prefix(dest, vendorPrefix, "any-link"),
			
			checked => write(dest, ":checked"),
			
			default => write(dest, ":default"),
			
			disabled => write(dest, ":disabled"),
			
			dir(ref vendorPrefix, ref value) => write_with_vendor_prefix_value(dest, vendorPrefix, "dir", value),
			
			enabled => write(dest, ":enabled"),
			
			first => write(dest, ":first"),
			
			focus => write(dest, ":focus"),
			
			focus_within => write(dest, ":focus-within"),
			
			fullscreen(ref vendorPrefix) =>
			{
				dest.write_char(':')?;
				let name = if let &Some(ref vendorPrefix) = vendorPrefix
				{
					vendorPrefix.to_css(dest)?;
					
					match *vendorPrefix
					{
						moz => "full-screen",
						webkit => "full-screen",
						_ => "fullscreen",
					}
				}
				else
				{
					"fullscreen"
				};
				dest.write_str(name)
			}
			
			hover => write(dest, ":hover"),
			
			indeterminate => write(dest, ":indeterminate"),
			
			in_range => write(dest, ":in-range"),
			
			invalid => write(dest, ":invalid"),
			
			lang(ref languages) =>
			{
				dest.write_str(":lang(")?;
				languages.to_css(dest)?;
				dest.write_char(')')
			}
			
			left => write(dest, ":left"),
			
			link => write(dest, ":link"),
			
			optional => write(dest, ":optional"),
			
			out_of_range => write(dest, ":out-of-range"),
			
			placeholder_shown(ref vendorPrefix) => write_with_vendor_prefix(dest, vendorPrefix, "placeholder-shown"),
			
			read_only(ref vendorPrefix) => write_with_vendor_prefix(dest, vendorPrefix, "read-only"),
			
			read_write(ref vendorPrefix) => write_with_vendor_prefix(dest, vendorPrefix, "read-write"),
			
			required => write(dest, ":required"),
			
			right => write(dest, ":right"),
			
			target => write(dest, ":target"),
			
			valid => write(dest, ":valid"),
			
			visited => write(dest, ":visited"),
			
			
			// -servo- only
			
			case_sensitive_type_attr(ref vendorPrefix, ref value) => write_with_vendor_prefix_value(dest, vendorPrefix, "case-sensitive-type-attr", value),
			
			non_zero_border(ref vendorPrefix) => write_with_vendor_prefix(dest, vendorPrefix, "non-zero-border"),
			
			
			// -moz- only
			
			broken(ref vendorPrefix) => write_with_vendor_prefix(dest, vendorPrefix, "broken"),
			
			drag_over(ref vendorPrefix) => write_with_vendor_prefix(dest, vendorPrefix, "drag-over"),
			
			first_node(ref vendorPrefix) => write_with_vendor_prefix(dest, vendorPrefix, "first-node"),
			
			focusring(ref vendorPrefix) => write_with_vendor_prefix(dest, vendorPrefix, "focusring"),
			
			full_screen_ancestor(ref vendorPrefix) => write_with_vendor_prefix(dest, vendorPrefix, "full-screen-ancestor"),
			
			handler_blocked(ref vendorPrefix) => write_with_vendor_prefix(dest, vendorPrefix, "handler-blocked"),
			
			handler_crashed(ref vendorPrefix) => write_with_vendor_prefix(dest, vendorPrefix, "handler-crashed"),
			
			handler_disabled(ref vendorPrefix) => write_with_vendor_prefix(dest, vendorPrefix, "handler-disabled"),
			
			last_node(ref vendorPrefix) => write_with_vendor_prefix(dest, vendorPrefix, "last-node"),
			
			list_bullet(ref vendorPrefix) => write_with_vendor_prefix(dest, vendorPrefix, "list-bullet"),
			
			list_number(ref vendorPrefix) => write_with_vendor_prefix(dest, vendorPrefix, "list-number"),
			
			loading(ref vendorPrefix) => write_with_vendor_prefix(dest, vendorPrefix, "loading"),
			
			locale_dir(ref vendorPrefix, ref value) => write_with_vendor_prefix_value(dest, vendorPrefix, "locale-dir", value),
			
			lwtheme(ref vendorPrefix) => write_with_vendor_prefix(dest, vendorPrefix, "lwtheme"),
			
			lwtheme_brighttext(ref vendorPrefix) => write_with_vendor_prefix(dest, vendorPrefix, "lwtheme-brighttext"),
			
			lwtheme_darktext(ref vendorPrefix) => write_with_vendor_prefix(dest, vendorPrefix, "lwtheme-darktext"),
			
			native_anonymous(ref vendorPrefix) => write_with_vendor_prefix(dest, vendorPrefix, "native-anonymous"),
			
			only_whitespace(ref vendorPrefix) => write_with_vendor_prefix(dest, vendorPrefix, "only-whitespace"),
			
			submit_invalid(ref vendorPrefix) => write_with_vendor_prefix(dest, vendorPrefix, "submit-invalid"),
			
			suppressed(ref vendorPrefix) => write_with_vendor_prefix(dest, vendorPrefix, "suppressed"),
			
			system_metric(ref vendorPrefix, ref value) => write_with_vendor_prefix_value(dest, vendorPrefix, "system-metric", value),
			
			tree_cell(ref vendorPrefix) => write_with_vendor_prefix(dest, vendorPrefix, "tree-cell"),
			
			tree_cell_text(ref vendorPrefix, ref value) => write_with_vendor_prefix_value(dest, vendorPrefix, "tree-cell-text", value),
			
			tree_checkbox(ref vendorPrefix) => write_with_vendor_prefix(dest, vendorPrefix, "tree-checkbox"),
			
			tree_column(ref vendorPrefix) => write_with_vendor_prefix(dest, vendorPrefix, "tree-column"),
			
			tree_drop_feedback(ref vendorPrefix) => write_with_vendor_prefix(dest, vendorPrefix, "tree-drop-feedback"),
			
			tree_image(ref vendorPrefix) => write_with_vendor_prefix(dest, vendorPrefix, "tree-image"),
			
			tree_indentation(ref vendorPrefix) => write_with_vendor_prefix(dest, vendorPrefix, "tree-indentation"),
			
			tree_line(ref vendorPrefix) => write_with_vendor_prefix(dest, vendorPrefix, "tree-line"),
			
			tree_progressmeter(ref vendorPrefix) => write_with_vendor_prefix(dest, vendorPrefix, "tree-progressmeter"),
			
			tree_row(ref vendorPrefix, ref value) => write_with_vendor_prefix_value(dest, vendorPrefix, "tree-row", value),
			
			tree_separator(ref vendorPrefix) => write_with_vendor_prefix(dest, vendorPrefix, "tree-separator"),
			
			tree_twisty(ref vendorPrefix) => write_with_vendor_prefix(dest, vendorPrefix, "tree-twisty"),
			
			ui_invalid(ref vendorPrefix) => write_with_vendor_prefix(dest, vendorPrefix, "ui-invalid"),
			
			ui_valid(ref vendorPrefix) => write_with_vendor_prefix(dest, vendorPrefix, "ui-valid"),
			
			user_disabled(ref vendorPrefix) => write_with_vendor_prefix(dest, vendorPrefix, "user-disabled"),
			
			window_inactive(ref vendorPrefix) => write_with_vendor_prefix(dest, vendorPrefix, "window-inactive"),
			
			autofill(ref vendorPrefix) => write_with_vendor_prefix(dest, vendorPrefix, "autofill"),
		}
	}
}

impl SelectorMethods for NonTreeStructuralPseudoClass
{
	type Impl = OurSelectorImpl;
	
	fn visit<V: SelectorVisitor<Impl = Self::Impl>>(&self, _visitor: &mut V) -> bool
	{
		true
	}
}

impl NonTreeStructuralPseudoClass
{
	/// Returns true if the evaluation of the pseudo-class depends on the element's attributes.
	pub fn is_attr_based(&self) -> bool
	{
		use self::NonTreeStructuralPseudoClass::*;
		
		match *self
		{
			lang(..) => true,
			_ => false,
		}
	}
	
	/// https://drafts.csswg.org/selectors-4/#useraction-pseudos
	///
	/// We intentionally skip the link-related ones.
	pub fn is_safe_user_action_state(&self) -> bool
	{
		use self::NonTreeStructuralPseudoClass::*;
		
		match *self
		{
			active => true,
			focus => true,
			hover => true,
			_ => false,
		}
	}
	
	#[inline(always)]
	fn applyVendorPrefix(pseudoClassName: VendorPrefixablePseudoClassName, applyVendorPrefixToPseudoClasses: &HashMap<VendorPrefixablePseudoClassName, VendorPrefix>) -> Option<VendorPrefix>
	{
		applyVendorPrefixToPseudoClasses.get(&pseudoClassName).map(|vendorPrefix| vendorPrefix.clone())
	}
	
	//noinspection SpellCheckingInspection
	#[inline(always)]
	pub(crate) fn parse_without_arguments<'i>(applyVendorPrefixToPseudoClasses: &HashMap<VendorPrefixablePseudoClassName, VendorPrefix>, name: CowRcStr<'i>) -> Result<Self, ParseError<'i, SelectorParseError<'i, CustomParseError<'i>>>>
	{
		use self::NonTreeStructuralPseudoClass::*;
		use self::VendorPrefix::*;
		
		match_ignore_ascii_case!
		{
			&name,
			
			"active" => Ok(active),
			
			"any-link" => Ok(any_link(Self::applyVendorPrefix(VendorPrefixablePseudoClassName::any_link, applyVendorPrefixToPseudoClasses))),
			
			"-moz-any-link" => Ok(any_link(Some(moz))),
			
			"-webkit-any-link" => Ok(any_link(Some(webkit))),
			
			"checked" => Ok(checked),
			
			"default" => Ok(default),
			
			"disabled" => Ok(disabled),
			
			"enabled" => Ok(enabled),
			
			"first" => Ok(first),
			
			"focus" => Ok(focus),
			
			"focus-within" => Ok(focus_within),
			
			"fullscreen" => Ok(fullscreen(Self::applyVendorPrefix(VendorPrefixablePseudoClassName::fullscreen, applyVendorPrefixToPseudoClasses))),
			
			"-ms-fullscreen" => Ok(fullscreen(Some(ms))),
			
			"-moz-full-screen" => Ok(fullscreen(Some(moz))),
			
			"-webkit-full-screen" => Ok(fullscreen(Some(webkit))),
			
			"hover" => Ok(hover),
			
			"indeterminate" => Ok(indeterminate),
			
			"in-range" => Ok(in_range),
			
			"invalid" => Ok(invalid),
			
			"left" => Ok(left),
			
			"link" => Ok(link),
			
			"optional" => Ok(optional),
			
			"out-of-range" => Ok(out_of_range),
			
			"placeholder-shown" => Ok(placeholder_shown(Self::applyVendorPrefix(VendorPrefixablePseudoClassName::placeholder_shown, applyVendorPrefixToPseudoClasses))),
			
			"-moz-placeholder-shown" => Ok(placeholder_shown(Some(moz))),
			
			// See https://developer.mozilla.org/en-US/docs/Web/CSS/:-moz-placeholder
			"-moz-placeholder" => Ok(placeholder_shown(Self::applyVendorPrefix(VendorPrefixablePseudoClassName::placeholder_shown, applyVendorPrefixToPseudoClasses))),
			
			"read-only" => Ok(read_only(Self::applyVendorPrefix(VendorPrefixablePseudoClassName::read_only, applyVendorPrefixToPseudoClasses))),
			
			"-moz-read-only" => Ok(read_only(Some(moz))),
			
			"read-write" => Ok(read_write(Self::applyVendorPrefix(VendorPrefixablePseudoClassName::read_write, applyVendorPrefixToPseudoClasses))),
			
			"-moz-read-write" => Ok(read_write(Some(moz))),
			
			"required" => Ok(required),
			
			"right" => Ok(right),
			
			"scope" => Err(ParseError::Custom(SelectorParseError::Custom(CustomParseError::NonTreeStructuralPseudoClassScopeIsObsoleteAsOfFirefox55))),
			
			"target" => Ok(target),
			
			"valid" => Ok(valid),
			
			"visited" => Ok(visited),
			
			
			// -servo-only
			
			"-servo-non-zero-border" => Ok(non_zero_border(Some(servo))),
			
			
			// -moz- only

			"-moz-broken" => Ok(broken(Some(moz))),
			
			"-moz-drag-over" => Ok(drag_over(Some(moz))),
			
			"-moz-first-node" => Ok(first_node(Some(moz))),
			
			"-moz-focusring" => Ok(focusring(Some(moz))),
			
			"-moz-full-screen-ancestor" => Ok(full_screen_ancestor(Some(moz))),
			
			"-moz-handler-blocked" => Ok(handler_blocked(Some(moz))),
			
			"-moz-handler-crashed" => Ok(handler_crashed(Some(moz))),
			
			"-moz-handler-disabled" => Ok(handler_disabled(Some(moz))),
			
			"-moz-last-node" => Ok(last_node(Some(moz))),
			
			"-moz-list-bullet" => Ok(list_bullet(Some(moz))),
			
			"-moz-list-number" => Ok(list_number(Some(moz))),
			
			"-moz-loading" => Ok(loading(Some(moz))),
			
			"-moz-lwtheme" => Ok(lwtheme(Some(moz))),
			
			"-moz-lwtheme-brighttext" => Ok(lwtheme_brighttext(Some(moz))),
			
			"-moz-lwtheme-darktext" => Ok(lwtheme_darktext(Some(moz))),
			
			"-moz-native-anonymous" => Ok(native_anonymous(Some(moz))),
			
			"-moz-only-whitespace" => Ok(only_whitespace(Some(moz))),
			
			"-moz-submit-invalid" => Ok(submit_invalid(Some(moz))),
			
			"-moz-suppressed" => Ok(suppressed(Some(moz))),
			
			"-moz-tree-cell" => Ok(tree_cell(Some(moz))),
			
			"-moz-tree-checkbox" => Ok(tree_checkbox(Some(moz))),
			
			"-moz-tree-column" => Ok(tree_column(Some(moz))),
			
			"-moz-tree-drop-feedback" => Ok(tree_drop_feedback(Some(moz))),
			
			"-moz-tree-image" => Ok(tree_image(Some(moz))),
			
			"-moz-tree-indentation" => Ok(tree_indentation(Some(moz))),
			
			"-moz-tree-line" => Ok(tree_line(Some(moz))),
			
			"-moz-tree-progressmeter" => Ok(tree_progressmeter(Some(moz))),
			
			"-moz-tree-separator" => Ok(tree_separator(Some(moz))),
			
			"-moz-tree-twisty" => Ok(tree_twisty(Some(moz))),
			
			"-moz-ui-invalid" => Ok(ui_invalid(Some(moz))),
			
			"-moz-ui-valid" => Ok(ui_valid(Some(moz))),
			
			"-moz-user-disabled" => Ok(user_disabled(Some(moz))),
			
			"-moz-window-inactive" => Ok(window_inactive(Some(moz))),
			
			
			// -webkit- only, with potential Mozilla support coming
			
			"-webkit-autofill" => Ok(autofill(Some(webkit))),
			
			"-moz-autofill" => Ok(autofill(Some(moz))),
			
			
			_ => Err(ParseError::Custom(SelectorParseError::UnsupportedPseudoClassOrElement(name.clone()))),
		}
	}
	
	#[inline(always)]
	pub(crate) fn parse_with_arguments<'i, 't>(applyVendorPrefixToPseudoClasses: &HashMap<VendorPrefixablePseudoClassName, VendorPrefix>, name: CowRcStr<'i>, input: &mut Parser<'i, 't>, ourSelectorParser: &OurSelectorParser) -> Result<Self, ParseError<'i, SelectorParseError<'i, CustomParseError<'i>>>>
	{
		use self::NonTreeStructuralPseudoClass::*;
		use self::VendorPrefix::*;
		
		match_ignore_ascii_case!
		{
			&name,
			
			"any" => Ok(any(Self::applyVendorPrefix(VendorPrefixablePseudoClassName::any, applyVendorPrefixToPseudoClasses), Self::parse_any(input, ourSelectorParser)?)),
			
			"-moz-any" => Ok(any(Some(moz), Self::parse_any(input, ourSelectorParser)?)),
			
			"-webkit-any" => Ok(any(Some(webkit), Self::parse_any(input, ourSelectorParser)?)),
			
			"dir" => Ok(dir(Self::applyVendorPrefix(VendorPrefixablePseudoClassName::dir, applyVendorPrefixToPseudoClasses), Self::parse_text_directionality(input)?)),
			
			"-moz-dir" => Ok(dir(Some(moz), Self::parse_text_directionality(input)?)),
			
			"lang" => Ok(lang(Self::parse_lang(input)?)),
			
			
			// -servo- only
			
			"-servo-case-sensitive-type-attr" => Ok(case_sensitive_type_attr(Some(servo), Atom::from(input.expect_ident()?))),
			
			
			// -moz- only
			
			"-moz-locale-dir" => Ok(locale_dir(Some(moz), Self::parse_text_directionality(input)?)),
			
			"-moz-system-metric" => Ok(system_metric(Some(moz), Self::parse_system_metric(input)?)),
			
			"-moz-tree-cell-text" => Ok(tree_cell_text(Some(moz), Self::parse_tree_hover(input)?)),
			
			"-moz-tree-row" => Ok(tree_row(Some(moz), Self::parse_tree_hover(input)?)),
			
			
			_ => Err(ParseError::Custom(SelectorParseError::UnsupportedPseudoClassOrElement(name.clone()))),
		}
	}
	
	#[inline(always)]
	fn parse_any<'i, 't>(input: &mut Parser<'i, 't>, ourSelectorParser: &OurSelectorParser) -> Result<DeduplicatedSelectors, ParseError<'i, SelectorParseError<'i, CustomParseError<'i>>>>
	{
		use ::cssparser::ParseError::*;
		
		ourSelectorParser.parse_internal(input, OurSelectorExt::is_false_if_any_selector_is_simple_and_only_uses_the_descendant_combinator).map_err(|error|
		{
			match error
			{
				Basic(error) => Basic(error),
				Custom(customParseError) => Custom(SelectorParseError::Custom(customParseError))
			}
		})
	}
	
	#[inline(always)]
	fn parse_text_directionality<'i, 't>(input: &mut Parser<'i, 't>) -> Result<TextDirectionality, ParseError<'i, SelectorParseError<'i, CustomParseError<'i>>>>
	{
		use ::cssparser::ParseError::*;
		
		TextDirectionality::parse(input).map_err(|error|
		{
			match error
			{
				Basic(error) => Basic(error),
				Custom(customParseError) => Custom(SelectorParseError::Custom(customParseError))
			}
		})
	}
	
	#[inline(always)]
	fn parse_system_metric<'i, 't>(input: &mut Parser<'i, 't>) -> Result<SystemMetric, ParseError<'i, SelectorParseError<'i, CustomParseError<'i>>>>
	{
		use ::cssparser::ParseError::*;
		
		SystemMetric::parse(input).map_err(|error|
		{
			match error
			{
				Basic(error) => Basic(error),
				Custom(customParseError) => Custom(SelectorParseError::Custom(customParseError))
			}
		})
	}
	
	#[inline(always)]
	fn parse_tree_hover<'i, 't>(input: &mut Parser<'i, 't>) -> Result<TreeHover, ParseError<'i, SelectorParseError<'i, CustomParseError<'i>>>>
	{
		use ::cssparser::ParseError::*;
		
		TreeHover::parse(input).map_err(|error|
		{
			match error
			{
				Basic(error) => Basic(error),
				Custom(customParseError) => Custom(SelectorParseError::Custom(customParseError))
			}
		})
	}
	
	#[inline(always)]
	fn parse_lang<'i, 't>(input: &mut Parser<'i, 't>) -> Result<LanguageRanges, ParseError<'i, SelectorParseError<'i, CustomParseError<'i>>>>
	{
		// the :lang() pseudo-class represents an element that is in one of the languages listed in its argument. It accepts a comma-separated list of one or more language ranges as its argument. Each language range in :lang() must be a valid CSS <ident> or <string>. (Language ranges containing asterisks, for example, must be quoted as strings.)
		input.parse_comma_separated(|input| Ok(LanguageRange(Atom::from(input.expect_ident_or_string()?.as_ref())))).map(LanguageRanges)
	}
}