Diff
Modified: trunk/Source/WebCore/ChangeLog (280017 => 280018)
--- trunk/Source/WebCore/ChangeLog 2021-07-17 05:42:32 UTC (rev 280017)
+++ trunk/Source/WebCore/ChangeLog 2021-07-17 17:27:25 UTC (rev 280018)
@@ -1,3 +1,99 @@
+2021-07-17 Alan Bujtas <[email protected]>
+
+ [LFC][IFC] Move InlineLevelBox class to its own file
+ https://bugs.webkit.org/show_bug.cgi?id=228045
+
+ Reviewed by Sam Weinig.
+
+ LineBox class has grown a lot since the subclass of InlineLevelBox has been introduced.
+ It is also in preparation for merging LineBox and LineBoxGeometry classes.
+
+ * WebCore.xcodeproj/project.pbxproj:
+ * layout/formattingContexts/inline/InlineFormattingGeometry.cpp:
+ (WebCore::Layout::LineBoxBuilder::setVerticalGeometryForInlineBox const):
+ (WebCore::Layout::LineBoxBuilder::constructAndAlignInlineLevelBoxes):
+ (WebCore::Layout::LineBoxBuilder::computeLineBoxHeightAndAlignInlineLevelBoxesVertically):
+ (WebCore::Layout::LineBoxBuilder::SimplifiedVerticalAlignment::SimplifiedVerticalAlignment):
+ (WebCore::Layout::LineBoxBuilder::SimplifiedVerticalAlignment::canUseSimplifiedAlignment):
+ (WebCore::Layout::LineBoxBuilder::SimplifiedVerticalAlignment::align):
+ (WebCore::Layout::LineBoxBuilder::SimplifiedVerticalAlignment::adjust):
+ (WebCore::Layout::InlineFormattingGeometry::inlineLevelBoxAffectsLineBox const):
+ * layout/formattingContexts/inline/InlineFormattingGeometry.h:
+ * layout/formattingContexts/inline/InlineFormattingQuirks.cpp:
+ (WebCore::Layout::InlineFormattingQuirks::inlineLevelBoxAffectsLineBox const):
+ * layout/formattingContexts/inline/InlineFormattingQuirks.h:
+ * layout/formattingContexts/inline/InlineLevelBox.h: Added.
+ (WebCore::Layout::InlineLevelBox::baseline const):
+ (WebCore::Layout::InlineLevelBox::descent const):
+ (WebCore::Layout::InlineLevelBox::LayoutBounds::height const):
+ (WebCore::Layout::InlineLevelBox::LayoutBounds::operator== const):
+ (WebCore::Layout::InlineLevelBox::layoutBounds const):
+ (WebCore::Layout::InlineLevelBox::hasContent const):
+ (WebCore::Layout::InlineLevelBox::verticalAlign const):
+ (WebCore::Layout::InlineLevelBox::layoutBox const):
+ (WebCore::Layout::InlineLevelBox::style const):
+ (WebCore::Layout::InlineLevelBox::isInlineBox const):
+ (WebCore::Layout::InlineLevelBox::isRootInlineBox const):
+ (WebCore::Layout::InlineLevelBox::isAtomicInlineLevelBox const):
+ (WebCore::Layout::InlineLevelBox::isLineBreakBox const):
+ (WebCore::Layout::InlineLevelBox::type const):
+ (WebCore::Layout::InlineLevelBox::logicalRect const):
+ (WebCore::Layout::InlineLevelBox::logicalTop const):
+ (WebCore::Layout::InlineLevelBox::logicalBottom const):
+ (WebCore::Layout::InlineLevelBox::logicalLeft const):
+ (WebCore::Layout::InlineLevelBox::logicalWidth const):
+ (WebCore::Layout::InlineLevelBox::logicalHeight const):
+ (WebCore::Layout::InlineLevelBox::setLogicalWidth):
+ (WebCore::Layout::InlineLevelBox::setLogicalHeight):
+ (WebCore::Layout::InlineLevelBox::setLogicalTop):
+ (WebCore::Layout::InlineLevelBox::setBaseline):
+ (WebCore::Layout::InlineLevelBox::setDescent):
+ (WebCore::Layout::InlineLevelBox::setLayoutBounds):
+ (WebCore::Layout::InlineLevelBox::InlineLevelBox):
+ (WebCore::Layout::m_type):
+ (WebCore::Layout::InlineLevelBox::setHasContent):
+ (WebCore::Layout::InlineLevelBox::hasLineBoxRelativeAlignment const):
+ (WebCore::Layout::InlineLevelBox::createAtomicInlineLevelBox):
+ (WebCore::Layout::InlineLevelBox::createInlineBox):
+ (WebCore::Layout::InlineLevelBox::createLineBreakBox):
+ (WebCore::Layout::InlineLevelBox::createGenericInlineLevelBox):
+ * layout/formattingContexts/inline/InlineLineBox.cpp:
+ (WebCore::Layout::LineBox::InlineLevelBox::InlineLevelBox): Deleted.
+ (WebCore::Layout::m_type): Deleted.
+ (WebCore::Layout::LineBox::InlineLevelBox::setBaseline): Deleted.
+ (WebCore::Layout::LineBox::InlineLevelBox::setDescent): Deleted.
+ (WebCore::Layout::LineBox::InlineLevelBox::setLayoutBounds): Deleted.
+ (WebCore::Layout::LineBox::InlineLevelBox::setLogicalTop): Deleted.
+ (WebCore::Layout::LineBox::InlineLevelBox::setLogicalHeight): Deleted.
+ (WebCore::Layout::LineBox::InlineLevelBox::setHasContent): Deleted.
+ (WebCore::Layout::LineBox::InlineLevelBox::hasLineBoxRelativeAlignment const): Deleted.
+ * layout/formattingContexts/inline/InlineLineBox.h:
+ (WebCore::Layout::LineBox::InlineLevelBox::baseline const): Deleted.
+ (WebCore::Layout::LineBox::InlineLevelBox::descent const): Deleted.
+ (WebCore::Layout::LineBox::InlineLevelBox::LayoutBounds::height const): Deleted.
+ (WebCore::Layout::LineBox::InlineLevelBox::LayoutBounds::operator== const): Deleted.
+ (WebCore::Layout::LineBox::InlineLevelBox::layoutBounds const): Deleted.
+ (WebCore::Layout::LineBox::InlineLevelBox::hasContent const): Deleted.
+ (WebCore::Layout::LineBox::InlineLevelBox::verticalAlign const): Deleted.
+ (WebCore::Layout::LineBox::InlineLevelBox::layoutBox const): Deleted.
+ (WebCore::Layout::LineBox::InlineLevelBox::style const): Deleted.
+ (WebCore::Layout::LineBox::InlineLevelBox::isInlineBox const): Deleted.
+ (WebCore::Layout::LineBox::InlineLevelBox::isRootInlineBox const): Deleted.
+ (WebCore::Layout::LineBox::InlineLevelBox::isAtomicInlineLevelBox const): Deleted.
+ (WebCore::Layout::LineBox::InlineLevelBox::isLineBreakBox const): Deleted.
+ (WebCore::Layout::LineBox::InlineLevelBox::type const): Deleted.
+ (WebCore::Layout::LineBox::InlineLevelBox::logicalRect const): Deleted.
+ (WebCore::Layout::LineBox::InlineLevelBox::logicalTop const): Deleted.
+ (WebCore::Layout::LineBox::InlineLevelBox::logicalBottom const): Deleted.
+ (WebCore::Layout::LineBox::InlineLevelBox::logicalLeft const): Deleted.
+ (WebCore::Layout::LineBox::InlineLevelBox::logicalWidth const): Deleted.
+ (WebCore::Layout::LineBox::InlineLevelBox::logicalHeight const): Deleted.
+ (WebCore::Layout::LineBox::InlineLevelBox::setLogicalWidth): Deleted.
+ (WebCore::Layout::LineBox::InlineLevelBox::createAtomicInlineLevelBox): Deleted.
+ (WebCore::Layout::LineBox::InlineLevelBox::createInlineBox): Deleted.
+ (WebCore::Layout::LineBox::InlineLevelBox::createLineBreakBox): Deleted.
+ (WebCore::Layout::LineBox::InlineLevelBox::createGenericInlineLevelBox): Deleted.
+
2021-07-16 Simon Fraser <[email protected]>
getBoundingClientRect() returns the incorrect rectangle on elements whose parent element is set -webkit-column-count
Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (280017 => 280018)
--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2021-07-17 05:42:32 UTC (rev 280017)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2021-07-17 17:27:25 UTC (rev 280018)
@@ -2167,6 +2167,7 @@
6F995A381A70833700A735F4 /* JSWebGLTransformFeedback.h in Headers */ = {isa = PBXBuildFile; fileRef = 6F995A2E1A70833700A735F4 /* JSWebGLTransformFeedback.h */; };
6F995A3A1A70833700A735F4 /* JSWebGLVertexArrayObject.h in Headers */ = {isa = PBXBuildFile; fileRef = 6F995A301A70833700A735F4 /* JSWebGLVertexArrayObject.h */; };
6FA4454E898F2FC168BC38C1 /* JSBeforeUnloadEvent.h in Headers */ = {isa = PBXBuildFile; fileRef = 29E04A27BED2F81F98E9022B /* JSBeforeUnloadEvent.h */; };
+ 6FAAE71326A2814B00E07502 /* InlineLevelBox.h in Headers */ = {isa = PBXBuildFile; fileRef = 6FAAE71126A2814A00E07502 /* InlineLevelBox.h */; settings = {ATTRIBUTES = (Private, ); }; };
6FB11B5C21783FD000E2A574 /* TextUtil.h in Headers */ = {isa = PBXBuildFile; fileRef = 6FB11B5921783FCF00E2A574 /* TextUtil.h */; settings = {ATTRIBUTES = (Private, ); }; };
6FB2400523DFF12800796458 /* InlineLineBox.h in Headers */ = {isa = PBXBuildFile; fileRef = 6FB2400323DFF12700796458 /* InlineLineBox.h */; settings = {ATTRIBUTES = (Private, ); }; };
6FB47E632277425A00C7BCB0 /* LayoutIntegrationLine.h in Headers */ = {isa = PBXBuildFile; fileRef = 6FB47E612277425A00C7BCB0 /* LayoutIntegrationLine.h */; settings = {ATTRIBUTES = (Private, ); }; };
@@ -10072,6 +10073,7 @@
6F995A2E1A70833700A735F4 /* JSWebGLTransformFeedback.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSWebGLTransformFeedback.h; sourceTree = "<group>"; };
6F995A2F1A70833700A735F4 /* JSWebGLVertexArrayObject.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSWebGLVertexArrayObject.cpp; sourceTree = "<group>"; };
6F995A301A70833700A735F4 /* JSWebGLVertexArrayObject.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSWebGLVertexArrayObject.h; sourceTree = "<group>"; };
+ 6FAAE71126A2814A00E07502 /* InlineLevelBox.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = InlineLevelBox.h; sourceTree = "<group>"; };
6FAE16BA2406DE7E00A48414 /* PrecomputedBlockMarginCollapse.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = PrecomputedBlockMarginCollapse.cpp; sourceTree = "<group>"; };
6FB0ED112427B6C6002737E6 /* LayoutInitialContainingBlock.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = LayoutInitialContainingBlock.cpp; sourceTree = "<group>"; };
6FB11B5921783FCF00E2A574 /* TextUtil.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TextUtil.h; sourceTree = "<group>"; };
@@ -18399,6 +18401,7 @@
115CFA7C208B8E10001E6991 /* InlineFormattingState.h */,
6F7B8CEC23626E6600C9FF15 /* InlineItem.cpp */,
6FE7CFA02177EEF1005B1573 /* InlineItem.h */,
+ 6FAAE71126A2814A00E07502 /* InlineLevelBox.h */,
6F0CD692229ED31900C5994E /* InlineLine.cpp */,
6F0CD694229ED32700C5994E /* InlineLine.h */,
6F69A79924D6FAB800E6B85D /* InlineLineBox.cpp */,
@@ -33206,6 +33209,7 @@
115CFA7E208B8E10001E6991 /* InlineFormattingState.h in Headers */,
6FE7CFA22177EEF2005B1573 /* InlineItem.h in Headers */,
BCE789161120D6080060ECE5 /* InlineIterator.h in Headers */,
+ 6FAAE71326A2814B00E07502 /* InlineLevelBox.h in Headers */,
6F0CD695229ED32700C5994E /* InlineLine.h in Headers */,
6FB2400523DFF12800796458 /* InlineLineBox.h in Headers */,
6F26EB48234004A5006906E2 /* InlineLineBuilder.h in Headers */,
Modified: trunk/Source/WebCore/layout/formattingContexts/inline/InlineFormattingGeometry.cpp (280017 => 280018)
--- trunk/Source/WebCore/layout/formattingContexts/inline/InlineFormattingGeometry.cpp 2021-07-17 05:42:32 UTC (rev 280017)
+++ trunk/Source/WebCore/layout/formattingContexts/inline/InlineFormattingGeometry.cpp 2021-07-17 17:27:25 UTC (rev 280018)
@@ -47,11 +47,11 @@
private:
struct SimplifiedVerticalAlignment {
- SimplifiedVerticalAlignment(const LineBox::InlineLevelBox& rootInlineBox);
+ SimplifiedVerticalAlignment(const InlineLevelBox& rootInlineBox);
- static bool canUseSimplifiedAlignment(const LineBox::InlineLevelBox& rootInlineBox, const LineBox::InlineLevelBox&, std::optional<const BoxGeometry> inlineLevelBoxGeometry);
+ static bool canUseSimplifiedAlignment(const InlineLevelBox& rootInlineBox, const InlineLevelBox&, std::optional<const BoxGeometry> inlineLevelBoxGeometry);
- void align(LineBox::InlineLevelBox&);
+ void align(InlineLevelBox&);
InlineLayoutUnit rootInlineBoxLogicalTop() const { return m_rootInlineBoxLogicalTop; }
InlineLayoutUnit lineBoxHeight() const { return m_lineBoxLogicalBottom - m_lineBoxLogicalTop; }
@@ -60,9 +60,9 @@
bool isEnabled() const { return m_isEnabled; }
private:
- void adjust(const LineBox::InlineLevelBox&);
+ void adjust(const InlineLevelBox&);
- const LineBox::InlineLevelBox& m_rootInlineBox;
+ const InlineLevelBox& m_rootInlineBox;
bool m_isEnabled { true };
InlineLayoutUnit m_lineBoxLogicalTop { 0 };
InlineLayoutUnit m_lineBoxLogicalBottom { 0 };
@@ -69,7 +69,7 @@
InlineLayoutUnit m_rootInlineBoxLogicalTop { 0 };
};
- void setVerticalGeometryForInlineBox(LineBox::InlineLevelBox&) const;
+ void setVerticalGeometryForInlineBox(InlineLevelBox&) const;
void constructAndAlignInlineLevelBoxes(LineBox&, const Line::RunList&);
void computeLineBoxHeightAndAlignInlineLevelBoxesVertically(LineBox&);
@@ -167,7 +167,7 @@
return lineBox;
}
-void LineBoxBuilder::setVerticalGeometryForInlineBox(LineBox::InlineLevelBox& inlineLevelBox) const
+void LineBoxBuilder::setVerticalGeometryForInlineBox(InlineLevelBox& inlineLevelBox) const
{
ASSERT(inlineLevelBox.isInlineBox() || inlineLevelBox.isLineBreakBox());
auto& fontMetrics = inlineLevelBox.style().fontMetrics();
@@ -198,7 +198,7 @@
descent += halfLeading;
}
// We need floor/ceil to match legacy layout integral positioning.
- inlineLevelBox.setLayoutBounds(LineBox::InlineLevelBox::LayoutBounds { floorf(ascent), ceil(descent) });
+ inlineLevelBox.setLayoutBounds(InlineLevelBox::LayoutBounds { floorf(ascent), ceil(descent) });
}
void LineBoxBuilder::constructAndAlignInlineLevelBoxes(LineBox& lineBox, const Line::RunList& runs)
@@ -225,8 +225,8 @@
return;
// An inline box may not necessarily start on the current line:
// <span id=outer>line break<br>this content's parent inline box('outer') <span id=inner>starts on the previous line</span></span>
- // We need to make sure that there's an LineBox::InlineLevelBox for every inline box that's present on the current line.
- // In nesting case we need to create LineBox::InlineLevelBoxes for the inline box ancestors.
+ // We need to make sure that there's an InlineLevelBox for every inline box that's present on the current line.
+ // In nesting case we need to create InlineLevelBoxes for the inline box ancestors.
// We only have to do it on the first run as any subsequent inline content is either at the same/higher nesting level or
// nested with a [inline box start] run.
auto& firstRun = runs[0];
@@ -249,7 +249,7 @@
}
// Construct the missing LineBox::InlineBoxes starting with the topmost layout box.
for (auto* layoutBox : WTF::makeReversedRange(layoutBoxesWithoutInlineBoxes)) {
- auto inlineBox = LineBox::InlineLevelBox::createInlineBox(*layoutBox, rootInlineBox.logicalLeft(), lineBox.contentLogicalWidth());
+ auto inlineBox = InlineLevelBox::createInlineBox(*layoutBox, rootInlineBox.logicalLeft(), lineBox.contentLogicalWidth());
setVerticalGeometryForInlineBox(inlineBox);
simplifiedAlignVerticallyIfApplicable(inlineBox, { });
lineBox.addInlineLevelBox(WTFMove(inlineBox));
@@ -302,9 +302,9 @@
else
ascent = marginBoxHeight;
logicalLeft += std::max(0_lu, inlineLevelBoxGeometry.marginStart());
- auto atomicInlineLevelBox = LineBox::InlineLevelBox::createAtomicInlineLevelBox(layoutBox, logicalLeft, { inlineLevelBoxGeometry.borderBoxWidth(), marginBoxHeight });
+ auto atomicInlineLevelBox = InlineLevelBox::createAtomicInlineLevelBox(layoutBox, logicalLeft, { inlineLevelBoxGeometry.borderBoxWidth(), marginBoxHeight });
atomicInlineLevelBox.setBaseline(ascent);
- atomicInlineLevelBox.setLayoutBounds(LineBox::InlineLevelBox::LayoutBounds { ascent, marginBoxHeight - ascent });
+ atomicInlineLevelBox.setLayoutBounds(InlineLevelBox::LayoutBounds { ascent, marginBoxHeight - ascent });
simplifiedAlignVerticallyIfApplicable(atomicInlineLevelBox, inlineLevelBoxGeometry);
lineBox.addInlineLevelBox(WTFMove(atomicInlineLevelBox));
continue;
@@ -318,7 +318,7 @@
auto marginStart = std::max(0_lu, formattingContext().geometryForBox(layoutBox).marginStart());
logicalLeft += marginStart;
initialLogicalWidth -= marginStart;
- auto inlineBox = LineBox::InlineLevelBox::createInlineBox(layoutBox, logicalLeft, initialLogicalWidth);
+ auto inlineBox = InlineLevelBox::createInlineBox(layoutBox, logicalLeft, initialLogicalWidth);
setVerticalGeometryForInlineBox(inlineBox);
simplifiedAlignVerticallyIfApplicable(inlineBox, { });
lineBox.addInlineLevelBox(WTFMove(inlineBox));
@@ -341,7 +341,7 @@
continue;
}
if (run.isHardLineBreak()) {
- auto lineBreakBox = LineBox::InlineLevelBox::createLineBreakBox(layoutBox, logicalLeft);
+ auto lineBreakBox = InlineLevelBox::createLineBreakBox(layoutBox, logicalLeft);
setVerticalGeometryForInlineBox(lineBreakBox);
simplifiedAlignVerticallyIfApplicable(lineBreakBox, { });
lineBox.addInlineLevelBox(WTFMove(lineBreakBox));
@@ -348,7 +348,7 @@
continue;
}
if (run.isWordBreakOpportunity()) {
- lineBox.addInlineLevelBox(LineBox::InlineLevelBox::createGenericInlineLevelBox(layoutBox, logicalLeft));
+ lineBox.addInlineLevelBox(InlineLevelBox::createGenericInlineLevelBox(layoutBox, logicalLeft));
continue;
}
ASSERT_NOT_REACHED();
@@ -381,7 +381,7 @@
InlineLayoutUnit top { 0 };
InlineLayoutUnit bottom { 0 };
};
- HashMap<const LineBox::InlineLevelBox*, AbsoluteTopAndBottom> inlineLevelBoxAbsoluteTopAndBottomMap;
+ HashMap<const InlineLevelBox*, AbsoluteTopAndBottom> inlineLevelBoxAbsoluteTopAndBottomMap;
auto minimumLogicalTop = std::optional<InlineLayoutUnit> { };
auto maximumLogicalBottom = std::optional<InlineLayoutUnit> { };
@@ -392,7 +392,7 @@
} else
inlineLevelBoxAbsoluteTopAndBottomMap.add(&rootInlineBox, AbsoluteTopAndBottom { });
- Vector<LineBox::InlineLevelBox*> lineBoxRelativeInlineLevelBoxes;
+ Vector<InlineLevelBox*> lineBoxRelativeInlineLevelBoxes;
for (auto& inlineLevelBox : lineBox.nonRootInlineLevelBoxes()) {
auto& layoutBox = inlineLevelBox.layoutBox();
if (inlineLevelBox.hasLineBoxRelativeAlignment()) {
@@ -466,7 +466,7 @@
computeLineBoxLogicalHeight();
auto computeRootInlineBoxVerticalPosition = [&] {
- HashMap<const LineBox::InlineLevelBox*, InlineLayoutUnit> inlineLevelBoxAbsoluteBaselineOffsetMap;
+ HashMap<const InlineLevelBox*, InlineLayoutUnit> inlineLevelBoxAbsoluteBaselineOffsetMap;
inlineLevelBoxAbsoluteBaselineOffsetMap.add(&rootInlineBox, InlineLayoutUnit { });
auto maximumTopOffsetFromRootInlineBoxBaseline = std::optional<InlineLayoutUnit> { };
@@ -598,13 +598,13 @@
alignInlineLevelBoxes();
}
-LineBoxBuilder::SimplifiedVerticalAlignment::SimplifiedVerticalAlignment(const LineBox::InlineLevelBox& rootInlineBox)
+LineBoxBuilder::SimplifiedVerticalAlignment::SimplifiedVerticalAlignment(const InlineLevelBox& rootInlineBox)
: m_rootInlineBox(rootInlineBox)
{
adjust(rootInlineBox);
}
-bool LineBoxBuilder::SimplifiedVerticalAlignment::canUseSimplifiedAlignment(const LineBox::InlineLevelBox& rootInlineBox, const LineBox::InlineLevelBox& inlineLevelBox, std::optional<const BoxGeometry> inlineLevelBoxGeometry)
+bool LineBoxBuilder::SimplifiedVerticalAlignment::canUseSimplifiedAlignment(const InlineLevelBox& rootInlineBox, const InlineLevelBox& inlineLevelBox, std::optional<const BoxGeometry> inlineLevelBoxGeometry)
{
if (inlineLevelBox.isAtomicInlineLevelBox()) {
ASSERT(inlineLevelBoxGeometry);
@@ -627,7 +627,7 @@
return false;
}
-void LineBoxBuilder::SimplifiedVerticalAlignment::align(LineBox::InlineLevelBox& inlineLevelBox)
+void LineBoxBuilder::SimplifiedVerticalAlignment::align(InlineLevelBox& inlineLevelBox)
{
if (inlineLevelBox.isAtomicInlineLevelBox() || inlineLevelBox.isLineBreakBox() || inlineLevelBox.isInlineBox()) {
// Only baseline alignment for now.
@@ -638,7 +638,7 @@
ASSERT_NOT_IMPLEMENTED_YET();
}
-void LineBoxBuilder::SimplifiedVerticalAlignment::adjust(const LineBox::InlineLevelBox& inlineLevelBox)
+void LineBoxBuilder::SimplifiedVerticalAlignment::adjust(const InlineLevelBox& inlineLevelBox)
{
auto layoutBoundsLogicalTop = m_rootInlineBox.layoutBounds().ascent - inlineLevelBox.layoutBounds().ascent;
m_lineBoxLogicalTop = std::min(m_lineBoxLogicalTop, layoutBoundsLogicalTop);
@@ -709,7 +709,7 @@
return complicatedCases(layoutBox, horizontalConstraints, overriddenVerticalValues);
}
-bool InlineFormattingGeometry::inlineLevelBoxAffectsLineBox(const LineBox::InlineLevelBox& inlineLevelBox, const LineBox& lineBox) const
+bool InlineFormattingGeometry::inlineLevelBoxAffectsLineBox(const InlineLevelBox& inlineLevelBox, const LineBox& lineBox) const
{
if (inlineLevelBox.isInlineBox() || inlineLevelBox.isLineBreakBox())
return layoutState().inStandardsMode() ? true : formattingContext().formattingQuirks().inlineLevelBoxAffectsLineBox(inlineLevelBox, lineBox);
Modified: trunk/Source/WebCore/layout/formattingContexts/inline/InlineFormattingGeometry.h (280017 => 280018)
--- trunk/Source/WebCore/layout/formattingContexts/inline/InlineFormattingGeometry.h 2021-07-17 05:42:32 UTC (rev 280017)
+++ trunk/Source/WebCore/layout/formattingContexts/inline/InlineFormattingGeometry.h 2021-07-17 17:27:25 UTC (rev 280018)
@@ -46,7 +46,7 @@
ContentHeightAndMargin inlineBlockContentHeightAndMargin(const Box&, const HorizontalConstraints&, const OverriddenVerticalValues&) const;
ContentWidthAndMargin inlineBlockContentWidthAndMargin(const Box&, const HorizontalConstraints&, const OverriddenHorizontalValues&) const;
- bool inlineLevelBoxAffectsLineBox(const LineBox::InlineLevelBox&, const LineBox&) const;
+ bool inlineLevelBoxAffectsLineBox(const InlineLevelBox&, const LineBox&) const;
private:
const InlineFormattingContext& formattingContext() const { return downcast<InlineFormattingContext>(FormattingGeometry::formattingContext()); }
Modified: trunk/Source/WebCore/layout/formattingContexts/inline/InlineFormattingQuirks.cpp (280017 => 280018)
--- trunk/Source/WebCore/layout/formattingContexts/inline/InlineFormattingQuirks.cpp 2021-07-17 05:42:32 UTC (rev 280017)
+++ trunk/Source/WebCore/layout/formattingContexts/inline/InlineFormattingQuirks.cpp 2021-07-17 17:27:25 UTC (rev 280018)
@@ -47,7 +47,7 @@
return rootStyle.lineHeight().isNegative() ? rootStyle.fontMetrics().floatHeight() : rootStyle.computedLineHeight();
}
-bool InlineFormattingQuirks::inlineLevelBoxAffectsLineBox(const LineBox::InlineLevelBox& inlineLevelBox, const LineBox& lineBox) const
+bool InlineFormattingQuirks::inlineLevelBoxAffectsLineBox(const InlineLevelBox& inlineLevelBox, const LineBox& lineBox) const
{
ASSERT(!layoutState().inStandardsMode());
if (inlineLevelBox.isLineBreakBox()) {
Modified: trunk/Source/WebCore/layout/formattingContexts/inline/InlineFormattingQuirks.h (280017 => 280018)
--- trunk/Source/WebCore/layout/formattingContexts/inline/InlineFormattingQuirks.h 2021-07-17 05:42:32 UTC (rev 280017)
+++ trunk/Source/WebCore/layout/formattingContexts/inline/InlineFormattingQuirks.h 2021-07-17 17:27:25 UTC (rev 280018)
@@ -41,7 +41,7 @@
InlineLayoutUnit initialLineHeight() const;
bool hasSoftWrapOpportunityAtImage() const;
- bool inlineLevelBoxAffectsLineBox(const LineBox::InlineLevelBox&, const LineBox&) const;
+ bool inlineLevelBoxAffectsLineBox(const InlineLevelBox&, const LineBox&) const;
};
}
Added: trunk/Source/WebCore/layout/formattingContexts/inline/InlineLevelBox.h (0 => 280018)
--- trunk/Source/WebCore/layout/formattingContexts/inline/InlineLevelBox.h (rev 0)
+++ trunk/Source/WebCore/layout/formattingContexts/inline/InlineLevelBox.h 2021-07-17 17:27:25 UTC (rev 280018)
@@ -0,0 +1,159 @@
+/*
+ * Copyright (C) 2021 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+#if ENABLE(LAYOUT_FORMATTING_CONTEXT)
+
+#include "InlineRect.h"
+#include "LayoutBox.h"
+#include "LayoutUnits.h"
+#include <wtf/WeakPtr.h>
+
+namespace WebCore {
+namespace Layout {
+
+class LineBox;
+class LineBoxBuilder;
+struct SimplifiedVerticalAlignment;
+
+class InlineLevelBox {
+public:
+ static InlineLevelBox createInlineBox(const Box&, InlineLayoutUnit logicalLeft, InlineLayoutUnit logicalWidth);
+ static InlineLevelBox createAtomicInlineLevelBox(const Box&, InlineLayoutUnit logicalLeft, InlineLayoutSize);
+ static InlineLevelBox createLineBreakBox(const Box&, InlineLayoutUnit logicalLeft);
+ static InlineLevelBox createGenericInlineLevelBox(const Box&, InlineLayoutUnit logicalLeft);
+
+ InlineLayoutUnit baseline() const { return m_baseline; }
+ std::optional<InlineLayoutUnit> descent() const { return m_descent; }
+ // See https://www.w3.org/TR/css-inline-3/#layout-bounds
+ struct LayoutBounds {
+ InlineLayoutUnit height() const { return ascent + descent; }
+ bool operator==(const LayoutBounds& other) const { return ascent == other.ascent && descent == other.descent; }
+
+ InlineLayoutUnit ascent { 0 };
+ InlineLayoutUnit descent { 0 };
+ };
+ LayoutBounds layoutBounds() const { return m_layoutBounds; }
+
+ bool hasContent() const { return m_hasContent; }
+ void setHasContent();
+
+ VerticalAlign verticalAlign() const { return layoutBox().style().verticalAlign(); }
+ const Box& layoutBox() const { return *m_layoutBox; }
+ const RenderStyle& style() const { return m_layoutBox->style(); }
+
+ bool isInlineBox() const { return m_type == Type::InlineBox || m_type == Type::RootInlineBox; }
+ bool isRootInlineBox() const { return m_type == Type::RootInlineBox; }
+ bool isAtomicInlineLevelBox() const { return m_type == Type::AtomicInlineLevelBox; }
+ bool isLineBreakBox() const { return m_type == Type::LineBreakBox; }
+ bool hasLineBoxRelativeAlignment() const;
+
+ enum class Type : uint8_t {
+ InlineBox = 1 << 0,
+ RootInlineBox = 1 << 1,
+ AtomicInlineLevelBox = 1 << 2,
+ LineBreakBox = 1 << 3,
+ GenericInlineLevelBox = 1 << 4
+ };
+ Type type() const { return m_type; }
+
+ InlineLevelBox(const Box&, InlineLayoutUnit logicalLeft, InlineLayoutSize, Type);
+ InlineLevelBox() = default;
+
+private:
+ friend struct SimplifiedVerticalAlignment;
+ friend class LineBoxBuilder;
+ friend class LineBox;
+
+ const InlineRect& logicalRect() const { return m_logicalRect; }
+ InlineLayoutUnit logicalTop() const { return m_logicalRect.top(); }
+ InlineLayoutUnit logicalBottom() const { return m_logicalRect.bottom(); }
+ InlineLayoutUnit logicalLeft() const { return m_logicalRect.left(); }
+ InlineLayoutUnit logicalWidth() const { return m_logicalRect.width(); }
+ InlineLayoutUnit logicalHeight() const { return m_logicalRect.height(); }
+
+ // FIXME: Remove legacy rounding.
+ void setLogicalWidth(InlineLayoutUnit logicalWidth) { m_logicalRect.setWidth(logicalWidth); }
+ void setLogicalHeight(InlineLayoutUnit logicalHeight) { m_logicalRect.setHeight(roundToInt(logicalHeight)); }
+ void setLogicalTop(InlineLayoutUnit logicalTop) { m_logicalRect.setTop(roundToInt(logicalTop)); }
+ void setBaseline(InlineLayoutUnit baseline) { m_baseline = roundToInt(baseline); }
+ void setDescent(InlineLayoutUnit descent) { m_descent = roundToInt(descent); }
+ void setLayoutBounds(const LayoutBounds& layoutBounds) { m_layoutBounds = { InlineLayoutUnit(roundToInt(layoutBounds.ascent)), InlineLayoutUnit(roundToInt(layoutBounds.descent)) }; }
+
+private:
+ WeakPtr<const Box> m_layoutBox;
+ // This is the combination of margin and border boxes. Inline level boxes are vertically aligned using their margin boxes.
+ InlineRect m_logicalRect;
+ LayoutBounds m_layoutBounds;
+ InlineLayoutUnit m_baseline { 0 };
+ std::optional<InlineLayoutUnit> m_descent;
+ bool m_hasContent { false };
+ Type m_type { Type::InlineBox };
+};
+
+inline InlineLevelBox::InlineLevelBox(const Box& layoutBox, InlineLayoutUnit logicalLeft, InlineLayoutSize logicalSize, Type type)
+ : m_layoutBox(makeWeakPtr(layoutBox))
+ , m_logicalRect({ }, logicalLeft, logicalSize.width(), logicalSize.height())
+ , m_type(type)
+{
+}
+
+inline void InlineLevelBox::setHasContent()
+{
+ ASSERT(isInlineBox());
+ m_hasContent = true;
+}
+
+inline bool InlineLevelBox::hasLineBoxRelativeAlignment() const
+{
+ auto verticalAlignment = layoutBox().style().verticalAlign();
+ return verticalAlignment == VerticalAlign::Top || verticalAlignment == VerticalAlign::Bottom;
+}
+
+inline InlineLevelBox InlineLevelBox::createAtomicInlineLevelBox(const Box& layoutBox, InlineLayoutUnit logicalLeft, InlineLayoutSize logicalSize)
+{
+ return InlineLevelBox { layoutBox, logicalLeft, logicalSize, Type::AtomicInlineLevelBox };
+}
+
+inline InlineLevelBox InlineLevelBox::createInlineBox(const Box& layoutBox, InlineLayoutUnit logicalLeft, InlineLayoutUnit logicalWidth)
+{
+ return InlineLevelBox { layoutBox, logicalLeft, InlineLayoutSize { logicalWidth, { } }, Type::InlineBox };
+}
+
+inline InlineLevelBox InlineLevelBox::createLineBreakBox(const Box& layoutBox, InlineLayoutUnit logicalLeft)
+{
+ return InlineLevelBox { layoutBox, logicalLeft, InlineLayoutSize { }, Type::LineBreakBox };
+}
+
+inline InlineLevelBox InlineLevelBox::createGenericInlineLevelBox(const Box& layoutBox, InlineLayoutUnit logicalLeft)
+{
+ return InlineLevelBox { layoutBox, logicalLeft, InlineLayoutSize { }, Type::GenericInlineLevelBox };
+}
+
+}
+}
+
+#endif
Modified: trunk/Source/WebCore/layout/formattingContexts/inline/InlineLineBox.cpp (280017 => 280018)
--- trunk/Source/WebCore/layout/formattingContexts/inline/InlineLineBox.cpp 2021-07-17 05:42:32 UTC (rev 280017)
+++ trunk/Source/WebCore/layout/formattingContexts/inline/InlineLineBox.cpp 2021-07-17 17:27:25 UTC (rev 280018)
@@ -34,55 +34,6 @@
namespace WebCore {
namespace Layout {
-LineBox::InlineLevelBox::InlineLevelBox(const Box& layoutBox, InlineLayoutUnit logicalLeft, InlineLayoutSize logicalSize, Type type)
- : m_layoutBox(makeWeakPtr(layoutBox))
- , m_logicalRect({ }, logicalLeft, logicalSize.width(), logicalSize.height())
- , m_type(type)
-{
-}
-
-void LineBox::InlineLevelBox::setBaseline(InlineLayoutUnit baseline)
-{
- // FIXME: Remove legacy rounding.
- m_baseline = roundToInt(baseline);
-}
-
-void LineBox::InlineLevelBox::setDescent(InlineLayoutUnit descent)
-{
- // FIXME: Remove legacy rounding.
- m_descent = roundToInt(descent);
-}
-
-void LineBox::InlineLevelBox::setLayoutBounds(const LayoutBounds& layoutBounds)
-{
- // FIXME: Remove legacy rounding.
- m_layoutBounds = { InlineLayoutUnit(roundToInt(layoutBounds.ascent)), InlineLayoutUnit(roundToInt(layoutBounds.descent)) };
-}
-
-void LineBox::InlineLevelBox::setLogicalTop(InlineLayoutUnit logicalTop)
-{
- // FIXME: Remove legacy rounding.
- m_logicalRect.setTop(roundToInt(logicalTop));
-}
-
-void LineBox::InlineLevelBox::setLogicalHeight(InlineLayoutUnit logicalHeight)
-{
- // FIXME: Remove legacy rounding.
- m_logicalRect.setHeight(roundToInt(logicalHeight));
-}
-
-void LineBox::InlineLevelBox::setHasContent()
-{
- ASSERT(isInlineBox());
- m_hasContent = true;
-}
-
-bool LineBox::InlineLevelBox::hasLineBoxRelativeAlignment() const
-{
- auto verticalAlignment = layoutBox().style().verticalAlign();
- return verticalAlignment == VerticalAlign::Top || verticalAlignment == VerticalAlign::Bottom;
-}
-
LineBox::LineBox(const Box& rootLayoutBox, const InlineLayoutPoint& logicalTopleft, InlineLayoutUnit lineLogicalWidth, InlineLayoutUnit contentLogicalLeft, InlineLayoutUnit contentLogicalWidth, size_t nonSpanningInlineLevelBoxCount)
: m_logicalRect(logicalTopleft, InlineLayoutSize { lineLogicalWidth, { } })
, m_contentLogicalWidth(contentLogicalWidth)
Modified: trunk/Source/WebCore/layout/formattingContexts/inline/InlineLineBox.h (280017 => 280018)
--- trunk/Source/WebCore/layout/formattingContexts/inline/InlineLineBox.h 2021-07-17 05:42:32 UTC (rev 280017)
+++ trunk/Source/WebCore/layout/formattingContexts/inline/InlineLineBox.h 2021-07-17 17:27:25 UTC (rev 280018)
@@ -27,6 +27,7 @@
#if ENABLE(LAYOUT_FORMATTING_CONTEXT)
+#include "InlineLevelBox.h"
#include "InlineLine.h"
#include "InlineRect.h"
#include <wtf/IsoMallocInlines.h>
@@ -59,80 +60,6 @@
class LineBox {
WTF_MAKE_FAST_ALLOCATED;
public:
- struct InlineLevelBox {
- public:
- static LineBox::InlineLevelBox createInlineBox(const Box&, InlineLayoutUnit logicalLeft, InlineLayoutUnit logicalWidth);
- static LineBox::InlineLevelBox createAtomicInlineLevelBox(const Box&, InlineLayoutUnit logicalLeft, InlineLayoutSize);
- static LineBox::InlineLevelBox createLineBreakBox(const Box&, InlineLayoutUnit logicalLeft);
- static LineBox::InlineLevelBox createGenericInlineLevelBox(const Box&, InlineLayoutUnit logicalLeft);
-
- InlineLayoutUnit baseline() const { return m_baseline; }
- std::optional<InlineLayoutUnit> descent() const { return m_descent; }
- // See https://www.w3.org/TR/css-inline-3/#layout-bounds
- struct LayoutBounds {
- InlineLayoutUnit height() const { return ascent + descent; }
- bool operator==(const LayoutBounds& other) const { return ascent == other.ascent && descent == other.descent; }
-
- InlineLayoutUnit ascent { 0 };
- InlineLayoutUnit descent { 0 };
- };
- LayoutBounds layoutBounds() const { return m_layoutBounds; }
-
- bool hasContent() const { return m_hasContent; }
- void setHasContent();
-
- VerticalAlign verticalAlign() const { return layoutBox().style().verticalAlign(); }
- const Box& layoutBox() const { return *m_layoutBox; }
- const RenderStyle& style() const { return m_layoutBox->style(); }
-
- bool isInlineBox() const { return m_type == Type::InlineBox || m_type == Type::RootInlineBox; }
- bool isRootInlineBox() const { return m_type == Type::RootInlineBox; }
- bool isAtomicInlineLevelBox() const { return m_type == Type::AtomicInlineLevelBox; }
- bool isLineBreakBox() const { return m_type == Type::LineBreakBox; }
- bool hasLineBoxRelativeAlignment() const;
-
- enum class Type : uint8_t {
- InlineBox = 1 << 0,
- RootInlineBox = 1 << 1,
- AtomicInlineLevelBox = 1 << 2,
- LineBreakBox = 1 << 3,
- GenericInlineLevelBox = 1 << 4
- };
- Type type() const { return m_type; }
-
- InlineLevelBox(const Box&, InlineLayoutUnit logicalLeft, InlineLayoutSize, Type);
- InlineLevelBox() = default;
-
- private:
- friend struct SimplifiedVerticalAlignment;
- friend class LineBoxBuilder;
- friend class LineBox;
-
- const InlineRect& logicalRect() const { return m_logicalRect; }
- InlineLayoutUnit logicalTop() const { return m_logicalRect.top(); }
- InlineLayoutUnit logicalBottom() const { return m_logicalRect.bottom(); }
- InlineLayoutUnit logicalLeft() const { return m_logicalRect.left(); }
- InlineLayoutUnit logicalWidth() const { return m_logicalRect.width(); }
- InlineLayoutUnit logicalHeight() const { return m_logicalRect.height(); }
-
- void setLogicalWidth(InlineLayoutUnit logicalWidth) { m_logicalRect.setWidth(logicalWidth); }
- void setLogicalHeight(InlineLayoutUnit);
- void setLogicalTop(InlineLayoutUnit);
- void setBaseline(InlineLayoutUnit);
- void setDescent(InlineLayoutUnit);
- void setLayoutBounds(const LayoutBounds&);
-
- private:
- WeakPtr<const Box> m_layoutBox;
- // This is the combination of margin and border boxes. Inline level boxes are vertically aligned using their margin boxes.
- InlineRect m_logicalRect;
- LayoutBounds m_layoutBounds;
- InlineLayoutUnit m_baseline { 0 };
- std::optional<InlineLayoutUnit> m_descent;
- bool m_hasContent { false };
- Type m_type { Type::InlineBox };
- };
-
LineBox(const Box& rootLayoutBox, const InlineLayoutPoint& logicalTopLeft, InlineLayoutUnit contentLogicalLeft, InlineLayoutUnit lineLogicalWidth, InlineLayoutUnit contentLogicalWidth, size_t nonSpanningInlineLevelBoxCount);
const InlineRect& logicalRect() const { return m_logicalRect; }
@@ -189,27 +116,7 @@
HashMap<const Box*, size_t> m_nonRootInlineLevelBoxMap;
};
-inline LineBox::InlineLevelBox LineBox::InlineLevelBox::createAtomicInlineLevelBox(const Box& layoutBox, InlineLayoutUnit logicalLeft, InlineLayoutSize logicalSize)
-{
- return LineBox::InlineLevelBox { layoutBox, logicalLeft, logicalSize, Type::AtomicInlineLevelBox };
}
-
-inline LineBox::InlineLevelBox LineBox::InlineLevelBox::createInlineBox(const Box& layoutBox, InlineLayoutUnit logicalLeft, InlineLayoutUnit logicalWidth)
-{
- return LineBox::InlineLevelBox { layoutBox, logicalLeft, InlineLayoutSize { logicalWidth, { } }, Type::InlineBox };
}
-inline LineBox::InlineLevelBox LineBox::InlineLevelBox::createLineBreakBox(const Box& layoutBox, InlineLayoutUnit logicalLeft)
-{
- return LineBox::InlineLevelBox { layoutBox, logicalLeft, InlineLayoutSize { }, Type::LineBreakBox };
-}
-
-inline LineBox::InlineLevelBox LineBox::InlineLevelBox::createGenericInlineLevelBox(const Box& layoutBox, InlineLayoutUnit logicalLeft)
-{
- return LineBox::InlineLevelBox { layoutBox, logicalLeft, InlineLayoutSize { }, Type::GenericInlineLevelBox };
-}
-
-}
-}
-
#endif