[SCM] WebKit Debian packaging branch, debian/experimental, updated. upstream/1.3.3-9427-gc2be6fc

apavlov at chromium.org apavlov at chromium.org
Wed Dec 22 13:17:26 UTC 2010


The following commit has been merged in the debian/experimental branch:
commit 93691630e31c2ceb0595104ed6ae3b3704a1c143
Author: apavlov at chromium.org <apavlov at chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Fri Sep 10 12:08:26 2010 +0000

    2010-09-09  Alexander Pavlov  <apavlov at chromium.org>
    
            Reviewed by Yury Semikhatsky.
    
            Web Inspector: Add navigation items into the Elements panel context menu.
    
            For all anchors that have the class of "webkit-html-resource-link" or "webkit-html-external-link",
            a custom context menu with the items "Open Link in New Window" (invokes InspectorBackend.openInInspectedWindow() with
            the related URL) and "Open Link in Resources Panel" (opens the related resource in the Resources panel) is shown
            (the latter item is displayed only if the corresponding resource is known to the Web Inspector).
            https://bugs.webkit.org/show_bug.cgi?id=34250
    
            * English.lproj/localizedStrings.js:
            * inspector/front-end/ElementsPanel.js:
            (WebInspector.ElementsPanel.prototype.populateHrefContextMenu):
            * inspector/front-end/ElementsTreeOutline.js:
            (WebInspector.ElementsTreeOutline.prototype._contextMenuEventFired):
            (WebInspector.ElementsTreeElement.prototype._attributeHTML):
            * inspector/front-end/StylesSidebarPane.js:
            (WebInspector.StylesSidebarPane.prototype._contextMenuEventFired):
            * inspector/front-end/inspector.js:
            (WebInspector.openResource):
            (WebInspector.resourceURLForRelatedNode):
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@67191 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index 497ba90..a8b53a8 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,27 @@
+2010-09-09  Alexander Pavlov  <apavlov at chromium.org>
+
+        Reviewed by Yury Semikhatsky.
+
+        Web Inspector: Add navigation items into the Elements panel context menu.
+
+        For all anchors that have the class of "webkit-html-resource-link" or "webkit-html-external-link",
+        a custom context menu with the items "Open Link in New Window" (invokes InspectorBackend.openInInspectedWindow() with
+        the related URL) and "Open Link in Resources Panel" (opens the related resource in the Resources panel) is shown
+        (the latter item is displayed only if the corresponding resource is known to the Web Inspector).
+        https://bugs.webkit.org/show_bug.cgi?id=34250
+
+        * English.lproj/localizedStrings.js:
+        * inspector/front-end/ElementsPanel.js:
+        (WebInspector.ElementsPanel.prototype.populateHrefContextMenu):
+        * inspector/front-end/ElementsTreeOutline.js:
+        (WebInspector.ElementsTreeOutline.prototype._contextMenuEventFired):
+        (WebInspector.ElementsTreeElement.prototype._attributeHTML):
+        * inspector/front-end/StylesSidebarPane.js:
+        (WebInspector.StylesSidebarPane.prototype._contextMenuEventFired):
+        * inspector/front-end/inspector.js:
+        (WebInspector.openResource):
+        (WebInspector.resourceURLForRelatedNode):
+
 2010-09-10  Kwang Yul Seo  <skyul at company100.net>
 
         Reviewed by James Robinson.
diff --git a/WebCore/English.lproj/localizedStrings.js b/WebCore/English.lproj/localizedStrings.js
index 28cdf1a..38dba9b 100644
Binary files a/WebCore/English.lproj/localizedStrings.js and b/WebCore/English.lproj/localizedStrings.js differ
diff --git a/WebCore/inspector/front-end/ElementsPanel.js b/WebCore/inspector/front-end/ElementsPanel.js
index c60d4b1..728c48e 100644
--- a/WebCore/inspector/front-end/ElementsPanel.js
+++ b/WebCore/inspector/front-end/ElementsPanel.js
@@ -261,6 +261,23 @@ WebInspector.ElementsPanel.prototype = {
         this._nodeSearchButton.toggled = false;
     },
 
+    populateHrefContextMenu: function(contextMenu, event, anchorElement)
+    {
+        if (!anchorElement.href)
+            return false;
+
+        var resourceURL = WebInspector.resourceURLForRelatedNode(this.focusedDOMNode, anchorElement.href);
+        if (!resourceURL)
+            return false;
+
+        // Add resource-related actions.
+        // Keep these consistent with those added in WebInspector.StylesSidebarPane.prototype._populateHrefContextMenu().
+        contextMenu.appendItem(WebInspector.UIString("Open Link in New Window"), WebInspector.openResource.bind(null, resourceURL, false));
+        if (WebInspector.resourceForURL(resourceURL))
+            contextMenu.appendItem(WebInspector.UIString("Open Link in Resources Panel"), WebInspector.openResource.bind(null, resourceURL, true));
+        return true;
+    },
+
     _updateMatchesCount: function()
     {
         WebInspector.updateSearchMatchesCount(this._searchResults.length, this);
diff --git a/WebCore/inspector/front-end/ElementsTreeOutline.js b/WebCore/inspector/front-end/ElementsTreeOutline.js
index 10131f4..1888a17 100644
--- a/WebCore/inspector/front-end/ElementsTreeOutline.js
+++ b/WebCore/inspector/front-end/ElementsTreeOutline.js
@@ -285,12 +285,21 @@ WebInspector.ElementsTreeOutline.prototype = {
 
         var contextMenu = new WebInspector.ContextMenu();
 
+        var href = event.target.enclosingNodeOrSelfWithClass("webkit-html-resource-link") || event.target.enclosingNodeOrSelfWithClass("webkit-html-external-link");
         var tag = event.target.enclosingNodeOrSelfWithClass("webkit-html-tag");
         var textNode = event.target.enclosingNodeOrSelfWithClass("webkit-html-text-node");
-        if (tag && listItem.treeElement._populateTagContextMenu)
+        var needSeparator;
+        if (href)
+            needSeparator = WebInspector.panels.elements.populateHrefContextMenu(contextMenu, event, href);
+        if (tag && listItem.treeElement._populateTagContextMenu) {
+            if (needSeparator)
+                contextMenu.appendSeparator();
             listItem.treeElement._populateTagContextMenu(contextMenu, event);
-        else if (textNode && listItem.treeElement._populateTextContextMenu)
+        } else if (textNode && listItem.treeElement._populateTextContextMenu) {
+            if (needSeparator)
+                contextMenu.appendSeparator();
             listItem.treeElement._populateTextContextMenu(contextMenu, textNode);
+        }
         contextMenu.show(event);
     }
 }
@@ -1189,29 +1198,6 @@ WebInspector.ElementsTreeElement.prototype = {
         this._highlightSearchResults();
     },
 
-    _rewriteAttrHref: function(node, hrefValue)
-    {
-        if (!hrefValue || hrefValue.indexOf("://") > 0)
-            return hrefValue;
-
-        for (var frameOwnerCandidate = node; frameOwnerCandidate; frameOwnerCandidate = frameOwnerCandidate.parentNode) {
-            if (frameOwnerCandidate.documentURL) {
-                var result = WebInspector.completeURL(frameOwnerCandidate.documentURL, hrefValue);
-                if (result)
-                    return result;
-                break;
-            }
-        }
-
-        // documentURL not found or has bad value
-        for (var url in WebInspector.resourceURLMap) {
-            var match = url.match(WebInspector.URLRegExp);
-            if (match && match[4] === hrefValue)
-                return url;
-        }
-        return hrefValue;
-    },
-
     _attributeHTML: function(name, value, node, linkify)
     {
         var hasText = (value.length > 0);
@@ -1221,7 +1207,7 @@ WebInspector.ElementsTreeElement.prototype = {
             html += "=&#8203;\"";
 
         if (linkify && (name === "src" || name === "href")) {
-            var rewrittenHref = this._rewriteAttrHref(node, value);
+            var rewrittenHref = WebInspector.resourceURLForRelatedNode(node, value);
             value = value.replace(/([\/;:\)\]\}])/g, "$1\u200B");
             html += linkify(rewrittenHref, value, "webkit-html-attribute-value", node.nodeName.toLowerCase() === "a");
         } else {
diff --git a/WebCore/inspector/front-end/StylesSidebarPane.js b/WebCore/inspector/front-end/StylesSidebarPane.js
index 1dddde7..6aff37d 100644
--- a/WebCore/inspector/front-end/StylesSidebarPane.js
+++ b/WebCore/inspector/front-end/StylesSidebarPane.js
@@ -64,6 +64,7 @@ WebInspector.StylesSidebarPane = function(computedStylePane)
 
     this.titleElement.appendChild(this.settingsSelectElement);
     this._computedStylePane = computedStylePane;
+    this.element.addEventListener("contextmenu", this._contextMenuEventFired.bind(this), true);
 }
 
 // Taken from http://www.w3.org/TR/CSS21/propidx.html.
@@ -105,6 +106,17 @@ WebInspector.StylesSidebarPane.prototype = {
             this.settingsSelectElement[2].selected = true;
     },
 
+    _contextMenuEventFired: function(event)
+    {
+        var href = event.target.enclosingNodeOrSelfWithClass("webkit-html-resource-link") || event.target.enclosingNodeOrSelfWithClass("webkit-html-external-link");
+        if (href) {
+            var contextMenu = new WebInspector.ContextMenu();
+            var filled = WebInspector.panels.elements.populateHrefContextMenu(contextMenu, event, href);
+            if (filled)
+                contextMenu.show(event);
+        }
+    },
+
     update: function(node, editedSection, forceUpdate)
     {
         var refresh = false;
diff --git a/WebCore/inspector/front-end/inspector.js b/WebCore/inspector/front-end/inspector.js
index 840745f..4c38a5a 100644
--- a/WebCore/inspector/front-end/inspector.js
+++ b/WebCore/inspector/front-end/inspector.js
@@ -788,6 +788,16 @@ WebInspector.documentClick = function(event)
     followLink();
 }
 
+WebInspector.openResource = function(resourceURL, inResourcesPanel)
+{
+    var resource = WebInspector.resourceForURL(resourceURL);
+    if (inResourcesPanel && resource) {
+        WebInspector.panels.resources.showResource(resource);
+        WebInspector.showPanel("resources");
+    } else
+        InspectorBackend.openInInspectedWindow(resource ? resource.url : resourceURL);
+}
+
 WebInspector._registerShortcuts = function()
 {
     var shortcut = WebInspector.KeyboardShortcut;
@@ -1828,6 +1838,29 @@ WebInspector.linkifyResourceAsNode = function(url, preferredPanel, lineNumber, c
     return node;
 }
 
+WebInspector.resourceURLForRelatedNode = function(node, url)
+{
+    if (!url || url.indexOf("://") > 0)
+        return url;
+
+    for (var frameOwnerCandidate = node; frameOwnerCandidate; frameOwnerCandidate = frameOwnerCandidate.parentNode) {
+        if (frameOwnerCandidate.documentURL) {
+            var result = WebInspector.completeURL(frameOwnerCandidate.documentURL, url);
+            if (result)
+                return result;
+            break;
+        }
+    }
+
+    // documentURL not found or has bad value
+    for (var resourceURL in WebInspector.resourceURLMap) {
+        var match = resourceURL.match(WebInspector.URLRegExp);
+        if (match && match[4] === url)
+            return resourceURL;
+    }
+    return url;
+},
+
 WebInspector.completeURL = function(baseURL, href)
 {
     var match = baseURL.match(WebInspector.URLRegExp);

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list