Skip to content

Should padding be respected on "natively styled" form controls? #8560

Open

Description

@emilio

Consider:

data:text/html,<button style="padding: 20px;">Foo</button><select style="padding: 20px"><option>Bar

The behavior is all over the place:

  • WebKit ignores the padding altogether.
  • Chrome respects the author padding, but adds some magical extra padding, only to <select>.
  • Firefox respects the author padding.

With appearance: none, all browsers respect the author padding.

My intuition is that given padding is not one of the properties that disable native appearance, it should be respected as is (that is, that the Firefox behavior is preferable).

Firefox used to have magical "extra" padding on <select> regardless of native appearance which was removed in bug 1560824 and bug 1582545 for the block and inline directions respectively.

The Chrome code claims to match (old) Firefox behavior, but it never did (because Firefox did this regardless of appearance).

My preference is to match current Firefox behavior, though ignoring padding could also be an option (rather unfotunate IMO, tho). What Chrome is doing for <select> seems rather bespoke. However, I'm curious about thoughts from others and whether we could reach interop here.

cc @annevk @mfreed7 @nt1m @zcorpan

Activity

  1. added
    topic: rendering
    topic: forms
    agenda+
    on Nov 29, 2022
  2. nt1m commented on Nov 29, 2022

    @nt1m
    Member

    The reason Safari doesn't match author padding here is because the native appearance can't be painted at certain sizes. One exception is <button> where we paint a custom "native" style at larger sizes in order to support multi-line/custom content that can be inside buttons, see data:text/html,<button style="padding: 20px">hello</button><button>world</button>.

    Given the Safari wants to render native controls, honoring padding would mean having to support 2 types of "native" styling, the styling that's actually native, and one that supports arbitrary sizes.

    @pxlcoder Do you have an opinion regarding this?

  3. emilio commented on Nov 29, 2022

    @emilio
    ContributorAuthor

    @nt1m you support arbitrary font sizes and so, right? How is this not similar?

  4. zcorpan commented on Dec 8, 2022

    @zcorpan
    Member

    select in this issue is only drop-down select. Related issue for listbox select: #8270

  5. mfreed7 commented on Dec 8, 2022

    @mfreed7
    Contributor

    Sorry, in the meeting just now, I misunderstood due to a quick scan of the issue. This issue is just about the <select> control, right? The <button> element seems to respect padding regardless of appearance on Chromium, Gecko, WebKit, at least for me on a Mac.

    Is that right?

    Chrome:
    Screen Shot 2022-12-08 at 9 37 46 AM

    Safari:
    Screen Shot 2022-12-08 at 9 38 11 AM

    Firefox:
    Screen Shot 2022-12-08 at 9 38 33 AM

  6. emilio commented on Dec 8, 2022

    @emilio
    ContributorAuthor

    Yeah, exactly. This is interopearable in the <button> case and not in the <select> case (not sure if there are others). I think we should make <select> just like <button>.

  7. removed
    agenda+
    on Dec 13, 2022
  8. mfreed7 commented on Dec 16, 2022

    @mfreed7
    Contributor

    Yeah, exactly. This is interopearable in the <button> case and not in the <select> case (not sure if there are others). I think we should make <select> just like <button>.

    Ok, thanks. Then I agree we should try to make this interoperable. The best option from a developer point of view would seem to be to respect the padding even when appearance:auto. Chromium-wise, I think that just requires returning zero here and something smaller here. If we can spec this and get a test, I'm happy to make the Chromium change. This seems hard to write a WPT for, right? I suppose just a <link rel="mismatch" type test that makes sure padding has an effect?

  9. pxlcoder commented on Dec 16, 2022

    @pxlcoder

    I would like to note that WebKit cannot truly support padding on "natively styled" <select>. Our control is painted using AppKit's NSPopupButtonCell – which draws at 4 fixed sizes, and does not allow us to customize padding. For the same reason, WebKit does not support arbitrary font sizes on "natively styled" <select>.

    If WebKit were to "respect" padding for this form of <select>, the rendered appearance would essentially be as if the <select> were wrapped in a <span> with the specified padding.

  10. zcorpan commented on Dec 16, 2022

    @zcorpan
    Member

    In WebKit <input type=button value=Foo> also doesn't respect padding. I think the difference is the internal appearance is push-button vs for <button> it is square-button. (The appearance values aren't controllable from author CSS since the keywords map to auto.)

    http://software.hixie.ch/utilities/js/live-dom-viewer/saved/11113

  11. nt1m commented on Dec 16, 2022

    @nt1m
    Member

    In WebKit <input type=button value=Foo> also doesn't respect padding. I think the difference is the internal appearance is push-button vs for <button> it is square-button. (The appearance values aren't controllable from author CSS since the keywords map to auto.)

    http://software.hixie.ch/utilities/js/live-dom-viewer/saved/11113

    We do want to fix that: https://bugs.webkit.org/show_bug.cgi?id=238803 since it affects our ability to render multi-line <input type=button> (push-button cannot be rendered with multiple lines, platform limitation).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    topic: formstopic: rendering

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions