Commit dfe7b677 authored by Rune Lillesveen's avatar Rune Lillesveen Committed by Commit Bot

Refactor dirty font cache handling.

ApplyRuleSetChanges was hard to understand because it contained various
branching for user style updates which wasn't clear were for user style.
Move the user style specific font and keyframes handling to a separate
ApplyUserRuleSetChanges and create a common InvalidateForRuleSetChanges
to do the common code for marking nodes for style invalidation/recalc.

Change-Id: I7b4907e526e5768f1957e5be3ad1b41f9a5d35f0
Reviewed-on: https://chromium-review.googlesource.com/c/1258543Reviewed-by: default avatarAnders Ruud <andruud@chromium.org>
Commit-Queue: Rune Lillesveen <futhark@chromium.org>
Cr-Commit-Position: refs/heads/master@{#597081}
parent 88194fb8
......@@ -116,10 +116,13 @@ void FontFaceCache::RemoveFontFace(FontFace* font_face, bool css_connected) {
IncrementVersion();
}
void FontFaceCache::ClearCSSConnected() {
bool FontFaceCache::ClearCSSConnected() {
if (style_rule_to_font_face_.IsEmpty())
return false;
for (const auto& item : style_rule_to_font_face_)
RemoveFontFace(item.value.Get(), true);
style_rule_to_font_face_.clear();
return true;
}
void FontFaceCache::ClearAll() {
......
......@@ -50,7 +50,8 @@ class CORE_EXPORT FontFaceCache final {
void Add(const StyleRuleFontFace*, FontFace*);
void Remove(const StyleRuleFontFace*);
void ClearCSSConnected();
// Returns true if at least one font was removed.
bool ClearCSSConnected();
void ClearAll();
void AddFontFace(FontFace*, bool css_connected);
void RemoveFontFace(FontFace*, bool css_connected);
......
......@@ -318,8 +318,9 @@ class CORE_EXPORT StyleEngine final
void ApplyRuleSetChanges(TreeScope&,
const ActiveStyleSheetVector& old_style_sheets,
const ActiveStyleSheetVector& new_style_sheets,
InvalidationScope = kInvalidateCurrentScope);
const ActiveStyleSheetVector& new_style_sheets);
void ApplyUserRuleSetChanges(const ActiveStyleSheetVector& old_style_sheets,
const ActiveStyleSheetVector& new_style_sheets);
void CollectMatchingUserRules(ElementRuleCollector&) const;
......@@ -413,6 +414,11 @@ class CORE_EXPORT StyleEngine final
void ScheduleTypeRuleSetInvalidations(ContainerNode&,
const HeapHashSet<Member<RuleSet>>&);
void InvalidateSlottedElements(HTMLSlotElement&);
void InvalidateForRuleSetChanges(
TreeScope& tree_scope,
const HeapHashSet<Member<RuleSet>>& changed_rule_sets,
unsigned changed_rule_flags,
InvalidationScope invalidation_scope);
void UpdateViewport();
void UpdateActiveUserStyleSheets();
......@@ -425,11 +431,7 @@ class CORE_EXPORT StyleEngine final
const MediaQueryEvaluator& EnsureMediaQueryEvaluator();
void UpdateStyleSheetList(TreeScope&);
void ClearFontCache();
void RefreshFontCache();
void MarkFontCacheDirty() { font_cache_dirty_ = true; }
bool IsFontCacheDirty() const { return font_cache_dirty_; }
void ClearFontCacheAndAddUserFonts();
void ClearKeyframeRules() { keyframes_rule_map_.clear(); }
void AddFontFaceRules(const RuleSet&);
......@@ -492,7 +494,6 @@ class CORE_EXPORT StyleEngine final
HeapHashSet<Member<Element>> whitespace_reattach_set_;
Member<CSSFontSelector> font_selector_;
bool font_cache_dirty_ = false;
HeapHashMap<AtomicString, WeakMember<StyleSheetContents>>
text_to_sheet_cache_;
......
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