Bug 939396 - Fix <input type=range> so that the focus code doesn't overwrite the correct pre-focus value onclick. r=smaug

--HG--
extra : rebase_source : 095f67af802d9b63e7eda93e33d580c8d0286b9c
This commit is contained in:
Jonathan Watt 2013-11-21 12:55:01 +00:00
Родитель 0d53fff241
Коммит aa5b501ff5
2 изменённых файлов: 14 добавлений и 1 удалений

Просмотреть файл

@ -3236,6 +3236,14 @@ HTMLInputElement::StartRangeThumbDrag(WidgetGUIEvent* aEvent)
nsIPresShell::SetCapturingContent(this, CAPTURE_IGNOREALLOWED |
CAPTURE_RETARGETTOELEMENT);
nsRangeFrame* rangeFrame = do_QueryFrame(GetPrimaryFrame());
// Before we change the value, record the current value so that we'll
// correctly send a 'change' event if appropriate. We need to do this here
// because the 'focus' event is handled after the 'mousedown' event that
// we're being called for (i.e. too late to update mFocusedValue, since we'll
// have changed it by then).
GetValueInternal(mFocusedValue);
SetValueOfRangeForUserEvent(rangeFrame->GetValueAtEventPoint(aEvent));
}
@ -3383,7 +3391,8 @@ HTMLInputElement::PostHandleEvent(nsEventChainPostVisitor& aVisitor)
if (aVisitor.mEvent->message == NS_FOCUS_CONTENT ||
aVisitor.mEvent->message == NS_BLUR_CONTENT) {
if (aVisitor.mEvent->message == NS_FOCUS_CONTENT &&
MayFireChangeOnBlur()) {
MayFireChangeOnBlur() &&
!mIsDraggingRange) { // StartRangeThumbDrag already set mFocusedValue
GetValueInternal(mFocusedValue);
}

Просмотреть файл

@ -185,6 +185,10 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=722599
is(rangeChange, 1, "Change event shouldn't be dispatched on range input element during drag of thumb");
synthesizeMouse(range, centerOfRangeX, centerOfRangeY, { type: "mouseup" });
is(rangeChange, 2, "Change event should be dispatched on range input element at end of drag");
range.blur();
is(rangeChange, 2, "Change event shouldn't be dispatched on range input element when range loses focus after a drag");
synthesizeMouse(range, centerOfRangeX - 10, centerOfRangeY, {});
is(rangeChange, 3, "Change event should be dispatched on range input element for a click that gives the range focus");
//Input type change test.
input = document.getElementById("input_checkbox");