Title: [268976] trunk/Source/WebCore
Revision
268976
Author
[email protected]
Date
2020-10-26 06:58:58 -0700 (Mon, 26 Oct 2020)

Log Message

[LFC][Integration] Allow all replaced elements
https://bugs.webkit.org/show_bug.cgi?id=218074

Reviewed by Zalan Bujtas.

Add a #define to allow all RenderReplaced in modern line layout.
Also add one for inline-blocks.

Both are disabled for now.

* layout/integration/LayoutIntegrationBoxTree.cpp:
(WebCore::LayoutIntegration::BoxTree::buildTree):
* layout/integration/LayoutIntegrationCoverage.cpp:
(WebCore::LayoutIntegration::canUseForChild):
(WebCore::LayoutIntegration::canUseForLineLayoutWithReason):
* layout/integration/LayoutIntegrationLineLayout.cpp:
(WebCore::LayoutIntegration::LineLayout::containing):
(WebCore::LayoutIntegration::LineLayout::hitTest):

Implement hit testing.

* rendering/RenderBlockFlow.cpp:
(WebCore::RenderBlockFlow::layoutLFCLines):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (268975 => 268976)


--- trunk/Source/WebCore/ChangeLog	2020-10-26 13:48:46 UTC (rev 268975)
+++ trunk/Source/WebCore/ChangeLog	2020-10-26 13:58:58 UTC (rev 268976)
@@ -1,3 +1,29 @@
+2020-10-26  Antti Koivisto  <[email protected]>
+
+        [LFC][Integration] Allow all replaced elements
+        https://bugs.webkit.org/show_bug.cgi?id=218074
+
+        Reviewed by Zalan Bujtas.
+
+        Add a #define to allow all RenderReplaced in modern line layout.
+        Also add one for inline-blocks.
+
+        Both are disabled for now.
+
+        * layout/integration/LayoutIntegrationBoxTree.cpp:
+        (WebCore::LayoutIntegration::BoxTree::buildTree):
+        * layout/integration/LayoutIntegrationCoverage.cpp:
+        (WebCore::LayoutIntegration::canUseForChild):
+        (WebCore::LayoutIntegration::canUseForLineLayoutWithReason):
+        * layout/integration/LayoutIntegrationLineLayout.cpp:
+        (WebCore::LayoutIntegration::LineLayout::containing):
+        (WebCore::LayoutIntegration::LineLayout::hitTest):
+
+        Implement hit testing.
+
+        * rendering/RenderBlockFlow.cpp:
+        (WebCore::RenderBlockFlow::layoutLFCLines):
+
 2020-10-26  Xabier Rodriguez Calvar  <[email protected]>
 
         [EME] Fix casts and sizes printing

Modified: trunk/Source/WebCore/layout/integration/LayoutIntegrationBoxTree.cpp (268975 => 268976)


--- trunk/Source/WebCore/layout/integration/LayoutIntegrationBoxTree.cpp	2020-10-26 13:48:46 UTC (rev 268975)
+++ trunk/Source/WebCore/layout/integration/LayoutIntegrationBoxTree.cpp	2020-10-26 13:58:58 UTC (rev 268976)
@@ -71,10 +71,12 @@
             clonedStyle.setFloating(Float::No);
             clonedStyle.setPosition(PositionType::Static);
             childBox = makeUnique<Layout::LineBreakBox>(downcast<RenderLineBreak>(childRenderer).isWBR(), WTFMove(clonedStyle));
-        } else if (is<RenderImage>(childRenderer)) {
-            auto& image = downcast<RenderImage>(childRenderer);
-            auto clonedStyle = RenderStyle::clone(image.style());
-            childBox = makeUnique<Layout::ReplacedBox>(Layout::Box::ElementAttributes { Layout::Box::ElementType::Image }, WTFMove(clonedStyle));
+        } else if (is<RenderReplaced>(childRenderer)) {
+            auto clonedStyle = RenderStyle::clone(childRenderer.style());
+            childBox = makeUnique<Layout::ReplacedBox>(Layout::Box::ElementAttributes { is<RenderImage>(childRenderer) ? Layout::Box::ElementType::Image : Layout::Box::ElementType::GenericElement }, WTFMove(clonedStyle));
+        } else if (is<RenderBlock>(childRenderer)) {
+            auto clonedStyle = RenderStyle::clone(childRenderer.style());
+            childBox = makeUnique<Layout::ReplacedBox>(Layout::Box::ElementAttributes { Layout::Box::ElementType::GenericElement }, WTFMove(clonedStyle));
         }
         ASSERT(childBox);
 

Modified: trunk/Source/WebCore/layout/integration/LayoutIntegrationCoverage.cpp (268975 => 268976)


--- trunk/Source/WebCore/layout/integration/LayoutIntegrationCoverage.cpp	2020-10-26 13:48:46 UTC (rev 268975)
+++ trunk/Source/WebCore/layout/integration/LayoutIntegrationCoverage.cpp	2020-10-26 13:58:58 UTC (rev 268976)
@@ -42,7 +42,9 @@
 
 #if ENABLE(LAYOUT_FORMATTING_CONTEXT)
 
-#define ALLOW_INLINE_IMAGES 0
+#define ALLOW_IMAGES 0
+#define ALLOW_ALL_REPLACED 0
+#define ALLOW_INLINE_BLOCK 0
 
 #ifndef NDEBUG
 #define SET_REASON_AND_RETURN_IF_NEEDED(reason, reasons, includeReasons) { \
@@ -245,6 +247,76 @@
     return reasons;
 }
 
+static OptionSet<AvoidanceReason> canUseForChild(const RenderObject& child, IncludeReasons includeReasons)
+{
+    OptionSet<AvoidanceReason> reasons;
+    if (child.selectionState() != RenderObject::HighlightState::None)
+        SET_REASON_AND_RETURN_IF_NEEDED(FlowChildIsSelected, reasons, includeReasons);
+    if (is<RenderText>(child)) {
+        const auto& renderText = downcast<RenderText>(child);
+        if (renderText.textNode() && !renderText.document().markers().markersFor(*renderText.textNode()).isEmpty())
+            SET_REASON_AND_RETURN_IF_NEEDED(FlowIncludesDocumentMarkers, reasons, includeReasons);
+        return reasons;
+    }
+
+    if (is<RenderLineBreak>(child))
+        return reasons;
+
+#if ALLOW_IMAGES || ALLOW_ALL_REPLACED
+    if (is<RenderReplaced>(child)) {
+        auto& replaced = downcast<RenderReplaced>(child);
+        if (replaced.isFloating() || replaced.isPositioned())
+            SET_REASON_AND_RETURN_IF_NEEDED(FlowHasNonSupportedChild, reasons, includeReasons)
+
+        if (replaced.isSVGRoot())
+            SET_REASON_AND_RETURN_IF_NEEDED(FlowHasNonSupportedChild, reasons, includeReasons);
+
+        auto& style = replaced.style();
+        if (style.verticalAlign() != VerticalAlign::Baseline)
+            SET_REASON_AND_RETURN_IF_NEEDED(FlowHasNonSupportedChild, reasons, includeReasons);
+        if (style.width().isPercent() || style.height().isPercent())
+            SET_REASON_AND_RETURN_IF_NEEDED(FlowHasNonSupportedChild, reasons, includeReasons);
+        if (style.objectFit() != RenderStyle::initialObjectFit())
+            SET_REASON_AND_RETURN_IF_NEEDED(FlowHasNonSupportedChild, reasons, includeReasons);
+
+        if (is<RenderImage>(replaced)) {
+            auto& image = downcast<RenderImage>(replaced);
+            if (image.imageMap())
+                SET_REASON_AND_RETURN_IF_NEEDED(FlowHasNonSupportedChild, reasons, includeReasons);
+            return reasons;
+        }
+#if !ALLOW_ALL_REPLACED
+        SET_REASON_AND_RETURN_IF_NEEDED(FlowHasNonSupportedChild, reasons, includeReasons);
+#endif
+        return reasons;
+    }
+#endif
+
+#if ALLOW_INLINE_BLOCK
+    if (is<RenderBlock>(child)) {
+        auto& block = downcast<RenderBlock>(child);
+        if (!block.isReplaced() || !block.isInline())
+            SET_REASON_AND_RETURN_IF_NEEDED(FlowHasNonSupportedChild, reasons, includeReasons)
+        if (block.isFloating() || block.isPositioned())
+            SET_REASON_AND_RETURN_IF_NEEDED(FlowHasNonSupportedChild, reasons, includeReasons)
+        if (block.isRubyRun())
+            SET_REASON_AND_RETURN_IF_NEEDED(FlowHasNonSupportedChild, reasons, includeReasons);
+
+        auto& style = block.style();
+        if (style.verticalAlign() != VerticalAlign::Baseline)
+            SET_REASON_AND_RETURN_IF_NEEDED(FlowHasNonSupportedChild, reasons, includeReasons);
+        if (style.width().isPercent() || style.height().isPercent())
+            SET_REASON_AND_RETURN_IF_NEEDED(FlowHasNonSupportedChild, reasons, includeReasons);
+
+        return reasons;
+    }
+#endif
+
+    SET_REASON_AND_RETURN_IF_NEEDED(FlowHasNonSupportedChild, reasons, includeReasons);
+    return reasons;
+}
+
+
 OptionSet<AvoidanceReason> canUseForLineLayoutWithReason(const RenderBlockFlow& flow, IncludeReasons includeReasons)
 {
     OptionSet<AvoidanceReason> reasons;
@@ -309,35 +381,9 @@
     // This currently covers <blockflow>#text</blockflow>, <blockflow>#text<br></blockflow> and mutiple (sibling) RenderText cases.
     // The <blockflow><inline>#text</inline></blockflow> case is also popular and should be relatively easy to cover.
     for (const auto* child = flow.firstChild(); child; child = child->nextSibling()) {
-        if (child->selectionState() != RenderObject::HighlightState::None)
-            SET_REASON_AND_RETURN_IF_NEEDED(FlowChildIsSelected, reasons, includeReasons);
-        if (is<RenderText>(*child)) {
-            const auto& renderText = downcast<RenderText>(*child);
-            if (renderText.textNode() && !renderText.document().markers().markersFor(*renderText.textNode()).isEmpty())
-                SET_REASON_AND_RETURN_IF_NEEDED(FlowIncludesDocumentMarkers, reasons, includeReasons);
-            continue;
-        }
-        if (is<RenderLineBreak>(*child))
-            continue;
-#if ALLOW_INLINE_IMAGES
-        if (is<RenderImage>(*child)) {
-            auto& image = downcast<RenderImage>(*child);
-            if (image.imageMap())
-                SET_REASON_AND_RETURN_IF_NEEDED(FlowHasNonSupportedChild, reasons, includeReasons);                
-            if (image.isFloating() || image.isPositioned())
-                SET_REASON_AND_RETURN_IF_NEEDED(FlowHasNonSupportedChild, reasons, includeReasons);
-            auto& style = image.style();
-            if (style.verticalAlign() != VerticalAlign::Baseline)
-                SET_REASON_AND_RETURN_IF_NEEDED(FlowHasNonSupportedChild, reasons, includeReasons);
-            if (style.width().isPercent() || style.height().isPercent())
-                SET_REASON_AND_RETURN_IF_NEEDED(FlowHasNonSupportedChild, reasons, includeReasons);
-            if (style.objectFit() != RenderStyle::initialObjectFit())
-                SET_REASON_AND_RETURN_IF_NEEDED(FlowHasNonSupportedChild, reasons, includeReasons);
-            continue;
-        }
-#endif
-        SET_REASON_AND_RETURN_IF_NEEDED(FlowHasNonSupportedChild, reasons, includeReasons);
-        break;
+        auto childReasons = canUseForChild(*child, includeReasons);
+        if (childReasons)
+            ADD_REASONS_AND_RETURN_IF_NEEDED(childReasons, reasons, includeReasons);
     }
     auto styleReasons = canUseForStyle(flow.style(), includeReasons);
     if (styleReasons)

Modified: trunk/Source/WebCore/layout/integration/LayoutIntegrationLineLayout.cpp (268975 => 268976)


--- trunk/Source/WebCore/layout/integration/LayoutIntegrationLineLayout.cpp	2020-10-26 13:48:46 UTC (rev 268975)
+++ trunk/Source/WebCore/layout/integration/LayoutIntegrationLineLayout.cpp	2020-10-26 13:58:58 UTC (rev 268976)
@@ -68,8 +68,11 @@
 
 LineLayout* LineLayout::containing(RenderObject& renderer)
 {
-    if (!is<RenderText>(renderer) && !is<RenderLineBreak>(renderer) && !is<RenderImage>(renderer))
+    if (!renderer.isInline())
         return nullptr;
+
+    if (renderer.isReplica())
+        return nullptr;
     
     if (auto* parent = renderer.parent()) {
         if (is<RenderBlockFlow>(*parent))
@@ -519,9 +522,23 @@
 
         auto& renderer = m_boxTree.rendererForLayoutBox(run.layoutBox());
 
-        renderer.updateHitTestResult(result, locationInContainer.point() - toLayoutSize(accumulatedOffset));
-        if (result.addNodeToListBasedTestResult(renderer.nodeForHitTest(), request, locationInContainer, runRect) == HitTestProgress::Stop)
-            return true;
+        if (is<RenderText>(renderer)) {
+            renderer.updateHitTestResult(result, locationInContainer.point() - toLayoutSize(accumulatedOffset));
+            if (result.addNodeToListBasedTestResult(renderer.nodeForHitTest(), request, locationInContainer, runRect) == HitTestProgress::Stop)
+                return true;
+            continue;
+        }
+
+        if (is<RenderBox>(renderer)) {
+            auto& renderBox = downcast<RenderBox>(renderer);
+            if (renderBox.hasSelfPaintingLayer())
+                continue;
+            
+            if (renderBox.hitTest(request, result, locationInContainer, accumulatedOffset)) {
+                renderBox.updateHitTestResult(result, locationInContainer.point() - toLayoutSize(accumulatedOffset));
+                return true;
+            }
+        }
     }
 
     return false;

Modified: trunk/Source/WebCore/rendering/RenderBlockFlow.cpp (268975 => 268976)


--- trunk/Source/WebCore/rendering/RenderBlockFlow.cpp	2020-10-26 13:48:46 UTC (rev 268975)
+++ trunk/Source/WebCore/rendering/RenderBlockFlow.cpp	2020-10-26 13:58:58 UTC (rev 268976)
@@ -3676,6 +3676,14 @@
             layoutFormattingContextLineLayout.updateReplacedDimensions(replaced);
             continue;
         }
+        if (is<RenderBlock>(renderer)) {
+            auto& block = downcast<RenderBlock>(renderer);
+            block.layoutIfNeeded();
+            // FIXME: Taking the same path as replaced for now.
+            layoutFormattingContextLineLayout.updateReplacedDimensions(block);
+            continue;
+        }
+
         renderer.clearNeedsLayout();
     }
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to