Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(81)

Side by Side Diff: third_party/WebKit/Source/core/css/resolver/ScopedStyleResolver.cpp

Issue 1382353002: Oilpan: promptly dispose style resolvers upon clearing. Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebased Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 * Copyright (C) 2012 Google Inc. All rights reserved. 4 * Copyright (C) 2012 Google Inc. All rights reserved.
5 * 5 *
6 * Redistribution and use in source and binary forms, with or without 6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions 7 * modification, are permitted provided that the following conditions
8 * are met: 8 * are met:
9 * 1. Redistributions of source code must retain the above copyright 9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
(...skipping 28 matching lines...) Expand all
39 #include "core/css/resolver/ViewportStyleResolver.h" 39 #include "core/css/resolver/ViewportStyleResolver.h"
40 #include "core/dom/Document.h" 40 #include "core/dom/Document.h"
41 #include "core/dom/StyleEngine.h" 41 #include "core/dom/StyleEngine.h"
42 #include "core/dom/shadow/ElementShadow.h" 42 #include "core/dom/shadow/ElementShadow.h"
43 #include "core/dom/shadow/ShadowRoot.h" 43 #include "core/dom/shadow/ShadowRoot.h"
44 #include "core/html/HTMLStyleElement.h" 44 #include "core/html/HTMLStyleElement.h"
45 #include "core/svg/SVGStyleElement.h" 45 #include "core/svg/SVGStyleElement.h"
46 46
47 namespace blink { 47 namespace blink {
48 48
49 void ScopedStyleResolver::dispose()
50 {
51 m_keyframesRuleMap.clear();
52
53 if (m_treeBoundaryCrossingRuleSet) {
54 for (size_t i = 0; i < m_treeBoundaryCrossingRuleSet->size(); ++i) {
55 if (RuleSet* ruleSet = m_treeBoundaryCrossingRuleSet->at(i)->m_ruleS et.get())
56 ruleSet->dispose();
57 }
58
59 m_treeBoundaryCrossingRuleSet->clear();
60 m_treeBoundaryCrossingRuleSet.clear();
61 }
62
63 }
64
49 ScopedStyleResolver* ScopedStyleResolver::parent() const 65 ScopedStyleResolver* ScopedStyleResolver::parent() const
50 { 66 {
51 for (TreeScope* scope = treeScope().parentTreeScope(); scope; scope = scope- >parentTreeScope()) { 67 for (TreeScope* scope = treeScope().parentTreeScope(); scope; scope = scope- >parentTreeScope()) {
52 if (ScopedStyleResolver* resolver = scope->scopedStyleResolver()) 68 if (ScopedStyleResolver* resolver = scope->scopedStyleResolver())
53 return resolver; 69 return resolver;
54 } 70 }
55 return nullptr; 71 return nullptr;
56 } 72 }
57 73
58 void ScopedStyleResolver::addKeyframeRules(const RuleSet& ruleSet) 74 void ScopedStyleResolver::addKeyframeRules(const RuleSet& ruleSet)
59 { 75 {
60 const WillBeHeapVector<RawPtrWillBeMember<StyleRuleKeyframes>> keyframesRule s = ruleSet.keyframesRules(); 76 const WillBeHeapVector<RawPtrWillBeMember<StyleRuleKeyframes>> keyframesRule s = ruleSet.keyframesRules();
61 for (unsigned i = 0; i < keyframesRules.size(); ++i) 77 for (unsigned i = 0; i < keyframesRules.size(); ++i)
62 addKeyframeStyle(keyframesRules[i]); 78 addKeyframeStyle(keyframesRules[i]);
63 } 79 }
64 80
65 void ScopedStyleResolver::addFontFaceRules(const RuleSet& ruleSet) 81 void ScopedStyleResolver::addFontFaceRules(const RuleSet& ruleSet)
66 { 82 {
67 // FIXME(BUG 72461): We don't add @font-face rules of scoped style sheets fo r the moment. 83 // FIXME(BUG 72461): We don't add @font-face rules of scoped style sheets fo r the moment.
68 if (!treeScope().rootNode().isDocumentNode()) 84 if (!treeScope().rootNode().isDocumentNode())
69 return; 85 return;
70 86
71 Document& document = treeScope().document(); 87 Document& document = treeScope().document();
72 CSSFontSelector* cssFontSelector = document.styleEngine().fontSelector(); 88 CSSFontSelector* cssFontSelector = document.styleEngine().fontSelector();
73 const WillBeHeapVector<RawPtrWillBeMember<StyleRuleFontFace>> fontFaceRules = ruleSet.fontFaceRules(); 89 const WillBeHeapVector<RawPtrWillBeMember<StyleRuleFontFace>> fontFaceRules = ruleSet.fontFaceRules();
90 if (!fontFaceRules.size())
91 return;
74 for (auto& fontFaceRule : fontFaceRules) { 92 for (auto& fontFaceRule : fontFaceRules) {
75 if (RefPtrWillBeRawPtr<FontFace> fontFace = FontFace::create(&document, fontFaceRule)) 93 if (RefPtrWillBeRawPtr<FontFace> fontFace = FontFace::create(&document, fontFaceRule))
76 cssFontSelector->fontFaceCache()->add(cssFontSelector, fontFaceRule, fontFace); 94 cssFontSelector->fontFaceCache()->add(cssFontSelector, fontFaceRule, fontFace);
77 } 95 }
78 if (fontFaceRules.size()) 96 document.styleResolver()->invalidateMatchedPropertiesCache();
79 document.styleResolver()->invalidateMatchedPropertiesCache();
80 } 97 }
81 98
82 void ScopedStyleResolver::appendCSSStyleSheet(CSSStyleSheet& cssSheet, const Med iaQueryEvaluator& medium) 99 void ScopedStyleResolver::appendCSSStyleSheet(CSSStyleSheet& cssSheet, const Med iaQueryEvaluator& medium)
83 { 100 {
84 unsigned index = m_authorStyleSheets.size(); 101 unsigned index = m_authorStyleSheets.size();
85 m_authorStyleSheets.append(&cssSheet); 102 m_authorStyleSheets.append(&cssSheet);
86 StyleSheetContents* sheet = cssSheet.contents(); 103 StyleSheetContents* sheet = cssSheet.contents();
87 AddRuleFlags addRuleFlags = treeScope().document().securityOrigin()->canRequ est(sheet->baseURL()) ? RuleHasDocumentSecurityOrigin : RuleHasNoSpecialState; 104 AddRuleFlags addRuleFlags = treeScope().document().securityOrigin()->canRequ est(sheet->baseURL()) ? RuleHasDocumentSecurityOrigin : RuleHasNoSpecialState;
88 const RuleSet& ruleSet = sheet->ensureRuleSet(medium, addRuleFlags); 105 const RuleSet& ruleSet = sheet->ensureRuleSet(medium, addRuleFlags);
89 106
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
229 m_treeBoundaryCrossingRuleSet->append(RuleSubSet::create(parentStyleSheet, s heetIndex, ruleSetForScope.release())); 246 m_treeBoundaryCrossingRuleSet->append(RuleSubSet::create(parentStyleSheet, s heetIndex, ruleSetForScope.release()));
230 } 247 }
231 248
232 DEFINE_TRACE(ScopedStyleResolver::RuleSubSet) 249 DEFINE_TRACE(ScopedStyleResolver::RuleSubSet)
233 { 250 {
234 visitor->trace(m_parentStyleSheet); 251 visitor->trace(m_parentStyleSheet);
235 visitor->trace(m_ruleSet); 252 visitor->trace(m_ruleSet);
236 } 253 }
237 254
238 } // namespace blink 255 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698