| 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 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 81 // If any changes to CSS Animations were detected, stash the update away for
application after the | 81 // If any changes to CSS Animations were detected, stash the update away for
application after the |
| 82 // render object is updated if we're in the appropriate scope. | 82 // render object is updated if we're in the appropriate scope. |
| 83 if (state.animationUpdate()) | 83 if (state.animationUpdate()) |
| 84 element.ensureActiveAnimations().cssAnimations().setPendingUpdate(state.
takeAnimationUpdate()); | 84 element.ensureActiveAnimations().cssAnimations().setPendingUpdate(state.
takeAnimationUpdate()); |
| 85 } | 85 } |
| 86 | 86 |
| 87 } // namespace | 87 } // namespace |
| 88 | 88 |
| 89 namespace blink { | 89 namespace blink { |
| 90 | 90 |
| 91 static void addFontFaceRule(Document* document, CSSFontSelector* cssFontSelector
, const StyleRuleFontFace* fontFaceRule) | |
| 92 { | |
| 93 RefPtr<FontFace> fontFace = FontFace::create(document, fontFaceRule); | |
| 94 if (fontFace) | |
| 95 cssFontSelector->fontFaceCache()->add(cssFontSelector, fontFaceRule, fon
tFace); | |
| 96 } | |
| 97 | |
| 98 static RuleSet& defaultStyles() | 91 static RuleSet& defaultStyles() |
| 99 { | 92 { |
| 100 DEFINE_STATIC_LOCAL(RefPtr<StyleSheetContents>, styleSheet, ()); | 93 DEFINE_STATIC_LOCAL(RefPtr<StyleSheetContents>, styleSheet, ()); |
| 101 DEFINE_STATIC_LOCAL(OwnPtr<RuleSet>, ruleSet, ()); | 94 DEFINE_STATIC_LOCAL(OwnPtr<RuleSet>, ruleSet, ()); |
| 102 | 95 |
| 103 if (ruleSet) | 96 if (ruleSet) |
| 104 return *ruleSet; | 97 return *ruleSet; |
| 105 | 98 |
| 106 String cssText = | 99 String cssText = |
| 107 "link, import, meta, script, style, template, title {\n" | 100 "link, import, meta, script, style, template, title {\n" |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 157 ASSERT(cssSheet); | 150 ASSERT(cssSheet); |
| 158 if (cssSheet->mediaQueries() && !m_medium->eval(cssSheet->mediaQueries(), &m
_viewportDependentMediaQueryResults)) | 151 if (cssSheet->mediaQueries() && !m_medium->eval(cssSheet->mediaQueries(), &m
_viewportDependentMediaQueryResults)) |
| 159 return; | 152 return; |
| 160 | 153 |
| 161 Node* ownerNode = cssSheet->ownerNode(); | 154 Node* ownerNode = cssSheet->ownerNode(); |
| 162 if (!ownerNode) | 155 if (!ownerNode) |
| 163 return; | 156 return; |
| 164 | 157 |
| 165 TreeScope& treeScope = ownerNode->treeScope(); | 158 TreeScope& treeScope = ownerNode->treeScope(); |
| 166 ScopedStyleResolver& resolver = treeScope.scopedStyleResolver(); | 159 ScopedStyleResolver& resolver = treeScope.scopedStyleResolver(); |
| 167 resolver.addRulesFromSheet(cssSheet, this); | 160 resolver.addRulesFromSheet(cssSheet); |
| 161 |
| 162 RuleSet& ruleSet = cssSheet->contents()->ruleSet(); |
| 163 |
| 164 const MediaQueryResultList& list = ruleSet.viewportDependentMediaQueryResult
s(); |
| 165 for (size_t i = 0; i < list.size(); ++i) |
| 166 m_viewportDependentMediaQueryResults.append(list[i]); |
| 167 |
| 168 // FIXME(BUG 72461): We don't add @font-face rules of scoped style sheets fo
r the moment. |
| 169 if (ownerNode->isDocumentNode()) { |
| 170 CSSFontSelector* fontSelector = document().styleEngine()->fontSelector()
; |
| 171 const Vector<RawPtr<StyleRuleFontFace> > fontFaceRules = ruleSet.fontFac
eRules(); |
| 172 for (unsigned i = 0; i < fontFaceRules.size(); ++i) { |
| 173 if (RefPtr<FontFace> fontFace = FontFace::create(&document(), fontFa
ceRules[i])) |
| 174 fontSelector->fontFaceCache()->add(fontSelector, fontFaceRules[i
], fontFace); |
| 175 } |
| 176 if (fontFaceRules.size()) |
| 177 invalidateMatchedPropertiesCache(); |
| 178 } |
| 168 } | 179 } |
| 169 | 180 |
| 170 void StyleResolver::appendPendingAuthorStyleSheets() | 181 void StyleResolver::appendPendingAuthorStyleSheets() |
| 171 { | 182 { |
| 172 for (ListHashSet<RawPtr<CSSStyleSheet>, 16>::iterator it = m_pendingStyleShe
ets.begin(); it != m_pendingStyleSheets.end(); ++it) | 183 for (ListHashSet<RawPtr<CSSStyleSheet>, 16>::iterator it = m_pendingStyleShe
ets.begin(); it != m_pendingStyleSheets.end(); ++it) |
| 173 appendCSSStyleSheet(*it); | 184 appendCSSStyleSheet(*it); |
| 174 | 185 |
| 175 m_pendingStyleSheets.clear(); | 186 m_pendingStyleSheets.clear(); |
| 176 finishAppendAuthorStyleSheets(); | 187 finishAppendAuthorStyleSheets(); |
| 177 } | 188 } |
| 178 | 189 |
| 179 void StyleResolver::appendAuthorStyleSheets(const Vector<RefPtr<CSSStyleSheet> >
& styleSheets) | 190 void StyleResolver::appendAuthorStyleSheets(const Vector<RefPtr<CSSStyleSheet> >
& styleSheets) |
| 180 { | 191 { |
| 181 // This handles sheets added to the end of the stylesheet list only. In othe
r cases the style resolver | 192 // This handles sheets added to the end of the stylesheet list only. In othe
r cases the style resolver |
| 182 // needs to be reconstructed. To handle insertions too the rule order number
s would need to be updated. | 193 // needs to be reconstructed. To handle insertions too the rule order number
s would need to be updated. |
| 183 unsigned size = styleSheets.size(); | 194 unsigned size = styleSheets.size(); |
| 184 for (unsigned i = 0; i < size; ++i) | 195 for (unsigned i = 0; i < size; ++i) |
| 185 appendCSSStyleSheet(styleSheets[i].get()); | 196 appendCSSStyleSheet(styleSheets[i].get()); |
| 186 } | 197 } |
| 187 | 198 |
| 188 void StyleResolver::finishAppendAuthorStyleSheets() | 199 void StyleResolver::finishAppendAuthorStyleSheets() |
| 189 { | 200 { |
| 190 if (document().renderView() && document().renderView()->style()) | 201 if (document().renderView() && document().renderView()->style()) |
| 191 document().renderView()->style()->font().update(document().styleEngine()
->fontSelector()); | 202 document().renderView()->style()->font().update(document().styleEngine()
->fontSelector()); |
| 192 } | 203 } |
| 193 | 204 |
| 194 void StyleResolver::processScopedRules(const RuleSet& authorRules, CSSStyleSheet
* parentStyleSheet, unsigned parentIndex, ContainerNode& scope) | |
| 195 { | |
| 196 // FIXME(BUG 72461): We don't add @font-face rules of scoped style sheets fo
r the moment. | |
| 197 if (scope.isDocumentNode()) { | |
| 198 const Vector<RawPtr<StyleRuleFontFace> > fontFaceRules = authorRules.fon
tFaceRules(); | |
| 199 for (unsigned i = 0; i < fontFaceRules.size(); ++i) | |
| 200 addFontFaceRule(m_document, document().styleEngine()->fontSelector()
, fontFaceRules[i]); | |
| 201 if (fontFaceRules.size()) | |
| 202 invalidateMatchedPropertiesCache(); | |
| 203 } | |
| 204 } | |
| 205 | |
| 206 void StyleResolver::addToStyleSharingList(Element& element) | 205 void StyleResolver::addToStyleSharingList(Element& element) |
| 207 { | 206 { |
| 208 // Never add elements to the style sharing list if we're not in a recalcStyl
e, | 207 // Never add elements to the style sharing list if we're not in a recalcStyl
e, |
| 209 // otherwise we could leave stale pointers in there. | 208 // otherwise we could leave stale pointers in there. |
| 210 if (!document().inStyleRecalc()) | 209 if (!document().inStyleRecalc()) |
| 211 return; | 210 return; |
| 212 ASSERT(element.supportsStyleSharing()); | 211 ASSERT(element.supportsStyleSharing()); |
| 213 INCREMENT_STYLE_STATS_COUNTER(*this, sharedStyleCandidates); | 212 INCREMENT_STYLE_STATS_COUNTER(*this, sharedStyleCandidates); |
| 214 StyleSharingList& list = styleSharingList(); | 213 StyleSharingList& list = styleSharingList(); |
| 215 if (list.size() >= styleSharingListSize) | 214 if (list.size() >= styleSharingListSize) |
| (...skipping 577 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 793 updateFont(state); | 792 updateFont(state); |
| 794 break; | 793 break; |
| 795 default: | 794 default: |
| 796 break; | 795 break; |
| 797 } | 796 } |
| 798 StyleBuilder::applyProperty(properties[i].property, state, propertie
s[i].value); | 797 StyleBuilder::applyProperty(properties[i].property, state, propertie
s[i].value); |
| 799 } | 798 } |
| 800 } | 799 } |
| 801 } | 800 } |
| 802 | 801 |
| 803 void StyleResolver::addMediaQueryResults(const MediaQueryResultList& list) | |
| 804 { | |
| 805 for (size_t i = 0; i < list.size(); ++i) | |
| 806 m_viewportDependentMediaQueryResults.append(list[i]); | |
| 807 } | |
| 808 | |
| 809 bool StyleResolver::mediaQueryAffectedByViewportChange() const | 802 bool StyleResolver::mediaQueryAffectedByViewportChange() const |
| 810 { | 803 { |
| 811 for (unsigned i = 0; i < m_viewportDependentMediaQueryResults.size(); ++i) { | 804 for (unsigned i = 0; i < m_viewportDependentMediaQueryResults.size(); ++i) { |
| 812 if (m_medium->eval(m_viewportDependentMediaQueryResults[i]->expression()
) != m_viewportDependentMediaQueryResults[i]->result()) | 805 if (m_medium->eval(m_viewportDependentMediaQueryResults[i]->expression()
) != m_viewportDependentMediaQueryResults[i]->result()) |
| 813 return true; | 806 return true; |
| 814 } | 807 } |
| 815 return false; | 808 return false; |
| 816 } | 809 } |
| 817 | 810 |
| 818 } // namespace blink | 811 } // namespace blink |
| OLD | NEW |