| OLD | NEW |
| (Empty) |
| 1 /* | |
| 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. | |
| 4 * | |
| 5 * This library is free software; you can redistribute it and/or | |
| 6 * modify it under the terms of the GNU Library General Public | |
| 7 * License as published by the Free Software Foundation; either | |
| 8 * version 2 of the License, or (at your option) any later version. | |
| 9 * | |
| 10 * This library is distributed in the hope that it will be useful, | |
| 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
| 13 * Library General Public License for more details. | |
| 14 * | |
| 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 | |
| 17 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | |
| 18 * Boston, MA 02110-1301, USA. | |
| 19 * | |
| 20 */ | |
| 21 | |
| 22 #ifndef StyleResolver_h | |
| 23 #define StyleResolver_h | |
| 24 | |
| 25 #include "core/css/CSSRuleList.h" | |
| 26 #include "core/css/CSSToStyleMap.h" | |
| 27 #include "core/css/CSSValueList.h" | |
| 28 #include "core/css/DocumentRuleSets.h" | |
| 29 #include "core/css/InspectorCSSOMWrappers.h" | |
| 30 #include "core/css/MediaQueryExp.h" | |
| 31 #include "core/css/RuleFeature.h" | |
| 32 #include "core/css/RuleSet.h" | |
| 33 #include "core/css/ScopedStyleResolver.h" | |
| 34 #include "core/css/SelectorChecker.h" | |
| 35 #include "core/css/SelectorFilter.h" | |
| 36 #include "core/css/SiblingTraversalStrategies.h" | |
| 37 #include "core/css/StyleResolverState.h" | |
| 38 #include "core/css/ViewportStyleResolver.h" | |
| 39 #include "RuntimeEnabledFeatures.h" | |
| 40 #include "core/platform/LinkHash.h" | |
| 41 #include "core/platform/ScrollTypes.h" | |
| 42 #include "core/rendering/style/RenderStyle.h" | |
| 43 #if ENABLE(SVG) | |
| 44 #include "core/css/WebKitCSSSVGDocumentValue.h" | |
| 45 #endif | |
| 46 #include "core/platform/graphics/filters/custom/CustomFilterConstants.h" | |
| 47 #include <wtf/HashMap.h> | |
| 48 #include <wtf/HashSet.h> | |
| 49 #include <wtf/RefPtr.h> | |
| 50 #include <wtf/text/AtomicStringHash.h> | |
| 51 #include <wtf/text/StringHash.h> | |
| 52 #include <wtf/Vector.h> | |
| 53 | |
| 54 namespace WebCore { | |
| 55 | |
| 56 enum ESmartMinimumForFontSize { DoNotUseSmartMinimumForFontSize, UseSmartMinimum
ForFontFize }; | |
| 57 | |
| 58 class CSSCursorImageValue; | |
| 59 class CSSFontSelector; | |
| 60 class CSSFontFace; | |
| 61 class CSSFontFaceRule; | |
| 62 class CSSImageGeneratorValue; | |
| 63 class CSSImageSetValue; | |
| 64 class CSSImageValue; | |
| 65 class CSSPageRule; | |
| 66 class CSSPrimitiveValue; | |
| 67 class CSSProperty; | |
| 68 class CSSRuleList; | |
| 69 class CSSSelector; | |
| 70 class CSSStyleSheet; | |
| 71 class CSSValue; | |
| 72 class ContainerNode; | |
| 73 class CustomFilterOperation; | |
| 74 class CustomFilterParameter; | |
| 75 class CustomFilterParameterList; | |
| 76 class CustomFilterProgram; | |
| 77 struct CustomFilterProgramMixSettings; | |
| 78 class DeprecatedStyleBuilder; | |
| 79 class Document; | |
| 80 class Element; | |
| 81 class ElementRuleCollector; | |
| 82 class Frame; | |
| 83 class FrameView; | |
| 84 class KURL; | |
| 85 class KeyframeList; | |
| 86 class KeyframeValue; | |
| 87 class MediaQueryEvaluator; | |
| 88 class Node; | |
| 89 class RenderRegion; | |
| 90 class RenderScrollbar; | |
| 91 class RuleData; | |
| 92 class RuleSet; | |
| 93 class Settings; | |
| 94 class StaticCSSRuleList; | |
| 95 class StyleCustomFilterProgramCache; | |
| 96 class StyleImage; | |
| 97 class StyleKeyframe; | |
| 98 class StylePendingImage; | |
| 99 class StylePropertySet; | |
| 100 class StyleRule; | |
| 101 class StyleRuleHost; | |
| 102 class StyleRuleKeyframes; | |
| 103 class StyleRulePage; | |
| 104 class StyleRuleRegion; | |
| 105 class StyleShader; | |
| 106 class StyleSheet; | |
| 107 class StyleSheetList; | |
| 108 class StyledElement; | |
| 109 class ViewportStyleResolver; | |
| 110 class WebKitCSSFilterValue; | |
| 111 class WebKitCSSShaderValue; | |
| 112 class WebKitCSSSVGDocumentValue; | |
| 113 | |
| 114 class MediaQueryResult { | |
| 115 WTF_MAKE_NONCOPYABLE(MediaQueryResult); WTF_MAKE_FAST_ALLOCATED; | |
| 116 public: | |
| 117 MediaQueryResult(const MediaQueryExp& expr, bool result) | |
| 118 : m_expression(expr) | |
| 119 , m_result(result) | |
| 120 { | |
| 121 } | |
| 122 void reportMemoryUsage(MemoryObjectInfo*) const; | |
| 123 | |
| 124 MediaQueryExp m_expression; | |
| 125 bool m_result; | |
| 126 }; | |
| 127 | |
| 128 enum StyleSharingBehavior { | |
| 129 AllowStyleSharing, | |
| 130 DisallowStyleSharing, | |
| 131 }; | |
| 132 | |
| 133 // MatchOnlyUserAgentRules is used in media queries, where relative units | |
| 134 // are interpreted according to the document root element style, and styled only | |
| 135 // from the User Agent Stylesheet rules. | |
| 136 | |
| 137 enum RuleMatchingBehavior { | |
| 138 MatchAllRules, | |
| 139 MatchAllRulesExcludingSMIL, | |
| 140 MatchOnlyUserAgentRules, | |
| 141 }; | |
| 142 | |
| 143 class PseudoStyleRequest { | |
| 144 public: | |
| 145 PseudoStyleRequest(PseudoId pseudoId, RenderScrollbar* scrollbar = 0, Scroll
barPart scrollbarPart = NoPart) | |
| 146 : pseudoId(pseudoId) | |
| 147 , scrollbarPart(scrollbarPart) | |
| 148 , scrollbar(scrollbar) | |
| 149 { | |
| 150 } | |
| 151 | |
| 152 PseudoId pseudoId; | |
| 153 ScrollbarPart scrollbarPart; | |
| 154 RenderScrollbar* scrollbar; | |
| 155 }; | |
| 156 | |
| 157 class MatchRequest { | |
| 158 public: | |
| 159 MatchRequest(RuleSet* ruleSet, bool includeEmptyRules = false, const Contain
erNode* scope = 0) | |
| 160 : ruleSet(ruleSet) | |
| 161 , includeEmptyRules(includeEmptyRules) | |
| 162 , scope(scope) { } | |
| 163 const RuleSet* ruleSet; | |
| 164 const bool includeEmptyRules; | |
| 165 const ContainerNode* scope; | |
| 166 }; | |
| 167 | |
| 168 // This class selects a RenderStyle for a given element based on a collection of
stylesheets. | |
| 169 class StyleResolver { | |
| 170 WTF_MAKE_NONCOPYABLE(StyleResolver); WTF_MAKE_FAST_ALLOCATED; | |
| 171 public: | |
| 172 StyleResolver(Document*, bool matchAuthorAndUserStyles); | |
| 173 ~StyleResolver(); | |
| 174 | |
| 175 // Using these during tree walk will allow style selector to optimize child
and descendant selector lookups. | |
| 176 void pushParentElement(Element*); | |
| 177 void popParentElement(Element*); | |
| 178 void pushParentShadowRoot(const ShadowRoot*); | |
| 179 void popParentShadowRoot(const ShadowRoot*); | |
| 180 void addHostRule(StyleRuleHost* rule, bool hasDocumentSecurityOrigin, const
ContainerNode* scope) { ensureScopeResolver()->addHostRule(rule, hasDocumentSecu
rityOrigin, scope); } | |
| 181 | |
| 182 PassRefPtr<RenderStyle> styleForElement(Element*, RenderStyle* parentStyle =
0, StyleSharingBehavior = AllowStyleSharing, | |
| 183 RuleMatchingBehavior = MatchAllRules, RenderRegion* regionForStyling = 0
); | |
| 184 | |
| 185 void keyframeStylesForAnimation(Element*, const RenderStyle*, KeyframeList&)
; | |
| 186 | |
| 187 PassRefPtr<RenderStyle> pseudoStyleForElement(Element*, const PseudoStyleReq
uest&, RenderStyle* parentStyle); | |
| 188 | |
| 189 PassRefPtr<RenderStyle> styleForPage(int pageIndex); | |
| 190 PassRefPtr<RenderStyle> defaultStyleForElement(); | |
| 191 PassRefPtr<RenderStyle> styleForText(Text*); | |
| 192 | |
| 193 static PassRefPtr<RenderStyle> styleForDocument(Document*, CSSFontSelector*
= 0); | |
| 194 | |
| 195 Color colorFromPrimitiveValue(CSSPrimitiveValue* value, bool forVisitedLink
= false) const | |
| 196 { | |
| 197 return m_state.colorFromPrimitiveValue(value, forVisitedLink); | |
| 198 } | |
| 199 RenderStyle* style() const { return m_state.style(); } | |
| 200 RenderStyle* parentStyle() const { return m_state.parentStyle(); } | |
| 201 RenderStyle* rootElementStyle() const { return m_state.rootElementStyle(); } | |
| 202 Element* element() { return m_state.element(); } | |
| 203 Document* document() { return m_document; } | |
| 204 ScopedStyleResolver* scopeResolver() const { return m_scopeResolver.get(); } | |
| 205 bool hasParentNode() const { return m_state.parentNode(); } | |
| 206 | |
| 207 // FIXME: It could be better to call m_ruleSets.appendAuthorStyleSheets() di
rectly after we factor StyleRsolver further. | |
| 208 // https://bugs.webkit.org/show_bug.cgi?id=108890 | |
| 209 void appendAuthorStyleSheets(unsigned firstNew, const Vector<RefPtr<CSSStyle
Sheet> >&); | |
| 210 | |
| 211 DocumentRuleSets& ruleSets() { return m_ruleSets; } | |
| 212 const DocumentRuleSets& ruleSets() const { return m_ruleSets; } | |
| 213 SelectorFilter& selectorFilter() { return m_selectorFilter; } | |
| 214 | |
| 215 ScopedStyleResolver* ensureScopeResolver() | |
| 216 { | |
| 217 if (!m_scopeResolver) | |
| 218 m_scopeResolver = adoptPtr(new ScopedStyleResolver()); | |
| 219 return m_scopeResolver.get(); | |
| 220 } | |
| 221 | |
| 222 private: | |
| 223 void initElement(Element*); | |
| 224 RenderStyle* locateSharedStyle(); | |
| 225 bool styleSharingCandidateMatchesRuleSet(RuleSet*); | |
| 226 bool styleSharingCandidateMatchesHostRules(); | |
| 227 Node* locateCousinList(Element* parent, unsigned& visitedNodeCount) const; | |
| 228 StyledElement* findSiblingForStyleSharing(Node*, unsigned& count) const; | |
| 229 bool canShareStyleWithElement(StyledElement*) const; | |
| 230 | |
| 231 PassRefPtr<RenderStyle> styleForKeyframe(const RenderStyle*, const StyleKeyf
rame*, KeyframeValue&); | |
| 232 | |
| 233 public: | |
| 234 // These methods will give back the set of rules that matched for a given el
ement (or a pseudo-element). | |
| 235 enum CSSRuleFilter { | |
| 236 UAAndUserCSSRules = 1 << 1, | |
| 237 AuthorCSSRules = 1 << 2, | |
| 238 EmptyCSSRules = 1 << 3, | |
| 239 CrossOriginCSSRules = 1 << 4, | |
| 240 AllButEmptyCSSRules = UAAndUserCSSRules | AuthorCSSRules | CrossOriginCS
SRules, | |
| 241 AllCSSRules = AllButEmptyCSSRules | EmptyCSSRules, | |
| 242 }; | |
| 243 PassRefPtr<CSSRuleList> styleRulesForElement(Element*, unsigned rulesToInclu
de = AllButEmptyCSSRules); | |
| 244 PassRefPtr<CSSRuleList> pseudoStyleRulesForElement(Element*, PseudoId, unsig
ned rulesToInclude = AllButEmptyCSSRules); | |
| 245 | |
| 246 // Given a CSS keyword in the range (xx-small to -webkit-xxx-large), this fu
nction will return | |
| 247 // the correct font size scaled relative to the user's default (medium). | |
| 248 static float fontSizeForKeyword(Document*, int keyword, bool shouldUseFixedD
efaultSize); | |
| 249 | |
| 250 // Given a font size in pixel, this function will return legacy font size be
tween 1 and 7. | |
| 251 static int legacyFontSize(Document*, int pixelFontSize, bool shouldUseFixedD
efaultSize); | |
| 252 | |
| 253 public: | |
| 254 void applyPropertyToStyle(CSSPropertyID, CSSValue*, RenderStyle*); | |
| 255 | |
| 256 void applyPropertyToCurrentStyle(CSSPropertyID, CSSValue*); | |
| 257 | |
| 258 void updateFont(); | |
| 259 void initializeFontStyle(Settings*); | |
| 260 | |
| 261 static float getComputedSizeFromSpecifiedSize(Document*, float zoomFactor, b
ool isAbsoluteSize, float specifiedSize, ESmartMinimumForFontSize = UseSmartMini
mumForFontFize); | |
| 262 | |
| 263 void setFontSize(FontDescription&, float size); | |
| 264 | |
| 265 private: | |
| 266 static float getComputedSizeFromSpecifiedSize(Document*, RenderStyle*, bool
isAbsoluteSize, float specifiedSize, bool useSVGZoomRules); | |
| 267 | |
| 268 public: | |
| 269 bool useSVGZoomRules(); | |
| 270 | |
| 271 static bool colorFromPrimitiveValueIsDerivedFromElement(CSSPrimitiveValue*); | |
| 272 | |
| 273 bool hasSelectorForId(const AtomicString&) const; | |
| 274 bool hasSelectorForClass(const AtomicString&) const; | |
| 275 bool hasSelectorForAttribute(const AtomicString&) const; | |
| 276 | |
| 277 CSSFontSelector* fontSelector() const { return m_fontSelector.get(); } | |
| 278 #if ENABLE(CSS_DEVICE_ADAPTATION) | |
| 279 ViewportStyleResolver* viewportStyleResolver() { return m_viewportStyleResol
ver.get(); } | |
| 280 #endif | |
| 281 | |
| 282 void addViewportDependentMediaQueryResult(const MediaQueryExp*, bool result)
; | |
| 283 bool hasViewportDependentMediaQueries() const { return !m_viewportDependentM
ediaQueryResults.isEmpty(); } | |
| 284 bool affectedByViewportChange() const; | |
| 285 | |
| 286 void addKeyframeStyle(PassRefPtr<StyleRuleKeyframes>); | |
| 287 | |
| 288 bool checkRegionStyle(Element* regionElement); | |
| 289 | |
| 290 bool usesSiblingRules() const { return !m_ruleSets.features().siblingRules.i
sEmpty(); } | |
| 291 bool usesFirstLineRules() const { return m_ruleSets.features().usesFirstLine
Rules; } | |
| 292 bool usesBeforeAfterRules() const { return m_ruleSets.features().usesBeforeA
fterRules; } | |
| 293 | |
| 294 void invalidateMatchedPropertiesCache(); | |
| 295 | |
| 296 void loadPendingShaders(); | |
| 297 #if ENABLE(SVG) | |
| 298 void loadPendingSVGDocuments(); | |
| 299 #endif | |
| 300 | |
| 301 void loadPendingResources(); | |
| 302 | |
| 303 struct RuleRange { | |
| 304 RuleRange(int& firstRuleIndex, int& lastRuleIndex): firstRuleIndex(first
RuleIndex), lastRuleIndex(lastRuleIndex) { } | |
| 305 int& firstRuleIndex; | |
| 306 int& lastRuleIndex; | |
| 307 }; | |
| 308 | |
| 309 struct MatchRanges { | |
| 310 MatchRanges() : firstUARule(-1), lastUARule(-1), firstAuthorRule(-1), la
stAuthorRule(-1), firstUserRule(-1), lastUserRule(-1) { } | |
| 311 int firstUARule; | |
| 312 int lastUARule; | |
| 313 int firstAuthorRule; | |
| 314 int lastAuthorRule; | |
| 315 int firstUserRule; | |
| 316 int lastUserRule; | |
| 317 RuleRange UARuleRange() { return RuleRange(firstUARule, lastUARule); } | |
| 318 RuleRange authorRuleRange() { return RuleRange(firstAuthorRule, lastAuth
orRule); } | |
| 319 RuleRange userRuleRange() { return RuleRange(firstUserRule, lastUserRule
); } | |
| 320 }; | |
| 321 | |
| 322 struct MatchedProperties { | |
| 323 MatchedProperties(); | |
| 324 ~MatchedProperties(); | |
| 325 void reportMemoryUsage(MemoryObjectInfo*) const; | |
| 326 | |
| 327 RefPtr<StylePropertySet> properties; | |
| 328 union { | |
| 329 struct { | |
| 330 unsigned linkMatchType : 2; | |
| 331 unsigned whitelistType : 2; | |
| 332 }; | |
| 333 // Used to make sure all memory is zero-initialized since we compute
the hash over the bytes of this object. | |
| 334 void* possiblyPaddedMember; | |
| 335 }; | |
| 336 }; | |
| 337 | |
| 338 struct MatchResult { | |
| 339 MatchResult() : isCacheable(true) { } | |
| 340 Vector<MatchedProperties, 64> matchedProperties; | |
| 341 Vector<StyleRule*, 64> matchedRules; | |
| 342 MatchRanges ranges; | |
| 343 bool isCacheable; | |
| 344 | |
| 345 void addMatchedProperties(const StylePropertySet* properties, StyleRule*
= 0, unsigned linkMatchType = SelectorChecker::MatchAll, PropertyWhitelistType
= PropertyWhitelistNone); | |
| 346 }; | |
| 347 | |
| 348 private: | |
| 349 void matchUARules(ElementRuleCollector&, RuleSet*); | |
| 350 void matchAuthorRules(ElementRuleCollector&, bool includeEmptyRules); | |
| 351 void matchShadowDistributedRules(ElementRuleCollector&, bool includeEmptyRul
es, RuleRange&); | |
| 352 void matchHostRules(ElementRuleCollector&, bool includeEmptyRules); | |
| 353 void matchScopedAuthorRules(ElementRuleCollector&, bool includeEmptyRules); | |
| 354 void matchAllRules(ElementRuleCollector&, bool matchAuthorAndUserStyles, boo
l includeSMILProperties); | |
| 355 void matchUARules(ElementRuleCollector&); | |
| 356 void matchUserRules(ElementRuleCollector&, bool includeEmptyRules); | |
| 357 | |
| 358 private: | |
| 359 // This function fixes up the default font size if it detects that the curre
nt generic font family has changed. -dwh | |
| 360 void checkForGenericFamilyChange(RenderStyle*, RenderStyle* parentStyle); | |
| 361 void checkForZoomChange(RenderStyle*, RenderStyle* parentStyle); | |
| 362 | |
| 363 void adjustRenderStyle(RenderStyle* styleToAdjust, RenderStyle* parentStyle,
Element*); | |
| 364 void adjustGridItemPosition(RenderStyle* styleToAdjust) const; | |
| 365 | |
| 366 bool fastRejectSelector(const RuleData&) const; | |
| 367 | |
| 368 void applyMatchedProperties(const MatchResult&, const Element*); | |
| 369 | |
| 370 enum StyleApplicationPass { | |
| 371 VariableDefinitions, | |
| 372 HighPriorityProperties, | |
| 373 LowPriorityProperties | |
| 374 }; | |
| 375 template <StyleApplicationPass pass> | |
| 376 void applyMatchedProperties(const MatchResult&, bool important, int startInd
ex, int endIndex, bool inheritedOnly); | |
| 377 template <StyleApplicationPass pass> | |
| 378 void applyProperties(const StylePropertySet* properties, StyleRule*, bool is
Important, bool inheritedOnly, PropertyWhitelistType = PropertyWhitelistNone); | |
| 379 template <StyleApplicationPass pass> | |
| 380 void applyAnimatedProperties(const Element* target); | |
| 381 void resolveVariables(CSSPropertyID, CSSValue*, Vector<std::pair<CSSProperty
ID, String> >& knownExpressions); | |
| 382 static bool isValidRegionStyleProperty(CSSPropertyID); | |
| 383 static bool isValidCueStyleProperty(CSSPropertyID); | |
| 384 void matchPageRules(MatchResult&, RuleSet*, bool isLeftPage, bool isFirstPag
e, const String& pageName); | |
| 385 void matchPageRulesForList(Vector<StyleRulePage*>& matchedRules, const Vecto
r<StyleRulePage*>&, bool isLeftPage, bool isFirstPage, const String& pageName); | |
| 386 Settings* documentSettings() { return m_document->settings(); } | |
| 387 | |
| 388 bool isLeftPage(int pageIndex) const; | |
| 389 bool isRightPage(int pageIndex) const { return !isLeftPage(pageIndex); } | |
| 390 bool isFirstPage(int pageIndex) const; | |
| 391 String pageName(int pageIndex) const; | |
| 392 | |
| 393 DocumentRuleSets m_ruleSets; | |
| 394 | |
| 395 typedef HashMap<AtomicStringImpl*, RefPtr<StyleRuleKeyframes> > KeyframesRul
eMap; | |
| 396 KeyframesRuleMap m_keyframesRuleMap; | |
| 397 | |
| 398 public: | |
| 399 static RenderStyle* styleNotYetAvailable() { return s_styleNotYetAvailable;
} | |
| 400 | |
| 401 PassRefPtr<StyleImage> styleImage(CSSPropertyID, CSSValue*); | |
| 402 PassRefPtr<StyleImage> cachedOrPendingFromValue(CSSPropertyID, CSSImageValue
*); | |
| 403 PassRefPtr<StyleImage> generatedOrPendingFromValue(CSSPropertyID, CSSImageGe
neratorValue*); | |
| 404 PassRefPtr<StyleImage> setOrPendingFromValue(CSSPropertyID, CSSImageSetValue
*); | |
| 405 PassRefPtr<StyleImage> cursorOrPendingFromValue(CSSPropertyID, CSSCursorImag
eValue*); | |
| 406 | |
| 407 bool applyPropertyToRegularStyle() const { return m_state.applyPropertyToReg
ularStyle(); } | |
| 408 bool applyPropertyToVisitedLinkStyle() const { return m_state.applyPropertyT
oVisitedLinkStyle(); } | |
| 409 | |
| 410 static Length convertToIntLength(CSSPrimitiveValue*, RenderStyle*, RenderSty
le* rootStyle, double multiplier = 1); | |
| 411 static Length convertToFloatLength(CSSPrimitiveValue*, RenderStyle*, RenderS
tyle* rootStyle, double multiplier = 1); | |
| 412 | |
| 413 CSSToStyleMap* styleMap() { return &m_styleMap; } | |
| 414 InspectorCSSOMWrappers& inspectorCSSOMWrappers() { return m_inspectorCSSOMWr
appers; } | |
| 415 const FontDescription& fontDescription() { return m_state.fontDescription();
} | |
| 416 const FontDescription& parentFontDescription() { return m_state.parentFontDe
scription(); } | |
| 417 void setFontDescription(const FontDescription& fontDescription) { m_state.se
tFontDescription(fontDescription); } | |
| 418 void setZoom(float f) { m_state.setZoom(f); } | |
| 419 void setEffectiveZoom(float f) { m_state.setEffectiveZoom(f); } | |
| 420 void setWritingMode(WritingMode writingMode) { m_state.setWritingMode(writin
gMode); } | |
| 421 void setTextOrientation(TextOrientation textOrientation) { m_state.setTextOr
ientation(textOrientation); } | |
| 422 | |
| 423 void reportMemoryUsage(MemoryObjectInfo*) const; | |
| 424 | |
| 425 private: | |
| 426 static RenderStyle* s_styleNotYetAvailable; | |
| 427 | |
| 428 void cacheBorderAndBackground(); | |
| 429 | |
| 430 private: | |
| 431 bool canShareStyleWithControl(StyledElement*) const; | |
| 432 | |
| 433 void applyProperty(CSSPropertyID, CSSValue*); | |
| 434 | |
| 435 #if ENABLE(SVG) | |
| 436 void applySVGProperty(CSSPropertyID, CSSValue*); | |
| 437 #endif | |
| 438 | |
| 439 PassRefPtr<StyleImage> loadPendingImage(StylePendingImage*); | |
| 440 void loadPendingImages(); | |
| 441 | |
| 442 static unsigned computeMatchedPropertiesHash(const MatchedProperties*, unsig
ned size); | |
| 443 struct MatchedPropertiesCacheItem { | |
| 444 void reportMemoryUsage(MemoryObjectInfo*) const; | |
| 445 Vector<MatchedProperties> matchedProperties; | |
| 446 MatchRanges ranges; | |
| 447 RefPtr<RenderStyle> renderStyle; | |
| 448 RefPtr<RenderStyle> parentRenderStyle; | |
| 449 }; | |
| 450 const MatchedPropertiesCacheItem* findFromMatchedPropertiesCache(unsigned ha
sh, const MatchResult&); | |
| 451 void addToMatchedPropertiesCache(const RenderStyle*, const RenderStyle* pare
ntStyle, unsigned hash, const MatchResult&); | |
| 452 | |
| 453 // Every N additions to the matched declaration cache trigger a sweep where
entries holding | |
| 454 // the last reference to a style declaration are garbage collected. | |
| 455 void sweepMatchedPropertiesCache(Timer<StyleResolver>*); | |
| 456 | |
| 457 bool classNamesAffectedByRules(const SpaceSplitString&) const; | |
| 458 bool sharingCandidateHasIdenticalStyleAffectingAttributes(StyledElement*) co
nst; | |
| 459 | |
| 460 unsigned m_matchedPropertiesCacheAdditionsSinceLastSweep; | |
| 461 | |
| 462 typedef HashMap<unsigned, MatchedPropertiesCacheItem> MatchedPropertiesCache
; | |
| 463 MatchedPropertiesCache m_matchedPropertiesCache; | |
| 464 | |
| 465 Timer<StyleResolver> m_matchedPropertiesCacheSweepTimer; | |
| 466 | |
| 467 OwnPtr<MediaQueryEvaluator> m_medium; | |
| 468 RefPtr<RenderStyle> m_rootDefaultStyle; | |
| 469 | |
| 470 Document* m_document; | |
| 471 SelectorFilter m_selectorFilter; | |
| 472 | |
| 473 bool m_matchAuthorAndUserStyles; | |
| 474 | |
| 475 RefPtr<CSSFontSelector> m_fontSelector; | |
| 476 Vector<OwnPtr<MediaQueryResult> > m_viewportDependentMediaQueryResults; | |
| 477 | |
| 478 #if ENABLE(CSS_DEVICE_ADAPTATION) | |
| 479 RefPtr<ViewportStyleResolver> m_viewportStyleResolver; | |
| 480 #endif | |
| 481 | |
| 482 const DeprecatedStyleBuilder& m_styleBuilder; | |
| 483 | |
| 484 OwnPtr<ScopedStyleResolver> m_scopeResolver; | |
| 485 CSSToStyleMap m_styleMap; | |
| 486 InspectorCSSOMWrappers m_inspectorCSSOMWrappers; | |
| 487 | |
| 488 StyleResolverState m_state; | |
| 489 | |
| 490 OwnPtr<StyleCustomFilterProgramCache> m_customFilterProgramCache; | |
| 491 | |
| 492 friend class DeprecatedStyleBuilder; | |
| 493 friend bool operator==(const MatchedProperties&, const MatchedProperties&); | |
| 494 friend bool operator!=(const MatchedProperties&, const MatchedProperties&); | |
| 495 friend bool operator==(const MatchRanges&, const MatchRanges&); | |
| 496 friend bool operator!=(const MatchRanges&, const MatchRanges&); | |
| 497 }; | |
| 498 | |
| 499 inline bool StyleResolver::hasSelectorForAttribute(const AtomicString &attribute
Name) const | |
| 500 { | |
| 501 ASSERT(!attributeName.isEmpty()); | |
| 502 return m_ruleSets.features().attrsInRules.contains(attributeName.impl()); | |
| 503 } | |
| 504 | |
| 505 inline bool StyleResolver::hasSelectorForClass(const AtomicString& classValue) c
onst | |
| 506 { | |
| 507 ASSERT(!classValue.isEmpty()); | |
| 508 return m_ruleSets.features().classesInRules.contains(classValue.impl()); | |
| 509 } | |
| 510 | |
| 511 inline bool StyleResolver::hasSelectorForId(const AtomicString& idValue) const | |
| 512 { | |
| 513 ASSERT(!idValue.isEmpty()); | |
| 514 return m_ruleSets.features().idsInRules.contains(idValue.impl()); | |
| 515 } | |
| 516 | |
| 517 inline bool checkRegionSelector(const CSSSelector* regionSelector, Element* regi
onElement) | |
| 518 { | |
| 519 if (!regionSelector || !regionElement) | |
| 520 return false; | |
| 521 | |
| 522 SelectorChecker selectorChecker(regionElement->document(), SelectorChecker::
QueryingRules); | |
| 523 for (const CSSSelector* s = regionSelector; s; s = CSSSelectorList::next(s))
{ | |
| 524 SelectorChecker::SelectorCheckingContext selectorCheckingContext(s, regi
onElement, SelectorChecker::VisitedMatchDisabled); | |
| 525 PseudoId ignoreDynamicPseudo = NOPSEUDO; | |
| 526 if (selectorChecker.match(selectorCheckingContext, ignoreDynamicPseudo,
DOMSiblingTraversalStrategy()) == SelectorChecker::SelectorMatches) | |
| 527 return true; | |
| 528 } | |
| 529 return false; | |
| 530 } | |
| 531 | |
| 532 } // namespace WebCore | |
| 533 | |
| 534 #endif // StyleResolver_h | |
| OLD | NEW |