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 import 'dart:html' show | 5 import 'dart:html' show |
6 DivElement, | 6 DivElement, |
7 MutationObserver, | 7 MutationObserver, |
8 document; | 8 document; |
9 | 9 |
10 import '../../site/try/src/interaction_manager.dart' show | 10 import 'package:try/src/interaction_manager.dart' show |
11 InteractionManager; | 11 InteractionManager; |
12 | 12 |
13 import '../../site/try/src/ui.dart' show | 13 import 'package:try/src/ui.dart' show |
14 hackDiv, | 14 hackDiv, |
15 mainEditorPane, | 15 mainEditorPane, |
16 observer; | 16 observer; |
17 | 17 |
18 import '../../site/try/src/user_option.dart' show | 18 import 'package:try/src/user_option.dart' show |
19 UserOption; | 19 UserOption; |
20 | 20 |
21 InteractionManager mockTryDartInteraction() { | 21 InteractionManager mockTryDartInteraction() { |
22 UserOption.storage = {}; | 22 UserOption.storage = {}; |
23 | 23 |
24 InteractionManager interaction = new InteractionManager(); | 24 InteractionManager interaction = new InteractionManager(); |
25 | 25 |
26 hackDiv = new DivElement(); | 26 hackDiv = new DivElement(); |
27 mainEditorPane = new DivElement() | 27 mainEditorPane = new DivElement() |
28 ..style.whiteSpace = 'pre' | 28 ..style.whiteSpace = 'pre' |
29 ..contentEditable = 'true'; | 29 ..contentEditable = 'true'; |
30 | 30 |
31 observer = new MutationObserver(interaction.onMutation); | 31 observer = new MutationObserver(interaction.onMutation); |
32 observer.observe( | 32 observer.observe( |
33 mainEditorPane, childList: true, characterData: true, subtree: true); | 33 mainEditorPane, childList: true, characterData: true, subtree: true); |
34 | 34 |
35 document.body.nodes.addAll([mainEditorPane, hackDiv]); | 35 document.body.nodes.addAll([mainEditorPane, hackDiv]); |
36 | 36 |
37 return interaction; | 37 return interaction; |
38 } | 38 } |
39 | 39 |
40 void clearEditorPaneWithoutNotifications() { | 40 void clearEditorPaneWithoutNotifications() { |
41 mainEditorPane.nodes.clear(); | 41 mainEditorPane.nodes.clear(); |
42 observer.takeRecords(); | 42 observer.takeRecords(); |
43 } | 43 } |
OLD | NEW |