Closed Bug 1180240 Opened 9 years ago Closed 9 years ago

ContentEventHandler::OnQuerySelectedText() should use mFirstSelectedRange if mSelection doesn't have selection range

Categories

(Core :: DOM: UI Events & Focus Handling, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla42
Tracking Status
firefox42 --- fixed

People

(Reporter: masayuki, Assigned: masayuki)

References

(Blocks 1 open bug)

Details

Attachments

(1 file)

By the fix of bug 1179090, ContentEventHandler assumes that there is a selection range [0-0] when there is not selection range actually.

On the other hand, in ContentEventHanldler::OnQuerySelectedText(), it uses mSelection->Get(Anchor|Focus)Node() for retrieving selection range. So, we should use mFirstSelectionRange if it doesn't return proper node.
Attached patch PatchSplinter Review
Attachment #8629882 - Flags: review?(bugs)
Comment on attachment 8629882 [details] [diff] [review]
Patch

>+    NS_ASSERTION(mFirstSelectedRange->Collapsed(),
>+     "When mSelection doesn't have selection, mFirstSelectedRange must be "
>+     "collapsed");
nit, 2 spaces for indentation


>+    anchorNode = focusNode = mFirstSelectedRange->GetStartParent();
It is guaranteed that mFirstSelectedRange is always non-null when this method is run, right?
Attachment #8629882 - Flags: review?(bugs) → review+
(In reply to Olli Pettay [:smaug] from comment #2)
> >+    anchorNode = focusNode = mFirstSelectedRange->GetStartParent();
> It is guaranteed that mFirstSelectedRange is always non-null when this
> method is run, right?

Yes. It's guaranteed at initializing the members:
http://mxr.mozilla.org/mozilla-central/source/dom/events/ContentEventHandler.cpp?rev=20245e58fd57&mark=108-111#85
https://hg.mozilla.org/mozilla-central/rev/6629ba7c735a
Status: ASSIGNED → RESOLVED
Closed: 9 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla42
Component: Event Handling → User events and focus handling
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: