Title: [289183] trunk/Source/WebCore
- Revision
- 289183
- Author
- [email protected]
- Date
- 2022-02-06 14:28:04 -0800 (Sun, 06 Feb 2022)
Log Message
[LFC][IFC] Add initial ideographic baseline support
https://bugs.webkit.org/show_bug.cgi?id=236177
Reviewed by Antti Koivisto.
This patch is in preparation for supporting vertical writing mode.
We don't know in advance if the style/content requires ideographic or alphabetic baseline, so
either we pre-compute it by going through all the individual runs or post-adjust it
by looping through the newly constructed inline boxes (which most of the time is the root inline box only).
This patch implements the post-adjust version where after constructInlineLevelBoxes(), we call
adjustIdeographicBaselineIfApplicable and reset the ascent/descent values accordingly.
* layout/formattingContexts/inline/InlineLineBoxBuilder.cpp:
(WebCore::Layout::LineBoxBuilder::build):
(WebCore::Layout::LineBoxBuilder::adjustIdeographicBaselineIfApplicable):
(WebCore::Layout::computedHeightAndLayoutBounds):
(WebCore::Layout::LineBoxBuilder::setVerticalGeometryForLineBreakBox const):
(WebCore::Layout::LineBoxBuilder::setInitialVerticalGeometryForInlineBox const):
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (289182 => 289183)
--- trunk/Source/WebCore/ChangeLog 2022-02-06 22:21:55 UTC (rev 289182)
+++ trunk/Source/WebCore/ChangeLog 2022-02-06 22:28:04 UTC (rev 289183)
@@ -1,3 +1,25 @@
+2022-02-06 Alan Bujtas <[email protected]>
+
+ [LFC][IFC] Add initial ideographic baseline support
+ https://bugs.webkit.org/show_bug.cgi?id=236177
+
+ Reviewed by Antti Koivisto.
+
+ This patch is in preparation for supporting vertical writing mode.
+
+ We don't know in advance if the style/content requires ideographic or alphabetic baseline, so
+ either we pre-compute it by going through all the individual runs or post-adjust it
+ by looping through the newly constructed inline boxes (which most of the time is the root inline box only).
+ This patch implements the post-adjust version where after constructInlineLevelBoxes(), we call
+ adjustIdeographicBaselineIfApplicable and reset the ascent/descent values accordingly.
+
+ * layout/formattingContexts/inline/InlineLineBoxBuilder.cpp:
+ (WebCore::Layout::LineBoxBuilder::build):
+ (WebCore::Layout::LineBoxBuilder::adjustIdeographicBaselineIfApplicable):
+ (WebCore::Layout::computedHeightAndLayoutBounds):
+ (WebCore::Layout::LineBoxBuilder::setVerticalGeometryForLineBreakBox const):
+ (WebCore::Layout::LineBoxBuilder::setInitialVerticalGeometryForInlineBox const):
+
2022-02-06 Antoine Quint <[email protected]>
[css-logical] Animations should convert logical properties to their physical equivalents
Modified: trunk/Source/WebCore/layout/formattingContexts/inline/InlineLineBoxBuilder.cpp (289182 => 289183)
--- trunk/Source/WebCore/layout/formattingContexts/inline/InlineLineBoxBuilder.cpp 2022-02-06 22:21:55 UTC (rev 289182)
+++ trunk/Source/WebCore/layout/formattingContexts/inline/InlineLineBoxBuilder.cpp 2022-02-06 22:28:04 UTC (rev 289183)
@@ -110,6 +110,7 @@
// FIXME: The overflowing hanging content should be part of the ink overflow.
auto lineBox = LineBox { rootBox(), rootInlineBoxAlignmentOffset, lineContent.contentLogicalWidth - lineContent.hangingContentWidth, lineIndex, lineContent.nonSpanningInlineLevelBoxCount };
constructInlineLevelBoxes(lineBox, lineContent, lineIndex);
+ adjustIdeographicBaselineIfApplicable(lineBox, lineIndex);
auto lineBoxLogicalHeight = LineBoxVerticalAligner { formattingContext() }.computeLogicalHeightAndAlign(lineBox);
return { lineBox, lineBoxLogicalHeight };
}
@@ -155,12 +156,12 @@
InlineLayoutUnit lineSpacing { 0 };
std::optional<InlineLayoutUnit> preferredLineHeight { };
};
-static LayoutBoundsMetrics layoutBoundsMetricsForInlineBox(const InlineLevelBox& inlineBox)
+static LayoutBoundsMetrics layoutBoundsMetricsForInlineBox(const InlineLevelBox& inlineBox, FontBaseline fontBaseline = AlphabeticBaseline)
{
ASSERT(inlineBox.isInlineBox());
auto& fontMetrics = inlineBox.primarymetricsOfPrimaryFont();
- InlineLayoutUnit ascent = fontMetrics.ascent();
- InlineLayoutUnit descent = fontMetrics.descent();
+ InlineLayoutUnit ascent = fontMetrics.ascent(fontBaseline);
+ InlineLayoutUnit descent = fontMetrics.descent(fontBaseline);
InlineLayoutUnit lineSpacing = fontMetrics.lineSpacing();
return { ascent, descent, lineSpacing, inlineBox.isPreferredLineHeightFontMetricsBased() ? std::nullopt : std::make_optional(inlineBox.preferredLineHeight()) };
}
@@ -323,7 +324,53 @@
lineBox.setHasContent(lineHasContent);
}
+void LineBoxBuilder::adjustIdeographicBaselineIfApplicable(LineBox& lineBox, size_t lineIndex)
+{
+ // Re-compute the ascent/descent values for the inline boxes on the line (including the root inline box)
+ // when the style/content needs ideographic baseline setup in vertical writing mode.
+ auto& rootInlineBox = lineBox.rootInlineBox();
+
+ auto lineNeedsIdeographicBaseline = [&] {
+ auto styleToUse = [&] (auto& inlineLevelBox) -> const RenderStyle& {
+ return !lineIndex ? inlineLevelBox.layoutBox().firstLineStyle() : inlineLevelBox.layoutBox().style();
+ };
+ auto& rootInlineBoxStyle = styleToUse(rootInlineBox);
+ if (rootInlineBoxStyle.isHorizontalWritingMode())
+ return false;
+
+ auto styleRequiresIdeographicBaseline = [&] (auto& style) {
+ return style.fontDescription().orientation() == FontOrientation::Vertical || style.fontCascade().primaryFont().hasVerticalGlyphs();
+ };
+
+ if (styleRequiresIdeographicBaseline(rootInlineBoxStyle))
+ return true;
+ for (auto& inlineLevelBox : lineBox.nonRootInlineLevelBoxes()) {
+ if (styleRequiresIdeographicBaseline(styleToUse(inlineLevelBox)))
+ return true;
+ }
+
+ auto contentRequiresIdeographicBaseline = [&] {
+ // FIXME: Add support for fallback fonts.
+ return false;
+ };
+ return contentRequiresIdeographicBaseline();
+ };
+
+ if (!lineNeedsIdeographicBaseline())
+ return;
+
+ setBaselineAndLayoutBounds(rootInlineBox, layoutBoundsMetricsForInlineBox(rootInlineBox, IdeographicBaseline));
+ for (auto& inlineLevelBox : lineBox.nonRootInlineLevelBoxes()) {
+ if (inlineLevelBox.isInlineBox())
+ setBaselineAndLayoutBounds(inlineLevelBox, layoutBoundsMetricsForInlineBox(inlineLevelBox, IdeographicBaseline));
+ else if (inlineLevelBox.isLineBreakBox()) {
+ auto& parentInlineBox = lineBox.inlineLevelBoxForLayoutBox(inlineLevelBox.layoutBox().parent());
+ setBaselineAndLayoutBounds(inlineLevelBox, layoutBoundsMetricsForInlineBox(parentInlineBox, IdeographicBaseline));
+ }
+ }
}
+
}
+}
#endif
Modified: trunk/Source/WebCore/layout/formattingContexts/inline/InlineLineBoxBuilder.h (289182 => 289183)
--- trunk/Source/WebCore/layout/formattingContexts/inline/InlineLineBoxBuilder.h 2022-02-06 22:21:55 UTC (rev 289182)
+++ trunk/Source/WebCore/layout/formattingContexts/inline/InlineLineBoxBuilder.h 2022-02-06 22:28:04 UTC (rev 289183)
@@ -52,7 +52,9 @@
private:
void setBaselineAndLayoutBounds(InlineLevelBox&, const LayoutBoundsMetrics&) const;
void adjustLayoutBoundsWithFallbackFonts(InlineLevelBox&, const TextUtil::FallbackFontList&) const;
+
void constructInlineLevelBoxes(LineBox&, const LineBuilder::LineContent&, size_t lineIndex);
+ void adjustIdeographicBaselineIfApplicable(LineBox&, size_t lineIndex);
const InlineFormattingContext& formattingContext() const { return m_inlineFormattingContext; }
const Box& rootBox() const { return formattingContext().root(); }
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes