Chromium Code Reviews| OLD | NEW |
|---|---|
| 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.interaction_manager; | 5 library trydart.interaction_manager; |
| 6 | 6 |
| 7 import 'dart:html'; | 7 import 'dart:html'; |
| 8 | 8 |
| 9 import 'dart:convert' show | 9 import 'dart:convert' show |
| 10 JSON; | 10 JSON; |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 87 | 87 |
| 88 /** | 88 /** |
| 89 * UI interaction manager for the entire application. | 89 * UI interaction manager for the entire application. |
| 90 */ | 90 */ |
| 91 abstract class InteractionManager { | 91 abstract class InteractionManager { |
| 92 // Design note: All UI interactions go through one instance of this | 92 // Design note: All UI interactions go through one instance of this |
| 93 // class. This is by design. | 93 // class. This is by design. |
| 94 // | 94 // |
| 95 // Simplicity in UI is in the eye of the beholder, not the implementor. Great | 95 // Simplicity in UI is in the eye of the beholder, not the implementor. Great |
| 96 // 'natural UI' is usually achieved with substantial implementation | 96 // 'natural UI' is usually achieved with substantial implementation |
| 97 // complexity that doesn't modularise well and has nasty complicated state | 97 // complexity that doesn't modularize well and has nasty complicated state |
|
ahe
2014/05/14 11:01:24
Sometimes I encounter a bug in Chrome and it turns
| |
| 98 // dependencies. | 98 // dependencies. |
| 99 // | 99 // |
| 100 // In rare cases, some UI components can be independent of this state | 100 // In rare cases, some UI components can be independent of this state |
| 101 // machine. For example, animation and auto-save loops. | 101 // machine. For example, animation and auto-save loops. |
| 102 | 102 |
| 103 // Implementation note: The state machine is actually implemented by | 103 // Implementation note: The state machine is actually implemented by |
| 104 // [InteractionContext], this class represents public event handlers. | 104 // [InteractionContext], this class represents public event handlers. |
| 105 | 105 |
| 106 factory InteractionManager() => new InteractionContext(); | 106 factory InteractionManager() => new InteractionContext(); |
| 107 | 107 |
| (...skipping 374 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 482 } | 482 } |
| 483 } | 483 } |
| 484 | 484 |
| 485 void onHeartbeat(Timer timer) { | 485 void onHeartbeat(Timer timer) { |
| 486 if (context.unitsToSave.isEmpty && | 486 if (context.unitsToSave.isEmpty && |
| 487 context.saveTimer.elapsed > SAVE_INTERVAL) { | 487 context.saveTimer.elapsed > SAVE_INTERVAL) { |
| 488 context.saveTimer | 488 context.saveTimer |
| 489 ..stop() | 489 ..stop() |
| 490 ..reset(); | 490 ..reset(); |
| 491 context.unitsToSave.addAll(context.modifiedUnits); | 491 context.unitsToSave.addAll(context.modifiedUnits); |
| 492 context.modifiedUnits.clear(); | |
| 492 saveUnits(); | 493 saveUnits(); |
| 493 } | 494 } |
| 494 if (!settings.compilationPaused && | 495 if (!settings.compilationPaused && |
| 495 context.compileTimer.elapsed > COMPILE_INTERVAL) { | 496 context.compileTimer.elapsed > COMPILE_INTERVAL) { |
| 496 if (startCompilation()) { | 497 if (startCompilation()) { |
| 497 context.compileTimer | 498 context.compileTimer |
| 498 ..stop() | 499 ..stop() |
| 499 ..reset(); | 500 ..reset(); |
| 500 } | 501 } |
| 501 } | 502 } |
| (...skipping 462 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 964 return text.split(new RegExp('^', multiLine: true)); | 965 return text.split(new RegExp('^', multiLine: true)); |
| 965 } | 966 } |
| 966 | 967 |
| 967 void removeCodeCompletion() { | 968 void removeCodeCompletion() { |
| 968 List<Node> highlighting = | 969 List<Node> highlighting = |
| 969 mainEditorPane.querySelectorAll('.dart-code-completion'); | 970 mainEditorPane.querySelectorAll('.dart-code-completion'); |
| 970 for (Element element in highlighting) { | 971 for (Element element in highlighting) { |
| 971 element.remove(); | 972 element.remove(); |
| 972 } | 973 } |
| 973 } | 974 } |
| OLD | NEW |