Web Inspector: srcset attributes should have hyperlinks to the resources
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 22 Oct 2015 21:37:04 +0000 (21:37 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 22 Oct 2015 21:37:04 +0000 (21:37 +0000)
https://bugs.webkit.org/show_bug.cgi?id=150409

Patch by Joseph Pecoraro <pecoraro@apple.com> on 2015-10-22
Reviewed by Timothy Hatcher.

Follow-up tweaks and fixes that were intended to be landed.

* UserInterface/Views/CodeMirrorAdditions.js:
(tokenizeSrcSetString):
Multiline parsing has issues recovering the state CodeMirror
expects, so we just bail in those cases. Leading whitespace
is also handled poorly, but expected to be rare.

* UserInterface/Views/DOMTreeElement.js:
(WebInspector.DOMTreeElement.prototype._buildAttributeDOM):
Trim to eliminate leading whitespace.

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

Source/WebInspectorUI/ChangeLog
Source/WebInspectorUI/UserInterface/Views/CodeMirrorAdditions.js
Source/WebInspectorUI/UserInterface/Views/DOMTreeElement.js

index 4c755a3..af84787 100644 (file)
@@ -1,5 +1,24 @@
 2015-10-22  Joseph Pecoraro  <pecoraro@apple.com>
 
+        Web Inspector: srcset attributes should have hyperlinks to the resources
+        https://bugs.webkit.org/show_bug.cgi?id=150409
+
+        Reviewed by Timothy Hatcher.
+
+        Follow-up tweaks and fixes that were intended to be landed.
+
+        * UserInterface/Views/CodeMirrorAdditions.js:
+        (tokenizeSrcSetString):
+        Multiline parsing has issues recovering the state CodeMirror
+        expects, so we just bail in those cases. Leading whitespace
+        is also handled poorly, but expected to be rare.
+
+        * UserInterface/Views/DOMTreeElement.js:
+        (WebInspector.DOMTreeElement.prototype._buildAttributeDOM):
+        Trim to eliminate leading whitespace.
+
+2015-10-22  Joseph Pecoraro  <pecoraro@apple.com>
+
         Web Inspector: Restore :not(:placeholder-shown) behavior on search bars with comments
         https://bugs.webkit.org/show_bug.cgi?id=150452
 
index 30a7725..f963e2e 100644 (file)
             if (state._linkQuoteCharacter)
                 stream.eatWhile(new RegExp("[^," + state._linkQuoteCharacter + "]"));
             else
-                stream.eatWhile(/[^\s\u00a0=<>\"\',]/);
+                stream.eatWhile(/[^\s\u00a0=<>\"\']/);
             stream.eatWhile(/[\s,]/);
         }
 
         // If the stream isn't at the end of line and we found the end quote
         // change _linkTokenize to parse the end of the link next. Otherwise
         // _linkTokenize will stay as-is to parse more of the srcset.
-        if (!stream.eol() && (!state._linkQuoteCharacter || stream.peek() === state._linkQuoteCharacter))
+        if (stream.eol() || (!state._linkQuoteCharacter || stream.peek() === state._linkQuoteCharacter))
             state._linkTokenize = tokenizeEndOfLinkString;
 
         // Link portion.
                 state._linkTokenize = tokenizeLinkString;
                 state._linkBaseStyle = style;
 
-                // The attribute should be quoted.
+                // The attribute may or may not be quoted.
                 var quote = current[0];
 
                 state._linkQuoteCharacter = quote === "'" || quote === "\"" ? quote : null;
index 5a99629..3bfec95 100644 (file)
@@ -1113,9 +1113,10 @@ WebInspector.DOMTreeElement = class DOMTreeElement extends WebInspector.TreeElem
             let baseURL = node.ownerDocument ? node.ownerDocument.documentURL : null;
             attrValueElement = attrSpanElement.createChild("span", "html-attribute-value");
 
+            // Leading whitespace.
             let groups = value.split(/\s*,\s*/);
             for (let i = 0; i < groups.length; ++i) {
-                let string = groups[i];
+                let string = groups[i].trim();
                 let spaceIndex = string.search(/\s/);
 
                 if (spaceIndex === -1) {