OLD | NEW |
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 452 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
463 const QualifiedName& selectorAttr = selector.attribute(); | 463 const QualifiedName& selectorAttr = selector.attribute(); |
464 ASSERT(selectorAttr.localName() != starAtom); // Should not be possible from
the CSS grammar. | 464 ASSERT(selectorAttr.localName() != starAtom); // Should not be possible from
the CSS grammar. |
465 | 465 |
466 // Synchronize the attribute in case it is lazy-computed. | 466 // Synchronize the attribute in case it is lazy-computed. |
467 // Currently all lazy properties have a null namespace, so only pass localNa
me(). | 467 // Currently all lazy properties have a null namespace, so only pass localNa
me(). |
468 element.synchronizeAttribute(selectorAttr.localName()); | 468 element.synchronizeAttribute(selectorAttr.localName()); |
469 | 469 |
470 if (!element.hasAttributesWithoutUpdate()) | 470 if (!element.hasAttributesWithoutUpdate()) |
471 return false; | 471 return false; |
472 | 472 |
473 const AtomicString& selectorValue = selector.value(); | 473 const AtomicString& selectorValue = selector.value(); |
| 474 bool caseInsensitive = selector.attributeMatchType() == CSSSelector::CaseIns
ensitive; |
474 | 475 |
475 AttributeCollection attributes = element.attributes(); | 476 AttributeCollection attributes = element.attributes(); |
476 AttributeCollection::const_iterator end = attributes.end(); | 477 AttributeCollection::const_iterator end = attributes.end(); |
477 for (AttributeCollection::const_iterator it = attributes.begin(); it != end;
++it) { | 478 for (AttributeCollection::const_iterator it = attributes.begin(); it != end;
++it) { |
478 const Attribute& attributeItem = *it; | 479 const Attribute& attributeItem = *it; |
479 | 480 |
480 if (!attributeItem.matches(selectorAttr)) | 481 if (!attributeItem.matches(selectorAttr)) |
481 continue; | 482 continue; |
482 | 483 |
483 if (attributeValueMatches(attributeItem, match, selectorValue, true)) | 484 if (attributeValueMatches(attributeItem, match, selectorValue, !caseInse
nsitive)) |
484 return true; | 485 return true; |
485 | 486 |
486 // Case sensitivity for attribute matching is looser than hasAttribute o
r | 487 if (caseInsensitive) |
487 // Element::shouldIgnoreAttributeCase() for now. Unclear if that's corre
ct. | 488 continue; |
488 bool caseSensitive = !element.document().isHTMLDocument() || HTMLDocumen
t::isCaseSensitiveAttribute(selectorAttr); | 489 |
| 490 // Legacy dictates that values of some attributes should be compared in |
| 491 // a case-insensitive manner regardless of whether the case insensitive |
| 492 // flag is set or not. |
| 493 bool legacyCaseInsensitive = element.document().isHTMLDocument() && !HTM
LDocument::isCaseSensitiveAttribute(selectorAttr); |
489 | 494 |
490 // If case-insensitive, re-check, and count if result differs. | 495 // If case-insensitive, re-check, and count if result differs. |
491 // See http://code.google.com/p/chromium/issues/detail?id=327060 | 496 // See http://code.google.com/p/chromium/issues/detail?id=327060 |
492 if (!caseSensitive && attributeValueMatches(attributeItem, match, select
orValue, false)) { | 497 if (legacyCaseInsensitive && attributeValueMatches(attributeItem, match,
selectorValue, false)) { |
493 UseCounter::count(element.document(), UseCounter::CaseInsensitiveAtt
rSelectorMatch); | 498 UseCounter::count(element.document(), UseCounter::CaseInsensitiveAtt
rSelectorMatch); |
494 return true; | 499 return true; |
495 } | 500 } |
496 } | 501 } |
497 | 502 |
498 return false; | 503 return false; |
499 } | 504 } |
500 | 505 |
501 template<typename SiblingTraversalStrategy> | 506 template<typename SiblingTraversalStrategy> |
502 bool SelectorChecker::checkOne(const SelectorCheckingContext& context, const Sib
lingTraversalStrategy& siblingTraversalStrategy, unsigned* specificity) const | 507 bool SelectorChecker::checkOne(const SelectorCheckingContext& context, const Sib
lingTraversalStrategy& siblingTraversalStrategy, unsigned* specificity) const |
(...skipping 626 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1129 return isHTMLOptionElement(element) && toHTMLOptionElement(element).spatialN
avigationFocused() && isFrameFocused(element); | 1134 return isHTMLOptionElement(element) && toHTMLOptionElement(element).spatialN
avigationFocused() && isFrameFocused(element); |
1130 } | 1135 } |
1131 | 1136 |
1132 template | 1137 template |
1133 SelectorChecker::Match SelectorChecker::match(const SelectorCheckingContext&, co
nst DOMSiblingTraversalStrategy&, MatchResult*) const; | 1138 SelectorChecker::Match SelectorChecker::match(const SelectorCheckingContext&, co
nst DOMSiblingTraversalStrategy&, MatchResult*) const; |
1134 | 1139 |
1135 template | 1140 template |
1136 SelectorChecker::Match SelectorChecker::match(const SelectorCheckingContext&, co
nst ShadowDOMSiblingTraversalStrategy&, MatchResult*) const; | 1141 SelectorChecker::Match SelectorChecker::match(const SelectorCheckingContext&, co
nst ShadowDOMSiblingTraversalStrategy&, MatchResult*) const; |
1137 | 1142 |
1138 } | 1143 } |
OLD | NEW |