Web Inspector: Single click on links in non-read-only TextEditors should not follow...
authordrousso@apple.com <drousso@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 3 Apr 2019 21:03:58 +0000 (21:03 +0000)
committerdrousso@apple.com <drousso@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 3 Apr 2019 21:03:58 +0000 (21:03 +0000)
https://bugs.webkit.org/show_bug.cgi?id=123364
<rdar://problem/15323913>

Reviewed by Timothy Hatcher.

* UserInterface/Base/Main.js:
(WI._updateModifierKeys):
Add classes to the body whenever alt, shift, or ctrl are pressed.

* UserInterface/Views/CodeMirrorEditor.js:
(WI.CodeMirrorEditor.create):
Add a `read-only` class if the `CodeMirror` is readonly.

* UserInterface/Views/SyntaxHighlightingDefaultTheme.css:
(.cm-s-default .cm-link,):
(.read-only.cm-s-default .cm-link:hover,):
(.cm-s-default .cm-link:hover,): Deleted.

* UserInterface/Views/TextEditor.js:
(WI.TextEditor.prototype.set readOnly):
(WI.TextEditor.prototype._openClickedLinks):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@243826 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebInspectorUI/ChangeLog
Source/WebInspectorUI/UserInterface/Base/Main.js
Source/WebInspectorUI/UserInterface/Views/CodeMirrorEditor.js
Source/WebInspectorUI/UserInterface/Views/SyntaxHighlightingDefaultTheme.css
Source/WebInspectorUI/UserInterface/Views/TextEditor.js

index c7b8aa9..6809f8d 100644 (file)
@@ -1,3 +1,28 @@
+2019-04-03  Devin Rousso  <drousso@apple.com>
+
+        Web Inspector: Single click on links in non-read-only TextEditors should not follow links
+        https://bugs.webkit.org/show_bug.cgi?id=123364
+        <rdar://problem/15323913>
+
+        Reviewed by Timothy Hatcher.
+
+        * UserInterface/Base/Main.js:
+        (WI._updateModifierKeys):
+        Add classes to the body whenever alt, shift, or ctrl are pressed.
+
+        * UserInterface/Views/CodeMirrorEditor.js:
+        (WI.CodeMirrorEditor.create):
+        Add a `read-only` class if the `CodeMirror` is readonly.
+
+        * UserInterface/Views/SyntaxHighlightingDefaultTheme.css:
+        (.cm-s-default .cm-link,):
+        (.read-only.cm-s-default .cm-link:hover,):
+        (.cm-s-default .cm-link:hover,): Deleted.
+
+        * UserInterface/Views/TextEditor.js:
+        (WI.TextEditor.prototype.set readOnly):
+        (WI.TextEditor.prototype._openClickedLinks):
+
 2019-04-03  Myles C. Maxfield  <mmaxfield@apple.com>
 
         Remove support for -apple-trailing-word
index aa67dce..04cf543 100644 (file)
@@ -1651,15 +1651,23 @@ WI._windowResized = function(event)
 
 WI._updateModifierKeys = function(event)
 {
-    let metaKeyDidChange = this.modifierKeys.metaKey !== event.metaKey;
-    let didChange = this.modifierKeys.altKey !== event.altKey || metaKeyDidChange || this.modifierKeys.shiftKey !== event.shiftKey;
+    let keys = {
+        altKey: event.altKey,
+        metaKey: event.metaKey,
+        ctrlKey: event.ctrlKey,
+        shiftKey: event.shiftKey,
+    };
+
+    let changed = !Object.shallowEqual(this.modifierKeys, keys);
 
-    this.modifierKeys = {altKey: event.altKey, metaKey: event.metaKey, shiftKey: event.shiftKey};
+    this.modifierKeys = keys;
 
-    if (metaKeyDidChange)
-        document.body.classList.toggle("meta-key-pressed", this.modifierKeys.metaKey);
+    document.body.classList.toggle("alt-key-pressed", this.modifierKeys.altKey);
+    document.body.classList.toggle("ctrl-key-pressed", this.modifierKeys.ctrlKey);
+    document.body.classList.toggle("meta-key-pressed", this.modifierKeys.metaKey);
+    document.body.classList.toggle("shift-key-pressed", this.modifierKeys.shiftKey);
 
-    if (didChange)
+    if (changed)
         this.notifications.dispatchEventToListeners(WI.Notification.GlobalModifierKeysDidChange, event);
 };
 
index 66e47ee..f453cc7 100644 (file)
@@ -31,6 +31,7 @@ WI.CodeMirrorEditor = class CodeMirrorEditor
         // nor does it handle braces and brackets well, so default to using LTR.
         // Clients can override this if custom layout for RTL is available.
         element.setAttribute("dir", "ltr");
+        element.classList.toggle("read-only", options.readOnly);
 
         let codeMirror = new CodeMirror(element, options);
 
index 3bb4432..f459de1 100644 (file)
 .cm-s-default .cm-link,
 .syntax-highlighted a {
     text-decoration: none;
-    cursor: pointer;
 }
 
-.cm-s-default .cm-link:hover,
+.read-only.cm-s-default .cm-link:hover,
+.mac-platform.meta-key-pressed :not(.read-only).cm-s-default .cm-link:hover,
+:not(.mac-platform).control-key-pressed :not(.read-only).cm-s-default .cm-link:hover,
 .syntax-highlighted a:hover {
     text-decoration: underline;
+    cursor: pointer;
 }
 
 .supports-find-banner.showing-find-banner.syntax-highlighted .search-result,
index 7eac1ef..814f24b 100644 (file)
@@ -180,6 +180,7 @@ WI.TextEditor = class TextEditor extends WI.View
     set readOnly(readOnly)
     {
         this._codeMirror.setOption("readOnly", readOnly);
+        this._codeMirror.getWrapperElement().classList.toggle("read-only", !!readOnly);
     }
 
     get formatted()
@@ -1687,6 +1688,9 @@ WI.TextEditor = class TextEditor extends WI.View
 
     _openClickedLinks(event)
     {
+        if (!this.readOnly && !event.commandOrControlKey)
+            return;
+
         // Get the position in the text and the token at that position.
         var position = this._codeMirror.coordsChar({left: event.pageX, top: event.pageY});
         var tokenInfo = this._codeMirror.getTokenAt(position);