Diff
Modified: trunk/Source/WebCore/ChangeLog (234816 => 234817)
--- trunk/Source/WebCore/ChangeLog 2018-08-13 21:07:55 UTC (rev 234816)
+++ trunk/Source/WebCore/ChangeLog 2018-08-13 21:17:10 UTC (rev 234817)
@@ -1,5 +1,28 @@
2018-08-13 Alex Christensen <[email protected]>
+ Remove unused CSSSelector::parseNth
+ https://bugs.webkit.org/show_bug.cgi?id=188529
+
+ Reviewed by Simon Fraser.
+
+ This was conceptually replaced by the call to setNth in CSSSelectorParser::consumePseudo.
+
+ * css/CSSSelector.cpp:
+ (WebCore::CSSSelector::CSSSelector):
+ (WebCore::CSSSelector::setNth):
+ (WebCore::CSSSelector::nthA const):
+ (WebCore::CSSSelector::nthB const):
+ (WebCore::CSSSelector::parseNth const): Deleted.
+ (WebCore::CSSSelector::RareData::parseNth): Deleted.
+ * css/CSSSelector.h:
+ (WebCore::CSSSelector::CSSSelector):
+ * css/SelectorChecker.cpp:
+ (WebCore::SelectorChecker::checkOne const):
+ * cssjit/SelectorCompiler.cpp:
+ (WebCore::SelectorCompiler::addNthChildType):
+
+2018-08-13 Alex Christensen <[email protected]>
+
Remove unused code in CSSParserSelector/CSSSelector
https://bugs.webkit.org/show_bug.cgi?id=188528
Modified: trunk/Source/WebCore/css/CSSSelector.cpp (234816 => 234817)
--- trunk/Source/WebCore/css/CSSSelector.cpp 2018-08-13 21:07:55 UTC (rev 234816)
+++ trunk/Source/WebCore/css/CSSSelector.cpp 2018-08-13 21:17:10 UTC (rev 234817)
@@ -52,7 +52,6 @@
: m_relation(DescendantSpace)
, m_match(Tag)
, m_pseudoType(0)
- , m_parsedNth(false)
, m_isLastInSelectorList(false)
, m_isLastInTagHistory(true)
, m_hasRareData(false)
@@ -780,22 +779,9 @@
void CSSSelector::setNth(int a, int b)
{
createRareData();
- m_parsedNth = true; // FIXME-NEWPARSER: Can remove this parsed boolean once old parser is gone.
m_data.m_rareData->m_a = a;
m_data.m_rareData->m_b = b;
}
-
-// FIXME-NEWPARSER: All the code to parse nth-child stuff can be removed when
-// the new parser is enabled.
-bool CSSSelector::parseNth() const
-{
- if (!m_hasRareData)
- return false;
- if (m_parsedNth)
- return true;
- m_parsedNth = m_data.m_rareData->parseNth();
- return m_parsedNth;
-}
bool CSSSelector::matchNth(int count) const
{
@@ -806,7 +792,6 @@
int CSSSelector::nthA() const
{
ASSERT(m_hasRareData);
- ASSERT(m_parsedNth);
return m_data.m_rareData->m_a;
}
@@ -813,7 +798,6 @@
int CSSSelector::nthB() const
{
ASSERT(m_hasRareData);
- ASSERT(m_parsedNth);
return m_data.m_rareData->m_b;
}
@@ -829,67 +813,6 @@
CSSSelector::RareData::~RareData() = default;
-// a helper function for parsing nth-arguments
-bool CSSSelector::RareData::parseNth()
-{
- if (m_argument.isEmpty())
- return false;
-
- if (equalLettersIgnoringASCIICase(m_argument, "odd")) {
- m_a = 2;
- m_b = 1;
- } else if (equalLettersIgnoringASCIICase(m_argument, "even")) {
- m_a = 2;
- m_b = 0;
- } else {
- m_a = 0;
- m_b = 0;
-
- size_t n = std::min(m_argument.find('n'), m_argument.find('N'));
- if (n != notFound) {
- if (m_argument[0] == '-') {
- if (n == 1)
- m_a = -1; // -n == -1n
- else {
- bool ok;
- m_a = StringView(m_argument).substring(0, n).toIntStrict(ok);
- if (!ok)
- return false;
- }
- } else if (!n)
- m_a = 1; // n == 1n
- else {
- bool ok;
- m_a = StringView(m_argument).substring(0, n).toIntStrict(ok);
- if (!ok)
- return false;
- }
-
- size_t p = m_argument.find('+', n);
- if (p != notFound) {
- bool ok;
- m_b = StringView(m_argument).substring(p + 1).toIntStrict(ok);
- if (!ok)
- return false;
- } else {
- p = m_argument.find('-', n);
- if (p != notFound) {
- bool ok;
- m_b = -StringView(m_argument).substring(p + 1).toIntStrict(ok);
- if (!ok)
- return false;
- }
- }
- } else {
- bool ok;
- m_b = m_argument.string().toIntStrict(&ok);
- if (!ok)
- return false;
- }
- }
- return true;
-}
-
// a helper function for checking nth-arguments
bool CSSSelector::RareData::matchNth(int count)
{
Modified: trunk/Source/WebCore/css/CSSSelector.h (234816 => 234817)
--- trunk/Source/WebCore/css/CSSSelector.h 2018-08-13 21:07:55 UTC (rev 234816)
+++ trunk/Source/WebCore/css/CSSSelector.h 2018-08-13 21:17:10 UTC (rev 234817)
@@ -248,7 +248,6 @@
void setLangArgumentList(std::unique_ptr<Vector<AtomicString>>);
void setSelectorList(std::unique_ptr<CSSSelectorList>);
- bool parseNth() const;
bool matchNth(int count) const;
int nthA() const;
int nthB() const;
@@ -323,7 +322,6 @@
unsigned m_relation : 4; // enum RelationType.
mutable unsigned m_match : 4; // enum Match.
mutable unsigned m_pseudoType : 8; // PseudoType.
- mutable unsigned m_parsedNth : 1; // Used for :nth-*.
unsigned m_isLastInSelectorList : 1;
unsigned m_isLastInTagHistory : 1;
unsigned m_hasRareData : 1;
@@ -344,7 +342,6 @@
static Ref<RareData> create(AtomicString&& value) { return adoptRef(*new RareData(WTFMove(value))); }
~RareData();
- bool parseNth();
bool matchNth(int count);
// For quirks mode, class and id are case-insensitive. In the case where uppercase
@@ -481,7 +478,6 @@
: m_relation(DescendantSpace)
, m_match(Unknown)
, m_pseudoType(0)
- , m_parsedNth(false)
, m_isLastInSelectorList(false)
, m_isLastInTagHistory(true)
, m_hasRareData(false)
@@ -499,7 +495,6 @@
: m_relation(o.m_relation)
, m_match(o.m_match)
, m_pseudoType(o.m_pseudoType)
- , m_parsedNth(o.m_parsedNth)
, m_isLastInSelectorList(o.m_isLastInSelectorList)
, m_isLastInTagHistory(o.m_isLastInTagHistory)
, m_hasRareData(o.m_hasRareData)
Modified: trunk/Source/WebCore/css/SelectorChecker.cpp (234816 => 234817)
--- trunk/Source/WebCore/css/SelectorChecker.cpp 2018-08-13 21:07:55 UTC (rev 234816)
+++ trunk/Source/WebCore/css/SelectorChecker.cpp 2018-08-13 21:17:10 UTC (rev 234817)
@@ -837,8 +837,6 @@
}
return false;
case CSSSelector::PseudoClassNthChild:
- if (!selector.parseNth())
- break;
if (auto* parentElement = element.parentElement()) {
auto relation = context.isSubjectOrAdjacentElement ? Style::Relation::ChildrenAffectedByForwardPositionalRules : Style::Relation::DescendantsAffectedByForwardPositionalRules;
addStyleRelation(checkingContext, *parentElement, relation);
@@ -867,9 +865,6 @@
}
break;
case CSSSelector::PseudoClassNthOfType:
- if (!selector.parseNth())
- break;
-
if (auto* parentElement = element.parentElement()) {
auto relation = context.isSubjectOrAdjacentElement ? Style::Relation::ChildrenAffectedByForwardPositionalRules : Style::Relation::DescendantsAffectedByForwardPositionalRules;
addStyleRelation(checkingContext, *parentElement, relation);
@@ -880,8 +875,6 @@
}
break;
case CSSSelector::PseudoClassNthLastChild:
- if (!selector.parseNth())
- break;
if (Element* parentElement = element.parentElement()) {
if (const CSSSelectorList* selectorList = selector.selectorList()) {
unsigned selectorListSpecificity;
@@ -913,8 +906,6 @@
}
break;
case CSSSelector::PseudoClassNthLastOfType:
- if (!selector.parseNth())
- break;
if (Element* parentElement = element.parentElement()) {
auto relation = context.isSubjectOrAdjacentElement ? Style::Relation::ChildrenAffectedByBackwardPositionalRules : Style::Relation::DescendantsAffectedByBackwardPositionalRules;
addStyleRelation(checkingContext, *parentElement, relation);
Modified: trunk/Source/WebCore/cssjit/SelectorCompiler.cpp (234816 => 234817)
--- trunk/Source/WebCore/cssjit/SelectorCompiler.cpp 2018-08-13 21:07:55 UTC (rev 234816)
+++ trunk/Source/WebCore/cssjit/SelectorCompiler.cpp 2018-08-13 21:17:10 UTC (rev 234817)
@@ -451,9 +451,6 @@
// Handle the forward :nth-child() and backward :nth-last-child().
static FunctionType addNthChildType(const CSSSelector& selector, SelectorContext selectorContext, FragmentPositionInRootFragments positionInRootFragments, CSSSelector::PseudoClassType firstMatchAlternative, bool visitedMatchEnabled, Vector<std::pair<int, int>, 2>& simpleCases, Vector<NthChildOfSelectorInfo>& filteredCases, HashSet<unsigned>& pseudoClasses, unsigned& internalSpecificity)
{
- if (!selector.parseNth())
- return FunctionType::CannotMatchAnything;
-
int a = selector.nthA();
int b = selector.nthB();