Title: [260491] trunk
Revision
260491
Author
cathiec...@igalia.com
Date
2020-04-21 20:03:43 -0700 (Tue, 21 Apr 2020)

Log 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.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (260490 => 260491)


--- trunk/LayoutTests/ChangeLog	2020-04-22 02:54:28 UTC (rev 260490)
+++ trunk/LayoutTests/ChangeLog	2020-04-22 03:03:43 UTC (rev 260491)
@@ -1,3 +1,18 @@
+2020-04-21  Cathie Chen  <cathiec...@igalia.com>
+
+        REGRESSION (r254790): No longer get smooth scrolling on music.apple.com
+        https://bugs.webkit.org/show_bug.cgi?id=210634
+
+        Reviewed by Darin Adler.
+
+        "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.
+
 2020-04-21  Yusuke Suzuki  <ysuz...@apple.com>
 
         Canonicalize JSBigInt generated by structured-cloning by calling rightTrim

Added: trunk/LayoutTests/fast/scrolling/scroll-behavior-invalidate-if-disabled-expected.txt (0 => 260491)


--- trunk/LayoutTests/fast/scrolling/scroll-behavior-invalidate-if-disabled-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/scrolling/scroll-behavior-invalidate-if-disabled-expected.txt	2020-04-22 03:03:43 UTC (rev 260491)
@@ -0,0 +1 @@
+Pass test scrollBehavior should be invalidate if CSSOMViewSmoothScrollingEnabled is disabled.

Added: trunk/LayoutTests/fast/scrolling/scroll-behavior-invalidate-if-disabled.html (0 => 260491)


--- trunk/LayoutTests/fast/scrolling/scroll-behavior-invalidate-if-disabled.html	                        (rev 0)
+++ trunk/LayoutTests/fast/scrolling/scroll-behavior-invalidate-if-disabled.html	2020-04-22 03:03:43 UTC (rev 260491)
@@ -0,0 +1,15 @@
+<!DOCTYPE html><!-- webkit-test-runner [ experimental:CSSOMViewSmoothScrollingEnabled=false ] -->
+<html>
+    <head>
+    <script>
+        if (window.testRunner)
+            testRunner.dumpAsText();
+
+        if ("scrollBehavior" in document.documentElement.style)
+            document.write("Fail test scrollBehavior should be invalidate if CSSOMViewSmoothScrollingEnabled is disabled.");
+        else
+            document.write("Pass test scrollBehavior should be invalidate if CSSOMViewSmoothScrollingEnabled is disabled.");
+
+    </script>
+    </head>
+</html>
\ No newline at end of file

Added: trunk/LayoutTests/fast/scrolling/scroll-behavior-validate-if-enabled-expected.txt (0 => 260491)


--- trunk/LayoutTests/fast/scrolling/scroll-behavior-validate-if-enabled-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/scrolling/scroll-behavior-validate-if-enabled-expected.txt	2020-04-22 03:03:43 UTC (rev 260491)
@@ -0,0 +1 @@
+Pass test scrollBehavior should be validate if CSSOMViewSmoothScrollingEnabled is enabled.

Added: trunk/LayoutTests/fast/scrolling/scroll-behavior-validate-if-enabled.html (0 => 260491)


--- trunk/LayoutTests/fast/scrolling/scroll-behavior-validate-if-enabled.html	                        (rev 0)
+++ trunk/LayoutTests/fast/scrolling/scroll-behavior-validate-if-enabled.html	2020-04-22 03:03:43 UTC (rev 260491)
@@ -0,0 +1,15 @@
+<!DOCTYPE html><!-- webkit-test-runner [ experimental:CSSOMViewSmoothScrollingEnabled=true ] -->
+<html>
+    <head>
+    <script>
+        if (window.testRunner)
+            testRunner.dumpAsText();
+
+        if ("scrollBehavior" in document.documentElement.style)
+            document.write("Pass test scrollBehavior should be validate if CSSOMViewSmoothScrollingEnabled is enabled.");
+        else
+            document.write("Fail test scrollBehavior should be validate if CSSOMViewSmoothScrollingEnabled is enabled.");
+
+    </script>
+    </head>
+</html>
\ No newline at end of file

Modified: trunk/Source/WebCore/ChangeLog (260490 => 260491)


--- trunk/Source/WebCore/ChangeLog	2020-04-22 02:54:28 UTC (rev 260490)
+++ trunk/Source/WebCore/ChangeLog	2020-04-22 03:03:43 UTC (rev 260491)
@@ -1,3 +1,37 @@
+2020-04-21  Cathie Chen  <cathiec...@igalia.com>
+
+        REGRESSION (r254790): No longer get smooth scrolling on music.apple.com
+        https://bugs.webkit.org/show_bug.cgi?id=210634
+
+        Reviewed by Darin Adler.
+
+        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):
+
 2020-04-21  Yusuke Suzuki  <ysuz...@apple.com>
 
         Canonicalize JSBigInt generated by structured-cloning by calling rightTrim

Modified: trunk/Source/WebCore/css/CSSProperties.json (260490 => 260491)


--- trunk/Source/WebCore/css/CSSProperties.json	2020-04-22 02:54:28 UTC (rev 260490)
+++ trunk/Source/WebCore/css/CSSProperties.json	2020-04-22 03:03:43 UTC (rev 260491)
@@ -130,6 +130,10 @@
         "The name of the flag on RuntimeEnabledFeatures (e.g. \"cssLogical\")",
         "that conditionally enables the property.",
         "",
+        "* settings-flag:",
+        "The name of the flag on Settings (e.g. \"CSSOMViewSmoothScrolling\")",
+        "that conditionally enables the property.",
+        "",
         "2. Lesser known capabilities of this file format",
         "",
         "Conditional CSS keyword value:",
@@ -3572,16 +3576,6 @@
                 "url": "https://www.w3.org/TR/SVG/shapes.html"
             }
         },
-        "scroll-behavior": {
-            "values": [
-                "auto",
-                "smooth"
-            ],
-            "specification": {
-                "category": "cssom-view",
-                "url": "https://drafts.csswg.org/cssom-view/#propdef-scroll-behavior"
-            }
-        },
         "shape-rendering": {
             "inherited": true,
             "values": [
@@ -6515,6 +6509,7 @@
                 "smooth"
             ],
             "codegen-properties": {
+                "settings-flag": "CSSOMViewSmoothScrolling",
                 "converter": "SmoothScrolling",
                 "name-for-methods": "UseSmoothScrolling"
             },

Modified: trunk/Source/WebCore/css/CSSStyleDeclaration.cpp (260490 => 260491)


--- trunk/Source/WebCore/css/CSSStyleDeclaration.cpp	2020-04-22 02:54:28 UTC (rev 260490)
+++ trunk/Source/WebCore/css/CSSStyleDeclaration.cpp	2020-04-22 03:03:43 UTC (rev 260491)
@@ -29,8 +29,11 @@
 #include "CSSPropertyNames.h"
 #include "CSSPropertyParser.h"
 #include "DeprecatedGlobalSettings.h"
+#include "Document.h"
 #include "HashTools.h"
 #include "RuntimeEnabledFeatures.h"
+#include "Settings.h"
+#include "StyledElement.h"
 #include <wtf/IsoMallocInlines.h>
 #include <wtf/Optional.h>
 #include <wtf/Variant.h>
@@ -149,7 +152,7 @@
     bool hadPixelOrPosPrefix;
 };
 
-static CSSPropertyInfo parseJavaScriptCSSPropertyName(const AtomString& propertyName)
+static CSSPropertyInfo parseJavaScriptCSSPropertyName(const AtomString& propertyName, const Settings* settingsPtr)
 {
     using CSSPropertyInfoMap = HashMap<String, CSSPropertyInfo>;
     static NeverDestroyed<CSSPropertyInfoMap> propertyInfoCache;
@@ -247,7 +250,7 @@
     auto* hashTableEntry = findProperty(name, outputLength);
     if (auto propertyID = hashTableEntry ? hashTableEntry->id : 0) {
         auto id = static_cast<CSSPropertyID>(propertyID);
-        if (isEnabledCSSProperty(id)) {
+        if (isEnabledCSSProperty(id) && isCSSPropertyEnabledBySettings(id, settingsPtr)) {
             propertyInfo.hadPixelOrPosPrefix = hadPixelOrPosPrefix;
             propertyInfo.propertyID = id;
             propertyInfoCache.get().add(propertyNameString, propertyInfo);
@@ -260,12 +263,13 @@
 
 CSSPropertyID CSSStyleDeclaration::getCSSPropertyIDFromJavaScriptPropertyName(const AtomString& propertyName)
 {
-    return parseJavaScriptCSSPropertyName(propertyName).propertyID;
+    return parseJavaScriptCSSPropertyName(propertyName, nullptr).propertyID;
 }
 
 Optional<Variant<String, double>> CSSStyleDeclaration::namedItem(const AtomString& propertyName)
 {
-    auto propertyInfo = parseJavaScriptCSSPropertyName(propertyName);
+    auto* settingsPtr = parentElement() ? &parentElement()->document().settings() : nullptr;
+    auto propertyInfo = parseJavaScriptCSSPropertyName(propertyName, settingsPtr);
     if (!propertyInfo.propertyID)
         return WTF::nullopt;
 
@@ -287,7 +291,8 @@
 
 ExceptionOr<void> CSSStyleDeclaration::setNamedItem(const AtomString& propertyName, String value, bool& propertySupported)
 {
-    auto propertyInfo = parseJavaScriptCSSPropertyName(propertyName);
+    auto* settingsPtr = parentElement() ? &parentElement()->document().settings() : nullptr;
+    auto propertyInfo = parseJavaScriptCSSPropertyName(propertyName, settingsPtr);
     if (!propertyInfo.propertyID) {
         propertySupported = false;
         return { };
@@ -321,6 +326,7 @@
         String names[numCSSProperties];
         for (int i = 0; i < numCSSProperties; ++i) {
             CSSPropertyID id = static_cast<CSSPropertyID>(firstCSSProperty + i);
+            // FIXME: Should take account for flags in settings().
             if (isEnabledCSSProperty(id))
                 names[numNames++] = getJSPropertyName(id);
         }

Modified: trunk/Source/WebCore/css/makeprop.pl (260490 => 260491)


--- trunk/Source/WebCore/css/makeprop.pl	2020-04-22 02:54:28 UTC (rev 260490)
+++ trunk/Source/WebCore/css/makeprop.pl	2020-04-22 03:03:43 UTC (rev 260491)
@@ -63,6 +63,7 @@
 my @names;
 my @internalProprerties;
 my %runtimeFlags;
+my %settingsFlags;
 my $numPredefinedProperties = 2;
 my %nameIsInherited;
 my %nameIsHighPriority;
@@ -251,6 +252,8 @@
                     push @internalProprerties, $name
                 } elsif ($codegenOptionName eq "runtime-flag") {
                     $runtimeFlags{$name} = $codegenProperties->{"runtime-flag"};
+                } elsif ($codegenOptionName eq "settings-flag") {
+                    $settingsFlags{$name} = $codegenProperties->{"settings-flag"};
                 } else {
                     die "Unrecognized codegen property \"$codegenOptionName\" for $name property.";
                 }
@@ -296,6 +299,7 @@
 #include \"CSSPropertyNames.h\"
 #include \"HashTools.h\"
 #include "RuntimeEnabledFeatures.h"
+#include "Settings.h"
 #include <wtf/ASCIICType.h>
 #include <wtf/text/AtomString.h>
 #include <wtf/text/WTFString.h>
@@ -389,6 +393,26 @@
     }
 }
 
+bool isCSSPropertyEnabledBySettings(const CSSPropertyID id, const Settings* settings)
+{
+    if (!settings)
+        return true;
+
+    switch (id) {
+EOF
+
+foreach my $name (keys %settingsFlags) {
+  print GPERF "    case CSSPropertyID::CSSProperty" . $nameToId{$name} . ":\n";
+  print GPERF "        return settings->" . $settingsFlags{$name} . "Enabled();\n";
+}
+
+print GPERF << "EOF";
+    default:
+        return true;
+    }
+    return true;
+}
+
 const char* getPropertyName(CSSPropertyID id)
 {
     if (id < firstCSSProperty)
@@ -522,6 +546,8 @@
 
 namespace WebCore {
 
+class Settings;
+
 enum CSSPropertyID : uint16_t {
     CSSPropertyInvalid = 0,
     CSSPropertyCustom = 1,
@@ -576,6 +602,7 @@
 
 bool isInternalCSSProperty(const CSSPropertyID);
 bool isEnabledCSSProperty(const CSSPropertyID);
+bool isCSSPropertyEnabledBySettings(const CSSPropertyID, const Settings* = nullptr);
 const char* getPropertyName(CSSPropertyID);
 const WTF::AtomString& getPropertyNameAtomString(CSSPropertyID id);
 WTF::String getPropertyNameString(CSSPropertyID id);

Modified: trunk/Source/WebCore/css/parser/CSSPropertyParser.cpp (260490 => 260491)


--- trunk/Source/WebCore/css/parser/CSSPropertyParser.cpp	2020-04-22 02:54:28 UTC (rev 260490)
+++ trunk/Source/WebCore/css/parser/CSSPropertyParser.cpp	2020-04-22 03:03:43 UTC (rev 260491)
@@ -143,6 +143,7 @@
     const Property* hashTableEntry = findProperty(name, length);
     if (hashTableEntry) {
         auto propertyID = static_cast<CSSPropertyID>(hashTableEntry->id);
+        // FIXME: Should take account for flags in settings().
         if (isEnabledCSSProperty(propertyID))
             return propertyID;
     }

Modified: trunk/Source/WebCore/inspector/InspectorStyleSheet.cpp (260490 => 260491)


--- trunk/Source/WebCore/inspector/InspectorStyleSheet.cpp	2020-04-22 02:54:28 UTC (rev 260490)
+++ trunk/Source/WebCore/inspector/InspectorStyleSheet.cpp	2020-04-22 03:03:43 UTC (rev 260491)
@@ -604,6 +604,7 @@
     if (includeAll) {
         for (auto i = firstCSSProperty; i < lastCSSProperty; ++i) {
             auto id = convertToCSSPropertyID(i);
+            // FIXME: Should take account for flags in settings().
             if (isInternalCSSProperty(id) || !isEnabledCSSProperty(id))
                 continue;
 

Modified: trunk/Source/WebCore/inspector/agents/InspectorCSSAgent.cpp (260490 => 260491)


--- trunk/Source/WebCore/inspector/agents/InspectorCSSAgent.cpp	2020-04-22 02:54:28 UTC (rev 260490)
+++ trunk/Source/WebCore/inspector/agents/InspectorCSSAgent.cpp	2020-04-22 03:03:43 UTC (rev 260491)
@@ -780,6 +780,7 @@
     auto properties = JSON::ArrayOf<Inspector::Protocol::CSS::CSSPropertyInfo>::create();
     for (int i = firstCSSProperty; i <= lastCSSProperty; ++i) {
         CSSPropertyID propertyID = convertToCSSPropertyID(i);
+        // FIXME: Should take account for flags in settings().
         if (isInternalCSSProperty(propertyID) || !isEnabledCSSProperty(propertyID))
             continue;
 

Modified: trunk/Source/WebKitLegacy/win/WebPreferenceKeysPrivate.h (260490 => 260491)


--- trunk/Source/WebKitLegacy/win/WebPreferenceKeysPrivate.h	2020-04-22 02:54:28 UTC (rev 260490)
+++ trunk/Source/WebKitLegacy/win/WebPreferenceKeysPrivate.h	2020-04-22 03:03:43 UTC (rev 260491)
@@ -214,6 +214,7 @@
 #define WebKitServerTimingEnabledPreferenceKey "WebKitServerTimingEnabled"
 
 #define WebKitCSSOMViewScrollingAPIEnabledPreferenceKey "WebKitCSSOMViewScrollingAPIEnabled"
+
 #define WebKitCSSOMViewSmoothScrollingEnabledPreferenceKey "WebKitCSSOMViewSmoothScrollingEnabled"
 
 #define WebKitResizeObserverEnabledPreferenceKey "WebKitResizeObserverEnabled"

Modified: trunk/Tools/ChangeLog (260490 => 260491)


--- trunk/Tools/ChangeLog	2020-04-22 02:54:28 UTC (rev 260490)
+++ trunk/Tools/ChangeLog	2020-04-22 03:03:43 UTC (rev 260491)
@@ -1,3 +1,18 @@
+2020-04-21  Cathie Chen  <cathiec...@igalia.com>
+
+        REGRESSION (r254790): No longer get smooth scrolling on music.apple.com
+        https://bugs.webkit.org/show_bug.cgi?id=210634
+
+        Reviewed by Darin Adler.
+
+        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):
+
 2020-04-21  Peng Liu  <peng.l...@apple.com>
 
         Fix MACCATALYST build failures

Modified: trunk/Tools/DumpRenderTree/win/DumpRenderTree.cpp (260490 => 260491)


--- trunk/Tools/DumpRenderTree/win/DumpRenderTree.cpp	2020-04-22 02:54:28 UTC (rev 260490)
+++ trunk/Tools/DumpRenderTree/win/DumpRenderTree.cpp	2020-04-22 03:03:43 UTC (rev 260491)
@@ -803,6 +803,7 @@
     prefsPrivate->setAspectRatioOfImgFromWidthAndHeightEnabled(TRUE);
     // FIXME: WebGL2
     // FIXME: WebRTC
+    prefsPrivate->setCSSOMViewSmoothScrollingEnabled(TRUE);
 }
 
 static void resetWebPreferencesToConsistentValues(IWebPreferences* preferences)
@@ -921,6 +922,7 @@
     prefsPrivate->setAllowTopNavigationToDataURLs(options.allowTopNavigationToDataURLs);
     preferences->setPrivateBrowsingEnabled(options.useEphemeralSession);
     preferences->setUsesPageCache(options.enableBackForwardCache);
+    prefsPrivate->setCSSOMViewSmoothScrollingEnabled(options.enableCSSOMViewSmoothScrolling);
 }
 
 static String applicationId()

Modified: trunk/Tools/Scripts/webkitpy/style/checkers/jsonchecker.py (260490 => 260491)


--- trunk/Tools/Scripts/webkitpy/style/checkers/jsonchecker.py	2020-04-22 02:54:28 UTC (rev 260490)
+++ trunk/Tools/Scripts/webkitpy/style/checkers/jsonchecker.py	2020-04-22 03:03:43 UTC (rev 260491)
@@ -290,6 +290,7 @@
             'related-property': self.validate_string,
             'runtime-flag': self.validate_string,
             'setter': self.validate_string,
+            'settings-flag': self.validate_string,
             'skip-builder': self.validate_boolean,
             'skip-codegen': self.validate_boolean,
             'svg': self.validate_boolean,
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to