Title: [243826] trunk/Source/WebInspectorUI
Revision
243826
Author
[email protected]
Date
2019-04-03 14:03:58 -0700 (Wed, 03 Apr 2019)

Log Message

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):

Modified Paths

Diff

Modified: trunk/Source/WebInspectorUI/ChangeLog (243825 => 243826)


--- trunk/Source/WebInspectorUI/ChangeLog	2019-04-03 20:49:17 UTC (rev 243825)
+++ trunk/Source/WebInspectorUI/ChangeLog	2019-04-03 21:03:58 UTC (rev 243826)
@@ -1,3 +1,28 @@
+2019-04-03  Devin Rousso  <[email protected]>
+
+        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  <[email protected]>
 
         Remove support for -apple-trailing-word

Modified: trunk/Source/WebInspectorUI/UserInterface/Base/Main.js (243825 => 243826)


--- trunk/Source/WebInspectorUI/UserInterface/Base/Main.js	2019-04-03 20:49:17 UTC (rev 243825)
+++ trunk/Source/WebInspectorUI/UserInterface/Base/Main.js	2019-04-03 21:03:58 UTC (rev 243826)
@@ -1651,15 +1651,23 @@
 
 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,
+    };
 
-    this.modifierKeys = {altKey: event.altKey, metaKey: event.metaKey, shiftKey: event.shiftKey};
+    let changed = !Object.shallowEqual(this.modifierKeys, keys);
 
-    if (metaKeyDidChange)
-        document.body.classList.toggle("meta-key-pressed", this.modifierKeys.metaKey);
+    this.modifierKeys = keys;
 
-    if (didChange)
+    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 (changed)
         this.notifications.dispatchEventToListeners(WI.Notification.GlobalModifierKeysDidChange, event);
 };
 

Modified: trunk/Source/WebInspectorUI/UserInterface/Views/CodeMirrorEditor.js (243825 => 243826)


--- trunk/Source/WebInspectorUI/UserInterface/Views/CodeMirrorEditor.js	2019-04-03 20:49:17 UTC (rev 243825)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/CodeMirrorEditor.js	2019-04-03 21:03:58 UTC (rev 243826)
@@ -31,6 +31,7 @@
         // 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);
 

Modified: trunk/Source/WebInspectorUI/UserInterface/Views/SyntaxHighlightingDefaultTheme.css (243825 => 243826)


--- trunk/Source/WebInspectorUI/UserInterface/Views/SyntaxHighlightingDefaultTheme.css	2019-04-03 20:49:17 UTC (rev 243825)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/SyntaxHighlightingDefaultTheme.css	2019-04-03 21:03:58 UTC (rev 243826)
@@ -82,12 +82,14 @@
 .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,

Modified: trunk/Source/WebInspectorUI/UserInterface/Views/TextEditor.js (243825 => 243826)


--- trunk/Source/WebInspectorUI/UserInterface/Views/TextEditor.js	2019-04-03 20:49:17 UTC (rev 243825)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/TextEditor.js	2019-04-03 21:03:58 UTC (rev 243826)
@@ -180,6 +180,7 @@
     set readOnly(readOnly)
     {
         this._codeMirror.setOption("readOnly", readOnly);
+        this._codeMirror.getWrapperElement().classList.toggle("read-only", !!readOnly);
     }
 
     get formatted()
@@ -1687,6 +1688,9 @@
 
     _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);
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to