Closed Bug 1179090 Opened 6 years ago Closed 6 years ago

ContentEventHandler should assume that the selection range is [0-0] when there is not 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)

When WidgetQueryContentEvent queries the whole contents of the document, there may be no selection range. In such case, ContentEventHandler should assume that there is a selection range [0-0].
Attached patch PatchSplinter Review
See comment 0 and the comment in this patch for the detail.
Attachment #8628576 - Flags: review?(bugs)
Comment on attachment 8628576 [details] [diff] [review]
Patch

>+  if (!mSelection->RangeCount()) {
>+    // If there is no selection range, we should compute the selection root
>+    // with ancestor limiter and root content of the document.
compute the selection root from ancestor limiter or root content of the document
(I think)


>+    rv = mSelection->GetAncestorLimiter(getter_AddRefs(mRootContent));
>+    if (NS_WARN_IF(NS_FAILED(rv))) {
>+      return NS_ERROR_FAILURE;
>+    }
>+    if (!mRootContent) {
>+      mRootContent = mPresShell->GetDocument()->GetRootElement();
>+      if (NS_WARN_IF(!mRootContent)) {
>+        // Although, this is possible in XML/XHTML document.  However,
>+        // ContentEventHandler won't support such rare case for now.
HTML documents may not have root element after
document.removeChild(document.documentElement);
So, perhaps just drop the comment.
Attachment #8628576 - Flags: review?(bugs) → review+
https://hg.mozilla.org/mozilla-central/rev/20245e58fd57
Status: ASSIGNED → RESOLVED
Closed: 6 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.