1 /* This Source Code Form is subject to the terms of the Mozilla Public 2 * License, v. 2.0. If a copy of the MPL was not distributed with this 3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 4 5 /// Gecko's pseudo-element definition. 6 #[derive(Clone, Debug, Eq, Hash, PartialEq)] 7 pub enum PseudoElement { 8 /// :after 9 After, 10 /// :before 11 Before, 12 /// :backdrop 13 Backdrop, 14 /// :cue 15 Cue, 16 /// :first-letter 17 FirstLetter, 18 /// :first-line 19 FirstLine, 20 /// :-moz-selection 21 MozSelection, 22 /// :-moz-focus-inner 23 MozFocusInner, 24 /// :-moz-focus-outer 25 MozFocusOuter, 26 /// :-moz-list-bullet 27 MozListBullet, 28 /// :-moz-list-number 29 MozListNumber, 30 /// :-moz-math-anonymous 31 MozMathAnonymous, 32 /// :-moz-number-wrapper 33 MozNumberWrapper, 34 /// :-moz-number-text 35 MozNumberText, 36 /// :-moz-number-spin-box 37 MozNumberSpinBox, 38 /// :-moz-number-spin-up 39 MozNumberSpinUp, 40 /// :-moz-number-spin-down 41 MozNumberSpinDown, 42 /// :-moz-progress-bar 43 MozProgressBar, 44 /// :-moz-range-track 45 MozRangeTrack, 46 /// :-moz-range-progress 47 MozRangeProgress, 48 /// :-moz-range-thumb 49 MozRangeThumb, 50 /// :-moz-meter-bar 51 MozMeterBar, 52 /// :-moz-placeholder 53 MozPlaceholder, 54 /// :placeholder 55 Placeholder, 56 /// :-moz-color-swatch 57 MozColorSwatch, 58 /// :-moz-text 59 MozText, 60 /// :-moz-oof-placeholder 61 OofPlaceholder, 62 /// :-moz-first-letter-continuation 63 FirstLetterContinuation, 64 /// :-moz-block-inside-inline-wrapper 65 MozBlockInsideInlineWrapper, 66 /// :-moz-mathml-anonymous-block 67 MozMathMLAnonymousBlock, 68 /// :-moz-xul-anonymous-block 69 MozXULAnonymousBlock, 70 /// :-moz-hframeset-border 71 HorizontalFramesetBorder, 72 /// :-moz-vframeset-border 73 VerticalFramesetBorder, 74 /// :-moz-line-frame 75 MozLineFrame, 76 /// :-moz-button-content 77 ButtonContent, 78 /// :-moz-cell-content 79 CellContent, 80 /// :-moz-dropdown-list 81 DropDownList, 82 /// :-moz-fieldset-content 83 FieldsetContent, 84 /// :-moz-frameset-blank 85 FramesetBlank, 86 /// :-moz-display-comboboxcontrol-frame 87 MozDisplayComboboxControlFrame, 88 /// :-moz-html-canvas-content 89 HtmlCanvasContent, 90 /// :-moz-inline-table 91 InlineTable, 92 /// :-moz-table 93 Table, 94 /// :-moz-table-cell 95 TableCell, 96 /// :-moz-table-column-group 97 TableColGroup, 98 /// :-moz-table-column 99 TableCol, 100 /// :-moz-table-wrapper 101 TableWrapper, 102 /// :-moz-table-row-group 103 TableRowGroup, 104 /// :-moz-table-row 105 TableRow, 106 /// :-moz-canvas 107 Canvas, 108 /// :-moz-pagebreak 109 PageBreak, 110 /// :-moz-page 111 Page, 112 /// :-moz-pagecontent 113 PageContent, 114 /// :-moz-page-sequence 115 PageSequence, 116 /// :-moz-scrolled-content 117 ScrolledContent, 118 /// :-moz-scrolled-canvas 119 ScrolledCanvas, 120 /// :-moz-scrolled-page-sequence 121 ScrolledPageSequence, 122 /// :-moz-column-content 123 ColumnContent, 124 /// :-moz-viewport 125 Viewport, 126 /// :-moz-viewport-scroll 127 ViewportScroll, 128 /// :-moz-anonymous-flex-item 129 AnonymousFlexItem, 130 /// :-moz-anonymous-grid-item 131 AnonymousGridItem, 132 /// :-moz-ruby 133 Ruby, 134 /// :-moz-ruby-base 135 RubyBase, 136 /// :-moz-ruby-base-container 137 RubyBaseContainer, 138 /// :-moz-ruby-text 139 RubyText, 140 /// :-moz-ruby-text-container 141 RubyTextContainer, 142 /// :-moz-tree-column 143 MozTreeColumn(Box<[Atom]>), 144 /// :-moz-tree-row 145 MozTreeRow(Box<[Atom]>), 146 /// :-moz-tree-separator 147 MozTreeSeparator(Box<[Atom]>), 148 /// :-moz-tree-cell 149 MozTreeCell(Box<[Atom]>), 150 /// :-moz-tree-indentation 151 MozTreeIndentation(Box<[Atom]>), 152 /// :-moz-tree-line 153 MozTreeLine(Box<[Atom]>), 154 /// :-moz-tree-twisty 155 MozTreeTwisty(Box<[Atom]>), 156 /// :-moz-tree-image 157 MozTreeImage(Box<[Atom]>), 158 /// :-moz-tree-cell-text 159 MozTreeCellText(Box<[Atom]>), 160 /// :-moz-tree-checkbox 161 MozTreeCheckbox(Box<[Atom]>), 162 /// :-moz-tree-drop-feedback 163 MozTreeDropFeedback(Box<[Atom]>), 164 /// :-moz-svg-marker-anon-child 165 MozSVGMarkerAnonChild, 166 /// :-moz-svg-outer-svg-anon-child 167 MozSVGOuterSVGAnonChild, 168 /// :-moz-svg-foreign-content 169 MozSVGForeignContent, 170 /// :-moz-svg-text 171 MozSVGText, 172 } 173 174 /// Important: If you change this, you should also update Gecko's 175 /// nsCSSPseudoElements::IsEagerlyCascadedInServo. 176 177 178 179 180 /// The number of eager pseudo-elements. 181 pub const EAGER_PSEUDO_COUNT: usize = 4; 182 183 /// The number of non-functional pseudo-elements. 184 pub const SIMPLE_PSEUDO_COUNT: usize = 71; 185 186 /// The number of tree pseudo-elements. 187 pub const TREE_PSEUDO_COUNT: usize = 11; 188 189 /// The number of all pseudo-elements. 190 pub const PSEUDO_COUNT: usize = 82; 191 192 /// The list of eager pseudos. 193 pub const EAGER_PSEUDOS: [PseudoElement; EAGER_PSEUDO_COUNT] = [ 194 PseudoElement::Before, 195 PseudoElement::After, 196 PseudoElement::FirstLine, 197 PseudoElement::FirstLetter, 198 ]; 199 200 201 202 impl PseudoElement { 203 /// Get the pseudo-element as an atom. 204 #[inline] atom(&self) -> Atom205 pub fn atom(&self) -> Atom { 206 match *self { 207 PseudoElement::After => atom!(":after"), 208 PseudoElement::Before => atom!(":before"), 209 PseudoElement::Backdrop => atom!(":backdrop"), 210 PseudoElement::Cue => atom!(":cue"), 211 PseudoElement::FirstLetter => atom!(":first-letter"), 212 PseudoElement::FirstLine => atom!(":first-line"), 213 PseudoElement::MozSelection => atom!(":-moz-selection"), 214 PseudoElement::MozFocusInner => atom!(":-moz-focus-inner"), 215 PseudoElement::MozFocusOuter => atom!(":-moz-focus-outer"), 216 PseudoElement::MozListBullet => atom!(":-moz-list-bullet"), 217 PseudoElement::MozListNumber => atom!(":-moz-list-number"), 218 PseudoElement::MozMathAnonymous => atom!(":-moz-math-anonymous"), 219 PseudoElement::MozNumberWrapper => atom!(":-moz-number-wrapper"), 220 PseudoElement::MozNumberText => atom!(":-moz-number-text"), 221 PseudoElement::MozNumberSpinBox => atom!(":-moz-number-spin-box"), 222 PseudoElement::MozNumberSpinUp => atom!(":-moz-number-spin-up"), 223 PseudoElement::MozNumberSpinDown => atom!(":-moz-number-spin-down"), 224 PseudoElement::MozProgressBar => atom!(":-moz-progress-bar"), 225 PseudoElement::MozRangeTrack => atom!(":-moz-range-track"), 226 PseudoElement::MozRangeProgress => atom!(":-moz-range-progress"), 227 PseudoElement::MozRangeThumb => atom!(":-moz-range-thumb"), 228 PseudoElement::MozMeterBar => atom!(":-moz-meter-bar"), 229 PseudoElement::MozPlaceholder => atom!(":-moz-placeholder"), 230 PseudoElement::Placeholder => atom!(":placeholder"), 231 PseudoElement::MozColorSwatch => atom!(":-moz-color-swatch"), 232 PseudoElement::MozText => atom!(":-moz-text"), 233 PseudoElement::OofPlaceholder => atom!(":-moz-oof-placeholder"), 234 PseudoElement::FirstLetterContinuation => atom!(":-moz-first-letter-continuation"), 235 PseudoElement::MozBlockInsideInlineWrapper => atom!(":-moz-block-inside-inline-wrapper"), 236 PseudoElement::MozMathMLAnonymousBlock => atom!(":-moz-mathml-anonymous-block"), 237 PseudoElement::MozXULAnonymousBlock => atom!(":-moz-xul-anonymous-block"), 238 PseudoElement::HorizontalFramesetBorder => atom!(":-moz-hframeset-border"), 239 PseudoElement::VerticalFramesetBorder => atom!(":-moz-vframeset-border"), 240 PseudoElement::MozLineFrame => atom!(":-moz-line-frame"), 241 PseudoElement::ButtonContent => atom!(":-moz-button-content"), 242 PseudoElement::CellContent => atom!(":-moz-cell-content"), 243 PseudoElement::DropDownList => atom!(":-moz-dropdown-list"), 244 PseudoElement::FieldsetContent => atom!(":-moz-fieldset-content"), 245 PseudoElement::FramesetBlank => atom!(":-moz-frameset-blank"), 246 PseudoElement::MozDisplayComboboxControlFrame => atom!(":-moz-display-comboboxcontrol-frame"), 247 PseudoElement::HtmlCanvasContent => atom!(":-moz-html-canvas-content"), 248 PseudoElement::InlineTable => atom!(":-moz-inline-table"), 249 PseudoElement::Table => atom!(":-moz-table"), 250 PseudoElement::TableCell => atom!(":-moz-table-cell"), 251 PseudoElement::TableColGroup => atom!(":-moz-table-column-group"), 252 PseudoElement::TableCol => atom!(":-moz-table-column"), 253 PseudoElement::TableWrapper => atom!(":-moz-table-wrapper"), 254 PseudoElement::TableRowGroup => atom!(":-moz-table-row-group"), 255 PseudoElement::TableRow => atom!(":-moz-table-row"), 256 PseudoElement::Canvas => atom!(":-moz-canvas"), 257 PseudoElement::PageBreak => atom!(":-moz-pagebreak"), 258 PseudoElement::Page => atom!(":-moz-page"), 259 PseudoElement::PageContent => atom!(":-moz-pagecontent"), 260 PseudoElement::PageSequence => atom!(":-moz-page-sequence"), 261 PseudoElement::ScrolledContent => atom!(":-moz-scrolled-content"), 262 PseudoElement::ScrolledCanvas => atom!(":-moz-scrolled-canvas"), 263 PseudoElement::ScrolledPageSequence => atom!(":-moz-scrolled-page-sequence"), 264 PseudoElement::ColumnContent => atom!(":-moz-column-content"), 265 PseudoElement::Viewport => atom!(":-moz-viewport"), 266 PseudoElement::ViewportScroll => atom!(":-moz-viewport-scroll"), 267 PseudoElement::AnonymousFlexItem => atom!(":-moz-anonymous-flex-item"), 268 PseudoElement::AnonymousGridItem => atom!(":-moz-anonymous-grid-item"), 269 PseudoElement::Ruby => atom!(":-moz-ruby"), 270 PseudoElement::RubyBase => atom!(":-moz-ruby-base"), 271 PseudoElement::RubyBaseContainer => atom!(":-moz-ruby-base-container"), 272 PseudoElement::RubyText => atom!(":-moz-ruby-text"), 273 PseudoElement::RubyTextContainer => atom!(":-moz-ruby-text-container"), 274 PseudoElement::MozTreeColumn(..) => atom!(":-moz-tree-column"), 275 PseudoElement::MozTreeRow(..) => atom!(":-moz-tree-row"), 276 PseudoElement::MozTreeSeparator(..) => atom!(":-moz-tree-separator"), 277 PseudoElement::MozTreeCell(..) => atom!(":-moz-tree-cell"), 278 PseudoElement::MozTreeIndentation(..) => atom!(":-moz-tree-indentation"), 279 PseudoElement::MozTreeLine(..) => atom!(":-moz-tree-line"), 280 PseudoElement::MozTreeTwisty(..) => atom!(":-moz-tree-twisty"), 281 PseudoElement::MozTreeImage(..) => atom!(":-moz-tree-image"), 282 PseudoElement::MozTreeCellText(..) => atom!(":-moz-tree-cell-text"), 283 PseudoElement::MozTreeCheckbox(..) => atom!(":-moz-tree-checkbox"), 284 PseudoElement::MozTreeDropFeedback(..) => atom!(":-moz-tree-drop-feedback"), 285 PseudoElement::MozSVGMarkerAnonChild => atom!(":-moz-svg-marker-anon-child"), 286 PseudoElement::MozSVGOuterSVGAnonChild => atom!(":-moz-svg-outer-svg-anon-child"), 287 PseudoElement::MozSVGForeignContent => atom!(":-moz-svg-foreign-content"), 288 PseudoElement::MozSVGText => atom!(":-moz-svg-text"), 289 } 290 } 291 292 /// Returns an index of the pseudo-element. 293 #[inline] index(&self) -> usize294 pub fn index(&self) -> usize { 295 match *self { 296 PseudoElement::After => 0, 297 PseudoElement::Before => 1, 298 PseudoElement::Backdrop => 2, 299 PseudoElement::Cue => 3, 300 PseudoElement::FirstLetter => 4, 301 PseudoElement::FirstLine => 5, 302 PseudoElement::MozSelection => 6, 303 PseudoElement::MozFocusInner => 7, 304 PseudoElement::MozFocusOuter => 8, 305 PseudoElement::MozListBullet => 9, 306 PseudoElement::MozListNumber => 10, 307 PseudoElement::MozMathAnonymous => 11, 308 PseudoElement::MozNumberWrapper => 12, 309 PseudoElement::MozNumberText => 13, 310 PseudoElement::MozNumberSpinBox => 14, 311 PseudoElement::MozNumberSpinUp => 15, 312 PseudoElement::MozNumberSpinDown => 16, 313 PseudoElement::MozProgressBar => 17, 314 PseudoElement::MozRangeTrack => 18, 315 PseudoElement::MozRangeProgress => 19, 316 PseudoElement::MozRangeThumb => 20, 317 PseudoElement::MozMeterBar => 21, 318 PseudoElement::MozPlaceholder => 22, 319 PseudoElement::Placeholder => 23, 320 PseudoElement::MozColorSwatch => 24, 321 PseudoElement::MozText => 25, 322 PseudoElement::OofPlaceholder => 26, 323 PseudoElement::FirstLetterContinuation => 27, 324 PseudoElement::MozBlockInsideInlineWrapper => 28, 325 PseudoElement::MozMathMLAnonymousBlock => 29, 326 PseudoElement::MozXULAnonymousBlock => 30, 327 PseudoElement::HorizontalFramesetBorder => 31, 328 PseudoElement::VerticalFramesetBorder => 32, 329 PseudoElement::MozLineFrame => 33, 330 PseudoElement::ButtonContent => 34, 331 PseudoElement::CellContent => 35, 332 PseudoElement::DropDownList => 36, 333 PseudoElement::FieldsetContent => 37, 334 PseudoElement::FramesetBlank => 38, 335 PseudoElement::MozDisplayComboboxControlFrame => 39, 336 PseudoElement::HtmlCanvasContent => 40, 337 PseudoElement::InlineTable => 41, 338 PseudoElement::Table => 42, 339 PseudoElement::TableCell => 43, 340 PseudoElement::TableColGroup => 44, 341 PseudoElement::TableCol => 45, 342 PseudoElement::TableWrapper => 46, 343 PseudoElement::TableRowGroup => 47, 344 PseudoElement::TableRow => 48, 345 PseudoElement::Canvas => 49, 346 PseudoElement::PageBreak => 50, 347 PseudoElement::Page => 51, 348 PseudoElement::PageContent => 52, 349 PseudoElement::PageSequence => 53, 350 PseudoElement::ScrolledContent => 54, 351 PseudoElement::ScrolledCanvas => 55, 352 PseudoElement::ScrolledPageSequence => 56, 353 PseudoElement::ColumnContent => 57, 354 PseudoElement::Viewport => 58, 355 PseudoElement::ViewportScroll => 59, 356 PseudoElement::AnonymousFlexItem => 60, 357 PseudoElement::AnonymousGridItem => 61, 358 PseudoElement::Ruby => 62, 359 PseudoElement::RubyBase => 63, 360 PseudoElement::RubyBaseContainer => 64, 361 PseudoElement::RubyText => 65, 362 PseudoElement::RubyTextContainer => 66, 363 PseudoElement::MozTreeColumn(..) => 67, 364 PseudoElement::MozTreeRow(..) => 68, 365 PseudoElement::MozTreeSeparator(..) => 69, 366 PseudoElement::MozTreeCell(..) => 70, 367 PseudoElement::MozTreeIndentation(..) => 71, 368 PseudoElement::MozTreeLine(..) => 72, 369 PseudoElement::MozTreeTwisty(..) => 73, 370 PseudoElement::MozTreeImage(..) => 74, 371 PseudoElement::MozTreeCellText(..) => 75, 372 PseudoElement::MozTreeCheckbox(..) => 76, 373 PseudoElement::MozTreeDropFeedback(..) => 77, 374 PseudoElement::MozSVGMarkerAnonChild => 78, 375 PseudoElement::MozSVGOuterSVGAnonChild => 79, 376 PseudoElement::MozSVGForeignContent => 80, 377 PseudoElement::MozSVGText => 81, 378 } 379 } 380 381 /// Returns an array of `None` values. 382 /// 383 /// FIXME(emilio): Integer generics can't come soon enough. pseudo_none_array<T>() -> [Option<T>; PSEUDO_COUNT]384 pub fn pseudo_none_array<T>() -> [Option<T>; PSEUDO_COUNT] { 385 [ 386 None, 387 None, 388 None, 389 None, 390 None, 391 None, 392 None, 393 None, 394 None, 395 None, 396 None, 397 None, 398 None, 399 None, 400 None, 401 None, 402 None, 403 None, 404 None, 405 None, 406 None, 407 None, 408 None, 409 None, 410 None, 411 None, 412 None, 413 None, 414 None, 415 None, 416 None, 417 None, 418 None, 419 None, 420 None, 421 None, 422 None, 423 None, 424 None, 425 None, 426 None, 427 None, 428 None, 429 None, 430 None, 431 None, 432 None, 433 None, 434 None, 435 None, 436 None, 437 None, 438 None, 439 None, 440 None, 441 None, 442 None, 443 None, 444 None, 445 None, 446 None, 447 None, 448 None, 449 None, 450 None, 451 None, 452 None, 453 None, 454 None, 455 None, 456 None, 457 None, 458 None, 459 None, 460 None, 461 None, 462 None, 463 None, 464 None, 465 None, 466 None, 467 None 468 ] 469 } 470 471 /// Whether this pseudo-element is an anonymous box. 472 #[inline] is_anon_box(&self) -> bool473 pub fn is_anon_box(&self) -> bool { 474 match *self { 475 PseudoElement::MozText => true, 476 PseudoElement::OofPlaceholder => true, 477 PseudoElement::FirstLetterContinuation => true, 478 PseudoElement::MozBlockInsideInlineWrapper => true, 479 PseudoElement::MozMathMLAnonymousBlock => true, 480 PseudoElement::MozXULAnonymousBlock => true, 481 PseudoElement::HorizontalFramesetBorder => true, 482 PseudoElement::VerticalFramesetBorder => true, 483 PseudoElement::MozLineFrame => true, 484 PseudoElement::ButtonContent => true, 485 PseudoElement::CellContent => true, 486 PseudoElement::DropDownList => true, 487 PseudoElement::FieldsetContent => true, 488 PseudoElement::FramesetBlank => true, 489 PseudoElement::MozDisplayComboboxControlFrame => true, 490 PseudoElement::HtmlCanvasContent => true, 491 PseudoElement::InlineTable => true, 492 PseudoElement::Table => true, 493 PseudoElement::TableCell => true, 494 PseudoElement::TableColGroup => true, 495 PseudoElement::TableCol => true, 496 PseudoElement::TableWrapper => true, 497 PseudoElement::TableRowGroup => true, 498 PseudoElement::TableRow => true, 499 PseudoElement::Canvas => true, 500 PseudoElement::PageBreak => true, 501 PseudoElement::Page => true, 502 PseudoElement::PageContent => true, 503 PseudoElement::PageSequence => true, 504 PseudoElement::ScrolledContent => true, 505 PseudoElement::ScrolledCanvas => true, 506 PseudoElement::ScrolledPageSequence => true, 507 PseudoElement::ColumnContent => true, 508 PseudoElement::Viewport => true, 509 PseudoElement::ViewportScroll => true, 510 PseudoElement::AnonymousFlexItem => true, 511 PseudoElement::AnonymousGridItem => true, 512 PseudoElement::Ruby => true, 513 PseudoElement::RubyBase => true, 514 PseudoElement::RubyBaseContainer => true, 515 PseudoElement::RubyText => true, 516 PseudoElement::RubyTextContainer => true, 517 PseudoElement::MozTreeColumn(..) => true, 518 PseudoElement::MozTreeRow(..) => true, 519 PseudoElement::MozTreeSeparator(..) => true, 520 PseudoElement::MozTreeCell(..) => true, 521 PseudoElement::MozTreeIndentation(..) => true, 522 PseudoElement::MozTreeLine(..) => true, 523 PseudoElement::MozTreeTwisty(..) => true, 524 PseudoElement::MozTreeImage(..) => true, 525 PseudoElement::MozTreeCellText(..) => true, 526 PseudoElement::MozTreeCheckbox(..) => true, 527 PseudoElement::MozTreeDropFeedback(..) => true, 528 PseudoElement::MozSVGMarkerAnonChild => true, 529 PseudoElement::MozSVGOuterSVGAnonChild => true, 530 PseudoElement::MozSVGForeignContent => true, 531 PseudoElement::MozSVGText => true, 532 _ => false, 533 } 534 } 535 536 /// Whether this pseudo-element is eagerly-cascaded. 537 #[inline] is_eager(&self) -> bool538 pub fn is_eager(&self) -> bool { 539 matches!(*self, 540 PseudoElement::Before | PseudoElement::After | PseudoElement::FirstLine | PseudoElement::FirstLetter) 541 } 542 543 /// Whether this pseudo-element is tree pseudo-element. 544 #[inline] is_tree_pseudo_element(&self) -> bool545 pub fn is_tree_pseudo_element(&self) -> bool { 546 match *self { 547 PseudoElement::MozTreeColumn(..) => true, 548 PseudoElement::MozTreeRow(..) => true, 549 PseudoElement::MozTreeSeparator(..) => true, 550 PseudoElement::MozTreeCell(..) => true, 551 PseudoElement::MozTreeIndentation(..) => true, 552 PseudoElement::MozTreeLine(..) => true, 553 PseudoElement::MozTreeTwisty(..) => true, 554 PseudoElement::MozTreeImage(..) => true, 555 PseudoElement::MozTreeCellText(..) => true, 556 PseudoElement::MozTreeCheckbox(..) => true, 557 PseudoElement::MozTreeDropFeedback(..) => true, 558 _ => false, 559 } 560 } 561 562 /// Gets the flags associated to this pseudo-element, or 0 if it's an 563 /// anonymous box. flags(&self) -> u32564 pub fn flags(&self) -> u32 { 565 match *self { 566 PseudoElement::After => 567 structs::SERVO_CSS_PSEUDO_ELEMENT_FLAGS_after, 568 PseudoElement::Before => 569 structs::SERVO_CSS_PSEUDO_ELEMENT_FLAGS_before, 570 PseudoElement::Backdrop => 571 structs::SERVO_CSS_PSEUDO_ELEMENT_FLAGS_backdrop, 572 PseudoElement::Cue => 573 structs::SERVO_CSS_PSEUDO_ELEMENT_FLAGS_cue, 574 PseudoElement::FirstLetter => 575 structs::SERVO_CSS_PSEUDO_ELEMENT_FLAGS_firstLetter, 576 PseudoElement::FirstLine => 577 structs::SERVO_CSS_PSEUDO_ELEMENT_FLAGS_firstLine, 578 PseudoElement::MozSelection => 579 structs::SERVO_CSS_PSEUDO_ELEMENT_FLAGS_mozSelection, 580 PseudoElement::MozFocusInner => 581 structs::SERVO_CSS_PSEUDO_ELEMENT_FLAGS_mozFocusInner, 582 PseudoElement::MozFocusOuter => 583 structs::SERVO_CSS_PSEUDO_ELEMENT_FLAGS_mozFocusOuter, 584 PseudoElement::MozListBullet => 585 structs::SERVO_CSS_PSEUDO_ELEMENT_FLAGS_mozListBullet, 586 PseudoElement::MozListNumber => 587 structs::SERVO_CSS_PSEUDO_ELEMENT_FLAGS_mozListNumber, 588 PseudoElement::MozMathAnonymous => 589 structs::SERVO_CSS_PSEUDO_ELEMENT_FLAGS_mozMathAnonymous, 590 PseudoElement::MozNumberWrapper => 591 structs::SERVO_CSS_PSEUDO_ELEMENT_FLAGS_mozNumberWrapper, 592 PseudoElement::MozNumberText => 593 structs::SERVO_CSS_PSEUDO_ELEMENT_FLAGS_mozNumberText, 594 PseudoElement::MozNumberSpinBox => 595 structs::SERVO_CSS_PSEUDO_ELEMENT_FLAGS_mozNumberSpinBox, 596 PseudoElement::MozNumberSpinUp => 597 structs::SERVO_CSS_PSEUDO_ELEMENT_FLAGS_mozNumberSpinUp, 598 PseudoElement::MozNumberSpinDown => 599 structs::SERVO_CSS_PSEUDO_ELEMENT_FLAGS_mozNumberSpinDown, 600 PseudoElement::MozProgressBar => 601 structs::SERVO_CSS_PSEUDO_ELEMENT_FLAGS_mozProgressBar, 602 PseudoElement::MozRangeTrack => 603 structs::SERVO_CSS_PSEUDO_ELEMENT_FLAGS_mozRangeTrack, 604 PseudoElement::MozRangeProgress => 605 structs::SERVO_CSS_PSEUDO_ELEMENT_FLAGS_mozRangeProgress, 606 PseudoElement::MozRangeThumb => 607 structs::SERVO_CSS_PSEUDO_ELEMENT_FLAGS_mozRangeThumb, 608 PseudoElement::MozMeterBar => 609 structs::SERVO_CSS_PSEUDO_ELEMENT_FLAGS_mozMeterBar, 610 PseudoElement::MozPlaceholder => 611 structs::SERVO_CSS_PSEUDO_ELEMENT_FLAGS_mozPlaceholder, 612 PseudoElement::Placeholder => 613 structs::SERVO_CSS_PSEUDO_ELEMENT_FLAGS_placeholder, 614 PseudoElement::MozColorSwatch => 615 structs::SERVO_CSS_PSEUDO_ELEMENT_FLAGS_mozColorSwatch, 616 PseudoElement::MozText => 617 structs::CSS_PSEUDO_ELEMENT_ENABLED_IN_UA_SHEETS, 618 PseudoElement::OofPlaceholder => 619 structs::CSS_PSEUDO_ELEMENT_ENABLED_IN_UA_SHEETS, 620 PseudoElement::FirstLetterContinuation => 621 structs::CSS_PSEUDO_ELEMENT_ENABLED_IN_UA_SHEETS, 622 PseudoElement::MozBlockInsideInlineWrapper => 623 structs::CSS_PSEUDO_ELEMENT_ENABLED_IN_UA_SHEETS, 624 PseudoElement::MozMathMLAnonymousBlock => 625 structs::CSS_PSEUDO_ELEMENT_ENABLED_IN_UA_SHEETS, 626 PseudoElement::MozXULAnonymousBlock => 627 structs::CSS_PSEUDO_ELEMENT_ENABLED_IN_UA_SHEETS, 628 PseudoElement::HorizontalFramesetBorder => 629 structs::CSS_PSEUDO_ELEMENT_ENABLED_IN_UA_SHEETS, 630 PseudoElement::VerticalFramesetBorder => 631 structs::CSS_PSEUDO_ELEMENT_ENABLED_IN_UA_SHEETS, 632 PseudoElement::MozLineFrame => 633 structs::CSS_PSEUDO_ELEMENT_ENABLED_IN_UA_SHEETS, 634 PseudoElement::ButtonContent => 635 structs::CSS_PSEUDO_ELEMENT_ENABLED_IN_UA_SHEETS, 636 PseudoElement::CellContent => 637 structs::CSS_PSEUDO_ELEMENT_ENABLED_IN_UA_SHEETS, 638 PseudoElement::DropDownList => 639 structs::CSS_PSEUDO_ELEMENT_ENABLED_IN_UA_SHEETS, 640 PseudoElement::FieldsetContent => 641 structs::CSS_PSEUDO_ELEMENT_ENABLED_IN_UA_SHEETS, 642 PseudoElement::FramesetBlank => 643 structs::CSS_PSEUDO_ELEMENT_ENABLED_IN_UA_SHEETS, 644 PseudoElement::MozDisplayComboboxControlFrame => 645 structs::CSS_PSEUDO_ELEMENT_ENABLED_IN_UA_SHEETS, 646 PseudoElement::HtmlCanvasContent => 647 structs::CSS_PSEUDO_ELEMENT_ENABLED_IN_UA_SHEETS, 648 PseudoElement::InlineTable => 649 structs::CSS_PSEUDO_ELEMENT_ENABLED_IN_UA_SHEETS, 650 PseudoElement::Table => 651 structs::CSS_PSEUDO_ELEMENT_ENABLED_IN_UA_SHEETS, 652 PseudoElement::TableCell => 653 structs::CSS_PSEUDO_ELEMENT_ENABLED_IN_UA_SHEETS, 654 PseudoElement::TableColGroup => 655 structs::CSS_PSEUDO_ELEMENT_ENABLED_IN_UA_SHEETS, 656 PseudoElement::TableCol => 657 structs::CSS_PSEUDO_ELEMENT_ENABLED_IN_UA_SHEETS, 658 PseudoElement::TableWrapper => 659 structs::CSS_PSEUDO_ELEMENT_ENABLED_IN_UA_SHEETS, 660 PseudoElement::TableRowGroup => 661 structs::CSS_PSEUDO_ELEMENT_ENABLED_IN_UA_SHEETS, 662 PseudoElement::TableRow => 663 structs::CSS_PSEUDO_ELEMENT_ENABLED_IN_UA_SHEETS, 664 PseudoElement::Canvas => 665 structs::CSS_PSEUDO_ELEMENT_ENABLED_IN_UA_SHEETS, 666 PseudoElement::PageBreak => 667 structs::CSS_PSEUDO_ELEMENT_ENABLED_IN_UA_SHEETS, 668 PseudoElement::Page => 669 structs::CSS_PSEUDO_ELEMENT_ENABLED_IN_UA_SHEETS, 670 PseudoElement::PageContent => 671 structs::CSS_PSEUDO_ELEMENT_ENABLED_IN_UA_SHEETS, 672 PseudoElement::PageSequence => 673 structs::CSS_PSEUDO_ELEMENT_ENABLED_IN_UA_SHEETS, 674 PseudoElement::ScrolledContent => 675 structs::CSS_PSEUDO_ELEMENT_ENABLED_IN_UA_SHEETS, 676 PseudoElement::ScrolledCanvas => 677 structs::CSS_PSEUDO_ELEMENT_ENABLED_IN_UA_SHEETS, 678 PseudoElement::ScrolledPageSequence => 679 structs::CSS_PSEUDO_ELEMENT_ENABLED_IN_UA_SHEETS, 680 PseudoElement::ColumnContent => 681 structs::CSS_PSEUDO_ELEMENT_ENABLED_IN_UA_SHEETS, 682 PseudoElement::Viewport => 683 structs::CSS_PSEUDO_ELEMENT_ENABLED_IN_UA_SHEETS, 684 PseudoElement::ViewportScroll => 685 structs::CSS_PSEUDO_ELEMENT_ENABLED_IN_UA_SHEETS, 686 PseudoElement::AnonymousFlexItem => 687 structs::CSS_PSEUDO_ELEMENT_ENABLED_IN_UA_SHEETS, 688 PseudoElement::AnonymousGridItem => 689 structs::CSS_PSEUDO_ELEMENT_ENABLED_IN_UA_SHEETS, 690 PseudoElement::Ruby => 691 structs::CSS_PSEUDO_ELEMENT_ENABLED_IN_UA_SHEETS, 692 PseudoElement::RubyBase => 693 structs::CSS_PSEUDO_ELEMENT_ENABLED_IN_UA_SHEETS, 694 PseudoElement::RubyBaseContainer => 695 structs::CSS_PSEUDO_ELEMENT_ENABLED_IN_UA_SHEETS, 696 PseudoElement::RubyText => 697 structs::CSS_PSEUDO_ELEMENT_ENABLED_IN_UA_SHEETS, 698 PseudoElement::RubyTextContainer => 699 structs::CSS_PSEUDO_ELEMENT_ENABLED_IN_UA_SHEETS, 700 PseudoElement::MozTreeColumn(..) => 701 0, 702 PseudoElement::MozTreeRow(..) => 703 0, 704 PseudoElement::MozTreeSeparator(..) => 705 0, 706 PseudoElement::MozTreeCell(..) => 707 0, 708 PseudoElement::MozTreeIndentation(..) => 709 0, 710 PseudoElement::MozTreeLine(..) => 711 0, 712 PseudoElement::MozTreeTwisty(..) => 713 0, 714 PseudoElement::MozTreeImage(..) => 715 0, 716 PseudoElement::MozTreeCellText(..) => 717 0, 718 PseudoElement::MozTreeCheckbox(..) => 719 0, 720 PseudoElement::MozTreeDropFeedback(..) => 721 0, 722 PseudoElement::MozSVGMarkerAnonChild => 723 structs::CSS_PSEUDO_ELEMENT_ENABLED_IN_UA_SHEETS, 724 PseudoElement::MozSVGOuterSVGAnonChild => 725 structs::CSS_PSEUDO_ELEMENT_ENABLED_IN_UA_SHEETS, 726 PseudoElement::MozSVGForeignContent => 727 structs::CSS_PSEUDO_ELEMENT_ENABLED_IN_UA_SHEETS, 728 PseudoElement::MozSVGText => 729 structs::CSS_PSEUDO_ELEMENT_ENABLED_IN_UA_SHEETS, 730 } 731 } 732 733 /// Construct a pseudo-element from a `CSSPseudoElementType`. 734 #[inline] from_pseudo_type(type_: CSSPseudoElementType) -> Option<Self>735 pub fn from_pseudo_type(type_: CSSPseudoElementType) -> Option<Self> { 736 match type_ { 737 CSSPseudoElementType::after => { 738 Some(PseudoElement::After) 739 }, 740 CSSPseudoElementType::before => { 741 Some(PseudoElement::Before) 742 }, 743 CSSPseudoElementType::backdrop => { 744 Some(PseudoElement::Backdrop) 745 }, 746 CSSPseudoElementType::cue => { 747 Some(PseudoElement::Cue) 748 }, 749 CSSPseudoElementType::firstLetter => { 750 Some(PseudoElement::FirstLetter) 751 }, 752 CSSPseudoElementType::firstLine => { 753 Some(PseudoElement::FirstLine) 754 }, 755 CSSPseudoElementType::mozSelection => { 756 Some(PseudoElement::MozSelection) 757 }, 758 CSSPseudoElementType::mozFocusInner => { 759 Some(PseudoElement::MozFocusInner) 760 }, 761 CSSPseudoElementType::mozFocusOuter => { 762 Some(PseudoElement::MozFocusOuter) 763 }, 764 CSSPseudoElementType::mozListBullet => { 765 Some(PseudoElement::MozListBullet) 766 }, 767 CSSPseudoElementType::mozListNumber => { 768 Some(PseudoElement::MozListNumber) 769 }, 770 CSSPseudoElementType::mozMathAnonymous => { 771 Some(PseudoElement::MozMathAnonymous) 772 }, 773 CSSPseudoElementType::mozNumberWrapper => { 774 Some(PseudoElement::MozNumberWrapper) 775 }, 776 CSSPseudoElementType::mozNumberText => { 777 Some(PseudoElement::MozNumberText) 778 }, 779 CSSPseudoElementType::mozNumberSpinBox => { 780 Some(PseudoElement::MozNumberSpinBox) 781 }, 782 CSSPseudoElementType::mozNumberSpinUp => { 783 Some(PseudoElement::MozNumberSpinUp) 784 }, 785 CSSPseudoElementType::mozNumberSpinDown => { 786 Some(PseudoElement::MozNumberSpinDown) 787 }, 788 CSSPseudoElementType::mozProgressBar => { 789 Some(PseudoElement::MozProgressBar) 790 }, 791 CSSPseudoElementType::mozRangeTrack => { 792 Some(PseudoElement::MozRangeTrack) 793 }, 794 CSSPseudoElementType::mozRangeProgress => { 795 Some(PseudoElement::MozRangeProgress) 796 }, 797 CSSPseudoElementType::mozRangeThumb => { 798 Some(PseudoElement::MozRangeThumb) 799 }, 800 CSSPseudoElementType::mozMeterBar => { 801 Some(PseudoElement::MozMeterBar) 802 }, 803 CSSPseudoElementType::mozPlaceholder => { 804 Some(PseudoElement::MozPlaceholder) 805 }, 806 CSSPseudoElementType::placeholder => { 807 Some(PseudoElement::Placeholder) 808 }, 809 CSSPseudoElementType::mozColorSwatch => { 810 Some(PseudoElement::MozColorSwatch) 811 }, 812 _ => None, 813 } 814 } 815 816 /// Construct a `CSSPseudoElementType` from a pseudo-element 817 #[inline] pseudo_type(&self) -> CSSPseudoElementType818 pub fn pseudo_type(&self) -> CSSPseudoElementType { 819 use gecko_bindings::structs::CSSPseudoElementType_InheritingAnonBox; 820 821 match *self { 822 PseudoElement::After => CSSPseudoElementType::after, 823 PseudoElement::Before => CSSPseudoElementType::before, 824 PseudoElement::Backdrop => CSSPseudoElementType::backdrop, 825 PseudoElement::Cue => CSSPseudoElementType::cue, 826 PseudoElement::FirstLetter => CSSPseudoElementType::firstLetter, 827 PseudoElement::FirstLine => CSSPseudoElementType::firstLine, 828 PseudoElement::MozSelection => CSSPseudoElementType::mozSelection, 829 PseudoElement::MozFocusInner => CSSPseudoElementType::mozFocusInner, 830 PseudoElement::MozFocusOuter => CSSPseudoElementType::mozFocusOuter, 831 PseudoElement::MozListBullet => CSSPseudoElementType::mozListBullet, 832 PseudoElement::MozListNumber => CSSPseudoElementType::mozListNumber, 833 PseudoElement::MozMathAnonymous => CSSPseudoElementType::mozMathAnonymous, 834 PseudoElement::MozNumberWrapper => CSSPseudoElementType::mozNumberWrapper, 835 PseudoElement::MozNumberText => CSSPseudoElementType::mozNumberText, 836 PseudoElement::MozNumberSpinBox => CSSPseudoElementType::mozNumberSpinBox, 837 PseudoElement::MozNumberSpinUp => CSSPseudoElementType::mozNumberSpinUp, 838 PseudoElement::MozNumberSpinDown => CSSPseudoElementType::mozNumberSpinDown, 839 PseudoElement::MozProgressBar => CSSPseudoElementType::mozProgressBar, 840 PseudoElement::MozRangeTrack => CSSPseudoElementType::mozRangeTrack, 841 PseudoElement::MozRangeProgress => CSSPseudoElementType::mozRangeProgress, 842 PseudoElement::MozRangeThumb => CSSPseudoElementType::mozRangeThumb, 843 PseudoElement::MozMeterBar => CSSPseudoElementType::mozMeterBar, 844 PseudoElement::MozPlaceholder => CSSPseudoElementType::mozPlaceholder, 845 PseudoElement::Placeholder => CSSPseudoElementType::placeholder, 846 PseudoElement::MozColorSwatch => CSSPseudoElementType::mozColorSwatch, 847 PseudoElement::MozText => CSSPseudoElementType_InheritingAnonBox, 848 PseudoElement::OofPlaceholder => CSSPseudoElementType::NonInheritingAnonBox, 849 PseudoElement::FirstLetterContinuation => CSSPseudoElementType_InheritingAnonBox, 850 PseudoElement::MozBlockInsideInlineWrapper => CSSPseudoElementType_InheritingAnonBox, 851 PseudoElement::MozMathMLAnonymousBlock => CSSPseudoElementType_InheritingAnonBox, 852 PseudoElement::MozXULAnonymousBlock => CSSPseudoElementType_InheritingAnonBox, 853 PseudoElement::HorizontalFramesetBorder => CSSPseudoElementType::NonInheritingAnonBox, 854 PseudoElement::VerticalFramesetBorder => CSSPseudoElementType::NonInheritingAnonBox, 855 PseudoElement::MozLineFrame => CSSPseudoElementType_InheritingAnonBox, 856 PseudoElement::ButtonContent => CSSPseudoElementType_InheritingAnonBox, 857 PseudoElement::CellContent => CSSPseudoElementType_InheritingAnonBox, 858 PseudoElement::DropDownList => CSSPseudoElementType_InheritingAnonBox, 859 PseudoElement::FieldsetContent => CSSPseudoElementType_InheritingAnonBox, 860 PseudoElement::FramesetBlank => CSSPseudoElementType::NonInheritingAnonBox, 861 PseudoElement::MozDisplayComboboxControlFrame => CSSPseudoElementType_InheritingAnonBox, 862 PseudoElement::HtmlCanvasContent => CSSPseudoElementType_InheritingAnonBox, 863 PseudoElement::InlineTable => CSSPseudoElementType_InheritingAnonBox, 864 PseudoElement::Table => CSSPseudoElementType_InheritingAnonBox, 865 PseudoElement::TableCell => CSSPseudoElementType_InheritingAnonBox, 866 PseudoElement::TableColGroup => CSSPseudoElementType::NonInheritingAnonBox, 867 PseudoElement::TableCol => CSSPseudoElementType::NonInheritingAnonBox, 868 PseudoElement::TableWrapper => CSSPseudoElementType_InheritingAnonBox, 869 PseudoElement::TableRowGroup => CSSPseudoElementType_InheritingAnonBox, 870 PseudoElement::TableRow => CSSPseudoElementType_InheritingAnonBox, 871 PseudoElement::Canvas => CSSPseudoElementType_InheritingAnonBox, 872 PseudoElement::PageBreak => CSSPseudoElementType::NonInheritingAnonBox, 873 PseudoElement::Page => CSSPseudoElementType_InheritingAnonBox, 874 PseudoElement::PageContent => CSSPseudoElementType_InheritingAnonBox, 875 PseudoElement::PageSequence => CSSPseudoElementType_InheritingAnonBox, 876 PseudoElement::ScrolledContent => CSSPseudoElementType_InheritingAnonBox, 877 PseudoElement::ScrolledCanvas => CSSPseudoElementType_InheritingAnonBox, 878 PseudoElement::ScrolledPageSequence => CSSPseudoElementType_InheritingAnonBox, 879 PseudoElement::ColumnContent => CSSPseudoElementType_InheritingAnonBox, 880 PseudoElement::Viewport => CSSPseudoElementType_InheritingAnonBox, 881 PseudoElement::ViewportScroll => CSSPseudoElementType_InheritingAnonBox, 882 PseudoElement::AnonymousFlexItem => CSSPseudoElementType_InheritingAnonBox, 883 PseudoElement::AnonymousGridItem => CSSPseudoElementType_InheritingAnonBox, 884 PseudoElement::Ruby => CSSPseudoElementType_InheritingAnonBox, 885 PseudoElement::RubyBase => CSSPseudoElementType_InheritingAnonBox, 886 PseudoElement::RubyBaseContainer => CSSPseudoElementType_InheritingAnonBox, 887 PseudoElement::RubyText => CSSPseudoElementType_InheritingAnonBox, 888 PseudoElement::RubyTextContainer => CSSPseudoElementType_InheritingAnonBox, 889 PseudoElement::MozTreeColumn(..) => CSSPseudoElementType::XULTree, 890 PseudoElement::MozTreeRow(..) => CSSPseudoElementType::XULTree, 891 PseudoElement::MozTreeSeparator(..) => CSSPseudoElementType::XULTree, 892 PseudoElement::MozTreeCell(..) => CSSPseudoElementType::XULTree, 893 PseudoElement::MozTreeIndentation(..) => CSSPseudoElementType::XULTree, 894 PseudoElement::MozTreeLine(..) => CSSPseudoElementType::XULTree, 895 PseudoElement::MozTreeTwisty(..) => CSSPseudoElementType::XULTree, 896 PseudoElement::MozTreeImage(..) => CSSPseudoElementType::XULTree, 897 PseudoElement::MozTreeCellText(..) => CSSPseudoElementType::XULTree, 898 PseudoElement::MozTreeCheckbox(..) => CSSPseudoElementType::XULTree, 899 PseudoElement::MozTreeDropFeedback(..) => CSSPseudoElementType::XULTree, 900 PseudoElement::MozSVGMarkerAnonChild => CSSPseudoElementType_InheritingAnonBox, 901 PseudoElement::MozSVGOuterSVGAnonChild => CSSPseudoElementType_InheritingAnonBox, 902 PseudoElement::MozSVGForeignContent => CSSPseudoElementType_InheritingAnonBox, 903 PseudoElement::MozSVGText => CSSPseudoElementType_InheritingAnonBox, 904 } 905 } 906 907 /// Get a PseudoInfo for a pseudo pseudo_info(&self) -> (*mut structs::nsAtom, CSSPseudoElementType)908 pub fn pseudo_info(&self) -> (*mut structs::nsAtom, CSSPseudoElementType) { 909 (self.atom().as_ptr(), self.pseudo_type()) 910 } 911 912 /// Get the argument list of a tree pseudo-element. 913 #[inline] tree_pseudo_args(&self) -> Option<&[Atom]>914 pub fn tree_pseudo_args(&self) -> Option<&[Atom]> { 915 match *self { 916 PseudoElement::MozTreeColumn(ref args) => Some(args), 917 PseudoElement::MozTreeRow(ref args) => Some(args), 918 PseudoElement::MozTreeSeparator(ref args) => Some(args), 919 PseudoElement::MozTreeCell(ref args) => Some(args), 920 PseudoElement::MozTreeIndentation(ref args) => Some(args), 921 PseudoElement::MozTreeLine(ref args) => Some(args), 922 PseudoElement::MozTreeTwisty(ref args) => Some(args), 923 PseudoElement::MozTreeImage(ref args) => Some(args), 924 PseudoElement::MozTreeCellText(ref args) => Some(args), 925 PseudoElement::MozTreeCheckbox(ref args) => Some(args), 926 PseudoElement::MozTreeDropFeedback(ref args) => Some(args), 927 _ => None, 928 } 929 } 930 931 /// Construct a pseudo-element from an `Atom`. 932 #[inline] from_atom(atom: &Atom) -> Option<Self>933 pub fn from_atom(atom: &Atom) -> Option<Self> { 934 if atom == &atom!(":after") { 935 return Some(PseudoElement::After); 936 } 937 if atom == &atom!(":before") { 938 return Some(PseudoElement::Before); 939 } 940 if atom == &atom!(":backdrop") { 941 return Some(PseudoElement::Backdrop); 942 } 943 if atom == &atom!(":cue") { 944 return Some(PseudoElement::Cue); 945 } 946 if atom == &atom!(":first-letter") { 947 return Some(PseudoElement::FirstLetter); 948 } 949 if atom == &atom!(":first-line") { 950 return Some(PseudoElement::FirstLine); 951 } 952 if atom == &atom!(":-moz-selection") { 953 return Some(PseudoElement::MozSelection); 954 } 955 if atom == &atom!(":-moz-focus-inner") { 956 return Some(PseudoElement::MozFocusInner); 957 } 958 if atom == &atom!(":-moz-focus-outer") { 959 return Some(PseudoElement::MozFocusOuter); 960 } 961 if atom == &atom!(":-moz-list-bullet") { 962 return Some(PseudoElement::MozListBullet); 963 } 964 if atom == &atom!(":-moz-list-number") { 965 return Some(PseudoElement::MozListNumber); 966 } 967 if atom == &atom!(":-moz-math-anonymous") { 968 return Some(PseudoElement::MozMathAnonymous); 969 } 970 if atom == &atom!(":-moz-number-wrapper") { 971 return Some(PseudoElement::MozNumberWrapper); 972 } 973 if atom == &atom!(":-moz-number-text") { 974 return Some(PseudoElement::MozNumberText); 975 } 976 if atom == &atom!(":-moz-number-spin-box") { 977 return Some(PseudoElement::MozNumberSpinBox); 978 } 979 if atom == &atom!(":-moz-number-spin-up") { 980 return Some(PseudoElement::MozNumberSpinUp); 981 } 982 if atom == &atom!(":-moz-number-spin-down") { 983 return Some(PseudoElement::MozNumberSpinDown); 984 } 985 if atom == &atom!(":-moz-progress-bar") { 986 return Some(PseudoElement::MozProgressBar); 987 } 988 if atom == &atom!(":-moz-range-track") { 989 return Some(PseudoElement::MozRangeTrack); 990 } 991 if atom == &atom!(":-moz-range-progress") { 992 return Some(PseudoElement::MozRangeProgress); 993 } 994 if atom == &atom!(":-moz-range-thumb") { 995 return Some(PseudoElement::MozRangeThumb); 996 } 997 if atom == &atom!(":-moz-meter-bar") { 998 return Some(PseudoElement::MozMeterBar); 999 } 1000 if atom == &atom!(":-moz-placeholder") { 1001 return Some(PseudoElement::MozPlaceholder); 1002 } 1003 if atom == &atom!(":placeholder") { 1004 return Some(PseudoElement::Placeholder); 1005 } 1006 if atom == &atom!(":-moz-color-swatch") { 1007 return Some(PseudoElement::MozColorSwatch); 1008 } 1009 if atom == &atom!(":-moz-text") { 1010 return Some(PseudoElement::MozText); 1011 } 1012 if atom == &atom!(":-moz-oof-placeholder") { 1013 return Some(PseudoElement::OofPlaceholder); 1014 } 1015 if atom == &atom!(":-moz-first-letter-continuation") { 1016 return Some(PseudoElement::FirstLetterContinuation); 1017 } 1018 if atom == &atom!(":-moz-block-inside-inline-wrapper") { 1019 return Some(PseudoElement::MozBlockInsideInlineWrapper); 1020 } 1021 if atom == &atom!(":-moz-mathml-anonymous-block") { 1022 return Some(PseudoElement::MozMathMLAnonymousBlock); 1023 } 1024 if atom == &atom!(":-moz-xul-anonymous-block") { 1025 return Some(PseudoElement::MozXULAnonymousBlock); 1026 } 1027 if atom == &atom!(":-moz-hframeset-border") { 1028 return Some(PseudoElement::HorizontalFramesetBorder); 1029 } 1030 if atom == &atom!(":-moz-vframeset-border") { 1031 return Some(PseudoElement::VerticalFramesetBorder); 1032 } 1033 if atom == &atom!(":-moz-line-frame") { 1034 return Some(PseudoElement::MozLineFrame); 1035 } 1036 if atom == &atom!(":-moz-button-content") { 1037 return Some(PseudoElement::ButtonContent); 1038 } 1039 if atom == &atom!(":-moz-cell-content") { 1040 return Some(PseudoElement::CellContent); 1041 } 1042 if atom == &atom!(":-moz-dropdown-list") { 1043 return Some(PseudoElement::DropDownList); 1044 } 1045 if atom == &atom!(":-moz-fieldset-content") { 1046 return Some(PseudoElement::FieldsetContent); 1047 } 1048 if atom == &atom!(":-moz-frameset-blank") { 1049 return Some(PseudoElement::FramesetBlank); 1050 } 1051 if atom == &atom!(":-moz-display-comboboxcontrol-frame") { 1052 return Some(PseudoElement::MozDisplayComboboxControlFrame); 1053 } 1054 if atom == &atom!(":-moz-html-canvas-content") { 1055 return Some(PseudoElement::HtmlCanvasContent); 1056 } 1057 if atom == &atom!(":-moz-inline-table") { 1058 return Some(PseudoElement::InlineTable); 1059 } 1060 if atom == &atom!(":-moz-table") { 1061 return Some(PseudoElement::Table); 1062 } 1063 if atom == &atom!(":-moz-table-cell") { 1064 return Some(PseudoElement::TableCell); 1065 } 1066 if atom == &atom!(":-moz-table-column-group") { 1067 return Some(PseudoElement::TableColGroup); 1068 } 1069 if atom == &atom!(":-moz-table-column") { 1070 return Some(PseudoElement::TableCol); 1071 } 1072 if atom == &atom!(":-moz-table-wrapper") { 1073 return Some(PseudoElement::TableWrapper); 1074 } 1075 if atom == &atom!(":-moz-table-row-group") { 1076 return Some(PseudoElement::TableRowGroup); 1077 } 1078 if atom == &atom!(":-moz-table-row") { 1079 return Some(PseudoElement::TableRow); 1080 } 1081 if atom == &atom!(":-moz-canvas") { 1082 return Some(PseudoElement::Canvas); 1083 } 1084 if atom == &atom!(":-moz-pagebreak") { 1085 return Some(PseudoElement::PageBreak); 1086 } 1087 if atom == &atom!(":-moz-page") { 1088 return Some(PseudoElement::Page); 1089 } 1090 if atom == &atom!(":-moz-pagecontent") { 1091 return Some(PseudoElement::PageContent); 1092 } 1093 if atom == &atom!(":-moz-page-sequence") { 1094 return Some(PseudoElement::PageSequence); 1095 } 1096 if atom == &atom!(":-moz-scrolled-content") { 1097 return Some(PseudoElement::ScrolledContent); 1098 } 1099 if atom == &atom!(":-moz-scrolled-canvas") { 1100 return Some(PseudoElement::ScrolledCanvas); 1101 } 1102 if atom == &atom!(":-moz-scrolled-page-sequence") { 1103 return Some(PseudoElement::ScrolledPageSequence); 1104 } 1105 if atom == &atom!(":-moz-column-content") { 1106 return Some(PseudoElement::ColumnContent); 1107 } 1108 if atom == &atom!(":-moz-viewport") { 1109 return Some(PseudoElement::Viewport); 1110 } 1111 if atom == &atom!(":-moz-viewport-scroll") { 1112 return Some(PseudoElement::ViewportScroll); 1113 } 1114 if atom == &atom!(":-moz-anonymous-flex-item") { 1115 return Some(PseudoElement::AnonymousFlexItem); 1116 } 1117 if atom == &atom!(":-moz-anonymous-grid-item") { 1118 return Some(PseudoElement::AnonymousGridItem); 1119 } 1120 if atom == &atom!(":-moz-ruby") { 1121 return Some(PseudoElement::Ruby); 1122 } 1123 if atom == &atom!(":-moz-ruby-base") { 1124 return Some(PseudoElement::RubyBase); 1125 } 1126 if atom == &atom!(":-moz-ruby-base-container") { 1127 return Some(PseudoElement::RubyBaseContainer); 1128 } 1129 if atom == &atom!(":-moz-ruby-text") { 1130 return Some(PseudoElement::RubyText); 1131 } 1132 if atom == &atom!(":-moz-ruby-text-container") { 1133 return Some(PseudoElement::RubyTextContainer); 1134 } 1135 // We cannot generate PseudoElement::MozTreeColumn(..) from just an atom. 1136 // We cannot generate PseudoElement::MozTreeRow(..) from just an atom. 1137 // We cannot generate PseudoElement::MozTreeSeparator(..) from just an atom. 1138 // We cannot generate PseudoElement::MozTreeCell(..) from just an atom. 1139 // We cannot generate PseudoElement::MozTreeIndentation(..) from just an atom. 1140 // We cannot generate PseudoElement::MozTreeLine(..) from just an atom. 1141 // We cannot generate PseudoElement::MozTreeTwisty(..) from just an atom. 1142 // We cannot generate PseudoElement::MozTreeImage(..) from just an atom. 1143 // We cannot generate PseudoElement::MozTreeCellText(..) from just an atom. 1144 // We cannot generate PseudoElement::MozTreeCheckbox(..) from just an atom. 1145 // We cannot generate PseudoElement::MozTreeDropFeedback(..) from just an atom. 1146 if atom == &atom!(":-moz-svg-marker-anon-child") { 1147 return Some(PseudoElement::MozSVGMarkerAnonChild); 1148 } 1149 if atom == &atom!(":-moz-svg-outer-svg-anon-child") { 1150 return Some(PseudoElement::MozSVGOuterSVGAnonChild); 1151 } 1152 if atom == &atom!(":-moz-svg-foreign-content") { 1153 return Some(PseudoElement::MozSVGForeignContent); 1154 } 1155 if atom == &atom!(":-moz-svg-text") { 1156 return Some(PseudoElement::MozSVGText); 1157 } 1158 None 1159 } 1160 1161 /// Construct a pseudo-element from an anonymous box `Atom`. 1162 #[inline] from_anon_box_atom(atom: &Atom) -> Option<Self>1163 pub fn from_anon_box_atom(atom: &Atom) -> Option<Self> { 1164 if atom == &atom!(":-moz-text") { 1165 return Some(PseudoElement::MozText); 1166 } 1167 if atom == &atom!(":-moz-oof-placeholder") { 1168 return Some(PseudoElement::OofPlaceholder); 1169 } 1170 if atom == &atom!(":-moz-first-letter-continuation") { 1171 return Some(PseudoElement::FirstLetterContinuation); 1172 } 1173 if atom == &atom!(":-moz-block-inside-inline-wrapper") { 1174 return Some(PseudoElement::MozBlockInsideInlineWrapper); 1175 } 1176 if atom == &atom!(":-moz-mathml-anonymous-block") { 1177 return Some(PseudoElement::MozMathMLAnonymousBlock); 1178 } 1179 if atom == &atom!(":-moz-xul-anonymous-block") { 1180 return Some(PseudoElement::MozXULAnonymousBlock); 1181 } 1182 if atom == &atom!(":-moz-hframeset-border") { 1183 return Some(PseudoElement::HorizontalFramesetBorder); 1184 } 1185 if atom == &atom!(":-moz-vframeset-border") { 1186 return Some(PseudoElement::VerticalFramesetBorder); 1187 } 1188 if atom == &atom!(":-moz-line-frame") { 1189 return Some(PseudoElement::MozLineFrame); 1190 } 1191 if atom == &atom!(":-moz-button-content") { 1192 return Some(PseudoElement::ButtonContent); 1193 } 1194 if atom == &atom!(":-moz-cell-content") { 1195 return Some(PseudoElement::CellContent); 1196 } 1197 if atom == &atom!(":-moz-dropdown-list") { 1198 return Some(PseudoElement::DropDownList); 1199 } 1200 if atom == &atom!(":-moz-fieldset-content") { 1201 return Some(PseudoElement::FieldsetContent); 1202 } 1203 if atom == &atom!(":-moz-frameset-blank") { 1204 return Some(PseudoElement::FramesetBlank); 1205 } 1206 if atom == &atom!(":-moz-display-comboboxcontrol-frame") { 1207 return Some(PseudoElement::MozDisplayComboboxControlFrame); 1208 } 1209 if atom == &atom!(":-moz-html-canvas-content") { 1210 return Some(PseudoElement::HtmlCanvasContent); 1211 } 1212 if atom == &atom!(":-moz-inline-table") { 1213 return Some(PseudoElement::InlineTable); 1214 } 1215 if atom == &atom!(":-moz-table") { 1216 return Some(PseudoElement::Table); 1217 } 1218 if atom == &atom!(":-moz-table-cell") { 1219 return Some(PseudoElement::TableCell); 1220 } 1221 if atom == &atom!(":-moz-table-column-group") { 1222 return Some(PseudoElement::TableColGroup); 1223 } 1224 if atom == &atom!(":-moz-table-column") { 1225 return Some(PseudoElement::TableCol); 1226 } 1227 if atom == &atom!(":-moz-table-wrapper") { 1228 return Some(PseudoElement::TableWrapper); 1229 } 1230 if atom == &atom!(":-moz-table-row-group") { 1231 return Some(PseudoElement::TableRowGroup); 1232 } 1233 if atom == &atom!(":-moz-table-row") { 1234 return Some(PseudoElement::TableRow); 1235 } 1236 if atom == &atom!(":-moz-canvas") { 1237 return Some(PseudoElement::Canvas); 1238 } 1239 if atom == &atom!(":-moz-pagebreak") { 1240 return Some(PseudoElement::PageBreak); 1241 } 1242 if atom == &atom!(":-moz-page") { 1243 return Some(PseudoElement::Page); 1244 } 1245 if atom == &atom!(":-moz-pagecontent") { 1246 return Some(PseudoElement::PageContent); 1247 } 1248 if atom == &atom!(":-moz-page-sequence") { 1249 return Some(PseudoElement::PageSequence); 1250 } 1251 if atom == &atom!(":-moz-scrolled-content") { 1252 return Some(PseudoElement::ScrolledContent); 1253 } 1254 if atom == &atom!(":-moz-scrolled-canvas") { 1255 return Some(PseudoElement::ScrolledCanvas); 1256 } 1257 if atom == &atom!(":-moz-scrolled-page-sequence") { 1258 return Some(PseudoElement::ScrolledPageSequence); 1259 } 1260 if atom == &atom!(":-moz-column-content") { 1261 return Some(PseudoElement::ColumnContent); 1262 } 1263 if atom == &atom!(":-moz-viewport") { 1264 return Some(PseudoElement::Viewport); 1265 } 1266 if atom == &atom!(":-moz-viewport-scroll") { 1267 return Some(PseudoElement::ViewportScroll); 1268 } 1269 if atom == &atom!(":-moz-anonymous-flex-item") { 1270 return Some(PseudoElement::AnonymousFlexItem); 1271 } 1272 if atom == &atom!(":-moz-anonymous-grid-item") { 1273 return Some(PseudoElement::AnonymousGridItem); 1274 } 1275 if atom == &atom!(":-moz-ruby") { 1276 return Some(PseudoElement::Ruby); 1277 } 1278 if atom == &atom!(":-moz-ruby-base") { 1279 return Some(PseudoElement::RubyBase); 1280 } 1281 if atom == &atom!(":-moz-ruby-base-container") { 1282 return Some(PseudoElement::RubyBaseContainer); 1283 } 1284 if atom == &atom!(":-moz-ruby-text") { 1285 return Some(PseudoElement::RubyText); 1286 } 1287 if atom == &atom!(":-moz-ruby-text-container") { 1288 return Some(PseudoElement::RubyTextContainer); 1289 } 1290 // We cannot generate PseudoElement::MozTreeColumn(..) from just an atom. 1291 // We cannot generate PseudoElement::MozTreeRow(..) from just an atom. 1292 // We cannot generate PseudoElement::MozTreeSeparator(..) from just an atom. 1293 // We cannot generate PseudoElement::MozTreeCell(..) from just an atom. 1294 // We cannot generate PseudoElement::MozTreeIndentation(..) from just an atom. 1295 // We cannot generate PseudoElement::MozTreeLine(..) from just an atom. 1296 // We cannot generate PseudoElement::MozTreeTwisty(..) from just an atom. 1297 // We cannot generate PseudoElement::MozTreeImage(..) from just an atom. 1298 // We cannot generate PseudoElement::MozTreeCellText(..) from just an atom. 1299 // We cannot generate PseudoElement::MozTreeCheckbox(..) from just an atom. 1300 // We cannot generate PseudoElement::MozTreeDropFeedback(..) from just an atom. 1301 if atom == &atom!(":-moz-svg-marker-anon-child") { 1302 return Some(PseudoElement::MozSVGMarkerAnonChild); 1303 } 1304 if atom == &atom!(":-moz-svg-outer-svg-anon-child") { 1305 return Some(PseudoElement::MozSVGOuterSVGAnonChild); 1306 } 1307 if atom == &atom!(":-moz-svg-foreign-content") { 1308 return Some(PseudoElement::MozSVGForeignContent); 1309 } 1310 if atom == &atom!(":-moz-svg-text") { 1311 return Some(PseudoElement::MozSVGText); 1312 } 1313 None 1314 } 1315 1316 /// Construct a tree pseudo-element from atom and args. 1317 #[inline] from_tree_pseudo_atom(atom: &Atom, args: Box<[Atom]>) -> Option<Self>1318 pub fn from_tree_pseudo_atom(atom: &Atom, args: Box<[Atom]>) -> Option<Self> { 1319 if atom == &atom!(":-moz-tree-column") { 1320 return Some(PseudoElement::MozTreeColumn(args)); 1321 } 1322 if atom == &atom!(":-moz-tree-row") { 1323 return Some(PseudoElement::MozTreeRow(args)); 1324 } 1325 if atom == &atom!(":-moz-tree-separator") { 1326 return Some(PseudoElement::MozTreeSeparator(args)); 1327 } 1328 if atom == &atom!(":-moz-tree-cell") { 1329 return Some(PseudoElement::MozTreeCell(args)); 1330 } 1331 if atom == &atom!(":-moz-tree-indentation") { 1332 return Some(PseudoElement::MozTreeIndentation(args)); 1333 } 1334 if atom == &atom!(":-moz-tree-line") { 1335 return Some(PseudoElement::MozTreeLine(args)); 1336 } 1337 if atom == &atom!(":-moz-tree-twisty") { 1338 return Some(PseudoElement::MozTreeTwisty(args)); 1339 } 1340 if atom == &atom!(":-moz-tree-image") { 1341 return Some(PseudoElement::MozTreeImage(args)); 1342 } 1343 if atom == &atom!(":-moz-tree-cell-text") { 1344 return Some(PseudoElement::MozTreeCellText(args)); 1345 } 1346 if atom == &atom!(":-moz-tree-checkbox") { 1347 return Some(PseudoElement::MozTreeCheckbox(args)); 1348 } 1349 if atom == &atom!(":-moz-tree-drop-feedback") { 1350 return Some(PseudoElement::MozTreeDropFeedback(args)); 1351 } 1352 None 1353 } 1354 1355 /// Constructs an atom from a string of text, and whether we're in a 1356 /// user-agent stylesheet. 1357 /// 1358 /// If we're not in a user-agent stylesheet, we will never parse anonymous 1359 /// box pseudo-elements. 1360 /// 1361 /// Returns `None` if the pseudo-element is not recognised. 1362 #[inline] from_slice(name: &str) -> Option<Self>1363 pub fn from_slice(name: &str) -> Option<Self> { 1364 // We don't need to support tree pseudos because functional 1365 // pseudo-elements needs arguments, and thus should be created 1366 // via other methods. 1367 match_ignore_ascii_case! { name, 1368 "after" => { 1369 return Some(PseudoElement::After) 1370 } 1371 "before" => { 1372 return Some(PseudoElement::Before) 1373 } 1374 "backdrop" => { 1375 return Some(PseudoElement::Backdrop) 1376 } 1377 "cue" => { 1378 return Some(PseudoElement::Cue) 1379 } 1380 "first-letter" => { 1381 return Some(PseudoElement::FirstLetter) 1382 } 1383 "first-line" => { 1384 return Some(PseudoElement::FirstLine) 1385 } 1386 "-moz-selection" => { 1387 return Some(PseudoElement::MozSelection) 1388 } 1389 "-moz-focus-inner" => { 1390 return Some(PseudoElement::MozFocusInner) 1391 } 1392 "-moz-focus-outer" => { 1393 return Some(PseudoElement::MozFocusOuter) 1394 } 1395 "-moz-list-bullet" => { 1396 return Some(PseudoElement::MozListBullet) 1397 } 1398 "-moz-list-number" => { 1399 return Some(PseudoElement::MozListNumber) 1400 } 1401 "-moz-math-anonymous" => { 1402 return Some(PseudoElement::MozMathAnonymous) 1403 } 1404 "-moz-number-wrapper" => { 1405 return Some(PseudoElement::MozNumberWrapper) 1406 } 1407 "-moz-number-text" => { 1408 return Some(PseudoElement::MozNumberText) 1409 } 1410 "-moz-number-spin-box" => { 1411 return Some(PseudoElement::MozNumberSpinBox) 1412 } 1413 "-moz-number-spin-up" => { 1414 return Some(PseudoElement::MozNumberSpinUp) 1415 } 1416 "-moz-number-spin-down" => { 1417 return Some(PseudoElement::MozNumberSpinDown) 1418 } 1419 "-moz-progress-bar" => { 1420 return Some(PseudoElement::MozProgressBar) 1421 } 1422 "-moz-range-track" => { 1423 return Some(PseudoElement::MozRangeTrack) 1424 } 1425 "-moz-range-progress" => { 1426 return Some(PseudoElement::MozRangeProgress) 1427 } 1428 "-moz-range-thumb" => { 1429 return Some(PseudoElement::MozRangeThumb) 1430 } 1431 "-moz-meter-bar" => { 1432 return Some(PseudoElement::MozMeterBar) 1433 } 1434 "-moz-placeholder" => { 1435 return Some(PseudoElement::MozPlaceholder) 1436 } 1437 "placeholder" => { 1438 return Some(PseudoElement::Placeholder) 1439 } 1440 "-moz-color-swatch" => { 1441 return Some(PseudoElement::MozColorSwatch) 1442 } 1443 "-moz-text" => { 1444 return Some(PseudoElement::MozText) 1445 } 1446 "-moz-oof-placeholder" => { 1447 return Some(PseudoElement::OofPlaceholder) 1448 } 1449 "-moz-first-letter-continuation" => { 1450 return Some(PseudoElement::FirstLetterContinuation) 1451 } 1452 "-moz-block-inside-inline-wrapper" => { 1453 return Some(PseudoElement::MozBlockInsideInlineWrapper) 1454 } 1455 "-moz-mathml-anonymous-block" => { 1456 return Some(PseudoElement::MozMathMLAnonymousBlock) 1457 } 1458 "-moz-xul-anonymous-block" => { 1459 return Some(PseudoElement::MozXULAnonymousBlock) 1460 } 1461 "-moz-hframeset-border" => { 1462 return Some(PseudoElement::HorizontalFramesetBorder) 1463 } 1464 "-moz-vframeset-border" => { 1465 return Some(PseudoElement::VerticalFramesetBorder) 1466 } 1467 "-moz-line-frame" => { 1468 return Some(PseudoElement::MozLineFrame) 1469 } 1470 "-moz-button-content" => { 1471 return Some(PseudoElement::ButtonContent) 1472 } 1473 "-moz-cell-content" => { 1474 return Some(PseudoElement::CellContent) 1475 } 1476 "-moz-dropdown-list" => { 1477 return Some(PseudoElement::DropDownList) 1478 } 1479 "-moz-fieldset-content" => { 1480 return Some(PseudoElement::FieldsetContent) 1481 } 1482 "-moz-frameset-blank" => { 1483 return Some(PseudoElement::FramesetBlank) 1484 } 1485 "-moz-display-comboboxcontrol-frame" => { 1486 return Some(PseudoElement::MozDisplayComboboxControlFrame) 1487 } 1488 "-moz-html-canvas-content" => { 1489 return Some(PseudoElement::HtmlCanvasContent) 1490 } 1491 "-moz-inline-table" => { 1492 return Some(PseudoElement::InlineTable) 1493 } 1494 "-moz-table" => { 1495 return Some(PseudoElement::Table) 1496 } 1497 "-moz-table-cell" => { 1498 return Some(PseudoElement::TableCell) 1499 } 1500 "-moz-table-column-group" => { 1501 return Some(PseudoElement::TableColGroup) 1502 } 1503 "-moz-table-column" => { 1504 return Some(PseudoElement::TableCol) 1505 } 1506 "-moz-table-wrapper" => { 1507 return Some(PseudoElement::TableWrapper) 1508 } 1509 "-moz-table-row-group" => { 1510 return Some(PseudoElement::TableRowGroup) 1511 } 1512 "-moz-table-row" => { 1513 return Some(PseudoElement::TableRow) 1514 } 1515 "-moz-canvas" => { 1516 return Some(PseudoElement::Canvas) 1517 } 1518 "-moz-pagebreak" => { 1519 return Some(PseudoElement::PageBreak) 1520 } 1521 "-moz-page" => { 1522 return Some(PseudoElement::Page) 1523 } 1524 "-moz-pagecontent" => { 1525 return Some(PseudoElement::PageContent) 1526 } 1527 "-moz-page-sequence" => { 1528 return Some(PseudoElement::PageSequence) 1529 } 1530 "-moz-scrolled-content" => { 1531 return Some(PseudoElement::ScrolledContent) 1532 } 1533 "-moz-scrolled-canvas" => { 1534 return Some(PseudoElement::ScrolledCanvas) 1535 } 1536 "-moz-scrolled-page-sequence" => { 1537 return Some(PseudoElement::ScrolledPageSequence) 1538 } 1539 "-moz-column-content" => { 1540 return Some(PseudoElement::ColumnContent) 1541 } 1542 "-moz-viewport" => { 1543 return Some(PseudoElement::Viewport) 1544 } 1545 "-moz-viewport-scroll" => { 1546 return Some(PseudoElement::ViewportScroll) 1547 } 1548 "-moz-anonymous-flex-item" => { 1549 return Some(PseudoElement::AnonymousFlexItem) 1550 } 1551 "-moz-anonymous-grid-item" => { 1552 return Some(PseudoElement::AnonymousGridItem) 1553 } 1554 "-moz-ruby" => { 1555 return Some(PseudoElement::Ruby) 1556 } 1557 "-moz-ruby-base" => { 1558 return Some(PseudoElement::RubyBase) 1559 } 1560 "-moz-ruby-base-container" => { 1561 return Some(PseudoElement::RubyBaseContainer) 1562 } 1563 "-moz-ruby-text" => { 1564 return Some(PseudoElement::RubyText) 1565 } 1566 "-moz-ruby-text-container" => { 1567 return Some(PseudoElement::RubyTextContainer) 1568 } 1569 "-moz-svg-marker-anon-child" => { 1570 return Some(PseudoElement::MozSVGMarkerAnonChild) 1571 } 1572 "-moz-svg-outer-svg-anon-child" => { 1573 return Some(PseudoElement::MozSVGOuterSVGAnonChild) 1574 } 1575 "-moz-svg-foreign-content" => { 1576 return Some(PseudoElement::MozSVGForeignContent) 1577 } 1578 "-moz-svg-text" => { 1579 return Some(PseudoElement::MozSVGText) 1580 } 1581 _ => { 1582 // FIXME: -moz-tree check should probably be 1583 // ascii-case-insensitive. 1584 if name.starts_with("-moz-tree-") { 1585 return PseudoElement::tree_pseudo_element(name, Box::new([])) 1586 } 1587 } 1588 } 1589 1590 None 1591 } 1592 1593 /// Constructs a tree pseudo-element from the given name and arguments. 1594 /// "name" must start with "-moz-tree-". 1595 /// 1596 /// Returns `None` if the pseudo-element is not recognized. 1597 #[inline] tree_pseudo_element(name: &str, args: Box<[Atom]>) -> Option<Self>1598 pub fn tree_pseudo_element(name: &str, args: Box<[Atom]>) -> Option<Self> { 1599 debug_assert!(name.starts_with("-moz-tree-")); 1600 let tree_part = &name[10..]; 1601 if tree_part.eq_ignore_ascii_case("column") { 1602 return Some(PseudoElement::MozTreeColumn(args)); 1603 } 1604 if tree_part.eq_ignore_ascii_case("row") { 1605 return Some(PseudoElement::MozTreeRow(args)); 1606 } 1607 if tree_part.eq_ignore_ascii_case("separator") { 1608 return Some(PseudoElement::MozTreeSeparator(args)); 1609 } 1610 if tree_part.eq_ignore_ascii_case("cell") { 1611 return Some(PseudoElement::MozTreeCell(args)); 1612 } 1613 if tree_part.eq_ignore_ascii_case("indentation") { 1614 return Some(PseudoElement::MozTreeIndentation(args)); 1615 } 1616 if tree_part.eq_ignore_ascii_case("line") { 1617 return Some(PseudoElement::MozTreeLine(args)); 1618 } 1619 if tree_part.eq_ignore_ascii_case("twisty") { 1620 return Some(PseudoElement::MozTreeTwisty(args)); 1621 } 1622 if tree_part.eq_ignore_ascii_case("image") { 1623 return Some(PseudoElement::MozTreeImage(args)); 1624 } 1625 if tree_part.eq_ignore_ascii_case("cell-text") { 1626 return Some(PseudoElement::MozTreeCellText(args)); 1627 } 1628 if tree_part.eq_ignore_ascii_case("checkbox") { 1629 return Some(PseudoElement::MozTreeCheckbox(args)); 1630 } 1631 if tree_part.eq_ignore_ascii_case("drop-feedback") { 1632 return Some(PseudoElement::MozTreeDropFeedback(args)); 1633 } 1634 None 1635 } 1636 } 1637 1638 impl ToCss for PseudoElement { to_css<W>(&self, dest: &mut W) -> fmt::Result where W: fmt::Write1639 fn to_css<W>(&self, dest: &mut W) -> fmt::Result where W: fmt::Write { 1640 dest.write_char(':')?; 1641 match *self { 1642 PseudoElement::After => dest.write_str(":after")?, 1643 PseudoElement::Before => dest.write_str(":before")?, 1644 PseudoElement::Backdrop => dest.write_str(":backdrop")?, 1645 PseudoElement::Cue => dest.write_str(":cue")?, 1646 PseudoElement::FirstLetter => dest.write_str(":first-letter")?, 1647 PseudoElement::FirstLine => dest.write_str(":first-line")?, 1648 PseudoElement::MozSelection => dest.write_str(":-moz-selection")?, 1649 PseudoElement::MozFocusInner => dest.write_str(":-moz-focus-inner")?, 1650 PseudoElement::MozFocusOuter => dest.write_str(":-moz-focus-outer")?, 1651 PseudoElement::MozListBullet => dest.write_str(":-moz-list-bullet")?, 1652 PseudoElement::MozListNumber => dest.write_str(":-moz-list-number")?, 1653 PseudoElement::MozMathAnonymous => dest.write_str(":-moz-math-anonymous")?, 1654 PseudoElement::MozNumberWrapper => dest.write_str(":-moz-number-wrapper")?, 1655 PseudoElement::MozNumberText => dest.write_str(":-moz-number-text")?, 1656 PseudoElement::MozNumberSpinBox => dest.write_str(":-moz-number-spin-box")?, 1657 PseudoElement::MozNumberSpinUp => dest.write_str(":-moz-number-spin-up")?, 1658 PseudoElement::MozNumberSpinDown => dest.write_str(":-moz-number-spin-down")?, 1659 PseudoElement::MozProgressBar => dest.write_str(":-moz-progress-bar")?, 1660 PseudoElement::MozRangeTrack => dest.write_str(":-moz-range-track")?, 1661 PseudoElement::MozRangeProgress => dest.write_str(":-moz-range-progress")?, 1662 PseudoElement::MozRangeThumb => dest.write_str(":-moz-range-thumb")?, 1663 PseudoElement::MozMeterBar => dest.write_str(":-moz-meter-bar")?, 1664 PseudoElement::MozPlaceholder => dest.write_str(":-moz-placeholder")?, 1665 PseudoElement::Placeholder => dest.write_str(":placeholder")?, 1666 PseudoElement::MozColorSwatch => dest.write_str(":-moz-color-swatch")?, 1667 PseudoElement::MozText => dest.write_str(":-moz-text")?, 1668 PseudoElement::OofPlaceholder => dest.write_str(":-moz-oof-placeholder")?, 1669 PseudoElement::FirstLetterContinuation => dest.write_str(":-moz-first-letter-continuation")?, 1670 PseudoElement::MozBlockInsideInlineWrapper => dest.write_str(":-moz-block-inside-inline-wrapper")?, 1671 PseudoElement::MozMathMLAnonymousBlock => dest.write_str(":-moz-mathml-anonymous-block")?, 1672 PseudoElement::MozXULAnonymousBlock => dest.write_str(":-moz-xul-anonymous-block")?, 1673 PseudoElement::HorizontalFramesetBorder => dest.write_str(":-moz-hframeset-border")?, 1674 PseudoElement::VerticalFramesetBorder => dest.write_str(":-moz-vframeset-border")?, 1675 PseudoElement::MozLineFrame => dest.write_str(":-moz-line-frame")?, 1676 PseudoElement::ButtonContent => dest.write_str(":-moz-button-content")?, 1677 PseudoElement::CellContent => dest.write_str(":-moz-cell-content")?, 1678 PseudoElement::DropDownList => dest.write_str(":-moz-dropdown-list")?, 1679 PseudoElement::FieldsetContent => dest.write_str(":-moz-fieldset-content")?, 1680 PseudoElement::FramesetBlank => dest.write_str(":-moz-frameset-blank")?, 1681 PseudoElement::MozDisplayComboboxControlFrame => dest.write_str(":-moz-display-comboboxcontrol-frame")?, 1682 PseudoElement::HtmlCanvasContent => dest.write_str(":-moz-html-canvas-content")?, 1683 PseudoElement::InlineTable => dest.write_str(":-moz-inline-table")?, 1684 PseudoElement::Table => dest.write_str(":-moz-table")?, 1685 PseudoElement::TableCell => dest.write_str(":-moz-table-cell")?, 1686 PseudoElement::TableColGroup => dest.write_str(":-moz-table-column-group")?, 1687 PseudoElement::TableCol => dest.write_str(":-moz-table-column")?, 1688 PseudoElement::TableWrapper => dest.write_str(":-moz-table-wrapper")?, 1689 PseudoElement::TableRowGroup => dest.write_str(":-moz-table-row-group")?, 1690 PseudoElement::TableRow => dest.write_str(":-moz-table-row")?, 1691 PseudoElement::Canvas => dest.write_str(":-moz-canvas")?, 1692 PseudoElement::PageBreak => dest.write_str(":-moz-pagebreak")?, 1693 PseudoElement::Page => dest.write_str(":-moz-page")?, 1694 PseudoElement::PageContent => dest.write_str(":-moz-pagecontent")?, 1695 PseudoElement::PageSequence => dest.write_str(":-moz-page-sequence")?, 1696 PseudoElement::ScrolledContent => dest.write_str(":-moz-scrolled-content")?, 1697 PseudoElement::ScrolledCanvas => dest.write_str(":-moz-scrolled-canvas")?, 1698 PseudoElement::ScrolledPageSequence => dest.write_str(":-moz-scrolled-page-sequence")?, 1699 PseudoElement::ColumnContent => dest.write_str(":-moz-column-content")?, 1700 PseudoElement::Viewport => dest.write_str(":-moz-viewport")?, 1701 PseudoElement::ViewportScroll => dest.write_str(":-moz-viewport-scroll")?, 1702 PseudoElement::AnonymousFlexItem => dest.write_str(":-moz-anonymous-flex-item")?, 1703 PseudoElement::AnonymousGridItem => dest.write_str(":-moz-anonymous-grid-item")?, 1704 PseudoElement::Ruby => dest.write_str(":-moz-ruby")?, 1705 PseudoElement::RubyBase => dest.write_str(":-moz-ruby-base")?, 1706 PseudoElement::RubyBaseContainer => dest.write_str(":-moz-ruby-base-container")?, 1707 PseudoElement::RubyText => dest.write_str(":-moz-ruby-text")?, 1708 PseudoElement::RubyTextContainer => dest.write_str(":-moz-ruby-text-container")?, 1709 PseudoElement::MozTreeColumn(..) => dest.write_str(":-moz-tree-column")?, 1710 PseudoElement::MozTreeRow(..) => dest.write_str(":-moz-tree-row")?, 1711 PseudoElement::MozTreeSeparator(..) => dest.write_str(":-moz-tree-separator")?, 1712 PseudoElement::MozTreeCell(..) => dest.write_str(":-moz-tree-cell")?, 1713 PseudoElement::MozTreeIndentation(..) => dest.write_str(":-moz-tree-indentation")?, 1714 PseudoElement::MozTreeLine(..) => dest.write_str(":-moz-tree-line")?, 1715 PseudoElement::MozTreeTwisty(..) => dest.write_str(":-moz-tree-twisty")?, 1716 PseudoElement::MozTreeImage(..) => dest.write_str(":-moz-tree-image")?, 1717 PseudoElement::MozTreeCellText(..) => dest.write_str(":-moz-tree-cell-text")?, 1718 PseudoElement::MozTreeCheckbox(..) => dest.write_str(":-moz-tree-checkbox")?, 1719 PseudoElement::MozTreeDropFeedback(..) => dest.write_str(":-moz-tree-drop-feedback")?, 1720 PseudoElement::MozSVGMarkerAnonChild => dest.write_str(":-moz-svg-marker-anon-child")?, 1721 PseudoElement::MozSVGOuterSVGAnonChild => dest.write_str(":-moz-svg-outer-svg-anon-child")?, 1722 PseudoElement::MozSVGForeignContent => dest.write_str(":-moz-svg-foreign-content")?, 1723 PseudoElement::MozSVGText => dest.write_str(":-moz-svg-text")?, 1724 } 1725 if let Some(args) = self.tree_pseudo_args() { 1726 if !args.is_empty() { 1727 dest.write_char('(')?; 1728 let mut iter = args.iter(); 1729 if let Some(first) = iter.next() { 1730 serialize_atom_identifier(&first, dest)?; 1731 for item in iter { 1732 dest.write_str(", ")?; 1733 serialize_atom_identifier(item, dest)?; 1734 } 1735 } 1736 dest.write_char(')')?; 1737 } 1738 } 1739 Ok(()) 1740 } 1741 } 1742