diff options
Diffstat (limited to 'chromium/third_party/blink/renderer/core/css/resolver/font_builder.cc')
-rw-r--r-- | chromium/third_party/blink/renderer/core/css/resolver/font_builder.cc | 28 |
1 files changed, 26 insertions, 2 deletions
diff --git a/chromium/third_party/blink/renderer/core/css/resolver/font_builder.cc b/chromium/third_party/blink/renderer/core/css/resolver/font_builder.cc index 08667ae3f4a..2a4b1aa50b9 100644 --- a/chromium/third_party/blink/renderer/core/css/resolver/font_builder.cc +++ b/chromium/third_party/blink/renderer/core/css/resolver/font_builder.cc @@ -37,7 +37,7 @@ namespace blink { -FontBuilder::FontBuilder(Document* document) : document_(document), flags_(0) { +FontBuilder::FontBuilder(Document* document) : document_(document) { DCHECK(!document || document->GetFrame()); } @@ -48,6 +48,7 @@ void FontBuilder::SetInitial(float effective_zoom) { SetFamilyDescription(font_description_, FontBuilder::InitialFamilyDescription()); + SetFamilyTreeScope(nullptr); SetSize(font_description_, FontBuilder::InitialSize()); } @@ -110,6 +111,10 @@ void FontBuilder::SetFamilyDescription( SetFamilyDescription(font_description_, family_description); } +void FontBuilder::SetFamilyTreeScope(const TreeScope* tree_scope) { + family_tree_scope_ = tree_scope; +} + void FontBuilder::SetWeight(FontSelectionValue weight) { Set(PropertySetFlag::kWeight); @@ -410,6 +415,25 @@ void FontBuilder::UpdateFontDescription(FontDescription& description, description.SetAdjustedSize(size); } +FontSelector* FontBuilder::FontSelectorFromTreeScope( + const TreeScope* tree_scope) { + // TODO(crbug.com/437837): The tree_scope may be from a different Document in + // the case where we are resolving style for elements in a <svg:use> shadow + // tree. + DCHECK(!tree_scope || tree_scope->GetDocument() == document_ || + tree_scope->GetDocument().IsSVGDocument()); + // TODO(crbug.com/336876): Font selector should be based on tree_scope for + // tree-scoped references. + return document_->GetStyleEngine().GetFontSelector(); +} + +FontSelector* FontBuilder::ComputeFontSelector(const ComputedStyle& style) { + if (IsSet(PropertySetFlag::kFamily)) + return FontSelectorFromTreeScope(family_tree_scope_); + else + return style.GetFont().GetFontSelector(); +} + void FontBuilder::CreateFont(ComputedStyle& style, const ComputedStyle* parent_style) { DCHECK(document_); @@ -423,7 +447,7 @@ void FontBuilder::CreateFont(ComputedStyle& style, UpdateSpecifiedSize(description, style, parent_style); UpdateComputedSize(description, style); - FontSelector* font_selector = document_->GetStyleEngine().GetFontSelector(); + FontSelector* font_selector = ComputeFontSelector(style); UpdateAdjustedSize(description, style, font_selector); style.SetFontInternal(Font(description, font_selector)); |