Closed Bug 205006 Opened 22 years ago Closed 22 years ago

scrollSelectionIntoView off by one line when selection starts at beginning of a line

Categories

(Core :: DOM: Core & HTML, defect)

x86
Windows XP
defect
Not set
normal

Tracking

()

RESOLVED WONTFIX

People

(Reporter: bugzilla.mozilla.org-3, Unassigned)

Details

Attachments

(1 file)

2.05 KB, application/vnd.mozilla.xul+xml
Details
While I was working on a patch for bug 104383 I was told to use the following to scroll the current selection into view: getBrowser().docShell .QueryInterface(Components.interfaces.nsIInterfaceRequestor) .getInterface(Components.interfaces.nsISelectionDisplay) .QueryInterface(Components.interfaces.nsISelectionController) .scrollSelectionIntoView( Components.interfaces.nsISelectionController.SELECTION_NORMAL, Components.interfaces.nsISelectionController.SELECTION_ANCHOR_REGION, true); However, this fails when the selection starts at the beginning of a line. Instead the end of the previous line is scrolled into view. If the previous line longer than the current window size, horizontal scrolling will occur. I am using Mozilla 1.4b on WinXP.
Attached file Testcase: XUL page
This testcase displays a document that contains a number of lines. Steps to reproduce: 1. Load test case 2. Select the first word on line 91, e.g. using the mouse 3. Scroll the document to the beginning without clearing the selection 4. Observe that the end of the previous line is scrolled into view, not the selected word 5. An alert box shows the selection. Make sure that the selection does not include anything else than the first word, i.e. no linefeeds etc. Expected results: When the button is pressed the selected word should be visible.
The real issue was that the selection start's offset (cursor/caret) is logically after the "\n" at the end of the previous line. It was discovered that the intended effect of moving the selection to the next line can be achieved by setting the interline hint ("hintright"). Specicifically, bug 104383 is no using + selection.QueryInterface(Components.interfaces.nsISelectionPrivate) + .interlinePosition = true; which boils down to nsIFrameSelection::SetHint(HINTRIGHT) which has helped to achieve the desired effect. Marking WONTFIX since no further action is required.
Status: UNCONFIRMED → RESOLVED
Closed: 22 years ago
Resolution: --- → WONTFIX
Component: DOM: HTML → DOM: Core & HTML
QA Contact: desale → general
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: