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

Unified Diff: third_party/WebKit/Source/core/css/CSSSelector.cpp

Issue 2645563002: Serialize type and attribute selectors as identifiers (Closed)
Patch Set: weird -> escaped; add "serialize character as code point" test Created 3 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
« no previous file with comments | « third_party/WebKit/LayoutTests/cssom/serialize-namespaced-type-selectors.html ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/core/css/CSSSelector.cpp
diff --git a/third_party/WebKit/Source/core/css/CSSSelector.cpp b/third_party/WebKit/Source/core/css/CSSSelector.cpp
index 308d664efdf4ec43e478cba0854a2403d6644c20..8cb455f0c4e9c23f6a8e13fc7f2be80c408822c4 100644
--- a/third_party/WebKit/Source/core/css/CSSSelector.cpp
+++ b/third_party/WebKit/Source/core/css/CSSSelector.cpp
@@ -630,17 +630,28 @@ bool CSSSelector::operator==(const CSSSelector& other) const {
return true;
}
+static void serializeIdentifierOrAny(const AtomicString& identifier,
+ StringBuilder& builder) {
+ if (identifier != starAtom)
+ serializeIdentifier(identifier, builder);
+ else
+ builder.append(identifier);
+}
+
+static void serializeNamespacePrefixIfNeeded(const AtomicString& prefix,
+ StringBuilder& builder) {
+ if (prefix.isNull())
+ return;
+ serializeIdentifierOrAny(prefix, builder);
+ builder.append('|');
+}
+
String CSSSelector::selectorText(const String& rightSide) const {
StringBuilder str;
if (m_match == Tag && !m_tagIsImplicit) {
- if (tagQName().prefix().isNull()) {
- str.append(tagQName().localName());
- } else {
- str.append(tagQName().prefix().getString());
- str.append('|');
- str.append(tagQName().localName());
- }
+ serializeNamespacePrefixIfNeeded(tagQName().prefix(), str);
+ serializeIdentifierOrAny(tagQName().localName(), str);
}
const CSSSelector* cs = this;
@@ -699,12 +710,8 @@ String CSSSelector::selectorText(const String& rightSide) const {
str.append(cs->serializingValue());
} else if (cs->isAttributeSelector()) {
str.append('[');
- const AtomicString& prefix = cs->attribute().prefix();
- if (!prefix.isNull()) {
- str.append(prefix);
- str.append('|');
- }
- str.append(cs->attribute().localName());
+ serializeNamespacePrefixIfNeeded(cs->attribute().prefix(), str);
+ serializeIdentifier(cs->attribute().localName(), str);
switch (cs->m_match) {
case AttributeExact:
str.append('=');
« no previous file with comments | « third_party/WebKit/LayoutTests/cssom/serialize-namespaced-type-selectors.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698