Changeset 167585 in webkit
- Timestamp:
- Apr 20, 2014, 11:26:20 PM (12 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 4 edited
-
LayoutTests/ChangeLog (modified) (1 diff)
-
LayoutTests/fast/selectors/nth-child-on-root-expected.txt (added)
-
LayoutTests/fast/selectors/nth-child-on-root.html (added)
-
Source/WebCore/ChangeLog (modified) (1 diff)
-
Source/WebCore/cssjit/SelectorCompiler.cpp (modified) (7 diffs)
-
Source/WebCore/dom/Document.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r167584 r167585 1 2014-04-20 Benjamin Poulain <benjamin@webkit.org> 2 3 Compile the :root pseudo class and fix a related issue with :nth-child() 4 https://bugs.webkit.org/show_bug.cgi?id=131926 5 6 Reviewed by Andreas Kling. 7 8 Add more test coverage that would have caught the bug with :nth-child(n). 9 10 * fast/selectors/nth-child-on-root-expected.txt: Added. 11 * fast/selectors/nth-child-on-root.html: Added. 12 1 13 2014-04-20 Benjamin Poulain <benjamin@webkit.org> 2 14 -
trunk/Source/WebCore/ChangeLog
r167584 r167585 1 2014-04-20 Benjamin Poulain <benjamin@webkit.org> 2 3 Compile the :root pseudo class and fix a related issue with :nth-child() 4 https://bugs.webkit.org/show_bug.cgi?id=131926 5 6 Reviewed by Andreas Kling. 7 8 Add the :root pseudo class. This is another trivial selector, we just need to compare 9 the element pointer with the documentElement. 10 11 I discovered some issues with :nth-child(n) through the layout tests for ":root". 12 When the pseudo class nth-child could match anything, no code was generated. That decision 13 was taken when generating the fragments. 14 15 The specification of :nth-child() has two tests: the parent test and the counter test. 16 Since some fragments would not generate any code for :nth-child(n), they would succeed on the root, 17 which is incorrect since the root should fail the parent test. 18 19 This was fixed by moving the filtering of non-counting :nth-child() after we generate the parent 20 check. 21 We still don't generate any counter test unless required. 22 23 Test: fast/selectors/nth-child-on-root.html 24 25 * cssjit/SelectorCompiler.cpp: 26 (WebCore::SelectorCompiler::addPseudoClassType): 27 (WebCore::SelectorCompiler::SelectorCodeGenerator::generateElementMatching): 28 (WebCore::SelectorCompiler::SelectorCodeGenerator::generateElementIsNthChild): 29 (WebCore::SelectorCompiler::SelectorCodeGenerator::generateElementIsRoot): 30 * dom/Document.h: 31 (WebCore::Document::documentElementMemoryOffset): 32 1 33 2014-04-20 Benjamin Poulain <benjamin@webkit.org> 2 34 -
trunk/Source/WebCore/cssjit/SelectorCompiler.cpp
r167575 r167585 191 191 void generateElementIsLink(Assembler::JumpList& failureCases); 192 192 void generateElementIsNthChild(Assembler::JumpList& failureCases, const SelectorFragment&); 193 void generateElementIsRoot(Assembler::JumpList& failureCases); 193 194 void generateElementIsTarget(Assembler::JumpList& failureCases); 194 195 … … 320 321 321 322 case CSSSelector::PseudoClassLink: 323 case CSSSelector::PseudoClassRoot: 322 324 case CSSSelector::PseudoClassTarget: 323 325 fragment.pseudoClasses.add(type); … … 343 345 if (a <= 0 && b < 1) 344 346 return FunctionType::CannotMatchAnything; 345 346 // Anything modulo 1 is zero. Unless b restrict the range, this does not filter anything out.347 if (a == 1 && (!b || (b == 1)))348 return FunctionType::SimpleSelectorChecker;349 347 350 348 fragment.nthChildfilters.append(std::pair<int, int>(a, b)); … … 1169 1167 generateElementIsLink(failureCases); 1170 1168 1169 if (fragment.pseudoClasses.contains(CSSSelector::PseudoClassRoot)) 1170 generateElementIsRoot(failureCases); 1171 1171 1172 if (fragment.pseudoClasses.contains(CSSSelector::PseudoClassTarget)) 1172 1173 generateElementIsTarget(failureCases); … … 1943 1944 generateWalkToParentElement(failureCases, parentElement); 1944 1945 1946 Vector<std::pair<int, int>> validSubsetFilters; 1947 validSubsetFilters.reserveInitialCapacity(fragment.nthChildfilters.size()); 1948 for (const auto& slot : fragment.nthChildfilters) { 1949 int a = slot.first; 1950 int b = slot.second; 1951 1952 // Anything modulo 1 is zero. Unless b restricts the range, this does not filter anything out. 1953 if (a == 1 && (!b || (b == 1))) 1954 continue; 1955 validSubsetFilters.uncheckedAppend(slot); 1956 } 1957 if (validSubsetFilters.isEmpty()) 1958 return; 1959 1945 1960 // Setup the counter at 1. 1946 1961 LocalRegister elementCounter(m_registerAllocator); … … 2019 2034 2020 2035 // Test every the nth-child filter. 2021 for (const auto& slot : fragment.nthChildfilters) {2036 for (const auto& slot : validSubsetFilters) { 2022 2037 int a = slot.first; 2023 2038 int b = slot.second; … … 2044 2059 } 2045 2060 2061 void SelectorCodeGenerator::generateElementIsRoot(Assembler::JumpList& failureCases) 2062 { 2063 LocalRegister document(m_registerAllocator); 2064 getDocument(m_assembler, elementAddressRegister, document); 2065 failureCases.append(m_assembler.branchPtr(Assembler::NotEqual, Assembler::Address(document, Document::documentElementMemoryOffset()), elementAddressRegister)); 2066 } 2067 2046 2068 void SelectorCodeGenerator::generateElementIsTarget(Assembler::JumpList& failureCases) 2047 2069 { -
trunk/Source/WebCore/dom/Document.h
r167574 r167585 407 407 return m_documentElement.get(); 408 408 } 409 static ptrdiff_t documentElementMemoryOffset() { return OBJECT_OFFSETOF(Document, m_documentElement); } 409 410 410 411 Element* activeElement();
Note:
See TracChangeset
for help on using the changeset viewer.