Changeset 179819 in webkit
- Timestamp:
- Feb 8, 2015 7:44:57 PM (9 years ago)
- Location:
- trunk
- Files:
-
- 8 added
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r179818 r179819 1 2015-02-08 Benjamin Poulain <benjamin@webkit.org> 2 3 Add parsing support for CSS Selector L4's case-insensitive attribute 4 https://bugs.webkit.org/show_bug.cgi?id=141373 5 6 Reviewed by Darin Adler. 7 8 * fast/css/css-selector-text-expected.txt: 9 * fast/css/css-selector-text.html: 10 * fast/css/css-set-selector-text-expected.txt: 11 * fast/css/css-set-selector-text.html: 12 Basic round-trip serialization through CSSOM. 13 14 * fast/css/parsing-css-attribute-case-insensitive-value-1-expected.txt: Added. 15 * fast/css/parsing-css-attribute-case-insensitive-value-1.html: Added. 16 Simple cases by themself and used in complex selectors. 17 18 * fast/css/parsing-css-attribute-case-insensitive-value-2-expected.txt: Added. 19 * fast/css/parsing-css-attribute-case-insensitive-value-2.html: Added. 20 Less simple cases, all kinds of valid syntax for case-insensitive attributes. 21 22 * fast/css/parsing-css-attribute-case-insensitive-value-3-expected.txt: Added. 23 * fast/css/parsing-css-attribute-case-insensitive-value-3.html: Added. 24 Cases that must be treated as invalid selectors. 25 26 * fast/css/parsing-css-attribute-case-insensitive-value-4-expected.txt: Added. 27 * fast/css/parsing-css-attribute-case-insensitive-value-4.html: Added. 28 Verify that invalid rules do not affect surrounding valid rules. 29 1 30 2015-02-08 David Kilzer <ddkilzer@apple.com> 2 31 -
trunk/LayoutTests/fast/css/css-selector-text-expected.txt
r178592 r179819 16 16 PASS parseThenSerializeRule('[a$="b"] { }') is '[a$="b"] { }' 17 17 PASS parseThenSerializeRule('[a*="b"] { }') is '[a*="b"] { }' 18 PASS parseThenSerializeRule('[a="b" i] { }') is '[a="b" i] { }' 19 PASS parseThenSerializeRule('[a~="b" i] { }') is '[a~="b" i] { }' 20 PASS parseThenSerializeRule('[a|="b" i] { }') is '[a|="b" i] { }' 21 PASS parseThenSerializeRule('[a^="b" i] { }') is '[a^="b" i] { }' 22 PASS parseThenSerializeRule('[a$="b" i] { }') is '[a$="b" i] { }' 23 PASS parseThenSerializeRule('[a*="b" i] { }') is '[a*="b" i] { }' 18 24 19 25 PASS parseThenSerializeRule('*|a { }') is '*|a { }' -
trunk/LayoutTests/fast/css/css-selector-text.html
r178592 r179819 41 41 testSelectorRoundTrip('[a$="b"]'); 42 42 testSelectorRoundTrip('[a*="b"]'); 43 testSelectorRoundTrip('[a="b" i]'); 44 testSelectorRoundTrip('[a~="b" i]'); 45 testSelectorRoundTrip('[a|="b" i]'); 46 testSelectorRoundTrip('[a^="b" i]'); 47 testSelectorRoundTrip('[a$="b" i]'); 48 testSelectorRoundTrip('[a*="b" i]'); 43 49 44 50 debug(''); -
trunk/LayoutTests/fast/css/css-set-selector-text-expected.txt
r178592 r179819 26 26 PASS setThenReadSelectorText('[a$="b"]') is '[a$="b"]' 27 27 PASS setThenReadSelectorText('[a*="b"]') is '[a*="b"]' 28 PASS setThenReadSelectorText('[a="b" i]') is '[a="b" i]' 29 PASS setThenReadSelectorText('[a~="b" i]') is '[a~="b" i]' 30 PASS setThenReadSelectorText('[a|="b" i]') is '[a|="b" i]' 31 PASS setThenReadSelectorText('[a^="b" i]') is '[a^="b" i]' 32 PASS setThenReadSelectorText('[a$="b" i]') is '[a$="b" i]' 33 PASS setThenReadSelectorText('[a*="b" i]') is '[a*="b" i]' 28 34 29 35 PASS setThenReadSelectorText('*|a') is '*|a' -
trunk/LayoutTests/fast/css/css-set-selector-text.html
r178592 r179819 58 58 testSelectorRoundTrip('[a$="b"]'); 59 59 testSelectorRoundTrip('[a*="b"]'); 60 testSelectorRoundTrip('[a="b" i]'); 61 testSelectorRoundTrip('[a~="b" i]'); 62 testSelectorRoundTrip('[a|="b" i]'); 63 testSelectorRoundTrip('[a^="b" i]'); 64 testSelectorRoundTrip('[a$="b" i]'); 65 testSelectorRoundTrip('[a*="b" i]'); 60 66 61 67 debug(''); -
trunk/Source/WebCore/ChangeLog
r179813 r179819 1 2015-02-08 Benjamin Poulain <benjamin@webkit.org> 2 3 Add parsing support for CSS Selector L4's case-insensitive attribute 4 https://bugs.webkit.org/show_bug.cgi?id=141373 5 6 Reviewed by Darin Adler. 7 8 This patch adds parsing for the case-insensitive attribute value 9 matching of CSS Selectors Level 4: http://dev.w3.org/csswg/selectors-4/#attribute-case 10 Excuse of a grammar: http://dev.w3.org/csswg/selectors-4/#grammar 11 12 This patch also covers serialization for CSSOM. The serialization 13 is defined here: http://dev.w3.org/csswg/cssom/#serializing-selectors 14 15 Matching is completely ignored in this patch. All the simple selectors 16 are treated as regular attribute selectors. 17 18 Tests: fast/css/parsing-css-attribute-case-insensitive-value-1.html 19 fast/css/parsing-css-attribute-case-insensitive-value-2.html 20 fast/css/parsing-css-attribute-case-insensitive-value-3.html 21 fast/css/parsing-css-attribute-case-insensitive-value-4.html 22 23 * css/CSSGrammar.y.in: 24 * css/CSSParserValues.h: 25 (WebCore::CSSParserSelector::setAttributeValueMatchingIsCaseInsensitive): 26 * css/CSSSelector.cpp: 27 (WebCore::CSSSelector::CSSSelector): 28 (WebCore::CSSSelector::selectorText): 29 * css/CSSSelector.h: 30 (WebCore::CSSSelector::CSSSelector): 31 (WebCore::CSSSelector::setAttributeValueMatchingIsCaseInsensitive): 32 (WebCore::CSSSelector::attributeValueMatchingIsCaseInsensitive): 33 1 34 2015-02-08 Darin Adler <darin@apple.com> 2 35 -
trunk/Source/WebCore/css/CSSGrammar.y.in
r179485 r179819 307 307 308 308 %union { bool boolean; } 309 %type <boolean> declaration declaration_list decl_list priority309 %type <boolean> attrib_flags declaration declaration_list decl_list priority 310 310 311 311 %union { CSSSelector::Match match; } … … 1264 1264 $$->setMatch(CSSSelector::Set); 1265 1265 } 1266 | '[' maybe_space IDENT maybe_space match maybe_space ident_or_string maybe_space ']' {1266 | '[' maybe_space IDENT maybe_space match maybe_space ident_or_string maybe_space attrib_flags ']' { 1267 1267 $$ = new CSSParserSelector; 1268 1268 $$->setAttribute(QualifiedName(nullAtom, $3, nullAtom), parser->m_context.isHTMLDocument); 1269 1269 $$->setMatch($5); 1270 1270 $$->setValue($7); 1271 $$->setAttributeValueMatchingIsCaseInsensitive($9); 1271 1272 } 1272 1273 | '[' maybe_space namespace_selector IDENT maybe_space ']' { … … 1275 1276 $$->setMatch(CSSSelector::Set); 1276 1277 } 1277 | '[' maybe_space namespace_selector IDENT maybe_space match maybe_space ident_or_string maybe_space ']' {1278 | '[' maybe_space namespace_selector IDENT maybe_space match maybe_space ident_or_string maybe_space attrib_flags ']' { 1278 1279 $$ = new CSSParserSelector; 1279 1280 $$->setAttribute(parser->determineNameInNamespace($3, $4), parser->m_context.isHTMLDocument); 1280 1281 $$->setMatch($6); 1281 1282 $$->setValue($8); 1282 } 1283 ; 1283 $$->setAttributeValueMatchingIsCaseInsensitive($10); 1284 } 1285 ; 1286 1287 attrib_flags: 1288 #if ENABLE_CSS_SELECTORS_LEVEL4 1289 IDENT maybe_space { 1290 if (UNLIKELY($1.length() != 1 || !isASCIIAlphaCaselessEqual($1[0], 'i'))) 1291 YYERROR; 1292 $$ = true; 1293 } 1294 | 1295 #endif 1296 /* empty */ { 1297 $$ = false; 1298 } 1284 1299 1285 1300 match: -
trunk/Source/WebCore/css/CSSParserValues.h
r178675 r179819 224 224 void setAttribute(const QualifiedName& value, bool isCaseInsensitive) { m_selector->setAttribute(value, isCaseInsensitive); } 225 225 void setArgument(const AtomicString& value) { m_selector->setArgument(value); } 226 void setAttributeValueMatchingIsCaseInsensitive(bool isCaseInsensitive) { m_selector->setAttributeValueMatchingIsCaseInsensitive(isCaseInsensitive); } 226 227 void setMatch(CSSSelector::Match value) { m_selector->setMatch(value); } 227 228 void setRelation(CSSSelector::Relation value) { m_selector->setRelation(value); } 228 229 void setForPage() { m_selector->setForPage(); } 229 230 230 231 231 void adoptSelectorVector(Vector<std::unique_ptr<CSSParserSelector>>& selectorVector); -
trunk/Source/WebCore/css/CSSSelector.cpp
r179323 r179819 62 62 , m_tagIsForNamespaceRule(tagIsForNamespaceRule) 63 63 , m_descendantDoubleChildSyntax(false) 64 , m_caseInsensitiveAttributeValueMatching(false) 64 65 { 65 66 const AtomicString& tagLocalName = tagQName.localName(); … … 684 685 if (cs->match() != CSSSelector::Set) { 685 686 serializeString(cs->value(), str); 686 str.append(']'); 687 if (cs->attributeValueMatchingIsCaseInsensitive()) 688 str.appendLiteral(" i]"); 689 else 690 str.append(']'); 687 691 } 688 692 } else if (cs->match() == CSSSelector::PagePseudoClass) { -
trunk/Source/WebCore/css/CSSSelector.h
r179132 r179819 235 235 const AtomicString& attributeCanonicalLocalName() const; 236 236 const AtomicString& argument() const { return m_hasRareData ? m_data.m_rareData->m_argument : nullAtom; } 237 bool attributeValueMatchingIsCaseInsensitive() const; 237 238 #if ENABLE(CSS_SELECTORS_LEVEL4) 238 239 const Vector<LanguageArgument>* langArgumentList() const { return m_hasRareData ? m_data.m_rareData->m_langArgumentList.get() : nullptr; } … … 243 244 void setAttribute(const QualifiedName&, bool isCaseInsensitive); 244 245 void setArgument(const AtomicString&); 246 void setAttributeValueMatchingIsCaseInsensitive(bool); 245 247 #if ENABLE(CSS_SELECTORS_LEVEL4) 246 248 void setLangArgumentList(std::unique_ptr<Vector<LanguageArgument>>); … … 332 334 unsigned m_tagIsForNamespaceRule : 1; 333 335 unsigned m_descendantDoubleChildSyntax : 1; 336 unsigned m_caseInsensitiveAttributeValueMatching : 1; 334 337 335 338 unsigned simpleSelectorSpecificityForPage() const; … … 473 476 , m_tagIsForNamespaceRule(false) 474 477 , m_descendantDoubleChildSyntax(false) 478 , m_caseInsensitiveAttributeValueMatching(false) 475 479 { 476 480 } … … 488 492 , m_tagIsForNamespaceRule(o.m_tagIsForNamespaceRule) 489 493 , m_descendantDoubleChildSyntax(o.m_descendantDoubleChildSyntax) 494 , m_caseInsensitiveAttributeValueMatching(o.m_caseInsensitiveAttributeValueMatching) 490 495 { 491 496 if (o.m_hasRareData) { … … 539 544 } 540 545 546 inline void CSSSelector::setAttributeValueMatchingIsCaseInsensitive(bool isCaseInsensitive) 547 { 548 ASSERT(isAttributeSelector() && match() != CSSSelector::Set); 549 m_caseInsensitiveAttributeValueMatching = isCaseInsensitive; 550 } 551 552 inline bool CSSSelector::attributeValueMatchingIsCaseInsensitive() const 553 { 554 return m_caseInsensitiveAttributeValueMatching; 555 } 541 556 542 557 } // namespace WebCore
Note: See TracChangeset
for help on using the changeset viewer.