Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(506)

Issue 542623003: Fix Try Dart handling of Backspace that joins lines (Closed)

Created:
6 years, 3 months ago by aam-me
Modified:
6 years, 3 months ago
Reviewers:
ahe
CC:
reviews_dartlang.org, lukechurch, Johnni Winther, kasperl
Visibility:
Public.

Description

Fix Try Dart handling of Backspace that joins lines BUG=dartbug.com/20731 R=ahe@google.com Committed: https://code.google.com/p/dart/source/detail?r=39930

Patch Set 1 #

Total comments: 3

Patch Set 2 : Added applescript to validate Firefox line-merging fix #

Total comments: 1
Unified diffs Side-by-side diffs Delta from patch set Stats (+99 lines, -1 line) Patch
M site/try/src/interaction_manager.dart View 1 chunk +1 line, -1 line 0 comments Download
A tests/try/firefox-linemerges.applescript View 1 1 chunk +98 lines, -0 lines 1 comment Download

Messages

Total messages: 16 (1 generated)
aam-me
Hi Peter, with [modify] fix in place this is the only thing remaining in Firefox ...
6 years, 3 months ago (2014-09-04 10:37:46 UTC) #2
ahe
https://codereview.chromium.org/542623003/diff/1/site/try/src/interaction_manager.dart File site/try/src/interaction_manager.dart (right): https://codereview.chromium.org/542623003/diff/1/site/try/src/interaction_manager.dart#newcode1237 site/try/src/interaction_manager.dart:1237: if (first is Text && line.nextNode != null) { ...
6 years, 3 months ago (2014-09-04 11:42:37 UTC) #3
aam-me
https://codereview.chromium.org/542623003/diff/1/site/try/src/interaction_manager.dart File site/try/src/interaction_manager.dart (right): https://codereview.chromium.org/542623003/diff/1/site/try/src/interaction_manager.dart#newcode1237 site/try/src/interaction_manager.dart:1237: if (first is Text && line.nextNode != null) { ...
6 years, 3 months ago (2014-09-04 12:01:06 UTC) #4
ahe
I sounds like you have found the right approach to this really annoying problem. Can ...
6 years, 3 months ago (2014-09-04 12:11:10 UTC) #5
aam-me
On 2014/09/04 12:11:10, ahe wrote: > I sounds like you have found the right approach ...
6 years, 3 months ago (2014-09-04 12:21:49 UTC) #6
ahe
On 2014/09/04 12:21:49, aam wrote: > Sure. I have looked at it briefly, but got ...
6 years, 3 months ago (2014-09-04 12:31:34 UTC) #7
ahe
On 2014/09/04 12:31:34, ahe wrote: > On 2014/09/04 12:21:49, aam wrote: > > Sure. I ...
6 years, 3 months ago (2014-09-04 12:42:20 UTC) #8
ahe
On 2014/09/04 12:42:20, ahe wrote: > On 2014/09/04 12:31:34, ahe wrote: > > On 2014/09/04 ...
6 years, 3 months ago (2014-09-05 09:52:37 UTC) #9
ahe
On 2014/09/05 09:52:37, ahe wrote: > But as we already know, modify doesn't work in ...
6 years, 3 months ago (2014-09-05 09:59:37 UTC) #10
aam-me
> So perhaps you could make a test based on AppleScript? Hi Peter, can you ...
6 years, 3 months ago (2014-09-05 11:06:10 UTC) #11
ahe
On 2014/09/05 09:59:37, ahe wrote: > window.getSelection().createRange().moveStart('character', -1) That doesn't work :-( IE11 removed window.selection, ...
6 years, 3 months ago (2014-09-05 12:08:25 UTC) #12
ahe
LGTM https://codereview.chromium.org/542623003/diff/20001/tests/try/firefox-linemerges.applescript File tests/try/firefox-linemerges.applescript (right): https://codereview.chromium.org/542623003/diff/20001/tests/try/firefox-linemerges.applescript#newcode33 tests/try/firefox-linemerges.applescript:33: repeat 8 times Fancy stuff :-)
6 years, 3 months ago (2014-09-05 13:10:44 UTC) #13
aam-me
Committed patchset #2 (id:20001) manually as 39930 (presubmit successful).
6 years, 3 months ago (2014-09-05 21:03:36 UTC) #14
aam-me
On 2014/09/05 12:08:25, ahe wrote: > On 2014/09/05 09:59:37, ahe wrote: > > window.getSelection().createRange().moveStart('character', -1) ...
6 years, 3 months ago (2014-09-08 05:09:56 UTC) #15
ahe
6 years, 3 months ago (2014-09-08 08:30:25 UTC) #16
Message was sent while issue was closed.
On 2014/09/08 05:09:56, aam wrote:
> On 2014/09/05 12:08:25, ahe wrote:
> > On 2014/09/05 09:59:37, ahe wrote:
> > > window.getSelection().createRange().moveStart('character', -1)
> > 
> > That doesn't work :-(
> > 
> > IE11 removed window.selection, but window.getSelection() isn't compatible.
> > 
> > So far I've managed to create a TextRange, but I'm having a hard time
> > initializing it to the selection.
> 
> I managed to write simple backspace test passing on IE11 using TextRange
> moveToPoint/moveStart/execCommand:
> 
> === JS ===
>       var range = window.getSelection().getRangeAt(0).cloneRange();
>       range.collapse(true);
>       var rects = range.getClientRects();
>       if (rects.length > 0) {
>         var rect = range.getClientRects()[0];
>         var r = document.body.createTextRange();
>         r.moveToPoint(rect.left, rect.top);
>         r.moveStart("character", -1);
>         r.execCommand("Delete");
>       }
> === end of JS ===
> 
> === Dart ===
> import 'dart:js' as hack;
> ...
>         var sel = window.getSelection();
>         var range = sel.getRangeAt(0).cloneRange();
>         range.collapse(true);
>         var rects = range.getClientRects();
>         if (rects.length > 0) {
>           var rect = rects[0];
>           var d = hack.context['document'];
>           var b = new hack.JsObject.fromBrowserObject(d.body);
>           var r = b.callMethod('createTextRange');
> 
>           r.callMethod("moveToPoint", [rect.left, rect.top]);
>           r.callMethod("moveStart", ["character", -1]);
>           r.callMethod("execCommand", ["Delete"]);
>         }
>       }
> === end of Dart ===

Awesome. We can also polyfill Selection.modify using this approach. I always got
"unspecified error" when calling "moveStart", but perhaps that is because I
called it from the developer console.

Powered by Google App Engine
This is Rietveld 408576698