Bug 16079 - Web Inspector: SVG image content view should toggle between image and source
Summary: Web Inspector: SVG image content view should toggle between image and source
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Web Inspector (show other bugs)
Version: 528+ (Nightly build)
Hardware: All All
: P2 Normal
Assignee: Devin Rousso
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2007-11-21 00:17 PST by Eric Seidel (no email)
Modified: 2017-03-15 12:54 PDT (History)
8 users (show)

See Also:


Attachments
Patch (10.59 KB, patch)
2017-03-13 18:58 PDT, Devin Rousso
no flags Details | Formatted Diff | Diff
[Image] After Patch is applied (691.26 KB, image/png)
2017-03-13 19:00 PDT, Devin Rousso
no flags Details
Patch (11.77 KB, patch)
2017-03-13 20:22 PDT, Devin Rousso
joepeck: review+
Details | Formatted Diff | Diff
[Image] After Patch is applied (689.62 KB, image/png)
2017-03-13 20:22 PDT, Devin Rousso
no flags Details
Patch (11.34 KB, patch)
2017-03-14 13:44 PDT, Devin Rousso
no flags Details | Formatted Diff | Diff
Archive of layout-test-results from ews126 for ios-simulator-wk2 (deleted)
2017-03-14 14:55 PDT, Build Bot
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Eric Seidel (no email) 2007-11-21 00:17:34 PST
No way to view source for SVGImage resources in inspector

The Inspector has not yet been educated about SVG images and the fact that they have source which is human readable.  I discovered this today when looking at if bug 16056 applied to CachedImage (for the SVGImage case).  bug 16056 does apply to CachedImage, but only if the Inspector is able to display the source for .svg files used by <img> tags or CSS backgrounds.
Comment 1 Timothy Hatcher 2007-11-21 08:42:04 PST
Where does the SVG image show up in resources? I assume under the Images category?

We could have Preview, Source and DOM views for SVG images (a three part segmented-button in the toolbar.)

Comment 2 Eric Seidel (no email) 2007-11-21 11:05:59 PST
Yes, it shows up under Images.  Preview/Source/DOM sounds great to me. :)  Obviously this is not a high priority issue, but once we work out more of the bugs in SVGImage, I do see that as the major way SVG will be used on the web (in HTML via <img> tags and CSS background-image: properties).
Comment 3 Adam Roben (:aroben) 2008-01-29 11:04:18 PST
<rdar://problem/5712856>
Comment 4 Anthony Ricaud 2009-09-14 16:03:08 PDT
Isn't it fixed by now ?
Comment 5 Timothy Hatcher 2009-09-14 16:52:55 PDT
I don't think so. I think we still just show a preview for SVG images, and no way to see the source.
Comment 6 Alexei Masterov 2010-09-16 08:22:15 PDT
There are at least two ways that I know of that and SVG can be included into page:

1. <img="name.svg">

2. <object data="name.svg">

in the first case - the browser treats it as a static image and renders it as such, in the second case - the browser treats it as an organic part of the page, allows javascript that is inside it to interact with the page DOM, etc.

Inspector is consistent with the browser in a way that it displays the content of an SVG in both cases.  In the first case it treats it as an image, in the second case it treats it as a source file, allows javascript debugging, and includes it's DOM as a subtree into the DOM of the page.

Can you please provide a reason for why it would be beneficial to the end user to show more than what the browser sees in the first case?
Comment 7 Devin Rousso 2017-03-13 18:58:22 PDT
Created attachment 304332 [details]
Patch
Comment 8 Devin Rousso 2017-03-13 19:00:48 PDT
Created attachment 304334 [details]
[Image] After Patch is applied
Comment 9 Joseph Pecoraro 2017-03-13 19:20:09 PDT
Comment on attachment 304332 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=304332&action=review

> Source/WebInspectorUI/UserInterface/Views/ImageResourceContentView.js:43
> +        if (this._resource.mimeTypeComponents.type === "image/svg+xml") {
> +            if (!this._showSourceButtonNavigationItem) {
> +                this._showSourceButtonNavigationItem = new WebInspector.ActivateButtonNavigationItem("svg-show-source", WebInspector.UIString("Show Source"), WebInspector.UIString("Show Image"), "Images/NavigationItemCurleyBraces.svg", 13, 13);
> +                this._showSourceButtonNavigationItem.addEventListener(WebInspector.ButtonNavigationItem.Event.Clicked, this._handleShowSourceClick, this);
> +            }
> +            return [this._showSourceButtonNavigationItem];
> +        }

I think we should experiment with a ResourceClusterView like approach and have a toggle between "Image" and "Text" or "Source" (and maybe eventually "DOM" or "Tree"). This button is okay, but I think the other approach is more generic and expands to more than 2 displays. I've stopped the review here because I think we both agree we should try out this approach.
Comment 10 Devin Rousso 2017-03-13 20:22:17 PDT
Created attachment 304341 [details]
Patch
Comment 11 Devin Rousso 2017-03-13 20:22:30 PDT
Created attachment 304342 [details]
[Image] After Patch is applied
Comment 12 BJ Burg 2017-03-13 22:07:52 PDT
Comment on attachment 304332 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=304332&action=review

>> Source/WebInspectorUI/UserInterface/Views/ImageResourceContentView.js:43
>> +        }
> 
> I think we should experiment with a ResourceClusterView like approach and have a toggle between "Image" and "Text" or "Source" (and maybe eventually "DOM" or "Tree"). This button is okay, but I think the other approach is more generic and expands to more than 2 displays. I've stopped the review here because I think we both agree we should try out this approach.

I agree as well.
Comment 13 Dean Jackson 2017-03-14 11:08:15 PDT
Comment on attachment 304341 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=304341&action=review

This looks good to me, but I'll let a WI team member put the r+

> Source/WebInspectorUI/UserInterface/Views/SVGImageResourceClusterContentView.js:140
> +                    representedObject += contentViewToShow.textEditor.string = fileReader.result;

I'm not sure about WI coding guidelines, but I'd do this in two separate lines. Also, I'm not sure why you need representedObject here at all - you used it above when creating the TextContentView, but I don't see where you use it again.
Comment 14 Joseph Pecoraro 2017-03-14 11:35:13 PDT
Comment on attachment 304341 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=304341&action=review

r=me

> Source/WebInspectorUI/UserInterface/Main.html:665
>      <script src="Views/StorageSidebarPanel.js"></script>
> +    <script src="Views/SVGImageResourceClusterContentView.js"></script>
>      <script src="Views/SyntaxHighlightingSupport.js"></script>

Nit: Sort using `sort`. Capitalizes are less than lower case. So "SVG" < "St".

> Source/WebInspectorUI/UserInterface/Views/SVGImageResourceClusterContentView.js:43
> +        this._imagePathComponent = createPathComponent(WebInspector.UIString("Image"), "image", WebInspector.SVGImageResourceClusterContentView.Identifier.ShowImage);
> +        this._sourcePathComponent = createPathComponent(WebInspector.UIString("Source"), "source", WebInspector.SVGImageResourceClusterContentView.Identifier.ShowSource);

Do these have icons? They should have something.

> Source/WebInspectorUI/UserInterface/Views/SVGImageResourceClusterContentView.js:66
> +    shown()

Add a `// Protected` comment above these.

> Source/WebInspectorUI/UserInterface/Views/SVGImageResourceClusterContentView.js:137
> +            this._resource.requestContent()
> +            .then((result) => {

Style: I'd read this easier as:

    this._resource.requestContent().then((result) => {
        ...
    }).catch(handlePromiseException);

I understand others disagree.

>> Source/WebInspectorUI/UserInterface/Views/SVGImageResourceClusterContentView.js:140
>> +                    representedObject += contentViewToShow.textEditor.string = fileReader.result;
> 
> I'm not sure about WI coding guidelines, but I'd do this in two separate lines. Also, I'm not sure why you need representedObject here at all - you used it above when creating the TextContentView, but I don't see where you use it again.

Indeed, representedObject is unused here, so you can drop the var everywhere and just inline an empty string above.

> Source/WebInspectorUI/UserInterface/Views/SVGImageResourceClusterContentView.js:168
> +WebInspector.SVGImageResourceClusterContentView.Identifier = {
> +    ShowImage: "show-image",
> +    ShowSource: "show-source",
> +};

Why the "Show" prefix? Seems Identifier.Image and Identifier.Source would be sufficient.
Comment 15 Devin Rousso 2017-03-14 13:44:22 PDT
Created attachment 304417 [details]
Patch
Comment 16 Build Bot 2017-03-14 14:55:05 PDT
Comment on attachment 304417 [details]
Patch

Attachment 304417 [details] did not pass ios-sim-ews (ios-simulator-wk2):
Output: http://webkit-queues.webkit.org/results/3323797

New failing tests:
imported/w3c/web-platform-tests/IndexedDB/fire-success-event-exception.html
Comment 17 Build Bot 2017-03-14 14:55:12 PDT
Created attachment 304432 [details]
Archive of layout-test-results from ews126 for ios-simulator-wk2

The attached test failures were seen while running run-webkit-tests on the ios-sim-ews.
Bot: ews126  Port: ios-simulator-wk2  Platform: Mac OS X 10.11.6
Comment 18 Joseph Pecoraro 2017-03-15 11:33:43 PDT
Comment on attachment 304417 [details]
Patch

What is left to review of this patch? I still think there should be icons for the options, but other than that this looks good.
Comment 19 Devin Rousso 2017-03-15 11:45:34 PDT
Comment on attachment 304417 [details]
Patch

(In reply to comment #18)
> Comment on attachment 304417 [details]
> Patch
> 
> What is left to review of this patch? I still think there should be icons
> for the options, but other than that this looks good.

<https://webkit.org/b/169687>
Comment 20 WebKit Commit Bot 2017-03-15 12:15:30 PDT
Comment on attachment 304417 [details]
Patch

Clearing flags on attachment: 304417

Committed r213999: <http://trac.webkit.org/changeset/213999>
Comment 21 WebKit Commit Bot 2017-03-15 12:15:36 PDT
All reviewed patches have been landed.  Closing bug.
Comment 22 Timothy Hatcher 2017-03-15 12:54:01 PDT
Comment on attachment 304417 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=304417&action=review

> Source/WebInspectorUI/UserInterface/Views/SVGImageResourceClusterContentView.js:42
> +        this._imagePathComponent = createPathComponent(WebInspector.UIString("Image"), "image", WebInspector.SVGImageResourceClusterContentView.Identifier.Image);

I'm on the fence on if this should say "Image" or "Preview". Eventually we might even want "DOM Tree", and then it really might be "Preview" if changes to the DOM are allowed.