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

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

Issue 2308313002: Clean up RuleSet::addChildRules() (Closed)
Patch Set: Created 4 years, 3 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
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/css/CSSSelectorList.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 895 matching lines...) Expand 10 before | Expand all | Expand 10 after
906 for (const CSSSelector* current = this; current; current = current->tagHisto ry()) { 906 for (const CSSSelector* current = this; current; current = current->tagHisto ry()) {
907 if (current->match() == PseudoElement) 907 if (current->match() == PseudoElement)
908 return true; 908 return true;
909 if (current->relation() != SubSelector) 909 if (current->relation() != SubSelector)
910 return false; 910 return false;
911 } 911 }
912 return false; 912 return false;
913 } 913 }
914 914
915 template <typename Functor> 915 template <typename Functor>
916 static bool forEachTagSelector(const Functor& functor, const CSSSelector& select or) 916 static bool forEachTagHistory(const Functor& functor, const CSSSelector& selecto r)
917 { 917 {
918 for (const CSSSelector* current = &selector; current; current = current->tag History()) { 918 for (const CSSSelector* current = &selector; current; current = current->tag History()) {
919 if (functor(*current)) 919 if (functor(*current))
920 return true; 920 return true;
921 if (const CSSSelectorList* selectorList = current->selectorList()) { 921 if (const CSSSelectorList* selectorList = current->selectorList()) {
922 for (const CSSSelector* subSelector = selectorList->first(); subSele ctor; subSelector = CSSSelectorList::next(*subSelector)) { 922 for (const CSSSelector* subSelector = selectorList->first(); subSele ctor; subSelector = CSSSelectorList::next(*subSelector)) {
923 if (forEachTagSelector(functor, *subSelector)) 923 if (forEachTagHistory(functor, *subSelector))
924 return true; 924 return true;
925 } 925 }
926 } 926 }
927 } 927 }
928 928
929 return false; 929 return false;
930 } 930 }
931 931
932 bool CSSSelector::hasContentPseudo() const 932 bool CSSSelector::hasContentPseudo() const
933 { 933 {
934 return forEachTagSelector([](const CSSSelector& selector) -> bool { 934 return forEachTagHistory([](const CSSSelector& selector) -> bool {
935 return selector.relationIsAffectedByPseudoContent(); 935 return selector.relationIsAffectedByPseudoContent();
936 }, *this); 936 }, *this);
937 } 937 }
938 938
939 bool CSSSelector::hasSlottedPseudo() const 939 bool CSSSelector::hasSlottedPseudo() const
940 { 940 {
941 return forEachTagSelector([](const CSSSelector& selector) -> bool { 941 return forEachTagHistory([](const CSSSelector& selector) -> bool {
942 return selector.getPseudoType() == CSSSelector::PseudoSlotted; 942 return selector.getPseudoType() == CSSSelector::PseudoSlotted;
943 }, *this); 943 }, *this);
944 } 944 }
945 945
946 bool CSSSelector::hasDeepCombinatorOrShadowPseudo() const 946 bool CSSSelector::hasDeepCombinatorOrShadowPseudo() const
947 { 947 {
948 return forEachTagSelector([](const CSSSelector& selector) -> bool { 948 return forEachTagHistory([](const CSSSelector& selector) -> bool {
949 return selector.relation() == CSSSelector::ShadowDeep || selector.getPse udoType() == CSSSelector::PseudoShadow; 949 return selector.relation() == CSSSelector::ShadowDeep || selector.getPse udoType() == CSSSelector::PseudoShadow;
950 }, *this); 950 }, *this);
951 } 951 }
952 952
953 bool CSSSelector::needsUpdatedDistribution() const 953 bool CSSSelector::needsUpdatedDistribution() const
954 { 954 {
955 return forEachTagSelector([](const CSSSelector& selector) -> bool { 955 return forEachTagHistory([](const CSSSelector& selector) -> bool {
956 return selector.relationIsAffectedByPseudoContent() || selector.getPseud oType() == CSSSelector::PseudoSlotted || selector.getPseudoType() == CSSSelector ::PseudoHostContext; 956 return selector.relationIsAffectedByPseudoContent() || selector.getPseud oType() == CSSSelector::PseudoSlotted || selector.getPseudoType() == CSSSelector ::PseudoHostContext;
957 }, *this); 957 }, *this);
958 } 958 }
959 959
960 CSSSelector::RareData::RareData(const AtomicString& value) 960 CSSSelector::RareData::RareData(const AtomicString& value)
961 : m_matchingValue(value) 961 : m_matchingValue(value)
962 , m_serializingValue(value) 962 , m_serializingValue(value)
963 , m_bits() 963 , m_bits()
964 , m_attribute(anyQName()) 964 , m_attribute(anyQName())
965 , m_argument(nullAtom) 965 , m_argument(nullAtom)
(...skipping 13 matching lines...) Expand all
979 if (count < nthBValue()) 979 if (count < nthBValue())
980 return false; 980 return false;
981 return (count - nthBValue()) % nthAValue() == 0; 981 return (count - nthBValue()) % nthAValue() == 0;
982 } 982 }
983 if (count > nthBValue()) 983 if (count > nthBValue())
984 return false; 984 return false;
985 return (nthBValue() - count) % (-nthAValue()) == 0; 985 return (nthBValue() - count) % (-nthAValue()) == 0;
986 } 986 }
987 987
988 } // namespace blink 988 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/css/CSSSelectorList.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698