| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) | 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) |
| 3 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc.
All rights reserved. | 3 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 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, |
| 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 13 * Library General Public License for more details. | 13 * Library General Public License for more details. |
| 14 * | 14 * |
| 15 * You should have received a copy of the GNU Library General Public License | 15 * You should have received a copy of the GNU Library General Public License |
| 16 * along with this library; see the file COPYING.LIB. If not, write to | 16 * along with this library; see the file COPYING.LIB. If not, write to |
| 17 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | 17 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
| 18 * Boston, MA 02110-1301, USA. | 18 * Boston, MA 02110-1301, USA. |
| 19 * | 19 * |
| 20 */ | 20 */ |
| 21 | 21 |
| 22 #ifndef SKY_ENGINE_CORE_CSS_RESOLVER_STYLERESOLVER_H_ | 22 #ifndef SKY_ENGINE_CORE_CSS_RESOLVER_STYLERESOLVER_H_ |
| 23 #define SKY_ENGINE_CORE_CSS_RESOLVER_STYLERESOLVER_H_ | 23 #define SKY_ENGINE_CORE_CSS_RESOLVER_STYLERESOLVER_H_ |
| 24 | 24 |
| 25 #include "sky/engine/core/css/RuleFeature.h" | |
| 26 #include "sky/engine/core/css/RuleSet.h" | 25 #include "sky/engine/core/css/RuleSet.h" |
| 27 #include "sky/engine/core/css/SelectorChecker.h" | 26 #include "sky/engine/core/css/SelectorChecker.h" |
| 28 #include "sky/engine/core/css/resolver/MatchedPropertiesCache.h" | 27 #include "sky/engine/core/css/resolver/MatchedPropertiesCache.h" |
| 29 #include "sky/engine/core/css/resolver/ScopedStyleResolver.h" | 28 #include "sky/engine/core/css/resolver/ScopedStyleResolver.h" |
| 30 #include "sky/engine/core/css/resolver/StyleBuilder.h" | 29 #include "sky/engine/core/css/resolver/StyleBuilder.h" |
| 31 #include "sky/engine/core/css/resolver/StyleResourceLoader.h" | 30 #include "sky/engine/core/css/resolver/StyleResourceLoader.h" |
| 32 #include "sky/engine/platform/heap/Handle.h" | 31 #include "sky/engine/platform/heap/Handle.h" |
| 33 #include "sky/engine/wtf/Deque.h" | 32 #include "sky/engine/wtf/Deque.h" |
| 34 #include "sky/engine/wtf/HashMap.h" | 33 #include "sky/engine/wtf/HashMap.h" |
| 35 #include "sky/engine/wtf/HashSet.h" | 34 #include "sky/engine/wtf/HashSet.h" |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 109 | 108 |
| 110 static PassRefPtr<RenderStyle> styleForDocument(Document&); | 109 static PassRefPtr<RenderStyle> styleForDocument(Document&); |
| 111 | 110 |
| 112 // FIXME: This only has 5 callers and should be removed. Callers should be e
xplicit about | 111 // FIXME: This only has 5 callers and should be removed. Callers should be e
xplicit about |
| 113 // their dependency on Document* instead of grabbing one through StyleResolv
er. | 112 // their dependency on Document* instead of grabbing one through StyleResolv
er. |
| 114 Document& document() { return *m_document; } | 113 Document& document() { return *m_document; } |
| 115 | 114 |
| 116 // FIXME: It could be better to call appendAuthorStyleSheets() directly afte
r we factor StyleResolver further. | 115 // FIXME: It could be better to call appendAuthorStyleSheets() directly afte
r we factor StyleResolver further. |
| 117 // https://bugs.webkit.org/show_bug.cgi?id=108890 | 116 // https://bugs.webkit.org/show_bug.cgi?id=108890 |
| 118 void appendAuthorStyleSheets(const Vector<RefPtr<CSSStyleSheet> >&); | 117 void appendAuthorStyleSheets(const Vector<RefPtr<CSSStyleSheet> >&); |
| 119 void resetAuthorStyle(TreeScope&); | |
| 120 void finishAppendAuthorStyleSheets(); | 118 void finishAppendAuthorStyleSheets(); |
| 121 | 119 |
| 122 void processScopedRules(const RuleSet& authorRules, CSSStyleSheet*, unsigned
sheetIndex, ContainerNode& scope); | 120 void processScopedRules(const RuleSet& authorRules, CSSStyleSheet*, unsigned
sheetIndex, ContainerNode& scope); |
| 123 | 121 |
| 124 void lazyAppendAuthorStyleSheets(unsigned firstNew, const Vector<RefPtr<CSSS
tyleSheet> >&); | 122 void lazyAppendAuthorStyleSheets(unsigned firstNew, const Vector<RefPtr<CSSS
tyleSheet> >&); |
| 125 void removePendingAuthorStyleSheets(const Vector<RefPtr<CSSStyleSheet> >&); | 123 void removePendingAuthorStyleSheets(const Vector<RefPtr<CSSStyleSheet> >&); |
| 126 void appendPendingAuthorStyleSheets(); | 124 void appendPendingAuthorStyleSheets(); |
| 127 bool hasPendingAuthorStyleSheets() const { return m_pendingStyleSheets.size(
) > 0 || m_needCollectFeatures; } | 125 bool hasPendingAuthorStyleSheets() const { return m_pendingStyleSheets.size(
) > 0; } |
| 128 | 126 |
| 129 void styleTreeResolveScopedKeyframesRules(const Element*, Vector<RawPtr<Scop
edStyleResolver>, 8>&); | 127 void styleTreeResolveScopedKeyframesRules(const Element*, Vector<RawPtr<Scop
edStyleResolver>, 8>&); |
| 130 | 128 |
| 131 // |properties| is an array with |count| elements. | 129 // |properties| is an array with |count| elements. |
| 132 void applyPropertiesToStyle(const CSSPropertyValue* properties, size_t count
, RenderStyle*); | 130 void applyPropertiesToStyle(const CSSPropertyValue* properties, size_t count
, RenderStyle*); |
| 133 | 131 |
| 134 void addMediaQueryResults(const MediaQueryResultList&); | 132 void addMediaQueryResults(const MediaQueryResultList&); |
| 135 bool mediaQueryAffectedByViewportChange() const; | 133 bool mediaQueryAffectedByViewportChange() const; |
| 136 | 134 |
| 137 // FIXME: Rename to reflect the purpose, like didChangeFontSize or something
. | 135 // FIXME: Rename to reflect the purpose, like didChangeFontSize or something
. |
| 138 void invalidateMatchedPropertiesCache(); | 136 void invalidateMatchedPropertiesCache(); |
| 139 | 137 |
| 140 void notifyResizeForViewportUnits(); | 138 void notifyResizeForViewportUnits(); |
| 141 | 139 |
| 142 // Exposed for RenderStyle::isStyleAvilable(). | 140 // Exposed for RenderStyle::isStyleAvilable(). |
| 143 static RenderStyle* styleNotYetAvailable() { return s_styleNotYetAvailable;
} | 141 static RenderStyle* styleNotYetAvailable() { return s_styleNotYetAvailable;
} |
| 144 | 142 |
| 145 RuleFeatureSet& ensureUpdatedRuleFeatureSet() | |
| 146 { | |
| 147 if (hasPendingAuthorStyleSheets()) | |
| 148 appendPendingAuthorStyleSheets(); | |
| 149 return m_features; | |
| 150 } | |
| 151 | |
| 152 RuleFeatureSet& ruleFeatureSet() | |
| 153 { | |
| 154 return m_features; | |
| 155 } | |
| 156 | |
| 157 StyleSharingList& styleSharingList(); | 143 StyleSharingList& styleSharingList(); |
| 158 | 144 |
| 159 bool hasRulesForId(const AtomicString&) const; | |
| 160 | |
| 161 void addToStyleSharingList(Element&); | 145 void addToStyleSharingList(Element&); |
| 162 void clearStyleSharingList(); | 146 void clearStyleSharingList(); |
| 163 | 147 |
| 164 StyleResolverStats* stats() { return m_styleResolverStats.get(); } | 148 StyleResolverStats* stats() { return m_styleResolverStats.get(); } |
| 165 StyleResolverStats* statsTotals() { return m_styleResolverStatsTotals.get();
} | 149 StyleResolverStats* statsTotals() { return m_styleResolverStatsTotals.get();
} |
| 166 enum StatsReportType { ReportDefaultStats, ReportSlowStats }; | 150 enum StatsReportType { ReportDefaultStats, ReportSlowStats }; |
| 167 void enableStats(StatsReportType = ReportDefaultStats); | 151 void enableStats(StatsReportType = ReportDefaultStats); |
| 168 void disableStats(); | 152 void disableStats(); |
| 169 void printStats(); | 153 void printStats(); |
| 170 | 154 |
| 171 unsigned accessCount() const { return m_accessCount; } | 155 unsigned accessCount() const { return m_accessCount; } |
| 172 void didAccess() { ++m_accessCount; } | 156 void didAccess() { ++m_accessCount; } |
| 173 | 157 |
| 174 void increaseStyleSharingDepth() { ++m_styleSharingDepth; } | 158 void increaseStyleSharingDepth() { ++m_styleSharingDepth; } |
| 175 void decreaseStyleSharingDepth() { --m_styleSharingDepth; } | 159 void decreaseStyleSharingDepth() { --m_styleSharingDepth; } |
| 176 | 160 |
| 177 private: | 161 private: |
| 178 // FIXME: This should probably go away, folded into FontBuilder. | 162 // FIXME: This should probably go away, folded into FontBuilder. |
| 179 void updateFont(StyleResolverState&); | 163 void updateFont(StyleResolverState&); |
| 180 | 164 |
| 181 void loadPendingResources(StyleResolverState&); | 165 void loadPendingResources(StyleResolverState&); |
| 182 | 166 |
| 183 void appendCSSStyleSheet(CSSStyleSheet*); | 167 void appendCSSStyleSheet(CSSStyleSheet*); |
| 184 | 168 |
| 185 void matchUARules(ElementRuleCollector&, RuleSet*); | 169 void matchUARules(ElementRuleCollector&, RuleSet*); |
| 186 void matchAuthorRules(Element*, ElementRuleCollector&, bool includeEmptyRule
s); | 170 void matchAuthorRules(Element*, ElementRuleCollector&, bool includeEmptyRule
s); |
| 187 void matchAuthorRulesForShadowHost(Element*, ElementRuleCollector&, bool inc
ludeEmptyRules, Vector<RawPtr<ScopedStyleResolver>, 8>& resolvers, Vector<RawPtr
<ScopedStyleResolver>, 8>& resolversInShadowTree); | 171 void matchAuthorRulesForShadowHost(Element*, ElementRuleCollector&, bool inc
ludeEmptyRules, Vector<RawPtr<ScopedStyleResolver>, 8>& resolvers, Vector<RawPtr
<ScopedStyleResolver>, 8>& resolversInShadowTree); |
| 188 void matchAllRules(StyleResolverState&, ElementRuleCollector&, bool includeS
MILProperties); | 172 void matchAllRules(StyleResolverState&, ElementRuleCollector&, bool includeS
MILProperties); |
| 189 void matchUARules(ElementRuleCollector&); | 173 void matchUARules(ElementRuleCollector&); |
| 190 void collectFeatures(); | |
| 191 void resetRuleFeatures(); | |
| 192 | 174 |
| 193 void applyMatchedProperties(StyleResolverState&, const MatchResult&); | 175 void applyMatchedProperties(StyleResolverState&, const MatchResult&); |
| 194 bool applyAnimatedProperties(StyleResolverState&, Element* animatingElement)
; | 176 bool applyAnimatedProperties(StyleResolverState&, Element* animatingElement)
; |
| 195 | 177 |
| 196 void collectScopedResolversForHostedShadowTrees(const Element*, Vector<RawPt
r<ScopedStyleResolver>, 8>&); | 178 void collectScopedResolversForHostedShadowTrees(const Element*, Vector<RawPt
r<ScopedStyleResolver>, 8>&); |
| 197 | 179 |
| 198 enum StyleApplicationPass { | 180 enum StyleApplicationPass { |
| 199 HighPriorityProperties, | 181 HighPriorityProperties, |
| 200 LowPriorityProperties | 182 LowPriorityProperties |
| 201 }; | 183 }; |
| (...skipping 20 matching lines...) Expand all Loading... |
| 222 | 204 |
| 223 MatchedPropertiesCache m_matchedPropertiesCache; | 205 MatchedPropertiesCache m_matchedPropertiesCache; |
| 224 | 206 |
| 225 OwnPtr<MediaQueryEvaluator> m_medium; | 207 OwnPtr<MediaQueryEvaluator> m_medium; |
| 226 MediaQueryResultList m_viewportDependentMediaQueryResults; | 208 MediaQueryResultList m_viewportDependentMediaQueryResults; |
| 227 | 209 |
| 228 RawPtr<Document> m_document; | 210 RawPtr<Document> m_document; |
| 229 | 211 |
| 230 ListHashSet<RawPtr<CSSStyleSheet>, 16> m_pendingStyleSheets; | 212 ListHashSet<RawPtr<CSSStyleSheet>, 16> m_pendingStyleSheets; |
| 231 | 213 |
| 232 // FIXME: The entire logic of collecting features on StyleResolver, as well
as transferring them | |
| 233 // between various parts of machinery smells wrong. This needs to be better
somehow. | |
| 234 RuleFeatureSet m_features; | |
| 235 | |
| 236 bool m_needCollectFeatures; | |
| 237 bool m_printMediaType; | 214 bool m_printMediaType; |
| 238 | 215 |
| 239 StyleResourceLoader m_styleResourceLoader; | 216 StyleResourceLoader m_styleResourceLoader; |
| 240 | 217 |
| 241 unsigned m_styleSharingDepth; | 218 unsigned m_styleSharingDepth; |
| 242 Vector<OwnPtr<StyleSharingList>, styleSharingMaxDepth> m_styleSharingLists; | 219 Vector<OwnPtr<StyleSharingList>, styleSharingMaxDepth> m_styleSharingLists; |
| 243 | 220 |
| 244 OwnPtr<StyleResolverStats> m_styleResolverStats; | 221 OwnPtr<StyleResolverStats> m_styleResolverStats; |
| 245 OwnPtr<StyleResolverStats> m_styleResolverStatsTotals; | 222 OwnPtr<StyleResolverStats> m_styleResolverStatsTotals; |
| 246 unsigned m_styleResolverStatsSequence; | 223 unsigned m_styleResolverStatsSequence; |
| 247 | 224 |
| 248 // Use only for Internals::updateStyleAndReturnAffectedElementCount. | 225 // Use only for Internals::updateStyleAndReturnAffectedElementCount. |
| 249 unsigned m_accessCount; | 226 unsigned m_accessCount; |
| 250 }; | 227 }; |
| 251 | 228 |
| 252 } // namespace blink | 229 } // namespace blink |
| 253 | 230 |
| 254 #endif // SKY_ENGINE_CORE_CSS_RESOLVER_STYLERESOLVER_H_ | 231 #endif // SKY_ENGINE_CORE_CSS_RESOLVER_STYLERESOLVER_H_ |
| OLD | NEW |