Skip to content

Commit 47643b0

Browse files
author
Tamas Szentpeteri
committedSep 10, 2024
Backed out changeset 710d5d0be438 (bug 1917456) for causing mochitest leaks on mochitest.toml. CLOSED TREE
1 parent 9c36583 commit 47643b0

File tree

2 files changed

+13
-27
lines changed

2 files changed

+13
-27
lines changed
 

‎dom/html/test/forms/test_input_range_mouse_and_touch_events.html

+7-19
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,14 @@
1919
* predict exactly what value the input should take on for events at
2020
* certain coordinates.)
2121
*/
22-
input { margin: 0 !important; width: 200px !important; padding-inline: 100px; }
22+
input { margin: 0 ! important; width: 200px ! important; }
2323
</style>
2424
</head>
2525
<body>
2626
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=846380">Mozilla Bug 846380</a>
2727
<p id="display"></p>
2828
<div id="content">
29-
<input id="range" type="range"><br>
30-
<input id="range-appearance-none" type="range" style="appearance: none">
29+
<input id="range" type="range">
3130
</div>
3231
<pre id="test">
3332
<script type="application/javascript">
@@ -41,13 +40,10 @@
4140
* This test checks how the value of <input type=range> changes in response to
4241
* various mouse and touch events.
4342
**/
44-
SimpleTest.expectAssertions(0, 2); // bug 1917867
4543
SimpleTest.waitForExplicitFinish();
4644
SimpleTest.waitForFocus(function() {
47-
for (let element of document.querySelectorAll("input[type=range]")) {
48-
test(element, synthesizeMouse, "click", "mousedown", "mousemove", "mouseup");
49-
test(element, synthesizeTouch, "tap", "touchstart", "touchmove", "touchend");
50-
}
45+
test(synthesizeMouse, "click", "mousedown", "mousemove", "mouseup");
46+
test(synthesizeTouch, "tap", "touchstart", "touchmove", "touchend");
5147
SimpleTest.finish();
5248
});
5349

@@ -66,9 +62,8 @@
6662
document.body.clientWidth;
6763
}
6864

69-
function test(elem, synthesizeFunc, clickOrTap, startName, moveName, endName) {
70-
info(`Testing ${elem.id}`);
71-
65+
function test(synthesizeFunc, clickOrTap, startName, moveName, endName) {
66+
var elem = document.getElementById("range");
7267
elem.focus();
7368
flush();
7469

@@ -79,13 +74,6 @@
7974
var paddingLeft = parseFloat(window.getComputedStyle(elem).paddingLeft);
8075
var paddingTop = parseFloat(window.getComputedStyle(elem).paddingTop);
8176

82-
// If themed then we use our border-box size.
83-
if (elem.style.appearance != "none") {
84-
width += borderLeft * 2 + paddingLeft * 2;
85-
borderLeft = 0;
86-
paddingLeft = 0;
87-
}
88-
8977
// Extrema for mouse/touch events:
9078
var midY = height / 2 + borderTop + paddingTop;
9179
var minX = borderLeft + paddingLeft;
@@ -218,7 +206,7 @@
218206
synthesizeKey("KEY_Home");
219207
// The KEY_Home tests are disabled until I can figure out why they fail on Android -jwatt
220208
//is(elem.value, MINIMUM_OF_RANGE, "Test KEY_Home during a drag sets the value to the minimum of the range");
221-
synthesizeFunc(elem, maxX+100, midY, { type: moveName });
209+
synthesizeFunc(elem, midX+100, midY, { type: moveName });
222210
is(elem.value, MAXIMUM_OF_RANGE, "Test " + moveName + " outside range after key press that occurred during a drag changes the value");
223211
synthesizeFunc(elem, midX, midY, { type: moveName });
224212
is(elem.value, MIDDLE_OF_RANGE, "Test " + moveName + " in middle of range");

‎layout/forms/nsRangeFrame.cpp

+6-8
Original file line numberDiff line numberDiff line change
@@ -329,11 +329,10 @@ Decimal nsRangeFrame::GetValueAtEventPoint(WidgetGUIEvent* aEvent) {
329329
->GetValueAsDecimal();
330330
}
331331

332-
nsRect rangeRect;
332+
const nsRect rangeContentRect = GetContentRectRelativeToSelf();
333333
nsSize thumbSize;
334+
334335
if (IsThemed()) {
335-
// Themed ranges draw on the border-box rect.
336-
rangeRect = GetRectRelativeToSelf();
337336
// We need to get the size of the thumb from the theme.
338337
nsPresContext* pc = PresContext();
339338
LayoutDeviceIntSize size = pc->Theme()->GetMinimumWidgetSize(
@@ -349,7 +348,6 @@ Decimal nsRangeFrame::GetValueAtEventPoint(WidgetGUIEvent* aEvent) {
349348
(!IsHorizontal() && thumbSize.height > 0),
350349
"The thumb is expected to take up some slider space");
351350
} else {
352-
rangeRect = GetContentRectRelativeToSelf();
353351
nsIFrame* thumbFrame = mThumbDiv->GetPrimaryFrame();
354352
if (thumbFrame) { // diplay:none?
355353
thumbSize = thumbFrame->GetSize();
@@ -358,23 +356,23 @@ Decimal nsRangeFrame::GetValueAtEventPoint(WidgetGUIEvent* aEvent) {
358356

359357
Decimal fraction;
360358
if (IsHorizontal()) {
361-
nscoord traversableDistance = rangeRect.width - thumbSize.width;
359+
nscoord traversableDistance = rangeContentRect.width - thumbSize.width;
362360
if (traversableDistance <= 0) {
363361
return minimum;
364362
}
365-
nscoord posAtStart = rangeRect.x + thumbSize.width / 2;
363+
nscoord posAtStart = rangeContentRect.x + thumbSize.width / 2;
366364
nscoord posAtEnd = posAtStart + traversableDistance;
367365
nscoord posOfPoint = mozilla::clamped(point.x, posAtStart, posAtEnd);
368366
fraction = Decimal(posOfPoint - posAtStart) / Decimal(traversableDistance);
369367
if (IsRightToLeft()) {
370368
fraction = Decimal(1) - fraction;
371369
}
372370
} else {
373-
nscoord traversableDistance = rangeRect.height - thumbSize.height;
371+
nscoord traversableDistance = rangeContentRect.height - thumbSize.height;
374372
if (traversableDistance <= 0) {
375373
return minimum;
376374
}
377-
nscoord posAtStart = rangeRect.y + thumbSize.height / 2;
375+
nscoord posAtStart = rangeContentRect.y + thumbSize.height / 2;
378376
nscoord posAtEnd = posAtStart + traversableDistance;
379377
nscoord posOfPoint = mozilla::clamped(point.y, posAtStart, posAtEnd);
380378
// For a vertical range, the top (posAtStart) is the highest value, so we

0 commit comments

Comments
 (0)
Failed to load comments.