- Revision
- 164932
- Author
- [email protected]
- Date
- 2014-03-01 15:50:17 -0800 (Sat, 01 Mar 2014)
Log Message
Tighten minimumRegisterRequirements()
https://bugs.webkit.org/show_bug.cgi?id=129538
Reviewed by Andreas Kling.
Source/WebCore:
Fix small things that made minimumRegisterRequirements() a little optimistic
when dealing with attributes.
Test: fast/selectors/adjacent-descendant-tail-register-requirement.html
* cssjit/SelectorCompiler.cpp:
(WebCore::SelectorCompiler::SelectorCodeGenerator::SelectorCodeGenerator):
Attribute Set does not do value matching, the case sensitive value matching is irrelevant
The problem is that flag is also used by minimumRegisterRequirements()
to find if one more register is needed.
Set the flag to case sensitive to avoid reserving one extra register.
(WebCore::SelectorCompiler::minimumRegisterRequirements):
Use a new backtrackingFlag to know if there is a descendant tail, thus a backtracking register
reserved.
This is better than using the backtracking action because the backtracking chain could be
an adjacent chain inside a descendant chain.
The flags are designed for that, just set one for minimumRegisterRequirements().
The 2 extra registers for the attribute count and address become limited to all attributes
except the last one. We don't keep a copy for the last matching, those registers were not needed.
(WebCore::SelectorCompiler::SelectorCodeGenerator::computeBacktrackingInformation):
LayoutTests:
* fast/selectors/adjacent-descendant-tail-register-requirement-expected.txt: Added.
* fast/selectors/adjacent-descendant-tail-register-requirement.html: Added.
Modified Paths
Added Paths
Diff
Modified: trunk/LayoutTests/ChangeLog (164931 => 164932)
--- trunk/LayoutTests/ChangeLog 2014-03-01 23:31:03 UTC (rev 164931)
+++ trunk/LayoutTests/ChangeLog 2014-03-01 23:50:17 UTC (rev 164932)
@@ -1,3 +1,13 @@
+2014-03-01 Benjamin Poulain <[email protected]>
+
+ Tighten minimumRegisterRequirements()
+ https://bugs.webkit.org/show_bug.cgi?id=129538
+
+ Reviewed by Andreas Kling.
+
+ * fast/selectors/adjacent-descendant-tail-register-requirement-expected.txt: Added.
+ * fast/selectors/adjacent-descendant-tail-register-requirement.html: Added.
+
2014-03-01 Yoav Weiss <[email protected]>
Fix srcset related bugs
Added: trunk/LayoutTests/fast/selectors/adjacent-descendant-tail-register-requirement-expected.txt (0 => 164932)
--- trunk/LayoutTests/fast/selectors/adjacent-descendant-tail-register-requirement-expected.txt (rev 0)
+++ trunk/LayoutTests/fast/selectors/adjacent-descendant-tail-register-requirement-expected.txt 2014-03-01 23:50:17 UTC (rev 164932)
@@ -0,0 +1,11 @@
+The backtracking register was not taken into account when in an adjacent chain inside a backtracking descendant chain.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+Adjacent relations (tree modifiers), no descendant backtracking, multi-attribute match.
+PASS getComputedStyle(document.getElementById("target1")).backgroundColor is "rgb(1, 2, 3)"
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
Added: trunk/LayoutTests/fast/selectors/adjacent-descendant-tail-register-requirement.html (0 => 164932)
--- trunk/LayoutTests/fast/selectors/adjacent-descendant-tail-register-requirement.html (rev 0)
+++ trunk/LayoutTests/fast/selectors/adjacent-descendant-tail-register-requirement.html 2014-03-01 23:50:17 UTC (rev 164932)
@@ -0,0 +1,60 @@
+<!doctype html>
+<html>
+<head>
+<script src=""
+<style>
+[a][b]+c+d~e>ul>li span {
+ background-color:rgb(1,2,3);
+}
+</style>
+</head>
+<body>
+<div style="display:none">
+ <!-- case [a][b]+c+d~e>ul>li span -->
+ <div a b></div>
+ <c></c>
+ <d></d>
+ <div></div>
+
+ <div a></div>
+ <c></c>
+ <d></d>
+ <div></div>
+
+ <c></c>
+ <d></d>
+ <div></div>
+ <e>
+ <ul>
+ <li>
+
+ <!-- Subtree that fails, and should backtrack to the tree above. -->
+ <div a></div>
+ <c></c>
+ <d></d>
+ <div></div>
+ <c></c>
+ <d></d>
+ <div></div>
+ <e>
+ <ul>
+ <li>
+ <span id="target1"></span>
+ </li>
+ </ul>
+ </e>
+
+ </li>
+ </ul>
+ </e>
+</div>
+</body>
+<script>
+description('The backtracking register was not taken into account when in an adjacent chain inside a backtracking descendant chain.');
+
+debug("Adjacent relations (tree modifiers), no descendant backtracking, multi-attribute match.");
+shouldBeEqualToString('getComputedStyle(document.getElementById("target1")).backgroundColor', 'rgb(1, 2, 3)');
+
+</script>
+<script src=""
+</html>
Modified: trunk/Source/WebCore/ChangeLog (164931 => 164932)
--- trunk/Source/WebCore/ChangeLog 2014-03-01 23:31:03 UTC (rev 164931)
+++ trunk/Source/WebCore/ChangeLog 2014-03-01 23:50:17 UTC (rev 164932)
@@ -1,3 +1,36 @@
+2014-03-01 Benjamin Poulain <[email protected]>
+
+ Tighten minimumRegisterRequirements()
+ https://bugs.webkit.org/show_bug.cgi?id=129538
+
+ Reviewed by Andreas Kling.
+
+ Fix small things that made minimumRegisterRequirements() a little optimistic
+ when dealing with attributes.
+
+ Test: fast/selectors/adjacent-descendant-tail-register-requirement.html
+
+ * cssjit/SelectorCompiler.cpp:
+ (WebCore::SelectorCompiler::SelectorCodeGenerator::SelectorCodeGenerator):
+ Attribute Set does not do value matching, the case sensitive value matching is irrelevant
+ The problem is that flag is also used by minimumRegisterRequirements()
+ to find if one more register is needed.
+
+ Set the flag to case sensitive to avoid reserving one extra register.
+
+ (WebCore::SelectorCompiler::minimumRegisterRequirements):
+ Use a new backtrackingFlag to know if there is a descendant tail, thus a backtracking register
+ reserved.
+ This is better than using the backtracking action because the backtracking chain could be
+ an adjacent chain inside a descendant chain.
+
+ The flags are designed for that, just set one for minimumRegisterRequirements().
+
+ The 2 extra registers for the attribute count and address become limited to all attributes
+ except the last one. We don't keep a copy for the last matching, those registers were not needed.
+
+ (WebCore::SelectorCompiler::SelectorCodeGenerator::computeBacktrackingInformation):
+
2014-03-01 Pratik Solanki <[email protected]>
[iOS] selectionImageForcingBlackText should return autoreleased object
Modified: trunk/Source/WebCore/cssjit/SelectorCompiler.cpp (164931 => 164932)
--- trunk/Source/WebCore/cssjit/SelectorCompiler.cpp 2014-03-01 23:31:03 UTC (rev 164931)
+++ trunk/Source/WebCore/cssjit/SelectorCompiler.cpp 2014-03-01 23:50:17 UTC (rev 164932)
@@ -73,6 +73,7 @@
SaveAdjacentBacktrackingStart = 1 << 3,
DirectAdjacentTail = 1 << 4,
DescendantTail = 1 << 5,
+ InChainWithDescendantTail = 1 << 6
};
};
@@ -351,7 +352,7 @@
fragment.attributes.append(AttributeMatchingInfo(selector, HTMLDocument::isCaseSensitiveAttribute(selector->attribute())));
break;
case CSSSelector::Set:
- fragment.attributes.append(AttributeMatchingInfo(selector, false));
+ fragment.attributes.append(AttributeMatchingInfo(selector, true));
break;
case CSSSelector::Unknown:
case CSSSelector::List:
@@ -414,14 +415,14 @@
const SelectorFragment& selectorFragment = selectorFragments[selectorFragmentIndex];
const Vector<AttributeMatchingInfo>& attributes = selectorFragment.attributes;
- for (unsigned attributeIndex = 0; attributeIndex < attributes.size(); ++attributeIndex) {
+ unsigned attributeCount = attributes.size();
+ for (unsigned attributeIndex = 0; attributeIndex < attributeCount; ++attributeIndex) {
// Element + ElementData + scratchRegister + attributeArrayPointer + expectedLocalName + (qualifiedNameImpl && expectedValue).
unsigned attributeMinimum = 6;
- if (selectorFragment.traversalBacktrackingAction == BacktrackingAction::JumpToDescendantTail
- || selectorFragment.matchingBacktrackingAction == BacktrackingAction::JumpToDescendantTail)
+ if (selectorFragment.backtrackingFlags & BacktrackingFlag::InChainWithDescendantTail)
attributeMinimum += 1; // If there is a DescendantTail, there is a backtracking register.
- if (attributes.size() != 1)
+ if (attributeIndex + 1 < attributeCount)
attributeMinimum += 2; // For the local copy of the counter and attributeArrayPointer.
const AttributeMatchingInfo& attributeInfo = attributes[attributeIndex];
@@ -595,6 +596,9 @@
needsAdjacentTail |= requiresAdjacentTail(fragment);
needsDescendantTail |= requiresDescendantTail(fragment);
+ if (needsDescendantTail)
+ fragment.backtrackingFlags |= BacktrackingFlag::InChainWithDescendantTail;
+
// Add code generation flags.
if (fragment.relationToLeftFragment != FragmentRelation::Descendant && fragment.relationToRightFragment == FragmentRelation::Descendant)
fragment.backtrackingFlags |= BacktrackingFlag::DescendantEntryPoint;