Makes DOM attribute editing start on double-click to match the styles
authortimothy@apple.com <timothy@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 5 Aug 2008 22:34:09 +0000 (22:34 +0000)
committertimothy@apple.com <timothy@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 5 Aug 2008 22:34:09 +0000 (22:34 +0000)
        pane. Links in attributes are now triggered with a single click again.

        https://bugs.webkit.org/show_bug.cgi?id=20281

        Reviewed by Adam Roben.

        * English.lproj/localizedStrings.js: Removed some strings.
        * page/inspector/ElementsPanel.js:
        (WebInspector.DOMNodeTreeElement.prototype.onattach): Call
        _preventFollowingLinksOnDoubleClick.
        (WebInspector.DOMNodeTreeElement.prototype._preventFollowingLinksOnDoubleClick):
        Renamed from _makeURLsActivateOnModifiedClick. Simply sets the
        preventFollowOnDoubleClick property on all links.
        (WebInspector.DOMNodeTreeElement.prototype.onselect): Removed
        _selectedByCurrentMouseDown.
        (WebInspector.DOMNodeTreeElement.prototype.onmousedown): Moved
        editing code to ondblclick.
        (WebInspector.DOMNodeTreeElement.prototype.ondblclick): Calls
        _startEditing. Removed URL check.
        (WebInspector.DOMNodeTreeElement.prototype._updateTitle): Calls
        _preventFollowingLinksOnDoubleClick.
        * page/inspector/inspector.css:
        (.editing): Removed the text-decoration property.
        (.editing, .editing *): Added the text-decoration property here
        so it removes underlines on child elements.
        * page/inspector/inspector.js:
        (WebInspector.documentClick): Removed the followOnAltClick code.
        Added support for preventFollowOnDoubleClick, which sets a timeout
        on the first click where future clicks will cancel it (double click).
        If the timeout isn't canceled, the link is followed.

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

WebCore/ChangeLog
WebCore/English.lproj/localizedStrings.js
WebCore/page/inspector/ElementsPanel.js
WebCore/page/inspector/inspector.css
WebCore/page/inspector/inspector.js

index 9ef8c7f..87215fd 100644 (file)
@@ -1,3 +1,37 @@
+2008-08-05  Timothy Hatcher  <timothy@apple.com>
+
+        Makes DOM attribute editing start on double-click to match the styles
+        pane. Links in attributes are now triggered with a single click again.
+
+        https://bugs.webkit.org/show_bug.cgi?id=20281
+
+        Reviewed by Adam Roben.
+
+        * English.lproj/localizedStrings.js: Removed some strings.
+        * page/inspector/ElementsPanel.js:
+        (WebInspector.DOMNodeTreeElement.prototype.onattach): Call
+        _preventFollowingLinksOnDoubleClick.
+        (WebInspector.DOMNodeTreeElement.prototype._preventFollowingLinksOnDoubleClick):
+        Renamed from _makeURLsActivateOnModifiedClick. Simply sets the
+        preventFollowOnDoubleClick property on all links.
+        (WebInspector.DOMNodeTreeElement.prototype.onselect): Removed
+        _selectedByCurrentMouseDown.
+        (WebInspector.DOMNodeTreeElement.prototype.onmousedown): Moved
+        editing code to ondblclick.
+        (WebInspector.DOMNodeTreeElement.prototype.ondblclick): Calls
+        _startEditing. Removed URL check.
+        (WebInspector.DOMNodeTreeElement.prototype._updateTitle): Calls
+        _preventFollowingLinksOnDoubleClick.
+        * page/inspector/inspector.css:
+        (.editing): Removed the text-decoration property.
+        (.editing, .editing *): Added the text-decoration property here
+        so it removes underlines on child elements.
+        * page/inspector/inspector.js:
+        (WebInspector.documentClick): Removed the followOnAltClick code.
+        Added support for preventFollowOnDoubleClick, which sets a timeout
+        on the first click where future clicks will cancel it (double click).
+        If the timeout isn't canceled, the link is followed.
+
 2008-08-05  Antti Koivisto  <antti@apple.com>
 
         Reviewed by Sam Weinig.
index 5bca3da..f595e3b 100644 (file)
Binary files a/WebCore/English.lproj/localizedStrings.js and b/WebCore/English.lproj/localizedStrings.js differ
index afce0ee..bfa6f10 100644 (file)
@@ -1135,36 +1135,17 @@ WebInspector.DOMNodeTreeElement.prototype = {
     {
         this.listItemElement.addEventListener("mousedown", this.onmousedown.bind(this), false);
 
-        this._makeURLsActivateOnModifiedClick();
+        this._preventFollowingLinksOnDoubleClick();
     },
 
-    _makeURLsActivateOnModifiedClick: function()
+    _preventFollowingLinksOnDoubleClick: function()
     {
         var links = this.listItemElement.querySelectorAll("li > .webkit-html-tag > .webkit-html-attribute > .webkit-html-external-link, li > .webkit-html-tag > .webkit-html-attribute > .webkit-html-resource-link");
         if (!links)
             return;
 
-        var isMac = InspectorController.platform().indexOf("mac") == 0;
-
-        for (var i = 0; i < links.length; ++i) {
-            var link = links[i];
-            var isExternal = link.hasStyleClass("webkit-html-external-link");
-            var href = link.getAttribute("href");
-            var title;
-            if (isMac) {
-                if (isExternal)
-                    title = WebInspector.UIString("Option-click to visit %s.", href);
-                else
-                    title = WebInspector.UIString("Option-click to show %s.", href);
-            } else {
-                if (isExternal)
-                    title = WebInspector.UIString("Alt-click to visit %s.", href);
-                else
-                    title = WebInspector.UIString("Alt-click to show %s.", href);
-            }
-            link.setAttribute("title", title);
-            link.followOnAltClick = true;
-        }
+        for (var i = 0; i < links.length; ++i)
+            links[i].preventFollowOnDoubleClick = true;
     },
 
     onpopulate: function()
@@ -1282,7 +1263,6 @@ WebInspector.DOMNodeTreeElement.prototype = {
 
     onselect: function()
     {
-        this._selectedByCurrentMouseDown = true;
         this.treeOutline.panel.focusedDOMNode = this.representedObject;
         this.updateSelection();
     },
@@ -1292,13 +1272,6 @@ WebInspector.DOMNodeTreeElement.prototype = {
         if (this._editing)
             return;
 
-        if (this._selectedByCurrentMouseDown)
-            delete this._selectedByCurrentMouseDown;
-        else if (this._startEditing(event)) {
-            event.preventDefault();
-            return;
-        }
-
         // Prevent selecting the nearest word on double click.
         if (event.detail >= 2)
             event.preventDefault();
@@ -1309,6 +1282,9 @@ WebInspector.DOMNodeTreeElement.prototype = {
         if (this._editing)
             return;
 
+        if (this._startEditing(event))
+            return;
+
         var panel = this.treeOutline.panel;
         panel.rootDOMNode = this.parent.representedObject;
         panel.focusedDOMNode = this.representedObject;
@@ -1345,10 +1321,6 @@ WebInspector.DOMNodeTreeElement.prototype = {
         if (!attributeNameElement)
             return false;
 
-        var isURL = event.target.enclosingNodeOrSelfWithClass("webkit-html-external-link") || event.target.enclosingNodeOrSelfWithClass("webkit-html-resource-link");
-        if (isURL && event.altKey)
-            return false;
-
         var attributeName = attributeNameElement.innerText;
 
         function removeZeroWidthSpaceRecursive(node)
@@ -1431,7 +1403,6 @@ WebInspector.DOMNodeTreeElement.prototype = {
         this._updateTitle();
     },
 
-
     _editingCancelled: function(element, context)
     {
         delete this._editing;
@@ -1444,7 +1415,7 @@ WebInspector.DOMNodeTreeElement.prototype = {
         this.title = nodeTitleInfo.call(this.representedObject, this.hasChildren, WebInspector.linkifyURL).title;
         delete this.selectionElement;
         this.updateSelection();
-        this._makeURLsActivateOnModifiedClick();
+        this._preventFollowingLinksOnDoubleClick();
     },
 }
 
index 9fabb89..24fc0db 100644 (file)
@@ -1158,12 +1158,12 @@ body.inactive .placard.selected {
     padding-left: 2px;
     margin-bottom: -1px;
     padding-bottom: 1px;
-    text-decoration: none !important;
     opacity: 1.0 !important;
 }
 
 .editing, .editing * {
     color: black !important;
+    text-decoration: none !important;
 }
 
 .section .properties li.editing {
index 6534b02..7a8d410 100644 (file)
@@ -399,18 +399,28 @@ WebInspector.documentClick = function(event)
     if (!anchor)
         return;
 
-    if (anchor.followOnAltClick && !event.altKey) {
-        event.preventDefault();
-        return;
+    // Prevent the link from navigating, since we don't do any navigation by following links normally.
+    event.preventDefault();
+
+    function followLink()
+    {
+        // FIXME: support webkit-html-external-link links here.
+        if (anchor.hasStyleClass("webkit-html-resource-link"))
+            WebInspector.showResourceForURL(anchor.href, anchor.lineNumber, anchor.preferredPanel);
     }
 
-    if (!anchor.hasStyleClass("webkit-html-resource-link"))
-        return;
+    if (WebInspector.followLinkTimeout)
+        clearTimeout(WebInspector.followLinkTimeout);
 
-    if (WebInspector.showResourceForURL(anchor.href, anchor.lineNumber, anchor.preferredPanel)) {
-        event.preventDefault();
-        event.stopPropagation();
+    if (anchor.preventFollowOnDoubleClick) {
+        // Start a timeout if this is the first click, if the timeout is canceled
+        // before it fires, then a double clicked happened or another link was clicked.
+        if (event.detail === 1)
+            WebInspector.followLinkTimeout = setTimeout(followLink, 333);
+        return;
     }
+
+    followLink();
 }
 
 WebInspector.documentKeyDown = function(event)