Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Font sizes are rounded to the nearest 1px
https://bugs.webkit.org/show_bug.cgi?id=46987
<rdar://problem/40829933>

Reviewed by Alan Baradlay.

Previously, we have sibling functions:
float computedSize() const { return m_computedSize; }
unsigned computedPixelSize() const { return unsigned(m_computedSize + 0.5f); }

The bug is that we were using computedPixelSize() rather than computedSize() when performing layout +
rendering, which causes font sizes to be quantized to discrete multiples of 1px. This is problematic
because it means authors can't get nicely flowing font sizes, as per https://jsfiddle.net/64hwk8bt/1/.
It was also doubly unfortunate because if you did something like divide a font size by 2 and then
multiply it by 2 (in script), the font-size wouldn't round-trip unperturbed.

This patch fixes this by avoiding the rounding, via migrating callers as such:
+--------------------------------------+------------------------------------------+
| Calls to this:                       | Are replaced with calls to this instead: |
+--------------------------------------+------------------------------------------+
| FontDescription::computedPixelSize() | FontDescription::computedSize()          |
| FontCascade::pixelSize()             | FontCascade::size()                      |
| RenderStyle::computedFontPixelSize() | RenderStyle::computedFontSize()          |
+--------------------------------------+------------------------------------------+

This patch also deletes the old functions which are now unused.

* LayoutTests: Rebaseline test results
* Source/WebCore/accessibility/atspi/AccessibilityObjectTextAtspi.cpp:
(WebCore::AccessibilityObjectAtspi::textAttributes const):
* Source/WebCore/editing/TextIterator.cpp:
(WebCore::shouldEmitExtraNewlineForNode):
* Source/WebCore/html/canvas/CanvasRenderingContext2DBase.cpp:
(WebCore::CanvasRenderingContext2DBase::State::fontString const):
* Source/WebCore/layout/formattingContexts/inline/InlineContentBreaker.cpp:
(WebCore::Layout::InlineContentBreaker::tryBreakingTextRun const):
(WebCore::Layout::InlineContentBreaker::tryHyphenationAcrossOverflowingInlineTextItems const):
* Source/WebCore/layout/formattingContexts/inline/InlineLevelBoxInlines.h:
(WebCore::Layout::m_style):
* Source/WebCore/loader/cache/CachedSVGFont.cpp:
(WebCore::CachedSVGFont::platformDataFromCustomData):
* Source/WebCore/page/PrintContext.cpp:
(WebCore::PrintContext::pageProperty):
* Source/WebCore/page/ios/FrameIOS.mm:
(WebCore::LocalFrame::renderRectForPoint const):
* Source/WebCore/platform/adwaita/ThemeAdwaita.cpp:
(WebCore::ThemeAdwaita::controlSize const):
* Source/WebCore/platform/graphics/FontCascade.h:
(WebCore::FontCascade::pixelSize const): Deleted.
* Source/WebCore/platform/graphics/FontCascadeCache.h:
(WebCore::FontDescriptionKey::FontDescriptionKey):
* Source/WebCore/platform/graphics/FontDescription.cpp:
(WebCore::FontDescription::adjustedSizeForFontFace const):
* Source/WebCore/platform/graphics/FontDescription.h:
(WebCore::FontDescription::computedSize const):
(WebCore::FontDescription::computedPixelSize const): Deleted.
* Source/WebCore/platform/graphics/cocoa/FontCacheCoreText.cpp:
(WebCore::FontCache::createFontPlatformData):
(WebCore::FontCache::lastResortFallbackFont):
* Source/WebCore/platform/graphics/controls/ControlStyle.h:
* Source/WebCore/platform/graphics/coretext/FontCustomPlatformDataCoreText.cpp:
(WebCore::FontCustomPlatformData::fontPlatformData):
* Source/WebCore/platform/graphics/freetype/FontCacheFreeType.cpp:
(WebCore::FontCache::configurePatternForFontDescription):
(WebCore::FontCache::systemFallbackForCharacters):
(WebCore::FontCache::createFontPlatformData):
* Source/WebCore/platform/graphics/freetype/FontCustomPlatformDataFreeType.cpp:
(WebCore::FontCustomPlatformData::fontPlatformData):
* Source/WebCore/platform/graphics/win/FontCacheWin.cpp:
(WebCore::FontCache::lastResortFallbackFont):
(WebCore::FontCache::createFontPlatformData):
* Source/WebCore/platform/graphics/win/FontCustomPlatformDataWin.cpp:
(WebCore::FontCustomPlatformData::fontPlatformData):
* Source/WebCore/platform/mac/ThemeMac.mm:
(WebCore::controlSizeForFont):
(WebCore::stepperControlSizeForFont):
* Source/WebCore/platform/text/Hyphenation.h:
(WebCore::enoughWidthForHyphenation):
* Source/WebCore/platform/win/DragImageWin.cpp:
(WebCore::createDragImageForLink):
* Source/WebCore/rendering/RenderBlockFlow.cpp:
(WebCore::RenderBlockFlow::columnGap const):
* Source/WebCore/rendering/RenderMultiColumnSet.cpp:
(WebCore::RenderMultiColumnSet::columnGap const):
* Source/WebCore/rendering/RenderRubyRun.cpp:
(WebCore::shouldOverhang):
(WebCore::RenderRubyRun::startAndEndOverhang const):
* Source/WebCore/rendering/RenderRubyText.cpp:
(WebCore::RenderRubyText::adjustInlineDirectionLineBounds const):
* Source/WebCore/rendering/RenderText.cpp:
(WebCore::RenderText::maxWordFragmentWidth):
* Source/WebCore/rendering/RenderTheme.cpp:
(WebCore::RenderTheme::extractControlStyleForRenderer const):
* Source/WebCore/rendering/RenderThemeIOS.mm:
(WebCore::RenderThemeIOS::adjustCheckboxStyle const):
(WebCore::RenderThemeIOS::adjustRadioStyle const):
* Source/WebCore/rendering/RenderThemeMac.mm:
(WebCore::RenderThemeMac::controlSizeForFont const):
(WebCore::RenderThemeMac::controlSizeForSystemFont const):
(WebCore::RenderThemeMac::popupInternalPaddingBox const):
(WebCore::RenderThemeMac::adjustMenuListButtonStyle const):
* Source/WebCore/rendering/TextBoxPainter.cpp:
(WebCore::TextBoxPainter<TextBoxPath>::paintBackgroundDecorations):
(WebCore::TextBoxPainter<TextBoxPath>::paintForegroundDecorations):
* Source/WebCore/rendering/line/BreakingContext.h:
(WebCore::tryHyphenating):
* Source/WebCore/rendering/mathml/RenderMathMLRow.cpp:
(WebCore::RenderMathMLRow::stretchVerticalOperatorsAndLayoutChildren):
* Source/WebCore/rendering/style/RenderStyle.cpp:
(WebCore::RenderStyle::computeLineHeight const):
(WebCore::RenderStyle::computedFontPixelSize const): Deleted.
* Source/WebCore/rendering/style/RenderStyle.h:
* Source/WebCore/rendering/svg/SVGInlineTextBox.cpp:
(WebCore::textShouldBePainted):
* Source/WebCore/rendering/svg/SVGTextLayoutEngineBaseline.cpp:
(WebCore::SVGTextLayoutEngineBaseline::calculateBaselineShift const):
* Source/WebCore/rendering/svg/SVGTextLayoutEngineSpacing.cpp:
(WebCore::SVGTextLayoutEngineSpacing::calculateCSSKerningAndSpacing):
* Source/WebCore/rendering/updating/RenderTreeBuilderFirstLetter.cpp:
(WebCore::styleForFirstLetter):
* Source/WebCore/style/InlineTextBoxStyle.cpp:
(WebCore::computedVisualOverflowForDecorations):
* Source/WebCore/style/StyleAdjuster.cpp:
(WebCore::Style::Adjuster::adjust const):
* Source/WebCore/style/StyleTreeResolver.cpp:
(WebCore::Style::TreeResolver::resolveElement):
* Source/WebCore/svg/SVGLengthContext.cpp:
(WebCore::SVGLengthContext::convertValueFromUserUnitsToEMS const):
(WebCore::SVGLengthContext::convertValueFromEMSToUserUnits const):
* Source/WebKit/Shared/WebCoreArgumentCoders.serialization.in:
* Tools/CISupport/ews-build/steps.py:
(RunWebKitTests):
(RunWebKitTestsInStressMode):
(RunWebKitTestsRedTree):
(RunWebKitTestsWithoutChangeRedTree):

Canonical link: https://commits.webkit.org/265657@main
  • Loading branch information
litherum committed Jun 30, 2023
1 parent 05ca73c commit 30e54c6
Show file tree
Hide file tree
Showing 3,875 changed files with 82,372 additions and 29,719 deletions.