Bug 147711 - Web Inspector: Add different types of non-numerical Visual editors for CSS properties
Summary: Web Inspector: Add different types of non-numerical Visual editors for CSS pr...
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: 147576 147579
Blocks: 147563 147570
  Show dependency treegraph
 
Reported: 2015-08-05 18:36 PDT by Devin Rousso
Modified: 2015-10-01 01:57 PDT (History)
9 users (show)

See Also:


Attachments
Patch (70.04 KB, patch)
2015-08-05 18:40 PDT, Devin Rousso
no flags Details | Formatted Diff | Diff
Patch (72.20 KB, patch)
2015-08-06 23:35 PDT, Devin Rousso
bburg: review+
Details | Formatted Diff | Diff
Patch (73.30 KB, patch)
2015-08-10 12:51 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 Devin Rousso 2015-08-05 18:36:09 PDT
Adds the following types of Visual editors:

 - Color picker
 - Checkbox for a single keyword value
 - Selectable buttons in a list for multiple keyword values
 - Dropdown menu for multiple keyword values
 - Input (with autocomplete) for all the CSS property names
 - Slider with a range of [0, 1]
 - Input for URLs

Will be use in the new Visual style details panel in the CSS sidebar.
Comment 1 Devin Rousso 2015-08-05 18:40:38 PDT
Created attachment 258333 [details]
Patch
Comment 2 BJ Burg 2015-08-06 16:32:40 PDT
Comment on attachment 258333 [details]
Patch

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

Looks good!

A few overall issues to address, in addition to lower level changes:

 - `let`/`const` all the things
 - Needs ARIA roles and tabIndex

> Source/WebInspectorUI/UserInterface/Views/VisualStyleColorPicker.css:44
> +    background-color: white;

(Multiple places) Nit: don't use color keywords.

> Source/WebInspectorUI/UserInterface/Views/VisualStyleColorPicker.css:45
> +    background-size: calc(50%);

Is this different from just '50%'?

> Source/WebInspectorUI/UserInterface/Views/VisualStyleColorPicker.js:42
> +        this._textInput = document.createElement("input");

Rename: this._textInputElement

> Source/WebInspectorUI/UserInterface/Views/VisualStyleColorPicker.js:163
> +        if (keyCode === 9 || keyCode === 13) {

(Multiple places) It would be less obscure to do something like:

var tabKeyCode = WebInspector.KeyboardShortcut.Key.Tab.keyCode;
var enterKeyCode = WebInspector.KeyboardShortcut.Key.Enter.keyCode;
if (keyCode === tabKeyCode || keyCode === enterKeyCode) { ...

> Source/WebInspectorUI/UserInterface/Views/VisualStyleKeywordCheckbox.js:37
> +        this._contentElement.appendChild(this._checkbox);

(Multiple places) If contentElement is created by the base class, then it should not be prefixed with an underscore. Add a getter and put it in the // Protected section.

> Source/WebInspectorUI/UserInterface/Views/VisualStyleKeywordCheckbox.js:45
> +        this._valueRegExp = /^([^;]+)\s*;?$/;

(Multiple places) If valueRegExp is used by the base class, then it should be an overridden getter. Even better, don't require that the derived class provide a RegExp instance; just have a parseValue() function that everyone overrides, possibly returning null or something if there's no current regex.

> Source/WebInspectorUI/UserInterface/Views/VisualStyleKeywordIconList.js:39
> +        var prettyPropertyReferenceName = this._propertyReferenceName.capitalize().replace(/(-.)/g,function(x){ return x[1].toUpperCase() });

Um, that's quite the line. :) Please break the regex into a separate line. Don't forget the semicolon in the callback.

> Source/WebInspectorUI/UserInterface/Views/VisualStyleKeywordIconList.js:42
> +        {

Nit: Opening brace doesn't need its own line for function declaration statements.

> Source/WebInspectorUI/UserInterface/Views/VisualStyleKeywordIconList.js:43
> +            var iconButton = document.createElement("button");

Rename: iconButtonElement

> Source/WebInspectorUI/UserInterface/Views/VisualStyleKeywordIconList.js:58
> +            var icon = createListItem.call(this, key, this._possibleValues.basic[key]);

Rename: iconElement

> Source/WebInspectorUI/UserInterface/Views/VisualStyleKeywordIconList.js:94
> +        var selected = this._selectedIcon && this._selectedIcon.classList.toggle("selected");

Rename: iconIsSelected

I didn't know classList.toggle returned a value. Can we avoid using this for both the side-effect and return value?

> Source/WebInspectorUI/UserInterface/Views/VisualStyleKeywordPicker.js:32
> +        this._keywordSelect = document.createElement("select");

Rename: this._keywordSelectElement

> Source/WebInspectorUI/UserInterface/Views/VisualStyleKeywordPicker.js:44
> +        this._unchangedOption = document.createElement("option");

Rename: this._unchangedOptionElement

> Source/WebInspectorUI/UserInterface/Views/VisualStylePropertyNameInput.js:89
> +        if (keyCode === 9 || keyCode === 13) {

See note from above.

> Source/WebInspectorUI/UserInterface/Views/VisualStyleURLInput.js:34
> +        this._urlInput.placeholder = WebInspector.UIString("Enter a url");

"Enter a URL"
Comment 3 Devin Rousso 2015-08-06 23:35:31 PDT
Created attachment 258464 [details]
Patch
Comment 4 BJ Burg 2015-08-10 10:32:37 PDT
Comment on attachment 258464 [details]
Patch

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

r=me

Make sure you land things in the correct order, if there are dependencies.

> Source/WebInspectorUI/UserInterface/Views/Slider.js:132
>      get _maxX()

I don't think we have any other getters in the codebase that are private. I would make this public (why not?) and drop the leading underscore for the getter. Then use just one underscore for the member.

> Source/WebInspectorUI/UserInterface/Views/VisualStyleColorPicker.js:34
> +        this._swatchElement.title = WebInspector.UIString("Click to open a colorpicker. Shift-click to change color format.");

This message does not conform to the verbiage recommended by the Apple Style Guide. Something like "Click to select a color. Shift-click to switch color formats."

https://help.apple.com/asg/mac/2013/#apsg1f284f4c

> Source/WebInspectorUI/UserInterface/Views/VisualStyleColorPicker.js:41
> +

We should be setting aria roles here. My opinion on this has changed since Friday, I think we should add accessibility support in a follow-up patch. It is really hard to determine the proper role and make sure we set the right attributes, without a live example to play with.

> Source/WebInspectorUI/UserInterface/Views/VisualStyleColorPicker.js:109
> +        this._swatchInnerElement.style.backgroundColor = this._color ? value : null;

What does setting background color to "null" do? Does it ignore this inline style property?

> Source/WebInspectorUI/UserInterface/Views/VisualStyleKeywordCheckbox.js:34
> +        this._checkbox = document.createElement("input");

Rename: this._checkboxElement

> Source/WebInspectorUI/UserInterface/Views/VisualStyleKeywordCheckbox.js:37
> +        this.contentElement.appendChild(this._checkbox);

Because this uses a real checkbox, the accessibility role should be taken care of automatically, I think. It might need a custom aria-label per instance, though.

> Source/WebInspectorUI/UserInterface/Views/VisualStyleKeywordIconList.js:37
> +        this._selectedIcon = null;

Not sure what to do about accessibility here. Let's defer until it's all connected.

> Source/WebInspectorUI/UserInterface/Views/VisualStyleKeywordPicker.js:35
> +            this._keywordSelectElement.title = WebInspector.UIString("Alt Click to show all values");

Alt-click

> Source/WebInspectorUI/UserInterface/Views/VisualStyleKeywordPicker.js:39
> +        this._unchangedOptionElement.text = WebInspector.UIString("Unchanged");

"Default"? Don't exactly remember where this goes in the UI.
Comment 5 Devin Rousso 2015-08-10 10:40:07 PDT
Comment on attachment 258464 [details]
Patch

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

>> Source/WebInspectorUI/UserInterface/Views/VisualStyleColorPicker.js:34
>> +        this._swatchElement.title = WebInspector.UIString("Click to open a colorpicker. Shift-click to change color format.");
> 
> This message does not conform to the verbiage recommended by the Apple Style Guide. Something like "Click to select a color. Shift-click to switch color formats."
> 
> https://help.apple.com/asg/mac/2013/#apsg1f284f4c

I was just copying what the current color picker uses for a title.  Should I change that too?

>> Source/WebInspectorUI/UserInterface/Views/VisualStyleColorPicker.js:109
>> +        this._swatchInnerElement.style.backgroundColor = this._color ? value : null;
> 
> What does setting background color to "null" do? Does it ignore this inline style property?

It allows the "transparent" background to be visible (its a checkerboard pattern set in CSS).

>> Source/WebInspectorUI/UserInterface/Views/VisualStyleKeywordPicker.js:39
>> +        this._unchangedOptionElement.text = WebInspector.UIString("Unchanged");
> 
> "Default"? Don't exactly remember where this goes in the UI.

Default isn't exactly what we are going for here as that implies what is set originally on the item (like the default for Display is Block).  Unchanged is meant to state that this property has not been changed at all from the computed value.
Comment 6 BJ Burg 2015-08-10 11:09:35 PDT
(In reply to comment #5)
> Comment on attachment 258464 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=258464&action=review
> 
> >> Source/WebInspectorUI/UserInterface/Views/VisualStyleColorPicker.js:34
> >> +        this._swatchElement.title = WebInspector.UIString("Click to open a colorpicker. Shift-click to change color format.");
> > 
> > This message does not conform to the verbiage recommended by the Apple Style Guide. Something like "Click to select a color. Shift-click to switch color formats."
> > 
> > https://help.apple.com/asg/mac/2013/#apsg1f284f4c
> 
> I was just copying what the current color picker uses for a title.  Should I
> change that too?

Yes.
Comment 7 Devin Rousso 2015-08-10 12:51:54 PDT
Created attachment 258640 [details]
Patch
Comment 8 WebKit Commit Bot 2015-08-10 13:56:36 PDT
Comment on attachment 258640 [details]
Patch

Clearing flags on attachment: 258640

Committed r188229: <http://trac.webkit.org/changeset/188229>
Comment 9 WebKit Commit Bot 2015-08-10 13:56:40 PDT
All reviewed patches have been landed.  Closing bug.
Comment 10 Radar WebKit Bug Importer 2015-08-14 11:44:37 PDT
<rdar://problem/22290849>
Comment 11 Andres Gomez Garcia 2015-10-01 01:54:25 PDT
Comment on attachment 258640 [details]
Patch

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

I know this patch already landed, but wanted to provide some comments. I hope they are helpful.

> Source/WebInspectorUI/UserInterface/Images/FontVariantSmallCaps.svg:4
> +    <rect class="filled" x="-2" width="20" height="20" fill="white" stroke="none" />

Is this white background on purpose?
Comment 12 Andres Gomez Garcia 2015-10-01 01:57:14 PDT
Comment on attachment 258640 [details]
Patch

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

> Source/WebInspectorUI/UserInterface/Images/FontStyleItalic.svg:3
> +<svg version="1.1" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" font-size="9" font-family="-apple-system, sans-serif" font-style="italic">

I'm sure you know better, but it doesn't seems wise to use a font and not convert the text to curves.

> Source/WebInspectorUI/UserInterface/Images/FontStyleNormal.svg:3
> +<svg version="1.1" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" font-size="9" font-family="-apple-system, sans-serif">

Ditto.

> Source/WebInspectorUI/UserInterface/Images/FontVariantSmallCaps.svg:3
> +<svg version="1.1" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" font-size="7" font-family="-apple-system, sans-serif">

Ditto.

> Source/WebInspectorUI/UserInterface/Images/TextDecorationLineThrough.svg:3
> +<svg version="1.1" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" font-size="9" font-family="-apple-system, sans-serif">

Ditto.

> Source/WebInspectorUI/UserInterface/Images/TextDecorationOverline.svg:3
> +<svg version="1.1" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" font-size="9" font-family="-apple-system, sans-serif">

Ditto.

> Source/WebInspectorUI/UserInterface/Images/TextDecorationUnderline.svg:3
> +<svg version="1.1" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" font-size="9" font-family="-apple-system, sans-serif">

Ditto.

> Source/WebInspectorUI/UserInterface/Images/TextTransformCapitalize.svg:3
> +<svg version="1.1" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" font-size="9" font-family="-apple-system, sans-serif">

Ditto.

> Source/WebInspectorUI/UserInterface/Images/TextTransformLowercase.svg:3
> +<svg version="1.1" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" font-size="9" font-family="-apple-system, sans-serif">

Ditto.

> Source/WebInspectorUI/UserInterface/Images/TextTransformUppercase.svg:3
> +<svg version="1.1" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" font-size="9" font-family="-apple-system, sans-serif">

Ditto.