Title: [269299] trunk/Source/WebCore
Revision
269299
Author
[email protected]
Date
2020-11-03 06:16:40 -0800 (Tue, 03 Nov 2020)

Log Message

[LFC][IFC] Use "isConsideredEmpty" instead of "isVisuallyEmpty"
https://bugs.webkit.org/show_bug.cgi?id=218475

Reviewed by Antti Koivisto.

In certain cases the line may look visually empty, but still considered non-empty when computing the line box geometry.
Use a more precise term to indicated whether the line is empty.

* layout/inlineformatting/InlineFormattingContextGeometry.cpp:
(WebCore::Layout::LineBoxBuilder::build):
(WebCore::Layout::LineBoxBuilder::constructInlineLevelBoxes):
* layout/inlineformatting/InlineFormattingContextQuirks.cpp:
(WebCore::Layout::InlineFormattingContext::Quirks::shouldInlineLevelBoxStretchLineBox const):
* layout/inlineformatting/InlineLine.cpp:
(WebCore::Layout::Line::initialize):
(WebCore::Layout::Line::removeTrailingTrimmableContent):
(WebCore::Layout::Line::append):
(WebCore::Layout::Line::appendTextContent):
(WebCore::Layout::Line::isRunConsideredEmpty const):
(WebCore::Layout::Line::isRunVisuallyNonEmpty const): Deleted.
* layout/inlineformatting/InlineLine.h:
(WebCore::Layout::Line::isConsideredEmpty const):
(WebCore::Layout::Line::isVisuallyEmpty const): Deleted.
* layout/inlineformatting/InlineLineBox.cpp:
(WebCore::Layout::LineBox::LineBox):
(WebCore::Layout::m_isConsideredEmpty):
(WebCore::Layout::m_isLineVisuallyEmpty): Deleted.
* layout/inlineformatting/InlineLineBox.h:
(WebCore::Layout::LineBox::isConsideredEmpty const):
(WebCore::Layout::LineBox::isLineVisuallyEmpty const): Deleted.
* layout/inlineformatting/InlineLineBuilder.cpp:
(WebCore::Layout::LineBuilder::layoutInlineContent):
(WebCore::Layout::LineBuilder::close):
(WebCore::Layout::LineBuilder::handleFloatsAndInlineContent):
* layout/inlineformatting/InlineLineBuilder.h:

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (269298 => 269299)


--- trunk/Source/WebCore/ChangeLog	2020-11-03 14:14:45 UTC (rev 269298)
+++ trunk/Source/WebCore/ChangeLog	2020-11-03 14:16:40 UTC (rev 269299)
@@ -1,5 +1,43 @@
 2020-11-03  Zalan Bujtas  <[email protected]>
 
+        [LFC][IFC] Use "isConsideredEmpty" instead of "isVisuallyEmpty"
+        https://bugs.webkit.org/show_bug.cgi?id=218475
+
+        Reviewed by Antti Koivisto.
+
+        In certain cases the line may look visually empty, but still considered non-empty when computing the line box geometry.
+        Use a more precise term to indicated whether the line is empty.
+
+        * layout/inlineformatting/InlineFormattingContextGeometry.cpp:
+        (WebCore::Layout::LineBoxBuilder::build):
+        (WebCore::Layout::LineBoxBuilder::constructInlineLevelBoxes):
+        * layout/inlineformatting/InlineFormattingContextQuirks.cpp:
+        (WebCore::Layout::InlineFormattingContext::Quirks::shouldInlineLevelBoxStretchLineBox const):
+        * layout/inlineformatting/InlineLine.cpp:
+        (WebCore::Layout::Line::initialize):
+        (WebCore::Layout::Line::removeTrailingTrimmableContent):
+        (WebCore::Layout::Line::append):
+        (WebCore::Layout::Line::appendTextContent):
+        (WebCore::Layout::Line::isRunConsideredEmpty const):
+        (WebCore::Layout::Line::isRunVisuallyNonEmpty const): Deleted.
+        * layout/inlineformatting/InlineLine.h:
+        (WebCore::Layout::Line::isConsideredEmpty const):
+        (WebCore::Layout::Line::isVisuallyEmpty const): Deleted.
+        * layout/inlineformatting/InlineLineBox.cpp:
+        (WebCore::Layout::LineBox::LineBox):
+        (WebCore::Layout::m_isConsideredEmpty):
+        (WebCore::Layout::m_isLineVisuallyEmpty): Deleted.
+        * layout/inlineformatting/InlineLineBox.h:
+        (WebCore::Layout::LineBox::isConsideredEmpty const):
+        (WebCore::Layout::LineBox::isLineVisuallyEmpty const): Deleted.
+        * layout/inlineformatting/InlineLineBuilder.cpp:
+        (WebCore::Layout::LineBuilder::layoutInlineContent):
+        (WebCore::Layout::LineBuilder::close):
+        (WebCore::Layout::LineBuilder::handleFloatsAndInlineContent):
+        * layout/inlineformatting/InlineLineBuilder.h:
+
+2020-11-03  Zalan Bujtas  <[email protected]>
+
         [LFC] showInlineTreeAndRuns should print the inline level boxes in visual order
         https://bugs.webkit.org/show_bug.cgi?id=218478
 

Modified: trunk/Source/WebCore/layout/inlineformatting/InlineFormattingContextGeometry.cpp (269298 => 269299)


--- trunk/Source/WebCore/layout/inlineformatting/InlineFormattingContextGeometry.cpp	2020-11-03 14:14:45 UTC (rev 269298)
+++ trunk/Source/WebCore/layout/inlineformatting/InlineFormattingContextGeometry.cpp	2020-11-03 14:16:40 UTC (rev 269299)
@@ -156,8 +156,8 @@
     auto& runs = lineContent.runs;
     auto lineLogicalWidth = lineContent.lineLogicalWidth;
     auto contentLogicalWidth = lineContent.lineContentLogicalWidth;
-    auto isLineVisuallyEmpty = lineContent.isLineVisuallyEmpty ? LineBox::IsLineVisuallyEmpty::Yes : LineBox::IsLineVisuallyEmpty::No;
-    auto lineBox = LineBox { contentLogicalWidth, isLineVisuallyEmpty };
+    auto isLineConsideredEmpty = lineContent.isLineConsideredEmpty ? LineBox::IsLineConsideredEmpty::Yes : LineBox::IsLineConsideredEmpty::No;
+    auto lineBox = LineBox { contentLogicalWidth, isLineConsideredEmpty };
 
     if (auto horizontalAlignmentOffset = Layout::horizontalAlignmentOffset(runs, rootBox().style().textAlign(), lineLogicalWidth, contentLogicalWidth, lineContent.isLastLineWithInlineContent))
         lineBox.setHorizontalAlignmentOffset(*horizontalAlignmentOffset);
@@ -208,7 +208,7 @@
         auto rootInlineBox = LineBox::InlineLevelBox::createRootInlineBox(rootBox(), horizontalAligmentOffset, lineBox.logicalWidth());
 
         auto lineHasImaginaryStrut = layoutState().inNoQuirksMode();
-        auto isInitiallyConsideredNonEmpty = !lineBox.isLineVisuallyEmpty() && lineHasImaginaryStrut;
+        auto isInitiallyConsideredNonEmpty = !lineBox.isConsideredEmpty() && lineHasImaginaryStrut;
         if (isInitiallyConsideredNonEmpty)
             rootInlineBox->setIsNonEmpty();
         setVerticalGeometryForInlineBox(*rootInlineBox);

Modified: trunk/Source/WebCore/layout/inlineformatting/InlineFormattingContextQuirks.cpp (269298 => 269299)


--- trunk/Source/WebCore/layout/inlineformatting/InlineFormattingContextQuirks.cpp	2020-11-03 14:14:45 UTC (rev 269298)
+++ trunk/Source/WebCore/layout/inlineformatting/InlineFormattingContextQuirks.cpp	2020-11-03 14:16:40 UTC (rev 269299)
@@ -50,7 +50,7 @@
         return true;
     // <br> in non-standard mode stretches the line box only when the line is empty.
     // e.g. <div><span><br></span></div> will stretch but <div>this will not stretch to 200px<span style="font-size: 200px;"><br></span></div>
-    return lineBox.isLineVisuallyEmpty();
+    return lineBox.isConsideredEmpty();
 }
 
 bool InlineFormattingContext::Quirks::hasSoftWrapOpportunityAtImage() const

Modified: trunk/Source/WebCore/layout/inlineformatting/InlineLine.cpp (269298 => 269299)


--- trunk/Source/WebCore/layout/inlineformatting/InlineLine.cpp	2020-11-03 14:14:45 UTC (rev 269298)
+++ trunk/Source/WebCore/layout/inlineformatting/InlineLine.cpp	2020-11-03 14:16:40 UTC (rev 269299)
@@ -60,11 +60,11 @@
 {
     m_horizontalConstraint = horizontalConstraint;
     m_contentLogicalWidth = { };
-    m_isVisuallyEmpty = true;
     m_runs.clear();
     m_trailingSoftHyphenWidth = { };
     m_trimmableTrailingContent.reset();
-    m_lineIsVisuallyEmptyBeforeTrimmableTrailingContent = { };
+    m_isConsideredEmpty = true;
+    m_isConsideredEmptyBeforeTrimmableTrailingContent = { };
 }
 
 void Line::removeCollapsibleContent()
@@ -141,19 +141,17 @@
 
     m_contentLogicalWidth -= m_trimmableTrailingContent.remove();
     // If we removed the first visible run on the line, we need to re-check the visibility status.
-    if (m_lineIsVisuallyEmptyBeforeTrimmableTrailingContent) {
-        // Just because the line was visually empty before the removed content, it does not necessarily mean it is still visually empty.
+    if (m_isConsideredEmptyBeforeTrimmableTrailingContent) {
+        // Just because the line was considered empty before the removed content, it does not necessarily mean it is still empty.
         // <span>  </span><span style="padding-left: 10px"></span>  <- non-empty
-        auto lineIsVisuallyEmpty = [&] {
+        m_isConsideredEmpty = [&] {
             for (auto& run : m_runs) {
-                if (isRunVisuallyNonEmpty(run))
+                if (!isRunConsideredEmpty(run))
                     return false;
             }
             return true;
-        };
-        // We could only go from visually non empty -> to visually empty. Trimmed runs should never make the line visible.
-        m_isVisuallyEmpty = lineIsVisuallyEmpty();
-        m_lineIsVisuallyEmptyBeforeTrimmableTrailingContent = { };
+        }();
+        m_isConsideredEmptyBeforeTrimmableTrailingContent = { };
     }
 }
 
@@ -230,9 +228,9 @@
     else
         ASSERT_NOT_REACHED();
 
-    // Check if this newly appended content makes the line visually non-empty.
-    if (m_isVisuallyEmpty && !m_runs.isEmpty() && isRunVisuallyNonEmpty(m_runs.last()))
-        m_isVisuallyEmpty = false;
+    // Check if this newly appended content makes the line non-empty.
+    if (m_isConsideredEmpty && !m_runs.isEmpty() && !isRunConsideredEmpty(m_runs.last()))
+        m_isConsideredEmpty = false;
 }
 
 void Line::appendNonBreakableSpace(const InlineItem& inlineItem, InlineLayoutUnit logicalLeft, InlineLayoutUnit logicalWidth)
@@ -306,7 +304,7 @@
         m_trimmableTrailingContent.addFullyTrimmableContent(m_runs.size() - 1, logicalWidth);
         // If we ever trim this content, we need to know if the line visibility state needs to be recomputed.
         if (m_trimmableTrailingContent.isEmpty())
-            m_lineIsVisuallyEmptyBeforeTrimmableTrailingContent = isVisuallyEmpty();
+            m_isConsideredEmptyBeforeTrimmableTrailingContent = isConsideredEmpty();
         return;
     }
     // Any non-whitespace, no-trimmable content resets the existing trimmable.
@@ -349,37 +347,37 @@
     m_runs.append({ inlineItem, contentLogicalWidth(), 0_lu });
 }
 
-bool Line::isRunVisuallyNonEmpty(const Run& run) const
+bool Line::isRunConsideredEmpty(const Run& run) const
 {
     if (run.isText())
-        return true;
+        return false;
 
     if (run.isLineBreak())
-        return false;
+        return true;
 
     // Note that this does not check whether the inline container has content. It simply checks if the container itself is considered non-empty.
     if (run.isInlineBoxStart() || run.isInlineBoxEnd()) {
         if (!run.logicalWidth())
-            return false;
-        // Margin does not make the container visually non-empty. Check if it has border or padding.
+            return true;
+        // Margin does not make the container non-empty only border or padding.
         auto& boxGeometry = formattingContext().geometryForBox(run.layoutBox());
-        if (run.isInlineBoxStart())
-            return boxGeometry.borderLeft() || (boxGeometry.paddingLeft() && boxGeometry.paddingLeft().value());
-        return boxGeometry.borderRight() || (boxGeometry.paddingRight() && boxGeometry.paddingRight().value());
+        auto hasBorderOrPadding = run.isInlineBoxStart() ? boxGeometry.borderLeft() || (boxGeometry.paddingLeft() && boxGeometry.paddingLeft().value())
+            : boxGeometry.borderRight() || (boxGeometry.paddingRight() && boxGeometry.paddingRight().value());
+        return !hasBorderOrPadding;
     }
 
     if (run.isBox()) {
         if (run.layoutBox().isReplacedBox())
-            return true;
+            return false;
         ASSERT(run.layoutBox().isInlineBlockBox() || run.layoutBox().isInlineTableBox());
-        return run.logicalWidth();
+        return !run.logicalWidth();
     }
 
     if (run.isWordBreakOpportunity())
-        return false;
+        return true;
 
     ASSERT_NOT_REACHED();
-    return false;
+    return true;
 }
 
 void Line::addTrailingHyphen(InlineLayoutUnit hyphenLogicalWidth)

Modified: trunk/Source/WebCore/layout/inlineformatting/InlineLine.h (269298 => 269299)


--- trunk/Source/WebCore/layout/inlineformatting/InlineLine.h	2020-11-03 14:14:45 UTC (rev 269298)
+++ trunk/Source/WebCore/layout/inlineformatting/InlineLine.h	2020-11-03 14:16:40 UTC (rev 269299)
@@ -46,7 +46,11 @@
 
     void append(const InlineItem&, InlineLayoutUnit logicalWidth);
 
-    bool isVisuallyEmpty() const { return m_isVisuallyEmpty; }
+    // <span></span> considered empty.
+    // <span><br></span> is considered empty.
+    // <span>text</span> is not considered empty.
+    // <span style="padding: 10px"></span> is not considered empty. 
+    bool isConsideredEmpty() const { return m_isConsideredEmpty; }
 
     InlineLayoutUnit horizontalConstraint() const { return m_horizontalConstraint; }
     InlineLayoutUnit contentLogicalWidth() const { return m_contentLogicalWidth; }
@@ -148,7 +152,7 @@
     void removeTrailingTrimmableContent();
     void visuallyCollapsePreWrapOverflowContent();
 
-    bool isRunVisuallyNonEmpty(const Run&) const;
+    bool isRunConsideredEmpty(const Run&) const;
     const InlineFormattingContext& formattingContext() const;
 
     struct TrimmableTrailingContent {
@@ -181,8 +185,8 @@
     InlineLayoutUnit m_horizontalConstraint { 0 };
     InlineLayoutUnit m_contentLogicalWidth { 0 };
     Optional<InlineLayoutUnit> m_trailingSoftHyphenWidth { 0 };
-    bool m_isVisuallyEmpty { true };
-    Optional<bool> m_lineIsVisuallyEmptyBeforeTrimmableTrailingContent;
+    bool m_isConsideredEmpty { true };
+    Optional<bool> m_isConsideredEmptyBeforeTrimmableTrailingContent;
 };
 
 inline void Line::TrimmableTrailingContent::reset()

Modified: trunk/Source/WebCore/layout/inlineformatting/InlineLineBox.cpp (269298 => 269299)


--- trunk/Source/WebCore/layout/inlineformatting/InlineLineBox.cpp	2020-11-03 14:14:45 UTC (rev 269298)
+++ trunk/Source/WebCore/layout/inlineformatting/InlineLineBox.cpp	2020-11-03 14:16:40 UTC (rev 269299)
@@ -63,9 +63,9 @@
     return verticalAlignment == VerticalAlign::Top || verticalAlignment == VerticalAlign::Bottom;
 }
 
-LineBox::LineBox(InlineLayoutUnit contentLogicalWidth, IsLineVisuallyEmpty isLineVisuallyEmpty)
+LineBox::LineBox(InlineLayoutUnit contentLogicalWidth, IsLineConsideredEmpty isLineConsideredEmpty)
     : m_logicalSize(contentLogicalWidth, { })
-    , m_isLineVisuallyEmpty(isLineVisuallyEmpty == IsLineVisuallyEmpty::Yes)
+    , m_isConsideredEmpty(isLineConsideredEmpty == IsLineConsideredEmpty::Yes)
 {
 }
 

Modified: trunk/Source/WebCore/layout/inlineformatting/InlineLineBox.h (269298 => 269299)


--- trunk/Source/WebCore/layout/inlineformatting/InlineLineBox.h	2020-11-03 14:14:45 UTC (rev 269298)
+++ trunk/Source/WebCore/layout/inlineformatting/InlineLineBox.h	2020-11-03 14:16:40 UTC (rev 269299)
@@ -128,8 +128,8 @@
         Type m_type { Type::InlineBox };
     };
 
-    enum class IsLineVisuallyEmpty { No, Yes };
-    LineBox(InlineLayoutUnit logicalWidth, IsLineVisuallyEmpty);
+    enum class IsLineConsideredEmpty { No, Yes };
+    LineBox(InlineLayoutUnit logicalWidth, IsLineConsideredEmpty);
 
     InlineLayoutUnit logicalWidth() const { return m_logicalSize.width(); }
     InlineLayoutUnit logicalHeight() const { return m_logicalSize.height(); }
@@ -136,7 +136,7 @@
     InlineLayoutSize logicalSize() const { return m_logicalSize; }
 
     Optional<InlineLayoutUnit> horizontalAlignmentOffset() const { return m_horizontalAlignmentOffset; }
-    bool isLineVisuallyEmpty() const { return m_isLineVisuallyEmpty; }
+    bool isConsideredEmpty() const { return m_isConsideredEmpty; }
 
     const InlineLevelBox& inlineLevelBoxForLayoutBox(const Box& layoutBox) const { return *m_inlineLevelBoxRectMap.get(&layoutBox); }
 
@@ -168,7 +168,7 @@
 private:
     InlineLayoutSize m_logicalSize;
     Optional<InlineLayoutUnit> m_horizontalAlignmentOffset;
-    bool m_isLineVisuallyEmpty { true };
+    bool m_isConsideredEmpty { true };
 
     std::unique_ptr<InlineLevelBox> m_rootInlineBox;
     InlineLevelBoxList m_nonRootInlineLevelBoxList;

Modified: trunk/Source/WebCore/layout/inlineformatting/InlineLineBuilder.cpp (269298 => 269299)


--- trunk/Source/WebCore/layout/inlineformatting/InlineLineBuilder.cpp	2020-11-03 14:14:45 UTC (rev 269298)
+++ trunk/Source/WebCore/layout/inlineformatting/InlineLineBuilder.cpp	2020-11-03 14:16:40 UTC (rev 269299)
@@ -276,7 +276,7 @@
         , lineLogicalTopLeft
         , m_line.horizontalConstraint()
         , m_line.contentLogicalWidth()
-        , m_line.isVisuallyEmpty()
+        , m_line.isConsideredEmpty()
         , isLastLine
         , m_line.runs()};
 }
@@ -360,7 +360,7 @@
     if (runsExpandHorizontally)
         m_line.applyRunExpansion();
     auto lineEndsWithHyphen = false;
-    if (!m_line.isVisuallyEmpty()) {
+    if (!m_line.isConsideredEmpty()) {
         ASSERT(!m_line.runs().isEmpty());
         auto& lastTextContent = m_line.runs().last().textContent();
         lineEndsWithHyphen = lastTextContent && lastTextContent->needsHyphen();
@@ -597,7 +597,7 @@
     auto& floatContent = lineCandidate.floatContent;
     // Check if this new content fits.
     auto availableWidth = m_line.availableWidth() - floatContent.intrusiveWidth();
-    auto isLineConsideredEmpty = m_line.isVisuallyEmpty() && !m_contentIsConstrainedByFloat;
+    auto isLineConsideredEmpty = m_line.isConsideredEmpty() && !m_contentIsConstrainedByFloat;
     auto lineStatus = InlineContentBreaker::LineStatus { availableWidth, m_line.trimmableTrailingWidth(), m_line.trailingSoftHyphenWidth(), m_line.isTrailingRunFullyTrimmable(), isLineConsideredEmpty };
     auto result = inlineContentBreaker.processInlineContent(continuousInlineContent, lineStatus);
     if (result.lastWrapOpportunityItem)

Modified: trunk/Source/WebCore/layout/inlineformatting/InlineLineBuilder.h (269298 => 269299)


--- trunk/Source/WebCore/layout/inlineformatting/InlineLineBuilder.h	2020-11-03 14:14:45 UTC (rev 269298)
+++ trunk/Source/WebCore/layout/inlineformatting/InlineLineBuilder.h	2020-11-03 14:16:40 UTC (rev 269299)
@@ -60,7 +60,7 @@
         InlineLayoutPoint logicalTopLeft;
         InlineLayoutUnit lineLogicalWidth;
         InlineLayoutUnit lineContentLogicalWidth;
-        bool isLineVisuallyEmpty { true };
+        bool isLineConsideredEmpty { true };
         bool isLastLineWithInlineContent { true };
         const Line::RunList& runs;
     };
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to