Index: runtime/observatory/lib/src/elements/observatory_element.dart |
diff --git a/runtime/observatory/lib/src/elements/observatory_element.dart b/runtime/observatory/lib/src/elements/observatory_element.dart |
index f516bacbe6a214fd87b5d7c2a34f919e2b100636..8efc7b541936eefc5c2792bb339e30deade889f3 100644 |
--- a/runtime/observatory/lib/src/elements/observatory_element.dart |
+++ b/runtime/observatory/lib/src/elements/observatory_element.dart |
@@ -196,4 +196,35 @@ class ObservatoryElement extends PolymerElement { |
anchorElement.onClick.listen(onClickGoto); |
shadowRoot.children.add(anchorElement); |
} |
+ |
+ |
+ var _onCopySubscription; |
+ /// Exclude nodes from being copied, for example the line numbers and |
+ /// breakpoint toggles in script insets. Must be called after [root]'s |
+ /// children have been added, and only supports one node at a time. |
+ void makeCssClassUncopyable(Element root, String className) { |
+ var noCopyNodes = root.getElementsByClassName(className); |
+ for (var node in noCopyNodes) { |
+ node.style.setProperty('-moz-user-select', 'none'); |
+ node.style.setProperty('-khtml-user-select', 'none'); |
+ node.style.setProperty('-webkit-user-select', 'none'); |
+ node.style.setProperty('-ms-user-select', 'none'); |
+ node.style.setProperty('user-select', 'none'); |
+ } |
+ if (_onCopySubscription != null) { |
+ _onCopySubscription.cancel(); |
+ } |
+ _onCopySubscription = root.onCopy.listen((event) { |
+ // Mark the nodes as hidden before the copy happens, then mark them as |
+ // visible on the next event loop turn. |
+ for (var node in noCopyNodes) { |
+ node.style.visibility = 'hidden'; |
+ } |
+ Timer.run(() { |
+ for (var node in noCopyNodes) { |
+ node.style.visibility = 'visible'; |
+ } |
+ }); |
+ }); |
+ } |
} |