Closed Bug 765390 Opened 12 years ago Closed 12 years ago

Text selection should be cleared on page navigation

Categories

(Firefox for Android Graveyard :: Text Selection, defect)

ARM
Android
defect
Not set
normal

Tracking

(firefox15 verified, firefox16 verified, firefox17 verified)

VERIFIED FIXED
Firefox 16
Tracking Status
firefox15 --- verified
firefox16 --- verified
firefox17 --- verified

People

(Reporter: Margaret, Assigned: Margaret)

References

Details

Attachments

(3 files)

The selection won't be visible, but if you single tap in the correct place, endSelection will copy the selected text from the previous page to the clipboard.
(This is built on top of my patch queue, so it may not apply to m-c)

We've been checking _view to see if there's an active selection or not, and that can be flaky, since the view could be destroyed before we get the chance to officially clean up after ourselves in endSelection. I also feel like this just makes the code less confusing to follow.
Assignee: nobody → margaret.leibovic
Attachment #635976 - Flags: review?(mbrubeck)
I tested this by navigating to a new page in a tab with an active selection, as well as closing a tab with an active selection. I tried to make sure hideHandles is always called, so we're always removing this listener, and it looks like it is.
Attachment #635978 - Flags: review?(mbrubeck)
Attachment #635976 - Flags: review?(mbrubeck) → review+
Comment on attachment 635978 [details] [diff] [review]
(Part 2) End selection on pagehide

>+      case "pagehide":
>+        this.endSelection(0, 0);
>+        break;

I'm slightly concerned that in the rare cases where (0,0) is within the selection, this will still copy the text.  Maybe instead you should omit the arguments or pass null, and check for that in endSelection?  (The same problem already exists in the call from startSelection.)
Attachment #635978 - Flags: review?(mbrubeck) → review+
(In reply to Matt Brubeck (:mbrubeck) from comment #3)
> Comment on attachment 635978 [details] [diff] [review]
> (Part 2) End selection on pagehide
> 
> >+      case "pagehide":
> >+        this.endSelection(0, 0);
> >+        break;
> 
> I'm slightly concerned that in the rare cases where (0,0) is within the
> selection, this will still copy the text.  Maybe instead you should omit the
> arguments or pass null, and check for that in endSelection?  (The same
> problem already exists in the call from startSelection.)

Good call.
Attachment #635995 - Flags: review?(mbrubeck)
Comment on attachment 635995 [details] [diff] [review]
(Part 3) Don't always pass coordinates to endSelection

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

r=me with one nit fixed.

::: mobile/android/chrome/content/browser.js
@@ +1586,5 @@
>        }
>      }
>  
>      // Only try copying text if there's text to copy!
> +    if (aX && aY && selectedText.length) {

This will fail when aX or aY is legitimately zero.  You should check arguments.length instead, or (aX !== undefined && aY !== undefined), or typeof aX == "number"... choose your poison.  :)
Attachment #635995 - Flags: review?(mbrubeck) → review+
Uplifted to aurora as part of a roll-up patch:
https://hg.mozilla.org/releases/mozilla-aurora/rev/2fb0a358eaf6
Component: General → Text Selection
Status: RESOLVED → VERIFIED
Product: Firefox for Android → Firefox for Android Graveyard
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: