Chromium Code Reviews| Index: dart/site/try/src/selection.dart |
| diff --git a/dart/site/try/src/selection.dart b/dart/site/try/src/selection.dart |
| index 35e17a8bab13d09753ca7ad3746f5b0f3a7fc9a7..4ce3cce485a64186156ee69a2f574f2af7c91c50 100644 |
| --- a/dart/site/try/src/selection.dart |
| +++ b/dart/site/try/src/selection.dart |
| @@ -23,8 +23,9 @@ class TrySelection { |
| int globalOffset = -1; |
| TrySelection(this.root, Selection selection) |
| - : this.anchorNode = selection.isCollapsed ? selection.anchorNode : null, |
| - this.anchorOffset = selection.isCollapsed ? selection.anchorOffset : -1; |
| + : this.anchorNode = isCollapsed(selection) ? selection.anchorNode : null, |
|
kasperl
2014/05/06 04:42:22
You could get rid of the 'this.' prefixes here (th
ahe
2014/05/06 08:10:16
Done.
|
| + this.anchorOffset = |
| + isCollapsed(selection) ? selection.anchorOffset : -1; |
| Text addNodeFromSubstring(int start, |
| int end, |
| @@ -74,3 +75,9 @@ class TrySelection { |
| return -1; |
| } |
| } |
| + |
| +bool isCollapsed(Selection selection) { |
| + // Firefox and Chrome don't agree on if the selection is collapsed if there |
| + // is no node selected. |
| + return selection.isCollapsed && selection.anchorNode != null; |
| +} |