Commit a576e37f authored by Xiaocheng Hu's avatar Xiaocheng Hu Committed by Commit Bot

Make ComputedStyle::SetFontDescription() preserve FontSelector value

ComputedStyle::SetFontDescription() clears the FontFallbackList (and
hence, FontSelector) on the Font object when successful. As a result,
callers, need to store the FontSelector value before calling, and use
Update() to restore it after calling.

This patch makes SetFontDescription() preserve the FontSelector value,
so that the pattern can be eliminated, and we have fewer call sites of
the deprecated function Font::Update().

Bug: 1049295
Change-Id: I6f4c17d3d0cfe79d2f32ca610ad39ecbf75e2d54
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2108867Reviewed-by: default avatarRune Lillesveen <futhark@chromium.org>
Commit-Queue: Xiaocheng Hu <xiaochengh@chromium.org>
Cr-Commit-Position: refs/heads/master@{#751545}
parent 4ea65f28
......@@ -177,7 +177,7 @@ void LayoutTextCombine::UpdateFontStyleForCombinedText() {
FontSelector* font_selector = style->GetFont().GetFontSelector();
// Need to change font orientation to horizontal.
bool should_update_font = style->SetFontDescription(description);
style->SetFontDescription(description);
if (combined_text_width_ <= em_width) {
scale_x_ = 1.0f;
......@@ -193,7 +193,7 @@ void LayoutTextCombine::UpdateFontStyleForCombinedText() {
combined_text_width_ = run_width;
// Replace my font with the new one.
should_update_font = style->SetFontDescription(description);
style->SetFontDescription(description);
break;
}
}
......@@ -208,9 +208,6 @@ void LayoutTextCombine::UpdateFontStyleForCombinedText() {
scale_x_ = 1.0f;
}
}
if (should_update_font)
style->GetFont().Update(font_selector);
}
} // namespace blink
......@@ -715,10 +715,7 @@ void LayoutThemeMac::SetFontFromControlSize(ComputedStyle& style,
// Reset line height.
style.SetLineHeight(ComputedStyleInitialValues::InitialLineHeight());
// TODO(esprehn): The fontSelector manual management is buggy and error prone.
FontSelector* font_selector = style.GetFont().GetFontSelector();
if (style.SetFontDescription(font_description))
style.GetFont().Update(font_selector);
style.SetFontDescription(font_description);
}
NSControlSize LayoutThemeMac::ControlSizeForSystemFont(
......
......@@ -1779,11 +1779,9 @@ void ComputedStyle::UpdateFontOrientation() {
FontOrientation orientation = ComputeFontOrientation();
if (GetFontDescription().Orientation() == orientation)
return;
FontSelector* current_font_selector = GetFont().GetFontSelector();
FontDescription font_description = GetFontDescription();
font_description.SetOrientation(orientation);
SetFontDescription(font_description);
GetFont().Update(current_font_selector);
}
TextDecoration ComputedStyle::TextDecorationsInEffect() const {
......@@ -1959,7 +1957,7 @@ const CSSValue* ComputedStyle::GetVariableValue(
bool ComputedStyle::SetFontDescription(const FontDescription& v) {
if (FontInternal().GetFontDescription() != v) {
SetFontInternal(Font(v));
SetFontInternal(Font(v, FontInternal().GetFontSelector()));
return true;
}
return false;
......@@ -2020,19 +2018,15 @@ LayoutUnit ComputedStyle::ComputedLineHeightAsFixed() const {
}
void ComputedStyle::SetWordSpacing(float word_spacing) {
FontSelector* current_font_selector = GetFont().GetFontSelector();
FontDescription desc(GetFontDescription());
desc.SetWordSpacing(word_spacing);
SetFontDescription(desc);
GetFont().Update(current_font_selector);
}
void ComputedStyle::SetLetterSpacing(float letter_spacing) {
FontSelector* current_font_selector = GetFont().GetFontSelector();
FontDescription desc(GetFontDescription());
desc.SetLetterSpacing(letter_spacing);
SetFontDescription(desc);
GetFont().Update(current_font_selector);
}
void ComputedStyle::SetTextAutosizingMultiplier(float multiplier) {
......@@ -2046,7 +2040,6 @@ void ComputedStyle::SetTextAutosizingMultiplier(float multiplier) {
else
size = std::min(kMaximumAllowedFontSize, size);
FontSelector* current_font_selector = GetFont().GetFontSelector();
FontDescription desc(GetFontDescription());
desc.SetSpecifiedSize(size);
......@@ -2057,7 +2050,6 @@ void ComputedStyle::SetTextAutosizingMultiplier(float multiplier) {
desc.SetComputedSize(std::min(kMaximumAllowedFontSize, autosized_font_size));
SetFontDescription(desc);
GetFont().Update(current_font_selector);
}
void ComputedStyle::AddAppliedTextDecoration(
......
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