| Index: dart/site/try/src/editor.dart
|
| diff --git a/dart/site/try/src/editor.dart b/dart/site/try/src/editor.dart
|
| index 880ff3c4202e66ad267793a1784e58cadfa9ac85..615a8539aec63a83cf4fbb88e6228b433286dce3 100644
|
| --- a/dart/site/try/src/editor.dart
|
| +++ b/dart/site/try/src/editor.dart
|
| @@ -15,6 +15,7 @@ import 'package:compiler/implementation/scanner/scannerlib.dart' show
|
| import 'ui.dart' show
|
| currentTheme,
|
| hackDiv,
|
| + interaction,
|
| mainEditorPane,
|
| observer,
|
| outputDiv;
|
| @@ -152,20 +153,54 @@ addDiagnostic(String kind, String message, int begin, int end) {
|
| if (offset <= begin && begin < newOffset) {
|
| hasSelection = node == anchorNode;
|
| anchorOffset = selection.anchorOffset;
|
| - Node marker = new Text("");
|
| - node.replaceWith(marker);
|
| - // TODO(ahe): Don't highlight everything in the node. Find the
|
| - // relevant token (works for now as we create a node for each token,
|
| - // which is probably not great for performance).
|
| + var alert;
|
| if (kind == 'error') {
|
| - marker.replaceWith(diagnostic(node, error(message)));
|
| + alert = error(message);
|
| } else if (kind == 'warning') {
|
| - marker.replaceWith(diagnostic(node, warning(message)));
|
| + alert = warning(message);
|
| } else {
|
| - marker.replaceWith(diagnostic(node, info(message)));
|
| + alert = info(message);
|
| }
|
| - if (hasSelection) {
|
| - selection.collapse(node, anchorOffset);
|
| + Element parent = node.parent;
|
| + if (parent.classes.contains("diagnostic") &&
|
| + !interaction.oldDiagnostics.contains(parent)) {
|
| + Element other = parent.lastChild;
|
| + other.remove();
|
| + SpanElement wrapper = new SpanElement();
|
| + wrapper.style
|
| + ..fontWeight = 'normal';
|
| + var root = getShadowRoot(wrapper);
|
| + if (root is ShadowRoot) {
|
| + // When https://code.google.com/p/chromium/issues/detail?id=313458
|
| + // is fixed:
|
| + // var link = new LinkElement()
|
| + // ..rel = "stylesheet"
|
| + // ..type = "text/css"
|
| + // ..href = "dartlang-style.css";
|
| + // root.append(link);
|
| + root.append(
|
| + new StyleElement()..text = '@import url(dartlang-style.css)');
|
| + }
|
| + root
|
| + ..append(other)
|
| + ..append(alert);
|
| + other.style.display = 'block';
|
| + alert.style.display = 'block';
|
| + parent.append(wrapper);
|
| + } else {
|
| + if (interaction.oldDiagnostics.contains(parent)) {
|
| + node.remove();
|
| + parent.replaceWith(node);
|
| + }
|
| + Node marker = new Text("");
|
| + node.replaceWith(marker);
|
| + // TODO(ahe): Don't highlight everything in the node. Find the
|
| + // relevant token (works for now as we create a node for each token,
|
| + // which is probably not great for performance).
|
| + marker.replaceWith(diagnostic(node, alert));
|
| + if (hasSelection) {
|
| + selection.collapse(node, anchorOffset);
|
| + }
|
| }
|
| foundNode = true;
|
| return;
|
|
|