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) { ...@@ -116,10 +116,13 @@ void FontFaceCache::RemoveFontFace(FontFace* font_face, bool css_connected) {
IncrementVersion(); 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_) for (const auto& item : style_rule_to_font_face_)
RemoveFontFace(item.value.Get(), true); RemoveFontFace(item.value.Get(), true);
style_rule_to_font_face_.clear(); style_rule_to_font_face_.clear();
return true;
} }
void FontFaceCache::ClearAll() { void FontFaceCache::ClearAll() {
......
...@@ -50,7 +50,8 @@ class CORE_EXPORT FontFaceCache final { ...@@ -50,7 +50,8 @@ class CORE_EXPORT FontFaceCache final {
void Add(const StyleRuleFontFace*, FontFace*); void Add(const StyleRuleFontFace*, FontFace*);
void Remove(const StyleRuleFontFace*); void Remove(const StyleRuleFontFace*);
void ClearCSSConnected(); // Returns true if at least one font was removed.
bool ClearCSSConnected();
void ClearAll(); void ClearAll();
void AddFontFace(FontFace*, bool css_connected); void AddFontFace(FontFace*, bool css_connected);
void RemoveFontFace(FontFace*, bool css_connected); void RemoveFontFace(FontFace*, bool css_connected);
......
...@@ -318,8 +318,9 @@ class CORE_EXPORT StyleEngine final ...@@ -318,8 +318,9 @@ class CORE_EXPORT StyleEngine final
void ApplyRuleSetChanges(TreeScope&, void ApplyRuleSetChanges(TreeScope&,
const ActiveStyleSheetVector& old_style_sheets, const ActiveStyleSheetVector& old_style_sheets,
const ActiveStyleSheetVector& new_style_sheets, const ActiveStyleSheetVector& new_style_sheets);
InvalidationScope = kInvalidateCurrentScope); void ApplyUserRuleSetChanges(const ActiveStyleSheetVector& old_style_sheets,
const ActiveStyleSheetVector& new_style_sheets);
void CollectMatchingUserRules(ElementRuleCollector&) const; void CollectMatchingUserRules(ElementRuleCollector&) const;
...@@ -413,6 +414,11 @@ class CORE_EXPORT StyleEngine final ...@@ -413,6 +414,11 @@ class CORE_EXPORT StyleEngine final
void ScheduleTypeRuleSetInvalidations(ContainerNode&, void ScheduleTypeRuleSetInvalidations(ContainerNode&,
const HeapHashSet<Member<RuleSet>>&); const HeapHashSet<Member<RuleSet>>&);
void InvalidateSlottedElements(HTMLSlotElement&); 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 UpdateViewport();
void UpdateActiveUserStyleSheets(); void UpdateActiveUserStyleSheets();
...@@ -425,11 +431,7 @@ class CORE_EXPORT StyleEngine final ...@@ -425,11 +431,7 @@ class CORE_EXPORT StyleEngine final
const MediaQueryEvaluator& EnsureMediaQueryEvaluator(); const MediaQueryEvaluator& EnsureMediaQueryEvaluator();
void UpdateStyleSheetList(TreeScope&); void UpdateStyleSheetList(TreeScope&);
void ClearFontCache(); void ClearFontCacheAndAddUserFonts();
void RefreshFontCache();
void MarkFontCacheDirty() { font_cache_dirty_ = true; }
bool IsFontCacheDirty() const { return font_cache_dirty_; }
void ClearKeyframeRules() { keyframes_rule_map_.clear(); } void ClearKeyframeRules() { keyframes_rule_map_.clear(); }
void AddFontFaceRules(const RuleSet&); void AddFontFaceRules(const RuleSet&);
...@@ -492,7 +494,6 @@ class CORE_EXPORT StyleEngine final ...@@ -492,7 +494,6 @@ class CORE_EXPORT StyleEngine final
HeapHashSet<Member<Element>> whitespace_reattach_set_; HeapHashSet<Member<Element>> whitespace_reattach_set_;
Member<CSSFontSelector> font_selector_; Member<CSSFontSelector> font_selector_;
bool font_cache_dirty_ = false;
HeapHashMap<AtomicString, WeakMember<StyleSheetContents>> HeapHashMap<AtomicString, WeakMember<StyleSheetContents>>
text_to_sheet_cache_; 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