Closed
Bug 1344149
Opened 7 years ago
Closed 7 years ago
EditorEventListener should stop accepting odd focus/blur events
Categories
(Core :: DOM: Editor, enhancement)
Core
DOM: Editor
Tracking
()
RESOLVED
FIXED
mozilla55
People
(Reporter: masayuki, Assigned: masayuki)
References
Details
Attachments
(1 file)
EditorEventListener currently listen odd focus/blur events which may be synthesized by JS. Then, editor will setup selection limitation. This may cause odd behavior. Let's stop accepting such event.
Assignee | ||
Comment 1•7 years ago
|
||
https://treeherder.mozilla.org/#/jobs?repo=try&revision=f6d7df8f6a02
Assignee | ||
Comment 2•7 years ago
|
||
https://treeherder.mozilla.org/#/jobs?repo=try&revision=a0af70d65f1e
Comment hidden (mozreview-request) |
Assignee | ||
Comment 4•7 years ago
|
||
FYI: If chrome script synthesizes "focus" or "blur" event with |FocusEvent|, it still causes editor handling them for initializing/finalizing the selection limit. I'll file another bug for it because WidgetEvent needs new flag if it's initialized with script.
Comment 5•7 years ago
|
||
mozreview-review |
Comment on attachment 8844434 [details] Bug 1344149 EditorEventListener shouldn't handle odd focus/blur events which may be created in chrome script https://reviewboard.mozilla.org/r/117538/#review119646 ::: editor/libeditor/EditorEventListener.cpp:193 (Diff revision 1) > TrustedEventsAtCapture()); > elmP->AddEventListenerByType(this, > NS_LITERAL_STRING("click"), > TrustedEventsAtCapture()); > -// Focus event doesn't bubble so adding the listener to capturing phase. > + // Focus event doesn't bubble so adding the listener to capturing phase. > -// Make sure this works after bug 235441 gets fixed. > + // XXX Should we listen focus/blur events of system group too? Or should yes we should, I think, and IIRC I tried to make the change but it broke at least some tests ::: editor/libeditor/EditorEventListener.cpp:196 (Diff revision 1) > TrustedEventsAtCapture()); > -// Focus event doesn't bubble so adding the listener to capturing phase. > + // Focus event doesn't bubble so adding the listener to capturing phase. > -// Make sure this works after bug 235441 gets fixed. > + // XXX Should we listen focus/blur events of system group too? Or should > + // editor notified focus/blur of the element from nsFocusManager > + // directly? Because if the event propagation is stopped by JS, > + // editor cannot initialize selection as expected. Hmm, I don't know how to easily notify the editor. But stopPropagation in default group doesn't affect system group ::: editor/libeditor/EditorEventListener.cpp:1079 (Diff revision 1) > } > > nsresult > -EditorEventListener::Focus(WidgetEvent* aFocusEvent) > +EditorEventListener::Focus(InternalFocusEvent* aFocusEvent) > { > - if (NS_WARN_IF(!aFocusEvent) || DetachedFromEditor()) { > + if (DetachedFromEditorOrDefaultPrevented(aFocusEvent)) { focus/blur shouldn't care about defaultPrevented(), so DetachedFromEditor() should be enough ::: editor/libeditor/EditorEventListener.cpp:1162 (Diff revision 1) > } > > nsresult > -EditorEventListener::Blur(WidgetEvent* aBlurEvent) > +EditorEventListener::Blur(InternalFocusEvent* aBlurEvent) > { > - if (NS_WARN_IF(!aBlurEvent) || DetachedFromEditor()) { > + if (DetachedFromEditorOrDefaultPrevented(aBlurEvent)) { same here.
Attachment #8844434 -
Flags: review?(bugs) → review+
Assignee | ||
Comment 6•7 years ago
|
||
(In reply to Olli Pettay [:smaug] (high review load, queue closed for couple of days) from comment #5) > Comment on attachment 8844434 [details] > Bug 1344149 EditorEventListener shouldn't handle odd focus/blur events which > may be created in chrome script > > https://reviewboard.mozilla.org/r/117538/#review119646 > > ::: editor/libeditor/EditorEventListener.cpp:193 > (Diff revision 1) > > TrustedEventsAtCapture()); > > elmP->AddEventListenerByType(this, > > NS_LITERAL_STRING("click"), > > TrustedEventsAtCapture()); > > -// Focus event doesn't bubble so adding the listener to capturing phase. > > + // Focus event doesn't bubble so adding the listener to capturing phase. > > -// Make sure this works after bug 235441 gets fixed. > > + // XXX Should we listen focus/blur events of system group too? Or should > > yes we should, I think, and IIRC I tried to make the change but it broke at > least some tests > > ::: editor/libeditor/EditorEventListener.cpp:196 > (Diff revision 1) > > TrustedEventsAtCapture()); > > -// Focus event doesn't bubble so adding the listener to capturing phase. > > + // Focus event doesn't bubble so adding the listener to capturing phase. > > -// Make sure this works after bug 235441 gets fixed. > > + // XXX Should we listen focus/blur events of system group too? Or should > > + // editor notified focus/blur of the element from nsFocusManager > > + // directly? Because if the event propagation is stopped by JS, > > + // editor cannot initialize selection as expected. > > Hmm, I don't know how to easily notify the editor. But stopPropagation in > default group doesn't affect system group Yeah, but perhaps, if we'd listen to only system group events, we might break the web. For example, if web apps checks selection range in "focus" event handler, EditorEventListener hasn't listen to the coming "focus" event in system group. So, perhaps, it's the best way to stop listening "focus"/"blur" event and nsFocusManager should call something of editor directly. But I have no idea to decide focused editor before the editor getting "focus" event, sigh... > ::: editor/libeditor/EditorEventListener.cpp:1079 > (Diff revision 1) > > } > > > > nsresult > > -EditorEventListener::Focus(WidgetEvent* aFocusEvent) > > +EditorEventListener::Focus(InternalFocusEvent* aFocusEvent) > > { > > - if (NS_WARN_IF(!aFocusEvent) || DetachedFromEditor()) { > > + if (DetachedFromEditorOrDefaultPrevented(aFocusEvent)) { > > focus/blur shouldn't care about defaultPrevented(), so DetachedFromEditor() > should be enough Yeah, but DetachedFromEditorOrDefaultPrevented() is also checks if aFocusEvent is nullptr. Okay, I'll revert it as the current code.
Comment hidden (mozreview-request) |
Pushed by masayuki@d-toybox.com: https://hg.mozilla.org/integration/autoland/rev/fd66e733b075 EditorEventListener shouldn't handle odd focus/blur events which may be created in chrome script r=smaug
Comment 9•7 years ago
|
||
bugherder |
https://hg.mozilla.org/mozilla-central/rev/fd66e733b075
Status: ASSIGNED → RESOLVED
Closed: 7 years ago
status-firefox55:
--- → fixed
Resolution: --- → FIXED
Target Milestone: --- → mozilla55
Assignee | ||
Comment 10•7 years ago
|
||
https://treeherder.mozilla.org/#/jobs?repo=try&revision=d5daf64629d4
Updated•7 years ago
|
You need to log in
before you can comment on or make changes to this bug.
Description
•