Closed Bug 1645773 Opened 4 years ago Closed 4 years ago

Unstable textarea sizing when :focus { background-color } is used

Categories

(Core :: Layout: Form Controls, defect, P3)

defect

Tracking

()

RESOLVED FIXED
mozilla80
Tracking Status
firefox-esr68 --- unaffected
firefox-esr78 --- wontfix
firefox78 --- wontfix
firefox79 --- wontfix
firefox80 --- fixed

People

(Reporter: jfkthame, Assigned: emilio)

References

(Regressed 1 open bug)

Details

(Keywords: regression)

Attachments

(3 files, 1 obsolete file)

See attached testcase. When the onload script has finished, the three textareas end up with identical styling, but at least on macOS, I'm seeing the test (middle) textarea consistently rendering 2px larger (in both dimensions) than the reference areas.

Zooming the page and then resetting the zoom resolves the discrepancy.

(At least two tests under dom/html/reftests/autofocus, textarea-load.html and textarea-create.html, are unstable on macOS because of this issue. Loading the testcases locally, the issue is more likely to show up if the developer tools are open, presumably because this impacts the timing of focus/blur/reflow.)

Attachment #9156676 - Attachment is obsolete: true

Not specific to macOS; I see the same issue with the testcase here on Ubuntu.

And on Windows; well, at least it's consistent.

I'm pretty sure I've filed a bug on this before, but I can't find it right now. The issue is that when we change background we don't invalidate layout, only paint. But background on widgets can affect layout, because we suppress native styling when background or borders are specified.

For the purposes of making those tests reliable for now we could add -moz-appearance: none to the textarea.

The size change occurs because having :focus set background-color causes us to switch from native styling for the textarea, and this means we get thicker borders (2px rather than 1px); but we fail to resize the element to account for this.

However, if we instead set -moz-appearance:none, which has the same effect of disabling native styling and resulting in thicker borders, the element does resize as expected.

(In reply to Emilio Cobos Álvarez (:emilio) from comment #4)

I'm pretty sure I've filed a bug on this before, but I can't find it right now. The issue is that when we change background we don't invalidate layout, only paint. But background on widgets can affect layout, because we suppress native styling when background or borders are specified.

For the purposes of making those tests reliable for now we could add -moz-appearance: none to the textarea.

Yeah, I posted a patch in bug 1645794 to switch from styling background-color to color, but adding -moz-appearance would be another possible workaround.

Severity: -- → S4
Priority: -- → P3

As author-specified-background/border changes can change the effective
border and padding of form controls.

Assignee: nobody → emilio
Status: NEW → ASSIGNED
Pushed by ealvarez@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/2c022fc5b638 Make sure to reflow when author specified borders / backgrounds are changed if we're themed. r=jfkthame
Status: ASSIGNED → RESOLVED
Closed: 4 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla80

The patch landed in nightly and beta is affected.
:emilio, is this bug important enough to require an uplift?
If not please set status_beta to wontfix.

For more information, please visit auto_nag documentation.

Flags: needinfo?(emilio)
Flags: needinfo?(emilio)
Regressions: 1653832
QA Whiteboard: [qa-80b-p2]
Regressions: 1691363
Regressions: 1691256
Regressions: 1721262
No longer regressions: 1721262
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: