Commit 796725c8 authored by Yuzu Saijo's avatar Yuzu Saijo Committed by Commit Bot

Add PrepareForLeakDetection in CSSDefaultStyleSheets

This CL adds PrepareForLeakDetection in CSSDefaultStyleSheets which sets the members back to the constructor state in order to stabilize the number of resources for leak detection.

Bug: 763280
Change-Id: Ia91831594c6607cf316967d2d4b841d274ca8a10
Reviewed-on: https://chromium-review.googlesource.com/826344
Commit-Queue: Yuzu Saijo <yuzus@chromium.org>
Reviewed-by: default avatarnainar <nainar@chromium.org>
Reviewed-by: default avatarKeishi Hattori <keishi@chromium.org>
Cr-Commit-Position: refs/heads/master@{#524319}
parent a71b54d8
......@@ -77,22 +77,17 @@ static StyleSheetContents* ParseUASheet(const String& str) {
CSSDefaultStyleSheets::CSSDefaultStyleSheets()
: media_controls_style_sheet_loader_(nullptr) {
default_style_ = RuleSet::Create();
default_print_style_ = RuleSet::Create();
default_quirks_style_ = RuleSet::Create();
// Strict-mode rules.
String default_rules = GetDataResourceAsASCIIString("html.css") +
LayoutTheme::GetTheme().ExtraDefaultStyleSheet();
default_style_sheet_ = ParseUASheet(default_rules);
default_style_->AddRulesFromSheet(DefaultStyleSheet(), ScreenEval());
default_print_style_->AddRulesFromSheet(DefaultStyleSheet(), PrintEval());
// Quirks-mode rules.
String quirks_rules = GetDataResourceAsASCIIString("quirks.css") +
LayoutTheme::GetTheme().ExtraQuirksStyleSheet();
quirks_style_sheet_ = ParseUASheet(quirks_rules);
default_quirks_style_->AddRulesFromSheet(QuirksStyleSheet(), ScreenEval());
InitializeDefaultStyles();
#if DCHECK_IS_ON()
default_style_->CompactRulesIfNeeded();
......@@ -104,6 +99,31 @@ CSSDefaultStyleSheets::CSSDefaultStyleSheets()
#endif
}
void CSSDefaultStyleSheets::PrepareForLeakDetection() {
// Clear the optional style sheets.
media_controls_style_sheet_.Clear();
mobile_viewport_style_sheet_.Clear();
television_viewport_style_sheet_.Clear();
xhtml_mobile_profile_style_sheet_.Clear();
svg_style_sheet_.Clear();
mathml_style_sheet_.Clear();
fullscreen_style_sheet_.Clear();
// Initialize the styles that have the lazily loaded style sheets.
InitializeDefaultStyles();
default_view_source_style_.Clear();
}
void CSSDefaultStyleSheets::InitializeDefaultStyles() {
// This must be called only from constructor / PrepareForLeakDetection.
default_style_ = RuleSet::Create();
default_print_style_ = RuleSet::Create();
default_quirks_style_ = RuleSet::Create();
default_style_->AddRulesFromSheet(DefaultStyleSheet(), ScreenEval());
default_print_style_->AddRulesFromSheet(DefaultStyleSheet(), PrintEval());
default_quirks_style_->AddRulesFromSheet(QuirksStyleSheet(), ScreenEval());
}
RuleSet* CSSDefaultStyleSheets::DefaultViewSourceStyle() {
if (!default_view_source_style_) {
default_view_source_style_ = RuleSet::Create();
......
......@@ -65,6 +65,8 @@ class CSSDefaultStyleSheets
return fullscreen_style_sheet_.Get();
}
void PrepareForLeakDetection();
// Media Controls UA stylesheet loading is handled by the media_controls
// module.
class CORE_EXPORT UAStyleSheetLoader {
......@@ -85,6 +87,7 @@ class CSSDefaultStyleSheets
private:
CSSDefaultStyleSheets();
void InitializeDefaultStyles();
Member<RuleSet> default_style_;
Member<RuleSet> default_quirks_style_;
......
......@@ -7,6 +7,7 @@
#include "bindings/core/v8/V8BindingForCore.h"
#include "bindings/core/v8/V8GCController.h"
#include "core/CoreInitializer.h"
#include "core/css/CSSDefaultStyleSheets.h"
#include "core/editing/spellcheck/SpellChecker.h"
#include "core/frame/LocalFrame.h"
#include "core/frame/WebLocalFrameImpl.h"
......@@ -61,6 +62,9 @@ void BlinkLeakDetector::PrepareForLeakDetection(WebFrame* frame) {
// FIXME: HTML5 Notification should be closed because notification affects
// the result of number of DOM objects.
V8PerIsolateData::From(isolate)->ClearScriptRegexpContext();
// Clear lazily loaded style sheets.
CSSDefaultStyleSheets::Instance().PrepareForLeakDetection();
}
void BlinkLeakDetector::CollectGarbage() {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment