Closed Bug 1074736 Opened 10 years ago Closed 10 years ago

[Text Selection] Selection carets should consider multiple ranges selection

Categories

(Core :: DOM: Selection, defect, P1)

x86
macOS
defect

Tracking

()

RESOLVED FIXED
mozilla36

People

(Reporter: mtseng, Assigned: mtseng)

References

Details

Attachments

(3 files, 9 obsolete files)

3.17 KB, patch
mdas
: review+
Details | Diff | Splinter Review
10.47 KB, patch
Details | Diff | Splinter Review
6.40 KB, patch
Details | Diff | Splinter Review
In Bug 739396, we split a range to multiple ranges if selection content contains some non-selectable element. In this case, selection carets should support multiple ranges as well.
Attached patch wip:multiple-range (obsolete) — Splinter Review
This is wip for supporting multiple range. The idea is using first range to show start caret and using last range to show end caret. roc, could you give some feedback about this patch? thanks.
Attachment #8497389 - Flags: feedback?(roc)
Priority: -- → P1
Comment on attachment 8497389 [details] [diff] [review]
wip:multiple-range

Review of attachment 8497389 [details] [diff] [review]:
-----------------------------------------------------------------

Seems like a reasonable thing to do if we don't plan to have UX for multiple ranges.
Attachment #8497389 - Flags: feedback?(roc) → feedback+
Attached patch bug1074736 (obsolete) — Splinter Review
Ready for review!
Attachment #8497389 - Attachment is obsolete: true
Attachment #8507631 - Flags: review?(roc)
Attached patch bug1074736 v2 (obsolete) — Splinter Review
Rebased.
Attachment #8507631 - Attachment is obsolete: true
Attachment #8507631 - Flags: review?(roc)
Attachment #8507679 - Flags: review?(roc)
Comment on attachment 8507679 [details] [diff] [review]
bug1074736 v2

Review of attachment 8507679 [details] [diff] [review]:
-----------------------------------------------------------------

::: layout/base/SelectionCarets.cpp
@@ +389,5 @@
>      return;
>    }
>  
> +  int32_t rangeCount = selection->GetRangeCount();
> +  if (rangeCount <= 0) {

A collapsed selection must have at least one range, so you can take this check out.

@@ +395,5 @@
>      return;
>    }
>  
> +  nsRefPtr<nsRange> rangeStart = selection->GetRangeAt(0);
> +  nsRefPtr<nsRange> rangeEnd = selection->GetRangeAt(rangeCount - 1);

Call these firstRange, lastRange. rangeStart sounds like the start of a range.
Attachment #8507679 - Flags: review?(roc) → review+
Attached patch bug1074736 v3 (carry r+: roc) (obsolete) — Splinter Review
Fix addressed comment.

try push: https://treeherder.mozilla.org/ui/#/jobs?repo=try&revision=b918d73c5c22

I'll attach new testcase for this bug later.
Attachment #8507679 - Attachment is obsolete: true
Comment on attachment 8509245 [details] [diff] [review]
Marionette test part 1: selection_rect_list should consider multiple range as well

Review of attachment 8509245 [details] [diff] [review]:
-----------------------------------------------------------------

::: testing/marionette/client/marionette/selection.py
@@ +77,1 @@
>          '''Return the selection's DOMRectList object.

Please update the document. '''Returns the selection's DOMRectList object for the range at given idx.'''

@@ +77,5 @@
>          '''Return the selection's DOMRectList object.
>  
>          If the element is either <input> or <textarea>, return the selection's
>          DOMRectList within the element. Otherwise, return the DOMRectList of the
>          current selection.

Ditto.
Attachment #8509245 - Flags: feedback?(tlin) → feedback+
Comment on attachment 8509246 [details] [diff] [review]
Marionette test part 2: Marionette tests for selection carets with multiple range support

Review of attachment 8509246 [details] [diff] [review]:
-----------------------------------------------------------------

Selection Carets should support multiple range in non-editable fields. How about we just name the files test_selectioncarets_noneditable.py and test_selectioncarets_noneditable.html?

::: layout/base/tests/marionette/test_selectioncarets_multiplerange.py
@@ +37,5 @@
> +        self._nonsel1 = self.marionette.find_element(By.ID, 'nonsel1')
> +
> +    def _long_press_without_contextmenu(self, el, x, y):
> +        return self.actions.press(el, x, y).move_by_offset(0, 0).\
> +            wait(self._long_press_time).release()

Perhaps marionette should support a mechanism for this. Reviewer in ateam might have some ideas. :-)
Attachment #8509246 - Flags: feedback?(tlin) → feedback+
(In reply to Ting-Yu Lin [:TYLin] (UTC+8) from comment #11)
> Comment on attachment 8509246 [details] [diff] [review]
> Marionette test part 2: Marionette tests for selection carets with multiple
> range support
> 
> Review of attachment 8509246 [details] [diff] [review]:
> -----------------------------------------------------------------
> 
> Selection Carets should support multiple range in non-editable fields. How
> about we just name the files test_selectioncarets_noneditable.py and
> test_selectioncarets_noneditable.html?
This test is only for multiple range. I'll add tests for non-editable fields in another bug.

> 
> ::: layout/base/tests/marionette/test_selectioncarets_multiplerange.py
> @@ +37,5 @@
> > +        self._nonsel1 = self.marionette.find_element(By.ID, 'nonsel1')
> > +
> > +    def _long_press_without_contextmenu(self, el, x, y):
> > +        return self.actions.press(el, x, y).move_by_offset(0, 0).\
> > +            wait(self._long_press_time).release()
> 
> Perhaps marionette should support a mechanism for this. Reviewer in ateam
> might have some ideas. :-)
Attachment #8509246 - Flags: review?(mdas)
Attachment #8510021 - Flags: review?(mdas) → review+
Comment on attachment 8509246 [details] [diff] [review]
Marionette test part 2: Marionette tests for selection carets with multiple range support

Review of attachment 8509246 [details] [diff] [review]:
-----------------------------------------------------------------

r+ provided it passes in b2g. You should run this against try's emulators just to make sure. If it doesn't, then add b2g = false to the manifest entry
Attachment #8509246 - Flags: review?(mdas) → review+
Comment on attachment 8509246 [details] [diff] [review]
Marionette test part 2: Marionette tests for selection carets with multiple range support

Review of attachment 8509246 [details] [diff] [review]:
-----------------------------------------------------------------

I missed this question

::: layout/base/tests/marionette/test_selectioncarets_multiplerange.py
@@ +37,5 @@
> +        self._nonsel1 = self.marionette.find_element(By.ID, 'nonsel1')
> +
> +    def _long_press_without_contextmenu(self, el, x, y):
> +        return self.actions.press(el, x, y).move_by_offset(0, 0).\
> +            wait(self._long_press_time).release()

Are you trying to press something without the context menu event being fired?
rebased
Attachment #8508412 - Attachment is obsolete: true
(In reply to Malini Das [:mdas] from comment #15)
> Comment on attachment 8509246 [details] [diff] [review]
> Marionette test part 2: Marionette tests for selection carets with multiple
> range support
> 
> Review of attachment 8509246 [details] [diff] [review]:
> -----------------------------------------------------------------
> 
> I missed this question
> 
> ::: layout/base/tests/marionette/test_selectioncarets_multiplerange.py
> @@ +37,5 @@
> > +        self._nonsel1 = self.marionette.find_element(By.ID, 'nonsel1')
> > +
> > +    def _long_press_without_contextmenu(self, el, x, y):
> > +        return self.actions.press(el, x, y).move_by_offset(0, 0).\
> > +            wait(self._long_press_time).release()
> 
> Are you trying to press something without the context menu event being fired?

Yes, according to the code at marionette-listener.js, we'll send context menu event when isTap is true. So I made a workaround here let it move by offset with (0, 0) so isTap status would be reset after this move and then context menu won't be fired.
sorry had to back this out for test failures on windows like https://treeherder.mozilla.org/ui/logviewer.html#?job_id=3282505&repo=mozilla-inbound
Flags: needinfo?(mtseng)
Fix windows failure. This failure is because "select word" action on window would select extra tail space so our testcase would failed. So I strip space before doing test.

Try run: https://treeherder.mozilla.org/ui/#/jobs?repo=try&revision=7ac982300815
Attachment #8510843 - Attachment is obsolete: true
Flags: needinfo?(mtseng)
try looks good.
Keywords: checkin-needed
https://hg.mozilla.org/mozilla-central/rev/fb1c7fef9214
https://hg.mozilla.org/mozilla-central/rev/3863e1d10b69
https://hg.mozilla.org/mozilla-central/rev/7ce56791b0b7
Status: REOPENED → RESOLVED
Closed: 10 years ago10 years ago
Flags: in-testsuite+
Resolution: --- → FIXED
Target Milestone: --- → mozilla36
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: