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

Unified Diff: dart/site/try/src/selection.dart

Issue 266293002: Make Try Dart tests run on Firefox. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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;
+}

Powered by Google App Engine
This is Rietveld 408576698