| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2012 Apple Inc. All rights reserved. | 2 * Copyright (C) 2012 Apple Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
| 8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
| 9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
| 10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 44 analyzeStyleSheet(sheets[i]); | 44 analyzeStyleSheet(sheets[i]); |
| 45 } | 45 } |
| 46 | 46 |
| 47 static bool determineSelectorScopes(const CSSSelectorList& selectorList, HashSet
<StringImpl*>& idScopes, HashSet<StringImpl*>& classScopes) | 47 static bool determineSelectorScopes(const CSSSelectorList& selectorList, HashSet
<StringImpl*>& idScopes, HashSet<StringImpl*>& classScopes) |
| 48 { | 48 { |
| 49 for (const CSSSelector* selector = selectorList.first(); selector; selector
= CSSSelectorList::next(*selector)) { | 49 for (const CSSSelector* selector = selectorList.first(); selector; selector
= CSSSelectorList::next(*selector)) { |
| 50 const CSSSelector* scopeSelector = 0; | 50 const CSSSelector* scopeSelector = 0; |
| 51 // This picks the widest scope, not the narrowest, to minimize the numbe
r of found scopes. | 51 // This picks the widest scope, not the narrowest, to minimize the numbe
r of found scopes. |
| 52 for (const CSSSelector* current = selector; current; current = current->
tagHistory()) { | 52 for (const CSSSelector* current = selector; current; current = current->
tagHistory()) { |
| 53 // Prefer ids over classes. | 53 // Prefer ids over classes. |
| 54 if (current->m_match == CSSSelector::Id) | 54 if (current->match() == CSSSelector::Id) |
| 55 scopeSelector = current; | 55 scopeSelector = current; |
| 56 else if (current->m_match == CSSSelector::Class && (!scopeSelector |
| scopeSelector->m_match != CSSSelector::Id)) | 56 else if (current->match() == CSSSelector::Class && (!scopeSelector |
| scopeSelector->match() != CSSSelector::Id)) |
| 57 scopeSelector = current; | 57 scopeSelector = current; |
| 58 CSSSelector::Relation relation = current->relation(); | 58 CSSSelector::Relation relation = current->relation(); |
| 59 // FIXME: it would be better to use setNeedsStyleRecalc for all shad
ow hosts matching | 59 // FIXME: it would be better to use setNeedsStyleRecalc for all shad
ow hosts matching |
| 60 // scopeSelector. Currently requests full style recalc. | 60 // scopeSelector. Currently requests full style recalc. |
| 61 if (relation == CSSSelector::ShadowDeep || relation == CSSSelector::
ShadowPseudo) | 61 if (relation == CSSSelector::ShadowDeep || relation == CSSSelector::
ShadowPseudo) |
| 62 return false; | 62 return false; |
| 63 if (relation != CSSSelector::Descendant && relation != CSSSelector::
Child && relation != CSSSelector::SubSelector) | 63 if (relation != CSSSelector::Descendant && relation != CSSSelector::
Child && relation != CSSSelector::SubSelector) |
| 64 break; | 64 break; |
| 65 } | 65 } |
| 66 if (!scopeSelector) | 66 if (!scopeSelector) |
| 67 return false; | 67 return false; |
| 68 ASSERT(scopeSelector->m_match == CSSSelector::Class || scopeSelector->m_
match == CSSSelector::Id); | 68 ASSERT(scopeSelector->match() == CSSSelector::Class || scopeSelector->ma
tch() == CSSSelector::Id); |
| 69 if (scopeSelector->m_match == CSSSelector::Id) | 69 if (scopeSelector->match() == CSSSelector::Id) |
| 70 idScopes.add(scopeSelector->value().impl()); | 70 idScopes.add(scopeSelector->value().impl()); |
| 71 else | 71 else |
| 72 classScopes.add(scopeSelector->value().impl()); | 72 classScopes.add(scopeSelector->value().impl()); |
| 73 } | 73 } |
| 74 return true; | 74 return true; |
| 75 } | 75 } |
| 76 | 76 |
| 77 static bool hasDistributedRule(StyleSheetContents* styleSheetContents) | 77 static bool hasDistributedRule(StyleSheetContents* styleSheetContents) |
| 78 { | 78 { |
| 79 const WillBeHeapVector<RefPtrWillBeMember<StyleRuleBase> >& rules = styleShe
etContents->childRules(); | 79 const WillBeHeapVector<RefPtrWillBeMember<StyleRuleBase> >& rules = styleShe
etContents->childRules(); |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 212 element->setNeedsStyleRecalc(SubtreeStyleChange); | 212 element->setNeedsStyleRecalc(SubtreeStyleChange); |
| 213 // The whole subtree is now invalidated, we can skip to the next sib
ling. | 213 // The whole subtree is now invalidated, we can skip to the next sib
ling. |
| 214 element = ElementTraversal::nextSkippingChildren(*element); | 214 element = ElementTraversal::nextSkippingChildren(*element); |
| 215 continue; | 215 continue; |
| 216 } | 216 } |
| 217 element = ElementTraversal::next(*element); | 217 element = ElementTraversal::next(*element); |
| 218 } | 218 } |
| 219 } | 219 } |
| 220 | 220 |
| 221 } | 221 } |
| OLD | NEW |