Disable input-security CSS property
https://bugs.webkit.org/show_bug.cgi?id=235557
rdar://87984277

Reviewed by Dean Jackson.

Source/WebCore:

CSSWG is planning to remove input-security from CSS UI 4
(https://github.com/w3c/csswg-drafts/issues/6788).

Keep the property around as an experimental feature, so that
it can be used in the UA stylesheet, and easily turned on if the
resolution is not finalized.

* css/CSSComputedStyleDeclaration.cpp:
(WebCore::ComputedStyleExtractor::valueForPropertyInStyle):
* css/CSSProperties.json:
* css/parser/CSSParserContext.cpp:
(WebCore::CSSParserContext::CSSParserContext):

Enable input-security when parsing the UA stylesheet, as it is used to
obscure text in password inputs.

(WebCore::operator==):
(WebCore::add):
(WebCore::CSSParserContext::isPropertyRuntimeDisabled const):
* css/parser/CSSParserContext.h:
* css/parser/CSSParserFastPaths.cpp:
(WebCore::CSSParserFastPaths::isValidKeywordPropertyAndValue):

Source/WebKitLegacy/win:

Add support for tests enabling the CSSInputSecurityEnabled preference.

* WebPreferences.cpp:
(WebPreferences::cssInputSecurityEnabled):
* WebPreferences.h:
* WebView.cpp:
(WebView::notifyPreferencesChanged):

Source/WTF:

* Scripts/Preferences/WebPreferencesExperimental.yaml:

Make input-security a disabled-by-default experimental feature.

Tools:

* DumpRenderTree/TestOptions.cpp:
(WTR::TestOptions::defaults):

Add default for WebKitLegacy on Windows.

LayoutTests:

* fast/css/computed-text-security-for-input-security.html:


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@288590 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog
index 786eed7..421d3ab 100644
--- a/LayoutTests/ChangeLog
+++ b/LayoutTests/ChangeLog
@@ -1,3 +1,13 @@
+2022-01-25  Aditya Keerthi  <akeerthi@apple.com>
+
+        Disable input-security CSS property
+        https://bugs.webkit.org/show_bug.cgi?id=235557
+        rdar://87984277
+
+        Reviewed by Dean Jackson.
+
+        * fast/css/computed-text-security-for-input-security.html:
+
 2022-01-25  Myles C. Maxfield  <mmaxfield@apple.com>
 
         Add another test for locale-specific shaping
diff --git a/LayoutTests/fast/css/computed-text-security-for-input-security.html b/LayoutTests/fast/css/computed-text-security-for-input-security.html
index 9d7b7aa..bf78778 100644
--- a/LayoutTests/fast/css/computed-text-security-for-input-security.html
+++ b/LayoutTests/fast/css/computed-text-security-for-input-security.html
@@ -1,4 +1,4 @@
-<!DOCTYPE html>
+<!DOCTYPE html><!-- webkit-test-runner [ CSSInputSecurityEnabled=true ] -->
 <html>
 <head>
     <script src="../../resources/js-test.js"></script>
diff --git a/Source/WTF/ChangeLog b/Source/WTF/ChangeLog
index b0606b5..d2796067 100644
--- a/Source/WTF/ChangeLog
+++ b/Source/WTF/ChangeLog
@@ -1,3 +1,15 @@
+2022-01-25  Aditya Keerthi  <akeerthi@apple.com>
+
+        Disable input-security CSS property
+        https://bugs.webkit.org/show_bug.cgi?id=235557
+        rdar://87984277
+
+        Reviewed by Dean Jackson.
+
+        * Scripts/Preferences/WebPreferencesExperimental.yaml:
+
+        Make input-security a disabled-by-default experimental feature.
+
 2022-01-25  Adrian Perez de Castro  <aperez@igalia.com>
 
         [WTF] Make CRASH_WITH_INFO more useful when using GCC
diff --git a/Source/WTF/Scripts/Preferences/WebPreferencesExperimental.yaml b/Source/WTF/Scripts/Preferences/WebPreferencesExperimental.yaml
index 5cd7216..ba1e176 100644
--- a/Source/WTF/Scripts/Preferences/WebPreferencesExperimental.yaml
+++ b/Source/WTF/Scripts/Preferences/WebPreferencesExperimental.yaml
@@ -321,6 +321,18 @@
     WebCore:
       default: true
 
+CSSInputSecurityEnabled:
+  type: bool
+  humanReadableName: "CSS Input Security"
+  humanReadableDescription: "Enable input-security CSS property"
+  defaultValue:
+    WebKitLegacy:
+      default: false
+    WebKit:
+      default: false
+    WebCore:
+      default: false
+
 CSSMotionPathEnabled:
   type: bool
   humanReadableName: "CSS Motion Path"
diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog
index f07d6ca..8dd6ab1 100644
--- a/Source/WebCore/ChangeLog
+++ b/Source/WebCore/ChangeLog
@@ -1,3 +1,34 @@
+2022-01-25  Aditya Keerthi  <akeerthi@apple.com>
+
+        Disable input-security CSS property
+        https://bugs.webkit.org/show_bug.cgi?id=235557
+        rdar://87984277
+
+        Reviewed by Dean Jackson.
+
+        CSSWG is planning to remove input-security from CSS UI 4
+        (https://github.com/w3c/csswg-drafts/issues/6788).
+
+        Keep the property around as an experimental feature, so that
+        it can be used in the UA stylesheet, and easily turned on if the
+        resolution is not finalized.
+
+        * css/CSSComputedStyleDeclaration.cpp:
+        (WebCore::ComputedStyleExtractor::valueForPropertyInStyle):
+        * css/CSSProperties.json:
+        * css/parser/CSSParserContext.cpp:
+        (WebCore::CSSParserContext::CSSParserContext):
+
+        Enable input-security when parsing the UA stylesheet, as it is used to
+        obscure text in password inputs.
+
+        (WebCore::operator==):
+        (WebCore::add):
+        (WebCore::CSSParserContext::isPropertyRuntimeDisabled const):
+        * css/parser/CSSParserContext.h:
+        * css/parser/CSSParserFastPaths.cpp:
+        (WebCore::CSSParserFastPaths::isValidKeywordPropertyAndValue):
+
 2022-01-25  Alexey Shvayka  <ashvayka@apple.com>
 
         XPath::Step::nodesInAxis(): add null checks after Attr::ownerElement() calls
diff --git a/Source/WebCore/css/CSSComputedStyleDeclaration.cpp b/Source/WebCore/css/CSSComputedStyleDeclaration.cpp
index 3354294..692d846 100644
--- a/Source/WebCore/css/CSSComputedStyleDeclaration.cpp
+++ b/Source/WebCore/css/CSSComputedStyleDeclaration.cpp
@@ -3231,6 +3231,8 @@
             return cssValuePool.createValue(style.imageResolution(), CSSUnitType::CSS_DPPX);
 #endif
         case CSSPropertyInputSecurity:
+            if (!m_element->document().settings().cssInputSecurityEnabled())
+                return nullptr;
             return cssValuePool.createValue(style.inputSecurity());
         case CSSPropertyLeft:
             return positionOffsetValue(style, CSSPropertyLeft, renderer);
diff --git a/Source/WebCore/css/CSSProperties.json b/Source/WebCore/css/CSSProperties.json
index 8d6e345..26f3c3f 100644
--- a/Source/WebCore/css/CSSProperties.json
+++ b/Source/WebCore/css/CSSProperties.json
@@ -2843,6 +2843,9 @@
             }
         },
         "input-security": {
+            "codegen-properties": {
+                "settings-flag": "cssInputSecurityEnabled"
+            },
             "values": [
                 "auto",
                 "none"
diff --git a/Source/WebCore/css/parser/CSSParserContext.cpp b/Source/WebCore/css/parser/CSSParserContext.cpp
index 731b2d8..55d36bb5 100644
--- a/Source/WebCore/css/parser/CSSParserContext.cpp
+++ b/Source/WebCore/css/parser/CSSParserContext.cpp
@@ -50,6 +50,7 @@
     if (mode == UASheetMode) {
         individualTransformPropertiesEnabled = true;
         focusVisibleEnabled = true;
+        inputSecurityEnabled = true;
 #if ENABLE(CSS_TRANSFORM_STYLE_OPTIMIZED_3D)
         transformStyleOptimized3DEnabled = true;
 #endif
@@ -109,6 +110,7 @@
     , overflowClipEnabled { document.settings().overflowClipEnabled() }
     , gradientPremultipliedAlphaInterpolationEnabled { document.settings().cssGradientPremultipliedAlphaInterpolationEnabled() }
     , gradientInterpolationColorSpacesEnabled { document.settings().cssGradientInterpolationColorSpacesEnabled() }
+    , inputSecurityEnabled { document.settings().cssInputSecurityEnabled() }
 #if ENABLE(ATTACHMENT_ELEMENT)
     , attachmentEnabled { RuntimeEnabledFeatures::sharedFeatures().attachmentElementEnabled() }
 #endif
@@ -158,6 +160,7 @@
         && a.overflowClipEnabled == b.overflowClipEnabled
         && a.gradientPremultipliedAlphaInterpolationEnabled == b.gradientPremultipliedAlphaInterpolationEnabled
         && a.gradientInterpolationColorSpacesEnabled == b.gradientInterpolationColorSpacesEnabled
+        && a.inputSecurityEnabled == b.inputSecurityEnabled
 #if ENABLE(ATTACHMENT_ELEMENT)
         && a.attachmentEnabled == b.attachmentEnabled
 #endif
@@ -204,7 +207,8 @@
         | context.attachmentEnabled                         << 28
 #endif
         | context.accentColorEnabled                        << 29
-        | context.mode                                      << 30; // This is multiple bits, so keep it last.
+        | context.inputSecurityEnabled                      << 30
+        | context.mode                                      << 31; // This is multiple bits, so keep it last.
     add(hasher, context.baseURL, context.charset, bits);
 }
 
@@ -229,6 +233,8 @@
         return !containmentEnabled;
     case CSSPropertyAppleColorFilter:
         return !colorFilterEnabled;
+    case CSSPropertyInputSecurity:
+        return !inputSecurityEnabled;
     case CSSPropertyTranslate:
     case CSSPropertyRotate:
     case CSSPropertyScale:
diff --git a/Source/WebCore/css/parser/CSSParserContext.h b/Source/WebCore/css/parser/CSSParserContext.h
index 8c234df..d89b938 100644
--- a/Source/WebCore/css/parser/CSSParserContext.h
+++ b/Source/WebCore/css/parser/CSSParserContext.h
@@ -88,6 +88,7 @@
     bool overflowClipEnabled { false };
     bool gradientPremultipliedAlphaInterpolationEnabled { false };
     bool gradientInterpolationColorSpacesEnabled { false };
+    bool inputSecurityEnabled { false };
 
     // RuntimeEnabledFeatures.
 #if ENABLE(ATTACHMENT_ELEMENT)
diff --git a/Source/WebCore/css/parser/CSSParserFastPaths.cpp b/Source/WebCore/css/parser/CSSParserFastPaths.cpp
index fb6fe1a..1096f5c 100644
--- a/Source/WebCore/css/parser/CSSParserFastPaths.cpp
+++ b/Source/WebCore/css/parser/CSSParserFastPaths.cpp
@@ -648,6 +648,8 @@
     case CSSPropertyImageRendering: // auto | optimizeContrast | pixelated | optimizeSpeed | crispEdges | optimizeQuality | webkit-crispEdges
         return valueID == CSSValueAuto || valueID == CSSValueOptimizeSpeed || valueID == CSSValueOptimizeQuality || valueID == CSSValueWebkitCrispEdges || valueID == CSSValueWebkitOptimizeContrast || valueID == CSSValueCrispEdges || valueID == CSSValuePixelated;
     case CSSPropertyInputSecurity:
+        if (!context.inputSecurityEnabled)
+            return false;
         return valueID == CSSValueAuto || valueID == CSSValueNone;
 #if ENABLE(CSS_COMPOSITING)
     case CSSPropertyIsolation: // auto | isolate
diff --git a/Source/WebKitLegacy/win/ChangeLog b/Source/WebKitLegacy/win/ChangeLog
index aece14b..c326303 100644
--- a/Source/WebKitLegacy/win/ChangeLog
+++ b/Source/WebKitLegacy/win/ChangeLog
@@ -1,3 +1,19 @@
+2022-01-25  Aditya Keerthi  <akeerthi@apple.com>
+
+        Disable input-security CSS property
+        https://bugs.webkit.org/show_bug.cgi?id=235557
+        rdar://87984277
+
+        Reviewed by Dean Jackson.
+
+        Add support for tests enabling the CSSInputSecurityEnabled preference.
+
+        * WebPreferences.cpp:
+        (WebPreferences::cssInputSecurityEnabled):
+        * WebPreferences.h:
+        * WebView.cpp:
+        (WebView::notifyPreferencesChanged):
+
 2022-01-21  Fujii Hironori  <Hironori.Fujii@sony.com>
 
         Fix AppleWin build with newer MSVC
diff --git a/Source/WebKitLegacy/win/WebPreferences.cpp b/Source/WebKitLegacy/win/WebPreferences.cpp
index 50a3262..fd1a72e 100644
--- a/Source/WebKitLegacy/win/WebPreferences.cpp
+++ b/Source/WebKitLegacy/win/WebPreferences.cpp
@@ -2652,3 +2652,7 @@
     return boolValueForKey("WebKitMockScrollbarsControllerEnabled");
 }
 
+bool WebPreferences::cssInputSecurityEnabled()
+{
+    return boolValueForKey("WebKitCSSInputSecurityEnabled");
+}
diff --git a/Source/WebKitLegacy/win/WebPreferences.h b/Source/WebKitLegacy/win/WebPreferences.h
index 735af83..269c9d2 100644
--- a/Source/WebKitLegacy/win/WebPreferences.h
+++ b/Source/WebKitLegacy/win/WebPreferences.h
@@ -349,6 +349,7 @@
     bool cssGradientInterpolationColorSpacesEnabled();
     bool cssGradientPremultipliedAlphaInterpolationEnabled();
     bool mockScrollbarsControllerEnabled();
+    bool cssInputSecurityEnabled();
 
 private:
     WebPreferences();
diff --git a/Source/WebKitLegacy/win/WebView.cpp b/Source/WebKitLegacy/win/WebView.cpp
index fd53c64..37be949 100644
--- a/Source/WebKitLegacy/win/WebView.cpp
+++ b/Source/WebKitLegacy/win/WebView.cpp
@@ -5445,6 +5445,7 @@
     settings.setCSSGradientInterpolationColorSpacesEnabled(m_preferences->cssGradientInterpolationColorSpacesEnabled());
     settings.setCSSGradientPremultipliedAlphaInterpolationEnabled(m_preferences->cssGradientPremultipliedAlphaInterpolationEnabled());
     settings.setMockScrollbarsControllerEnabled(m_preferences->mockScrollbarsControllerEnabled());
+    settings.setCSSInputSecurityEnabled(m_preferences->cssInputSecurityEnabled());
 
     return S_OK;
 }
diff --git a/Tools/ChangeLog b/Tools/ChangeLog
index b54f392..f1108a7 100644
--- a/Tools/ChangeLog
+++ b/Tools/ChangeLog
@@ -1,3 +1,16 @@
+2022-01-25  Aditya Keerthi  <akeerthi@apple.com>
+
+        Disable input-security CSS property
+        https://bugs.webkit.org/show_bug.cgi?id=235557
+        rdar://87984277
+
+        Reviewed by Dean Jackson.
+
+        * DumpRenderTree/TestOptions.cpp:
+        (WTR::TestOptions::defaults):
+
+        Add default for WebKitLegacy on Windows.
+
 2022-01-25  Simon Fraser  <simon.fraser@apple.com>
 
         Fix the lldb Color formatter
diff --git a/Tools/DumpRenderTree/TestOptions.cpp b/Tools/DumpRenderTree/TestOptions.cpp
index e8c8dce..dff422a 100644
--- a/Tools/DumpRenderTree/TestOptions.cpp
+++ b/Tools/DumpRenderTree/TestOptions.cpp
@@ -137,6 +137,7 @@
             { "CSSCounterStyleAtRulesEnabled", false },
             { "CSSGradientInterpolationColorSpacesEnabled", true },
             { "CSSGradientPremultipliedAlphaInterpolationEnabled", true },
+            { "CSSInputSecurityEnabled", true },
             { "CSSLogicalEnabled", false },
             { "CSSOMViewSmoothScrollingEnabled", false },
             { "CanvasColorSpaceEnabled", true },