Bug 220946

Summary: [css-flexbox] REGRESSION(r266695): content inside a `<button>` inside a flex container has a height of `0` without a declared `min-height`
Product: WebKit Reporter: Devin Rousso <hi>
Component: Layout and RenderingAssignee: Sergio Villar Senin <svillar>
Status: RESOLVED FIXED    
Severity: Normal CC: bdakin, bfulgham, changseok, esprehn+autocc, ews-watchlist, glenn, hi, kondapallykalyan, pdr, simon.fraser, svillar, webkit-bug-importer, zalan
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
Bug Depends on: 210089    
Bug Blocks:    
Attachments:
Description Flags
[HTML] reduction
none
Rendering in different engines
none
Patch
none
Patch zalan: review+, zalan: commit-queue-

Description Devin Rousso 2021-01-25 13:59:25 PST
Created attachment 418333 [details]
[HTML] reduction

Inspecting the attached `reduction.html`, the Computed details sidebar panel shows a height of `0` for the child of the `<button>`.  After adding `min-height: 0;` to the parent of the `<button>` (which is the child of the `display: flex;`), however, the height then shows `50%` (`100px`) and the `background-color: red;` becomes visible.
Comment 1 Devin Rousso 2021-01-25 14:00:32 PST
<rdar://problem/73011184>
Comment 2 Sergio Villar Senin 2021-01-26 01:55:38 PST
Checking
Comment 3 Sergio Villar Senin 2021-01-26 02:12:18 PST
Created attachment 418383 [details]
Rendering in different engines

JFTR I'm attaching the rendering in 3 different engines, WebKit (pre-r266695), Chromium and Firefox. As you can see it's different in all of them, so it's unclear what's the right one.

Anyway I'll get back the old behaviour for buttons.
Comment 4 Sergio Villar Senin 2021-01-26 02:37:39 PST
(In reply to Sergio Villar Senin from comment #3)
> Created attachment 418383 [details]
> Rendering in different engines
> 
> JFTR I'm attaching the rendering in 3 different engines, WebKit
> (pre-r266695), Chromium and Firefox. As you can see it's different in all of
> them, so it's unclear what's the right one.

Ah the example contains a button, which has different UA styles in every single engine. Nevermind.
Comment 5 Devin Rousso 2021-01-26 10:04:30 PST
(In reply to Sergio Villar Senin from comment #4)
> (In reply to Sergio Villar Senin from comment #3)
> > Created attachment 418383 [details]
> > Rendering in different engines
> > 
> > JFTR I'm attaching the rendering in 3 different engines, WebKit (pre-r266695), Chromium and Firefox. As you can see it's different in all of them, so it's unclear what's the right one.
> 
> Ah the example contains a button, which has different UA styles in every  single engine. Nevermind.

Sorry I should've clarified.  The issue is that the `background-color: red;` isn't shown after r266695 (unless you add a `min-height: 0;` to the parent of `<button>`).
Comment 6 Sergio Villar Senin 2021-01-28 01:46:46 PST
Created attachment 418631 [details]
Patch
Comment 7 Sergio Villar Senin 2021-01-28 01:47:59 PST
Zalan mind taking a look? You did the optimization so you'd likely be the best reviewer for this.
Comment 8 Sergio Villar Senin 2021-01-28 03:46:37 PST
Created attachment 418634 [details]
Patch
Comment 9 zalan 2021-01-28 19:35:13 PST
Comment on attachment 418634 [details]
Patch

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

> Source/WebCore/ChangeLog:14
> +        FlexibleBoxImpl's like RenderButton wrap their DOM children in anonymous blocks. Those anonymous blocks are

Is it really always the case? -and what exactly do you mean by DOM children. This is the render tree, we don't have DOM objects here.

> Source/WebCore/rendering/RenderFlexibleBox.cpp:1639
> +        auto* descendants = percentHeightDescendants();

I'd prefer writing it out like this
auto& descendants = *percentHeightDescendants();
so that if "descendants" is later used in this function no one starts null checking it.
Comment 10 Sergio Villar Senin 2021-01-29 01:42:25 PST
Comment on attachment 418634 [details]
Patch

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

>> Source/WebCore/ChangeLog:14
>> +        FlexibleBoxImpl's like RenderButton wrap their DOM children in anonymous blocks. Those anonymous blocks are
> 
> Is it really always the case? -and what exactly do you mean by DOM children. This is the render tree, we don't have DOM objects here.

It's badly explained indeed. I wanted to say that <button> is a FlexibleBoxImpl which wraps the <button> children in anonymous blocks. I should not have mixed the render objects with the dom ones in the same explanation.

>> Source/WebCore/rendering/RenderFlexibleBox.cpp:1639
>> +        auto* descendants = percentHeightDescendants();
> 
> I'd prefer writing it out like this
> auto& descendants = *percentHeightDescendants();
> so that if "descendants" is later used in this function no one starts null checking it.

OK.
Comment 11 Sergio Villar Senin 2021-01-29 02:01:36 PST
Committed r272054: <https://trac.webkit.org/changeset/272054>