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

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: Only expose dispose()s to Oilpan 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 #if ENABLE(OILPAN)
50 void ScopedStyleResolver::dispose()
51 {
52 m_keyframesRuleMap.clear();
53
54 if (m_treeBoundaryCrossingRuleSet) {
55 for (size_t i = 0; i < m_treeBoundaryCrossingRuleSet->size(); ++i) {
56 if (RuleSet* ruleSet = m_treeBoundaryCrossingRuleSet->at(i)->m_ruleS et.get())
57 ruleSet->dispose();
58 }
59
60 m_treeBoundaryCrossingRuleSet->clear();
61 m_treeBoundaryCrossingRuleSet.clear();
62 }
63
64 }
65 #endif
66
49 ScopedStyleResolver* ScopedStyleResolver::parent() const 67 ScopedStyleResolver* ScopedStyleResolver::parent() const
50 { 68 {
51 for (TreeScope* scope = treeScope().parentTreeScope(); scope; scope = scope- >parentTreeScope()) { 69 for (TreeScope* scope = treeScope().parentTreeScope(); scope; scope = scope- >parentTreeScope()) {
52 if (ScopedStyleResolver* resolver = scope->scopedStyleResolver()) 70 if (ScopedStyleResolver* resolver = scope->scopedStyleResolver())
53 return resolver; 71 return resolver;
54 } 72 }
55 return nullptr; 73 return nullptr;
56 } 74 }
57 75
58 void ScopedStyleResolver::addKeyframeRules(const RuleSet& ruleSet) 76 void ScopedStyleResolver::addKeyframeRules(const RuleSet& ruleSet)
59 { 77 {
60 const WillBeHeapVector<RawPtrWillBeMember<StyleRuleKeyframes>> keyframesRule s = ruleSet.keyframesRules(); 78 const WillBeHeapVector<RawPtrWillBeMember<StyleRuleKeyframes>> keyframesRule s = ruleSet.keyframesRules();
61 for (unsigned i = 0; i < keyframesRules.size(); ++i) 79 for (unsigned i = 0; i < keyframesRules.size(); ++i)
62 addKeyframeStyle(keyframesRules[i]); 80 addKeyframeStyle(keyframesRules[i]);
63 } 81 }
64 82
65 void ScopedStyleResolver::addFontFaceRules(const RuleSet& ruleSet) 83 void ScopedStyleResolver::addFontFaceRules(const RuleSet& ruleSet)
66 { 84 {
67 // FIXME(BUG 72461): We don't add @font-face rules of scoped style sheets fo r the moment. 85 // FIXME(BUG 72461): We don't add @font-face rules of scoped style sheets fo r the moment.
68 if (!treeScope().rootNode().isDocumentNode()) 86 if (!treeScope().rootNode().isDocumentNode())
69 return; 87 return;
70 88
71 Document& document = treeScope().document(); 89 Document& document = treeScope().document();
72 CSSFontSelector* cssFontSelector = document.styleEngine().fontSelector(); 90 CSSFontSelector* cssFontSelector = document.styleEngine().fontSelector();
73 const WillBeHeapVector<RawPtrWillBeMember<StyleRuleFontFace>> fontFaceRules = ruleSet.fontFaceRules(); 91 const WillBeHeapVector<RawPtrWillBeMember<StyleRuleFontFace>> fontFaceRules = ruleSet.fontFaceRules();
92 if (!fontFaceRules.size())
93 return;
74 for (auto& fontFaceRule : fontFaceRules) { 94 for (auto& fontFaceRule : fontFaceRules) {
75 if (RefPtrWillBeRawPtr<FontFace> fontFace = FontFace::create(&document, fontFaceRule)) 95 if (RefPtrWillBeRawPtr<FontFace> fontFace = FontFace::create(&document, fontFaceRule))
76 cssFontSelector->fontFaceCache()->add(cssFontSelector, fontFaceRule, fontFace); 96 cssFontSelector->fontFaceCache()->add(cssFontSelector, fontFaceRule, fontFace);
77 } 97 }
78 if (fontFaceRules.size()) 98 document.styleResolver()->invalidateMatchedPropertiesCache();
79 document.styleResolver()->invalidateMatchedPropertiesCache();
80 } 99 }
81 100
82 void ScopedStyleResolver::appendCSSStyleSheet(CSSStyleSheet& cssSheet, const Med iaQueryEvaluator& medium) 101 void ScopedStyleResolver::appendCSSStyleSheet(CSSStyleSheet& cssSheet, const Med iaQueryEvaluator& medium)
83 { 102 {
84 unsigned index = m_authorStyleSheets.size(); 103 unsigned index = m_authorStyleSheets.size();
85 m_authorStyleSheets.append(&cssSheet); 104 m_authorStyleSheets.append(&cssSheet);
86 StyleSheetContents* sheet = cssSheet.contents(); 105 StyleSheetContents* sheet = cssSheet.contents();
87 AddRuleFlags addRuleFlags = treeScope().document().securityOrigin()->canRequ est(sheet->baseURL()) ? RuleHasDocumentSecurityOrigin : RuleHasNoSpecialState; 106 AddRuleFlags addRuleFlags = treeScope().document().securityOrigin()->canRequ est(sheet->baseURL()) ? RuleHasDocumentSecurityOrigin : RuleHasNoSpecialState;
88 const RuleSet& ruleSet = sheet->ensureRuleSet(medium, addRuleFlags); 107 const RuleSet& ruleSet = sheet->ensureRuleSet(medium, addRuleFlags);
89 108
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
229 m_treeBoundaryCrossingRuleSet->append(RuleSubSet::create(parentStyleSheet, s heetIndex, ruleSetForScope.release())); 248 m_treeBoundaryCrossingRuleSet->append(RuleSubSet::create(parentStyleSheet, s heetIndex, ruleSetForScope.release()));
230 } 249 }
231 250
232 DEFINE_TRACE(ScopedStyleResolver::RuleSubSet) 251 DEFINE_TRACE(ScopedStyleResolver::RuleSubSet)
233 { 252 {
234 visitor->trace(m_parentStyleSheet); 253 visitor->trace(m_parentStyleSheet);
235 visitor->trace(m_ruleSet); 254 visitor->trace(m_ruleSet);
236 } 255 }
237 256
238 } // namespace blink 257 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698