Closed
Bug 851782
Opened 12 years ago
Closed 12 years ago
Dispatch an 'input' event when the 'type' of an <input type=range> is changed while a user is dragging its thumb
Categories
(Core :: DOM: Core & HTML, defect)
Core
DOM: Core & HTML
Tracking
()
RESOLVED
FIXED
mozilla23
People
(Reporter: jwatt, Assigned: jwatt)
References
(Blocks 1 open bug)
Details
Attachments
(1 file, 1 obsolete file)
2.18 KB,
patch
|
smaug
:
review+
|
Details | Diff | Splinter Review |
It is possible in one rather contorted scenario for nsHTMLInputElement::SetValueOfRangeForUserEvent to dispatch a trusted "input" event under a change that was initiated by content script. Specifically this will happen if script changes the type of the <input> from "range" to something else while the user is in the middle of dragging the thumb. We then end up with a stack like this:
nsHTMLInputElement::SetValueOfRangeForUserEvent
nsHTMLInputElement::CancelRangeThumbDrag
nsHTMLInputElement::HandleTypeChange
nsHTMLInputElement::ParseAttribute
mozilla::dom::Element::SetAttr
nsGenericHTMLElement::SetAttr
nsGenericHTMLElement::SetAttr
nsGenericHTMLElement::SetAttrHelper
nsHTMLInputElement::SetType
nsIDOMHTMLInputElement_SetType
Really we should only call nsHTMLInputElement::SetValueOfRangeForUserEvent for an action being carried out by the user. However, it does seem like we need to dispatch an 'input' event in this case, or else the last action carried out by any 'input' handler in the page will have been for a value that isn't the final value, leaving it in a bad state. (We also may not fire a 'change' event, since cancelling the drag means that the value will be the same as the value at the start of the drag.)
Assignee | ||
Comment 1•12 years ago
|
||
To be clearer, a fuller stack where we hit the assertion that resulted in this bug is:
###!!! ASSERTION: This is unsafe! Fix the caller!: 'Error', file ../../../../content/events/src/nsEventDispatcher.cpp, line 494
nsEventDispatcher::Dispatch
nsEventDispatcher::DispatchDOMEvent
nsINode::DispatchEvent
nsContentUtils::DispatchEvent
nsContentUtils::DispatchTrustedEvent
nsHTMLInputElement::SetValueOfRangeForUserEvent
nsHTMLInputElement::CancelRangeThumbDrag
nsHTMLInputElement::HandleTypeChange
nsHTMLInputElement::ParseAttribute
mozilla::dom::Element::SetAttr
nsGenericHTMLElement::SetAttr
nsGenericHTMLElement::SetAttr
nsGenericHTMLElement::SetAttrHelper
nsHTMLInputElement::SetType
nsIDOMHTMLInputElement_SetType
Assignee | ||
Comment 2•12 years ago
|
||
The fix pushed in bug 851090 comment 15 stopped us from dispatching 'input' events at times that would trigger the assertion. So this bug is now about dispatching 'input' events when a drag is canceled by a script changing the 'type' attribute, but doing it in a safe way.
Summary: Prevent nsHTMLInputElement::SetValueOfRangeForUserEvent from dispatching trusted events under content script → Dispatch an 'input' event when the 'type' of an <input type=range> is changed while a user is dragging its thumb
Assignee | ||
Comment 3•12 years ago
|
||
As pointed out by smaug on IRC, this really is a pretty far out edge case, so probably it doesn't really block bug 841950. Changing it to block bug 853822 instead.
Assignee | ||
Comment 4•12 years ago
|
||
Nevertheless, here's a patch to fix this.
Attachment #737974 -
Flags: review?(bugs)
Assignee | ||
Comment 5•12 years ago
|
||
I ran test_input_range_mouse_and_touch_events.html with this patch, and it now works fine.
Comment 6•12 years ago
|
||
Comment on attachment 737974 [details] [diff] [review]
patch
New patch coming
Attachment #737974 -
Flags: review?(bugs)
Assignee | ||
Comment 7•12 years ago
|
||
patch with the setting of mIsDraggingRange moved up to happen before the event dispatch.
Attachment #737974 -
Attachment is obsolete: true
Attachment #737984 -
Flags: review?(bugs)
Updated•12 years ago
|
Attachment #737984 -
Flags: review?(bugs) → review+
Assignee | ||
Comment 8•12 years ago
|
||
Comment 9•12 years ago
|
||
Status: NEW → RESOLVED
Closed: 12 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla23
You need to log in
before you can comment on or make changes to this bug.
Description
•