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

Side by Side Diff: Source/core/css/parser/CSSParserToken.cpp

Issue 1253403005: Implement CSS.escape (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Fix final test Created 5 years, 4 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 unified diff | Download patch
« no previous file with comments | « Source/core/css/DOMWindowCSS.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "config.h" 5 #include "config.h"
6 #include "core/css/parser/CSSParserToken.h" 6 #include "core/css/parser/CSSParserToken.h"
7 7
8 #include "core/css/CSSMarkup.h" 8 #include "core/css/CSSMarkup.h"
9 #include "core/css/parser/CSSPropertyParser.h" 9 #include "core/css/parser/CSSPropertyParser.h"
10 #include "wtf/HashMap.h" 10 #include "wtf/HashMap.h"
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 ASSERT(m_type == IdentToken); 109 ASSERT(m_type == IdentToken);
110 return unresolvedCSSPropertyID(value()); 110 return unresolvedCSSPropertyID(value());
111 } 111 }
112 112
113 void CSSParserToken::serialize(StringBuilder& builder) const 113 void CSSParserToken::serialize(StringBuilder& builder) const
114 { 114 {
115 // This is currently only used for @supports CSSOM. To keep our implementati on 115 // This is currently only used for @supports CSSOM. To keep our implementati on
116 // simple we handle some of the edge cases incorrectly (see comments below). 116 // simple we handle some of the edge cases incorrectly (see comments below).
117 switch (type()) { 117 switch (type()) {
118 case IdentToken: 118 case IdentToken:
119 return serializeIdentifier(value(), builder); 119 serializeIdentifier(value(), builder);
120 break;
120 case FunctionToken: 121 case FunctionToken:
121 serializeIdentifier(value(), builder); 122 serializeIdentifier(value(), builder);
122 return builder.append('('); 123 return builder.append('(');
123 case AtKeywordToken: 124 case AtKeywordToken:
124 builder.append('@'); 125 builder.append('@');
125 return serializeIdentifier(value(), builder); 126 serializeIdentifier(value(), builder);
127 break;
126 case HashToken: 128 case HashToken:
127 // This will always serialize as a hash-token with 'id' type instead of 129 // This will always serialize as a hash-token with 'id' type instead of
128 // preserving the type of the input. 130 // preserving the type of the input.
129 builder.append('#'); 131 builder.append('#');
130 return serializeIdentifier(value(), builder); 132 serializeIdentifier(value(), builder);
133 break;
131 case UrlToken: 134 case UrlToken:
132 builder.append("url("); 135 builder.append("url(");
133 serializeIdentifier(value(), builder); 136 serializeIdentifier(value(), builder);
134 return builder.append(")"); 137 return builder.append(")");
135 case DelimiterToken: 138 case DelimiterToken:
136 if (delimiter() == '\\') 139 if (delimiter() == '\\')
137 return builder.append("\\\n"); 140 return builder.append("\\\n");
138 return builder.append(delimiter()); 141 return builder.append(delimiter());
139 case NumberToken: 142 case NumberToken:
140 // These won't properly preserve the NumericValueType flag 143 // These won't properly preserve the NumericValueType flag
141 return builder.appendNumber(numericValue()); 144 return builder.appendNumber(numericValue());
142 case PercentageToken: 145 case PercentageToken:
143 builder.appendNumber(numericValue()); 146 builder.appendNumber(numericValue());
144 return builder.append('%'); 147 return builder.append('%');
145 case DimensionToken: 148 case DimensionToken:
146 // This will incorrectly serialize e.g. 4e3e2 as 4000e2 149 // This will incorrectly serialize e.g. 4e3e2 as 4000e2
147 builder.appendNumber(numericValue()); 150 builder.appendNumber(numericValue());
148 return serializeIdentifier(value(), builder); 151 serializeIdentifier(value(), builder);
152 break;
149 case UnicodeRangeToken: 153 case UnicodeRangeToken:
150 return builder.append(String::format("U+%X-%X", unicodeRangeStart(), uni codeRangeEnd())); 154 return builder.append(String::format("U+%X-%X", unicodeRangeStart(), uni codeRangeEnd()));
151 case StringToken: 155 case StringToken:
152 return serializeString(value(), builder); 156 return serializeString(value(), builder);
153 157
154 case IncludeMatchToken: 158 case IncludeMatchToken:
155 return builder.append("~="); 159 return builder.append("~=");
156 case DashMatchToken: 160 case DashMatchToken:
157 return builder.append("|="); 161 return builder.append("|=");
158 case PrefixMatchToken: 162 case PrefixMatchToken:
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
193 return builder.append('}'); 197 return builder.append('}');
194 198
195 case EOFToken: 199 case EOFToken:
196 case CommentToken: 200 case CommentToken:
197 ASSERT_NOT_REACHED(); 201 ASSERT_NOT_REACHED();
198 return; 202 return;
199 } 203 }
200 } 204 }
201 205
202 } // namespace blink 206 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/css/DOMWindowCSS.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698