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

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

Issue 225893002: Refactor code to prepare for line-based tokenization. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 9 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
« no previous file with comments | « dart/site/try/src/interaction_manager.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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;
« no previous file with comments | « dart/site/try/src/interaction_manager.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698