Commit d31bbf29 authored by Xiaocheng Hu's avatar Xiaocheng Hu Committed by Chromium LUCI CQ

Move FontPreloadManager to Oilpan

Currently, TimerBase cannot correctly track the lifetime of objects
embedded in GC-ed objects, like FontPreloadManager which is embedded in
Document. This causes some memory safety issues.

This patch moves FontPreloadManager to Oilpan to avoid the issue.

Bug: 1154965
Change-Id: I490b416abc6a997034baaa7994cd3a50bca7e055
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2611755Reviewed-by: default avatarKentaro Hara <haraken@chromium.org>
Commit-Queue: Xiaocheng Hu <xiaochengh@chromium.org>
Cr-Commit-Position: refs/heads/master@{#841039}
parent 301c48fe
...@@ -816,7 +816,7 @@ Document::Document(const DocumentInit& initializer, ...@@ -816,7 +816,7 @@ Document::Document(const DocumentInit& initializer,
fragment_directive_(MakeGarbageCollected<FragmentDirective>()), fragment_directive_(MakeGarbageCollected<FragmentDirective>()),
display_lock_document_state_( display_lock_document_state_(
MakeGarbageCollected<DisplayLockDocumentState>(this)), MakeGarbageCollected<DisplayLockDocumentState>(this)),
font_preload_manager_(*this), font_preload_manager_(MakeGarbageCollected<FontPreloadManager>(*this)),
data_(MakeGarbageCollected<DocumentData>(GetExecutionContext())) { data_(MakeGarbageCollected<DocumentData>(GetExecutionContext())) {
if (GetFrame()) { if (GetFrame()) {
DCHECK(GetFrame()->GetPage()); DCHECK(GetFrame()->GetPage());
...@@ -6947,7 +6947,7 @@ void Document::BeginLifecycleUpdatesIfRenderingReady() { ...@@ -6947,7 +6947,7 @@ void Document::BeginLifecycleUpdatesIfRenderingReady() {
return; return;
if (!HaveRenderBlockingResourcesLoaded()) if (!HaveRenderBlockingResourcesLoaded())
return; return;
font_preload_manager_.WillBeginRendering(); font_preload_manager_->WillBeginRendering();
View()->BeginLifecycleUpdates(); View()->BeginLifecycleUpdates();
} }
...@@ -7651,7 +7651,7 @@ bool Document::HaveScriptBlockingStylesheetsLoaded() const { ...@@ -7651,7 +7651,7 @@ bool Document::HaveScriptBlockingStylesheetsLoaded() const {
bool Document::HaveRenderBlockingResourcesLoaded() const { bool Document::HaveRenderBlockingResourcesLoaded() const {
return HaveImportsLoaded() && return HaveImportsLoaded() &&
style_engine_->HaveRenderBlockingStylesheetsLoaded() && style_engine_->HaveRenderBlockingStylesheetsLoaded() &&
!font_preload_manager_.HasPendingRenderBlockingFonts(); !font_preload_manager_->HasPendingRenderBlockingFonts();
} }
Locale& Document::GetCachedLocale(const AtomicString& locale) { Locale& Document::GetCachedLocale(const AtomicString& locale) {
...@@ -8415,7 +8415,7 @@ void Document::ClearUseCounterForTesting(mojom::WebFeature feature) { ...@@ -8415,7 +8415,7 @@ void Document::ClearUseCounterForTesting(mojom::WebFeature feature) {
} }
void Document::FontPreloadingFinishedOrTimedOut() { void Document::FontPreloadingFinishedOrTimedOut() {
DCHECK(!font_preload_manager_.HasPendingRenderBlockingFonts()); DCHECK(!font_preload_manager_->HasPendingRenderBlockingFonts());
if (IsA<HTMLDocument>(this) && body()) { if (IsA<HTMLDocument>(this) && body()) {
// For HTML, we resume only when we're past the body tag, so that we should // For HTML, we resume only when we're past the body tag, so that we should
// have something to paint now. // have something to paint now.
......
...@@ -1628,7 +1628,7 @@ class CORE_EXPORT Document : public ContainerNode, ...@@ -1628,7 +1628,7 @@ class CORE_EXPORT Document : public ContainerNode,
unsigned new_length); unsigned new_length);
void NotifyChangeChildren(const ContainerNode& container); void NotifyChangeChildren(const ContainerNode& container);
FontPreloadManager& GetFontPreloadManager() { return font_preload_manager_; } FontPreloadManager& GetFontPreloadManager() { return *font_preload_manager_; }
void FontPreloadingFinishedOrTimedOut(); void FontPreloadingFinishedOrTimedOut();
void IncrementAsyncScriptCount() { async_script_count_++; } void IncrementAsyncScriptCount() { async_script_count_++; }
...@@ -2184,7 +2184,7 @@ class CORE_EXPORT Document : public ContainerNode, ...@@ -2184,7 +2184,7 @@ class CORE_EXPORT Document : public ContainerNode,
// call or potential user prompt. // call or potential user prompt.
bool expressly_denied_storage_access_ = false; bool expressly_denied_storage_access_ = false;
FontPreloadManager font_preload_manager_; Member<FontPreloadManager> font_preload_manager_;
int async_script_count_ = 0; int async_script_count_ = 0;
bool first_paint_recorded_ = false; bool first_paint_recorded_ = false;
......
...@@ -20,9 +20,8 @@ class ResourceFinishObserver; ...@@ -20,9 +20,8 @@ class ResourceFinishObserver;
// API) and notifies the relevant document, so that it can manage the first // API) and notifies the relevant document, so that it can manage the first
// rendering timing to work with preloaded fonts. // rendering timing to work with preloaded fonts.
// Design doc: https://bit.ly/36E8UKB // Design doc: https://bit.ly/36E8UKB
class CORE_EXPORT FontPreloadManager final { class CORE_EXPORT FontPreloadManager final
DISALLOW_NEW(); : public GarbageCollected<FontPreloadManager> {
public: public:
explicit FontPreloadManager(Document&); explicit FontPreloadManager(Document&);
~FontPreloadManager() = default; ~FontPreloadManager() = default;
......
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