Changeset 260491 in webkit


Ignore:
Timestamp:
Apr 21, 2020 8:03:43 PM (4 years ago)
Author:
cathiechen
Message:

REGRESSION (r254790): No longer get smooth scrolling on music.apple.com
https://bugs.webkit.org/show_bug.cgi?id=210634

Reviewed by Darin Adler.

Source/WebCore:

The page uses the access of "scrollBehavior" in CSSStyleDeclaration as the support of scroll-behavior.
If supported, it will use scroll-behavior. Otherwise, it will perform a JS smooth scroll.
Currently, "scrollBehavior" is still available when CSSOMViewSmoothScrolling is off, only the value
"smooth" is invalidated.
In order to fix this, CSSStyleDeclaration will take account of CSSOMViewSmoothScrolling in Settings.
This patch also tries to provide an interface which let flags in Settings can enable/disable a property.
However, it is not complete, for there are some scenarios that Settings isn't accessible. By adding
"settings-flag" to CSSProperties.json, it would be effective to control the property access in CSSStyleDeclaration.

Tests: fast/scrolling/scroll-behavior-invalidate-if-disabled.html

fast/scrolling/scroll-behavior-validate-if-enabled.html

  • css/CSSProperties.json:
  • css/CSSStyleDeclaration.cpp:

(WebCore::CSSStyleDeclaration::getCSSPropertyIDFromJavaScriptPropertyName):
(WebCore::CSSStyleDeclaration::namedItem):
(WebCore::CSSStyleDeclaration::setNamedItem):
(WebCore::CSSStyleDeclaration::supportedPropertyNames const):

  • css/makeprop.pl:

(addProperty):

  • css/parser/CSSPropertyParser.cpp:

(WebCore::cssPropertyID):

  • inspector/InspectorStyleSheet.cpp:

(WebCore::InspectorStyle::collectProperties const):

  • inspector/agents/InspectorCSSAgent.cpp:

(WebCore::InspectorCSSAgent::getSupportedCSSProperties):

Tools:

Add settings-flag. Add support for CSSOMViewSmoothScrolling on Windows DumpRenderTree.

  • DumpRenderTree/win/DumpRenderTree.cpp:

(enableExperimentalFeatures):
(setWebPreferencesForTestOptions):

  • Scripts/webkitpy/style/checkers/jsonchecker.py:

(JSONCSSPropertiesChecker.check_codegen_properties):

LayoutTests:

"scrollBehavior" is not available in CSSStyleDeclaration if the flag is off.
It's available if the flag is on.

  • fast/scrolling/scroll-behavior-invalidate-if-disabled-expected.txt: Added.
  • fast/scrolling/scroll-behavior-invalidate-if-disabled.html: Added.
  • fast/scrolling/scroll-behavior-validate-if-enabled-expected.txt: Added.
  • fast/scrolling/scroll-behavior-validate-if-enabled.html: Added.
Location:
trunk
Files:
4 added
12 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r260489 r260491  
     12020-04-21  Cathie Chen  <cathiechen@igalia.com>
     2
     3        REGRESSION (r254790): No longer get smooth scrolling on music.apple.com
     4        https://bugs.webkit.org/show_bug.cgi?id=210634
     5
     6        Reviewed by Darin Adler.
     7
     8        "scrollBehavior" is not available in CSSStyleDeclaration if the flag is off.
     9        It's available if the flag is on.
     10
     11        * fast/scrolling/scroll-behavior-invalidate-if-disabled-expected.txt: Added.
     12        * fast/scrolling/scroll-behavior-invalidate-if-disabled.html: Added.
     13        * fast/scrolling/scroll-behavior-validate-if-enabled-expected.txt: Added.
     14        * fast/scrolling/scroll-behavior-validate-if-enabled.html: Added.
     15
    1162020-04-21  Yusuke Suzuki  <ysuzuki@apple.com>
    217
  • trunk/Source/WebCore/ChangeLog

    r260489 r260491  
     12020-04-21  Cathie Chen  <cathiechen@igalia.com>
     2
     3        REGRESSION (r254790): No longer get smooth scrolling on music.apple.com
     4        https://bugs.webkit.org/show_bug.cgi?id=210634
     5
     6        Reviewed by Darin Adler.
     7
     8        The page uses the access of "scrollBehavior" in CSSStyleDeclaration as the support of scroll-behavior.
     9        If supported, it will use scroll-behavior. Otherwise, it will perform a JS smooth scroll.
     10        Currently, "scrollBehavior" is still available when CSSOMViewSmoothScrolling is off, only the value
     11        "smooth" is invalidated.
     12        In order to fix this, CSSStyleDeclaration will take account of CSSOMViewSmoothScrolling in Settings.
     13        This patch also tries to provide an interface which let flags in Settings can enable/disable a property.
     14        However, it is not complete, for there are some scenarios that Settings isn't accessible. By adding
     15        "settings-flag" to CSSProperties.json, it would be effective to control the property access in CSSStyleDeclaration.
     16
     17        Tests: fast/scrolling/scroll-behavior-invalidate-if-disabled.html
     18               fast/scrolling/scroll-behavior-validate-if-enabled.html
     19
     20        * css/CSSProperties.json:
     21        * css/CSSStyleDeclaration.cpp:
     22        (WebCore::CSSStyleDeclaration::getCSSPropertyIDFromJavaScriptPropertyName):
     23        (WebCore::CSSStyleDeclaration::namedItem):
     24        (WebCore::CSSStyleDeclaration::setNamedItem):
     25        (WebCore::CSSStyleDeclaration::supportedPropertyNames const):
     26        * css/makeprop.pl:
     27        (addProperty):
     28        * css/parser/CSSPropertyParser.cpp:
     29        (WebCore::cssPropertyID):
     30        * inspector/InspectorStyleSheet.cpp:
     31        (WebCore::InspectorStyle::collectProperties const):
     32        * inspector/agents/InspectorCSSAgent.cpp:
     33        (WebCore::InspectorCSSAgent::getSupportedCSSProperties):
     34
    1352020-04-21  Yusuke Suzuki  <ysuzuki@apple.com>
    236
  • trunk/Source/WebCore/css/CSSProperties.json

    r259532 r260491  
    131131        "that conditionally enables the property.",
    132132        "",
     133        "* settings-flag:",
     134        "The name of the flag on Settings (e.g. \"CSSOMViewSmoothScrolling\")",
     135        "that conditionally enables the property.",
     136        "",
    133137        "2. Lesser known capabilities of this file format",
    134138        "",
     
    35733577            }
    35743578        },
    3575         "scroll-behavior": {
    3576             "values": [
    3577                 "auto",
    3578                 "smooth"
    3579             ],
    3580             "specification": {
    3581                 "category": "cssom-view",
    3582                 "url": "https://drafts.csswg.org/cssom-view/#propdef-scroll-behavior"
    3583             }
    3584         },
    35853579        "shape-rendering": {
    35863580            "inherited": true,
     
    65166510            ],
    65176511            "codegen-properties": {
     6512                "settings-flag": "CSSOMViewSmoothScrolling",
    65186513                "converter": "SmoothScrolling",
    65196514                "name-for-methods": "UseSmoothScrolling"
  • trunk/Source/WebCore/css/CSSStyleDeclaration.cpp

    r252392 r260491  
    3030#include "CSSPropertyParser.h"
    3131#include "DeprecatedGlobalSettings.h"
     32#include "Document.h"
    3233#include "HashTools.h"
    3334#include "RuntimeEnabledFeatures.h"
     35#include "Settings.h"
     36#include "StyledElement.h"
    3437#include <wtf/IsoMallocInlines.h>
    3538#include <wtf/Optional.h>
     
    150153};
    151154
    152 static CSSPropertyInfo parseJavaScriptCSSPropertyName(const AtomString& propertyName)
     155static CSSPropertyInfo parseJavaScriptCSSPropertyName(const AtomString& propertyName, const Settings* settingsPtr)
    153156{
    154157    using CSSPropertyInfoMap = HashMap<String, CSSPropertyInfo>;
     
    248251    if (auto propertyID = hashTableEntry ? hashTableEntry->id : 0) {
    249252        auto id = static_cast<CSSPropertyID>(propertyID);
    250         if (isEnabledCSSProperty(id)) {
     253        if (isEnabledCSSProperty(id) && isCSSPropertyEnabledBySettings(id, settingsPtr)) {
    251254            propertyInfo.hadPixelOrPosPrefix = hadPixelOrPosPrefix;
    252255            propertyInfo.propertyID = id;
     
    261264CSSPropertyID CSSStyleDeclaration::getCSSPropertyIDFromJavaScriptPropertyName(const AtomString& propertyName)
    262265{
    263     return parseJavaScriptCSSPropertyName(propertyName).propertyID;
     266    return parseJavaScriptCSSPropertyName(propertyName, nullptr).propertyID;
    264267}
    265268
    266269Optional<Variant<String, double>> CSSStyleDeclaration::namedItem(const AtomString& propertyName)
    267270{
    268     auto propertyInfo = parseJavaScriptCSSPropertyName(propertyName);
     271    auto* settingsPtr = parentElement() ? &parentElement()->document().settings() : nullptr;
     272    auto propertyInfo = parseJavaScriptCSSPropertyName(propertyName, settingsPtr);
    269273    if (!propertyInfo.propertyID)
    270274        return WTF::nullopt;
     
    288292ExceptionOr<void> CSSStyleDeclaration::setNamedItem(const AtomString& propertyName, String value, bool& propertySupported)
    289293{
    290     auto propertyInfo = parseJavaScriptCSSPropertyName(propertyName);
     294    auto* settingsPtr = parentElement() ? &parentElement()->document().settings() : nullptr;
     295    auto propertyInfo = parseJavaScriptCSSPropertyName(propertyName, settingsPtr);
    291296    if (!propertyInfo.propertyID) {
    292297        propertySupported = false;
     
    322327        for (int i = 0; i < numCSSProperties; ++i) {
    323328            CSSPropertyID id = static_cast<CSSPropertyID>(firstCSSProperty + i);
     329            // FIXME: Should take account for flags in settings().
    324330            if (isEnabledCSSProperty(id))
    325331                names[numNames++] = getJSPropertyName(id);
  • trunk/Source/WebCore/css/makeprop.pl

    r260335 r260491  
    6464my @internalProprerties;
    6565my %runtimeFlags;
     66my %settingsFlags;
    6667my $numPredefinedProperties = 2;
    6768my %nameIsInherited;
     
    252253                } elsif ($codegenOptionName eq "runtime-flag") {
    253254                    $runtimeFlags{$name} = $codegenProperties->{"runtime-flag"};
     255                } elsif ($codegenOptionName eq "settings-flag") {
     256                    $settingsFlags{$name} = $codegenProperties->{"settings-flag"};
    254257                } else {
    255258                    die "Unrecognized codegen property \"$codegenOptionName\" for $name property.";
     
    297300#include \"HashTools.h\"
    298301#include "RuntimeEnabledFeatures.h"
     302#include "Settings.h"
    299303#include <wtf/ASCIICType.h>
    300304#include <wtf/text/AtomString.h>
     
    390394}
    391395
     396bool isCSSPropertyEnabledBySettings(const CSSPropertyID id, const Settings* settings)
     397{
     398    if (!settings)
     399        return true;
     400
     401    switch (id) {
     402EOF
     403
     404foreach my $name (keys %settingsFlags) {
     405  print GPERF "    case CSSPropertyID::CSSProperty" . $nameToId{$name} . ":\n";
     406  print GPERF "        return settings->" . $settingsFlags{$name} . "Enabled();\n";
     407}
     408
     409print GPERF << "EOF";
     410    default:
     411        return true;
     412    }
     413    return true;
     414}
     415
    392416const char* getPropertyName(CSSPropertyID id)
    393417{
     
    522546
    523547namespace WebCore {
     548
     549class Settings;
    524550
    525551enum CSSPropertyID : uint16_t {
     
    577603bool isInternalCSSProperty(const CSSPropertyID);
    578604bool isEnabledCSSProperty(const CSSPropertyID);
     605bool isCSSPropertyEnabledBySettings(const CSSPropertyID, const Settings* = nullptr);
    579606const char* getPropertyName(CSSPropertyID);
    580607const WTF::AtomString& getPropertyNameAtomString(CSSPropertyID id);
  • trunk/Source/WebCore/css/parser/CSSPropertyParser.cpp

    r259659 r260491  
    144144    if (hashTableEntry) {
    145145        auto propertyID = static_cast<CSSPropertyID>(hashTableEntry->id);
     146        // FIXME: Should take account for flags in settings().
    146147        if (isEnabledCSSProperty(propertyID))
    147148            return propertyID;
  • trunk/Source/WebCore/inspector/InspectorStyleSheet.cpp

    r260069 r260491  
    605605        for (auto i = firstCSSProperty; i < lastCSSProperty; ++i) {
    606606            auto id = convertToCSSPropertyID(i);
     607            // FIXME: Should take account for flags in settings().
    607608            if (isInternalCSSProperty(id) || !isEnabledCSSProperty(id))
    608609                continue;
  • trunk/Source/WebCore/inspector/agents/InspectorCSSAgent.cpp

    r260069 r260491  
    781781    for (int i = firstCSSProperty; i <= lastCSSProperty; ++i) {
    782782        CSSPropertyID propertyID = convertToCSSPropertyID(i);
     783        // FIXME: Should take account for flags in settings().
    783784        if (isInternalCSSProperty(propertyID) || !isEnabledCSSProperty(propertyID))
    784785            continue;
  • trunk/Source/WebKitLegacy/win/WebPreferenceKeysPrivate.h

    r256512 r260491  
    215215
    216216#define WebKitCSSOMViewScrollingAPIEnabledPreferenceKey "WebKitCSSOMViewScrollingAPIEnabled"
     217
    217218#define WebKitCSSOMViewSmoothScrollingEnabledPreferenceKey "WebKitCSSOMViewSmoothScrollingEnabled"
    218219
  • trunk/Tools/ChangeLog

    r260486 r260491  
     12020-04-21  Cathie Chen  <cathiechen@igalia.com>
     2
     3        REGRESSION (r254790): No longer get smooth scrolling on music.apple.com
     4        https://bugs.webkit.org/show_bug.cgi?id=210634
     5
     6        Reviewed by Darin Adler.
     7
     8        Add settings-flag. Add support for CSSOMViewSmoothScrolling on Windows DumpRenderTree.
     9
     10        * DumpRenderTree/win/DumpRenderTree.cpp:
     11        (enableExperimentalFeatures):
     12        (setWebPreferencesForTestOptions):
     13        * Scripts/webkitpy/style/checkers/jsonchecker.py:
     14        (JSONCSSPropertiesChecker.check_codegen_properties):
     15
    1162020-04-21  Peng Liu  <peng.liu6@apple.com>
    217
  • trunk/Tools/DumpRenderTree/win/DumpRenderTree.cpp

    r256512 r260491  
    804804    // FIXME: WebGL2
    805805    // FIXME: WebRTC
     806    prefsPrivate->setCSSOMViewSmoothScrollingEnabled(TRUE);
    806807}
    807808
     
    922923    preferences->setPrivateBrowsingEnabled(options.useEphemeralSession);
    923924    preferences->setUsesPageCache(options.enableBackForwardCache);
     925    prefsPrivate->setCSSOMViewSmoothScrollingEnabled(options.enableCSSOMViewSmoothScrolling);
    924926}
    925927
  • trunk/Tools/Scripts/webkitpy/style/checkers/jsonchecker.py

    r259006 r260491  
    291291            'runtime-flag': self.validate_string,
    292292            'setter': self.validate_string,
     293            'settings-flag': self.validate_string,
    293294            'skip-builder': self.validate_boolean,
    294295            'skip-codegen': self.validate_boolean,
Note: See TracChangeset for help on using the changeset viewer.