Changeset 228678 in webkit
- Timestamp:
- Feb 19, 2018 5:59:56 AM (6 years ago)
- Location:
- releases/WebKitGTK/webkit-2.20/Source/WebCore
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
releases/WebKitGTK/webkit-2.20/Source/WebCore/ChangeLog
r228677 r228678 1 2018-02-13 Antti Koivisto <antti@apple.com> 2 3 REGRESSION(r228313): Membuster | macOS | All Devices | 1.5 MB 4 https://bugs.webkit.org/show_bug.cgi?id=182744 5 <rdar://problem/37463770> 6 7 Reviewed by Zalan Bujtas. 8 9 We need to respect low memory notifications explicitly now that the compiled selectors are not part of RuleData. 10 11 * css/StyleRule.cpp: 12 (WebCore::StyleRule::StyleRule): 13 * css/StyleRule.h: 14 15 Switch to std::unique_ptr<[]> from Vector to avoid unnecessary bloat. 16 17 * css/StyleSheetContents.cpp: 18 (WebCore::traverseRulesInVector): 19 (WebCore::StyleSheetContents::traverseRules const): 20 21 Add a rule traversal function, similar to the existing traverseSubresources. 22 23 (WebCore::StyleSheetContents::traverseSubresources const): 24 25 Use traverseRules to implement traverseSubresources. 26 27 (WebCore::traverseSubresourcesInRules): Deleted. 28 * css/StyleSheetContents.h: 29 * page/MemoryRelease.cpp: 30 (WebCore::releaseCriticalMemory): 31 * style/StyleScope.cpp: 32 (WebCore::Style::Scope::releaseMemory): 33 34 Release memory for compiled selectors on memory notification. 35 36 * style/StyleScope.h: 37 1 38 2018-02-09 Antti Koivisto <antti@apple.com> 2 39 -
releases/WebKitGTK/webkit-2.20/Source/WebCore/css/StyleRule.cpp
r228677 r228678 192 192 , m_properties(o.properties().mutableCopy()) 193 193 , m_selectorList(o.m_selectorList) 194 #if ENABLE(CSS_SELECTOR_JIT)195 , m_compiledSelectors(o.m_compiledSelectors)196 #endif197 194 { 198 195 } -
releases/WebKitGTK/webkit-2.20/Source/WebCore/css/StyleRule.h
r228677 r228678 133 133 using StyleRuleBase::hasDocumentSecurityOrigin; 134 134 135 void parserAdoptSelectorVector(Vector<std::unique_ptr<CSSParserSelector>>& selectors) { m_selectorList.adoptSelectorVector(selectors); } 136 void wrapperAdoptSelectorList(CSSSelectorList& selectors) { m_selectorList = WTFMove(selectors); } 135 void wrapperAdoptSelectorList(CSSSelectorList& selectors) 136 { 137 m_selectorList = WTFMove(selectors); 138 #if ENABLE(CSS_SELECTOR_JIT) 139 m_compiledSelectors = nullptr; 140 #endif 141 } 137 142 void parserAdoptSelectorArray(CSSSelector* selectors) { m_selectorList.adoptSelectorArray(selectors); } 138 143 … … 144 149 CompiledSelector& compiledSelectorForListIndex(unsigned index) 145 150 { 146 if ( m_compiledSelectors.isEmpty())147 m_compiledSelectors .grow(m_selectorList.listSize());151 if (!m_compiledSelectors) 152 m_compiledSelectors = std::make_unique<CompiledSelector[]>(m_selectorList.listSize()); 148 153 return m_compiledSelectors[index]; 154 } 155 void releaseCompiledSelectors() const 156 { 157 m_compiledSelectors = nullptr; 149 158 } 150 159 #endif … … 162 171 163 172 #if ENABLE(CSS_SELECTOR_JIT) 164 Vector<CompiledSelector> m_compiledSelectors;173 mutable std::unique_ptr<CompiledSelector[]> m_compiledSelectors; 165 174 #endif 166 175 }; -
releases/WebKitGTK/webkit-2.20/Source/WebCore/css/StyleSheetContents.cpp
r222259 r228678 431 431 } 432 432 433 static bool traverse SubresourcesInRules(const Vector<RefPtr<StyleRuleBase>>& rules, const WTF::Function<bool (const CachedResource&)>& handler)433 static bool traverseRulesInVector(const Vector<RefPtr<StyleRuleBase>>& rules, const WTF::Function<bool (const StyleRuleBase&)>& handler) 434 434 { 435 435 for (auto& rule : rules) { 436 if (handler(*rule)) 437 return true; 436 438 switch (rule->type()) { 437 case StyleRuleBase::Style: {438 auto* properties = downcast<StyleRule>(*rule).propertiesWithoutDeferredParsing();439 if (properties && properties->traverseSubresources(handler))440 return true;441 break;442 }443 case StyleRuleBase::FontFace:444 if (downcast<StyleRuleFontFace>(*rule).properties().traverseSubresources(handler))445 return true;446 break;447 439 case StyleRuleBase::Media: { 448 440 auto* childRules = downcast<StyleRuleMedia>(*rule).childRulesWithoutDeferredParsing(); 449 if (childRules && traverse SubresourcesInRules(*childRules, handler))441 if (childRules && traverseRulesInVector(*childRules, handler)) 450 442 return true; 451 443 break; … … 453 445 case StyleRuleBase::Import: 454 446 ASSERT_NOT_REACHED(); 455 #if ASSERT_DISABLED 456 FALLTHROUGH;457 #endif 447 break; 448 case StyleRuleBase::Style: 449 case StyleRuleBase::FontFace: 458 450 case StyleRuleBase::Page: 459 451 case StyleRuleBase::Keyframes: … … 472 464 } 473 465 466 bool StyleSheetContents::traverseRules(const WTF::Function<bool (const StyleRuleBase&)>& handler) const 467 { 468 for (auto& importRule : m_importRules) { 469 if (handler(*importRule)) 470 return true; 471 auto* importedStyleSheet = importRule->styleSheet(); 472 if (importedStyleSheet && importedStyleSheet->traverseRules(handler)) 473 return true; 474 } 475 return traverseRulesInVector(m_childRules, handler); 476 } 477 474 478 bool StyleSheetContents::traverseSubresources(const WTF::Function<bool (const CachedResource&)>& handler) const 475 479 { 476 for (auto& importRule : m_importRules) { 477 if (auto* cachedResource = importRule->cachedCSSStyleSheet()) { 478 if (handler(*cachedResource)) 479 return true; 480 return traverseRules([&] (const StyleRuleBase& rule) { 481 switch (rule.type()) { 482 case StyleRuleBase::Style: { 483 auto* properties = downcast<StyleRule>(rule).propertiesWithoutDeferredParsing(); 484 return properties && properties->traverseSubresources(handler); 480 485 } 481 auto* importedStyleSheet = importRule->styleSheet(); 482 if (importedStyleSheet && importedStyleSheet->traverseSubresources(handler)) 483 return true; 484 } 485 return traverseSubresourcesInRules(m_childRules, handler); 486 case StyleRuleBase::FontFace: 487 return downcast<StyleRuleFontFace>(rule).properties().traverseSubresources(handler); 488 case StyleRuleBase::Import: 489 if (auto* cachedResource = downcast<StyleRuleImport>(rule).cachedCSSStyleSheet()) 490 return handler(*cachedResource); 491 return false; 492 case StyleRuleBase::Media: 493 case StyleRuleBase::Page: 494 case StyleRuleBase::Keyframes: 495 case StyleRuleBase::Namespace: 496 case StyleRuleBase::Unknown: 497 case StyleRuleBase::Charset: 498 case StyleRuleBase::Keyframe: 499 case StyleRuleBase::Supports: 500 #if ENABLE(CSS_DEVICE_ADAPTATION) 501 case StyleRuleBase::Viewport: 502 #endif 503 return false; 504 }; 505 ASSERT_NOT_REACHED(); 506 return false; 507 }); 486 508 } 487 509 -
releases/WebKitGTK/webkit-2.20/Source/WebCore/css/StyleSheetContents.h
r222422 r228678 87 87 88 88 URL completeURL(const String& url) const; 89 bool traverseRules(const WTF::Function<bool (const StyleRuleBase&)>& handler) const; 89 90 bool traverseSubresources(const WTF::Function<bool (const CachedResource&)>& handler) const; 90 91 -
releases/WebKitGTK/webkit-2.20/Source/WebCore/page/MemoryRelease.cpp
r223238 r228678 85 85 86 86 for (auto& document : copyToVectorOf<RefPtr<Document>>(Document::allDocuments())) { 87 document->styleScope(). clearResolver();87 document->styleScope().releaseMemory(); 88 88 document->fontSelector().emptyCaches(); 89 89 } -
releases/WebKitGTK/webkit-2.20/Source/WebCore/style/StyleScope.cpp
r224864 r228678 133 133 if (!m_shadowRoot) 134 134 m_document.didClearStyleResolver(); 135 } 136 137 void Scope::releaseMemory() 138 { 139 if (!m_shadowRoot) { 140 for (auto* descendantShadowRoot : m_document.inDocumentShadowRoots()) 141 descendantShadowRoot->styleScope().releaseMemory(); 142 } 143 144 #if ENABLE(CSS_SELECTOR_JIT) 145 for (auto& sheet : m_activeStyleSheets) { 146 sheet->contents().traverseRules([] (const StyleRuleBase& rule) { 147 if (is<StyleRule>(rule)) 148 downcast<StyleRule>(rule).releaseCompiledSelectors(); 149 return false; 150 }); 151 } 152 #endif 153 clearResolver(); 135 154 } 136 155 -
releases/WebKitGTK/webkit-2.20/Source/WebCore/style/StyleScope.h
r224535 r228678 119 119 StyleResolver* resolverIfExists(); 120 120 void clearResolver(); 121 void releaseMemory(); 121 122 122 123 const Document& document() const { return m_document; }
Note: See TracChangeset
for help on using the changeset viewer.