Bug 1487591 - Make Selection treat AccessibleCaretEventHub as concrete class rather than nsISelectionListener r=smaug
AccessibleCaretEventHub is an nsISelectionListener of Selection whose type is
"normal". This is added only when nsFrameSelection::Init() is called and
accessible caret is enabled. Additionally, nsFrameSelection::Init() is
always called immediately after creating nsFrameSelection.
Therefore, when AccessibleCaretEventHub is installed to Selection, this is
always second selection listener and won't be installed multiple times. So,
Selection can store pointer of AccessibleCaretEventHub directly only when
it's enabled and the Selection needs to notify it of selection change.
This patch makes Selection stores AccessibleCaretEventHub with RefPtr, then,
makes Selection::NotifySelectionListeners() call its OnSelectionChange()
immediately after AutoCopyListener.
Unfortunately, this patch includes making of MOZ_CAN_RUN_SCRIPT_BOUNDARY and
MOZ_CAN_RUN_SCRIPT a lot since some methods of AccessibleCaretEventHub are
marked as MOZ_CAN_RUN_SCRIPT and including AccessibleCaretEventHub.h into
Selection.h causes compile the compile errors.
Differential Revision: https://phabricator.services.mozilla.com/D4733

--- a/dom/base/nsCopySupport.h+++ b/dom/base/nsCopySupport.h@@ -46,16 +46,17 @@ class nsCopySupport // Get the selection as a transferable. Similar to HTMLCopy except does // not deal with the clipboard. static nsresult GetTransferableForSelection(mozilla::dom::Selection* aSelection, nsIDocument* aDocument, nsITransferable** aTransferable); // Same as GetTransferableForSelection, but doesn't skip invisible content.+ MOZ_CAN_RUN_SCRIPT_BOUNDARY static nsresult GetTransferableForNode(nsINode* aNode, nsIDocument* aDoc, nsITransferable** aTransferable); /** * Retrieve the selection for the given document. If the current focus * within the document has its own selection, aSelection will be set to it * and this focused content node returned. Otherwise, aSelection will be * set to the document's selection and null will be returned.