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

Side by Side Diff: dart/site/try/src/selection.dart

Issue 265063002: Better handling of large files. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Merged with r35799 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « dart/site/try/src/interaction_manager.dart ('k') | dart/tests/try/cursor_position_test.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 library trydart.selection; 5 library trydart.selection;
6 6
7 import 'dart:html' show 7 import 'dart:html' show
8 CharacterData, 8 CharacterData,
9 Node, 9 Node,
10 NodeFilter, 10 NodeFilter,
(...skipping 16 matching lines...) Expand all
27 anchorOffset = isCollapsed(selection) ? selection.anchorOffset : -1; 27 anchorOffset = isCollapsed(selection) ? selection.anchorOffset : -1;
28 28
29 Text addNodeFromSubstring(int start, 29 Text addNodeFromSubstring(int start,
30 int end, 30 int end,
31 List<Node> nodes, 31 List<Node> nodes,
32 [Decoration decoration]) { 32 [Decoration decoration]) {
33 if (start == end) return null; 33 if (start == end) return null;
34 34
35 Text textNode = new Text(text.substring(start, end)); 35 Text textNode = new Text(text.substring(start, end));
36 36
37 if (start <= globalOffset && globalOffset < end) { 37 if (start <= globalOffset && globalOffset <= end) {
38 anchorNode = textNode; 38 anchorNode = textNode;
39 anchorOffset = globalOffset - start; 39 anchorOffset = globalOffset - start;
40 } 40 }
41 41
42 nodes.add(decoration == null ? textNode : decoration.applyTo(textNode)); 42 nodes.add(decoration == null ? textNode : decoration.applyTo(textNode));
43 43
44 return textNode; 44 return textNode;
45 } 45 }
46 46
47 void adjust(Selection selection) { 47 void adjust(Selection selection) {
(...skipping 25 matching lines...) Expand all
73 73
74 return -1; 74 return -1;
75 } 75 }
76 } 76 }
77 77
78 bool isCollapsed(Selection selection) { 78 bool isCollapsed(Selection selection) {
79 // Firefox and Chrome don't agree on if the selection is collapsed if there 79 // Firefox and Chrome don't agree on if the selection is collapsed if there
80 // is no node selected. 80 // is no node selected.
81 return selection.isCollapsed && selection.anchorNode != null; 81 return selection.isCollapsed && selection.anchorNode != null;
82 } 82 }
OLDNEW
« no previous file with comments | « dart/site/try/src/interaction_manager.dart ('k') | dart/tests/try/cursor_position_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698