Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(380)

Unified Diff: third_party/WebKit/Source/core/css/parser/CSSSelectorParser.cpp

Issue 1607873002: Serialize namespaced type/* selectors according to CSSOM spec. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@queryselector-no-pseudoelm-20160118
Patch Set: Rebased Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/core/css/parser/CSSSelectorParser.cpp
diff --git a/third_party/WebKit/Source/core/css/parser/CSSSelectorParser.cpp b/third_party/WebKit/Source/core/css/parser/CSSSelectorParser.cpp
index eee79ac27113006856e8fc147240b2665b6c3c1b..4a90301af811f44ace35990f61d31643b075d50b 100644
--- a/third_party/WebKit/Source/core/css/parser/CSSSelectorParser.cpp
+++ b/third_party/WebKit/Source/core/css/parser/CSSSelectorParser.cpp
@@ -308,6 +308,8 @@ PassOwnPtr<CSSParserSelector> CSSSelectorParser::consumeCompoundSelector(CSSPars
m_failedParsing = true;
return nullptr;
}
+ if (namespaceURI == defaultNamespace())
+ namespacePrefix = nullAtom;
return CSSParserSelector::create(QualifiedName(namespacePrefix, elementName, namespaceURI));
}
prependTypeSelectorIfNeeded(namespacePrefix, elementName, compoundSelector.get());
@@ -725,7 +727,10 @@ void CSSSelectorParser::prependTypeSelectorIfNeeded(const AtomicString& namespac
m_failedParsing = true;
return;
}
- QualifiedName tag = QualifiedName(namespacePrefix, determinedElementName, namespaceURI);
+ AtomicString determinedPrefix = namespacePrefix;
+ if (namespaceURI == defaultNamespace())
+ determinedPrefix = nullAtom;
+ QualifiedName tag = QualifiedName(determinedPrefix, determinedElementName, namespaceURI);
// *:host/*:host-context never matches, so we can't discard the *,
// otherwise we can't tell the difference between *:host and just :host.
@@ -735,8 +740,9 @@ void CSSSelectorParser::prependTypeSelectorIfNeeded(const AtomicString& namespac
// ::cue, ::shadow), we need a universal selector to set the combinator
// (relation) on in the cases where there are no simple selectors preceding
// the pseudo element.
- if (tag != anyQName() || compoundSelector->isHostPseudoSelector() || compoundSelector->needsImplicitShadowCombinatorForMatching())
- compoundSelector->prependTagSelector(tag, elementName.isNull());
+ bool explicitForHost = compoundSelector->isHostPseudoSelector() && !elementName.isNull();
+ if (tag != anyQName() || explicitForHost || compoundSelector->needsImplicitShadowCombinatorForMatching())
+ compoundSelector->prependTagSelector(tag, determinedPrefix == nullAtom && determinedElementName == starAtom && !explicitForHost);
}
PassOwnPtr<CSSParserSelector> CSSSelectorParser::addSimpleSelectorToCompound(PassOwnPtr<CSSParserSelector> compoundSelector, PassOwnPtr<CSSParserSelector> simpleSelector)

Powered by Google App Engine
This is Rietveld 408576698