Bug 982189 - Fix Input type="number" immutability. r=jst, a=lsblakk
--- a/content/html/content/src/HTMLInputElement.cpp
+++ b/content/html/content/src/HTMLInputElement.cpp
@@ -3910,17 +3910,17 @@ HTMLInputElement::PostHandleEvent(nsEven
// control and as a result aVisitor.mEventStatus will already have been
// set to nsEventStatus_eConsumeNoDefault. However, we know that
// whenever the up/down arrow keys cause the value of the number
// control to change the string in the text control will change, and
// the cursor will be moved to the end of the text control, overwriting
// the editor's handling of up/down keypress events. For that reason we
// just ignore aVisitor.mEventStatus here and go ahead and handle the
// event to increase/decrease the value of the number control.
- if (!aVisitor.mEvent->mFlags.mDefaultPreventedByContent) {
+ if (!aVisitor.mEvent->mFlags.mDefaultPreventedByContent && IsMutable()) {
StepNumberControlForUserEvent(keyEvent->keyCode == NS_VK_UP ? 1 : -1);
aVisitor.mEventStatus = nsEventStatus_eConsumeNoDefault;
}
} else if (nsEventStatus_eIgnore == aVisitor.mEventStatus) {
switch (aVisitor.mEvent->message) {
case NS_FOCUS_CONTENT:
{
@@ -4135,17 +4135,18 @@ HTMLInputElement::PostHandleEvent(nsEven
if (mouseEvent->button == WidgetMouseEvent::eLeftButton &&
!(mouseEvent->IsShift() || mouseEvent->IsControl() ||
mouseEvent->IsAlt() || mouseEvent->IsMeta() ||
mouseEvent->IsAltGraph() || mouseEvent->IsFn() ||
mouseEvent->IsOS())) {
nsNumberControlFrame* numberControlFrame =
do_QueryFrame(GetPrimaryFrame());
if (numberControlFrame) {
- if (aVisitor.mEvent->message == NS_MOUSE_BUTTON_DOWN) {
+ if (aVisitor.mEvent->message == NS_MOUSE_BUTTON_DOWN &&
+ IsMutable()) {
switch (numberControlFrame->GetSpinButtonForPointerEvent(
aVisitor.mEvent->AsMouseEvent())) {
case nsNumberControlFrame::eSpinButtonUp:
StepNumberControlForUserEvent(1);
mNumberControlSpinnerSpinsUp = true;
StartNumberControlSpinnerSpin();
aVisitor.mEventStatus = nsEventStatus_eConsumeNoDefault;
break;