Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: a6fb71355a3d3d21d04f662d6ed0e192752d4450
      
https://github.com/WebKit/WebKit/commit/a6fb71355a3d3d21d04f662d6ed0e192752d4450
  Author: Razvan Caliman <[email protected]>
  Date:   2022-12-08 (Thu, 08 Dec 2022)

  Changed paths:
    M LayoutTests/inspector/css/css-property-expected.txt
    M LayoutTests/inspector/css/css-property.html
    M Source/WebCore/inspector/InspectorStyleSheet.cpp

  Log Message:
  -----------
  Web Inspector: REGRESSION(r256223@main) Styles Panel: All CSS variables 
marked as unsupported
https://bugs.webkit.org/show_bug.cgi?id=248314

Reviewed by Darin Adler.

Querying `WebCore::cssPropertyID()` defined in `CSSPropertyParser.cpp`
with a CSS custom property name (aka CSS variable) mistakenly returns
`CSSPropertyID::CSSPropertyInvalid` instead of 
`CSSPropertyID::CSSPropertyCustom`.

This was also the case before https://github.com/WebKit/WebKit/pull/5986 landed,
so this wasn't regressed by it.

What the refactoring in https://github.com/WebKit/WebKit/pull/5986 did was to
introduce stricter checks in `PropertySetCSSStyleDeclaration::isExposed()`
and in `WebCore::isExposed()` declared in the generated file 
`CSSPropertyNames.cpp`
to return `false` when encountering `CSSPropertyID::CSSPropertyInvalid`.

The specific `CSSPropertyID` wasn't of particular importance for Web Inspector 
so the
wrong id didn't cause issues previously.

But `InspectorStyle::styleWithProperties()` makes use of the `isExposed()` 
check to
mark a CSS custom property as `property->setParsedOk(false)` which ultimately 
marks it
as unsupported in the Web Inspector frontend.

Now that the check is more strict, compounded with the effect of the mistaken
`CSSPropertyID::CSSPropertyInvalid`, causes CSS custom properties to be 
incorrectly
marked as unsupported.

To mitigate this:

- explicitly check if the property is a custom property and assign it the 
correct id of
`CSSPropertyID::CSSPropertyCustom`.

- since `WebCore::nameString()` can't return an arbitrary CSS custom property 
name
even if it were provided the correct `CSSPropertyID`, we guard for this before 
calling the method.

There are many callers of `WebCore::cssPropertyID()` and only some of them
manually check for `WebCore::isCustomPropertyName()` to take special action.
Fixing the root issue so that it correctly returns 
`CSSPropertyID::CSSPropertyCustom`
will be done in another patch to account for any regressions it may introduce.

* LayoutTests/inspector/css/css-property-expected.txt:
* LayoutTests/inspector/css/css-property.html:

Added a check that CSS custom properties are valid.
`Protocol::CSS::CSSProperty::parsedOk` maps to `WI.CSSProperty.valid`.

* Source/WebCore/inspector/InspectorStyleSheet.cpp:
(WebCore::InspectorStyle::styleWithProperties const):

Canonical link: https://commits.webkit.org/257564@main


_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to