Changeset 51420 in webkit


Ignore:
Timestamp:
Nov 26, 2009 12:27:53 PM (14 years ago)
Author:
eric@webkit.org
Message:

2009-11-26 Daniel Bates <dbates@webkit.org>

Reviewed by Pavel Feldman.

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

Tests that the tooltip text for an image is its dimensions.

  • inspector/elements-img-tooltip-expected.txt: Added.
  • inspector/elements-img-tooltip.html: Added.

2009-11-26 Daniel Bates <dbates@webkit.org>

Reviewed by Pavel Feldman.

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

Implements support for hovering over <img> src to display the height and width of that image
in a tooltip. Displays both the displayable and natural dimensions of the image.

Test: inspector/elements-img-tooltip.html

  • inspector/front-end/ElementsTreeOutline.js: (WebInspector.ElementsTreeElement.prototype.createTooltipForImageNode): Added. (WebInspector.ElementsTreeElement.prototype._updateTitle.callback): (WebInspector.ElementsTreeElement.prototype._updateTitle): (WebInspector.ElementsTreeElement.prototype._nodeTitleInfo):
  • inspector/front-end/ObjectProxy.js: (WebInspector.ObjectProxy.getPropertiesAsync): Added.
  • inspector/front-end/inspector.js: (WebInspector.linkifyURLAsNode): Added tooltipText argument. (WebInspector.linkifyURL): Ditto.
Location:
trunk
Files:
2 added
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r51410 r51420  
     12009-11-26  Daniel Bates  <dbates@webkit.org>
     2
     3        Reviewed by Pavel Feldman.
     4
     5        https://bugs.webkit.org/show_bug.cgi?id=21554
     6
     7        Tests that the tooltip text for an image is its dimensions.
     8
     9        * inspector/elements-img-tooltip-expected.txt: Added.
     10        * inspector/elements-img-tooltip.html: Added.
     11
    1122009-11-21  Holger Hans Peter Freyther  <zecke@selfish.org>
    213
  • trunk/WebCore/ChangeLog

    r51419 r51420  
     12009-11-26  Daniel Bates  <dbates@webkit.org>
     2
     3        Reviewed by Pavel Feldman.
     4
     5        https://bugs.webkit.org/show_bug.cgi?id=21554
     6
     7        Implements support for hovering over <img> src to display the height and width of that image
     8        in a tooltip. Displays both the displayable and natural dimensions of the image.
     9
     10        Test: inspector/elements-img-tooltip.html
     11
     12        * inspector/front-end/ElementsTreeOutline.js:
     13        (WebInspector.ElementsTreeElement.prototype.createTooltipForImageNode): Added.
     14        (WebInspector.ElementsTreeElement.prototype._updateTitle.callback):
     15        (WebInspector.ElementsTreeElement.prototype._updateTitle):
     16        (WebInspector.ElementsTreeElement.prototype._nodeTitleInfo):
     17        * inspector/front-end/ObjectProxy.js:
     18        (WebInspector.ObjectProxy.getPropertiesAsync): Added.
     19        * inspector/front-end/inspector.js:
     20        (WebInspector.linkifyURLAsNode): Added tooltipText argument.
     21        (WebInspector.linkifyURL): Ditto.
     22
    1232009-11-26  Kevin Ollivier  <kevino@theolliviers.com>
    224
  • trunk/WebCore/inspector/front-end/ElementsTreeOutline.js

    r50627 r51420  
    326326    },
    327327
     328    createTooltipForImageNode: function(node, callback)
     329    {
     330        function createTooltipThenCallback(properties)
     331        {
     332            if (!properties) {
     333                callback();
     334                return;
     335            }
     336
     337            var tooltipText = null;
     338            if (properties.offsetHeight === properties.naturalHeight && properties.offsetWidth === properties.naturalWidth)
     339                tooltipText = WebInspector.UIString("%d\u00d7%d pixels", properties.offsetWidth, properties.offsetHeight);
     340            else
     341                tooltipText = WebInspector.UIString("%d\u00d7%d pixels (Natural: %d\u00d7%d pixels)", properties.offsetWidth, properties.offsetHeight, properties.naturalWidth, properties.naturalHeight);
     342            callback(tooltipText);
     343        }
     344        var objectProxy = new WebInspector.ObjectProxy(node.id);
     345        WebInspector.ObjectProxy.getPropertiesAsync(objectProxy, ["naturalHeight", "naturalWidth", "offsetHeight", "offsetWidth"], createTooltipThenCallback);
     346    },
     347
    328348    toggleNewAttributeButton: function(visible)
    329349    {
     
    788808            return;
    789809
    790         var title = this._nodeTitleInfo(this.representedObject, this.hasChildren, WebInspector.linkifyURL).title;
    791         this.title = "<span class=\"highlight\">" + title + "</span>";
    792         delete this.selectionElement;
    793         this.updateSelection();
    794         this._preventFollowingLinksOnDoubleClick();
    795     },
    796 
    797     _nodeTitleInfo: function(node, hasChildren, linkify)
     810        var self = this;
     811        function callback(tooltipText)
     812        {
     813            var title = self._nodeTitleInfo(self.representedObject, self.hasChildren, WebInspector.linkifyURL, tooltipText).title;
     814            self.title = "<span class=\"highlight\">" + title + "</span>";
     815            delete self.selectionElement;
     816            self.updateSelection();
     817            self._preventFollowingLinksOnDoubleClick();
     818        };
     819
     820        // TODO: Replace with InjectedScriptAccess.getBasicProperties(obj, [names]).
     821        if (this.representedObject.nodeName.toLowerCase() !== "img")
     822            callback();
     823        else
     824            this.createTooltipForImageNode(this.representedObject, callback);
     825    },
     826
     827    _nodeTitleInfo: function(node, hasChildren, linkify, tooltipText)
    798828    {
    799829        var info = {title: "", hasChildren: hasChildren};
     
    815845                        if (linkify && (attr.name === "src" || attr.name === "href")) {
    816846                            var value = value.replace(/([\/;:\)\]\}])/g, "$1\u200B");
    817                             info.title += linkify(attr.value, value, "webkit-html-attribute-value", node.nodeName.toLowerCase() == "a");
     847                            info.title += linkify(attr.value, value, "webkit-html-attribute-value", node.nodeName.toLowerCase() == "a", tooltipText);
    818848                        } else {
    819849                            var value = value.escapeHTML();
  • trunk/WebCore/inspector/front-end/ObjectProxy.js

    r48601 r51420  
    4646}
    4747
     48WebInspector.ObjectProxy.getPropertiesAsync = function(objectProxy, propertiesToQueryFor, callback)
     49{
     50    function createPropertiesMapThenCallback(propertiesPayload)
     51    {
     52        if (!propertiesPayload) {
     53            callback();
     54            return;
     55        }
     56
     57        var result = [];
     58        for (var i = 0; i < propertiesPayload.length; ++i)
     59            if (propertiesToQueryFor.indexOf(propertiesPayload[i].name) !== -1)
     60                result[propertiesPayload[i].name] = propertiesPayload[i].value.description;
     61        callback(result);
     62    };
     63    InjectedScriptAccess.getProperties(objectProxy, true, createPropertiesMapThenCallback);
     64}
     65
    4866WebInspector.ObjectPropertyProxy = function(name, value)
    4967{
  • trunk/WebCore/inspector/front-end/inspector.js

    r51250 r51420  
    14991499}
    15001500
    1501 WebInspector.linkifyURLAsNode = function(url, linkText, classes, isExternal)
     1501WebInspector.linkifyURLAsNode = function(url, linkText, classes, isExternal, tooltipText)
    15021502{
    15031503    if (!linkText)
     
    15091509    a.href = url;
    15101510    a.className = classes;
    1511     a.title = url;
     1511    a.title = tooltipText || url;
    15121512    a.target = "_blank";
    15131513    a.textContent = linkText;
     
    15161516}
    15171517
    1518 WebInspector.linkifyURL = function(url, linkText, classes, isExternal)
     1518WebInspector.linkifyURL = function(url, linkText, classes, isExternal, tooltipText)
    15191519{
    15201520    // Use the DOM version of this function so as to avoid needing to escape attributes.
    15211521    // FIXME:  Get rid of linkifyURL entirely.
    1522     return WebInspector.linkifyURLAsNode(url, linkText, classes, isExternal).outerHTML;
     1522    return WebInspector.linkifyURLAsNode(url, linkText, classes, isExternal, tooltipText).outerHTML;
    15231523}
    15241524
Note: See TracChangeset for help on using the changeset viewer.