Changeset 267557 in webkit
- Timestamp:
- Sep 24, 2020, 9:49:46 PM (6 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 4 edited
-
ChangeLog (modified) (1 diff)
-
layout/inlineformatting/InlineFormattingContextGeometry.cpp (modified) (4 diffs)
-
layout/inlineformatting/InlineLineBox.cpp (modified) (1 diff)
-
layout/inlineformatting/InlineLineBox.h (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r267551 r267557 1 2020-09-24 Zalan Bujtas <zalan@apple.com> 2 3 [LFC][IFC] Add helper functions to create LineBox::InlineBox objects for inline level boxes. 4 https://bugs.webkit.org/show_bug.cgi?id=216957 5 6 Reviewed by Simon Fraser. 7 8 The overloaded LineBox::InlineBox constructors were representing different types of inline level boxes. 9 These new helper functions make it easier to figure out how to initiate LineBox::InlineBox objects depending on the type of 10 the inline level box. 11 This patch also removes an incorrect ASSERT on the inline box's height. It is okay to have a zero height inline box. 12 13 * layout/inlineformatting/InlineFormattingContextGeometry.cpp: 14 (WebCore::Layout::LineBoxBuilder::constructInlineBoxes): 15 * layout/inlineformatting/InlineLineBox.cpp: 16 (WebCore::Layout::LineBox::InlineBox::InlineBox): 17 (WebCore::Layout::m_baseline): 18 * layout/inlineformatting/InlineLineBox.h: 19 (WebCore::Layout::LineBox::InlineBox::createBoxForRootInlineBox): 20 (WebCore::Layout::LineBox::InlineBox::createBoxForAtomicInlineLevelBox): 21 (WebCore::Layout::LineBox::InlineBox::createBoxForInlineBox): 22 1 23 2020-09-24 Keith Miller <keith_miller@apple.com> 2 24 -
trunk/Source/WebCore/layout/inlineformatting/InlineFormattingContextGeometry.cpp
r267308 r267557 180 180 inlineBox.setLineSpacing(lineSpacing); 181 181 }; 182 182 auto horizontalAligmentOffset = lineBox.horizontalAlignmentOffset().valueOr(InlineLayoutUnit { }); 183 183 auto constructRootInlineBox = [&] { 184 auto rootInlineBox = makeUnique<LineBox::InlineBox>(rootBox(), lineBox.horizontalAlignmentOffset().valueOr(InlineLayoutUnit { }), lineBox.logicalWidth());184 auto rootInlineBox = LineBox::InlineBox::createBoxForRootInlineBox(rootBox(), horizontalAligmentOffset, lineBox.logicalWidth()); 185 185 186 186 auto lineHasImaginaryStrut = !layoutState().inQuirksMode(); … … 216 216 // Construct the missing LineBox::InlineBoxes starting with the topmost ancestor. 217 217 for (auto* ancestor : WTF::makeReversedRange(ancestorsWithoutInlineBoxes)) { 218 auto inlineBox = makeUnique<LineBox::InlineBox>(*ancestor, lineBox.horizontalAlignmentOffset().valueOr(InlineLayoutUnit { }), lineBox.logicalWidth());218 auto inlineBox = LineBox::InlineBox::createBoxForInlineBox(*ancestor, horizontalAligmentOffset, lineBox.logicalWidth()); 219 219 inlineBox->setIsNonEmpty(); 220 220 adjustVerticalGeometryForNonEmptyInlineBox(*inlineBox); … … 227 227 auto& inlineLevelBox = run.layoutBox(); 228 228 if (run.isBox()) { 229 auto logicalLeft = lineBox.horizontalAlignmentOffset().valueOr(InlineLayoutUnit { })+ run.logicalLeft();229 auto logicalLeft = horizontalAligmentOffset + run.logicalLeft(); 230 230 auto& inlineLevelBoxGeometry = formattingContext().geometryForBox(inlineLevelBox); 231 231 auto logicalHeight = inlineLevelBoxGeometry.marginBoxHeight(); … … 249 249 baseline = inlineLevelBoxGeometry.marginBefore() + inlineLevelBoxGeometry.borderTop() + inlineLevelBoxGeometry.paddingTop().valueOr(0) + inlineBlockBaseline; 250 250 } 251 auto rect = InlineRect { { }, logicalLeft, run.logicalWidth(), logicalHeight }; 252 lineBox.addInlineBox(makeUnique<LineBox::InlineBox>(inlineLevelBox, rect, baseline)); 251 auto inlineBox = LineBox::InlineBox::createBoxForAtomicInlineLevelBox(inlineLevelBox, logicalLeft, { run.logicalWidth(), logicalHeight }, baseline); 252 if (logicalHeight) 253 inlineBox->setIsNonEmpty(); 254 lineBox.addInlineBox(WTFMove(inlineBox)); 253 255 } else if (run.isContainerStart()) { 254 auto logicalLeft = lineBox.horizontalAlignmentOffset().valueOr(InlineLayoutUnit { })+ run.logicalLeft();256 auto logicalLeft = horizontalAligmentOffset + run.logicalLeft(); 255 257 auto initialLogicalWidth = lineBox.logicalWidth() - run.logicalLeft(); 256 258 ASSERT(initialLogicalWidth >= 0); 257 lineBox.addInlineBox( makeUnique<LineBox::InlineBox>(inlineLevelBox, logicalLeft, initialLogicalWidth));259 lineBox.addInlineBox(LineBox::InlineBox::createBoxForInlineBox(inlineLevelBox, logicalLeft, initialLogicalWidth)); 258 260 } else if (run.isContainerEnd()) { 259 261 // Adjust the logical width when the inline level container closes on this line. -
trunk/Source/WebCore/layout/inlineformatting/InlineLineBox.cpp
r267328 r267557 33 33 namespace Layout { 34 34 35 LineBox::InlineBox::InlineBox(const Box& layoutBox, const InlineRect& rect, InlineLayoutUnit baseline)35 LineBox::InlineBox::InlineBox(const Box& layoutBox, InlineLayoutUnit logicalLeft, InlineLayoutSize logicalSize, InlineLayoutUnit baseline) 36 36 : m_layoutBox(makeWeakPtr(layoutBox)) 37 , m_logicalRect( rect)37 , m_logicalRect({ }, logicalLeft, logicalSize.width(), logicalSize.height()) 38 38 , m_baseline(baseline) 39 , m_isEmpty(false)40 39 { 41 ASSERT(rect.height());42 40 } 43 41 -
trunk/Source/WebCore/layout/inlineformatting/InlineLineBox.h
r267434 r267557 58 58 WTF_MAKE_FAST_ALLOCATED; 59 59 public: 60 // FIXME: This name is in conflict with the actual inline box term: inline level box whose contents participate in this IFC. 61 // This class represents a rectangle on the line (initiated by an inline level box) with some additional attributes like baseline, descent etc. 60 62 struct InlineBox { 61 63 WTF_MAKE_ISO_ALLOCATED_INLINE(InlineBox); 62 64 public: 63 InlineBox(const Box&, const InlineRect&, InlineLayoutUnit baseline);64 InlineBox(const Box&, InlineLayoutUnit logicalLeft, InlineLayoutUnit logicalWidth);65 InlineBox() = default;65 static std::unique_ptr<LineBox::InlineBox> createBoxForRootInlineBox(const Box&, InlineLayoutUnit logicalLeft, InlineLayoutUnit logicalWidth); 66 static std::unique_ptr<LineBox::InlineBox> createBoxForAtomicInlineLevelBox(const Box&, InlineLayoutUnit logicalLeft, InlineLayoutSize, InlineLayoutUnit baseline); 67 static std::unique_ptr<LineBox::InlineBox> createBoxForInlineBox(const Box&, InlineLayoutUnit logicalLeft, InlineLayoutUnit logicalWidth); 66 68 67 69 const InlineRect& logicalRect() const { return m_logicalRect; } … … 82 84 const Box& layoutBox() const { return *m_layoutBox; } 83 85 86 InlineBox(const Box&, InlineLayoutUnit logicalLeft, InlineLayoutSize, InlineLayoutUnit baseline); 87 InlineBox(const Box&, InlineLayoutUnit logicalLeft, InlineLayoutUnit logicalWidth); 88 InlineBox() = default; 89 84 90 private: 85 91 friend class LineBoxBuilder; … … 92 98 void setLineSpacing(InlineLayoutUnit lineSpacing) { m_lineSpacing = lineSpacing; } 93 99 100 private: 94 101 WeakPtr<const Box> m_layoutBox; 95 102 InlineRect m_logicalRect; … … 143 150 }; 144 151 152 inline std::unique_ptr<LineBox::InlineBox> LineBox::InlineBox::createBoxForRootInlineBox(const Box& layoutBox, InlineLayoutUnit logicalLeft, InlineLayoutUnit logicalWidth) 153 { 154 return makeUnique<LineBox::InlineBox>(layoutBox, logicalLeft, logicalWidth); 155 } 156 157 inline std::unique_ptr<LineBox::InlineBox> LineBox::InlineBox::createBoxForAtomicInlineLevelBox(const Box& layoutBox, InlineLayoutUnit logicalLeft, InlineLayoutSize logicalSize, InlineLayoutUnit baseline) 158 { 159 return makeUnique<LineBox::InlineBox>(layoutBox, logicalLeft, logicalSize, baseline); 160 } 161 162 inline std::unique_ptr<LineBox::InlineBox> LineBox::InlineBox::createBoxForInlineBox(const Box& layoutBox, InlineLayoutUnit logicalLeft, InlineLayoutUnit logicalWidth) 163 { 164 return makeUnique<LineBox::InlineBox>(layoutBox, logicalLeft, logicalWidth); 165 } 166 145 167 } 146 168 }
Note:
See TracChangeset
for help on using the changeset viewer.