Bug 158272 - Web Inspector: Visual Styles: "Text -> Content" section should only be visible for pseudo-element
Summary: Web Inspector: Visual Styles: "Text -> Content" section should only be visibl...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Web Inspector (show other bugs)
Version: WebKit Nightly Build
Hardware: All All
: P2 Normal
Assignee: Devin Rousso
URL:
Keywords: InRadar
Depends on: 160893
Blocks: 148269 158271
  Show dependency treegraph
 
Reported: 2016-06-01 13:53 PDT by Nikita Vasilyev
Modified: 2016-08-22 22:36 PDT (History)
8 users (show)

See Also:


Attachments
Patch (5.82 KB, patch)
2016-08-15 15:54 PDT, Devin Rousso
no flags Details | Formatted Diff | Diff
Patch (10.58 KB, patch)
2016-08-16 00:11 PDT, Devin Rousso
no flags Details | Formatted Diff | Diff
Patch (6.45 KB, patch)
2016-08-16 17:56 PDT, Devin Rousso
no flags Details | Formatted Diff | Diff
Patch (6.46 KB, patch)
2016-08-19 10:55 PDT, Devin Rousso
joepeck: review+
Details | Formatted Diff | Diff
Patch (6.52 KB, patch)
2016-08-22 22:05 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 Nikita Vasilyev 2016-06-01 13:53:21 PDT
Currently, "Content" is the first item in the "Text" section,
yet it doesn't do anything for regular (non pseudo) elements.

We should only show it for pseudo elements.
Comment 1 Radar WebKit Bug Importer 2016-06-01 13:54:02 PDT
<rdar://problem/26585010>
Comment 2 Devin Rousso 2016-08-15 15:54:22 PDT
Created attachment 286106 [details]
Patch
Comment 3 Joseph Pecoraro 2016-08-15 16:44:20 PDT
Comment on attachment 286106 [details]
Patch

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

r=me, but maybe file a follow-up on better detection.

> Source/WebInspectorUI/UserInterface/Views/VisualStyleDetailsPanel.css:-100
> -.visual-style-property-container.transition,
> -.visual-style-property-container.animation {
> -    margin-left: 11px;
> -}

Seems unrelated, but fine!

> Source/WebInspectorUI/UserInterface/Views/VisualStyleDetailsPanel.js:193
> +        let isPseudoElement = currentSelector.includes(":before") || currentSelector.includes(":after") || this._nodeStyles.node.isPseudoElement();

This is tricky. Selector text of:  "foo x::before bar" wouldn't want this. But "foo, x::before, bar" would. Perhaps this could be made smarter to check each of the selectors to see if one ends with :before/:after?
Comment 4 Devin Rousso 2016-08-16 00:11:44 PDT
Created attachment 286157 [details]
Patch
Comment 5 Joseph Pecoraro 2016-08-16 12:07:09 PDT
Comment on attachment 286157 [details]
Patch

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

> Source/WebInspectorUI/UserInterface/Models/CSSRule.js:164
> +    hasMatchedPseudoSelector()
> +    {
> +        if (this.nodeStyles && this.nodeStyles.node && this.nodeStyles.node.isPseudoElement())
> +            return true;
> +
> +        return this.selectors.some((selector, i) => selector.isPseudoSelector() && this.matchedSelectors.includes(i));
> +    }

The intent here is PsuedoElement selectors. But there are plenty of other pseudo element selectors and the CSS content property only affects ::before/::after, so this should be hasBeforeAfterPseudoElementSelector, with a CSSSelector method isBeforeAfterPsuedoElementSelector. In reality I don't think we can do this perfectly without re-implementing a selector engine or backend support, since things like ":matches(div::before, foo)" which expands to "div::before, foo" would be missed. But what you have catches the 90% case, so I think its worth doing.

> Source/WebInspectorUI/UserInterface/Views/VisualStyleDetailsPanel.js:194
> +        let isMatchedPseudoSelector = this._currentStyle.ownerRule && this._currentStyle.ownerRule.hasMatchedPseudoSelector();
> +        this._groups.content.section.element.classList.toggle("inactive", !isMatchedPseudoSelector);
> +        this._groups.listStyle.section.element.classList.toggle("inactive", isMatchedPseudoSelector);

Variable name suggestion: let ruleMatchesBeforeAfterPseudoElement.

> Source/WebInspectorUI/UserInterface/Views/VisualStyleSelectorTreeItem.js:58
> +        let iconClasses = [iconClassName];
> +        if (style.ownerRule && style.ownerRule.hasMatchedPseudoSelector())
> +            iconClasses.push(WebInspector.CSSStyleDeclarationSection.PseudoSelectorStyleClassName);

I see this is doing the [P] things from the other patch. Which is still being discussed. I think the top parts above regarding `content` look good to me. But these still need some discussion.
Comment 6 Devin Rousso 2016-08-16 17:56:28 PDT
Created attachment 286240 [details]
Patch
Comment 7 Devin Rousso 2016-08-19 10:55:39 PDT
Created attachment 286461 [details]
Patch
Comment 8 Joseph Pecoraro 2016-08-22 19:59:09 PDT
Comment on attachment 286461 [details]
Patch

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

r=me

> Source/WebInspectorUI/UserInterface/Views/VisualStyleDetailsPanel.js:668
> +        properties.content = new WebInspector.VisualStyleBasicInput("content", null, WebInspector.UIString("Enter a value"));

Something feels off about this placeholder string. Safari's URL bar says "Search or enter website name" not "Search or enter a website name". Maybe drop the "a" here making this "Enter value"?
Comment 9 Devin Rousso 2016-08-22 22:05:53 PDT
Created attachment 286672 [details]
Patch
Comment 10 WebKit Commit Bot 2016-08-22 22:36:25 PDT
Comment on attachment 286672 [details]
Patch

Clearing flags on attachment: 286672

Committed r204757: <http://trac.webkit.org/changeset/204757>
Comment 11 WebKit Commit Bot 2016-08-22 22:36:29 PDT
All reviewed patches have been landed.  Closing bug.