Ignore:
Timestamp:
Apr 21, 2020, 8:03:43 PM (5 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.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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);
Note: See TracChangeset for help on using the changeset viewer.