Commit 840dfccd authored by Xiaocheng Hu's avatar Xiaocheng Hu Committed by Commit Bot

Slightly refactor FontFallbackList invalidation

Since all access to FontFallbackList needs to go through Font, this
patch moves the call site of FontFallbackList::Invalidate() up into
Font::EnsureFontFallbackList() to make it simpler.

Bug: 441925
Change-Id: I1515ae4f76f528f7f395135c1cf799cff5106f6a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2146062
Commit-Queue: Koji Ishii <kojii@chromium.org>
Reviewed-by: default avatarKoji Ishii <kojii@chromium.org>
Cr-Commit-Position: refs/heads/master@{#758473}
parent b0bc1f88
......@@ -244,6 +244,10 @@ class PLATFORM_EXPORT Font {
FontFallbackList* EnsureFontFallbackList() const {
if (!font_fallback_list_)
font_fallback_list_ = FontFallbackList::Create(nullptr);
if (RuntimeEnabledFeatures::CSSReducedFontLoadingInvalidationsEnabled()) {
if (!font_fallback_list_->IsValid())
font_fallback_list_->Invalidate();
}
return font_fallback_list_.get();
}
......
......@@ -50,6 +50,7 @@ FontFallbackList::FontFallbackList(FontSelector* font_selector)
can_shape_word_by_word_computed_(false) {}
void FontFallbackList::Invalidate() {
DCHECK(RuntimeEnabledFeatures::CSSReducedFontLoadingInvalidationsEnabled());
ReleaseFontData();
font_list_.clear();
cached_primary_simple_font_data_ = nullptr;
......@@ -234,11 +235,6 @@ FallbackListCompositeKey FontFallbackList::CompositeKey(
const FontData* FontFallbackList::FontDataAt(
const FontDescription& font_description,
unsigned realized_font_index) {
if (RuntimeEnabledFeatures::CSSReducedFontLoadingInvalidationsEnabled()) {
if (!IsValid())
Invalidate();
}
// This fallback font is already in our list.
if (realized_font_index < font_list_.size())
return font_list_[realized_font_index].get();
......@@ -280,11 +276,6 @@ bool FontFallbackList::ComputeCanShapeWordByWord(
bool FontFallbackList::CanShapeWordByWord(
const FontDescription& font_description) {
if (RuntimeEnabledFeatures::CSSReducedFontLoadingInvalidationsEnabled()) {
if (!IsValid())
Invalidate();
}
if (!can_shape_word_by_word_computed_) {
can_shape_word_by_word_ = ComputeCanShapeWordByWord(font_description);
can_shape_word_by_word_computed_ = true;
......
......@@ -60,11 +60,6 @@ class PLATFORM_EXPORT FontFallbackList : public RefCounted<FontFallbackList> {
uint16_t Generation() const { return generation_; }
ShapeCache* GetShapeCache(const FontDescription& font_description) {
if (RuntimeEnabledFeatures::CSSReducedFontLoadingInvalidationsEnabled()) {
if (!IsValid())
Invalidate();
}
if (!shape_cache_) {
FallbackListCompositeKey key = CompositeKey(font_description);
shape_cache_ =
......@@ -78,11 +73,6 @@ class PLATFORM_EXPORT FontFallbackList : public RefCounted<FontFallbackList> {
const SimpleFontData* PrimarySimpleFontData(
const FontDescription& font_description) {
if (RuntimeEnabledFeatures::CSSReducedFontLoadingInvalidationsEnabled()) {
if (!IsValid())
Invalidate();
}
if (!cached_primary_simple_font_data_) {
cached_primary_simple_font_data_ =
DeterminePrimarySimpleFontData(font_description);
......
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