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

RESOLVED FIXED in Firefox 42

Status

()

Core
Event Handling
RESOLVED FIXED
2 years ago
2 years ago

People

(Reporter: masayuki, Assigned: masayuki)

Tracking

(Blocks: 1 bug)

Trunk
mozilla42
Points:
---
Dependency tree / graph

Firefox Tracking Flags

(firefox42 fixed)

Details

Attachments

(1 attachment)

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.
Created attachment 8629882 [details] [diff] [review]
Patch
Attachment #8629882 - Flags: review?(bugs)

Comment 2

2 years ago
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

Comment 4

2 years ago
https://hg.mozilla.org/integration/mozilla-inbound/rev/6629ba7c735a
https://hg.mozilla.org/mozilla-central/rev/6629ba7c735a
Status: ASSIGNED → RESOLVED
Last Resolved: 2 years ago
status-firefox42: affected → fixed
Resolution: --- → FIXED
Target Milestone: --- → mozilla42
You need to log in before you can comment on or make changes to this bug.