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;