Skip to content

Commit

Permalink
Apply patch. rdar://118701491
Browse files Browse the repository at this point in the history
Identifier: 267815.599@safari-7617-branch
  • Loading branch information
MyahCobbs committed Nov 30, 2023
1 parent 464bf89 commit 38eae99
Showing 1 changed file with 11 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -494,8 +494,9 @@ LineContent LineBuilder::placeInlineAndFloatContent(const InlineItemRange& needs
LineBuilder::UsedConstraints LineBuilder::initialConstraintsForLine(const InlineRect& initialLineLogicalRect, std::optional<bool> previousLineEndsWithLineBreak) const
{
auto isIntrinsicWidthMode = isInIntrinsicWidthMode() ? InlineFormattingGeometry::IsIntrinsicWidthMode::Yes : InlineFormattingGeometry::IsIntrinsicWidthMode::No;
auto textIndent = formattingContext().formattingGeometry().computedTextIndent(isIntrinsicWidthMode, previousLineEndsWithLineBreak, initialLineLogicalRect.width());
return floatConstrainedRect(initialLineLogicalRect, textIndent);
auto constraints = floatConstrainedRect(initialLineLogicalRect, { });
constraints.marginStart = formattingContext().formattingGeometry().computedTextIndent(isIntrinsicWidthMode, previousLineEndsWithLineBreak, initialLineLogicalRect.width());
return constraints;
}

InlineLayoutUnit LineBuilder::leadingPunctuationWidthForLineCandiate(size_t firstInlineTextItemIndex, size_t candidateContentStartIndex) const
Expand Down Expand Up @@ -708,20 +709,20 @@ LineBuilder::UsedConstraints LineBuilder::floatConstrainedRect(const InlineRect&
return { logicalRect, marginStart, { } };

auto isConstrainedByFloat = OptionSet<UsedFloat> { };
auto adjustedLogicalRect = logicalRect;
adjustedLogicalRect.shiftLeftBy(-marginStart);
// text-indent acts as (start)margin on the line. When looking for intrusive floats we need to check against the line's _margin_ box.
auto marginBoxRect = InlineRect { logicalRect.top(), logicalRect.left() - marginStart, logicalRect.width() + marginStart, logicalRect.height() };

if (constraints.left && constraints.left->x > adjustedLogicalRect.left()) {
adjustedLogicalRect.shiftLeftTo(constraints.left->x);
if (constraints.left && constraints.left->x > marginBoxRect.left()) {
marginBoxRect.shiftLeftTo(constraints.left->x);
isConstrainedByFloat.add(UsedFloat::Left);
}
if (constraints.right && constraints.right->x < adjustedLogicalRect.right()) {
adjustedLogicalRect.setRight(std::max<InlineLayoutUnit>(adjustedLogicalRect.left(), constraints.right->x));
if (constraints.right && constraints.right->x < marginBoxRect.right()) {
marginBoxRect.setRight(std::max<InlineLayoutUnit>(marginBoxRect.left(), constraints.right->x));
isConstrainedByFloat.add(UsedFloat::Right);
}

adjustedLogicalRect.shiftLeftBy(marginStart);
return { adjustedLogicalRect, marginStart, isConstrainedByFloat };
auto lineLogicalRect = InlineRect { marginBoxRect.top(), marginBoxRect.left() + marginStart, marginBoxRect.width() - marginStart, marginBoxRect.height() };
return { lineLogicalRect, marginStart, isConstrainedByFloat };
}

LineBuilder::UsedConstraints LineBuilder::adjustedLineRectWithCandidateInlineContent(const LineCandidate& lineCandidate) const
Expand Down

0 comments on commit 38eae99

Please sign in to comment.