Closed Bug 1825709 Opened 2 years ago Closed 1 years ago

date input positions incorrectly when using min-height

Categories

(Core :: Layout: Form Controls, defect)

Firefox 111
defect

Tracking

()

VERIFIED FIXED
114 Branch
Tracking Status
firefox114 --- verified
firefox115 --- verified

People

(Reporter: adampcooke, Assigned: emilio)

Details

Attachments

(5 files)

User Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:109.0) Gecko/20100101 Firefox/111.0

Steps to reproduce:

#div1 input {
min-height: 38px;
}
#div2 input {
height: 38px;
}

<div id='div1'>
<input type='text'/><input type='date'/>
</div>

<div id='div2'>
<input type='text'/><input type='date'/>
</div>

https://jsfiddle.net/2ozf63d4/2/

Actual results:

The position of inputs with a type='date' and a min-height behaves differently to text and number inputs or date inputs with height set instead of min-height.

date inputs with a min-height are offset down

Expected results:

inputs should be positioned the same

The Bugbug bot thinks this bug should belong to the 'Core::Layout: Form Controls' component, and is moving the bug to that component. Please correct in case you think the bot is wrong.

Component: Untriaged → Layout: Form Controls
Product: Firefox → Core

Possibly related to vertical alignment

https://jsfiddle.net/yhg4Lbqw/1/

Looks like the regression happened around here.
Maybe bug 1698606?

The severity field is not set for this bug.
:TYLin, could you have a look please?

For more information, please visit auto_nag documentation.

Flags: needinfo?(aethanyc)
Assignee: nobody → aethanyc
Status: UNCONFIRMED → NEW
Ever confirmed: true
Flags: needinfo?(aethanyc)

(In reply to David Shin[:dshin] from comment #3)

Looks like the regression happened around here.
Maybe bug 1698606?

bug 1698606 changes the baseline of date control. Maybe it's related.

Oops. I don't mean to take this bug.

Assignee: aethanyc → nobody
Severity: -- → S3
Flags: needinfo?(emilio)

Use inline initializers etc.

Assignee: nobody → emilio
Status: NEW → ASSIGNED

This seems to be here since nsTextControlFrame has a meaningful
baseline, but it doesn't make much sense to me:

  • Baseline is a block axis, not inline axis measurement.
  • It doesn't call into the base class which seems clearly a bug (though
    the intrinsic isize of the input is ~fixed, doesn't depend on font
    metrics, so it's probably ok).

My guess is that it was intended to be a debug-only check so that we
could detect stale baseline values.

Just remove this. If you think the check is useful we could keep this
but call the base class or something, but not convinced it's worth it.

Depends on D175744

This isn't needed for nsTextControlFrame because its ComputeAutoSize
implementation doesn't return an unconstrained line-height for inputs,
so we never end up in the UNCONSTRAINEDSIZE case, but it's needed for
date/time inputs.

Use GetLineHeight while at it, since it's the inflated line-height which
is what we want, and may be cached so we can avoid computing it.

Maybe in the future we can make date/time inputs just use
nsTextControlFrame, which would prevent this from happening in the
future.

Depends on D175745

Seems like this should be doable, and would avoid mistakes like this in
the future.

Flags: needinfo?(emilio)
Pushed by ealvarez@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/0093f90bfd85 Misc clean-ups in nsTextControlFrame. r=dshin
Pushed by ealvarez@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/4d22afc76172 Account for min/max bsize in nsTextControlFrame::ComputeBaseline. r=dshin
Pushed by ealvarez@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/dfc64b8c1591 Remove DEBUG-only override of nsTextControlFrame::MarkIntrinsicISizesDirty. r=dshin
Created web-platform-tests PR https://github.com/web-platform-tests/wpt/pull/39594 for changes under testing/web-platform/tests
Pushed by ealvarez@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/a9ef9922a38b Make nsDateTimeControlFrame inherit from nsTextControlFrame. r=dshin
Pushed by emilio@crisal.io: https://hg.mozilla.org/integration/autoland/rev/662b4b7bac25 Tweak assertion count of 1623918.html since it hits both the old and new asserts.
Status: ASSIGNED → RESOLVED
Closed: 1 years ago
Resolution: --- → FIXED
Target Milestone: --- → 114 Branch
Status: RESOLVED → REOPENED
Resolution: FIXED → ---

Ahh, the null crashes could be fixed like so:

diff --git a/layout/forms/nsTextControlFrame.cpp b/layout/forms/nsTextControlFrame.cpp
index b6233ee07c675..c92390d179df8 100644
--- a/layout/forms/nsTextControlFrame.cpp
+++ b/layout/forms/nsTextControlFrame.cpp
@@ -565,7 +565,9 @@ void nsTextControlFrame::AppendAnonymousContentTo(
     aElements.AppendElement(mRevealButton);
   }
 
-  aElements.AppendElement(mRootNode);
+  if (mRootNode) {
+    aElements.AppendElement(mRootNode);
+  }
 }
 
 nscoord nsTextControlFrame::GetPrefISize(gfxContext* aRenderingContext) {

But I don't have the cycles right now to investigate the other failure and I don't think it's important, the bug is fixed with the other changes.

Flags: needinfo?(emilio)
Upstream PR merged by moz-wptsync-bot
QA Whiteboard: [qa-114b-p2]

Reproducible on a 2023-04-16 Nightly build on Windows 10.
Verified as fixed on Firefox 114.0b4(build ID: 20230514175823) and Nightly 115.0a1(build ID: 20230515215623) on Windows 10, macOS 12, Ubuntu 22.

Status: RESOLVED → VERIFIED
QA Whiteboard: [qa-114b-p2]
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: