Closed Bug 1180240 Opened 7 years ago Closed 7 years ago
Event Handler::On Query Selected Text() should use m First Selected Range if m Selection doesn't have selection range
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.
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
Component: Event Handling → User events and focus handling
You need to log in before you can comment on or make changes to this bug.