Closed Bug 1486370 Opened 4 years ago Closed 4 years ago
Auto Copy Listener not derived from ns ISelection Listener
46 bytes, text/x-phabricator-request
|Details | Review|
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 email@example.com: https://hg.mozilla.org/integration/autoland/rev/c36af4e5a515 Change nsAutoCopyListener to a static class r=smaug
You need to log in before you can comment on or make changes to this bug.