Title: [274520] trunk
Revision
274520
Author
simon.fra...@apple.com
Date
2021-03-16 14:40:24 -0700 (Tue, 16 Mar 2021)

Log Message

Runtime-disabled CSS features still still appear enabled via two-arg CSS.supports()
https://bugs.webkit.org/show_bug.cgi?id=223141

Reviewed by Antti Koivisto.

Source/WebCore:

Fix the CSS.supports(property, value) entrypoint to check for runtime-disabled
CSS properties.

Move isPropertyRuntimeDisabled() to CSSParserContext, and call it from the
appropriate DOMCSSNamespace::supports() entrypoint.

Tested by fast/css/overscroll-behavior-invalidate-if-disabled.html

* css/DOMCSSNamespace.cpp:
(WebCore::DOMCSSNamespace::supports):
* css/parser/CSSParserContext.cpp:
(WebCore::CSSParserContext::isPropertyRuntimeDisabled const):
* css/parser/CSSParserContext.h:
* css/parser/CSSParserImpl.cpp:
(WebCore::CSSParserImpl::consumeDeclaration):
(WebCore::CSSParserImpl::isPropertyRuntimeDisabled const): Deleted.
* css/parser/CSSParserImpl.h:

LayoutTests:

* fast/css/overscroll-behavior-invalidate-if-disabled-expected.txt:
* fast/css/overscroll-behavior-invalidate-if-disabled.html:

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (274519 => 274520)


--- trunk/LayoutTests/ChangeLog	2021-03-16 21:30:23 UTC (rev 274519)
+++ trunk/LayoutTests/ChangeLog	2021-03-16 21:40:24 UTC (rev 274520)
@@ -1,3 +1,13 @@
+2021-03-16  Simon Fraser  <simon.fra...@apple.com>
+
+        Runtime-disabled CSS features still still appear enabled via two-arg CSS.supports()
+        https://bugs.webkit.org/show_bug.cgi?id=223141
+
+        Reviewed by Antti Koivisto.
+
+        * fast/css/overscroll-behavior-invalidate-if-disabled-expected.txt:
+        * fast/css/overscroll-behavior-invalidate-if-disabled.html:
+
 2021-03-16  Kimmo Kinnunen  <kkinnu...@apple.com>
 
         Make WebGL conformance test update script more usable and consistent

Modified: trunk/LayoutTests/fast/css/overscroll-behavior-invalidate-if-disabled-expected.txt (274519 => 274520)


--- trunk/LayoutTests/fast/css/overscroll-behavior-invalidate-if-disabled-expected.txt	2021-03-16 21:30:23 UTC (rev 274519)
+++ trunk/LayoutTests/fast/css/overscroll-behavior-invalidate-if-disabled-expected.txt	2021-03-16 21:40:24 UTC (rev 274520)
@@ -7,6 +7,7 @@
 PASS 'overscroll-behavior' in getComputedStyle(document.documentElement) is false
 PASS CSS.supports('overscroll-behavior: contain') is false
 PASS CSS.supports('overscroll-behavior: inherit') is false
+PASS CSS.supports('overscroll-behavior', 'inherit') is false
 PASS CSS.supports('overscroll-behavior-x: inherit') is false
 PASS CSS.supports('overscroll-behavior-y: inherit') is false
 PASS successfullyParsed is true

Modified: trunk/LayoutTests/fast/css/overscroll-behavior-invalidate-if-disabled.html (274519 => 274520)


--- trunk/LayoutTests/fast/css/overscroll-behavior-invalidate-if-disabled.html	2021-03-16 21:30:23 UTC (rev 274519)
+++ trunk/LayoutTests/fast/css/overscroll-behavior-invalidate-if-disabled.html	2021-03-16 21:40:24 UTC (rev 274520)
@@ -12,6 +12,7 @@
 shouldBeFalse("'overscroll-behavior' in getComputedStyle(document.documentElement)");
 shouldBeFalse("CSS.supports('overscroll-behavior: contain')");
 shouldBeFalse("CSS.supports('overscroll-behavior: inherit')");
+shouldBeFalse("CSS.supports('overscroll-behavior', 'inherit')");
 shouldBeFalse("CSS.supports('overscroll-behavior-x: inherit')");
 shouldBeFalse("CSS.supports('overscroll-behavior-y: inherit')");
 

Modified: trunk/Source/WebCore/ChangeLog (274519 => 274520)


--- trunk/Source/WebCore/ChangeLog	2021-03-16 21:30:23 UTC (rev 274519)
+++ trunk/Source/WebCore/ChangeLog	2021-03-16 21:40:24 UTC (rev 274520)
@@ -1,3 +1,28 @@
+2021-03-16  Simon Fraser  <simon.fra...@apple.com>
+
+        Runtime-disabled CSS features still still appear enabled via two-arg CSS.supports()
+        https://bugs.webkit.org/show_bug.cgi?id=223141
+
+        Reviewed by Antti Koivisto.
+
+        Fix the CSS.supports(property, value) entrypoint to check for runtime-disabled
+        CSS properties.
+
+        Move isPropertyRuntimeDisabled() to CSSParserContext, and call it from the
+        appropriate DOMCSSNamespace::supports() entrypoint.
+
+        Tested by fast/css/overscroll-behavior-invalidate-if-disabled.html
+
+        * css/DOMCSSNamespace.cpp:
+        (WebCore::DOMCSSNamespace::supports):
+        * css/parser/CSSParserContext.cpp:
+        (WebCore::CSSParserContext::isPropertyRuntimeDisabled const):
+        * css/parser/CSSParserContext.h:
+        * css/parser/CSSParserImpl.cpp:
+        (WebCore::CSSParserImpl::consumeDeclaration):
+        (WebCore::CSSParserImpl::isPropertyRuntimeDisabled const): Deleted.
+        * css/parser/CSSParserImpl.h:
+
 2021-03-16  Lauro Moura  <lmo...@igalia.com>
 
         Unreviewed. Fix Nicosia build without CSS_SCROLL_SNAP after r274495.

Modified: trunk/Source/WebCore/css/DOMCSSNamespace.cpp (274519 => 274520)


--- trunk/Source/WebCore/css/DOMCSSNamespace.cpp	2021-03-16 21:30:23 UTC (rev 274519)
+++ trunk/Source/WebCore/css/DOMCSSNamespace.cpp	2021-03-16 21:40:24 UTC (rev 274520)
@@ -59,6 +59,10 @@
 {
     CSSPropertyID propertyID = cssPropertyID(property.stripWhiteSpace());
 
+    CSSParserContext parserContext(document);
+    if (parserContext.isPropertyRuntimeDisabled(propertyID))
+        return false;
+
     if (propertyID == CSSPropertyInvalid)
         return false;
 
@@ -72,7 +76,7 @@
         return false;
 
     auto dummyStyle = MutableStyleProperties::create();
-    return CSSParser::parseValue(dummyStyle, propertyID, normalizedValue, false, document) != CSSParser::ParseResult::Error;
+    return CSSParser::parseValue(dummyStyle, propertyID, normalizedValue, false, parserContext) != CSSParser::ParseResult::Error;
 }
 
 bool DOMCSSNamespace::supports(Document& document, const String& conditionText)

Modified: trunk/Source/WebCore/css/parser/CSSParserContext.cpp (274519 => 274520)


--- trunk/Source/WebCore/css/parser/CSSParserContext.cpp	2021-03-16 21:30:23 UTC (rev 274519)
+++ trunk/Source/WebCore/css/parser/CSSParserContext.cpp	2021-03-16 21:40:24 UTC (rev 274520)
@@ -135,6 +135,40 @@
     ;
 }
 
+bool CSSParserContext::isPropertyRuntimeDisabled(CSSPropertyID property) const
+{
+    switch (property) {
+    case CSSPropertyAspectRatio:
+        return !aspectRatioEnabled;
+    case CSSPropertyAppleColorFilter:
+        return !colorFilterEnabled;
+    case CSSPropertyTranslate:
+    case CSSPropertyRotate:
+    case CSSPropertyScale:
+        return !individualTransformPropertiesEnabled;
+    case CSSPropertyOverscrollBehavior:
+    case CSSPropertyOverscrollBehaviorX:
+    case CSSPropertyOverscrollBehaviorY:
+        return !overscrollBehaviorEnabled;
+    case CSSPropertyScrollBehavior:
+        return !scrollBehaviorEnabled;
+#if ENABLE(TEXT_AUTOSIZING)
+    case CSSPropertyWebkitTextSizeAdjust:
+#if !PLATFORM(IOS_FAMILY)
+        return !textAutosizingEnabled;
+#endif
+        return false;
+#endif // ENABLE(TEXT_AUTOSIZING)
+#if ENABLE(OVERFLOW_SCROLLING_TOUCH)
+    case CSSPropertyWebkitOverflowScrolling:
+        return !legacyOverflowScrollingTouchEnabled;
+#endif
+    default:
+        return false;
+    }
+    return false;
+}
+
 URL CSSParserContext::completeURL(const String& url) const
 {
     auto completedURL = [&] {

Modified: trunk/Source/WebCore/css/parser/CSSParserContext.h (274519 => 274520)


--- trunk/Source/WebCore/css/parser/CSSParserContext.h	2021-03-16 21:30:23 UTC (rev 274519)
+++ trunk/Source/WebCore/css/parser/CSSParserContext.h	2021-03-16 21:40:24 UTC (rev 274520)
@@ -26,6 +26,7 @@
 #pragma once
 
 #include "CSSParserMode.h"
+#include "CSSPropertyNames.h"
 #include "StyleRuleType.h"
 #include "TextEncoding.h"
 #include <wtf/HashFunctions.h>
@@ -56,6 +57,8 @@
     bool isContentOpaque { false };
     bool useSystemAppearance { false };
 
+    bool isPropertyRuntimeDisabled(CSSPropertyID) const;
+
     // Settings.
     bool aspectRatioEnabled { false };
     bool colorContrastEnabled { false };

Modified: trunk/Source/WebCore/css/parser/CSSParserImpl.cpp (274519 => 274520)


--- trunk/Source/WebCore/css/parser/CSSParserImpl.cpp	2021-03-16 21:30:23 UTC (rev 274519)
+++ trunk/Source/WebCore/css/parser/CSSParserImpl.cpp	2021-03-16 21:40:24 UTC (rev 274520)
@@ -773,40 +773,6 @@
     }
 }
 
-bool CSSParserImpl::isPropertyRuntimeDisabled(CSSPropertyID property) const
-{
-    switch (property) {
-    case CSSPropertyAspectRatio:
-        return !m_context.aspectRatioEnabled;
-    case CSSPropertyAppleColorFilter:
-        return !m_context.colorFilterEnabled;
-    case CSSPropertyTranslate:
-    case CSSPropertyRotate:
-    case CSSPropertyScale:
-        return !m_context.individualTransformPropertiesEnabled;
-    case CSSPropertyOverscrollBehavior:
-    case CSSPropertyOverscrollBehaviorX:
-    case CSSPropertyOverscrollBehaviorY:
-        return !m_context.overscrollBehaviorEnabled;
-    case CSSPropertyScrollBehavior:
-        return !m_context.scrollBehaviorEnabled;
-#if ENABLE(TEXT_AUTOSIZING)
-    case CSSPropertyWebkitTextSizeAdjust:
-#if !PLATFORM(IOS_FAMILY)
-        return !m_context.textAutosizingEnabled;
-#endif
-        return false;
-#endif // ENABLE(TEXT_AUTOSIZING)
-#if ENABLE(OVERFLOW_SCROLLING_TOUCH)
-    case CSSPropertyWebkitOverflowScrolling:
-        return !m_context.legacyOverflowScrollingTouchEnabled;
-#endif
-    default:
-        return false;
-    }
-    return false;
-}
-
 void CSSParserImpl::consumeDeclaration(CSSParserTokenRange range, StyleRuleType ruleType)
 {
     CSSParserTokenRange rangeCopy = range; // For inspector callbacks
@@ -817,7 +783,7 @@
     if (range.consume().type() != ColonToken)
         return; // Parse error
 
-    if (isPropertyRuntimeDisabled(propertyID))
+    if (m_context.isPropertyRuntimeDisabled(propertyID))
         propertyID = CSSPropertyInvalid;
 
     bool important = false;

Modified: trunk/Source/WebCore/css/parser/CSSParserImpl.h (274519 => 274520)


--- trunk/Source/WebCore/css/parser/CSSParserImpl.h	2021-03-16 21:30:23 UTC (rev 274519)
+++ trunk/Source/WebCore/css/parser/CSSParserImpl.h	2021-03-16 21:40:24 UTC (rev 274520)
@@ -143,8 +143,6 @@
     void consumeDeclaration(CSSParserTokenRange, StyleRuleType);
     void consumeDeclarationValue(CSSParserTokenRange, CSSPropertyID, bool important, StyleRuleType);
     void consumeCustomPropertyValue(CSSParserTokenRange, const AtomString& propertyName, bool important);
-    
-    bool isPropertyRuntimeDisabled(CSSPropertyID) const;
 
     static Vector<double> consumeKeyframeKeyList(CSSParserTokenRange);
 
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to