[webkit-changes] [WebKit/WebKit] e0b44d: Apply Markable to FontMetrics for consistency

ChangSeok Oh noreply at github.com
Wed Feb 14 14:19:38 PST 2024


  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: e0b44ddffaafdfc7549ba4cf4638e12f0ee53556
      https://github.com/WebKit/WebKit/commit/e0b44ddffaafdfc7549ba4cf4638e12f0ee53556
  Author: ChangSeok Oh <changseok at webkit.org>
  Date:   2024-02-14 (Wed, 14 Feb 2024)

  Changed paths:
    M Source/WebCore/css/CSSPrimitiveValue.cpp
    M Source/WebCore/html/HTMLInputElement.cpp
    M Source/WebCore/html/canvas/CanvasRenderingContext2DBase.cpp
    M Source/WebCore/inspector/InspectorOverlay.cpp
    M Source/WebCore/inspector/InspectorOverlayLabel.cpp
    M Source/WebCore/layout/formattingContexts/inline/InlineLevelBox.h
    M Source/WebCore/layout/formattingContexts/inline/InlineLineBox.cpp
    M Source/WebCore/layout/formattingContexts/inline/InlineLineBoxBuilder.cpp
    M Source/WebCore/layout/formattingContexts/inline/InlineLineBoxVerticalAligner.cpp
    M Source/WebCore/layout/formattingContexts/inline/InlineQuirks.cpp
    M Source/WebCore/layout/formattingContexts/inline/display/InlineDisplayContentBuilder.cpp
    M Source/WebCore/layout/formattingContexts/inline/ruby/RubyFormattingContext.cpp
    M Source/WebCore/layout/integration/inline/LayoutIntegrationPagination.cpp
    M Source/WebCore/platform/graphics/Font.cpp
    M Source/WebCore/platform/graphics/FontCascade.cpp
    M Source/WebCore/platform/graphics/FontMetrics.h
    M Source/WebCore/platform/graphics/FontSizeAdjust.h
    M Source/WebCore/platform/graphics/PositionedGlyphs.cpp
    M Source/WebCore/platform/graphics/coretext/DrawGlyphsRecorderCoreText.cpp
    M Source/WebCore/platform/graphics/coretext/FontCascadeCoreText.cpp
    M Source/WebCore/platform/graphics/coretext/FontCoreText.cpp
    M Source/WebCore/platform/graphics/opentype/OpenTypeVerticalData.cpp
    M Source/WebCore/platform/win/DragImageWin.cpp
    M Source/WebCore/rendering/CaretRectComputation.cpp
    M Source/WebCore/rendering/EllipsisBoxPainter.cpp
    M Source/WebCore/rendering/LegacyEllipsisBox.cpp
    M Source/WebCore/rendering/LegacyInlineBox.cpp
    M Source/WebCore/rendering/LegacyInlineFlowBox.cpp
    M Source/WebCore/rendering/LegacyLineLayout.cpp
    M Source/WebCore/rendering/LegacyRootInlineBox.cpp
    M Source/WebCore/rendering/RenderBlock.cpp
    M Source/WebCore/rendering/RenderBlockFlow.cpp
    M Source/WebCore/rendering/RenderEmbeddedObject.cpp
    M Source/WebCore/rendering/RenderFileUploadControl.cpp
    M Source/WebCore/rendering/RenderImage.cpp
    M Source/WebCore/rendering/RenderInline.cpp
    M Source/WebCore/rendering/RenderLineBreak.cpp
    M Source/WebCore/rendering/RenderListBox.cpp
    M Source/WebCore/rendering/RenderListMarker.cpp
    M Source/WebCore/rendering/RenderRubyRun.cpp
    M Source/WebCore/rendering/TextBoxPainter.cpp
    M Source/WebCore/rendering/TextPainter.cpp
    M Source/WebCore/rendering/mathml/RenderMathMLBlock.cpp
    M Source/WebCore/rendering/mathml/RenderMathMLRoot.cpp
    M Source/WebCore/rendering/mathml/RenderMathMLScripts.cpp
    M Source/WebCore/rendering/mathml/RenderMathMLUnderOver.cpp
    M Source/WebCore/rendering/style/RenderStyle.cpp
    M Source/WebCore/rendering/style/TextDecorationThickness.h
    M Source/WebCore/rendering/svg/RenderSVGInlineText.cpp
    M Source/WebCore/rendering/svg/SVGInlineTextBox.cpp
    M Source/WebCore/rendering/svg/SVGTextLayoutEngineBaseline.cpp
    M Source/WebCore/rendering/svg/SVGTextMetrics.cpp
    M Source/WebCore/rendering/svg/SVGTextQuery.cpp
    M Source/WebCore/rendering/updating/RenderTreeBuilderFirstLetter.cpp
    M Source/WebCore/style/InlineTextBoxStyle.cpp
    M Source/WebCore/style/StyleFontSizeFunctions.cpp
    M Source/WebCore/svg/SVGLengthContext.cpp
    M Source/WebKit/WebProcess/WebCoreSupport/win/WebPopupMenuWin.cpp
    M Source/WebKit/WebProcess/WebPage/Cocoa/WebPageCocoa.mm
    M Source/WebKitLegacy/mac/WebView/WebImmediateActionController.mm

  Log Message:
  -----------
  Apply Markable to FontMetrics for consistency
https://bugs.webkit.org/show_bug.cgi?id=255378

Reviewed by Alan Baradlay and Matthieu Dubet.

This change aims at cleaning up the FontMetrics interface. There are three
inconsistencies in this class, which could mislead developers.

1. Inconsistent type of get/set methods. The set methods take float, but the
   corresponding get functions return int.
2. Inconsistent return types of get methods. For example, The height() returns
   an int, but the xHeight() returns a float.
3. Inconsistent validity checks. The xHeight and capHeight use their own has*
   functions, but the zeroWidth uses std::optional. Others font metrics do not
   provide any validity check methods.

This change applies Markable to FontMetrics and makes its interface
in the following way:

1. Each get method returns a float as default. To get an int value, callers
   should explicitly call the int* methods. (e.g., ascent() returns float and
   intAscent() returns int.)
2. Each font metric value is returned as a Markable value. So callers can check
   the validity with the boolean operator.

This patch does not change the existing layout or functionalities.

* Source/WebCore/css/CSSPrimitiveValue.cpp:
(WebCore::CSSPrimitiveValue::computeUnzoomedNonCalcLengthDouble):
(WebCore::CSSPrimitiveValue::computeNonCalcLengthDouble):
* Source/WebCore/html/HTMLInputElement.cpp:
(WebCore::HTMLInputElement::createInnerTextStyle):
* Source/WebCore/html/canvas/CanvasRenderingContext2DBase.cpp:
(WebCore::CanvasRenderingContext2DBase::drawTextUnchecked):
(WebCore::CanvasRenderingContext2DBase::measureTextInternal):
(WebCore::CanvasRenderingContext2DBase::textOffset):
* Source/WebCore/inspector/InspectorOverlay.cpp:
(WebCore::InspectorOverlay::drawRulers):
* Source/WebCore/inspector/InspectorOverlayLabel.cpp:
(WebCore::InspectorOverlayLabel::draw):
(WebCore::InspectorOverlayLabel::expectedSize):
* Source/WebCore/layout/formattingContexts/inline/InlineLevelBox.h:
(WebCore::Layout::InlineLevelBox::preferredLineHeight const):
* Source/WebCore/layout/formattingContexts/inline/InlineLineBox.cpp:
(WebCore::Layout::LineBox::logicalRectForTextRun const):
* Source/WebCore/layout/formattingContexts/inline/InlineLineBoxBuilder.cpp:
(WebCore::Layout::primaryFontMetricsForInlineBox):
(WebCore::Layout::ascentAndDescentWithTextBoxEdgeForInlineBox):
(WebCore::Layout::LineBoxBuilder::enclosingAscentDescentWithFallbackFonts const):
(WebCore::Layout::LineBoxBuilder::setLayoutBoundsForInlineBox const):
(WebCore::Layout::LineBoxBuilder::setVerticalPropertiesForInlineLevelBox const):
(WebCore::Layout::LineBoxBuilder::adjustInlineBoxHeightsForLineBoxContainIfApplicable):
(WebCore::Layout::LineBoxBuilder::computeLineBoxGeometry const):
* Source/WebCore/layout/formattingContexts/inline/InlineLineBoxVerticalAligner.cpp:
(WebCore::Layout::LineBoxVerticalAligner::computeLineBoxLogicalHeight const):
(WebCore::Layout::LineBoxVerticalAligner::computeRootInlineBoxVerticalPosition const):
(WebCore::Layout::LineBoxVerticalAligner::alignInlineLevelBoxes const):
* Source/WebCore/layout/formattingContexts/inline/InlineQuirks.cpp:
(WebCore::Layout::InlineQuirks::initialLetterAlignmentOffset const):
(WebCore::Layout::InlineQuirks::adjustmentForLineGridLineSnap const):
* Source/WebCore/layout/formattingContexts/inline/display/InlineDisplayContentBuilder.cpp:
(WebCore::Layout::InlineDisplayContentBuilder::appendTextDisplayBox):
* Source/WebCore/layout/formattingContexts/inline/ruby/RubyFormattingContext.cpp:
(WebCore::Layout::RubyFormattingContext::adjustLayoutBoundsAndStretchAncestorRubyBase):
* Source/WebCore/layout/integration/inline/LayoutIntegrationPagination.cpp:
(WebCore::LayoutIntegration::computeFirstLineSnapAdjustment):
* Source/WebCore/platform/graphics/Font.cpp:
(WebCore::Font::initCharWidths):
(WebCore::Font::platformGlyphInit):
* Source/WebCore/platform/graphics/FontCascade.cpp:
(WebCore::FontCascade::emphasisMarkAscent const):
(WebCore::FontCascade::emphasisMarkDescent const):
(WebCore::FontCascade::emphasisMarkHeight const):
(WebCore::FontCascade::floatEmphasisMarkHeight const):
(WebCore::FontCascade::floatWidthForSimpleText const):
(WebCore::FontCascade::floatWidthForComplexText const):
* Source/WebCore/platform/graphics/FontMetrics.h:
(WebCore::FontMetrics::MarkableTraits::isEmptyValue):
(WebCore::FontMetrics::MarkableTraits::emptyValue):
(WebCore::FontMetrics::height const):
(WebCore::FontMetrics::intHeight const):
(WebCore::FontMetrics::ascent const):
(WebCore::FontMetrics::intAscent const):
(WebCore::FontMetrics::setAscent):
(WebCore::FontMetrics::descent const):
(WebCore::FontMetrics::intDescent const):
(WebCore::FontMetrics::setDescent):
(WebCore::FontMetrics::lineGap const):
(WebCore::FontMetrics::intLineGap const):
(WebCore::FontMetrics::setLineGap):
(WebCore::FontMetrics::lineSpacing const):
(WebCore::FontMetrics::intLineSpacing const):
(WebCore::FontMetrics::setLineSpacing):
(WebCore::FontMetrics::xHeight const):
(WebCore::FontMetrics::capHeight const):
(WebCore::FontMetrics::intCapHeight const):
(WebCore::FontMetrics::setCapHeight):
(WebCore::FontMetrics::zeroWidth const):
(WebCore::FontMetrics::ideogramWidth const):
(WebCore::FontMetrics::underlinePosition const):
(WebCore::FontMetrics::underlineThickness const):
(WebCore::FontMetrics::hasIdenticalAscentDescentAndLineGap const):
(WebCore::FontMetrics::reset):
(WebCore::FontMetrics::floatAscent const): Deleted.
(WebCore::FontMetrics::floatDescent const): Deleted.
(WebCore::FontMetrics::floatHeight const): Deleted.
(WebCore::FontMetrics::floatLineGap const): Deleted.
(WebCore::FontMetrics::floatLineSpacing const): Deleted.
(WebCore::FontMetrics::hasXHeight const): Deleted.
(WebCore::FontMetrics::hasCapHeight const): Deleted.
(WebCore::FontMetrics::floatCapHeight const): Deleted.
* Source/WebCore/platform/graphics/FontSizeAdjust.h:
(WebCore::FontSizeAdjust::resolve const):
* Source/WebCore/platform/graphics/PositionedGlyphs.cpp:
(WebCore::PositionedGlyphs::computeBounds const):
* Source/WebCore/platform/graphics/coretext/DrawGlyphsRecorderCoreText.cpp:
(WebCore::DrawGlyphsRecorder::recordDrawGlyphs):
* Source/WebCore/platform/graphics/coretext/FontCascadeCoreText.cpp:
(WebCore::showGlyphsWithAdvances):
* Source/WebCore/platform/graphics/coretext/FontCoreText.cpp:
(WebCore::Font::platformInit):
* Source/WebCore/platform/graphics/opentype/OpenTypeVerticalData.cpp:
(WebCore::OpenTypeVerticalData::advanceHeight const):
(WebCore::OpenTypeVerticalData::getVerticalTranslationsForGlyphs const):
* Source/WebCore/platform/win/DragImageWin.cpp:
(WebCore::createDragImageForLink):
* Source/WebCore/rendering/CaretRectComputation.cpp:
(WebCore::computeCaretRectForEmptyElement):
(WebCore::computeCaretRectForBox):
* Source/WebCore/rendering/EllipsisBoxPainter.cpp:
(WebCore::EllipsisBoxPainter::paint):
* Source/WebCore/rendering/LegacyEllipsisBox.cpp:
(WebCore::LegacyEllipsisBox::paintMarkupBox):
(WebCore::LegacyEllipsisBox::nodeAtPoint):
* Source/WebCore/rendering/LegacyInlineBox.cpp:
(WebCore::LegacyInlineBox::logicalHeight const):
* Source/WebCore/rendering/LegacyInlineFlowBox.cpp:
(WebCore::placeChildInlineBoxesInBlockDirection):
(WebCore::LegacyInlineFlowBox::placeBoxesInBlockDirection):
* Source/WebCore/rendering/LegacyLineLayout.cpp:
(WebCore::setLogicalWidthForTextRun):
* Source/WebCore/rendering/LegacyRootInlineBox.cpp:
(WebCore::LegacyRootInlineBox::lineSnapAdjustment const):
(WebCore::LegacyRootInlineBox::ascentAndDescentForBox const):
(WebCore::LegacyRootInlineBox::verticalPositionForBox):
* Source/WebCore/rendering/RenderBlock.cpp:
(WebCore::RenderBlock::baselinePosition const):
(WebCore::RenderBlock::inlineBlockBaseline const):
* Source/WebCore/rendering/RenderBlockFlow.cpp:
(WebCore::RenderBlockFlow::adjustInitialLetterPosition):
(WebCore::RenderBlockFlow::firstLineBaseline const):
(WebCore::RenderBlockFlow::lastLineBaseline const):
(WebCore::RenderBlockFlow::inlineBlockBaseline const):
* Source/WebCore/rendering/RenderEmbeddedObject.cpp:
(WebCore::RenderEmbeddedObject::paintReplaced):
* Source/WebCore/rendering/RenderFileUploadControl.cpp:
(WebCore::RenderFileUploadControl::paintControl):
* Source/WebCore/rendering/RenderImage.cpp:
(WebCore::RenderImage::setImageSizeForAltText):
(WebCore::RenderImage::paintReplaced):
* Source/WebCore/rendering/RenderInline.cpp:
(WebCore::RenderInline::baselinePosition const):
* Source/WebCore/rendering/RenderLineBreak.cpp:
(WebCore::RenderLineBreak::baselinePosition const):
* Source/WebCore/rendering/RenderListBox.cpp:
(WebCore::itemOffsetForAlignment):
(WebCore::RenderListBox::itemLogicalHeight const):
* Source/WebCore/rendering/RenderListMarker.cpp:
(WebCore::RenderListMarker::paint):
(WebCore::RenderListMarker::layout):
(WebCore::RenderListMarker::updateContent):
(WebCore::RenderListMarker::computePreferredLogicalWidths):
(WebCore::RenderListMarker::updateMargins):
(WebCore::RenderListMarker::relativeMarkerRect):
* Source/WebCore/rendering/RenderRubyRun.cpp:
(WebCore::RenderRubyRun::layoutBlock):
(WebCore::RenderRubyRun::baselinePosition const):
* Source/WebCore/rendering/TextBoxPainter.cpp:
(WebCore::TextBoxPainter<TextBoxPath>::paintForeground):
(WebCore::computedLinethroughCenter):
(WebCore::TextBoxPainter<TextBoxPath>::paintBackgroundDecorations):
(WebCore::TextBoxPainter<TextBoxPath>::fillCompositionUnderline const):
(WebCore::calculateDocumentMarkerBounds):
(WebCore::TextBoxPainter<TextBoxPath>::textOriginFromPaintRect const):
* Source/WebCore/rendering/TextPainter.cpp:
(WebCore::TextPainter::paintTextAndEmphasisMarksIfNeeded):
* Source/WebCore/rendering/mathml/RenderMathMLBlock.cpp:
(WebCore::axisHeight):
(WebCore::toUserUnits):
* Source/WebCore/rendering/mathml/RenderMathMLRoot.cpp:
(WebCore::RenderMathMLRoot::verticalParameters):
* Source/WebCore/rendering/mathml/RenderMathMLScripts.cpp:
(WebCore::RenderMathMLScripts::verticalParameters const):
* Source/WebCore/rendering/mathml/RenderMathMLUnderOver.cpp:
(WebCore::RenderMathMLUnderOver::verticalParameters const):
* Source/WebCore/rendering/style/RenderStyle.cpp:
(WebCore::RenderStyle::computeLineHeight const):
* Source/WebCore/rendering/style/TextDecorationThickness.h:
(WebCore::TextDecorationThickness::resolve const):
* Source/WebCore/rendering/svg/RenderSVGInlineText.cpp:
(WebCore::RenderSVGInlineText::positionForPoint):
* Source/WebCore/rendering/svg/SVGInlineTextBox.cpp:
(WebCore::SVGInlineTextBox::selectionRectForTextFragment const):
(WebCore::positionOffsetForDecoration):
(WebCore::SVGInlineTextBox::paintDecorationWithStyle):
(WebCore::SVGInlineTextBox::paintTextWithShadows):
(WebCore::SVGInlineTextBox::calculateBoundaries const):
(WebCore::SVGInlineTextBox::nodeAtPoint):
* Source/WebCore/rendering/svg/SVGTextLayoutEngineBaseline.cpp:
(WebCore::SVGTextLayoutEngineBaseline::calculateBaselineShift const):
(WebCore::SVGTextLayoutEngineBaseline::calculateAlignmentBaselineShift const):
(WebCore::SVGTextLayoutEngineBaseline::calculateGlyphAdvanceAndOrientation const):
* Source/WebCore/rendering/svg/SVGTextMetrics.cpp:
(WebCore::SVGTextMetrics::SVGTextMetrics):
* Source/WebCore/rendering/svg/SVGTextQuery.cpp:
(WebCore::calculateGlyphBoundaries):
(WebCore::calculateFragmentBoundaries):
* Source/WebCore/rendering/updating/RenderTreeBuilderFirstLetter.cpp:
(WebCore::styleForFirstLetter):
* Source/WebCore/style/InlineTextBoxStyle.cpp:
(WebCore::computedUnderlineOffset):
(WebCore::computedVisualOverflowForDecorations):
* Source/WebCore/style/StyleFontSizeFunctions.cpp:
(WebCore::Style::adjustedFontSize):
* Source/WebCore/svg/SVGLengthContext.cpp:
(WebCore::SVGLengthContext::convertValueFromUserUnitsToEXS const):
(WebCore::SVGLengthContext::convertValueFromEXSToUserUnits const):
* Source/WebKit/WebProcess/WebCoreSupport/win/WebPopupMenuWin.cpp:
(WebKit::WebPopupMenu::setUpPlatformData):
* Source/WebKit/WebProcess/WebPage/Cocoa/WebPageCocoa.mm:
(WebKit::WebPage::dictionaryPopupInfoForRange):
* Source/WebKitLegacy/mac/WebView/WebImmediateActionController.mm:
(+[WebImmediateActionController _dictionaryPopupInfoForRange:inFrame:withLookupOptions:indicatorOptions:transition:]):

Canonical link: https://commits.webkit.org/274662@main




More information about the webkit-changes mailing list