Diff
Modified: trunk/Source/WebCore/ChangeLog (277544 => 277545)
--- trunk/Source/WebCore/ChangeLog 2021-05-15 18:27:43 UTC (rev 277544)
+++ trunk/Source/WebCore/ChangeLog 2021-05-15 19:50:54 UTC (rev 277545)
@@ -1,5 +1,21 @@
2021-05-15 Alan Bujtas <[email protected]>
+ [LFC] Move inline formatting quirks to its own class
+ https://bugs.webkit.org/show_bug.cgi?id=225759
+
+ Reviewed by Antti Koivisto.
+
+ * Sources.txt:
+ * WebCore.xcodeproj/project.pbxproj:
+ * layout/formattingContexts/inline/InlineFormattingContext.cpp:
+ (WebCore::Layout::InlineFormattingContext::quirks const):
+ * layout/formattingContexts/inline/InlineFormattingContext.h:
+ (WebCore::Layout::InlineFormattingContext::Quirks::Quirks): Deleted.
+ * layout/formattingContexts/inline/InlineFormattingContextQuirks.cpp: Removed.
+ * layout/integration/LayoutIntegrationInlineContentBuilder.cpp:
+
+2021-05-15 Alan Bujtas <[email protected]>
+
[LFC] Move table wrapper quirks to its own class
https://bugs.webkit.org/show_bug.cgi?id=225760
Modified: trunk/Source/WebCore/Sources.txt (277544 => 277545)
--- trunk/Source/WebCore/Sources.txt 2021-05-15 18:27:43 UTC (rev 277544)
+++ trunk/Source/WebCore/Sources.txt 2021-05-15 19:50:54 UTC (rev 277545)
@@ -1535,7 +1535,7 @@
layout/formattingContexts/inline/InlineContentBreaker.cpp
layout/formattingContexts/inline/InlineFormattingContext.cpp
layout/formattingContexts/inline/InlineFormattingContextGeometry.cpp
-layout/formattingContexts/inline/InlineFormattingContextQuirks.cpp
+layout/formattingContexts/inline/InlineFormattingQuirks.cpp
layout/formattingContexts/inline/InlineFormattingState.cpp
layout/formattingContexts/inline/InlineItem.cpp
layout/formattingContexts/inline/InlineLine.cpp
Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (277544 => 277545)
--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2021-05-15 18:27:43 UTC (rev 277544)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2021-05-15 19:50:54 UTC (rev 277545)
@@ -2163,6 +2163,7 @@
6FCE1A1A22618ABD004F0343 /* LayoutIntegrationRun.h in Headers */ = {isa = PBXBuildFile; fileRef = 6FCE1A1822618AB3004F0343 /* LayoutIntegrationRun.h */; settings = {ATTRIBUTES = (Private, ); }; };
6FD09543251115220098877D /* LayoutGeometryRect.h in Headers */ = {isa = PBXBuildFile; fileRef = 6FD09541251115220098877D /* LayoutGeometryRect.h */; settings = {ATTRIBUTES = (Private, ); }; };
6FE198172178397C00446F08 /* InlineContentBreaker.h in Headers */ = {isa = PBXBuildFile; fileRef = 6FE198152178397C00446F08 /* InlineContentBreaker.h */; settings = {ATTRIBUTES = (Private, ); }; };
+ 6FE636E82647962900F0951E /* InlineFormattingQuirks.h in Headers */ = {isa = PBXBuildFile; fileRef = 6FE636E72647962900F0951E /* InlineFormattingQuirks.h */; settings = {ATTRIBUTES = (Private, ); }; };
6FE7CFA22177EEF2005B1573 /* InlineItem.h in Headers */ = {isa = PBXBuildFile; fileRef = 6FE7CFA02177EEF1005B1573 /* InlineItem.h */; };
6FFA4C0123F2FED9007E4EBC /* LayoutLineBreakBox.h in Headers */ = {isa = PBXBuildFile; fileRef = 6FFA4C0023F2FED9007E4EBC /* LayoutLineBreakBox.h */; settings = {ATTRIBUTES = (Private, ); }; };
6FFDC442212EFF1700A9CA91 /* FloatAvoider.h in Headers */ = {isa = PBXBuildFile; fileRef = 6FFDC440212EFF1600A9CA91 /* FloatAvoider.h */; settings = {ATTRIBUTES = (Private, ); }; };
@@ -9946,7 +9947,7 @@
6F0B98B623F2690600EEC2F2 /* LayoutInlineTextBox.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = LayoutInlineTextBox.cpp; sourceTree = "<group>"; };
6F0CD692229ED31900C5994E /* InlineLine.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = InlineLine.cpp; sourceTree = "<group>"; };
6F0CD694229ED32700C5994E /* InlineLine.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = InlineLine.h; sourceTree = "<group>"; };
- 6F10B08622B8568D0090E69C /* InlineFormattingContextQuirks.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = InlineFormattingContextQuirks.cpp; sourceTree = "<group>"; };
+ 6F10B08622B8568D0090E69C /* InlineFormattingQuirks.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = InlineFormattingQuirks.cpp; sourceTree = "<group>"; };
6F15522026476B5B00E353C6 /* TableWrapperBlockFormattingQuirks.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TableWrapperBlockFormattingQuirks.h; sourceTree = "<group>"; };
6F17264C2470C5F700518C96 /* TableWrapperBlockFormattingContext.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = TableWrapperBlockFormattingContext.cpp; sourceTree = "<group>"; };
6F17264E2470C60A00518C96 /* TableWrapperBlockFormattingContext.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TableWrapperBlockFormattingContext.h; sourceTree = "<group>"; };
@@ -10029,6 +10030,7 @@
6FD09541251115220098877D /* LayoutGeometryRect.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LayoutGeometryRect.h; sourceTree = "<group>"; };
6FE198132178397B00446F08 /* InlineContentBreaker.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = InlineContentBreaker.cpp; sourceTree = "<group>"; };
6FE198152178397C00446F08 /* InlineContentBreaker.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = InlineContentBreaker.h; sourceTree = "<group>"; };
+ 6FE636E72647962900F0951E /* InlineFormattingQuirks.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = InlineFormattingQuirks.h; sourceTree = "<group>"; };
6FE7AA2621C37B6300296DCD /* MarginTypes.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MarginTypes.h; sourceTree = "<group>"; };
6FE7CFA02177EEF1005B1573 /* InlineItem.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = InlineItem.h; sourceTree = "<group>"; };
6FE8E6F7237BA5E800758D26 /* InvalidationContext.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = InvalidationContext.cpp; sourceTree = "<group>"; };
@@ -18254,7 +18256,8 @@
6F7CA3C9208C2B2E002F29AB /* InlineFormattingContext.cpp */,
6F7CA3C8208C2B2E002F29AB /* InlineFormattingContext.h */,
6F35EFAF2187CBD50044E0F4 /* InlineFormattingContextGeometry.cpp */,
- 6F10B08622B8568D0090E69C /* InlineFormattingContextQuirks.cpp */,
+ 6F10B08622B8568D0090E69C /* InlineFormattingQuirks.cpp */,
+ 6FE636E72647962900F0951E /* InlineFormattingQuirks.h */,
115CFA7D208B8E10001E6991 /* InlineFormattingState.cpp */,
115CFA7C208B8E10001E6991 /* InlineFormattingState.h */,
6F7B8CEC23626E6600C9FF15 /* InlineItem.cpp */,
@@ -32935,6 +32938,7 @@
B57CB52E182A3EFC0079A647 /* InlineElementBox.h in Headers */,
A8CFF5E30A155A05000A4234 /* InlineFlowBox.h in Headers */,
6F7CA3CA208C2B2E002F29AB /* InlineFormattingContext.h in Headers */,
+ 6FE636E82647962900F0951E /* InlineFormattingQuirks.h in Headers */,
115CFA7E208B8E10001E6991 /* InlineFormattingState.h in Headers */,
6FE7CFA22177EEF2005B1573 /* InlineItem.h in Headers */,
BCE789161120D6080060ECE5 /* InlineIterator.h in Headers */,
Modified: trunk/Source/WebCore/layout/formattingContexts/inline/InlineFormattingContext.cpp (277544 => 277545)
--- trunk/Source/WebCore/layout/formattingContexts/inline/InlineFormattingContext.cpp 2021-05-15 18:27:43 UTC (rev 277544)
+++ trunk/Source/WebCore/layout/formattingContexts/inline/InlineFormattingContext.cpp 2021-05-15 19:50:54 UTC (rev 277545)
@@ -30,6 +30,7 @@
#include "FloatingContext.h"
#include "FontCascade.h"
+#include "InlineFormattingQuirks.h"
#include "InlineFormattingState.h"
#include "InlineLineBox.h"
#include "InlineLineRun.h"
@@ -605,7 +606,13 @@
// FIXME: This is also where we would delete inline items if their content changed.
}
+InlineFormattingQuirks InlineFormattingContext::quirks() const
+{
+ return InlineFormattingQuirks(*this);
+
}
+
}
+}
#endif
Modified: trunk/Source/WebCore/layout/formattingContexts/inline/InlineFormattingContext.h (277544 => 277545)
--- trunk/Source/WebCore/layout/formattingContexts/inline/InlineFormattingContext.h 2021-05-15 18:27:43 UTC (rev 277544)
+++ trunk/Source/WebCore/layout/formattingContexts/inline/InlineFormattingContext.h 2021-05-15 19:50:54 UTC (rev 277545)
@@ -35,6 +35,7 @@
namespace Layout {
class InlineFormattingState;
+class InlineFormattingQuirks;
class InvalidationState;
class LineBox;
@@ -47,21 +48,8 @@
void layoutInFlowContent(InvalidationState&, const ConstraintsForInFlowContent&) override;
LayoutUnit usedContentHeight() const override;
- class Quirks : public FormattingContext::Quirks {
- public:
- InlineLayoutUnit initialLineHeight() const;
- bool hasSoftWrapOpportunityAtImage() const;
- bool inlineLevelBoxAffectsLineBox(const LineBox::InlineLevelBox&, const LineBox&) const;
+ InlineFormattingQuirks quirks() const;
- private:
- friend class InlineFormattingContext;
- Quirks(const InlineFormattingContext&);
-
- const InlineFormattingContext& formattingContext() const { return downcast<InlineFormattingContext>(FormattingContext::Quirks::formattingContext()); }
-
- };
- InlineFormattingContext::Quirks quirks() const { return Quirks(*this); }
-
const InlineFormattingState& formattingState() const { return downcast<InlineFormattingState>(FormattingContext::formattingState()); }
InlineFormattingState& formattingState() { return downcast<InlineFormattingState>(FormattingContext::formattingState()); }
@@ -106,13 +94,8 @@
{
}
-inline InlineFormattingContext::Quirks::Quirks(const InlineFormattingContext& inlineFormattingContext)
- : FormattingContext::Quirks(inlineFormattingContext)
-{
}
-
}
-}
SPECIALIZE_TYPE_TRAITS_LAYOUT_FORMATTING_CONTEXT(InlineFormattingContext, isInlineFormattingContext())
Deleted: trunk/Source/WebCore/layout/formattingContexts/inline/InlineFormattingContextQuirks.cpp (277544 => 277545)
--- trunk/Source/WebCore/layout/formattingContexts/inline/InlineFormattingContextQuirks.cpp 2021-05-15 18:27:43 UTC (rev 277544)
+++ trunk/Source/WebCore/layout/formattingContexts/inline/InlineFormattingContextQuirks.cpp 2021-05-15 19:50:54 UTC (rev 277545)
@@ -1,111 +0,0 @@
-/*
- * Copyright (C) 2019 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.
- */
-
-#include "config.h"
-#include "InlineFormattingContext.h"
-
-#if ENABLE(LAYOUT_FORMATTING_CONTEXT)
-
-#include "LayoutBoxGeometry.h"
-
-namespace WebCore {
-namespace Layout {
-
-InlineLayoutUnit InlineFormattingContext::Quirks::initialLineHeight() const
-{
- // Negative lineHeight value means the line-height is not set
- auto& root = formattingContext().root();
- if (layoutState().inStandardsMode() || !root.style().lineHeight().isNegative())
- return root.style().computedLineHeight();
- return root.style().fontMetrics().floatHeight();
-}
-
-bool InlineFormattingContext::Quirks::inlineLevelBoxAffectsLineBox(const LineBox::InlineLevelBox& inlineLevelBox, const LineBox& lineBox) const
-{
- if (inlineLevelBox.isLineBreakBox()) {
- if (layoutState().inStandardsMode())
- return true;
- // In quirks mode linebreak boxes (<br>) stop affecting the line box when (assume <br> is nested e.g. <span style="font-size: 100px"><br></span>)
- // 1. the root inline box has content <div>content<br>/div>
- // 2. there's at least one atomic inline level box on the line e.g <div><img><br></div> or <div><span><img></span><br></div>
- // 3. there's at least one inline box with content e.g. <div><span>content</span><br></div>
- if (lineBox.rootInlineBox().hasContent())
- return false;
- if (lineBox.hasAtomicInlineLevelBox())
- return false;
- // At this point we either have only the <br> on the line or inline boxes with or without content.
- auto& inlineLevelBoxes = lineBox.nonRootInlineLevelBoxes();
- ASSERT(!inlineLevelBoxes.isEmpty());
- if (inlineLevelBoxes.size() == 1)
- return true;
- for (auto& inlineLevelBox : lineBox.nonRootInlineLevelBoxes()) {
- // Filter out empty inline boxes e.g. <div><span></span><span></span><br></div>
- if (inlineLevelBox.isInlineBox() && inlineLevelBox.hasContent())
- return false;
- }
- return true;
- }
- if (inlineLevelBox.isInlineBox()) {
- // Inline boxes (e.g. root inline box or <span>) affects line boxes either through the strut or actual content.
- auto inlineBoxHasImaginaryStrut = layoutState().inStandardsMode();
- if (inlineLevelBox.hasContent() || inlineBoxHasImaginaryStrut)
- return true;
- if (inlineLevelBox.isRootInlineBox()) {
- // This root inline box has no direct text content and we are in non-standards mode.
- // Now according to legacy line layout, we need to apply the following list-item specific quirk:
- // We do not create markers for list items when the list-style-type is none, while other browsers do.
- // The side effect of having no marker is that in quirks mode we have to specifically check for list-item
- // and make sure it is treated as if it had content and stretched the line.
- // see InlineFlowBox c'tor.
- return inlineLevelBox.layoutBox().style().isOriginalDisplayListItemType();
- }
- // Non-root inline boxes (e.g. <span>).
- auto& boxGeometry = formattingContext().geometryForBox(inlineLevelBox.layoutBox());
- if (boxGeometry.horizontalBorder() || boxGeometry.horizontalPadding().valueOr(0_lu)) {
- // Horizontal border and padding make the inline box stretch the line (e.g. <span style="padding: 10px;"></span>).
- return true;
- }
- return false;
- }
- if (inlineLevelBox.isAtomicInlineLevelBox()) {
- if (inlineLevelBox.layoutBounds().height())
- return true;
- // While in practice when the negative vertical margin makes the layout bounds empty (e.g: height: 100px; margin-top: -100px;), and this inline
- // level box contributes 0px to the line box height, it still needs to be taken into account while computing line box geometries.
- auto& boxGeometry = formattingContext().geometryForBox(inlineLevelBox.layoutBox());
- return boxGeometry.marginBefore() || boxGeometry.marginAfter();
- }
- return false;
-}
-
-bool InlineFormattingContext::Quirks::hasSoftWrapOpportunityAtImage() const
-{
- return !formattingContext().root().isTableCell();
-}
-
-}
-}
-
-#endif
Copied: trunk/Source/WebCore/layout/formattingContexts/inline/InlineFormattingQuirks.cpp (from rev 277544, trunk/Source/WebCore/layout/formattingContexts/inline/InlineFormattingContextQuirks.cpp) (0 => 277545)
--- trunk/Source/WebCore/layout/formattingContexts/inline/InlineFormattingQuirks.cpp (rev 0)
+++ trunk/Source/WebCore/layout/formattingContexts/inline/InlineFormattingQuirks.cpp 2021-05-15 19:50:54 UTC (rev 277545)
@@ -0,0 +1,116 @@
+/*
+ * Copyright (C) 2019 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.
+ */
+
+#include "config.h"
+#include "InlineFormattingQuirks.h"
+
+#if ENABLE(LAYOUT_FORMATTING_CONTEXT)
+
+#include "LayoutBoxGeometry.h"
+
+namespace WebCore {
+namespace Layout {
+
+InlineFormattingQuirks::InlineFormattingQuirks(const InlineFormattingContext& inlineFormattingContext)
+ : FormattingContext::Quirks(inlineFormattingContext)
+{
+}
+
+InlineLayoutUnit InlineFormattingQuirks::initialLineHeight() const
+{
+ // Negative lineHeight value means the line-height is not set
+ auto& root = formattingContext().root();
+ if (layoutState().inStandardsMode() || !root.style().lineHeight().isNegative())
+ return root.style().computedLineHeight();
+ return root.style().fontMetrics().floatHeight();
+}
+
+bool InlineFormattingQuirks::inlineLevelBoxAffectsLineBox(const LineBox::InlineLevelBox& inlineLevelBox, const LineBox& lineBox) const
+{
+ if (inlineLevelBox.isLineBreakBox()) {
+ if (layoutState().inStandardsMode())
+ return true;
+ // In quirks mode linebreak boxes (<br>) stop affecting the line box when (assume <br> is nested e.g. <span style="font-size: 100px"><br></span>)
+ // 1. the root inline box has content <div>content<br>/div>
+ // 2. there's at least one atomic inline level box on the line e.g <div><img><br></div> or <div><span><img></span><br></div>
+ // 3. there's at least one inline box with content e.g. <div><span>content</span><br></div>
+ if (lineBox.rootInlineBox().hasContent())
+ return false;
+ if (lineBox.hasAtomicInlineLevelBox())
+ return false;
+ // At this point we either have only the <br> on the line or inline boxes with or without content.
+ auto& inlineLevelBoxes = lineBox.nonRootInlineLevelBoxes();
+ ASSERT(!inlineLevelBoxes.isEmpty());
+ if (inlineLevelBoxes.size() == 1)
+ return true;
+ for (auto& inlineLevelBox : lineBox.nonRootInlineLevelBoxes()) {
+ // Filter out empty inline boxes e.g. <div><span></span><span></span><br></div>
+ if (inlineLevelBox.isInlineBox() && inlineLevelBox.hasContent())
+ return false;
+ }
+ return true;
+ }
+ if (inlineLevelBox.isInlineBox()) {
+ // Inline boxes (e.g. root inline box or <span>) affects line boxes either through the strut or actual content.
+ auto inlineBoxHasImaginaryStrut = layoutState().inStandardsMode();
+ if (inlineLevelBox.hasContent() || inlineBoxHasImaginaryStrut)
+ return true;
+ if (inlineLevelBox.isRootInlineBox()) {
+ // This root inline box has no direct text content and we are in non-standards mode.
+ // Now according to legacy line layout, we need to apply the following list-item specific quirk:
+ // We do not create markers for list items when the list-style-type is none, while other browsers do.
+ // The side effect of having no marker is that in quirks mode we have to specifically check for list-item
+ // and make sure it is treated as if it had content and stretched the line.
+ // see InlineFlowBox c'tor.
+ return inlineLevelBox.layoutBox().style().isOriginalDisplayListItemType();
+ }
+ // Non-root inline boxes (e.g. <span>).
+ auto& boxGeometry = formattingContext().geometryForBox(inlineLevelBox.layoutBox());
+ if (boxGeometry.horizontalBorder() || boxGeometry.horizontalPadding().valueOr(0_lu)) {
+ // Horizontal border and padding make the inline box stretch the line (e.g. <span style="padding: 10px;"></span>).
+ return true;
+ }
+ return false;
+ }
+ if (inlineLevelBox.isAtomicInlineLevelBox()) {
+ if (inlineLevelBox.layoutBounds().height())
+ return true;
+ // While in practice when the negative vertical margin makes the layout bounds empty (e.g: height: 100px; margin-top: -100px;), and this inline
+ // level box contributes 0px to the line box height, it still needs to be taken into account while computing line box geometries.
+ auto& boxGeometry = formattingContext().geometryForBox(inlineLevelBox.layoutBox());
+ return boxGeometry.marginBefore() || boxGeometry.marginAfter();
+ }
+ return false;
+}
+
+bool InlineFormattingQuirks::hasSoftWrapOpportunityAtImage() const
+{
+ return !formattingContext().root().isTableCell();
+}
+
+}
+}
+
+#endif
Added: trunk/Source/WebCore/layout/formattingContexts/inline/InlineFormattingQuirks.h (0 => 277545)
--- trunk/Source/WebCore/layout/formattingContexts/inline/InlineFormattingQuirks.h (rev 0)
+++ trunk/Source/WebCore/layout/formattingContexts/inline/InlineFormattingQuirks.h 2021-05-15 19:50:54 UTC (rev 277545)
@@ -0,0 +1,52 @@
+/*
+ * 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 "FormattingContext.h"
+
+namespace WebCore {
+namespace Layout {
+
+class InlineFormattingQuirks : public FormattingContext::Quirks {
+public:
+ InlineLayoutUnit initialLineHeight() const;
+ bool hasSoftWrapOpportunityAtImage() const;
+ bool inlineLevelBoxAffectsLineBox(const LineBox::InlineLevelBox&, const LineBox&) const;
+
+private:
+ friend class InlineFormattingContext;
+ InlineFormattingQuirks(const InlineFormattingContext&);
+
+ const InlineFormattingContext& formattingContext() const { return downcast<InlineFormattingContext>(FormattingContext::Quirks::formattingContext()); }
+
+};
+
+}
+}
+
+#endif
Modified: trunk/Source/WebCore/layout/integration/LayoutIntegrationInlineContentBuilder.cpp (277544 => 277545)
--- trunk/Source/WebCore/layout/integration/LayoutIntegrationInlineContentBuilder.cpp 2021-05-15 18:27:43 UTC (rev 277544)
+++ trunk/Source/WebCore/layout/integration/LayoutIntegrationInlineContentBuilder.cpp 2021-05-15 19:50:54 UTC (rev 277545)
@@ -30,6 +30,7 @@
#include "BidiResolver.h"
#include "InlineFormattingContext.h"
+#include "InlineFormattingQuirks.h"
#include "InlineFormattingState.h"
#include "LayoutBoxGeometry.h"
#include "LayoutIntegrationBoxTree.h"