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

Get rid of a mutable member from FontDescription

FontDescription has a mutable bit field subpixel_ascent_descent_ that
can be modified via a const method. This patch removes the mutable
keyword and changes the callers so that FontDescription no longer has
mutable fields, and the code maintainability is improved.

Change-Id: I53fab83b3a8c00e2827aa19b0ba640bb59765fda
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2145072Reviewed-by: default avatarFernando Serboncini <fserb@chromium.org>
Reviewed-by: default avatarKoji Ishii <kojii@chromium.org>
Commit-Queue: Xiaocheng Hu <xiaochengh@chromium.org>
Cr-Commit-Position: refs/heads/master@{#759798}
parent a0f955c3
...@@ -846,7 +846,6 @@ void CanvasRenderingContext2D::DrawTextInternal( ...@@ -846,7 +846,6 @@ void CanvasRenderingContext2D::DrawTextInternal(
return; return;
const Font& font = AccessFont(); const Font& font = AccessFont();
font.GetFontDescription().SetSubpixelAscentDescent(true);
const SimpleFontData* font_data = font.PrimaryFont(); const SimpleFontData* font_data = font.PrimaryFont();
DCHECK(font_data); DCHECK(font_data);
if (!font_data) if (!font_data)
......
...@@ -254,8 +254,10 @@ void CanvasRenderingContext2DState::ClipPath( ...@@ -254,8 +254,10 @@ void CanvasRenderingContext2DState::ClipPath(
} }
void CanvasRenderingContext2DState::SetFont( void CanvasRenderingContext2DState::SetFont(
const FontDescription& font_description, const FontDescription& passed_font_description,
FontSelector* selector) { FontSelector* selector) {
FontDescription font_description = passed_font_description;
font_description.SetSubpixelAscentDescent(true);
font_ = Font(font_description, selector); font_ = Font(font_description, selector);
realized_font_ = true; realized_font_ = true;
if (selector) if (selector)
......
...@@ -510,8 +510,6 @@ void OffscreenCanvasRenderingContext2D::DrawTextInternal( ...@@ -510,8 +510,6 @@ void OffscreenCanvasRenderingContext2D::DrawTextInternal(
return; return;
const Font& font = AccessFont(); const Font& font = AccessFont();
font.GetFontDescription().SetSubpixelAscentDescent(true);
const SimpleFontData* font_data = font.PrimaryFont(); const SimpleFontData* font_data = font.PrimaryFont();
DCHECK(font_data); DCHECK(font_data);
if (!font_data) if (!font_data)
......
...@@ -328,7 +328,7 @@ class PLATFORM_EXPORT FontDescription { ...@@ -328,7 +328,7 @@ class PLATFORM_EXPORT FontDescription {
} }
static bool SubpixelPositioning() { return use_subpixel_text_positioning_; } static bool SubpixelPositioning() { return use_subpixel_text_positioning_; }
void SetSubpixelAscentDescent(bool sp) const { void SetSubpixelAscentDescent(bool sp) {
fields_.subpixel_ascent_descent_ = sp; fields_.subpixel_ascent_descent_ = sp;
} }
...@@ -420,7 +420,7 @@ class PLATFORM_EXPORT FontDescription { ...@@ -420,7 +420,7 @@ class PLATFORM_EXPORT FontDescription {
unsigned typesetting_features_ : 3; unsigned typesetting_features_ : 3;
unsigned variant_numeric_ : 8; unsigned variant_numeric_ : 8;
unsigned variant_east_asian_ : 6; unsigned variant_east_asian_ : 6;
mutable unsigned subpixel_ascent_descent_ : 1; unsigned subpixel_ascent_descent_ : 1;
unsigned font_optical_sizing_ : 1; unsigned font_optical_sizing_ : 1;
}; };
......
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