Closed Bug 591815 Opened 14 years ago Closed 14 years ago

event.preventDefault() in mousedown doesn't work on an img element that has been appended to a different element

Categories

(Core :: DOM: Events, defect)

x86
All
defect
Not set
major

Tracking

()

RESOLVED FIXED
Tracking Status
blocking2.0 --- betaN+

People

(Reporter: mattga, Assigned: tnikkel)

References

(Depends on 2 open bugs, )

Details

(Keywords: regression, testcase)

Attachments

(2 files)

User-Agent: Mozilla/5.0 (Windows NT 5.1; rv:2.0b4) Gecko/20100818 Firefox/4.0b4 Build Identifier: Mozilla/5.0 (Windows NT 5.1; rv:2.0b4) Gecko/20100818 Firefox/4.0b4 If an element is appended to another element using appendChild() inside of a mousedown event handler, and the mouse is over an img element, you can't use event.preventDefault() to prevent the default dragging behavior. Reproducible: Always Steps to Reproduce: 1. Open http://jsbin.com/ahuce3/4 in Firefox 4 Beta 2. Try clicking and dragging the 2nd firefox logo Actual Results: The element is dragged. Expected Results: The element should not have been dragged. Webkit based browsers and Firefox 3.6 correctly disable the dragging of the element.
I can reproduce this regression on Mozilla/5.0 (Macintosh; Intel Mac OS X 10.5; rv:2.0b6pre) Gecko/20100904 Firefox/4.0b6pre (works in Firefox 3.6.8)
Status: UNCONFIRMED → NEW
blocking2.0: --- → ?
Component: General → DOM: Events
Ever confirmed: true
Product: Firefox → Core
QA Contact: general → events
Version: unspecified → Trunk
This isn't specifically drag related. nsEventStateManager::PostHandleEvent never gets called when the element is moved so there isn't any default behaviour handling to prevent.
I believe this link shows another symptom of the same problem: http://jsbin.com/efowe4/9
Regression window: Works: http://hg.mozilla.org/mozilla-central/rev/021bf8e64199 Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.3a5pre) Gecko/20100413 Minefield/3.7a5pre ID:20100416094911 Fails: http://hg.mozilla.org/mozilla-central/rev/935bb616b8a6 Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.3a5pre) Gecko/20100413 Minefield/3.7a5pre ID:20100416121540 Pushlog: http://hg.mozilla.org/mozilla-central/pushloghtml?fromchange=021bf8e64199&tochange=935bb616b8a6 Candidate bug: Bug 502937 - (lazyfc) Consider doing lazy frame construction
Timothy, can you look into this regression, from the above comment this could be fallout from your lazy frame construction work...
Assignee: nobody → tnikkel
blocking2.0: ? → betaN+
At the start of nsEventStateManager::PostHandleEvent we bail if there is no current (frame) target and the event is not a mouse button up, so we never reach the StopTrackingDragGesture() call that happens for mouse downs in that function when the event status is consume no default. There is not current target frame when we post handle the event because the event handler moves the content node, so we eagerly delete the frame, and lazyily recreate it. So I think we just need to not bail for mouse down events at the start of PostHandleEvent.
Attached patch patchSplinter Review
Attachment #474804 - Flags: review?(Olli.Pettay)
Attachment #474804 - Flags: review?(Olli.Pettay) → review+
What's next here? Is this ready to land?
Yes, but the tree is restricted to beta7 blockers.
Status: NEW → RESOLVED
Closed: 14 years ago
Flags: in-testsuite+
Resolution: --- → FIXED
Depends on: 641598
Depends on: 651297
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: