Changeset 268823 in webkit
- Timestamp:
- Oct 21, 2020, 2:21:22 PM (6 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 2 edited
-
ChangeLog (modified) (1 diff)
-
layout/inlineformatting/InlineFormattingContextGeometry.cpp (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r268822 r268823 1 2020-10-21 Zalan Bujtas <zalan@apple.com> 2 3 [LFC][IFC] Apply font line-spacing to <br> inline level box 4 https://bugs.webkit.org/show_bug.cgi?id=218043 5 6 Reviewed by Antti Koivisto. 7 8 The inline level box initiated by <br> should be vertically sized the same way as the root inline box is. 9 (e.g. <div>root text<br></div> <- line break's inline level box should match the layout bounds of the root inline box). 10 11 * layout/inlineformatting/InlineFormattingContextGeometry.cpp: 12 (WebCore::Layout::LineBoxBuilder::isRootInlineBox const): 13 (WebCore::Layout::LineBoxBuilder::isRootBox const): 14 (WebCore::Layout::LineBoxBuilder::setVerticalGeometryForInlineBox const): 15 (WebCore::Layout::LineBoxBuilder::constructInlineLevelBoxes): 16 1 17 2020-10-21 Chris Dumez <cdumez@apple.com> 2 18 -
trunk/Source/WebCore/layout/inlineformatting/InlineFormattingContextGeometry.cpp
r268815 r268823 54 54 LayoutState& layoutState() const { return formattingContext().layoutState(); } 55 55 56 bool isRootInlineBox(const LineBox::InlineLevelBox& inlineLevelBox) const { return &inlineLevelBox.layoutBox() == &rootBox(); } 57 bool isRootBox(const ContainerBox& containerBox) const { return &containerBox == &rootBox(); } 58 56 59 private: 57 60 const InlineFormattingContext& m_inlineFormattingContext; … … 178 181 // If line-height computes to normal and either text-edge is leading or this is the root inline box, 179 182 // the font’s line gap metric may also be incorporated into A and D by adding half to each side as half-leading. 180 auto lineSpacing = &inlineLevelBox.layoutBox() == &rootBox() ? fontMetrics.lineSpacing() - logicalHeight : InlineLayoutUnit(); 181 ascent += lineSpacing / 2; 182 descent += lineSpacing / 2; 183 auto shouldLineGapStretchInlineLevelBox = isRootInlineBox(inlineLevelBox) || inlineLevelBox.isLineBreakBox(); 184 if (shouldLineGapStretchInlineLevelBox) { 185 auto halfLineGap = (fontMetrics.lineSpacing() - logicalHeight) / 2; 186 ascent += halfLineGap; 187 descent += halfLineGap; 188 } 183 189 } else { 184 190 InlineLayoutUnit lineHeight = style.computedLineHeight(); … … 224 230 // nested with a [container start] run. 225 231 auto& firstRun = runs[0]; 226 auto& firstRunParent InlineBox = firstRun.layoutBox().parent();232 auto& firstRunParentLayoutBox = firstRun.layoutBox().parent(); 227 233 // If the parent is the formatting root, we can stop here. This is root inline box content, there's no nesting inline box from the previous line(s) 228 234 // unless the inline box closing (container end run) is forced over to the current line. … … 230 236 // <span>normally the inline box closing forms a continuous content</span> 231 237 // <span>unless it's forced to the next line<br></span> 232 if ( &firstRunParentInlineBox == &rootBox() && !firstRun.isContainerEnd())238 if (isRootBox(firstRunParentLayoutBox) && !firstRun.isContainerEnd()) 233 239 return; 234 auto* ancestor = &firstRunParent InlineBox;240 auto* ancestor = &firstRunParentLayoutBox; 235 241 Vector<const Box*> ancestorsWithoutInlineBoxes; 236 while ( ancestor != &rootBox()) {242 while (!isRootBox(*ancestor)) { 237 243 ancestorsWithoutInlineBoxes.append(ancestor); 238 244 ancestor = &ancestor->parent(); … … 249 255 auto stretchRootInlineBoxIfNeededQuirk = [&] (const auto& layoutBox) { 250 256 auto& parentInlineBox = lineBox.inlineLevelBoxForLayoutBox(layoutBox.parent()); 251 if ( &parentInlineBox.layoutBox() != &rootBox() || !parentInlineBox.isEmpty())257 if (!isRootInlineBox(parentInlineBox) || !parentInlineBox.isEmpty()) 252 258 return; 253 259 setVerticalGeometryForInlineBox(parentInlineBox);
Note:
See TracChangeset
for help on using the changeset viewer.