Title: [282726] trunk/Source/WebCore
- Revision
- 282726
- Author
- [email protected]
- Date
- 2021-09-18 08:59:14 -0700 (Sat, 18 Sep 2021)
Log Message
[LFC][IFC] Stretch the inline box with glyphs coming from fallback fonts.
https://bugs.webkit.org/show_bug.cgi?id=230439
Reviewed by Antti Koivisto.
https://www.w3.org/TR/css-inline-3/#inline-height
"...
When the computed line-height is normal, the layout bounds of an inline box encloses all its glyphs, going from the highest A to the deepest D.
(Note that glyphs in a single box can come from different fonts and thus might not all have the same A and D.)
..."
(This is still no-op as TextUtil::fallbackFontsForRun returns an empty set)
* layout/formattingContexts/inline/InlineLineBoxBuilder.cpp:
(WebCore::Layout::LineBoxBuilder::adjustVerticalGeometryForInlineBoxWithFallbackFonts const):
(WebCore::Layout::LineBoxBuilder::constructAndAlignInlineLevelBoxes):
* layout/formattingContexts/inline/InlineLineBoxBuilder.h:
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (282725 => 282726)
--- trunk/Source/WebCore/ChangeLog 2021-09-18 13:29:40 UTC (rev 282725)
+++ trunk/Source/WebCore/ChangeLog 2021-09-18 15:59:14 UTC (rev 282726)
@@ -1,5 +1,24 @@
2021-09-18 Alan Bujtas <[email protected]>
+ [LFC][IFC] Stretch the inline box with glyphs coming from fallback fonts.
+ https://bugs.webkit.org/show_bug.cgi?id=230439
+
+ Reviewed by Antti Koivisto.
+
+ https://www.w3.org/TR/css-inline-3/#inline-height
+ "...
+ When the computed line-height is normal, the layout bounds of an inline box encloses all its glyphs, going from the highest A to the deepest D.
+ (Note that glyphs in a single box can come from different fonts and thus might not all have the same A and D.)
+ ..."
+ (This is still no-op as TextUtil::fallbackFontsForRun returns an empty set)
+
+ * layout/formattingContexts/inline/InlineLineBoxBuilder.cpp:
+ (WebCore::Layout::LineBoxBuilder::adjustVerticalGeometryForInlineBoxWithFallbackFonts const):
+ (WebCore::Layout::LineBoxBuilder::constructAndAlignInlineLevelBoxes):
+ * layout/formattingContexts/inline/InlineLineBoxBuilder.h:
+
+2021-09-18 Alan Bujtas <[email protected]>
+
[LFC][IFC] Add skeleton implementation for fallback font support
https://bugs.webkit.org/show_bug.cgi?id=230433
Modified: trunk/Source/WebCore/layout/formattingContexts/inline/InlineLineBoxBuilder.cpp (282725 => 282726)
--- trunk/Source/WebCore/layout/formattingContexts/inline/InlineLineBoxBuilder.cpp 2021-09-18 13:29:40 UTC (rev 282725)
+++ trunk/Source/WebCore/layout/formattingContexts/inline/InlineLineBoxBuilder.cpp 2021-09-18 15:59:14 UTC (rev 282726)
@@ -158,11 +158,38 @@
return { lineBox, lineGeometry() };
}
-void LineBoxBuilder::adjustVerticalGeometryForInlineBoxWithFallbackFonts(InlineLevelBox& parentInlineBox, const Line::Run& textRun, const TextUtil::FallbackFontList& fallbackFonts) const
+void LineBoxBuilder::adjustVerticalGeometryForInlineBoxWithFallbackFonts(InlineLevelBox& inlineBox, const TextUtil::FallbackFontList& fallbackFontsForContent) const
{
- UNUSED_PARAM(parentInlineBox);
- UNUSED_PARAM(textRun);
- UNUSED_PARAM(fallbackFonts);
+ ASSERT(!fallbackFontsForContent.isEmpty());
+ ASSERT(inlineBox.isInlineBox());
+ auto& style = inlineBox.style();
+ if (!style.lineHeight().isNegative())
+ return;
+
+ // https://www.w3.org/TR/css-inline-3/#inline-height
+ // When the computed line-height is normal, the layout bounds of an inline box encloses all its glyphs, going from the highest A to the deepest D.
+ auto maxAscent = InlineLayoutUnit { };
+ auto maxDescent = InlineLayoutUnit { };
+ // If line-height computes to normal and either text-edge is leading or this is the root inline box,
+ // the font's line gap metric may also be incorporated into A and D by adding half to each side as half-leading.
+ auto shouldUseLineGapToAdjustAscentDescent = inlineBox.isRootInlineBox();
+ for (auto* font : fallbackFontsForContent) {
+ auto& fontMetrics = font->fontMetrics();
+ InlineLayoutUnit ascent = fontMetrics.ascent();
+ InlineLayoutUnit descent = fontMetrics.descent();
+ if (shouldUseLineGapToAdjustAscentDescent) {
+ auto logicalHeight = ascent + descent;
+ auto halfLineGap = (fontMetrics.lineSpacing() - logicalHeight) / 2;
+ ascent = ascent + halfLineGap;
+ descent = descent + halfLineGap;
+ }
+ maxAscent = std::max(maxAscent, ascent);
+ maxDescent = std::max(maxDescent, descent);
+ }
+
+ // We need floor/ceil to match legacy layout integral positioning.
+ auto layoutBounds = inlineBox.layoutBounds();
+ inlineBox.setLayoutBounds({ std::max(layoutBounds.ascent, floorf(maxAscent)), std::max(layoutBounds.descent, floorf(maxDescent)) });
}
void LineBoxBuilder::setInitialVerticalGeometryForInlineBox(InlineLevelBox& inlineLevelBox) const
@@ -337,7 +364,7 @@
auto fallbackFonts = TextUtil::fallbackFontsForRun(run);
if (!fallbackFonts.isEmpty()) {
// Adjust non-empty inline box height when glyphs from the non-primary font stretch the box.
- adjustVerticalGeometryForInlineBoxWithFallbackFonts(parentInlineBox, run, fallbackFonts);
+ adjustVerticalGeometryForInlineBoxWithFallbackFonts(parentInlineBox, fallbackFonts);
updateCanUseSimplifiedAlignment(parentInlineBox);
}
continue;
Modified: trunk/Source/WebCore/layout/formattingContexts/inline/InlineLineBoxBuilder.h (282725 => 282726)
--- trunk/Source/WebCore/layout/formattingContexts/inline/InlineLineBoxBuilder.h 2021-09-18 13:29:40 UTC (rev 282725)
+++ trunk/Source/WebCore/layout/formattingContexts/inline/InlineLineBoxBuilder.h 2021-09-18 15:59:14 UTC (rev 282726)
@@ -52,7 +52,7 @@
private:
void setInitialVerticalGeometryForInlineBox(InlineLevelBox&) const;
- void adjustVerticalGeometryForInlineBoxWithFallbackFonts(InlineLevelBox&, const Line::Run&, const TextUtil::FallbackFontList&) const;
+ void adjustVerticalGeometryForInlineBoxWithFallbackFonts(InlineLevelBox&, const TextUtil::FallbackFontList&) const;
InlineLayoutUnit constructAndAlignInlineLevelBoxes(LineBox&, const Line::RunList&);
const InlineFormattingContext& formattingContext() const { return m_inlineFormattingContext; }
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes