Changeset 270839 in webkit


Ignore:
Timestamp:
Dec 15, 2020, 7:07:04 AM (5 years ago)
Author:
Alan Bujtas
Message:

REGRESSION: apple.com sign-in page footer does not wrap, "Site Map" option renders offscreen.
https://bugs.webkit.org/show_bug.cgi?id=219880
<rdar://problem/72128221>

Reviewed by Antti Koivisto.

Source/WebCore:

Do not check the inline-block's style for wrapping. It's the parent's style that drives the content wrapping.

E.g. <div style="white-space: nowrap">some text<div style="display: inline-block; white-space: pre-wrap"></div></div>.
While the inline-block has pre-wrap which allows wrapping, the content lives in a nowrap context.

Test: fast/inline/inline-block-no-wrap.html

  • layout/inlineformatting/InlineContentBreaker.cpp:

(WebCore::Layout::InlineContentBreaker::processOverflowingContent const):
(WebCore::Layout::lastContentRunIndex): Deleted.
(WebCore::Layout::InlineContentBreaker::isContentWrappingAllowed const): Deleted.

  • layout/inlineformatting/InlineContentBreaker.h:

LayoutTests:

  • fast/inline/inline-block-no-wrap-expected.html: Added.
  • fast/inline/inline-block-no-wrap.html: Added.
Location:
trunk
Files:
2 added
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r270838 r270839  
     12020-12-15  Zalan Bujtas  <zalan@apple.com>
     2
     3        REGRESSION: apple.com sign-in page footer does not wrap, "Site Map" option renders offscreen.
     4        https://bugs.webkit.org/show_bug.cgi?id=219880
     5        <rdar://problem/72128221>
     6
     7        Reviewed by Antti Koivisto.
     8
     9        * fast/inline/inline-block-no-wrap-expected.html: Added.
     10        * fast/inline/inline-block-no-wrap.html: Added.
     11
    1122020-12-15  Martin Robinson  <mrobinson@webkit.org>
    213
  • trunk/Source/WebCore/ChangeLog

    r270838 r270839  
     12020-12-15  Zalan Bujtas  <zalan@apple.com>
     2
     3        REGRESSION: apple.com sign-in page footer does not wrap, "Site Map" option renders offscreen.
     4        https://bugs.webkit.org/show_bug.cgi?id=219880
     5        <rdar://problem/72128221>
     6
     7        Reviewed by Antti Koivisto.
     8
     9        Do not check the inline-block's style for wrapping. It's the parent's style that drives the content wrapping.
     10
     11        E.g. <div style="white-space: nowrap">some text<div style="display: inline-block; white-space: pre-wrap"></div></div>.
     12        While the inline-block has pre-wrap which allows wrapping, the content lives in a nowrap context.
     13
     14        Test: fast/inline/inline-block-no-wrap.html
     15
     16        * layout/inlineformatting/InlineContentBreaker.cpp:
     17        (WebCore::Layout::InlineContentBreaker::processOverflowingContent const):
     18        (WebCore::Layout::lastContentRunIndex): Deleted.
     19        (WebCore::Layout::InlineContentBreaker::isContentWrappingAllowed const): Deleted.
     20        * layout/inlineformatting/InlineContentBreaker.h:
     21
    1222020-12-15  Martin Robinson  <mrobinson@webkit.org>
    223
  • trunk/Source/WebCore/layout/inlineformatting/InlineContentBreaker.cpp

    r270715 r270839  
    8888}
    8989
    90 static inline Optional<size_t> lastContentRunIndex(const InlineContentBreaker::ContinuousContent& continuousContent)
    91 {
    92     auto& runs = continuousContent.runs();
    93     for (auto index = runs.size(); index--;) {
    94         if (runs[index].inlineItem.isText() || runs[index].inlineItem.isBox())
    95             return index;
    96     }
    97     return { };
    98 }
    99 
    10090static inline bool isWrappingAllowed(const RenderStyle& style)
    10191{
     
    114104    auto lastItemIndex = runList.size() - 1;
    115105    return isWrappingAllowed(runList[lastItemIndex].inlineItem.style()) ? makeOptional(lastItemIndex) : WTF::nullopt;
    116 }
    117 
    118 bool InlineContentBreaker::isContentWrappingAllowed(const ContinuousContent& continuousContent) const
    119 {
    120     // Use the last inline item with content (where we would be wrapping) to decide if content wrapping is allowed.
    121     auto& continuousRuns = continuousContent.runs();
    122     auto runIndex = lastContentRunIndex(continuousContent).valueOr(continuousRuns.size() - 1);
    123     return isWrappingAllowed(continuousRuns[runIndex].inlineItem.style());
    124106}
    125107
     
    236218        return { Result::Action::Keep, IsEndOfLine::No };
    237219    }
    238     // Now either wrap here or at an earlier position, or not wrap at all.
    239     if (isContentWrappingAllowed(continuousContent))
     220    // Now either wrap this content over to the next line or revert back to an earlier wrapping opportunity, or not wrap at all.
     221    auto shouldWrapThisContentToNextLine = [&] {
     222        // The individual runs in this continuous content don't break, let's check if we are allowed to wrap this content to next line (e.g. pre would prevent us from wrapping).
     223        auto& runs = continuousContent.runs();
     224        auto& lastInlineItem = runs.last().inlineItem;
     225        // Parent style drives the wrapping behavior here.
     226        // e.g. <div style="white-space: nowrap">some text<div style="display: inline-block; white-space: pre-wrap"></div></div>.
     227        // While the inline-block has pre-wrap which allows wrapping, the content lives in a nowrap context.
     228        if (lastInlineItem.isBox() || lastInlineItem.isInlineBoxStart() || lastInlineItem.isInlineBoxStart())
     229            return isWrappingAllowed(lastInlineItem.layoutBox().parent().style());
     230        if (lastInlineItem.isText()) {
     231            if (runs.size() == 1) {
     232                // Fast path for the most common case of an individual text item.
     233                return isWrappingAllowed(lastInlineItem.layoutBox().style());
     234            }
     235            for (auto& run : WTF::makeReversedRange(runs)) {
     236                auto& inlineItem = run.inlineItem;
     237                if (inlineItem.isInlineBoxStart() || inlineItem.isInlineBoxStart())
     238                    return isWrappingAllowed(inlineItem.layoutBox().parent().style());
     239                ASSERT(!inlineItem.isBox());
     240            }
     241            // This must be a set of individual text runs. We could just check the last item.
     242            return isWrappingAllowed(lastInlineItem.layoutBox().style());
     243        }
     244        ASSERT_NOT_REACHED();
     245        return true;
     246    };
     247    if (shouldWrapThisContentToNextLine())
    240248        return { Result::Action::Wrap, IsEndOfLine::Yes };
    241249    if (m_hasWrapOpportunityAtPreviousPosition)
  • trunk/Source/WebCore/layout/inlineformatting/InlineContentBreaker.h

    r270153 r270839  
    129129    WordBreakRule wordBreakBehavior(const RenderStyle&) const;
    130130    bool shouldKeepEndOfLineWhitespace(const ContinuousContent&) const;
    131     bool isContentWrappingAllowed(const ContinuousContent&) const;
    132131
    133132    bool n_hyphenationIsDisabled { false };
Note: See TracChangeset for help on using the changeset viewer.