diff --git a/layout/forms/nsNumberControlFrame.cpp b/layout/forms/nsNumberControlFrame.cpp index 7a7886cc97b8..0e017ed23c90 100644 --- a/layout/forms/nsNumberControlFrame.cpp +++ b/layout/forms/nsNumberControlFrame.cpp @@ -419,7 +419,7 @@ nsresult nsNumberControlFrame::SetFormProperty(nsAtom* aName, return GetTextFieldFrame()->SetFormProperty(aName, aValue); } -HTMLInputElement* nsNumberControlFrame::GetAnonTextControl() { +HTMLInputElement* nsNumberControlFrame::GetAnonTextControl() const { return HTMLInputElement::FromNode(mTextField); } @@ -574,6 +574,25 @@ bool nsNumberControlFrame::ShouldUseNativeStyleForSpinner() const { spinDownFrame, STYLES_DISABLING_NATIVE_THEMING); } +bool nsNumberControlFrame::GetNaturalBaselineBOffset( + WritingMode aWM, BaselineSharingGroup aGroup, nscoord* aBaseline) const { + if (StyleDisplay()->IsContainLayout()) { + return false; + } + nsIFrame* inner = GetAnonTextControl()->GetPrimaryFrame(); + nscoord baseline; + DebugOnly hasBaseline = inner->GetNaturalBaselineBOffset( + aWM, BaselineSharingGroup::First, &baseline); + MOZ_ASSERT(hasBaseline); + nsPoint offset = inner->GetOffsetToIgnoringScrolling(this); + baseline += aWM.IsVertical() ? offset.x : offset.y; + if (aGroup == BaselineSharingGroup::Last) { + baseline = BSize(aWM) - baseline; + } + *aBaseline = baseline; + return true; +} + void nsNumberControlFrame::AppendAnonymousContentTo( nsTArray& aElements, uint32_t aFilter) { // Only one direct anonymous child: diff --git a/layout/forms/nsNumberControlFrame.h b/layout/forms/nsNumberControlFrame.h index a36acd53c74b..4b7c2fbf5b88 100644 --- a/layout/forms/nsNumberControlFrame.h +++ b/layout/forms/nsNumberControlFrame.h @@ -67,6 +67,10 @@ class nsNumberControlFrame final : public nsContainerFrame, virtual nsresult AttributeChanged(int32_t aNameSpaceID, nsAtom* aAttribute, int32_t aModType) override; + bool GetNaturalBaselineBOffset(mozilla::WritingMode aWM, + BaselineSharingGroup aGroup, + nscoord* aBaseline) const override; + // nsIAnonymousContentCreator virtual nsresult CreateAnonymousContent( nsTArray& aElements) override; @@ -116,7 +120,7 @@ class nsNumberControlFrame final : public nsContainerFrame, mHandlingInputEvent = aHandlingEvent; } - HTMLInputElement* GetAnonTextControl(); + HTMLInputElement* GetAnonTextControl() const; /** * If the frame is the frame for an nsNumberControlFrame's anonymous text diff --git a/testing/web-platform/tests/css/css-align/baseline-rules/grid-item-input-type-number-ref.html b/testing/web-platform/tests/css/css-align/baseline-rules/grid-item-input-type-number-ref.html new file mode 100644 index 000000000000..dc91342cc81d --- /dev/null +++ b/testing/web-platform/tests/css/css-align/baseline-rules/grid-item-input-type-number-ref.html @@ -0,0 +1,62 @@ + + + + + Reference baseline alignment of inline-grid with an INPUT type=number item + + + + + +
+ B +
+ B +
+ +
+ B +
+ B +
+ +
+
+ B +
+ B +
+ +
+ B +
+ B +
+
+ + + diff --git a/testing/web-platform/tests/css/css-align/baseline-rules/grid-item-input-type-number.html b/testing/web-platform/tests/css/css-align/baseline-rules/grid-item-input-type-number.html new file mode 100644 index 000000000000..9b9735c7be78 --- /dev/null +++ b/testing/web-platform/tests/css/css-align/baseline-rules/grid-item-input-type-number.html @@ -0,0 +1,63 @@ + + + + + Test baseline alignment of inline-grid with an INPUT type=number item + + + + + + + +
+ B +
+ B +
+ +
+ B +
+ B +
+ +
+
+ B +
+ B +
+ +
+ B +
+ B +
+
+ + + diff --git a/testing/web-platform/tests/css/css-align/baseline-rules/grid-item-input-type-text-ref.html b/testing/web-platform/tests/css/css-align/baseline-rules/grid-item-input-type-text-ref.html new file mode 100644 index 000000000000..e6d2786c5ef4 --- /dev/null +++ b/testing/web-platform/tests/css/css-align/baseline-rules/grid-item-input-type-text-ref.html @@ -0,0 +1,62 @@ + + + + + Reference baseline alignment of inline-grid with an INPUT type=text item + + + + + +
+ B +
+ B +
+ +
+ B +
+ B +
+ +
+
+ B +
+ B +
+ +
+ B +
+ B +
+
+ + + diff --git a/testing/web-platform/tests/css/css-align/baseline-rules/grid-item-input-type-text.html b/testing/web-platform/tests/css/css-align/baseline-rules/grid-item-input-type-text.html new file mode 100644 index 000000000000..526dcbae6a9c --- /dev/null +++ b/testing/web-platform/tests/css/css-align/baseline-rules/grid-item-input-type-text.html @@ -0,0 +1,63 @@ + + + + + Test baseline alignment of inline-grid with an INPUT type=text item + + + + + + + +
+ B +
+ B +
+ +
+ B +
+ B +
+ +
+
+ B +
+ B +
+ +
+ B +
+ B +
+
+ + +