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

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

Issue 10533036: Merge 118703 (Closed) Base URL: http://svn.webkit.org/repository/webkit/branches/chromium/1132/
Patch Set: Created 8 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
« no previous file with comments | « Source/WebCore/css/CSSSelector.cpp ('k') | no next file » | 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 Apple Inc. All rights reserved. 5 * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011 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 711 matching lines...) Expand 10 before | Expand all | Expand 10 after
722 722
723 bool caseSensitive = !m_documentIsHTML || !htmlAttributeHasCaseInsensiti veValue(attr); 723 bool caseSensitive = !m_documentIsHTML || !htmlAttributeHasCaseInsensiti veValue(attr);
724 724
725 if (!anyAttributeMatches(element, static_cast<CSSSelector::Match>(select or->m_match), attr, selector->value(), caseSensitive)) 725 if (!anyAttributeMatches(element, static_cast<CSSSelector::Match>(select or->m_match), attr, selector->value(), caseSensitive))
726 return false; 726 return false;
727 } 727 }
728 728
729 if (selector->m_match == CSSSelector::PseudoClass) { 729 if (selector->m_match == CSSSelector::PseudoClass) {
730 // Handle :not up front. 730 // Handle :not up front.
731 if (selector->pseudoType() == CSSSelector::PseudoNot) { 731 if (selector->pseudoType() == CSSSelector::PseudoNot) {
732 ASSERT(selector->selectorList()); 732 CSSSelectorList* selectorList = selector->selectorList();
733
734 // FIXME: We probably should fix the parser and make it never produc e :not rules with missing selector list.
735 if (!selectorList)
736 return false;
737
733 SelectorCheckingContext subContext(context); 738 SelectorCheckingContext subContext(context);
734 subContext.isSubSelector = true; 739 subContext.isSubSelector = true;
735 for (subContext.selector = selector->selectorList()->first(); subCon text.selector; subContext.selector = subContext.selector->tagHistory()) { 740 for (subContext.selector = selectorList->first(); subContext.selecto r; subContext.selector = subContext.selector->tagHistory()) {
736 // :not cannot nest. I don't really know why this is a 741 // :not cannot nest. I don't really know why this is a
737 // restriction in CSS3, but it is, so let's honor it. 742 // restriction in CSS3, but it is, so let's honor it.
738 // the parser enforces that this never occurs 743 // the parser enforces that this never occurs
739 ASSERT(subContext.selector->pseudoType() != CSSSelector::PseudoN ot); 744 ASSERT(subContext.selector->pseudoType() != CSSSelector::PseudoN ot);
740 // We select between :visited and :link when applying. We don't know which one applied (or not) yet. 745 // We select between :visited and :link when applying. We don't know which one applied (or not) yet.
741 if (subContext.selector->pseudoType() == CSSSelector::PseudoVisi ted || (subContext.selector->pseudoType() == CSSSelector::PseudoLink && subConte xt.visitedMatchType == VisitedMatchEnabled)) 746 if (subContext.selector->pseudoType() == CSSSelector::PseudoVisi ted || (subContext.selector->pseudoType() == CSSSelector::PseudoLink && subConte xt.visitedMatchType == VisitedMatchEnabled))
742 return true; 747 return true;
743 if (!checkOneSelector(subContext, dynamicPseudo)) 748 if (!checkOneSelector(subContext, dynamicPseudo))
744 return true; 749 return true;
745 } 750 }
(...skipping 568 matching lines...) Expand 10 before | Expand all | Expand 10 after
1314 1319
1315 unsigned SelectorChecker::determineLinkMatchType(const CSSSelector* selector) 1320 unsigned SelectorChecker::determineLinkMatchType(const CSSSelector* selector)
1316 { 1321 {
1317 unsigned linkMatchType = MatchAll; 1322 unsigned linkMatchType = MatchAll;
1318 1323
1319 // Statically determine if this selector will match a link in visited, unvis ited or any state, or never. 1324 // Statically determine if this selector will match a link in visited, unvis ited or any state, or never.
1320 // :visited never matches other elements than the innermost link element. 1325 // :visited never matches other elements than the innermost link element.
1321 for (; selector; selector = selector->tagHistory()) { 1326 for (; selector; selector = selector->tagHistory()) {
1322 switch (selector->pseudoType()) { 1327 switch (selector->pseudoType()) {
1323 case CSSSelector::PseudoNot: 1328 case CSSSelector::PseudoNot:
1324 // :not(:visited) is equivalent to :link. Parser enforces that :not can't nest. 1329 {
1325 for (CSSSelector* subSelector = selector->selectorList()->first(); s ubSelector; subSelector = subSelector->tagHistory()) { 1330 // :not(:visited) is equivalent to :link. Parser enforces that : not can't nest.
1326 CSSSelector::PseudoType subType = subSelector->pseudoType(); 1331 CSSSelectorList* selectorList = selector->selectorList();
1327 if (subType == CSSSelector::PseudoVisited) 1332 if (!selectorList)
1328 linkMatchType &= ~SelectorChecker::MatchVisited; 1333 break;
1329 else if (subType == CSSSelector::PseudoLink) 1334
1330 linkMatchType &= ~SelectorChecker::MatchLink; 1335 for (CSSSelector* subSelector = selectorList->first(); subSelect or; subSelector = subSelector->tagHistory()) {
1336 CSSSelector::PseudoType subType = subSelector->pseudoType();
1337 if (subType == CSSSelector::PseudoVisited)
1338 linkMatchType &= ~SelectorChecker::MatchVisited;
1339 else if (subType == CSSSelector::PseudoLink)
1340 linkMatchType &= ~SelectorChecker::MatchLink;
1341 }
1331 } 1342 }
1332 break; 1343 break;
1333 case CSSSelector::PseudoLink: 1344 case CSSSelector::PseudoLink:
1334 linkMatchType &= ~SelectorChecker::MatchVisited; 1345 linkMatchType &= ~SelectorChecker::MatchVisited;
1335 break; 1346 break;
1336 case CSSSelector::PseudoVisited: 1347 case CSSSelector::PseudoVisited:
1337 linkMatchType &= ~SelectorChecker::MatchLink; 1348 linkMatchType &= ~SelectorChecker::MatchLink;
1338 break; 1349 break;
1339 default: 1350 default:
1340 // We don't support :link and :visited inside :-webkit-any. 1351 // We don't support :link and :visited inside :-webkit-any.
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
1376 ASSERT(scopeSelector->m_match == CSSSelector::Class || scopeSelector->m_ match == CSSSelector::Id); 1387 ASSERT(scopeSelector->m_match == CSSSelector::Class || scopeSelector->m_ match == CSSSelector::Id);
1377 if (scopeSelector->m_match == CSSSelector::Id) 1388 if (scopeSelector->m_match == CSSSelector::Id)
1378 idScopes.add(scopeSelector->value().impl()); 1389 idScopes.add(scopeSelector->value().impl());
1379 else 1390 else
1380 classScopes.add(scopeSelector->value().impl()); 1391 classScopes.add(scopeSelector->value().impl());
1381 } 1392 }
1382 return true; 1393 return true;
1383 } 1394 }
1384 1395
1385 } 1396 }
OLDNEW
« no previous file with comments | « Source/WebCore/css/CSSSelector.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698