| Index: dart/site/try/src/selection.dart
|
| diff --git a/dart/site/try/src/selection.dart b/dart/site/try/src/selection.dart
|
| index bc918f4cea1285601be67fa5811153134b9e143e..35e17a8bab13d09753ca7ad3746f5b0f3a7fc9a7 100644
|
| --- a/dart/site/try/src/selection.dart
|
| +++ b/dart/site/try/src/selection.dart
|
| @@ -16,27 +16,15 @@ import 'decoration.dart';
|
|
|
| class TrySelection {
|
| final Node root;
|
| - final String text;
|
| - final int globalOffset;
|
| -
|
| Node anchorNode;
|
| int anchorOffset;
|
|
|
| - TrySelection.internal(
|
| - this.root, this.text, this.globalOffset,
|
| - this.anchorNode, this.anchorOffset);
|
| -
|
| - factory TrySelection(Node root, Selection selection, String text) {
|
| - if (selection.isCollapsed) {
|
| - Node anchorNode = selection.anchorNode;
|
| - int anchorOffset = selection.anchorOffset;
|
| - return new TrySelection.internal(
|
| - root, text, computeGlobalOffset(root, anchorNode, anchorOffset),
|
| - anchorNode, anchorOffset);
|
| - } else {
|
| - return new TrySelection.internal(root, text, -1, null, -1);
|
| - }
|
| - }
|
| + String text;
|
| + int globalOffset = -1;
|
| +
|
| + TrySelection(this.root, Selection selection)
|
| + : this.anchorNode = selection.isCollapsed ? selection.anchorNode : null,
|
| + this.anchorOffset = selection.isCollapsed ? selection.anchorOffset : -1;
|
|
|
| Text addNodeFromSubstring(int start,
|
| int end,
|
| @@ -62,6 +50,11 @@ class TrySelection {
|
| }
|
| }
|
|
|
| + void updateText(String newText) {
|
| + text = newText;
|
| + globalOffset = computeGlobalOffset(root, anchorNode, anchorOffset);
|
| + }
|
| +
|
| /// Computes the global offset, that is, the offset from [root].
|
| static int computeGlobalOffset(Node root, Node anchorNode, int anchorOffset) {
|
| if (anchorOffset == -1) return -1;
|
|
|