Closed Bug 369644 Opened 18 years ago Closed 17 years ago

text inputs trigger spurious mouseout/mouseovers at the border

Categories

(Core :: DOM: Events, defect)

x86
Windows XP
defect
Not set
normal

Tracking

()

RESOLVED FIXED

People

(Reporter: timeless, Assigned: smaug)

References

()

Details

Attachments

(2 files)

because of the widget impl, there's a native anonymous frame between the border and the text area (or something like that) which means that when you drag your mouse across a text widget, instead of getting:

[Over], [Out]

you get:
[Over, Out, Over], [Out, Over, Out]
Attached file testcase
Attached patch possible patchSplinter Review
This prevents mouseover/out propagation when they are happening 
somewhere in native anonymous content. I think the events should
be still dispatched normally, but just not propagated to
non-native-anon.
The patch is more complex than I'd like, but there are quite many 
cases to handle (when target is in native-anon, when related target is 
in native-anon, when both are in native-anon, but don't have the same
non-native-anon parent etc.)
mRelatedTargetIsInAnon is needed to reduce calls to IsInAnonContent
to max 1 per event.
Attachment #254359 - Flags: review?(jst)
Comment on attachment 254359 [details] [diff] [review]
possible patch

r=jst
Attachment #254359 - Flags: review?(jst) → review+
Attachment #254359 - Flags: superreview?(jonas)
Comment on attachment 254359 [details] [diff] [review]
possible patch

> nsGenericElement::doPreHandleEvent(nsIContent* aContent,
>                                    nsEventChainPreVisitor& aVisitor)
> {
>   //FIXME! Document how this event retargeting works, Bug 329124.
>   aVisitor.mCanHandle = PR_TRUE;
>+
>+  // Don't propagate mouseover and mouseout events when mouse is moving
>+  // inside native anonymous content.
>+  PRBool isAnonForEvents = aContent->IsAnonymousForEvents();
>+  if (aVisitor.mEvent->message == NS_MOUSE_ENTER_SYNTH ||
>+      aVisitor.mEvent->message == NS_MOUSE_EXIT_SYNTH) {
>+     nsCOMPtr<nsIContent> relatedTarget =
>+       do_QueryInterface(NS_STATIC_CAST(nsMouseEvent*,
>+                                        aVisitor.mEvent)->relatedTarget);
>+    if (relatedTarget &&
>+        relatedTarget->GetOwnerDoc() == aContent->GetOwnerDoc()) {

Note that this'll test true if both GetOwnerDoc calls return nsnull, is that a problem? GetOwnerDoc returns null if the document gets GC'ed while someone still holds a reference to the element.

sr=me if that's ok.
Attachment #254359 - Flags: superreview?(jonas) → superreview+
I can't think any cases where null ownerdoc would be a problem, because
either target or related target must be in nativeAnonContent, otherwise
the event is handled normally. And dispatching to an nsIContent which doesn't have ownerDoc sounds quite strange, though maybe possible.

I don't know if it is possible to write a mochitest for this bug. 
Status: NEW → RESOLVED
Closed: 17 years ago
Resolution: --- → FIXED
Depends on: 380716
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: