COMMIT_MESSAGE

 1Unreviewed, reverting 278130@main.
 2https://bugs.webkit.org/show_bug.cgi?id=273491
 3
 4SP3 1% regression
 5
 6Reverted changeset:
 7
 8"Decoupling from-font resolution from FontCascadeFonts::primaryFont"
 9https://bugs.webkit.org/show_bug.cgi?id=273339
 10https://commits.webkit.org/278130@main

Source/WebCore/css/ComputedStyleExtractor.cpp

@@static Ref<CSSValue> fontSizeAdjustFromStyle(const RenderStyle& style)
370370 return CSSPrimitiveValue::create(CSSValueNone);
371371
372372 auto metric = fontSizeAdjust.metric;
373  fontSizeAdjust.resolveFromFontIfNeeded(style.computedFontSize(), style.metricsOfPrimaryFont());
374  auto value = fontSizeAdjust.value.asOptional();
 373 auto value = fontSizeAdjust.isFromFont() ? fontSizeAdjust.resolve(style.computedFontSize(), style.metricsOfPrimaryFont()) : fontSizeAdjust.value.asOptional();
375374 if (metric == FontSizeAdjust::Metric::ExHeight)
376375 return CSSPrimitiveValue::create(*value);
377376

Source/WebCore/platform/graphics/FontCascade.h

@@private:
373373inline const Font& FontCascade::primaryFont() const
374374{
375375 ASSERT(m_fonts);
376  auto& font = protectedFonts()->primaryFont(m_fontDescription);
377  m_fontDescription.resolveFontSizeAdjustFromFontIfNeeded(font);
378  return font;
 376 return protectedFonts()->primaryFont(m_fontDescription);
379377}
380378
381379inline const FontRanges& FontCascade::fallbackRangesAt(unsigned index) const

Source/WebCore/platform/graphics/FontCascadeDescription.cpp

@@FontSmoothingMode FontCascadeDescription::usedFontSmoothing() const
147147 return fontSmoothingMode;
148148}
149149
150 void FontCascadeDescription::resolveFontSizeAdjustFromFontIfNeeded(const Font& font)
151 {
152  auto fontSizeAdjust = this->fontSizeAdjust();
153  if (fontSizeAdjust.resolveFromFontIfNeeded(computedSize(), font.fontMetrics()))
154  setFontSizeAdjust(fontSizeAdjust);
155 }
156 
157150} // namespace WebCore

Source/WebCore/platform/graphics/FontCascadeDescription.h

@@typedef FontFamilySpecificationNull FontFamilyPlatformSpecification;
4545
4646typedef std::variant<AtomString, FontFamilyPlatformSpecification> FontFamilySpecification;
4747
48 class Font;
49 
5048class FontCascadeDescription : public FontDescription {
5149public:
5250 WEBCORE_EXPORT FontCascadeDescription();

@@public:
120118 }
121119#endif
122120
123  WEBCORE_EXPORT void resolveFontSizeAdjustFromFontIfNeeded(const Font&);
124 
125121 // Initial values for font properties.
126122 static std::optional<FontSelectionValue> initialItalic() { return std::nullopt; }
127123 static FontStyleAxis initialFontStyleAxis() { return FontStyleAxis::slnt; }

Source/WebCore/platform/graphics/FontCascadeFonts.h

@@public:
7474 WidthCache& widthCache() { return m_widthCache; }
7575 const WidthCache& widthCache() const { return m_widthCache; }
7676
77  const Font& primaryFont(const FontCascadeDescription&);
 77 const Font& primaryFont(FontCascadeDescription&);
7878 WEBCORE_EXPORT const FontRanges& realizeFallbackRangesAt(const FontCascadeDescription&, unsigned fallbackIndex);
7979
8080 void pruneSystemFallbacks();

@@inline bool FontCascadeFonts::canTakeFixedPitchFastContentMeasuring(const FontCa
144144 return m_canTakeFixedPitchFastContentMeasuring == TriState::True;
145145}
146146
147 inline const Font& FontCascadeFonts::primaryFont(const FontCascadeDescription& description)
 147inline const Font& FontCascadeFonts::primaryFont(FontCascadeDescription& description)
148148{
149149 ASSERT(m_thread ? m_thread->ptr() == &Thread::current() : isMainThread());
150150 if (!m_cachedPrimaryFont) {

@@inline const Font& FontCascadeFonts::primaryFont(const FontCascadeDescription& d
164164 }
165165 }
166166 }
 167
 168 ASSERT(m_cachedPrimaryFont);
 169 auto fontSizeAdjust = description.fontSizeAdjust();
 170 if (fontSizeAdjust.isFromFont()) {
 171 auto aspectValue = fontSizeAdjust.resolve(description.computedSize(), m_cachedPrimaryFont->fontMetrics());
 172 description.setFontSizeAdjust({ fontSizeAdjust.metric, FontSizeAdjust::ValueType::FromFont, aspectValue });
 173 }
167174 }
168  ASSERT(m_cachedPrimaryFont);
169175 return *m_cachedPrimaryFont;
170176}
171177

Source/WebCore/platform/graphics/FontSizeAdjust.h

@@struct FontSizeAdjust {
6969 : std::nullopt;
7070 }
7171
72  bool resolveFromFontIfNeeded(float computedSize, const FontMetrics& fontMetrics)
73  {
74  if (!shouldResolveFromFont())
75  return false;
76  value = resolve(computedSize, fontMetrics);
77  return true;
78  }
79 
8072 bool isNone() const { return !value && type != ValueType::FromFont; }
8173 bool isFromFont() const { return type == ValueType::FromFont; }
82  bool shouldResolveFromFont() const { return isFromFont() && !value; }
8374
8475 Metric metric { Metric::ExHeight };
8576 ValueType type { ValueType::Number };