Diff
Modified: trunk/LayoutTests/ChangeLog (115970 => 115971)
--- trunk/LayoutTests/ChangeLog 2012-05-03 14:05:41 UTC (rev 115970)
+++ trunk/LayoutTests/ChangeLog 2012-05-03 14:45:12 UTC (rev 115971)
@@ -1,3 +1,15 @@
+2012-05-03 Arpita Bahuguna <[email protected]>
+
+ Broken handling of pseudo-elements in selectors API
+ https://bugs.webkit.org/show_bug.cgi?id=83446
+
+ Reviewed by Antti Koivisto.
+
+ * fast/dom/Window/querySelectorAll-with-pseudo-elements-expected.txt: Added.
+ * fast/dom/Window/querySelectorAll-with-pseudo-elements.html: Added.
+ New layout testcase added for verifying that the querySelectorAll() API returns zero
+ when querying for pseudo-elements selectors; as per the specification.
+
2012-05-03 Sudarsana Nagineni <[email protected]>
[EFL] [DRT] Update EFL baselines after r115846
Added: trunk/LayoutTests/fast/dom/Window/querySelectorAll-with-pseudo-elements-expected.txt (0 => 115971)
--- trunk/LayoutTests/fast/dom/Window/querySelectorAll-with-pseudo-elements-expected.txt (rev 0)
+++ trunk/LayoutTests/fast/dom/Window/querySelectorAll-with-pseudo-elements-expected.txt 2012-05-03 14:45:12 UTC (rev 115971)
@@ -0,0 +1,13 @@
+The test verifies that the querySelectorAll() API does not return any matched elements when querying for pseudo-element selectors.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS document.querySelectorAll("div::after").length is 0
+PASS document.querySelectorAll("html::before").length is 0
+PASS successfullyParsed is true
+
+TEST COMPLETE
+Test for Bugzilla Bug 83446: Broken handling for pseudo-elements in Selectors API.
+
+
Added: trunk/LayoutTests/fast/dom/Window/querySelectorAll-with-pseudo-elements.html (0 => 115971)
--- trunk/LayoutTests/fast/dom/Window/querySelectorAll-with-pseudo-elements.html (rev 0)
+++ trunk/LayoutTests/fast/dom/Window/querySelectorAll-with-pseudo-elements.html 2012-05-03 14:45:12 UTC (rev 115971)
@@ -0,0 +1,29 @@
+<!DOCTYPE html>
+<html>
+<head>
+<title>Test for Bugzilla Bug 83446 - Broken handling for pseudo-elements in Selectors API </title>
+<script src=""
+<script>
+function test() {
+description("The test verifies that the querySelectorAll() API does not return any matched elements when querying for pseudo-element selectors.");
+
+shouldBe('document.querySelectorAll("div::after").length', '0');
+shouldBe('document.querySelectorAll("html::before").length', '0');
+
+isSuccessfullyParsed();
+}
+</script>
+
+<style type="text/css">
+div:after {
+ content:"";
+}
+</style>
+
+</head>
+<body _onLoad_="test()">
+<p>Test for Bugzilla <a href="" 83446</a>: Broken handling for pseudo-elements in Selectors API.</p>
+<div> </div>
+
+</body>
+</html>
Modified: trunk/Source/WebCore/ChangeLog (115970 => 115971)
--- trunk/Source/WebCore/ChangeLog 2012-05-03 14:05:41 UTC (rev 115970)
+++ trunk/Source/WebCore/ChangeLog 2012-05-03 14:45:12 UTC (rev 115971)
@@ -1,3 +1,45 @@
+2012-05-03 Arpita Bahuguna <[email protected]>
+
+ Broken handling of pseudo-elements in selectors API
+ https://bugs.webkit.org/show_bug.cgi?id=83446
+
+ Reviewed by Antti Koivisto.
+
+ Test: fast/dom/Window/querySelectorAll-with-pseudo-elements.html
+
+ * css/SelectorChecker.cpp:
+ (WebCore::SelectorChecker::SelectorChecker):
+ Setting the default value for the enum member m_mode to ResolvingStyle.
+
+ (WebCore::SelectorChecker::checkSelector):
+ Instead of verifying against the bool m_isCollectingRulesOnly, we now check whether or not
+ m_mode is set to ResolvingStyle.
+
+ (WebCore::SelectorChecker::checkOneSelector):
+ Instead of verifying against the bool m_isCollectingRulesOnly, we now check whether or not
+ m_mode is set to ResolvingStyle. Also, for the pseudo-elements case we check if its
+ value is set to QueryingRules in which case we return false.
+
+ * css/SelectorChecker.h:
+ (WebCore::SelectorChecker::mode):
+ Returns the mode (m_mode) value.
+
+ (WebCore::SelectorChecker::setMode):
+ Sets the mode (m_mode) to the passed enum value.
+
+ * css/StyleResolver.cpp:
+ (WebCore::StyleResolver::sortAndTransferMatchedRules):
+ (WebCore::StyleResolver::collectMatchingRulesForList):
+ Retrieves SelectorChecker's mode value.
+
+ * dom/SelectorQuery.cpp:
+ (WebCore::SelectorQuery::SelectorQuery):
+ Sets SelectorChecker's mode to QueryingRules.
+
+ * html/shadow/ContentSelectorQuery.cpp:
+ (WebCore::ContentSelectorQuery::ContentSelectorQuery):
+ Sets SelectorChecker's mode to CollectingRules.
+
2012-05-03 Pavel Feldman <[email protected]>
Web Inspector: EXC_BAD_ACCESS in DOM breakpoint processing code.
Modified: trunk/Source/WebCore/css/SelectorChecker.cpp (115970 => 115971)
--- trunk/Source/WebCore/css/SelectorChecker.cpp 2012-05-03 14:05:41 UTC (rev 115970)
+++ trunk/Source/WebCore/css/SelectorChecker.cpp 2012-05-03 14:45:12 UTC (rev 115971)
@@ -69,7 +69,7 @@
: m_document(document)
, m_strictParsing(strictParsing)
, m_documentIsHTML(document->isHTMLDocument())
- , m_isCollectingRulesOnly(false)
+ , m_mode(ResolvingStyle)
, m_pseudoStyle(NOPSEUDO)
, m_hasUnknownPseudoElements(false)
{
@@ -492,7 +492,7 @@
return checkSelector(nextContext, dynamicPseudo);
case CSSSelector::DirectAdjacent:
- if (!m_isCollectingRulesOnly && context.element->parentElement()) {
+ if (m_mode == ResolvingStyle && context.element->parentElement()) {
RenderStyle* parentStyle = context.elementStyle ? context.elementParentStyle : context.element->parentNode()->renderStyle();
if (parentStyle)
parentStyle->setChildrenAffectedByDirectAdjacentRules();
@@ -506,7 +506,7 @@
return checkSelector(nextContext, dynamicPseudo);
case CSSSelector::IndirectAdjacent:
- if (!m_isCollectingRulesOnly && context.element->parentElement()) {
+ if (m_mode == ResolvingStyle && context.element->parentElement()) {
RenderStyle* parentStyle = context.elementStyle ? context.elementParentStyle : context.element->parentNode()->renderStyle();
if (parentStyle)
parentStyle->setChildrenAffectedByForwardPositionalRules();
@@ -526,7 +526,7 @@
// a selector is invalid if something follows a pseudo-element
// We make an exception for scrollbar pseudo elements and allow a set of pseudo classes (but nothing else)
// to follow the pseudo elements.
- if ((context.elementStyle || m_isCollectingRulesOnly) && dynamicPseudo != NOPSEUDO && dynamicPseudo != SELECTION
+ if ((context.elementStyle || m_mode == CollectingRules || m_mode == QueryingRules) && dynamicPseudo != NOPSEUDO && dynamicPseudo != SELECTION
&& !((RenderScrollbar::scrollbarForStyleResolve() || dynamicPseudo == SCROLLBAR_CORNER || dynamicPseudo == RESIZER) && nextContext.selector->m_match == CSSSelector::PseudoClass))
return SelectorFailsCompletely;
nextContext.isSubSelector = true;
@@ -773,7 +773,7 @@
}
}
}
- if (!m_isCollectingRulesOnly) {
+ if (m_mode == ResolvingStyle) {
if (context.elementStyle)
context.elementStyle->setEmptyState(result);
else if (element->renderStyle() && (element->document()->usesSiblingRules() || element->renderStyle()->unique()))
@@ -787,7 +787,7 @@
bool result = false;
if (!element->previousElementSibling())
result = true;
- if (!m_isCollectingRulesOnly) {
+ if (m_mode == ResolvingStyle) {
RenderStyle* childStyle = context.elementStyle ? context.elementStyle : element->renderStyle();
RenderStyle* parentStyle = context.elementStyle ? context.elementParentStyle : element->parentNode()->renderStyle();
if (parentStyle)
@@ -809,7 +809,7 @@
break;
}
}
- if (!m_isCollectingRulesOnly) {
+ if (m_mode == ResolvingStyle) {
RenderStyle* parentStyle = context.elementStyle ? context.elementParentStyle : element->parentNode()->renderStyle();
if (parentStyle)
parentStyle->setChildrenAffectedByForwardPositionalRules();
@@ -821,7 +821,7 @@
// last-child matches the last child that is an element
if (Element* parentElement = element->parentElement()) {
bool result = parentElement->isFinishedParsingChildren() && !element->nextElementSibling();
- if (!m_isCollectingRulesOnly) {
+ if (m_mode == ResolvingStyle) {
RenderStyle* childStyle = context.elementStyle ? context.elementStyle : element->renderStyle();
RenderStyle* parentStyle = context.elementStyle ? context.elementParentStyle : parentElement->renderStyle();
if (parentStyle)
@@ -835,7 +835,7 @@
case CSSSelector::PseudoLastOfType:
// last-of-type matches the last element of its type
if (Element* parentElement = element->parentElement()) {
- if (!m_isCollectingRulesOnly) {
+ if (m_mode == ResolvingStyle) {
RenderStyle* parentStyle = context.elementStyle ? context.elementParentStyle : parentElement->renderStyle();
if (parentStyle)
parentStyle->setChildrenAffectedByBackwardPositionalRules();
@@ -855,7 +855,7 @@
bool firstChild = !element->previousElementSibling();
bool _onlyChild_ = firstChild && parentElement->isFinishedParsingChildren() && !element->nextElementSibling();
- if (!m_isCollectingRulesOnly) {
+ if (m_mode == ResolvingStyle) {
RenderStyle* childStyle = context.elementStyle ? context.elementStyle : element->renderStyle();
RenderStyle* parentStyle = context.elementStyle ? context.elementParentStyle : parentElement->renderStyle();
if (parentStyle) {
@@ -873,7 +873,7 @@
case CSSSelector::PseudoOnlyOfType:
// FIXME: This selector is very slow.
if (Element* parentElement = element->parentElement()) {
- if (!m_isCollectingRulesOnly) {
+ if (m_mode == ResolvingStyle) {
RenderStyle* parentStyle = context.elementStyle ? context.elementParentStyle : parentElement->renderStyle();
if (parentStyle) {
parentStyle->setChildrenAffectedByForwardPositionalRules();
@@ -909,7 +909,7 @@
count++;
}
- if (!m_isCollectingRulesOnly) {
+ if (m_mode == ResolvingStyle) {
RenderStyle* childStyle = context.elementStyle ? context.elementStyle : element->renderStyle();
RenderStyle* parentStyle = context.elementStyle ? context.elementParentStyle : parentElement->renderStyle();
if (childStyle)
@@ -932,7 +932,7 @@
if (sibling->hasTagName(type))
++count;
}
- if (!m_isCollectingRulesOnly) {
+ if (m_mode == ResolvingStyle) {
RenderStyle* parentStyle = context.elementStyle ? context.elementParentStyle : parentElement->renderStyle();
if (parentStyle)
parentStyle->setChildrenAffectedByForwardPositionalRules();
@@ -946,7 +946,7 @@
if (!selector->parseNth())
break;
if (Element* parentElement = element->parentElement()) {
- if (!m_isCollectingRulesOnly) {
+ if (m_mode == ResolvingStyle) {
RenderStyle* parentStyle = context.elementStyle ? context.elementParentStyle : parentElement->renderStyle();
if (parentStyle)
parentStyle->setChildrenAffectedByBackwardPositionalRules();
@@ -964,7 +964,7 @@
if (!selector->parseNth())
break;
if (Element* parentElement = element->parentElement()) {
- if (!m_isCollectingRulesOnly) {
+ if (m_mode == ResolvingStyle) {
RenderStyle* parentStyle = context.elementStyle ? context.elementParentStyle : parentElement->renderStyle();
if (parentStyle)
parentStyle->setChildrenAffectedByBackwardPositionalRules();
@@ -1169,7 +1169,7 @@
return false;
}
if (selector->m_match == CSSSelector::PseudoElement) {
- if (!context.elementStyle && !m_isCollectingRulesOnly)
+ if ((!context.elementStyle && m_mode == ResolvingStyle) || m_mode == QueryingRules)
return false;
if (selector->isUnknownPseudoElement()) {
Modified: trunk/Source/WebCore/css/SelectorChecker.h (115970 => 115971)
--- trunk/Source/WebCore/css/SelectorChecker.h 2012-05-03 14:05:41 UTC (rev 115970)
+++ trunk/Source/WebCore/css/SelectorChecker.h 2012-05-03 14:45:12 UTC (rev 115971)
@@ -52,6 +52,7 @@
enum SelectorMatch { SelectorMatches, SelectorFailsLocally, SelectorFailsAllSiblings, SelectorFailsCompletely };
enum VisitedMatchType { VisitedMatchDisabled, VisitedMatchEnabled };
+ enum Mode { ResolvingStyle = 0, CollectingRules, QueryingRules };
struct SelectorCheckingContext {
// Initial selector constructor
@@ -96,8 +97,8 @@
Document* document() const { return m_document; }
bool strictParsing() const { return m_strictParsing; }
- bool isCollectingRulesOnly() const { return m_isCollectingRulesOnly; }
- void setCollectingRulesOnly(bool b) { m_isCollectingRulesOnly = b; }
+ Mode mode() const { return m_mode; }
+ void setMode(Mode mode) { m_mode = mode; }
PseudoId pseudoStyle() const { return m_pseudoStyle; }
void setPseudoStyle(PseudoId pseudoId) { m_pseudoStyle = pseudoId; }
@@ -135,7 +136,7 @@
Document* m_document;
bool m_strictParsing;
bool m_documentIsHTML;
- bool m_isCollectingRulesOnly;
+ Mode m_mode;
PseudoId m_pseudoStyle;
mutable bool m_hasUnknownPseudoElements;
mutable HashSet<LinkHash, LinkHashHash> m_linksCheckedForVisitedState;
Modified: trunk/Source/WebCore/css/StyleResolver.cpp (115970 => 115971)
--- trunk/Source/WebCore/css/StyleResolver.cpp 2012-05-03 14:05:41 UTC (rev 115970)
+++ trunk/Source/WebCore/css/StyleResolver.cpp 2012-05-03 14:45:12 UTC (rev 115971)
@@ -871,7 +871,7 @@
sortMatchedRules();
- if (m_checker.isCollectingRulesOnly()) {
+ if (m_checker.mode() == SelectorChecker::CollectingRules) {
if (!m_ruleList)
m_ruleList = StaticCSSRuleList::create();
for (unsigned i = 0; i < m_matchedRules.size(); ++i)
@@ -1045,7 +1045,7 @@
// If we're matching normal rules, set a pseudo bit if
// we really just matched a pseudo-element.
if (m_dynamicPseudo != NOPSEUDO && m_checker.pseudoStyle() == NOPSEUDO) {
- if (m_checker.isCollectingRulesOnly()) {
+ if (m_checker.mode() == SelectorChecker::CollectingRules) {
InspectorInstrumentation::didMatchRule(cookie, false);
continue;
}
@@ -2175,7 +2175,7 @@
if (!e || !e->document()->haveStylesheetsLoaded())
return 0;
- m_checker.setCollectingRulesOnly(true);
+ m_checker.setMode(SelectorChecker::CollectingRules);
initElement(e);
initForStyleResolve(e, 0, pseudoId);
@@ -2199,7 +2199,7 @@
m_sameOriginOnly = false;
}
- m_checker.setCollectingRulesOnly(false);
+ m_checker.setMode(SelectorChecker::ResolvingStyle);
return m_ruleList.release();
}
Modified: trunk/Source/WebCore/dom/SelectorQuery.cpp (115970 => 115971)
--- trunk/Source/WebCore/dom/SelectorQuery.cpp 2012-05-03 14:05:41 UTC (rev 115970)
+++ trunk/Source/WebCore/dom/SelectorQuery.cpp 2012-05-03 14:45:12 UTC (rev 115971)
@@ -151,7 +151,7 @@
, m_selectorChecker(rootNode->document(), !rootNode->document()->inQuirksMode())
, m_selectors(selectorList)
{
- m_selectorChecker.setCollectingRulesOnly(true);
+ m_selectorChecker.setMode(SelectorChecker::QueryingRules);
}
PassRefPtr<NodeList> SelectorQuery::queryAll() const
Modified: trunk/Source/WebCore/html/shadow/ContentSelectorQuery.cpp (115970 => 115971)
--- trunk/Source/WebCore/html/shadow/ContentSelectorQuery.cpp 2012-05-03 14:05:41 UTC (rev 115970)
+++ trunk/Source/WebCore/html/shadow/ContentSelectorQuery.cpp 2012-05-03 14:45:12 UTC (rev 115971)
@@ -37,7 +37,7 @@
: m_insertionPoint(insertionPoint)
, m_selectorChecker(insertionPoint->document(), !insertionPoint->document()->inQuirksMode())
{
- m_selectorChecker.setCollectingRulesOnly(true);
+ m_selectorChecker.setMode(SelectorChecker::CollectingRules);
if (insertionPoint->select().isNull() || insertionPoint->select().isEmpty()) {
m_isValidSelector = true;