Closed Bug 1536353 Opened 6 months ago Closed 6 months ago

PresShell::EventHandler does not need to treat untrusted event, but checked whether coming event is an untrusted event or not

Categories

(Core :: User events and focus handling, defect, P3)

defect

Tracking

()

RESOLVED FIXED
mozilla68
Tracking Status
firefox68 --- fixed

People

(Reporter: masayuki, Assigned: masayuki)

References

Details

Attachments

(3 files, 1 obsolete file)

Priority: -- → P3

PresShell::EventHandler shouldn't be used to dispatch untrusted event.
However, it checks whether the given event is trusted or untrusted somewhere
and that makes the code harder to understand. So, it should check each event
only with MOZ_ASSERT() or MOZ_DIAGNOSTIC_ASSERT() instead. Then,
developers can trust the event is always a trusted event.

PresShell::EventHandler::PrepareToDispatchEvent() checked whether the
given event is a trusted event or an untrusted event, but
PresShell::EventHandler::PrepareToDispatchOntextMenuEvent() didn't so.
However, now, both of them don't need to check it. Therefore, we can merge
them.

Pushed by masayuki@d-toybox.com:
https://hg.mozilla.org/integration/autoland/rev/64a815f04641
part 1: Make PresShell::EventHandler stop checking WidgetEvent::IsTrusted() at runtime in release channel r=smaug
https://hg.mozilla.org/integration/autoland/rev/6ef59933242a
part 2: Merge PresShell::EventHandler::PrepareToDispatchEvent() and PresShell::EventHandler::PrepareToDispatchContextMenuEvent() r=smaug

In normal cases, PresShell::EventHandler won't receive untrusted event.
However, only nsIDOMWindowUtils.dispatchDOMEventViaPresShell() may send
untrusted event if its aTrusted is false. Currently, this is not used by
chrome so that we don't need to keep supporting it for dispatching untrusted
events.

This patch removes aTrusted argument from it.

When adding an range via Selection::AddItem() and only when it's caused by
user's operation, the range may be split at non-selectable content. This is
done in nsRange::ExcludeNonSelectableNodes() but it modifies the given range
as the first range. Then, Selection::AddRangeInternal() calls
Selection::SelectFrames() with the range which may have been modified by
nsRange::ExcludeNonSelectableNodes()
.

Therefore, only the frames between first child of <body> element and
previous element of first non-selectable content are painted as selection
after user does "Select All".

Selection::Extend() calls Selection::SelectFrames() by itself for all
existing ranges
. Therefore, this patch creates new method and makes both
Selection::Extend() and Selection::SetStartAndEndInternal() call it only
when the result is not only one range.

Comment on attachment 9053539 [details]
Bug 1536353 - part 4: Make Selection::SetStartAndEndInternal() select frames by itself

Revision D24871 was moved to bug 1536852. Setting attachment 9053539 [details] to obsolete.

Attachment #9053539 - Attachment is obsolete: true
Pushed by masayuki@d-toybox.com:
https://hg.mozilla.org/integration/autoland/rev/d8b9492573ae
part 1: Make PresShell::EventHandler stop checking WidgetEvent::IsTrusted() at runtime in release channel r=smaug
https://hg.mozilla.org/integration/autoland/rev/6fc244ee32d6
part 2: Merge PresShell::EventHandler::PrepareToDispatchEvent() and PresShell::EventHandler::PrepareToDispatchContextMenuEvent() r=smaug
https://hg.mozilla.org/integration/autoland/rev/f05f8a612498
part 3: Make nsIDOMWindowUtils.dispatchDOMEventViaPresShell() dispatch only trusted event r=smaug
https://hg.mozilla.org/projects/ash/rev/d8b9492573ae028177a1b644bfcedddf26d7966a
Bug 1536353 - part 1: Make PresShell::EventHandler stop checking WidgetEvent::IsTrusted() at runtime in release channel r=smaug

https://hg.mozilla.org/projects/ash/rev/6fc244ee32d6a416a01422f994404e4492b9e84d
Bug 1536353 - part 2: Merge PresShell::EventHandler::PrepareToDispatchEvent() and PresShell::EventHandler::PrepareToDispatchContextMenuEvent() r=smaug

https://hg.mozilla.org/projects/ash/rev/f05f8a61249811eb2050f3f692ed28c94015ae38
Bug 1536353 - part 3: Make nsIDOMWindowUtils.dispatchDOMEventViaPresShell() dispatch only trusted event r=smaug
You need to log in before you can comment on or make changes to this bug.