Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(24)

Side by Side Diff: third_party/WebKit/Source/core/css/CSSSelector.cpp

Issue 1523843004: Add support for new CSS ::slotted() pseudo element (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: WIP Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 1999-2003 Lars Knoll (knoll@kde.org) 2 * Copyright (C) 1999-2003 Lars Knoll (knoll@kde.org)
3 * 1999 Waldo Bastian (bastian@kde.org) 3 * 1999 Waldo Bastian (bastian@kde.org)
4 * 2001 Andreas Schlapbach (schlpbch@iam.unibe.ch) 4 * 2001 Andreas Schlapbach (schlpbch@iam.unibe.ch)
5 * 2001-2003 Dirk Mueller (mueller@kde.org) 5 * 2001-2003 Dirk Mueller (mueller@kde.org)
6 * Copyright (C) 2002, 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights reserv ed. 6 * Copyright (C) 2002, 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights reserv ed.
7 * Copyright (C) 2008 David Smith (catfish.man@gmail.com) 7 * Copyright (C) 2008 David Smith (catfish.man@gmail.com)
8 * Copyright (C) 2010 Google Inc. All rights reserved. 8 * Copyright (C) 2010 Google Inc. All rights reserved.
9 * 9 *
10 * This library is free software; you can redistribute it and/or 10 * This library is free software; you can redistribute it and/or
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after
258 case PseudoPastCue: 258 case PseudoPastCue:
259 case PseudoUnresolved: 259 case PseudoUnresolved:
260 case PseudoContent: 260 case PseudoContent:
261 case PseudoHost: 261 case PseudoHost:
262 case PseudoHostContext: 262 case PseudoHostContext:
263 case PseudoShadow: 263 case PseudoShadow:
264 case PseudoFullScreen: 264 case PseudoFullScreen:
265 case PseudoFullScreenAncestor: 265 case PseudoFullScreenAncestor:
266 case PseudoSpatialNavigationFocus: 266 case PseudoSpatialNavigationFocus:
267 case PseudoListBox: 267 case PseudoListBox:
268 case PseudoSlotted:
268 return NOPSEUDO; 269 return NOPSEUDO;
269 } 270 }
270 271
271 ASSERT_NOT_REACHED(); 272 ASSERT_NOT_REACHED();
272 return NOPSEUDO; 273 return NOPSEUDO;
273 } 274 }
274 275
275 // Could be made smaller and faster by replacing pointer with an 276 // Could be made smaller and faster by replacing pointer with an
276 // offset into a string buffer and making the bit fields smaller but 277 // offset into a string buffer and making the bit fields smaller but
277 // that could not be maintained by hand. 278 // that could not be maintained by hand.
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
361 {"-webkit-any", CSSSelector::PseudoAny}, 362 {"-webkit-any", CSSSelector::PseudoAny},
362 {"cue", CSSSelector::PseudoCue}, 363 {"cue", CSSSelector::PseudoCue},
363 {"host", CSSSelector::PseudoHost}, 364 {"host", CSSSelector::PseudoHost},
364 {"host-context", CSSSelector::PseudoHostContext}, 365 {"host-context", CSSSelector::PseudoHostContext},
365 {"lang", CSSSelector::PseudoLang}, 366 {"lang", CSSSelector::PseudoLang},
366 {"not", CSSSelector::PseudoNot}, 367 {"not", CSSSelector::PseudoNot},
367 {"nth-child", CSSSelector::PseudoNthChild}, 368 {"nth-child", CSSSelector::PseudoNthChild},
368 {"nth-last-child", CSSSelector::PseudoNthLastChild}, 369 {"nth-last-child", CSSSelector::PseudoNthLastChild},
369 {"nth-last-of-type", CSSSelector::PseudoNthLastOfType}, 370 {"nth-last-of-type", CSSSelector::PseudoNthLastOfType},
370 {"nth-of-type", CSSSelector::PseudoNthOfType}, 371 {"nth-of-type", CSSSelector::PseudoNthOfType},
372 {"slotted", CSSSelector::PseudoSlotted},
371 }; 373 };
372 374
373 class NameToPseudoCompare { 375 class NameToPseudoCompare {
374 public: 376 public:
375 NameToPseudoCompare(const AtomicString& key) : m_key(key) { ASSERT(m_key.is8 Bit()); } 377 NameToPseudoCompare(const AtomicString& key) : m_key(key) { ASSERT(m_key.is8 Bit()); }
376 378
377 bool operator()(const NameToPseudoStruct& entry, const NameToPseudoStruct&) 379 bool operator()(const NameToPseudoStruct& entry, const NameToPseudoStruct&)
378 { 380 {
379 ASSERT(entry.string); 381 ASSERT(entry.string);
380 const char* key = reinterpret_cast<const char*>(m_key.characters8()); 382 const char* key = reinterpret_cast<const char*>(m_key.characters8());
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
475 case PseudoScrollbar: 477 case PseudoScrollbar:
476 case PseudoScrollbarCorner: 478 case PseudoScrollbarCorner:
477 case PseudoScrollbarButton: 479 case PseudoScrollbarButton:
478 case PseudoScrollbarThumb: 480 case PseudoScrollbarThumb:
479 case PseudoScrollbarTrack: 481 case PseudoScrollbarTrack:
480 case PseudoScrollbarTrackPiece: 482 case PseudoScrollbarTrackPiece:
481 case PseudoSelection: 483 case PseudoSelection:
482 case PseudoWebKitCustomElement: 484 case PseudoWebKitCustomElement:
483 case PseudoContent: 485 case PseudoContent:
484 case PseudoShadow: 486 case PseudoShadow:
487 case PseudoSlotted:
485 if (m_match != PseudoElement) 488 if (m_match != PseudoElement)
486 m_pseudoType = PseudoUnknown; 489 m_pseudoType = PseudoUnknown;
487 break; 490 break;
488 case PseudoFirstPage: 491 case PseudoFirstPage:
489 case PseudoLeftPage: 492 case PseudoLeftPage:
490 case PseudoRightPage: 493 case PseudoRightPage:
491 if (m_match != PagePseudoClass) 494 if (m_match != PagePseudoClass)
492 m_pseudoType = PseudoUnknown; 495 m_pseudoType = PseudoUnknown;
493 break; 496 break;
494 case PseudoActive: 497 case PseudoActive:
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after
723 return tagHistory->selectorText(" > " + str.toString() + rightSide); 726 return tagHistory->selectorText(" > " + str.toString() + rightSide);
724 case ShadowDeep: 727 case ShadowDeep:
725 return tagHistory->selectorText(" /deep/ " + str.toString() + rightS ide); 728 return tagHistory->selectorText(" /deep/ " + str.toString() + rightS ide);
726 case DirectAdjacent: 729 case DirectAdjacent:
727 return tagHistory->selectorText(" + " + str.toString() + rightSide); 730 return tagHistory->selectorText(" + " + str.toString() + rightSide);
728 case IndirectAdjacent: 731 case IndirectAdjacent:
729 return tagHistory->selectorText(" ~ " + str.toString() + rightSide); 732 return tagHistory->selectorText(" ~ " + str.toString() + rightSide);
730 case SubSelector: 733 case SubSelector:
731 ASSERT_NOT_REACHED(); 734 ASSERT_NOT_REACHED();
732 case ShadowPseudo: 735 case ShadowPseudo:
736 case ShadowSlot:
733 return tagHistory->selectorText(str.toString() + rightSide); 737 return tagHistory->selectorText(str.toString() + rightSide);
734 } 738 }
735 } 739 }
736 return str.toString() + rightSide; 740 return str.toString() + rightSide;
737 } 741 }
738 742
739 void CSSSelector::setAttribute(const QualifiedName& value, AttributeMatchType ma tchType) 743 void CSSSelector::setAttribute(const QualifiedName& value, AttributeMatchType ma tchType)
740 { 744 {
741 createRareData(); 745 createRareData();
742 m_data.m_rareData->m_attribute = value; 746 m_data.m_rareData->m_attribute = value;
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
793 case CSSSelector::PseudoFirstChild: 797 case CSSSelector::PseudoFirstChild:
794 case CSSSelector::PseudoLastChild: 798 case CSSSelector::PseudoLastChild:
795 case CSSSelector::PseudoFirstOfType: 799 case CSSSelector::PseudoFirstOfType:
796 case CSSSelector::PseudoLastOfType: 800 case CSSSelector::PseudoLastOfType:
797 case CSSSelector::PseudoOnlyOfType: 801 case CSSSelector::PseudoOnlyOfType:
798 case CSSSelector::PseudoHost: 802 case CSSSelector::PseudoHost:
799 case CSSSelector::PseudoHostContext: 803 case CSSSelector::PseudoHostContext:
800 case CSSSelector::PseudoNot: 804 case CSSSelector::PseudoNot:
801 case CSSSelector::PseudoSpatialNavigationFocus: 805 case CSSSelector::PseudoSpatialNavigationFocus:
802 case CSSSelector::PseudoListBox: 806 case CSSSelector::PseudoListBox:
807 case CSSSelector::PseudoSlotted:
803 return true; 808 return true;
804 default: 809 default:
805 return false; 810 return false;
806 } 811 }
807 } 812 }
808 813
809 bool CSSSelector::isCompound() const 814 bool CSSSelector::isCompound() const
810 { 815 {
811 if (!validateSubSelector(this)) 816 if (!validateSubSelector(this))
812 return false; 817 return false;
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
904 if (count < nthBValue()) 909 if (count < nthBValue())
905 return false; 910 return false;
906 return (count - nthBValue()) % nthAValue() == 0; 911 return (count - nthBValue()) % nthAValue() == 0;
907 } 912 }
908 if (count > nthBValue()) 913 if (count > nthBValue())
909 return false; 914 return false;
910 return (nthBValue() - count) % (-nthAValue()) == 0; 915 return (nthBValue() - count) % (-nthAValue()) == 0;
911 } 916 }
912 917
913 } // namespace blink 918 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698