Skip to content

Commit e128831

Browse files
committedOct 1, 2024
Bug 1917771 - Use bottom of border box as the range frame's baseline. r=emilio
Differential Revision: https://phabricator.services.mozilla.com/D223107
1 parent 6056d5b commit e128831

File tree

4 files changed

+64
-0
lines changed

4 files changed

+64
-0
lines changed
 

‎layout/forms/nsRangeFrame.cpp

+20
Original file line numberDiff line numberDiff line change
@@ -674,6 +674,26 @@ double nsRangeFrame::GetValue() const {
674674
.toDouble();
675675
}
676676

677+
Maybe<nscoord> nsRangeFrame::GetNaturalBaselineBOffset(
678+
WritingMode aWM, BaselineSharingGroup aBaselineGroup,
679+
BaselineExportContext) const {
680+
NS_ASSERTION(!IsSubtreeDirty(), "frame must not be dirty");
681+
682+
if (aBaselineGroup == BaselineSharingGroup::Last) {
683+
return Nothing{};
684+
}
685+
686+
if (StyleDisplay()->IsBlockOutsideStyle()) {
687+
return Nothing{};
688+
}
689+
690+
if (aWM.IsCentralBaseline()) {
691+
return Some(BSize(aWM) / 2);
692+
}
693+
694+
return Some(GetLogicalSize(aWM).BSize(aWM));
695+
}
696+
677697
bool nsRangeFrame::ShouldUseNativeStyle() const {
678698
nsIFrame* trackFrame = mTrackDiv->GetPrimaryFrame();
679699
nsIFrame* progressFrame = mProgressDiv->GetPrimaryFrame();

‎layout/forms/nsRangeFrame.h

+4
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,10 @@ class nsRangeFrame final : public nsContainerFrame,
5454
const ReflowInput& aReflowInput,
5555
nsReflowStatus& aStatus) override;
5656

57+
Maybe<nscoord> GetNaturalBaselineBOffset(
58+
mozilla::WritingMode aWM, BaselineSharingGroup aBaselineGroup,
59+
BaselineExportContext) const override;
60+
5761
#ifdef DEBUG_FRAME_DUMP
5862
nsresult GetFrameName(nsAString& aResult) const override {
5963
return MakeFrameName(u"Range"_ns, aResult);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<!DOCTYPE html>
2+
<meta charset="utf-8">
3+
<title>Reference for Input type=range baseline alignment</title>
4+
<style>
5+
.range-placeholder {
6+
display: inline-block;
7+
margin: 20px 20px 0 20px;
8+
padding: 10px;
9+
border: 20px solid transparent;
10+
box-sizing: border-box;
11+
width: 180px;
12+
height: 60px;
13+
}
14+
</style>
15+
<div>
16+
Baseline text
17+
<span class="range-placeholder"></span>
18+
More baseline text
19+
</div>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<!DOCTYPE html>
2+
<meta charset="utf-8">
3+
<title>Input type=range baseline alignment</title>
4+
<link rel="match" href="range-baseline-ref.html">
5+
<link rel="help" href="https://html.spec.whatwg.org/multipage/input.html#range-state-(type=range)">
6+
<style>
7+
.range-input {
8+
box-sizing: border-box;
9+
width: 180px;
10+
height: 60px;
11+
margin: 20px;
12+
padding: 10px;
13+
border: 20px solid transparent;
14+
visibility: hidden;
15+
}
16+
</style>
17+
<div class="text-wrapper">
18+
Baseline text
19+
<input type="range" class="range-input">
20+
More baseline text
21+
</div>

0 commit comments

Comments
 (0)
Failed to load comments.