Title: [289372] trunk/Source/WebCore
Revision
289372
Author
[email protected]
Date
2022-02-08 06:26:16 -0800 (Tue, 08 Feb 2022)

Log Message

[LFC][IFC] LineBoxBuilder::setBaselineAndLayoutBounds should handle atomic inline level boxes too
https://bugs.webkit.org/show_bug.cgi?id=236255

Reviewed by Antti Koivisto.

Call setBaselineAndLayoutBounds with atomic type of inline level boxes.
This is in preparation for adding support for ideographic baseline on atomic inline level boxes.

* layout/formattingContexts/inline/InlineLineBoxBuilder.cpp:
(WebCore::Layout::LineBoxBuilder::setBaselineAndLayoutBounds const):
(WebCore::Layout::LineBoxBuilder::constructInlineLevelBoxes):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (289371 => 289372)


--- trunk/Source/WebCore/ChangeLog	2022-02-08 14:19:50 UTC (rev 289371)
+++ trunk/Source/WebCore/ChangeLog	2022-02-08 14:26:16 UTC (rev 289372)
@@ -1,3 +1,17 @@
+2022-02-08  Alan Bujtas  <[email protected]>
+
+        [LFC][IFC] LineBoxBuilder::setBaselineAndLayoutBounds should handle atomic inline level boxes too
+        https://bugs.webkit.org/show_bug.cgi?id=236255
+
+        Reviewed by Antti Koivisto.
+
+        Call setBaselineAndLayoutBounds with atomic type of inline level boxes.
+        This is in preparation for adding support for ideographic baseline on atomic inline level boxes.
+
+        * layout/formattingContexts/inline/InlineLineBoxBuilder.cpp:
+        (WebCore::Layout::LineBoxBuilder::setBaselineAndLayoutBounds const):
+        (WebCore::Layout::LineBoxBuilder::constructInlineLevelBoxes):
+
 2022-02-08  Tyler Wilcock  <[email protected]>
 
         AX: When updating the isolated tree with a remove and add of the same object, the wrapper is not re-attached

Modified: trunk/Source/WebCore/layout/formattingContexts/inline/InlineLineBoxBuilder.cpp (289371 => 289372)


--- trunk/Source/WebCore/layout/formattingContexts/inline/InlineLineBoxBuilder.cpp	2022-02-08 14:19:50 UTC (rev 289371)
+++ trunk/Source/WebCore/layout/formattingContexts/inline/InlineLineBoxBuilder.cpp	2022-02-08 14:26:16 UTC (rev 289372)
@@ -164,7 +164,7 @@
     InlineLayoutUnit ascent { 0 };
     InlineLayoutUnit descent { 0 };
     InlineLayoutUnit lineSpacing { 0 };
-    std::optional<InlineLayoutUnit> preferredLineHeight;
+    std::optional<InlineLayoutUnit> preferredLineHeight { };
 };
 static LayoutBoundsMetrics layoutBoundsMetricsForInlineBox(const InlineLevelBox& inlineBox, FontBaseline fontBaseline = AlphabeticBaseline)
 {
@@ -176,26 +176,35 @@
     return { ascent, descent, lineSpacing, inlineBox.isPreferredLineHeightFontMetricsBased() ? std::nullopt : std::make_optional(inlineBox.preferredLineHeight()) };
 }
 
-void LineBoxBuilder::setBaselineAndLayoutBounds(InlineLevelBox& inlineBox, const LayoutBoundsMetrics& layoutBoundsMetrics) const
+void LineBoxBuilder::setBaselineAndLayoutBounds(InlineLevelBox& inlineLevelBox, const LayoutBoundsMetrics& layoutBoundsMetrics) const
 {
-    auto logicalHeight = layoutBoundsMetrics.ascent + layoutBoundsMetrics.descent;
-    auto halfLeading = InlineLayoutUnit { };
-    if (layoutBoundsMetrics.preferredLineHeight) {
-        // 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.
-        // https://www.w3.org/TR/css-inline-3/#inline-height
-        // Since text-edge is not supported yet and the initial value is leading, we should just apply it to
-        // all inline boxes.
-        halfLeading = (*layoutBoundsMetrics.preferredLineHeight - logicalHeight) / 2;
-    } else {
-        // Preferred line height is purely font metrics based (i.e glyphs stretch the line).
-        halfLeading = (layoutBoundsMetrics.lineSpacing - logicalHeight) / 2;
+    if (inlineLevelBox.isInlineBox() || inlineLevelBox.isLineBreakBox()) {
+        auto logicalHeight = layoutBoundsMetrics.ascent + layoutBoundsMetrics.descent;
+        auto halfLeading = InlineLayoutUnit { };
+        if (layoutBoundsMetrics.preferredLineHeight) {
+            // 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.
+            // https://www.w3.org/TR/css-inline-3/#inline-height
+            // Since text-edge is not supported yet and the initial value is leading, we should just apply it to
+            // all inline boxes.
+            halfLeading = (*layoutBoundsMetrics.preferredLineHeight - logicalHeight) / 2;
+        } else {
+            // Preferred line height is purely font metrics based (i.e glyphs stretch the line).
+            halfLeading = (layoutBoundsMetrics.lineSpacing - logicalHeight) / 2;
+        }
+        // We need floor/ceil to match legacy layout integral positioning.
+        inlineLevelBox.setAscent(floorf(layoutBoundsMetrics.ascent));
+        inlineLevelBox.setDescent(ceilf(layoutBoundsMetrics.descent));
+        inlineLevelBox.setLogicalHeight(logicalHeight);
+        inlineLevelBox.setLayoutBounds({ floorf(layoutBoundsMetrics.ascent + halfLeading), ceilf(layoutBoundsMetrics.descent + halfLeading) });
+        return;
     }
-    // We need floor/ceil to match legacy layout integral positioning.
-    inlineBox.setAscent(floorf(layoutBoundsMetrics.ascent));
-    inlineBox.setDescent(ceilf(layoutBoundsMetrics.descent));
-    inlineBox.setLogicalHeight(logicalHeight);
-    inlineBox.setLayoutBounds({ floorf(layoutBoundsMetrics.ascent + halfLeading), ceilf(layoutBoundsMetrics.descent + halfLeading) });
+    if (inlineLevelBox.isAtomicInlineLevelBox()) {
+        inlineLevelBox.setAscent(layoutBoundsMetrics.ascent);
+        inlineLevelBox.setLayoutBounds({ layoutBoundsMetrics.ascent, layoutBoundsMetrics.descent });
+        return;
+    }
+    ASSERT_NOT_REACHED();
 }
 
 void LineBoxBuilder::constructInlineLevelBoxes(LineBox& lineBox, const LineBuilder::LineContent& lineContent, size_t lineIndex)
@@ -256,8 +265,7 @@
                 ascent = marginBoxHeight;
             logicalLeft += std::max(0_lu, inlineLevelBoxGeometry.marginStart());
             auto atomicInlineLevelBox = InlineLevelBox::createAtomicInlineLevelBox(layoutBox, style, logicalLeft, { inlineLevelBoxGeometry.borderBoxWidth(), marginBoxHeight });
-            atomicInlineLevelBox.setAscent(ascent);
-            atomicInlineLevelBox.setLayoutBounds(InlineLevelBox::LayoutBounds { ascent, marginBoxHeight - ascent });
+            setBaselineAndLayoutBounds(atomicInlineLevelBox, { ascent, marginBoxHeight - ascent });
             lineBox.addInlineLevelBox(WTFMove(atomicInlineLevelBox));
             continue;
         }
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to