Bug 130239 - min-width on a display:table-cell element takes precedence over a width on an outer display:table;table-layout:fixed; element if the outer width is set after initial render
Summary: min-width on a display:table-cell element takes precedence over a width on an...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: New Bugs (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: gur.trio
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2014-03-14 08:27 PDT by Phil
Modified: 2023-02-10 20:06 PST (History)
16 users (show)

See Also:


Attachments
Patch (7.00 KB, patch)
2014-05-07 01:47 PDT, Gurpreet
no flags Details | Formatted Diff | Diff
Patch (7.01 KB, patch)
2014-05-07 02:22 PDT, Gurpreet
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Phil 2014-03-14 08:27:35 PDT
In the following test case, the outer and inner elements should end up both being 100px wide, because of the width that is set on the outer element, however, because the width on the outer element is set after initial render, the min-width on the inner element wins and both inner and outer elements end up being 200px wide.

<style>
    #outer {
        display: table;
        table-layout: fixed;
    }
    #inner {
        display: table-cell;
        height: 50px;
        background-color: green;
        min-width: 200px;
    }
</style>

<div id="outer">
    <div id="inner"></div>
</div>

<script>
    window.onload = function() {
        outer = document.getElementById('outer');
        outer.style.width = '100px';
    };
</script>

The following actions can be taken to work around the bug:
1. set the outer element's width in the stylesheet, or inline style, instead of setting the width after initial render
2. after setting the width on the outer element, hiding and showing it by setting display to "none" and then back to "table" will cause it to refresh and layout properly.

This bug is reproducible in the latest webkit nightly (March 7, 2014) and in the latest versions of Safari and Chrome.
Comment 1 Gurpreet 2014-05-07 01:47:30 PDT
Created attachment 230978 [details]
Patch
Comment 2 Gurpreet 2014-05-07 02:22:59 PDT
Created attachment 230979 [details]
Patch
Comment 3 Gurpreet 2014-05-07 04:21:19 PDT
Please review. Thanks.
Comment 4 Phil 2014-05-14 08:21:24 PDT
Here's an additional twist on what appears to be the same issue.  This time there is no min-width involved, just  a table/table-cell combo with table-layout:fixed and long non-wrapping text inside, but the symptom is the same - setting the width dynamically does not update the width of the outer element.  It always expands to include the width of the text, unless a refresh is triggered by toggling some style (display works) on a timer.


<style>
    #table {
        display: table;
        table-layout: fixed;
    }
    #cell {
        display: table-cell;
        white-space: nowrap;
        overflow: hidden;
    }
</style>

<div id="table">
    <div id="cell">Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</div>
</div>

<script>
    window.onload = function() {
        table = document.getElementById('table');

        table.style.width = '50px';

        // workaround:
//        table.style.display = 'none';
//        setTimeout(function() {
//            table.style.display = '';
//        });
    };
</script>
Comment 5 gur.trio 2014-05-14 21:54:24 PDT
Hi Phil. The latest content which you mentioned is also working with this patch right?
Comment 6 Gurpreet 2014-05-20 00:13:43 PDT
Hi Simon/Darin please review.
Comment 7 Jarred Nicholls 2014-05-23 20:00:22 PDT
Comment on attachment 230979 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=230979&action=review

> Source/WebCore/rendering/RenderTable.cpp:105
> +    bool fixedTableLayout = oldStyle ? oldStyle->isFixedTableLayout() : false;

May as well move this variable down to be above the if() that uses it.
Comment 8 Gurpreet 2014-05-25 22:59:06 PDT
(In reply to comment #7)
> (From update of attachment 230979 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=230979&action=review
> 
> > Source/WebCore/rendering/RenderTable.cpp:105
> > +    bool fixedTableLayout = oldStyle ? oldStyle->isFixedTableLayout() : false;
> 
> May as well move this variable down to be above the if() that uses it.

Is this required? Earlier also the variable was defined at the same place.
Comment 9 Gurpreet 2014-06-10 05:37:53 PDT
Hi. Its been more than and no one reviewed this. Please review. Its already landed on blink https://codereview.chromium.org/264283002.
Comment 10 Gurpreet 2014-08-28 04:04:36 PDT
Hello. Please review.
Comment 11 Darin Adler 2014-08-28 09:41:02 PDT
Hyatt, could you take a look? Do you agree this is correct and the correct approach?
Comment 12 Michael Catanzaro 2016-09-17 07:16:12 PDT
Comment on attachment 230979 [details]
Patch

Hi,

Apologies that your patch was not reviewed in a timely manner. Since it's now quite old, I am removing it from the review request queue. Please consider rebasing it on trunk and resubmitting.

To increase the chances of getting a review, consider using 'Tools/Scripts/webkit-patch upload --suggest-reviewers' to CC reviewers who might be interested in this bug.
Comment 13 fred 2018-10-29 13:59:56 PDT
This issue still exists.
What must we do to get it addressed?
Comment 14 Darin Adler 2018-11-08 17:16:45 PST
Alan, Simon, can one of you look over this patch?
Comment 15 EWS 2023-02-10 20:05:54 PST
Committed 260143@main (b6c71868cecc): <https://commits.webkit.org/260143@main>

Reviewed commits have been landed. Closing PR #9924 and removing active labels.
Comment 16 Radar WebKit Bug Importer 2023-02-10 20:06:18 PST
<rdar://problem/105310280>