Changeset 253348 in webkit


Ignore:
Timestamp:
Dec 10, 2019 3:01:47 PM (4 years ago)
Author:
Devin Rousso
Message:

Web Inspector: REGRESSION(r251038): Elements: Computed: implicit shorthands are not shown when "Prefer Shorthands" is enabled
https://bugs.webkit.org/show_bug.cgi?id=205035
<rdar://problem/57773470>

Reviewed by Brian Burg.

The computed style treats most shorthand properties as "implicit", meaning that if "Prefer
Shorthands" is enabled, we won't show the shorthand properties unless "Show All" is also
enabled. The frontend can fix this by checking to see if there are any non-implicit longhand
values for each shorthand value, and therefore decide not to hide the "implicit" shorthand.

  • UserInterface/Views/ComputedStyleSection.js:

(WI.ComputedStyleSection.prototype.get propertiesToRender):
(WI.ComputedStyleSection.prototype.get propertiesToRender.hasNonImplicitLonghand): Added.
Drive-by: filter the list of properties to render before sorting them for performance.

Location:
trunk/Source/WebInspectorUI
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebInspectorUI/ChangeLog

    r253338 r253348  
     12019-12-10  Devin Rousso  <drousso@apple.com>
     2
     3        Web Inspector: REGRESSION(r251038): Elements: Computed: implicit shorthands are not shown when "Prefer Shorthands" is enabled
     4        https://bugs.webkit.org/show_bug.cgi?id=205035
     5        <rdar://problem/57773470>
     6
     7        Reviewed by Brian Burg.
     8
     9        The computed style treats most shorthand properties as "implicit", meaning that if "Prefer
     10        Shorthands" is enabled, we won't show the shorthand properties unless "Show All" is also
     11        enabled. The frontend can fix this by checking to see if there are any non-implicit longhand
     12        values for each shorthand value, and therefore decide not to hide the "implicit" shorthand.
     13
     14        * UserInterface/Views/ComputedStyleSection.js:
     15        (WI.ComputedStyleSection.prototype.get propertiesToRender):
     16        (WI.ComputedStyleSection.prototype.get propertiesToRender.hasNonImplicitLonghand): Added.
     17        Drive-by: filter the list of properties to render before sorting them for performance.
     18
    1192019-12-10  Devin Rousso  <drousso@apple.com>
    220
  • trunk/Source/WebInspectorUI/UserInterface/Views/ComputedStyleSection.js

    r251883 r253348  
    141141            properties = this._style.properties;
    142142
    143         properties.sort((a, b) => a.name.extendedLocaleCompare(b.name));
     143        let propertyNameMap = new Map(properties.map((property) => [property.canonicalName, property]));
     144
     145        function hasNonImplicitLonghand(property) {
     146            if (property.canonicalName === "all")
     147                return false;
     148
     149            let longhandPropertyNames = WI.CSSKeywordCompletions.LonghandNamesForShorthandProperty.get(property.canonicalName);
     150            if (!longhandPropertyNames)
     151                return false;
     152
     153            for (let longhandPropertyName of longhandPropertyNames) {
     154                let property = propertyNameMap.get(longhandPropertyName);
     155                if (property && !property.implicit)
     156                    return true;
     157            }
     158
     159            return false;
     160        }
    144161
    145162        let hideVariables = this._propertyVisibilityMode === ComputedStyleSection.PropertyVisibilityMode.HideVariables;
    146163        let hideNonVariables = this._propertyVisibilityMode === ComputedStyleSection.PropertyVisibilityMode.HideNonVariables;
    147164
    148         return properties.filter((property) => {
     165        properties = properties.filter((property) => {
    149166            if (this._alwaysShowPropertyNames.has(property.canonicalName))
    150167                return true;
    151168
    152             if (property.implicit && !this._showsImplicitProperties)
    153                 return false;
     169            if (property.implicit && !this._showsImplicitProperties) {
     170                if (!(this._showsShorthandsInsteadOfLonghands && property.isShorthand && hasNonImplicitLonghand(property)))
     171                    return false;
     172            }
    154173
    155174            if (this._showsShorthandsInsteadOfLonghands) {
     
    167186            return true;
    168187        });
     188
     189        properties.sort((a, b) => a.name.extendedLocaleCompare(b.name));
     190        return properties;
    169191    }
    170192
Note: See TracChangeset for help on using the changeset viewer.