зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1802687 - Account for direction:rtl in vertical writing-mode <input type=range> controls. r=emilio
Differential Revision: https://phabricator.services.mozilla.com/D171375
This commit is contained in:
Родитель
b375906898
Коммит
d43d8f20e1
|
@ -434,8 +434,10 @@ Decimal nsRangeFrame::GetValueAtEventPoint(WidgetGUIEvent* aEvent) {
|
|||
nscoord posOfPoint = mozilla::clamped(point.y, posAtStart, posAtEnd);
|
||||
// For a vertical range, the top (posAtStart) is the highest value, so we
|
||||
// subtract the fraction from 1.0 to get that polarity correct.
|
||||
fraction = Decimal(1) -
|
||||
Decimal(posOfPoint - posAtStart) / Decimal(traversableDistance);
|
||||
fraction = Decimal(posOfPoint - posAtStart) / Decimal(traversableDistance);
|
||||
if (IsUpwards()) {
|
||||
fraction = Decimal(1) - fraction;
|
||||
}
|
||||
}
|
||||
|
||||
MOZ_ASSERT(fraction >= Decimal(0) && fraction <= Decimal(1));
|
||||
|
@ -572,7 +574,11 @@ void nsRangeFrame::DoUpdateThumbPosition(nsIFrame* aThumbFrame,
|
|||
nscoord traversableDistance =
|
||||
rangeContentBoxSize.height - thumbSize.height;
|
||||
newPosition.x += (rangeContentBoxSize.width - thumbSize.width) / 2;
|
||||
newPosition.y += NSToCoordRound((1.0 - fraction) * traversableDistance);
|
||||
if (IsUpwards()) {
|
||||
newPosition.y += NSToCoordRound((1.0 - fraction) * traversableDistance);
|
||||
} else {
|
||||
newPosition.y += NSToCoordRound(fraction * traversableDistance);
|
||||
}
|
||||
}
|
||||
}
|
||||
aThumbFrame->SetPosition(newPosition);
|
||||
|
@ -613,7 +619,9 @@ void nsRangeFrame::DoUpdateRangeProgressFrame(nsIFrame* aRangeProgressFrame,
|
|||
} else {
|
||||
nscoord progLength = NSToCoordRound(fraction * rangeContentBoxSize.height);
|
||||
progRect.x += (rangeContentBoxSize.width - progSize.width) / 2;
|
||||
progRect.y += rangeContentBoxSize.height - progLength;
|
||||
if (IsUpwards()) {
|
||||
progRect.y += rangeContentBoxSize.height - progLength;
|
||||
}
|
||||
progRect.height = progLength;
|
||||
}
|
||||
aRangeProgressFrame->SetRect(progRect);
|
||||
|
|
|
@ -115,6 +115,18 @@ class nsRangeFrame final : public nsContainerFrame,
|
|||
return GetWritingMode().IsPhysicalRTL();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the range progresses upwards (for vertical ranges in
|
||||
* horizontal writing mode, or for bidi-RTL in vertical mode). Only
|
||||
* relevant when IsHorizontal() is false.
|
||||
*/
|
||||
bool IsUpwards() const {
|
||||
MOZ_ASSERT(!IsHorizontal());
|
||||
mozilla::WritingMode wm = GetWritingMode();
|
||||
return wm.GetBlockDir() == mozilla::WritingMode::eBlockTB ||
|
||||
wm.GetInlineDir() == mozilla::WritingMode::eInlineBTT;
|
||||
}
|
||||
|
||||
double GetMin() const;
|
||||
double GetMax() const;
|
||||
double GetValue() const;
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<input type=range style="writing-mode:vertical-lr" orient=inline max=100 value=70>
|
||||
<input type=range style="writing-mode:vertical-lr;direction:rtl" orient=inline max=100 value=70>
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<input type=range style="writing-mode:vertical-lr" orient=vertical max=100 value=70>
|
||||
<input type=range style="writing-mode:vertical-lr;direction:rtl" orient=vertical max=100 value=70>
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<input type=range style="writing-mode:vertical-lr" max=100 value=70>
|
||||
<input type=range style="writing-mode:vertical-lr;direction:rtl" max=100 value=70>
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<input type=range style="writing-mode:vertical-rl" orient=inline max=100 value=70>
|
||||
<input type=range style="writing-mode:vertical-rl;direction:rtl" orient=inline max=100 value=70>
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<input type=range style="writing-mode:vertical-rl" orient=vertical max=100 value=70>
|
||||
<input type=range style="writing-mode:vertical-rl;direction:rtl" orient=vertical max=100 value=70>
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<input type=range style="writing-mode:vertical-rl" max=100 value=70>
|
||||
<input type=range style="writing-mode:vertical-rl;direction:rtl" max=100 value=70>
|
||||
|
|
|
@ -1,2 +0,0 @@
|
|||
[range-input-appearance-native-vertical-rtl.optional.html]
|
||||
expected: FAIL
|
|
@ -1,2 +0,0 @@
|
|||
[range-input-appearance-none-vertical-rtl.optional.html]
|
||||
expected: FAIL
|
|
@ -880,11 +880,18 @@ void Theme::PaintRange(nsIFrame* aFrame, PaintBackendData& aPaintData,
|
|||
tickMarkSize = LayoutDeviceSize(tickMarkHeight, tickMarkWidth);
|
||||
thumbRect.x = aRect.x + (aRect.width - thumbRect.width) / 2;
|
||||
|
||||
thumbRect.y =
|
||||
aRect.y + (aRect.height - thumbRect.height) * (1.0 - progress);
|
||||
float midPoint = thumbRect.Center().Y();
|
||||
trackClipRect.SetBoxY(aRect.Y(), midPoint);
|
||||
progressClipRect.SetBoxY(midPoint, aRect.YMost());
|
||||
if (rangeFrame->IsUpwards()) {
|
||||
thumbRect.y =
|
||||
aRect.y + (aRect.height - thumbRect.height) * (1.0 - progress);
|
||||
float midPoint = thumbRect.Center().Y();
|
||||
trackClipRect.SetBoxY(aRect.Y(), midPoint);
|
||||
progressClipRect.SetBoxY(midPoint, aRect.YMost());
|
||||
} else {
|
||||
thumbRect.y = aRect.y + (aRect.height - thumbRect.height) * progress;
|
||||
float midPoint = thumbRect.Center().Y();
|
||||
trackClipRect.SetBoxY(midPoint, aRect.YMost());
|
||||
progressClipRect.SetBoxY(aRect.Y(), midPoint);
|
||||
}
|
||||
}
|
||||
|
||||
const CSSCoord borderWidth = 1.0f;
|
||||
|
|
Загрузка…
Ссылка в новой задаче