Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 894 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 905 { | 905 { |
| 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> | |
| 916 static bool forEachTagSelector(const Functor& functor, const CSSSelector& select or) | |
| 917 { | |
| 918 for (const CSSSelector* current = &selector; current; current = current->tag History()) { | |
| 919 if (functor(*current)) | |
| 920 return true; | |
| 921 if (const CSSSelectorList* selectorList = current->selectorList()) { | |
| 922 for (const CSSSelector* subSelector = selectorList->first(); subSele ctor; subSelector = CSSSelectorList::next(*subSelector)) { | |
| 923 if (forEachTagSelector(functor, *subSelector)) | |
| 924 return true; | |
| 925 } | |
| 926 } | |
| 927 } | |
| 928 | |
| 929 return false; | |
| 930 } | |
| 931 | |
| 932 bool CSSSelector::hasContentPseudo() const | |
| 933 { | |
| 934 return forEachTagSelector([](const CSSSelector& selector) -> bool { | |
| 935 return selector.relationIsAffectedByPseudoContent(); | |
| 936 }, *this); | |
| 937 } | |
| 938 | |
| 939 bool CSSSelector::hasSlottedPseudo() const | |
| 940 { | |
| 941 return forEachTagSelector([](const CSSSelector& selector) -> bool { | |
| 942 return selector.getPseudoType() == CSSSelector::PseudoSlotted; | |
| 943 }, *this); | |
| 944 } | |
| 945 | |
| 946 bool CSSSelector::hasDeepCombinatorOrShadowPseudo() const | |
| 947 { | |
| 948 return forEachTagSelector([](const CSSSelector& selector) -> bool { | |
| 949 return selector.relation() == CSSSelector::ShadowDeep || selector.getPse udoType() == CSSSelector::PseudoShadow; | |
| 950 }, *this); | |
|
kochi
2016/09/02 06:52:52
Wrong indent?
Please be consistent with other case
hayato
2016/09/02 07:11:29
Done
| |
| 951 } | |
| 952 | |
| 953 bool CSSSelector::needsUpdatedDistribution() const | |
| 954 { | |
| 955 return forEachTagSelector([](const CSSSelector& selector) -> bool { | |
| 956 return selector.relationIsAffectedByPseudoContent() || selector.getPseud oType() == CSSSelector::PseudoSlotted || selector.getPseudoType() == CSSSelector ::PseudoHostContext; | |
| 957 }, *this); | |
| 958 } | |
| 959 | |
| 915 CSSSelector::RareData::RareData(const AtomicString& value) | 960 CSSSelector::RareData::RareData(const AtomicString& value) |
| 916 : m_matchingValue(value) | 961 : m_matchingValue(value) |
| 917 , m_serializingValue(value) | 962 , m_serializingValue(value) |
| 918 , m_bits() | 963 , m_bits() |
| 919 , m_attribute(anyQName()) | 964 , m_attribute(anyQName()) |
| 920 , m_argument(nullAtom) | 965 , m_argument(nullAtom) |
| 921 { | 966 { |
| 922 } | 967 } |
| 923 | 968 |
| 924 CSSSelector::RareData::~RareData() | 969 CSSSelector::RareData::~RareData() |
| 925 { | 970 { |
| 926 } | 971 } |
| 927 | 972 |
| 928 // a helper function for checking nth-arguments | 973 // a helper function for checking nth-arguments |
| 929 bool CSSSelector::RareData::matchNth(int count) | 974 bool CSSSelector::RareData::matchNth(int count) |
| 930 { | 975 { |
| 931 if (!nthAValue()) | 976 if (!nthAValue()) |
| 932 return count == nthBValue(); | 977 return count == nthBValue(); |
| 933 if (nthAValue() > 0) { | 978 if (nthAValue() > 0) { |
| 934 if (count < nthBValue()) | 979 if (count < nthBValue()) |
| 935 return false; | 980 return false; |
| 936 return (count - nthBValue()) % nthAValue() == 0; | 981 return (count - nthBValue()) % nthAValue() == 0; |
| 937 } | 982 } |
| 938 if (count > nthBValue()) | 983 if (count > nthBValue()) |
| 939 return false; | 984 return false; |
| 940 return (nthBValue() - count) % (-nthAValue()) == 0; | 985 return (nthBValue() - count) % (-nthAValue()) == 0; |
| 941 } | 986 } |
| 942 | 987 |
| 943 } // namespace blink | 988 } // namespace blink |
| OLD | NEW |