Title: [270703] trunk/Source/WebCore
- Revision
- 270703
- Author
- [email protected]
- Date
- 2020-12-11 12:41:35 -0800 (Fri, 11 Dec 2020)
Log Message
[LFC][IFC] Line should report the correct value for "content logical right"
https://bugs.webkit.org/show_bug.cgi?id=219779
Reviewed by Antti Koivisto.
Adjust the run's horizontal geometry when negative margin-start is present.
* layout/inlineformatting/InlineLine.cpp:
(WebCore::Layout::Line::appendNonReplacedInlineBox):
(WebCore::Layout::Line::appendReplacedInlineBox):
* layout/inlineformatting/InlineLine.h:
(WebCore::Layout::Line::contentLogicalRight const):
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (270702 => 270703)
--- trunk/Source/WebCore/ChangeLog 2020-12-11 20:39:38 UTC (rev 270702)
+++ trunk/Source/WebCore/ChangeLog 2020-12-11 20:41:35 UTC (rev 270703)
@@ -1,3 +1,18 @@
+2020-12-11 Zalan Bujtas <[email protected]>
+
+ [LFC][IFC] Line should report the correct value for "content logical right"
+ https://bugs.webkit.org/show_bug.cgi?id=219779
+
+ Reviewed by Antti Koivisto.
+
+ Adjust the run's horizontal geometry when negative margin-start is present.
+
+ * layout/inlineformatting/InlineLine.cpp:
+ (WebCore::Layout::Line::appendNonReplacedInlineBox):
+ (WebCore::Layout::Line::appendReplacedInlineBox):
+ * layout/inlineformatting/InlineLine.h:
+ (WebCore::Layout::Line::contentLogicalRight const):
+
2020-12-11 Alexey Shvayka <[email protected]>
Reflect.preventExtensions should not throw if called on WindowProxy or Location
Modified: trunk/Source/WebCore/layout/inlineformatting/InlineLine.cpp (270702 => 270703)
--- trunk/Source/WebCore/layout/inlineformatting/InlineLine.cpp 2020-12-11 20:39:38 UTC (rev 270702)
+++ trunk/Source/WebCore/layout/inlineformatting/InlineLine.cpp 2020-12-11 20:41:35 UTC (rev 270703)
@@ -297,22 +297,28 @@
m_trailingSoftHyphenWidth = inlineTextItem.hasTrailingSoftHyphen() ? makeOptional(style.fontCascade().width(TextRun { StringView { style.hyphenString() } })) : WTF::nullopt;
}
-void Line::appendNonReplacedInlineBox(const InlineItem& inlineItem, InlineLayoutUnit logicalWidth)
+void Line::appendNonReplacedInlineBox(const InlineItem& inlineItem, InlineLayoutUnit marginBoxLogicalWidth)
{
- auto& boxGeometry = formattingContext().geometryForBox(inlineItem.layoutBox());
- // Negative margin start pulls the content to the logical left direction.
- auto adjustedRunStart = contentLogicalRight() + std::min(boxGeometry.marginStart(), 0_lu);
- m_runs.append({ inlineItem, adjustedRunStart, logicalWidth });
- m_contentLogicalWidth += logicalWidth;
m_trimmableTrailingContent.reset();
m_trailingSoftHyphenWidth = { };
+ m_contentLogicalWidth += marginBoxLogicalWidth;
+ auto marginStart = formattingContext().geometryForBox(inlineItem.layoutBox()).marginStart();
+ if (marginStart >= 0) {
+ m_runs.append({ inlineItem, contentLogicalRight(), marginBoxLogicalWidth });
+ return;
+ }
+ // Negative margin-start pulls the content to the logical left direction.
+ // Negative margin also squeezes the margin box, we need to stretch it to make sure the subsequent content won't overlap.
+ // e.g. <img style="width: 100px; margin-left: -100px;"> pulls the replaced box to -100px with the margin box width of 0px.
+ // Instead we need to position it at -100px and size it to 100px so the subsequent content starts at 0px.
+ m_runs.append({ inlineItem, contentLogicalRight() + marginStart, marginBoxLogicalWidth - marginStart });
}
-void Line::appendReplacedInlineBox(const InlineItem& inlineItem, InlineLayoutUnit logicalWidth)
+void Line::appendReplacedInlineBox(const InlineItem& inlineItem, InlineLayoutUnit marginBoxLogicalWidth)
{
ASSERT(inlineItem.layoutBox().isReplacedBox());
// FIXME: Surely replaced boxes behave differently.
- appendNonReplacedInlineBox(inlineItem, logicalWidth);
+ appendNonReplacedInlineBox(inlineItem, marginBoxLogicalWidth);
}
void Line::appendLineBreak(const InlineItem& inlineItem)
Modified: trunk/Source/WebCore/layout/inlineformatting/InlineLine.h (270702 => 270703)
--- trunk/Source/WebCore/layout/inlineformatting/InlineLine.h 2020-12-11 20:39:38 UTC (rev 270702)
+++ trunk/Source/WebCore/layout/inlineformatting/InlineLine.h 2020-12-11 20:41:35 UTC (rev 270703)
@@ -53,8 +53,7 @@
bool isConsideredEmpty() const { return m_isConsideredEmpty; }
InlineLayoutUnit contentLogicalWidth() const { return m_contentLogicalWidth; }
- // FIXME: Add support for negative word-sapcing where contentLogicalRight != contentLogicalWidth.
- InlineLayoutUnit contentLogicalRight() const { return m_contentLogicalWidth; }
+ InlineLayoutUnit contentLogicalRight() const { return m_runs.isEmpty() ? 0.0f : m_runs.last().logicalRight(); }
InlineLayoutUnit trimmableTrailingWidth() const { return m_trimmableTrailingContent.width(); }
bool isTrailingRunFullyTrimmable() const { return m_trimmableTrailingContent.isTrailingRunFullyTrimmable(); }
@@ -137,8 +136,8 @@
private:
void appendNonBreakableSpace(const InlineItem&, InlineLayoutUnit logicalLeft, InlineLayoutUnit logicalWidth);
void appendTextContent(const InlineTextItem&, InlineLayoutUnit logicalWidth);
- void appendNonReplacedInlineBox(const InlineItem&, InlineLayoutUnit logicalWidth);
- void appendReplacedInlineBox(const InlineItem&, InlineLayoutUnit logicalWidth);
+ void appendNonReplacedInlineBox(const InlineItem&, InlineLayoutUnit marginBoxLogicalWidth);
+ void appendReplacedInlineBox(const InlineItem&, InlineLayoutUnit marginBoxLogicalWidth);
void appendInlineBoxStart(const InlineItem&, InlineLayoutUnit logicalWidth);
void appendInlineBoxEnd(const InlineItem&, InlineLayoutUnit logicalWidth);
void appendLineBreak(const InlineItem&);
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes