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

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

Issue 408783002: Enable Try Dart to run on IE11. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 years, 5 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
Index: site/try/src/interaction_manager.dart
===================================================================
--- site/try/src/interaction_manager.dart (revision 38416)
+++ site/try/src/interaction_manager.dart (working copy)
@@ -82,7 +82,8 @@
import 'shadow_root.dart' show
getShadowRoot,
getText,
- setShadowRoot;
+ setShadowRoot,
+ containsNode;
import 'iframe_error_handler.dart' show
ErrorMessage;
@@ -459,7 +460,7 @@
state = previousLine.getAttribute('dart-state');
}
- node.parent.insertAllBefore(
+ node.parentNode.insertAllBefore(
createHighlightedNodes(trySelection, currentText, state),
node);
node.remove();
@@ -476,7 +477,7 @@
..addAll(nodes);
}
- if (mainEditorPane.contains(trySelection.anchorNode)) {
+ if (containsNode(mainEditorPane, trySelection.anchorNode)) {
ahe 2014/07/21 08:16:00 Indentation.
aam-me 2014/07/21 12:20:38 Done.
// Sometimes the anchor node is removed by the above call. This has
// only been observed in Firefox, and is hard to reproduce.
trySelection.adjust(selection);
@@ -1217,7 +1218,7 @@
TrySelection selection,
Set<Node> normalizedNodes) {
for (Node node in record.addedNodes) {
- if (node.parent == null) continue;
+ if (node.parentNode == null) continue;
normalizedNodes.add(findLine(node));
if (node is Text) continue;
StringBuffer buffer = new StringBuffer();
@@ -1237,8 +1238,9 @@
normalizedNodes.add(line.nextNode);
}
normalizedNodes.add(line);
+
ahe 2014/07/21 08:16:00 Remove line.
aam-me 2014/07/21 12:20:38 Done.
}
- if (record.type == "characterData" && record.target.parent != null) {
+ if (record.type == "characterData" && record.target.parentNode != null) {
// At least Firefox sends a "characterData" record whose target is the
// deleted text node. It also sends a record where "removedNodes" isn't
// empty whose target is the parent (which we are interested in).
@@ -1250,7 +1252,7 @@
// If no such parent exists, return mainEditorPane if it is a parent.
// Otherwise return [node].
Node findLine(Node node) {
- for (Node n = node; n != null; n = n.parent) {
+ for (Node n = node; n != null; n = n.parentNode) {
if (n is Element && n.classes.contains('lineNumber')) return n;
if (n == mainEditorPane) return n;
}
@@ -1268,7 +1270,7 @@
Node line = findLine(text);
return
line.nextNode == null &&
- text.parent.nextNode == null &&
+ text.parentNode.nextNode == null &&
offset == text.length;
}
@@ -1307,11 +1309,16 @@
// Safari can also reach this code, but the offset isn't wrong, just
// inconsistent. After moving the cursor back and forth, Safari will make
// the offset relative to a text node.
- selection
- ..modify('move', 'backward', 'character')
- ..modify('move', 'forward', 'character');
- print('Selection adjusted $node@$offset -> '
- '${selection.anchorNode}@${selection.anchorOffset}.');
+ try {
+ selection
+ ..modify('move', 'backward', 'character')
+ ..modify('move', 'forward', 'character');
+ print('Selection adjusted $node@$offset -> '
+ '${selection.anchorNode}@${selection.anchorOffset}.');
+ } catch(e) {
+ // IE doesn't support selection.modify, but it's okay since the code
+ // above is for Firefox, IE doesn't have problems with anchorOffset.
ahe 2014/07/21 08:16:00 Can we detect that selection.modify doesn't work a
aam-me 2014/07/21 12:20:38 Acknowledged.
+ }
}
}

Powered by Google App Engine
This is Rietveld 408576698