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

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: rebase / fix comments for tests (FYI) Created 4 years, 11 months 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 246 matching lines...) Expand 10 before | Expand all | Expand 10 after
257 case PseudoPastCue: 257 case PseudoPastCue:
258 case PseudoUnresolved: 258 case PseudoUnresolved:
259 case PseudoContent: 259 case PseudoContent:
260 case PseudoHost: 260 case PseudoHost:
261 case PseudoHostContext: 261 case PseudoHostContext:
262 case PseudoShadow: 262 case PseudoShadow:
263 case PseudoFullScreen: 263 case PseudoFullScreen:
264 case PseudoFullScreenAncestor: 264 case PseudoFullScreenAncestor:
265 case PseudoSpatialNavigationFocus: 265 case PseudoSpatialNavigationFocus:
266 case PseudoListBox: 266 case PseudoListBox:
267 case PseudoSlotted:
267 return NOPSEUDO; 268 return NOPSEUDO;
268 } 269 }
269 270
270 ASSERT_NOT_REACHED(); 271 ASSERT_NOT_REACHED();
271 return NOPSEUDO; 272 return NOPSEUDO;
272 } 273 }
273 274
274 // Could be made smaller and faster by replacing pointer with an 275 // Could be made smaller and faster by replacing pointer with an
275 // offset into a string buffer and making the bit fields smaller but 276 // offset into a string buffer and making the bit fields smaller but
276 // that could not be maintained by hand. 277 // that could not be maintained by hand.
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
360 {"-webkit-any", CSSSelector::PseudoAny}, 361 {"-webkit-any", CSSSelector::PseudoAny},
361 {"cue", CSSSelector::PseudoCue}, 362 {"cue", CSSSelector::PseudoCue},
362 {"host", CSSSelector::PseudoHost}, 363 {"host", CSSSelector::PseudoHost},
363 {"host-context", CSSSelector::PseudoHostContext}, 364 {"host-context", CSSSelector::PseudoHostContext},
364 {"lang", CSSSelector::PseudoLang}, 365 {"lang", CSSSelector::PseudoLang},
365 {"not", CSSSelector::PseudoNot}, 366 {"not", CSSSelector::PseudoNot},
366 {"nth-child", CSSSelector::PseudoNthChild}, 367 {"nth-child", CSSSelector::PseudoNthChild},
367 {"nth-last-child", CSSSelector::PseudoNthLastChild}, 368 {"nth-last-child", CSSSelector::PseudoNthLastChild},
368 {"nth-last-of-type", CSSSelector::PseudoNthLastOfType}, 369 {"nth-last-of-type", CSSSelector::PseudoNthLastOfType},
369 {"nth-of-type", CSSSelector::PseudoNthOfType}, 370 {"nth-of-type", CSSSelector::PseudoNthOfType},
371 {"slotted", CSSSelector::PseudoSlotted},
370 }; 372 };
371 373
372 class NameToPseudoCompare { 374 class NameToPseudoCompare {
373 public: 375 public:
374 NameToPseudoCompare(const AtomicString& key) : m_key(key) { ASSERT(m_key.is8 Bit()); } 376 NameToPseudoCompare(const AtomicString& key) : m_key(key) { ASSERT(m_key.is8 Bit()); }
375 377
376 bool operator()(const NameToPseudoStruct& entry, const NameToPseudoStruct&) 378 bool operator()(const NameToPseudoStruct& entry, const NameToPseudoStruct&)
377 { 379 {
378 ASSERT(entry.string); 380 ASSERT(entry.string);
379 const char* key = reinterpret_cast<const char*>(m_key.characters8()); 381 const char* key = reinterpret_cast<const char*>(m_key.characters8());
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
474 case PseudoScrollbar: 476 case PseudoScrollbar:
475 case PseudoScrollbarCorner: 477 case PseudoScrollbarCorner:
476 case PseudoScrollbarButton: 478 case PseudoScrollbarButton:
477 case PseudoScrollbarThumb: 479 case PseudoScrollbarThumb:
478 case PseudoScrollbarTrack: 480 case PseudoScrollbarTrack:
479 case PseudoScrollbarTrackPiece: 481 case PseudoScrollbarTrackPiece:
480 case PseudoSelection: 482 case PseudoSelection:
481 case PseudoWebKitCustomElement: 483 case PseudoWebKitCustomElement:
482 case PseudoContent: 484 case PseudoContent:
483 case PseudoShadow: 485 case PseudoShadow:
486 case PseudoSlotted:
484 if (m_match != PseudoElement) 487 if (m_match != PseudoElement)
485 m_pseudoType = PseudoUnknown; 488 m_pseudoType = PseudoUnknown;
486 break; 489 break;
487 case PseudoFirstPage: 490 case PseudoFirstPage:
488 case PseudoLeftPage: 491 case PseudoLeftPage:
489 case PseudoRightPage: 492 case PseudoRightPage:
490 if (m_match != PagePseudoClass) 493 if (m_match != PagePseudoClass)
491 m_pseudoType = PseudoUnknown; 494 m_pseudoType = PseudoUnknown;
492 break; 495 break;
493 case PseudoActive: 496 case PseudoActive:
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after
722 return tagHistory->selectorText(" > " + str.toString() + rightSide); 725 return tagHistory->selectorText(" > " + str.toString() + rightSide);
723 case ShadowDeep: 726 case ShadowDeep:
724 return tagHistory->selectorText(" /deep/ " + str.toString() + rightS ide); 727 return tagHistory->selectorText(" /deep/ " + str.toString() + rightS ide);
725 case DirectAdjacent: 728 case DirectAdjacent:
726 return tagHistory->selectorText(" + " + str.toString() + rightSide); 729 return tagHistory->selectorText(" + " + str.toString() + rightSide);
727 case IndirectAdjacent: 730 case IndirectAdjacent:
728 return tagHistory->selectorText(" ~ " + str.toString() + rightSide); 731 return tagHistory->selectorText(" ~ " + str.toString() + rightSide);
729 case SubSelector: 732 case SubSelector:
730 ASSERT_NOT_REACHED(); 733 ASSERT_NOT_REACHED();
731 case ShadowPseudo: 734 case ShadowPseudo:
735 case ShadowSlot:
732 return tagHistory->selectorText(str.toString() + rightSide); 736 return tagHistory->selectorText(str.toString() + rightSide);
733 } 737 }
734 } 738 }
735 return str.toString() + rightSide; 739 return str.toString() + rightSide;
736 } 740 }
737 741
738 void CSSSelector::setAttribute(const QualifiedName& value, AttributeMatchType ma tchType) 742 void CSSSelector::setAttribute(const QualifiedName& value, AttributeMatchType ma tchType)
739 { 743 {
740 createRareData(); 744 createRareData();
741 m_data.m_rareData->m_attribute = value; 745 m_data.m_rareData->m_attribute = value;
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
792 case CSSSelector::PseudoFirstChild: 796 case CSSSelector::PseudoFirstChild:
793 case CSSSelector::PseudoLastChild: 797 case CSSSelector::PseudoLastChild:
794 case CSSSelector::PseudoFirstOfType: 798 case CSSSelector::PseudoFirstOfType:
795 case CSSSelector::PseudoLastOfType: 799 case CSSSelector::PseudoLastOfType:
796 case CSSSelector::PseudoOnlyOfType: 800 case CSSSelector::PseudoOnlyOfType:
797 case CSSSelector::PseudoHost: 801 case CSSSelector::PseudoHost:
798 case CSSSelector::PseudoHostContext: 802 case CSSSelector::PseudoHostContext:
799 case CSSSelector::PseudoNot: 803 case CSSSelector::PseudoNot:
800 case CSSSelector::PseudoSpatialNavigationFocus: 804 case CSSSelector::PseudoSpatialNavigationFocus:
801 case CSSSelector::PseudoListBox: 805 case CSSSelector::PseudoListBox:
806 case CSSSelector::PseudoSlotted:
802 return true; 807 return true;
803 default: 808 default:
804 return false; 809 return false;
805 } 810 }
806 } 811 }
807 812
808 bool CSSSelector::isCompound() const 813 bool CSSSelector::isCompound() const
809 { 814 {
810 if (!validateSubSelector(this)) 815 if (!validateSubSelector(this))
811 return false; 816 return false;
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
903 if (count < nthBValue()) 908 if (count < nthBValue())
904 return false; 909 return false;
905 return (count - nthBValue()) % nthAValue() == 0; 910 return (count - nthBValue()) % nthAValue() == 0;
906 } 911 }
907 if (count > nthBValue()) 912 if (count > nthBValue())
908 return false; 913 return false;
909 return (nthBValue() - count) % (-nthAValue()) == 0; 914 return (nthBValue() - count) % (-nthAValue()) == 0;
910 } 915 }
911 916
912 } // namespace blink 917 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/css/CSSSelector.h ('k') | third_party/WebKit/Source/core/css/CSSSelectorList.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698