Add a Native selection mode browse mode setting, disabled by default (#20665)
Replaces #18535
Fixes #15908
Summary of the issue:
When selecting text in browse mode, NVDA normally only updates its own internal selection. The application does not see this selection. Copying with control+c therefore copies plain text only. Formatting, links and table structure are lost.
NVDA has a native selection mode to address this. When it is on, NVDA also updates the selection in the application. Copying then uses the application's own copy functionality, and rich content is preserved. This mode is off by default. It must be turned on manually in every document with NVDA+shift+f10.
#15908 asks for native selection to be active automatically. #18535 implemented this by enabling native selection mode by default in supporting browsers. It was closed as abandoned while blocked by #19075 and #18028. Both blockers have since been fixed.
Description of user facing changes:
A new "Native selection mode" feature flag in NVDA's browse mode settings. The default behaviour is still Off.
Description of developer facing changes:
A new nativeSelectionMode bool feature flag in the [virtualBuffers] section of the configuration specification.
A new method on CursorManager: _initialize_nativeAppSelectionModeSupport. Browse mode implementations which can turn on native selection mode automatically should override it.
Description of development approach:
When a browse mode document gains focus for the first time, it needs a chance to turn on native selection mode. A new method provides this hook: _initialize_nativeAppSelectionModeSupport. BrowseModeDocumentTreeInterceptor.event_treeInterceptor_gainFocus calls it once per document, and only when the new setting is enabled. Implementations therefore do not read the setting themselves. A future implementation which forgets about the setting cannot enable the feature against the user's configuration.
The base implementation on CursorManager does nothing. This is deliberate: Microsoft Word and UIA documents define their native selection state as class attributes and do not override the hook. A base implementation which resets that state would turn off native selection in Word and Outlook.
The Gecko virtual buffer overrides the hook. It probes for support by clearing the native selection and then setting it to the current browse mode selection. When the probe succeeds, it turns native selection mode on. When the probe fails, such as in browsers based on Chromium older than 134, nothing changes: the mode stays off, and NVDA+shift+f10 reports that native selection is unsupported when tried.
Differences from #18535, besides the setting itself:
Enable Native selection mode by default in browsers #18535 enabled the mode through a class attribute on the Gecko buffer and reset both state attributes to False in the base hook. The reset would have broken native selection in Microsoft Word and Outlook, as described above.
Enable Native selection mode by default in browsers #18535 also called the hook on every focus change within the document (from _postGainFocus). This would revert a manual toggle-off at the next focus move, and would issue selection COM calls on every focus change. The hook is now called once per document.
Enable Native selection mode by default in browsers #18535 marked native selection as unsupported when the probe failed. This PR leaves the supported state untouched on failure. The manual toggle then retries and reports failure itself, exactly as on master.