| 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 360 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 |
| OLD | NEW |