Title: [191519] trunk/Source/WebInspectorUI
Revision
191519
Author
[email protected]
Date
2015-10-23 17:24:53 -0700 (Fri, 23 Oct 2015)

Log Message

Web Inspector: xlink:href should be linkified
https://bugs.webkit.org/show_bug.cgi?id=150505

Patch by Joseph Pecoraro <[email protected]> on 2015-10-23
Reviewed by Timothy Hatcher.

* UserInterface/Base/Main.js:
When opening a URL with a fragment, prefer opening a resource
that has the same URL without the fragment, otherwise this would
open in a new tab.

* UserInterface/Base/URLUtilities.js:
(absoluteURL):
Better handling absoluteURL("#frag", baseURL).

* UserInterface/Views/CodeMirrorAdditions.js:
* UserInterface/Views/DOMTreeElement.js:
(WebInspector.DOMTreeElement.prototype._buildAttributeDOM):
Allow for more "href" style attributes, such as XML namespaced
"xlink:href" attribute names.

Modified Paths

Diff

Modified: trunk/Source/WebInspectorUI/ChangeLog (191518 => 191519)


--- trunk/Source/WebInspectorUI/ChangeLog	2015-10-23 23:55:41 UTC (rev 191518)
+++ trunk/Source/WebInspectorUI/ChangeLog	2015-10-24 00:24:53 UTC (rev 191519)
@@ -1,3 +1,25 @@
+2015-10-23  Joseph Pecoraro  <[email protected]>
+
+        Web Inspector: xlink:href should be linkified
+        https://bugs.webkit.org/show_bug.cgi?id=150505
+
+        Reviewed by Timothy Hatcher.
+
+        * UserInterface/Base/Main.js:
+        When opening a URL with a fragment, prefer opening a resource
+        that has the same URL without the fragment, otherwise this would
+        open in a new tab.
+
+        * UserInterface/Base/URLUtilities.js:
+        (absoluteURL):
+        Better handling absoluteURL("#frag", baseURL).
+
+        * UserInterface/Views/CodeMirrorAdditions.js:
+        * UserInterface/Views/DOMTreeElement.js:
+        (WebInspector.DOMTreeElement.prototype._buildAttributeDOM):
+        Allow for more "href" style attributes, such as XML namespaced
+        "xlink:href" attribute names.
+
 2015-10-23  Nikita Vasilyev  <[email protected]>
 
         Web Inspector: Command-Enter in Debugger should show a popover with evaluation result

Modified: trunk/Source/WebInspectorUI/UserInterface/Base/Main.js (191518 => 191519)


--- trunk/Source/WebInspectorUI/UserInterface/Base/Main.js	2015-10-23 23:55:41 UTC (rev 191518)
+++ trunk/Source/WebInspectorUI/UserInterface/Base/Main.js	2015-10-24 00:24:53 UTC (rev 191519)
@@ -688,7 +688,8 @@
     console.assert(frame);
 
     // WebInspector.Frame.resourceForURL does not check the main resource, only sub-resources. So check both.
-    var resource = frame.url ="" url ? frame.mainResource : frame.resourceForURL(url, searchChildFrames);
+    let simplifiedURL = removeURLFragment(url);
+    var resource = frame.url ="" simplifiedURL ? frame.mainResource : frame.resourceForURL(simplifiedURL, searchChildFrames);
     if (resource) {
         var position = new WebInspector.SourceCodePosition(lineNumber, 0);
         this.showSourceCode(resource, position);

Modified: trunk/Source/WebInspectorUI/UserInterface/Base/URLUtilities.js (191518 => 191519)


--- trunk/Source/WebInspectorUI/UserInterface/Base/URLUtilities.js	2015-10-23 23:55:41 UTC (rev 191518)
+++ trunk/Source/WebInspectorUI/UserInterface/Base/URLUtilities.js	2015-10-24 00:24:53 UTC (rev 191519)
@@ -153,6 +153,12 @@
     if (partialURL[0] === "/")
         return baseURLPrefix + resolveDotsInPath(partialURL);
 
+    // A URL that starts with "#" is just a fragment that gets applied to the base URL (replacing the base URL fragment, maintaining the query string).
+    if (partialURL[0] === "#") {
+        let queryStringComponent = baseURLComponents.queryString ? "?" + baseURLComponents.queryString : "";
+        return baseURLPrefix + baseURLComponents.path + queryStringComponent + partialURL;
+    }
+
     // Generate the base path that is used in the final case by removing everything after the last "/" from the base URL's path.
     var basePath = baseURLComponents.path.substring(0, baseURLComponents.path.lastIndexOf("/")) + "/";
     return baseURLPrefix + resolveDotsInPath(basePath + partialURL);

Modified: trunk/Source/WebInspectorUI/UserInterface/Views/CodeMirrorAdditions.js (191518 => 191519)


--- trunk/Source/WebInspectorUI/UserInterface/Views/CodeMirrorAdditions.js	2015-10-23 23:55:41 UTC (rev 191518)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/CodeMirrorAdditions.js	2015-10-24 00:24:53 UTC (rev 191519)
@@ -124,7 +124,7 @@
             // Look for "href" or "src" attributes. If found then we should
             // expect a string later that should get the "link" style instead.
             var text = stream.current().toLowerCase();
-            if (text === "href" || text === "src")
+            if (text === "src" || /\bhref\b/.test(text))
                 state._expectLink = true;
             else if (text === "srcset")
                 state._expectSrcSet = true;

Modified: trunk/Source/WebInspectorUI/UserInterface/Views/DOMTreeElement.js (191518 => 191519)


--- trunk/Source/WebInspectorUI/UserInterface/Views/DOMTreeElement.js	2015-10-23 23:55:41 UTC (rev 191518)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/DOMTreeElement.js	2015-10-24 00:24:53 UTC (rev 191519)
@@ -1093,7 +1093,7 @@
         if (hasText)
             attrSpanElement.append("=\u200B\"");
 
-        if (name === "src" || name === "href") {
+        if (name === "src" || /\bhref\b/.test(name)) {
             let baseURL = node.ownerDocument ? node.ownerDocument.documentURL : null;
             let rewrittenURL = absoluteURL(value, baseURL);
             value = value.insertWordBreakCharacters();
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to