⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 268976 in webkit


Ignore:
Timestamp:
Oct 26, 2020, 6:58:58 AM (6 years ago)
Author:
Antti Koivisto
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):

Location:
trunk/Source/WebCore
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r268975 r268976  
     12020-10-26  Antti Koivisto  <antti@apple.com>
     2
     3        [LFC][Integration] Allow all replaced elements
     4        https://bugs.webkit.org/show_bug.cgi?id=218074
     5
     6        Reviewed by Zalan Bujtas.
     7
     8        Add a #define to allow all RenderReplaced in modern line layout.
     9        Also add one for inline-blocks.
     10
     11        Both are disabled for now.
     12
     13        * layout/integration/LayoutIntegrationBoxTree.cpp:
     14        (WebCore::LayoutIntegration::BoxTree::buildTree):
     15        * layout/integration/LayoutIntegrationCoverage.cpp:
     16        (WebCore::LayoutIntegration::canUseForChild):
     17        (WebCore::LayoutIntegration::canUseForLineLayoutWithReason):
     18        * layout/integration/LayoutIntegrationLineLayout.cpp:
     19        (WebCore::LayoutIntegration::LineLayout::containing):
     20        (WebCore::LayoutIntegration::LineLayout::hitTest):
     21
     22        Implement hit testing.
     23
     24        * rendering/RenderBlockFlow.cpp:
     25        (WebCore::RenderBlockFlow::layoutLFCLines):
     26
    1272020-10-26  Xabier Rodriguez Calvar  <calvaris@igalia.com>
    228
  • trunk/Source/WebCore/layout/integration/LayoutIntegrationBoxTree.cpp

    r268798 r268976  
    7272            clonedStyle.setPosition(PositionType::Static);
    7373            childBox = makeUnique<Layout::LineBreakBox>(downcast<RenderLineBreak>(childRenderer).isWBR(), WTFMove(clonedStyle));
    74         } else if (is<RenderImage>(childRenderer)) {
    75             auto& image = downcast<RenderImage>(childRenderer);
    76             auto clonedStyle = RenderStyle::clone(image.style());
    77             childBox = makeUnique<Layout::ReplacedBox>(Layout::Box::ElementAttributes { Layout::Box::ElementType::Image }, WTFMove(clonedStyle));
     74        } else if (is<RenderReplaced>(childRenderer)) {
     75            auto clonedStyle = RenderStyle::clone(childRenderer.style());
     76            childBox = makeUnique<Layout::ReplacedBox>(Layout::Box::ElementAttributes { is<RenderImage>(childRenderer) ? Layout::Box::ElementType::Image : Layout::Box::ElementType::GenericElement }, WTFMove(clonedStyle));
     77        } else if (is<RenderBlock>(childRenderer)) {
     78            auto clonedStyle = RenderStyle::clone(childRenderer.style());
     79            childBox = makeUnique<Layout::ReplacedBox>(Layout::Box::ElementAttributes { Layout::Box::ElementType::GenericElement }, WTFMove(clonedStyle));
    7880        }
    7981        ASSERT(childBox);
  • trunk/Source/WebCore/layout/integration/LayoutIntegrationCoverage.cpp

    r268804 r268976  
    4343#if ENABLE(LAYOUT_FORMATTING_CONTEXT)
    4444
    45 #define ALLOW_INLINE_IMAGES 0
     45#define ALLOW_IMAGES 0
     46#define ALLOW_ALL_REPLACED 0
     47#define ALLOW_INLINE_BLOCK 0
    4648
    4749#ifndef NDEBUG
    … …  
    246248}
    247249
     250static OptionSet<AvoidanceReason> canUseForChild(const RenderObject& child, IncludeReasons includeReasons)
     251{
     252    OptionSet<AvoidanceReason> reasons;
     253    if (child.selectionState() != RenderObject::HighlightState::None)
     254        SET_REASON_AND_RETURN_IF_NEEDED(FlowChildIsSelected, reasons, includeReasons);
     255    if (is<RenderText>(child)) {
     256        const auto& renderText = downcast<RenderText>(child);
     257        if (renderText.textNode() && !renderText.document().markers().markersFor(*renderText.textNode()).isEmpty())
     258            SET_REASON_AND_RETURN_IF_NEEDED(FlowIncludesDocumentMarkers, reasons, includeReasons);
     259        return reasons;
     260    }
     261
     262    if (is<RenderLineBreak>(child))
     263        return reasons;
     264
     265#if ALLOW_IMAGES || ALLOW_ALL_REPLACED
     266    if (is<RenderReplaced>(child)) {
     267        auto& replaced = downcast<RenderReplaced>(child);
     268        if (replaced.isFloating() || replaced.isPositioned())
     269            SET_REASON_AND_RETURN_IF_NEEDED(FlowHasNonSupportedChild, reasons, includeReasons)
     270
     271        if (replaced.isSVGRoot())
     272            SET_REASON_AND_RETURN_IF_NEEDED(FlowHasNonSupportedChild, reasons, includeReasons);
     273
     274        auto& style = replaced.style();
     275        if (style.verticalAlign() != VerticalAlign::Baseline)
     276            SET_REASON_AND_RETURN_IF_NEEDED(FlowHasNonSupportedChild, reasons, includeReasons);
     277        if (style.width().isPercent() || style.height().isPercent())
     278            SET_REASON_AND_RETURN_IF_NEEDED(FlowHasNonSupportedChild, reasons, includeReasons);
     279        if (style.objectFit() != RenderStyle::initialObjectFit())
     280            SET_REASON_AND_RETURN_IF_NEEDED(FlowHasNonSupportedChild, reasons, includeReasons);
     281
     282        if (is<RenderImage>(replaced)) {
     283            auto& image = downcast<RenderImage>(replaced);
     284            if (image.imageMap())
     285                SET_REASON_AND_RETURN_IF_NEEDED(FlowHasNonSupportedChild, reasons, includeReasons);
     286            return reasons;
     287        }
     288#if !ALLOW_ALL_REPLACED
     289        SET_REASON_AND_RETURN_IF_NEEDED(FlowHasNonSupportedChild, reasons, includeReasons);
     290#endif
     291        return reasons;
     292    }
     293#endif
     294
     295#if ALLOW_INLINE_BLOCK
     296    if (is<RenderBlock>(child)) {
     297        auto& block = downcast<RenderBlock>(child);
     298        if (!block.isReplaced() || !block.isInline())
     299            SET_REASON_AND_RETURN_IF_NEEDED(FlowHasNonSupportedChild, reasons, includeReasons)
     300        if (block.isFloating() || block.isPositioned())
     301            SET_REASON_AND_RETURN_IF_NEEDED(FlowHasNonSupportedChild, reasons, includeReasons)
     302        if (block.isRubyRun())
     303            SET_REASON_AND_RETURN_IF_NEEDED(FlowHasNonSupportedChild, reasons, includeReasons);
     304
     305        auto& style = block.style();
     306        if (style.verticalAlign() != VerticalAlign::Baseline)
     307            SET_REASON_AND_RETURN_IF_NEEDED(FlowHasNonSupportedChild, reasons, includeReasons);
     308        if (style.width().isPercent() || style.height().isPercent())
     309            SET_REASON_AND_RETURN_IF_NEEDED(FlowHasNonSupportedChild, reasons, includeReasons);
     310
     311        return reasons;
     312    }
     313#endif
     314
     315    SET_REASON_AND_RETURN_IF_NEEDED(FlowHasNonSupportedChild, reasons, includeReasons);
     316    return reasons;
     317}
     318
     319
    248320OptionSet<AvoidanceReason> canUseForLineLayoutWithReason(const RenderBlockFlow& flow, IncludeReasons includeReasons)
    249321{
    … …  
    310382    // The <blockflow><inline>#text</inline></blockflow> case is also popular and should be relatively easy to cover.
    311383    for (const auto* child = flow.firstChild(); child; child = child->nextSibling()) {
    312         if (child->selectionState() != RenderObject::HighlightState::None)
    313             SET_REASON_AND_RETURN_IF_NEEDED(FlowChildIsSelected, reasons, includeReasons);
    314         if (is<RenderText>(*child)) {
    315             const auto& renderText = downcast<RenderText>(*child);
    316             if (renderText.textNode() && !renderText.document().markers().markersFor(*renderText.textNode()).isEmpty())
    317                 SET_REASON_AND_RETURN_IF_NEEDED(FlowIncludesDocumentMarkers, reasons, includeReasons);
    318             continue;
    319         }
    320         if (is<RenderLineBreak>(*child))
    321             continue;
    322 #if ALLOW_INLINE_IMAGES
    323         if (is<RenderImage>(*child)) {
    324             auto& image = downcast<RenderImage>(*child);
    325             if (image.imageMap())
    326                 SET_REASON_AND_RETURN_IF_NEEDED(FlowHasNonSupportedChild, reasons, includeReasons);               
    327             if (image.isFloating() || image.isPositioned())
    328                 SET_REASON_AND_RETURN_IF_NEEDED(FlowHasNonSupportedChild, reasons, includeReasons);
    329             auto& style = image.style();
    330             if (style.verticalAlign() != VerticalAlign::Baseline)
    331                 SET_REASON_AND_RETURN_IF_NEEDED(FlowHasNonSupportedChild, reasons, includeReasons);
    332             if (style.width().isPercent() || style.height().isPercent())
    333                 SET_REASON_AND_RETURN_IF_NEEDED(FlowHasNonSupportedChild, reasons, includeReasons);
    334             if (style.objectFit() != RenderStyle::initialObjectFit())
    335                 SET_REASON_AND_RETURN_IF_NEEDED(FlowHasNonSupportedChild, reasons, includeReasons);
    336             continue;
    337         }
    338 #endif
    339         SET_REASON_AND_RETURN_IF_NEEDED(FlowHasNonSupportedChild, reasons, includeReasons);
    340         break;
     384        auto childReasons = canUseForChild(*child, includeReasons);
     385        if (childReasons)
     386            ADD_REASONS_AND_RETURN_IF_NEEDED(childReasons, reasons, includeReasons);
    341387    }
    342388    auto styleReasons = canUseForStyle(flow.style(), includeReasons);
  • trunk/Source/WebCore/layout/integration/LayoutIntegrationLineLayout.cpp

    r268895 r268976  
    6969LineLayout* LineLayout::containing(RenderObject& renderer)
    7070{
    71     if (!is<RenderText>(renderer) && !is<RenderLineBreak>(renderer) && !is<RenderImage>(renderer))
     71    if (!renderer.isInline())
     72        return nullptr;
     73
     74    if (renderer.isReplica())
    7275        return nullptr;
    7376   
    … …  
    520523        auto& renderer = m_boxTree.rendererForLayoutBox(run.layoutBox());
    521524
    522         renderer.updateHitTestResult(result, locationInContainer.point() - toLayoutSize(accumulatedOffset));
    523         if (result.addNodeToListBasedTestResult(renderer.nodeForHitTest(), request, locationInContainer, runRect) == HitTestProgress::Stop)
    524             return true;
     525        if (is<RenderText>(renderer)) {
     526            renderer.updateHitTestResult(result, locationInContainer.point() - toLayoutSize(accumulatedOffset));
     527            if (result.addNodeToListBasedTestResult(renderer.nodeForHitTest(), request, locationInContainer, runRect) == HitTestProgress::Stop)
     528                return true;
     529            continue;
     530        }
     531
     532        if (is<RenderBox>(renderer)) {
     533            auto& renderBox = downcast<RenderBox>(renderer);
     534            if (renderBox.hasSelfPaintingLayer())
     535                continue;
     536           
     537            if (renderBox.hitTest(request, result, locationInContainer, accumulatedOffset)) {
     538                renderBox.updateHitTestResult(result, locationInContainer.point() - toLayoutSize(accumulatedOffset));
     539                return true;
     540            }
     541        }
    525542    }
    526543
  • trunk/Source/WebCore/rendering/RenderBlockFlow.cpp

    r268951 r268976  
    36773677            continue;
    36783678        }
     3679        if (is<RenderBlock>(renderer)) {
     3680            auto& block = downcast<RenderBlock>(renderer);
     3681            block.layoutIfNeeded();
     3682            // FIXME: Taking the same path as replaced for now.
     3683            layoutFormattingContextLineLayout.updateReplacedDimensions(block);
     3684            continue;
     3685        }
     3686
    36793687        renderer.clearNeedsLayout();
    36803688    }
Note: See TracChangeset for help on using the changeset viewer.