Bug 148269 - Web Inspector: Visual styles sidebar should do something sane for SVG elements
Summary: Web Inspector: Visual styles sidebar should do something sane for SVG elements
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Web Inspector (show other bugs)
Version: WebKit Local Build
Hardware: All All
: P2 Normal
Assignee: Devin Rousso
URL:
Keywords: InRadar
Depends on: 158272
Blocks: 147563
  Show dependency treegraph
 
Reported: 2015-08-20 17:06 PDT by Timothy Hatcher
Modified: 2016-08-22 22:58 PDT (History)
12 users (show)

See Also:


Attachments
WIP-Patch (24.08 KB, patch)
2016-08-15 18:16 PDT, Devin Rousso
no flags Details | Formatted Diff | Diff
Patch (20.54 KB, patch)
2016-08-16 01:10 PDT, Devin Rousso
joepeck: review+
Details | Formatted Diff | Diff
Patch (20.18 KB, patch)
2016-08-16 17:01 PDT, Devin Rousso
no flags Details | Formatted Diff | Diff
Patch (20.59 KB, patch)
2016-08-19 10:51 PDT, Devin Rousso
joepeck: review+
Details | Formatted Diff | Diff
Patch (20.46 KB, patch)
2016-08-22 22:47 PDT, Devin Rousso
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Timothy Hatcher 2015-08-20 17:06:25 PDT
We likely need to have SVG specific sections we swap in and hide the more HTML specific sections.
Comment 1 Radar WebKit Bug Importer 2015-08-20 17:07:43 PDT
<rdar://problem/22371972>
Comment 2 Devin Rousso 2015-09-08 16:05:46 PDT
(In reply to comment #0)
> We likely need to have SVG specific sections we swap in and hide the more
> HTML specific sections.

I like this idea.  What specific sections do you have in mind?
Comment 3 Timothy Hatcher 2015-09-08 16:31:07 PDT
Anything that does not have an effect in SVG. :) I don't know off the top of my head.
Comment 4 Devin Rousso 2016-08-15 18:16:13 PDT
Created attachment 286129 [details]
WIP-Patch
Comment 5 WebKit Commit Bot 2016-08-15 18:17:41 PDT
Attachment 286129 [details] did not pass style-queue:


ERROR: Source/WebCore/ChangeLog:8:  You should remove the 'No new tests' and either add and list tests, or explain why no new tests were possible.  [changelog/nonewtests] [5]
Total errors found: 1 in 10 files


If any of these errors are false positives, please file a bug against check-webkit-style.
Comment 6 Joseph Pecoraro 2016-08-15 19:49:20 PDT
Comment on attachment 286129 [details]
WIP-Patch

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

Seems good, but I'm weary of the protocol change needed. r- while we work that part out. I suggested a frontend change, does that miss something?

> Source/JavaScriptCore/inspector/protocol/DOM.json:57
> +                { "name": "ownerSVGElement", "$ref": "Node", "optional": true, "description": "SVG element that contains this node." },

Hmm, I think we should avoid adding this to the protocol unless we (1) really need to (2) would get a good performance benefit from it.

I think we should be able to do this in the frontend. For example:

    ownerSVGElement()
    {
        if (this._nodeName === "svg")
            return this;
        if (!this.parentNode)
            return null;
        return this.parentNode.ownerSVGElement;
    }

    isSVGElement()
    {
        return !!this.ownerSVGElement;
    }

Is there something this might miss?

> Source/WebInspectorUI/UserInterface/Views/VisualStyleDetailsPanel.js:226
> +        this._groups.position.properties.cx.element.classList.toggle("inactive", !isSVGCircle && !isSVGEllipse && !isSVGRadialGradient);
> +        this._groups.position.properties.cy.element.classList.toggle("inactive", !isSVGCircle && !isSVGEllipse && !isSVGRadialGradient);

My eyes glazed over reading the states here. I trust it, but a few screenshots would help =)
Comment 7 Joseph Pecoraro 2016-08-15 20:00:55 PDT
>     ownerSVGElement()
>     {
>         if (this._nodeName === "svg")
>             return this;
>         if (!this.parentNode)
>             return null;
>         return this.parentNode.ownerSVGElement;

Err, `return this.parentNode.ownerSVGElement()`


>     }
> 
>     isSVGElement()
>     {
>         return !!this.ownerSVGElement;

Same here =)
Comment 8 Devin Rousso 2016-08-16 01:10:10 PDT
Created attachment 286167 [details]
Patch
Comment 9 Joseph Pecoraro 2016-08-16 11:56:13 PDT
Comment on attachment 286167 [details]
Patch

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

r=me

> Source/WebInspectorUI/UserInterface/Views/VisualStyleDetailsPanel.js:212
> +        // Only show the dimensions section if the current element is not <svg> or is <ellipse>, <rect>, <circle>, or <radialGradient>.
> +        this._groups.dimensions.section.element.classList.toggle("inactive", isSVGElement && !isSVGEllipse && !isSVGRect && !isSVGCircle && !isSVGRadialGradient);

Does "is not <svg>" really mean the SVGSVGElement? Because "isSVGElement" is just checking if the element is any kind of SVG element. Perhaps the comment should say "is not an SVG element".

The comments are great but they are the opposite of the conditions. Maybe the conditions should be written to match the comment?

    !( !isSVGElement || isSVGEllipse || isSVGRect || isSVGCircle || isSVGRadialGradient )
Comment 10 Devin Rousso 2016-08-16 17:01:58 PDT
Created attachment 286235 [details]
Patch
Comment 11 Devin Rousso 2016-08-19 10:51:08 PDT
Created attachment 286459 [details]
Patch
Comment 12 Nikita Vasilyev 2016-08-19 12:31:44 PDT
I applied this patch, opened WebInspectorUI/UserInterface/Images/NavigationItemTypes.svg, opened "Styles — Visual" and immediately got this uncaught exception:

undefined is not an object (evaluating 'this._groups.content.section')​ (at VisualStyleDetailsPanel.js:​197:​29)​
    _updateSections @ VisualStyleDetailsPanel.js:​197:​29
    dispatch @ Object.js:​162:​30
    dispatchEventToListeners @ Object.js:​169:​17
    _selectorChanged @ VisualStyleSelectorSection.js:​257:​38
    dispatch @ Object.js:​162:​30
    dispatchEventToListeners @ Object.js:​169:​17
    select @ TreeElement.js:​507:​49
    createSelectorItem @ VisualStyleSelectorSection.js:​113:​32
    update @ VisualStyleSelectorSection.js:​163:​36
    refresh @ VisualStyleDetailsPanel.js:​64:​41
    _refreshPreservingScrollPosition @ StyleDetailsPanel.js:​143:​21
    nodeStylesRefreshed @ StyleDetailsPanel.js:​114:​50
    dispatch @ Object.js:​162:​30
    dispatchEventToListeners @ Object.js:​169:​17
    fetchedComputedStyle @ DOMNodeStyles.js:​228:​42
    fetchedComputedStyle @ [native code]​
    _dispatchResponseToCallback @ InspectorBackend.js:​311:​27
    _dispatchResponse @ InspectorBackend.js:​281:​45
    dispatch @ InspectorBackend.js:​157:​35
    dispatchNextQueuedMessageFromBackend @ MessageDispatcher.js:​42:​34

Additional Details:​
    cause --> An uncaught exception was thrown while dispatching response callback for command CSS.getComputedStyleForNode.
Comment 13 Devin Rousso 2016-08-19 12:33:37 PDT
(In reply to comment #12)
> I applied this patch, opened
> WebInspectorUI/UserInterface/Images/NavigationItemTypes.svg, opened "Styles
> — Visual" and immediately got this uncaught exception:
> 
> undefined is not an object (evaluating 'this._groups.content.section')​ (at
> VisualStyleDetailsPanel.js:​197:​29)​
>     _updateSections @ VisualStyleDetailsPanel.js:​197:​29
>     dispatch @ Object.js:​162:​30
>     dispatchEventToListeners @ Object.js:​169:​17
>     _selectorChanged @ VisualStyleSelectorSection.js:​257:​38
>     dispatch @ Object.js:​162:​30
>     dispatchEventToListeners @ Object.js:​169:​17
>     select @ TreeElement.js:​507:​49
>     createSelectorItem @ VisualStyleSelectorSection.js:​113:​32
>     update @ VisualStyleSelectorSection.js:​163:​36
>     refresh @ VisualStyleDetailsPanel.js:​64:​41
>     _refreshPreservingScrollPosition @ StyleDetailsPanel.js:​143:​21
>     nodeStylesRefreshed @ StyleDetailsPanel.js:​114:​50
>     dispatch @ Object.js:​162:​30
>     dispatchEventToListeners @ Object.js:​169:​17
>     fetchedComputedStyle @ DOMNodeStyles.js:​228:​42
>     fetchedComputedStyle @ [native code]​
>     _dispatchResponseToCallback @ InspectorBackend.js:​311:​27
>     _dispatchResponse @ InspectorBackend.js:​281:​45
>     dispatch @ InspectorBackend.js:​157:​35
>     dispatchNextQueuedMessageFromBackend @ MessageDispatcher.js:​42:​34
> 
> Additional Details:​
>     cause --> An uncaught exception was thrown while dispatching response
> callback for command CSS.getComputedStyleForNode.

This is because it depends on <https://webkit.org/b/158272>, which redefines the Content section in the Visual Styles sidebar.
Comment 14 Nikita Vasilyev 2016-08-19 12:42:41 PDT
I still see all existing HTML sections for SVG? Is this intended?
Comment 15 Devin Rousso 2016-08-19 22:44:31 PDT
(In reply to comment #14)
> I still see all existing HTML sections for SVG? Is this intended?

The hiding of sections/editors is also derived from <https://webkit.org/b/158272> via the CSS rule:

.sidebar > .panel.details.css-style .visual > .details-section :matches(.details-section, .group).inactive {
    display: none;
}

To answer your question, some of the HTML sections should disappear (float, content, border, list style, etc.) when selecting an SVG element.
Comment 16 Joseph Pecoraro 2016-08-22 21:17:11 PDT
Comment on attachment 286459 [details]
Patch

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

r=me

> Source/WebInspectorUI/UserInterface/Views/VisualStyleDetailsPanel.js:199
> +        this._groups.fill.section.element.classList.toggle("inactive", !isSVGElement);
> +        this._groups.stroke.section.element.classList.toggle("inactive", !isSVGElement);

Can we separate these two lines from the others, so it is obvious that they are different?

> Source/WebInspectorUI/UserInterface/Views/VisualStyleUnitSlider.css:29
> +    background-image: linear-gradient(90deg, hsla(0, 0%, 0%, 0), #000), url(../Images/Checkers.svg);

Nit: We normally just say `black` instead of #000?
Comment 17 Devin Rousso 2016-08-22 22:47:46 PDT
Created attachment 286677 [details]
Patch
Comment 18 WebKit Commit Bot 2016-08-22 22:58:27 PDT
Comment on attachment 286677 [details]
Patch

Clearing flags on attachment: 286677

Committed r204758: <http://trac.webkit.org/changeset/204758>
Comment 19 WebKit Commit Bot 2016-08-22 22:58:33 PDT
All reviewed patches have been landed.  Closing bug.