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

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

Issue 102953007: Selectors in styles in shadowRoots should match in all of the host's shadowRoots. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 11 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/ElementRuleCollector.h ('k') | Source/core/css/resolver/ScopedStyleResolver.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 360 matching lines...) Expand 10 before | Expand all | Expand 10 after
371 static inline bool compareRules(const MatchedRule& matchedRule1, const MatchedRu le& matchedRule2) 371 static inline bool compareRules(const MatchedRule& matchedRule1, const MatchedRu le& matchedRule2)
372 { 372 {
373 if (matchedRule1.cascadeScope() != matchedRule2.cascadeScope()) 373 if (matchedRule1.cascadeScope() != matchedRule2.cascadeScope())
374 return matchedRule1.cascadeScope() > matchedRule2.cascadeScope(); 374 return matchedRule1.cascadeScope() > matchedRule2.cascadeScope();
375 375
376 unsigned specificity1 = matchedRule1.specificity(); 376 unsigned specificity1 = matchedRule1.specificity();
377 unsigned specificity2 = matchedRule2.specificity(); 377 unsigned specificity2 = matchedRule2.specificity();
378 if (specificity1 != specificity2) 378 if (specificity1 != specificity2)
379 return specificity1 < specificity2; 379 return specificity1 < specificity2;
380 380
381 if (matchedRule1.styleSheetIndex() != matchedRule2.styleSheetIndex())
382 return matchedRule1.styleSheetIndex() < matchedRule2.styleSheetIndex();
383
384 return matchedRule1.position() < matchedRule2.position(); 381 return matchedRule1.position() < matchedRule2.position();
385 } 382 }
386 383
387 void ElementRuleCollector::sortMatchedRules() 384 void ElementRuleCollector::sortMatchedRules()
388 { 385 {
389 ASSERT(m_matchedRules); 386 ASSERT(m_matchedRules);
390 std::sort(m_matchedRules->begin(), m_matchedRules->end(), compareRules); 387 std::sort(m_matchedRules->begin(), m_matchedRules->end(), compareRules);
391 } 388 }
392 389
393 bool ElementRuleCollector::hasAnyMatchingRules(RuleSet* ruleSet) 390 bool ElementRuleCollector::hasAnyMatchingRules(RuleSet* ruleSet)
394 { 391 {
395 clearMatchedRules(); 392 clearMatchedRules();
396 393
397 m_mode = SelectorChecker::SharingRules; 394 m_mode = SelectorChecker::SharingRules;
398 // To check whether a given RuleSet has any rule matching a given element, 395 // To check whether a given RuleSet has any rule matching a given element,
399 // should not see the element's treescope. Because RuleSet has no 396 // should not see the element's treescope. Because RuleSet has no
400 // information about "scope". 397 // information about "scope".
401 int firstRuleIndex = -1, lastRuleIndex = -1; 398 int firstRuleIndex = -1, lastRuleIndex = -1;
402 RuleRange ruleRange(firstRuleIndex, lastRuleIndex); 399 RuleRange ruleRange(firstRuleIndex, lastRuleIndex);
403 // FIXME: Verify whether it's ok to ignore CascadeScope here. 400 // FIXME: Verify whether it's ok to ignore CascadeScope here.
404 collectMatchingRules(MatchRequest(ruleSet), ruleRange, SelectorChecker::Stay sWithinTreeScope); 401 collectMatchingRules(MatchRequest(ruleSet), ruleRange, SelectorChecker::Stay sWithinTreeScope);
405 402
406 return m_matchedRules && !m_matchedRules->isEmpty(); 403 return m_matchedRules && !m_matchedRules->isEmpty();
407 } 404 }
408 405
409 } // namespace WebCore 406 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/core/css/ElementRuleCollector.h ('k') | Source/core/css/resolver/ScopedStyleResolver.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698