Diff
Modified: trunk/Source/WebCore/ChangeLog (267556 => 267557)
--- trunk/Source/WebCore/ChangeLog 2020-09-25 03:19:50 UTC (rev 267556)
+++ trunk/Source/WebCore/ChangeLog 2020-09-25 04:49:46 UTC (rev 267557)
@@ -1,3 +1,25 @@
+2020-09-24 Zalan Bujtas <[email protected]>
+
+ [LFC][IFC] Add helper functions to create LineBox::InlineBox objects for inline level boxes.
+ https://bugs.webkit.org/show_bug.cgi?id=216957
+
+ Reviewed by Simon Fraser.
+
+ The overloaded LineBox::InlineBox constructors were representing different types of inline level boxes.
+ These new helper functions make it easier to figure out how to initiate LineBox::InlineBox objects depending on the type of
+ the inline level box.
+ This patch also removes an incorrect ASSERT on the inline box's height. It is okay to have a zero height inline box.
+
+ * layout/inlineformatting/InlineFormattingContextGeometry.cpp:
+ (WebCore::Layout::LineBoxBuilder::constructInlineBoxes):
+ * layout/inlineformatting/InlineLineBox.cpp:
+ (WebCore::Layout::LineBox::InlineBox::InlineBox):
+ (WebCore::Layout::m_baseline):
+ * layout/inlineformatting/InlineLineBox.h:
+ (WebCore::Layout::LineBox::InlineBox::createBoxForRootInlineBox):
+ (WebCore::Layout::LineBox::InlineBox::createBoxForAtomicInlineLevelBox):
+ (WebCore::Layout::LineBox::InlineBox::createBoxForInlineBox):
+
2020-09-24 Keith Miller <[email protected]>
CSS angle unit conversions should consistently use the same associativity
Modified: trunk/Source/WebCore/layout/inlineformatting/InlineFormattingContextGeometry.cpp (267556 => 267557)
--- trunk/Source/WebCore/layout/inlineformatting/InlineFormattingContextGeometry.cpp 2020-09-25 03:19:50 UTC (rev 267556)
+++ trunk/Source/WebCore/layout/inlineformatting/InlineFormattingContextGeometry.cpp 2020-09-25 04:49:46 UTC (rev 267557)
@@ -179,9 +179,9 @@
if (auto lineSpacing = fontMetrics.lineSpacing() - logicalHeight)
inlineBox.setLineSpacing(lineSpacing);
};
-
+ auto horizontalAligmentOffset = lineBox.horizontalAlignmentOffset().valueOr(InlineLayoutUnit { });
auto constructRootInlineBox = [&] {
- auto rootInlineBox = makeUnique<LineBox::InlineBox>(rootBox(), lineBox.horizontalAlignmentOffset().valueOr(InlineLayoutUnit { }), lineBox.logicalWidth());
+ auto rootInlineBox = LineBox::InlineBox::createBoxForRootInlineBox(rootBox(), horizontalAligmentOffset, lineBox.logicalWidth());
auto lineHasImaginaryStrut = !layoutState().inQuirksMode();
auto isInitiallyConsideredNonEmpty = !lineBox.isLineVisuallyEmpty() && lineHasImaginaryStrut;
@@ -215,7 +215,7 @@
}
// Construct the missing LineBox::InlineBoxes starting with the topmost ancestor.
for (auto* ancestor : WTF::makeReversedRange(ancestorsWithoutInlineBoxes)) {
- auto inlineBox = makeUnique<LineBox::InlineBox>(*ancestor, lineBox.horizontalAlignmentOffset().valueOr(InlineLayoutUnit { }), lineBox.logicalWidth());
+ auto inlineBox = LineBox::InlineBox::createBoxForInlineBox(*ancestor, horizontalAligmentOffset, lineBox.logicalWidth());
inlineBox->setIsNonEmpty();
adjustVerticalGeometryForNonEmptyInlineBox(*inlineBox);
lineBox.addInlineBox(WTFMove(inlineBox));
@@ -226,7 +226,7 @@
for (auto& run : runs) {
auto& inlineLevelBox = run.layoutBox();
if (run.isBox()) {
- auto logicalLeft = lineBox.horizontalAlignmentOffset().valueOr(InlineLayoutUnit { }) + run.logicalLeft();
+ auto logicalLeft = horizontalAligmentOffset + run.logicalLeft();
auto& inlineLevelBoxGeometry = formattingContext().geometryForBox(inlineLevelBox);
auto logicalHeight = inlineLevelBoxGeometry.marginBoxHeight();
auto baseline = logicalHeight;
@@ -248,13 +248,15 @@
auto inlineBlockBaseline = lastLine.logicalTop() + lastLine.baseline();
baseline = inlineLevelBoxGeometry.marginBefore() + inlineLevelBoxGeometry.borderTop() + inlineLevelBoxGeometry.paddingTop().valueOr(0) + inlineBlockBaseline;
}
- auto rect = InlineRect { { }, logicalLeft, run.logicalWidth(), logicalHeight };
- lineBox.addInlineBox(makeUnique<LineBox::InlineBox>(inlineLevelBox, rect, baseline));
+ auto inlineBox = LineBox::InlineBox::createBoxForAtomicInlineLevelBox(inlineLevelBox, logicalLeft, { run.logicalWidth(), logicalHeight }, baseline);
+ if (logicalHeight)
+ inlineBox->setIsNonEmpty();
+ lineBox.addInlineBox(WTFMove(inlineBox));
} else if (run.isContainerStart()) {
- auto logicalLeft = lineBox.horizontalAlignmentOffset().valueOr(InlineLayoutUnit { }) + run.logicalLeft();
+ auto logicalLeft = horizontalAligmentOffset + run.logicalLeft();
auto initialLogicalWidth = lineBox.logicalWidth() - run.logicalLeft();
ASSERT(initialLogicalWidth >= 0);
- lineBox.addInlineBox(makeUnique<LineBox::InlineBox>(inlineLevelBox, logicalLeft, initialLogicalWidth));
+ lineBox.addInlineBox(LineBox::InlineBox::createBoxForInlineBox(inlineLevelBox, logicalLeft, initialLogicalWidth));
} else if (run.isContainerEnd()) {
// Adjust the logical width when the inline level container closes on this line.
auto& inlineBox = lineBox.inlineBoxForLayoutBox(inlineLevelBox);
Modified: trunk/Source/WebCore/layout/inlineformatting/InlineLineBox.cpp (267556 => 267557)
--- trunk/Source/WebCore/layout/inlineformatting/InlineLineBox.cpp 2020-09-25 03:19:50 UTC (rev 267556)
+++ trunk/Source/WebCore/layout/inlineformatting/InlineLineBox.cpp 2020-09-25 04:49:46 UTC (rev 267557)
@@ -32,13 +32,11 @@
namespace WebCore {
namespace Layout {
-LineBox::InlineBox::InlineBox(const Box& layoutBox, const InlineRect& rect, InlineLayoutUnit baseline)
+LineBox::InlineBox::InlineBox(const Box& layoutBox, InlineLayoutUnit logicalLeft, InlineLayoutSize logicalSize, InlineLayoutUnit baseline)
: m_layoutBox(makeWeakPtr(layoutBox))
- , m_logicalRect(rect)
+ , m_logicalRect({ }, logicalLeft, logicalSize.width(), logicalSize.height())
, m_baseline(baseline)
- , m_isEmpty(false)
{
- ASSERT(rect.height());
}
LineBox::InlineBox::InlineBox(const Box& layoutBox, InlineLayoutUnit logicalLeft, InlineLayoutUnit logicalWidth)
Modified: trunk/Source/WebCore/layout/inlineformatting/InlineLineBox.h (267556 => 267557)
--- trunk/Source/WebCore/layout/inlineformatting/InlineLineBox.h 2020-09-25 03:19:50 UTC (rev 267556)
+++ trunk/Source/WebCore/layout/inlineformatting/InlineLineBox.h 2020-09-25 04:49:46 UTC (rev 267557)
@@ -57,12 +57,14 @@
class LineBox {
WTF_MAKE_FAST_ALLOCATED;
public:
+ // FIXME: This name is in conflict with the actual inline box term: inline level box whose contents participate in this IFC.
+ // This class represents a rectangle on the line (initiated by an inline level box) with some additional attributes like baseline, descent etc.
struct InlineBox {
WTF_MAKE_ISO_ALLOCATED_INLINE(InlineBox);
public:
- InlineBox(const Box&, const InlineRect&, InlineLayoutUnit baseline);
- InlineBox(const Box&, InlineLayoutUnit logicalLeft, InlineLayoutUnit logicalWidth);
- InlineBox() = default;
+ static std::unique_ptr<LineBox::InlineBox> createBoxForRootInlineBox(const Box&, InlineLayoutUnit logicalLeft, InlineLayoutUnit logicalWidth);
+ static std::unique_ptr<LineBox::InlineBox> createBoxForAtomicInlineLevelBox(const Box&, InlineLayoutUnit logicalLeft, InlineLayoutSize, InlineLayoutUnit baseline);
+ static std::unique_ptr<LineBox::InlineBox> createBoxForInlineBox(const Box&, InlineLayoutUnit logicalLeft, InlineLayoutUnit logicalWidth);
const InlineRect& logicalRect() const { return m_logicalRect; }
InlineLayoutUnit logicalTop() const { return m_logicalRect.top(); }
@@ -81,6 +83,10 @@
const FontMetrics& fontMetrics() const { return layoutBox().style().fontMetrics(); }
const Box& layoutBox() const { return *m_layoutBox; }
+ InlineBox(const Box&, InlineLayoutUnit logicalLeft, InlineLayoutSize, InlineLayoutUnit baseline);
+ InlineBox(const Box&, InlineLayoutUnit logicalLeft, InlineLayoutUnit logicalWidth);
+ InlineBox() = default;
+
private:
friend class LineBoxBuilder;
@@ -91,6 +97,7 @@
void setDescent(InlineLayoutUnit descent) { m_descent = descent; }
void setLineSpacing(InlineLayoutUnit lineSpacing) { m_lineSpacing = lineSpacing; }
+ private:
WeakPtr<const Box> m_layoutBox;
InlineRect m_logicalRect;
InlineLayoutUnit m_baseline { 0 };
@@ -142,7 +149,22 @@
HashMap<const Box*, InlineBox*> m_inlineBoxRectMap;
};
+inline std::unique_ptr<LineBox::InlineBox> LineBox::InlineBox::createBoxForRootInlineBox(const Box& layoutBox, InlineLayoutUnit logicalLeft, InlineLayoutUnit logicalWidth)
+{
+ return makeUnique<LineBox::InlineBox>(layoutBox, logicalLeft, logicalWidth);
}
+
+inline std::unique_ptr<LineBox::InlineBox> LineBox::InlineBox::createBoxForAtomicInlineLevelBox(const Box& layoutBox, InlineLayoutUnit logicalLeft, InlineLayoutSize logicalSize, InlineLayoutUnit baseline)
+{
+ return makeUnique<LineBox::InlineBox>(layoutBox, logicalLeft, logicalSize, baseline);
}
+inline std::unique_ptr<LineBox::InlineBox> LineBox::InlineBox::createBoxForInlineBox(const Box& layoutBox, InlineLayoutUnit logicalLeft, InlineLayoutUnit logicalWidth)
+{
+ return makeUnique<LineBox::InlineBox>(layoutBox, logicalLeft, logicalWidth);
+}
+
+}
+}
+
#endif