Changeset 31009 in webkit


Ignore:
Timestamp:
Mar 12, 2008 4:00:00 PM (16 years ago)
Author:
Adam Roben
Message:

Part of Bug 17224: DOM nodes/attributes should be editable

<http://bugs.webkit.org/show_bug.cgi?id=17224>
<rdar://problem/5732825>

We now start editing if the user single-clicks on an attribute,
attribute value, or text node while the parent element is selected.
Previously, we started editing on double-click regardless of the
selection state of the element.

URLs in the DOM tree are now followed on Alt/Option-click, rather than
on just click.

Reviewed by Tim.

  • English.lproj/InspectorLocalizedStrings.js: Added four new localized strings.
  • page/inspector/DocumentPanel.js: (WebInspector.DOMNodeTreeElement.onattach): Call new _makeURLSActivateOnModifiedClick. (WebInspector.DOMNodeTreeElement._makeURLsActivateOnModifiedClick): Added. Changes the tooltip of each link in this element to indicate that Alt/Option-click will follow the URL, and sets the followOnAltClick property on each link. (WebInspector.DOMNodeTreeElement.onselect): Mark that we're being selected. (WebInspector.DOMNodeTreeElement.onmousedown): If we're not currently being selected, start editing. (WebInspector.DOMNodeTreeElement.ondblclick): We no longer start editing here. We block re-rooting of the tree if we're currently editing. (WebInspector.DOMNodeTreeElement._startEditing):
    • Don't do anything if we're not focused
    • Pass the event down to _startEditingAttribute.

(WebInspector.DOMNodeTreeElement._startEditingAttribute): Don't do
anything if the event target is a URL and the Alt/Option key is
pressed -- in this case we want to follow the link.
(WebInspector.DOMNodeTreeElement._updateTitle): Call
_makeURLsActivateOnClick again since the anchor elements have all been
recreated.

  • page/inspector/inspector.js: (WebInspector.documentClick): If the anchor as a followOnAltClick property and the Alt/Option key is not pressed, do nothing.
Location:
trunk/WebCore
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/ChangeLog

    r31008 r31009  
     12008-03-12  Adam Roben  <aroben@apple.com>
     2
     3        Part of Bug 17224: DOM nodes/attributes should be editable
     4
     5        <http://bugs.webkit.org/show_bug.cgi?id=17224>
     6        <rdar://problem/5732825>
     7
     8        We now start editing if the user single-clicks on an attribute,
     9        attribute value, or text node while the parent element is selected.
     10        Previously, we started editing on double-click regardless of the
     11        selection state of the element.
     12
     13        URLs in the DOM tree are now followed on Alt/Option-click, rather than
     14        on just click.
     15
     16        Reviewed by Tim.
     17
     18        * English.lproj/InspectorLocalizedStrings.js: Added four new localized
     19        strings.
     20        * page/inspector/DocumentPanel.js:
     21        (WebInspector.DOMNodeTreeElement.onattach): Call new
     22        _makeURLSActivateOnModifiedClick.
     23        (WebInspector.DOMNodeTreeElement._makeURLsActivateOnModifiedClick):
     24        Added. Changes the tooltip of each link in this element to indicate
     25        that Alt/Option-click will follow the URL, and sets the
     26        followOnAltClick property on each link.
     27        (WebInspector.DOMNodeTreeElement.onselect): Mark that we're being
     28        selected.
     29        (WebInspector.DOMNodeTreeElement.onmousedown): If we're not currently
     30        being selected, start editing.
     31        (WebInspector.DOMNodeTreeElement.ondblclick): We no longer start
     32        editing here. We block re-rooting of the tree if we're currently
     33        editing.
     34        (WebInspector.DOMNodeTreeElement._startEditing):
     35          - Don't do anything if we're not focused
     36          - Pass the event down to _startEditingAttribute.
     37        (WebInspector.DOMNodeTreeElement._startEditingAttribute): Don't do
     38        anything if the event target is a URL and the Alt/Option key is
     39        pressed -- in this case we want to follow the link.
     40        (WebInspector.DOMNodeTreeElement._updateTitle): Call
     41        _makeURLsActivateOnClick again since the anchor elements have all been
     42        recreated.
     43        * page/inspector/inspector.js:
     44        (WebInspector.documentClick): If the anchor as a followOnAltClick
     45        property and the Alt/Option key is not pressed, do nothing.
     46
    1472008-03-12  Ada Chan  <adachan@apple.com>
    248
  • trunk/WebCore/English.lproj/InspectorLocalizedStrings.js

    r28918 r31009  
    55    "(text)": "(text)",
    66    "(whitespace)": "(whitespace)",
     7    "Alt-click to visit %s.": "Alt-click to visit %s.",
     8    "Alt-click to show %s.": "Alt-click to show %s.",
    79    "An error occurred trying to\nread the “%s” table.": "An error occurred trying to\nread the “%s” table.",
    810    "An unexpected error %s occured.": "An unexpected error %s occured.",
     
    1921    "Metrics": "Metrics",
    2022    "Network": "Network",
     23    "Option-click to visit %s.": "Option-click to visit %s.",
     24    "Option-click to show %s.": "Option-click to show %s.",
    2125    "Properties": "Properties",
    2226    "Prototype": "Prototype",
  • trunk/WebCore/page/inspector/DocumentPanel.js

    r30966 r31009  
    770770    {
    771771        this.listItemElement.addEventListener("mousedown", this.onmousedown.bind(this), false);
     772
     773        this._makeURLsActivateOnModifiedClick();
     774    },
     775
     776    _makeURLsActivateOnModifiedClick: function()
     777    {
     778        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");
     779        if (!links)
     780            return;
     781
     782        var isMac = InspectorController.platform().indexOf("mac") == 0;
     783
     784        for (var i = 0; i < links.length; ++i) {
     785            var link = links[i];
     786            var isExternal = link.hasStyleClass("webkit-html-external-link");
     787            var href = link.getAttribute("href");
     788            var title;
     789            if (isMac) {
     790                if (isExternal)
     791                    title = WebInspector.UIString("Option-click to visit %s.", href);
     792                else
     793                    title = WebInspector.UIString("Option-click to show %s.", href);
     794            } else {
     795                if (isExternal)
     796                    title = WebInspector.UIString("Alt-click to visit %s.", href);
     797                else
     798                    title = WebInspector.UIString("Alt-click to show %s.", href);
     799            }
     800            link.setAttribute("title", title);
     801            link.followOnAltClick = true;
     802        }
    772803    },
    773804
     
    812843    onselect: function()
    813844    {
     845        this._selectedByCurrentMouseDown = true;
    814846        this.treeOutline.panel.focusedDOMNode = this.representedObject;
    815847        this.updateSelection();
     
    820852        if (this._editing)
    821853            return;
     854
     855        if (this._selectedByCurrentMouseDown)
     856            delete this._selectedByCurrentMouseDown;
     857        else if (this._startEditing(event)) {
     858            event.preventDefault();
     859            return;
     860        }
    822861
    823862        // Prevent selecting the nearest word on double click.
     
    828867    ondblclick: function(treeElement, event)
    829868    {
    830         if (this._startEditing(event))
     869        if (this._editing)
    831870            return;
    832871
     
    841880    _startEditing: function(event)
    842881    {
     882        if (this.treeOutline.panel.focusedDOMNode != this.representedObject)
     883            return;
     884
    843885        if (this.representedObject.nodeType != Node.ELEMENT_NODE && this.representedObject.nodeType != Node.TEXT_NODE)
    844886            return false;
     
    850892        var attribute = event.target.firstParentOrSelfWithClass("webkit-html-attribute");
    851893        if (attribute)
    852             return this._startEditingAttribute(attribute);
     894            return this._startEditingAttribute(attribute, event);
    853895
    854896        return false;
    855897    },
    856898
    857     _startEditingAttribute: function(attribute)
     899    _startEditingAttribute: function(attribute, event)
    858900    {
    859901        if (WebInspector.isBeingEdited(attribute))
     
    862904        var attributeNameElement = attribute.getElementsByClassName("webkit-html-attribute-name")[0];
    863905        if (!attributeNameElement)
     906            return false;
     907
     908        var isURL = event.target.firstParentOrSelfWithClass("webkit-html-external-link") || event.target.firstParentOrSelfWithClass("webkit-html-resource-link");
     909        if (isURL && event.altKey)
    864910            return false;
    865911
     
    9581004        delete this.selectionElement;
    9591005        this.updateSelection();
     1006        this._makeURLsActivateOnModifiedClick();
    9601007    },
    9611008}
  • trunk/WebCore/page/inspector/inspector.js

    r30931 r31009  
    329329{
    330330    var anchor = event.target.firstParentOrSelfWithNodeName("a");
    331     if (!anchor || !anchor.hasStyleClass("webkit-html-resource-link"))
     331    if (!anchor)
     332        return;
     333
     334    if (anchor.followOnAltClick && !event.altKey) {
     335        event.preventDefault();
     336        return;
     337    }
     338
     339    if (!anchor.hasStyleClass("webkit-html-resource-link"))
    332340        return;
    333341
Note: See TracChangeset for help on using the changeset viewer.