OLD | NEW |
1 /* | 1 /* |
2 * (C) 1999-2003 Lars Knoll (knoll@kde.org) | 2 * (C) 1999-2003 Lars Knoll (knoll@kde.org) |
3 * Copyright (C) 2004, 2006, 2007, 2012 Apple Inc. All rights reserved. | 3 * Copyright (C) 2004, 2006, 2007, 2012 Apple Inc. All rights reserved. |
4 * | 4 * |
5 * This library is free software; you can redistribute it and/or | 5 * This library is free software; you can redistribute it and/or |
6 * modify it under the terms of the GNU Library General Public | 6 * modify it under the terms of the GNU Library General Public |
7 * License as published by the Free Software Foundation; either | 7 * License as published by the Free Software Foundation; either |
8 * version 2 of the License, or (at your option) any later version. | 8 * version 2 of the License, or (at your option) any later version. |
9 * | 9 * |
10 * This library is distributed in the hope that it will be useful, | 10 * This library is distributed in the hope that it will be useful, |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
106 | 106 |
107 void StyleSheetContents::setHasSyntacticallyValidCSSHeader(bool isValidCss) | 107 void StyleSheetContents::setHasSyntacticallyValidCSSHeader(bool isValidCss) |
108 { | 108 { |
109 if (!isValidCss) { | 109 if (!isValidCss) { |
110 if (Document* document = clientSingleOwnerDocument()) | 110 if (Document* document = clientSingleOwnerDocument()) |
111 removeSheetFromCache(document); | 111 removeSheetFromCache(document); |
112 } | 112 } |
113 m_hasSyntacticallyValidCSSHeader = isValidCss; | 113 m_hasSyntacticallyValidCSSHeader = isValidCss; |
114 } | 114 } |
115 | 115 |
116 bool StyleSheetContents::maybeCacheable() const | 116 bool StyleSheetContents::isCacheable() const |
117 { | 117 { |
| 118 // This would require dealing with multiple clients for load callbacks. |
| 119 if (!loadCompleted()) |
| 120 return false; |
118 // FIXME: StyleSheets with media queries can't be cached because their RuleS
et | 121 // FIXME: StyleSheets with media queries can't be cached because their RuleS
et |
119 // is processed differently based off the media queries, which might resolve | 122 // is processed differently based off the media queries, which might resolve |
120 // differently depending on the context of the parent CSSStyleSheet (e.g. | 123 // differently depending on the context of the parent CSSStyleSheet (e.g. |
121 // if they are in differently sized iframes). Once RuleSets are media query | 124 // if they are in differently sized iframes). Once RuleSets are media query |
122 // agnostic, we can restore sharing of StyleSheetContents with medea queries
. | 125 // agnostic, we can restore sharing of StyleSheetContents with medea queries
. |
123 if (m_hasMediaQueries) | 126 if (m_hasMediaQueries) |
124 return false; | 127 return false; |
125 // FIXME: Support copying import rules. | 128 // FIXME: Support copying import rules. |
126 if (!m_importRules.isEmpty()) | 129 if (!m_importRules.isEmpty()) |
127 return false; | 130 return false; |
128 // FIXME: Support cached stylesheets in import rules. | 131 // FIXME: Support cached stylesheets in import rules. |
129 if (m_ownerRule) | 132 if (m_ownerRule) |
130 return false; | 133 return false; |
131 if (m_didLoadErrorOccur) | 134 if (m_didLoadErrorOccur) |
132 return false; | 135 return false; |
133 // It is not the original sheet anymore. | 136 // It is not the original sheet anymore. |
134 if (m_isMutable) | 137 if (m_isMutable) |
135 return false; | 138 return false; |
136 // If the header is valid we are not going to need to check the SecurityOrig
in. | 139 // If the header is valid we are not going to need to check the SecurityOrig
in. |
137 // FIXME: Valid mime type avoids the check too. | 140 // FIXME: Valid mime type avoids the check too. |
138 if (!m_hasSyntacticallyValidCSSHeader) | 141 if (!m_hasSyntacticallyValidCSSHeader) |
139 return false; | 142 return false; |
140 return true; | 143 return true; |
141 } | 144 } |
142 | 145 |
143 bool StyleSheetContents::isCacheable() const | |
144 { | |
145 // This would require dealing with multiple clients for load callbacks. | |
146 if (!loadCompleted()) | |
147 return false; | |
148 return maybeCacheable(); | |
149 } | |
150 | |
151 void StyleSheetContents::parserAppendRule(PassRefPtrWillBeRawPtr<StyleRuleBase>
rule) | 146 void StyleSheetContents::parserAppendRule(PassRefPtrWillBeRawPtr<StyleRuleBase>
rule) |
152 { | 147 { |
153 ASSERT(!rule->isCharsetRule()); | 148 ASSERT(!rule->isCharsetRule()); |
154 if (rule->isImportRule()) { | 149 if (rule->isImportRule()) { |
155 // Parser enforces that @import rules come before anything else except @
charset. | 150 // Parser enforces that @import rules come before anything else except @
charset. |
156 ASSERT(m_childRules.isEmpty()); | 151 ASSERT(m_childRules.isEmpty()); |
157 StyleRuleImport* importRule = toStyleRuleImport(rule.get()); | 152 StyleRuleImport* importRule = toStyleRuleImport(rule.get()); |
158 if (importRule->mediaQueries()) | 153 if (importRule->mediaQueries()) |
159 setHasMediaQueries(); | 154 setHasMediaQueries(); |
160 m_importRules.append(importRule); | 155 m_importRules.append(importRule); |
(...skipping 421 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
582 void StyleSheetContents::clientLoadStarted(CSSStyleSheet* sheet) | 577 void StyleSheetContents::clientLoadStarted(CSSStyleSheet* sheet) |
583 { | 578 { |
584 ASSERT(m_completedClients.contains(sheet)); | 579 ASSERT(m_completedClients.contains(sheet)); |
585 m_completedClients.remove(sheet); | 580 m_completedClients.remove(sheet); |
586 m_loadingClients.add(sheet); | 581 m_loadingClients.add(sheet); |
587 } | 582 } |
588 | 583 |
589 void StyleSheetContents::removeSheetFromCache(Document* document) | 584 void StyleSheetContents::removeSheetFromCache(Document* document) |
590 { | 585 { |
591 ASSERT(document); | 586 ASSERT(document); |
592 if (!maybeCacheable()) | |
593 return; | |
594 document->styleEngine()->removeSheet(this); | 587 document->styleEngine()->removeSheet(this); |
595 } | 588 } |
596 | 589 |
597 void StyleSheetContents::addedToMemoryCache() | 590 void StyleSheetContents::addedToMemoryCache() |
598 { | 591 { |
599 ASSERT(!m_isInMemoryCache); | 592 ASSERT(!m_isInMemoryCache); |
600 ASSERT(isCacheable()); | 593 ASSERT(isCacheable()); |
601 m_isInMemoryCache = true; | 594 m_isInMemoryCache = true; |
602 } | 595 } |
603 | 596 |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
695 { | 688 { |
696 visitor->trace(m_ownerRule); | 689 visitor->trace(m_ownerRule); |
697 visitor->trace(m_importRules); | 690 visitor->trace(m_importRules); |
698 visitor->trace(m_childRules); | 691 visitor->trace(m_childRules); |
699 visitor->trace(m_loadingClients); | 692 visitor->trace(m_loadingClients); |
700 visitor->trace(m_completedClients); | 693 visitor->trace(m_completedClients); |
701 visitor->trace(m_ruleSet); | 694 visitor->trace(m_ruleSet); |
702 } | 695 } |
703 | 696 |
704 } | 697 } |
OLD | NEW |