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

Side by Side Diff: Source/core/css/SelectorChecker.cpp

Issue 330043003: Add support for case-insensitive attribute value selectors (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Make union w/ m_attributeFlags and nth-state; Return enum type. Created 6 years, 6 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 | Annotate | Revision Log
« no previous file with comments | « Source/core/css/CSSSelector.cpp ('k') | Source/core/css/parser/BisonCSSParser.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
3 * (C) 2004-2005 Allan Sandfeld Jensen (kde@carewolf.com) 3 * (C) 2004-2005 Allan Sandfeld Jensen (kde@carewolf.com)
4 * Copyright (C) 2006, 2007 Nicholas Shanks (webkit@nickshanks.com) 4 * Copyright (C) 2006, 2007 Nicholas Shanks (webkit@nickshanks.com)
5 * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013 Apple Inc. All rights reserved. 5 * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013 Apple Inc. All rights reserved.
6 * Copyright (C) 2007 Alexey Proskuryakov <ap@webkit.org> 6 * Copyright (C) 2007 Alexey Proskuryakov <ap@webkit.org>
7 * Copyright (C) 2007, 2008 Eric Seidel <eric@webkit.org> 7 * Copyright (C) 2007, 2008 Eric Seidel <eric@webkit.org>
8 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t orchmobile.com/) 8 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t orchmobile.com/)
9 * Copyright (c) 2011, Code Aurora Forum. All rights reserved. 9 * Copyright (c) 2011, Code Aurora Forum. All rights reserved.
10 * Copyright (C) Research In Motion Limited 2011. All rights reserved. 10 * Copyright (C) Research In Motion Limited 2011. All rights reserved.
(...skipping 480 matching lines...) Expand 10 before | Expand all | Expand 10 after
491 const QualifiedName& selectorAttr = selector.attribute(); 491 const QualifiedName& selectorAttr = selector.attribute();
492 ASSERT(selectorAttr.localName() != starAtom); // Should not be possible from the CSS grammar. 492 ASSERT(selectorAttr.localName() != starAtom); // Should not be possible from the CSS grammar.
493 493
494 // Synchronize the attribute in case it is lazy-computed. 494 // Synchronize the attribute in case it is lazy-computed.
495 // Currently all lazy properties have a null namespace, so only pass localNa me(). 495 // Currently all lazy properties have a null namespace, so only pass localNa me().
496 element.synchronizeAttribute(selectorAttr.localName()); 496 element.synchronizeAttribute(selectorAttr.localName());
497 497
498 if (!element.hasAttributesWithoutUpdate()) 498 if (!element.hasAttributesWithoutUpdate())
499 return false; 499 return false;
500 500
501 const AtomicString& selectorValue = selector.value(); 501 const AtomicString& selectorValue = selector.value();
502 bool caseInsensitive = selector.attributeFlags() & CSSSelector::CaseInsensit ive;
502 503
503 AttributeIteratorAccessor attributes = element.attributesIterator(); 504 AttributeIteratorAccessor attributes = element.attributesIterator();
504 AttributeConstIterator end = attributes.end(); 505 AttributeConstIterator end = attributes.end();
505 for (AttributeConstIterator it = attributes.begin(); it != end; ++it) { 506 for (AttributeConstIterator it = attributes.begin(); it != end; ++it) {
506 const Attribute& attributeItem = **it; 507 const Attribute& attributeItem = **it;
507 508
508 if (!attributeItem.matches(selectorAttr)) 509 if (!attributeItem.matches(selectorAttr))
509 continue; 510 continue;
510 511
511 if (attributeValueMatches(attributeItem, match, selectorValue, true)) 512 if (attributeValueMatches(attributeItem, match, selectorValue, !caseInse nsitive))
512 return true; 513 return true;
513 514
515 if (caseInsensitive)
516 continue;
517
514 // Case sensitivity for attribute matching is looser than hasAttribute o r 518 // Case sensitivity for attribute matching is looser than hasAttribute o r
515 // Element::shouldIgnoreAttributeCase() for now. Unclear if that's corre ct. 519 // Element::shouldIgnoreAttributeCase() for now. Unclear if that's corre ct.
516 bool caseSensitive = !element.document().isHTMLDocument() || HTMLDocumen t::isCaseSensitiveAttribute(selectorAttr); 520 bool caseSensitive = !element.document().isHTMLDocument() || HTMLDocumen t::isCaseSensitiveAttribute(selectorAttr);
Timothy Loh 2014/07/22 08:51:02 This is super confusing (we have a caseSensitive a
fs 2014/07/22 11:06:17 I suppose we could make the new (currently |caseIn
Timothy Loh 2014/07/22 11:50:26 If I'm reading crbug.com/327060 right, the existin
fs 2014/07/22 14:09:04 Thank you for elaborating. I've updated to somethi
Timothy Loh 2014/07/23 01:46:50 I think |legacyCaseInsensitive| (instead of |legac
517 521
518 // If case-insensitive, re-check, and count if result differs. 522 // If case-insensitive, re-check, and count if result differs.
519 // See http://code.google.com/p/chromium/issues/detail?id=327060 523 // See http://code.google.com/p/chromium/issues/detail?id=327060
520 if (!caseSensitive && attributeValueMatches(attributeItem, match, select orValue, false)) { 524 if (!caseSensitive && attributeValueMatches(attributeItem, match, select orValue, false)) {
521 UseCounter::count(element.document(), UseCounter::CaseInsensitiveAtt rSelectorMatch); 525 UseCounter::count(element.document(), UseCounter::CaseInsensitiveAtt rSelectorMatch);
522 return true; 526 return true;
523 } 527 }
524 } 528 }
525 529
526 return false; 530 return false;
(...skipping 622 matching lines...) Expand 10 before | Expand all | Expand 10 after
1149 return element.focused() && isFrameFocused(element); 1153 return element.focused() && isFrameFocused(element);
1150 } 1154 }
1151 1155
1152 template 1156 template
1153 SelectorChecker::Match SelectorChecker::match(const SelectorCheckingContext&, co nst DOMSiblingTraversalStrategy&, MatchResult*) const; 1157 SelectorChecker::Match SelectorChecker::match(const SelectorCheckingContext&, co nst DOMSiblingTraversalStrategy&, MatchResult*) const;
1154 1158
1155 template 1159 template
1156 SelectorChecker::Match SelectorChecker::match(const SelectorCheckingContext&, co nst ShadowDOMSiblingTraversalStrategy&, MatchResult*) const; 1160 SelectorChecker::Match SelectorChecker::match(const SelectorCheckingContext&, co nst ShadowDOMSiblingTraversalStrategy&, MatchResult*) const;
1157 1161
1158 } 1162 }
OLDNEW
« no previous file with comments | « Source/core/css/CSSSelector.cpp ('k') | Source/core/css/parser/BisonCSSParser.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698