Bug 218211 - RenderStyle::resetPadding sets incorrect computed value (auto)
Summary: RenderStyle::resetPadding sets incorrect computed value (auto)
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Layout and Rendering (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: zalan
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2020-10-26 15:55 PDT by zalan
Modified: 2020-10-27 10:02 PDT (History)
12 users (show)

See Also:


Attachments
Patch (1.57 KB, patch)
2020-10-26 16:01 PDT, zalan
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description zalan 2020-10-26 15:55:02 PDT
should be 0
Comment 1 zalan 2020-10-26 16:01:33 PDT
Created attachment 412361 [details]
Patch
Comment 2 zalan 2020-10-26 16:02:17 PDT
Alternatively we could just set it to LengthBox(Fixed). Not sure what the preferred way is in RenderStyle.
Comment 3 Simon Fraser (smfr) 2020-10-26 16:33:35 PDT
Comment on attachment 412361 [details]
Patch

Is this testable with CSS reset?
Comment 4 Darin Adler 2020-10-26 17:09:40 PDT
Comment on attachment 412361 [details]
Patch

Does this have any effect?
Comment 5 zalan 2020-10-26 18:49:18 PDT
(In reply to Darin Adler from comment #4)
> Comment on attachment 412361 [details]
> Patch
> 
> Does this have any effect?
Absolutely.

This is how in IFC we normally resolve the computed padding value (e.g. padding left):
 valueForLength(style.paddingLeft(), containingBlockWidth);
Now for the (incorrect)auto specified value, valueForLength returns the containingBlockWidth as opposed to the expected, initial value of 0.
(I noticed this after enabling <select> element in IFC. RenderTheme calls style.resetPadding() on the select renderer and when IFC resolves the computed value, it sees a non-zero padding left/right/top/bottom).
Comment 6 zalan 2020-10-26 18:59:26 PDT
(In reply to Simon Fraser (smfr) from comment #3)
> Comment on attachment 412361 [details]
> Patch
> 
> Is this testable with CSS reset?
the unset? It does not seem to call resetPadding.
Comment 7 Antti Koivisto 2020-10-27 06:14:13 PDT
Comment on attachment 412361 [details]
Patch

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

> Source/WebCore/rendering/style/RenderStyle.h:1027
> +    void resetPadding() { SET_VAR(m_surroundData, padding, LengthBox(initialPadding().intValue())); }

Just initialPadding()?
Comment 8 zalan 2020-10-27 06:19:07 PDT
(In reply to Antti Koivisto from comment #7)
> Comment on attachment 412361 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=412361&action=review
> 
> > Source/WebCore/rendering/style/RenderStyle.h:1027
> > +    void resetPadding() { SET_VAR(m_surroundData, padding, LengthBox(initialPadding().intValue())); }
> 
> Just initialPadding()?
That was my initial attempt, but LengthBox does not take Length.
Comment 9 EWS 2020-10-27 06:28:45 PDT
Committed r269037: <https://trac.webkit.org/changeset/269037>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 412361 [details].
Comment 10 Radar WebKit Bug Importer 2020-10-27 06:29:21 PDT
<rdar://problem/70719975>
Comment 11 Darin Adler 2020-10-27 09:21:54 PDT
If this has an effect why isn’t a test case going from fail to pass?
Comment 12 zalan 2020-10-27 09:55:21 PDT
(In reply to Darin Adler from comment #11)
> If this has an effect why isn’t a test case going from fail to pass?
I should have been more specific. There's no effect on trunk yet because the rendering code is written in a way that the incorrect 'auto' value gets resolved to 0.   

LayoutUnit RenderBoxModelObject::computedCSSPadding(const Length& padding) const
{
    LayoutUnit w;
    if (padding.isPercentOrCalculated())
        w = containingBlockLogicalWidthForContent();
    return minimumValueForLength(padding, w);
}
minimumValueForLength() returns 0 for auto values. 
The "from fail to pass" progression is behind a flag which is currently turned off on trunk (where we start exercising some more LFC code for inline content, specifically where LFC calls valueForLength(style.paddingLeft(), containingBlockWidth) to resolve the computed value.)
I could have waited with this fix until after we enabled the flag to show the progression but it looked like a valid correctness fix in itself (since 'auto' is an incorrect value for padding).
Comment 13 Darin Adler 2020-10-27 10:02:11 PDT
(In reply to zalan from comment #12)
> There's no effect on trunk yet because the
> rendering code is written in a way that the incorrect 'auto' value gets
> resolved to 0.

OK.