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

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

Issue 180723006: Have ElementData::attributeItem() return a reference (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Rebase Created 6 years, 9 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/SelectorChecker.h ('k') | Source/core/dom/DatasetDOMStringMap.cpp » ('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 345 matching lines...) Expand 10 before | Expand all | Expand 10 after
356 } 356 }
357 357
358 static inline bool containsHTMLSpace(const AtomicString& string) 358 static inline bool containsHTMLSpace(const AtomicString& string)
359 { 359 {
360 for (unsigned i = 0; i < string.length(); i++) 360 for (unsigned i = 0; i < string.length(); i++)
361 if (isHTMLSpace<UChar>(string[i])) 361 if (isHTMLSpace<UChar>(string[i]))
362 return true; 362 return true;
363 return false; 363 return false;
364 } 364 }
365 365
366 static bool attributeValueMatches(const Attribute* attributeItem, CSSSelector::M atch match, const AtomicString& selectorValue, bool caseSensitive) 366 static bool attributeValueMatches(const Attribute& attributeItem, CSSSelector::M atch match, const AtomicString& selectorValue, bool caseSensitive)
367 { 367 {
368 const AtomicString& value = attributeItem->value(); 368 const AtomicString& value = attributeItem.value();
369 if (value.isNull()) 369 if (value.isNull())
370 return false; 370 return false;
371 371
372 switch (match) { 372 switch (match) {
373 case CSSSelector::Exact: 373 case CSSSelector::Exact:
374 if (caseSensitive ? selectorValue != value : !equalIgnoringCase(selector Value, value)) 374 if (caseSensitive ? selectorValue != value : !equalIgnoringCase(selector Value, value))
375 return false; 375 return false;
376 break; 376 break;
377 case CSSSelector::List: 377 case CSSSelector::List:
378 { 378 {
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
435 // Currently all lazy properties have a null namespace, so only pass localNa me(). 435 // Currently all lazy properties have a null namespace, so only pass localNa me().
436 element.synchronizeAttribute(selectorAttr.localName()); 436 element.synchronizeAttribute(selectorAttr.localName());
437 437
438 if (!element.hasAttributesWithoutUpdate()) 438 if (!element.hasAttributesWithoutUpdate())
439 return false; 439 return false;
440 440
441 const AtomicString& selectorValue = selector.value(); 441 const AtomicString& selectorValue = selector.value();
442 442
443 unsigned attributeCount = element.attributeCount(); 443 unsigned attributeCount = element.attributeCount();
444 for (size_t i = 0; i < attributeCount; ++i) { 444 for (size_t i = 0; i < attributeCount; ++i) {
445 const Attribute* attributeItem = element.attributeItem(i); 445 const Attribute& attributeItem = element.attributeItem(i);
446 446
447 if (!attributeItem->matches(selectorAttr)) 447 if (!attributeItem.matches(selectorAttr))
448 continue; 448 continue;
449 449
450 if (attributeValueMatches(attributeItem, match, selectorValue, true)) 450 if (attributeValueMatches(attributeItem, match, selectorValue, true))
451 return true; 451 return true;
452 452
453 // Case sensitivity for attribute matching is looser than hasAttribute o r 453 // Case sensitivity for attribute matching is looser than hasAttribute o r
454 // Element::shouldIgnoreAttributeCase() for now. Unclear if that's corre ct. 454 // Element::shouldIgnoreAttributeCase() for now. Unclear if that's corre ct.
455 bool caseSensitive = !element.document().isHTMLDocument() || HTMLDocumen t::isCaseSensitiveAttribute(selectorAttr); 455 bool caseSensitive = !element.document().isHTMLDocument() || HTMLDocumen t::isCaseSensitiveAttribute(selectorAttr);
456 456
457 // If case-insensitive, re-check, and count if result differs. 457 // If case-insensitive, re-check, and count if result differs.
(...skipping 624 matching lines...) Expand 10 before | Expand all | Expand 10 after
1082 return element.focused() && isFrameFocused(element); 1082 return element.focused() && isFrameFocused(element);
1083 } 1083 }
1084 1084
1085 template 1085 template
1086 SelectorChecker::Match SelectorChecker::match(const SelectorCheckingContext&, co nst DOMSiblingTraversalStrategy&, MatchResult*) const; 1086 SelectorChecker::Match SelectorChecker::match(const SelectorCheckingContext&, co nst DOMSiblingTraversalStrategy&, MatchResult*) const;
1087 1087
1088 template 1088 template
1089 SelectorChecker::Match SelectorChecker::match(const SelectorCheckingContext&, co nst ShadowDOMSiblingTraversalStrategy&, MatchResult*) const; 1089 SelectorChecker::Match SelectorChecker::match(const SelectorCheckingContext&, co nst ShadowDOMSiblingTraversalStrategy&, MatchResult*) const;
1090 1090
1091 } 1091 }
OLDNEW
« no previous file with comments | « Source/core/css/SelectorChecker.h ('k') | Source/core/dom/DatasetDOMStringMap.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698