Closed Bug 1486370 Opened Last year Closed Last year

Make nsAutoCopyListener not derived from nsISelectionListener

Categories

(Core :: Selection, enhancement)

enhancement
Not set

Tracking

()

RESOLVED FIXED
mozilla63
Tracking Status
firefox63 --- fixed

People

(Reporter: masayuki, Assigned: masayuki)

References

(Blocks 1 open bug)

Details

Attachments

(1 file)

According to profile of bug 1346723, Selection::NotifySelectionListeners() is still slow.  So, if we can make it notify some selection listeners directly, we can save the cost of copying listener array to local variable and virtual calls.

nsAutoCopyListener is singleton class, and it's always added to normal selection as first listener.  So, we can make it just a static class and make Selection::NotifySelectionListeners() notify nsAutoCopyListener directly.
nsAutoCopyListener is a singleton class but refcountable and a selection
listener.  nsFrameSelection adds it to only normal Selection when it's on
macOS or it's enabled by the pref.  Additionally, it's always first selection
listener since it's added immediately after Selection instance is created.

So, we can make it a static class, and normal Selection instance should have
a bool to decide whether it should notify nsAutoCopyListener of its changes.
Then, we can save the cost of grabbing it with local RefPtr and the virtual
call.

Additionally, this patch renames nsAutoCopyListener to mozilla::AutoCopyListener
and optimizes constructor of nsFrameSelection (using bool var cache to retrieve
the pref, avoid retrieving the pref on macOS).
Comment on attachment 9004750 [details]
Bug 1486370 - Change nsAutoCopyListener to a static class

Olli Pettay [:smaug] has approved the revision.
Attachment #9004750 - Flags: review+
Pushed by masayuki@d-toybox.com:
https://hg.mozilla.org/integration/autoland/rev/c36af4e5a515
Change nsAutoCopyListener to a static class r=smaug
https://hg.mozilla.org/mozilla-central/rev/c36af4e5a515
Status: ASSIGNED → RESOLVED
Closed: Last year
Resolution: --- → FIXED
Target Milestone: --- → mozilla63
You need to log in before you can comment on or make changes to this bug.