Fix scrolling in ui.browseableMessage for plain and HTML messages (#21181) (#21186)
Fixes #21181
Summary of the issue:
In ui.browseableMessage (which uses HtmlMessageDialog backed by MSHTML browse mode):
Plain text messages wrapped in a single monolithic <pre> element never scroll when navigating down through lines past the viewport, leaving content clipped off-screen.
In HTML messages (paragraphs and tables), MSHTML.scrollIntoView unconditionally calls HTMLNode.scrollIntoView() with no arguments, which in MSHTML defaults to aligning elements to the top of the viewport. Every down-arrow step jumps the newly focused paragraph or table row to the top of the window even when already fully visible, disrupting reading and misaligning the Browse Mode visual highlighter.
Description of user facing changes:
Multiline plain text messages in ui.browseableMessage now scroll smoothly as the user navigates past the viewport boundary.
HTML messages in ui.browseableMessage no longer jump to the top of the viewport prematurely when navigating across elements that are already visible on screen.
Description of developer facing changes:
None.
Description of development approach:
In source/NVDAObjects/IAccessible/MSHTML.py, updated scrollIntoView() to inspect getBoundingClientRect() against doc.documentElement.clientHeight and clientWidth. If the element is already completely inside the viewport both vertically and horizontally, scrolling is suppressed. If below or extending past the right edge, it aligns bottom/right (scrollInToView(False)); if above or extending past the left edge, it aligns top/left (scrollInToView(True)).
In source/ui.py::browseableMessage, split plain text messages by line (message.splitlines(keepends=True)) and wrap each line in <div>{escape(line)}</div> inside <pre>. This gives MSHTML and browse mode individual element handles for each line, enabling accurate line-level scrolling and tracking without altering formatting or clipboard copy behavior.
Added unit tests in tests/unit/test_browseableMessage.py for plain text line wrapping and HTML entity escaping.