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

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

Issue 252683011: Add support for case-insensitive attribute value selectors (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: add runtime flag; fix selector serializing Created 6 years, 7 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
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 464 matching lines...) Expand 10 before | Expand all | Expand 10 after
475 const QualifiedName& selectorAttr = selector.attribute(); 475 const QualifiedName& selectorAttr = selector.attribute();
476 ASSERT(selectorAttr.localName() != starAtom); // Should not be possible from the CSS grammar. 476 ASSERT(selectorAttr.localName() != starAtom); // Should not be possible from the CSS grammar.
477 477
478 // Synchronize the attribute in case it is lazy-computed. 478 // Synchronize the attribute in case it is lazy-computed.
479 // Currently all lazy properties have a null namespace, so only pass localNa me(). 479 // Currently all lazy properties have a null namespace, so only pass localNa me().
480 element.synchronizeAttribute(selectorAttr.localName()); 480 element.synchronizeAttribute(selectorAttr.localName());
481 481
482 if (!element.hasAttributesWithoutUpdate()) 482 if (!element.hasAttributesWithoutUpdate())
483 return false; 483 return false;
484 484
485 const AtomicString& selectorValue = selector.value(); 485 const AtomicString& selectorValue = selector.value();
486 bool caseInsensitive = selector.attributeFlags() & CSSSelector::CaseInsensit ive;
486 487
487 unsigned attributeCount = element.attributeCount(); 488 unsigned attributeCount = element.attributeCount();
488 for (size_t i = 0; i < attributeCount; ++i) { 489 for (size_t i = 0; i < attributeCount; ++i) {
489 const Attribute& attributeItem = element.attributeItem(i); 490 const Attribute& attributeItem = element.attributeItem(i);
490 491
491 if (!attributeItem.matches(selectorAttr)) 492 if (!attributeItem.matches(selectorAttr))
492 continue; 493 continue;
493 494
494 if (attributeValueMatches(attributeItem, match, selectorValue, true)) 495 if (attributeValueMatches(attributeItem, match, selectorValue, !caseInse nsitive))
495 return true; 496 return true;
496 497
498 if (caseInsensitive)
499 continue;
500
497 // Case sensitivity for attribute matching is looser than hasAttribute o r 501 // Case sensitivity for attribute matching is looser than hasAttribute o r
498 // Element::shouldIgnoreAttributeCase() for now. Unclear if that's corre ct. 502 // Element::shouldIgnoreAttributeCase() for now. Unclear if that's corre ct.
499 bool caseSensitive = !element.document().isHTMLDocument() || HTMLDocumen t::isCaseSensitiveAttribute(selectorAttr); 503 bool caseSensitive = !element.document().isHTMLDocument() || HTMLDocumen t::isCaseSensitiveAttribute(selectorAttr);
500 504
501 // If case-insensitive, re-check, and count if result differs. 505 // If case-insensitive, re-check, and count if result differs.
502 // See http://code.google.com/p/chromium/issues/detail?id=327060 506 // See http://code.google.com/p/chromium/issues/detail?id=327060
503 if (!caseSensitive && attributeValueMatches(attributeItem, match, select orValue, false)) { 507 if (!caseSensitive && attributeValueMatches(attributeItem, match, select orValue, false)) {
504 UseCounter::count(element.document(), UseCounter::CaseInsensitiveAtt rSelectorMatch); 508 UseCounter::count(element.document(), UseCounter::CaseInsensitiveAtt rSelectorMatch);
505 return true; 509 return true;
506 } 510 }
(...skipping 627 matching lines...) Expand 10 before | Expand all | Expand 10 after
1134 return element.focused() && isFrameFocused(element); 1138 return element.focused() && isFrameFocused(element);
1135 } 1139 }
1136 1140
1137 template 1141 template
1138 SelectorChecker::Match SelectorChecker::match(const SelectorCheckingContext&, co nst DOMSiblingTraversalStrategy&, MatchResult*) const; 1142 SelectorChecker::Match SelectorChecker::match(const SelectorCheckingContext&, co nst DOMSiblingTraversalStrategy&, MatchResult*) const;
1139 1143
1140 template 1144 template
1141 SelectorChecker::Match SelectorChecker::match(const SelectorCheckingContext&, co nst ShadowDOMSiblingTraversalStrategy&, MatchResult*) const; 1145 SelectorChecker::Match SelectorChecker::match(const SelectorCheckingContext&, co nst ShadowDOMSiblingTraversalStrategy&, MatchResult*) const;
1142 1146
1143 } 1147 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698