Changeset 264960 in webkit


Ignore:
Timestamp:
Jul 27, 2020 5:30:17 PM (4 years ago)
Author:
Alan Bujtas
Message:

Extension is sized incorrectly, content is cut off.
https://bugs.webkit.org/show_bug.cgi?id=214858
<rdar://problem/64135680>

Reviewed by Simon Fraser.

Source/WebCore:

Autosizing uses an 1px tall viewport to layout the content initially. When the document renderer's height is set to a percent value, this
1px tall viewport will drive the available height for the descendants and we pretty much end up with overflow content.
Autosizing takes the overflow into account when computing the final content size, however this overflow depends on the type of the layout context (e.g. flex vs. block).

Let's replace percent height values on the document renderer with the initial "height: auto".

Test: fast/dynamic/size-to-content-autosize-with-percent-document-height.html

  • page/FrameView.cpp:

(WebCore::FrameView::performSizeToContentAutoSize):

LayoutTests:

  • fast/dynamic/size-to-content-autosize-with-percent-document-height-expected.html: Added.
  • fast/dynamic/size-to-content-autosize-with-percent-document-height.html: Added.
Location:
trunk
Files:
2 added
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r264953 r264960  
     12020-07-27  Zalan Bujtas  <zalan@apple.com>
     2
     3        Extension is sized incorrectly, content is cut off.
     4        https://bugs.webkit.org/show_bug.cgi?id=214858
     5        <rdar://problem/64135680>
     6
     7        Reviewed by Simon Fraser.
     8
     9        * fast/dynamic/size-to-content-autosize-with-percent-document-height-expected.html: Added.
     10        * fast/dynamic/size-to-content-autosize-with-percent-document-height.html: Added.
     11
    1122020-07-27  Ryan Haddad  <ryanhaddad@apple.com>
    213
  • trunk/Source/WebCore/ChangeLog

    r264958 r264960  
     12020-07-27  Zalan Bujtas  <zalan@apple.com>
     2
     3        Extension is sized incorrectly, content is cut off.
     4        https://bugs.webkit.org/show_bug.cgi?id=214858
     5        <rdar://problem/64135680>
     6
     7        Reviewed by Simon Fraser.
     8
     9        Autosizing uses an 1px tall viewport to layout the content initially. When the document renderer's height is set to a percent value, this
     10        1px tall viewport will drive the available height for the descendants and we pretty much end up with overflow content.
     11        Autosizing takes the overflow into account when computing the final content size, however this overflow depends on the type of the layout context (e.g. flex vs. block).
     12
     13        Let's replace percent height values on the document renderer with the initial "height: auto".
     14
     15        Test: fast/dynamic/size-to-content-autosize-with-percent-document-height.html
     16
     17        * page/FrameView.cpp:
     18        (WebCore::FrameView::performSizeToContentAutoSize):
     19
    1202020-07-27  Chris Dumez  <cdumez@apple.com>
    221
  • trunk/Source/WebCore/page/FrameView.cpp

    r264627 r264960  
    34883488void FrameView::performSizeToContentAutoSize()
    34893489{
     3490    // Do the resizing twice. The first time is basically a rough calculation using the preferred width
     3491    // which may result in a height change during the second iteration.
     3492    // Let's ignore renderers with viewport units first and resolve these boxes during the second phase of the autosizing.
    34903493    LOG(Layout, "FrameView %p performSizeToContentAutoSize", this);
    3491 
    3492     auto* document = frame().document();
    3493     auto* renderView = document->renderView();
    3494 
     3494    ASSERT(frame().document() && frame().document()->renderView());
     3495
     3496    auto& document = *frame().document();
     3497    auto& renderView = *document.renderView();
     3498    auto layoutWithAdjustedStyleIfNeeded = [&] {
     3499        document.updateStyleIfNeeded();
     3500        if (auto* documentRenderer = downcast<RenderElement>(renderView.firstChild())) {
     3501            auto& style = documentRenderer->mutableStyle();
     3502            if (style.logicalHeight().isPercent()) {
     3503                // Percent height values on the document renderer when we don't really have a proper viewport size can
     3504                // result incorrect rendering in certain layout contexts (e.g flex).
     3505                style.setLogicalHeight({ });
     3506            }
     3507        }
     3508        document.updateLayout();
     3509    };
     3510
     3511    resetOverriddenViewportWidthForCSSViewportUnits();
    34953512    // Start from the minimum size and allow it to grow.
    34963513    auto minAutoSize = IntSize { 1, 1 };
    34973514    resize(minAutoSize);
    34983515    auto size = frameRect().size();
    3499     // Do the resizing twice. The first time is basically a rough calculation using the preferred width
    3500     // which may result in a height change during the second iteration.
    3501     // Let's ignore renderers with viewport units first and resolve these boxes during the second phase of the autosizing.
    3502     resetOverriddenViewportWidthForCSSViewportUnits();
    35033516    for (int i = 0; i < 2; i++) {
     3517        layoutWithAdjustedStyleIfNeeded();
    35043518        // Update various sizes including contentsSize, scrollHeight, etc.
    3505         document->updateLayoutIgnorePendingStylesheets();
    3506         auto newSize = IntSize { renderView->minPreferredLogicalWidth(), renderView->documentRect().height() };
     3519        auto newSize = IntSize { renderView.minPreferredLogicalWidth(), renderView.documentRect().height() };
    35073520
    35083521        // Check to see if a scrollbar is needed for a given dimension and
     
    35643577    }
    35653578    // All the resizing above may have invalidated style (for example if viewport units are being used).
    3566     document->updateStyleIfNeeded();
    35673579    // FIXME: Use the final layout's result as the content size (webkit.org/b/173561).
    3568     document->updateLayoutIgnorePendingStylesheets();
     3580    layoutWithAdjustedStyleIfNeeded();
    35693581    m_autoSizeContentSize = contentsSize();
    35703582}
Note: See TracChangeset for help on using the changeset viewer.