WebKit Bugzilla
Attachment 350009 Details for
Bug 189694
: Implement CSS Custom Properties and Values Skeleton
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch
bug-189694-20180918004912.patch (text/plain), 34.06 KB, created by
Justin Michaud
on 2018-09-18 00:49:13 PDT
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Justin Michaud
Created:
2018-09-18 00:49:13 PDT
Size:
34.06 KB
patch
obsolete
>Subversion Revision: 236020 >diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog >index 44a7cfcf98d4072db1ae378e0217196ecb48c13d..5e2910e85446176162a2c9fa79090b291fb82f5b 100644 >--- a/Source/WebCore/ChangeLog >+++ b/Source/WebCore/ChangeLog >@@ -1,3 +1,41 @@ >+2018-09-18 Justin Michaud <justin_michaud@apple.com> >+ >+ Implement CSS Custom Properties and Values Skeleton >+ https://bugs.webkit.org/show_bug.cgi?id=189694 >+ >+ Add feature flag, CSS.registerProperty binding and registered property set in Document.h >+ for the css custom properties and values api. >+ >+ Also add support for static methods with EnabledAtRuntime=... to the bindings code generator >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Test: css-properties-values-api/registerProperty.html >+ >+ * CMakeLists.txt: >+ * DerivedSources.make: >+ * Sources.txt: >+ * WebCore.xcodeproj/project.pbxproj: >+ * bindings/scripts/CodeGeneratorJS.pm: >+ (GeneratePropertiesHashTable): >+ (GenerateRuntimeEnableConditionalStringForExposed): >+ (GenerateRuntimeEnableConditionalString): >+ (GenerateConstructorHelperMethods): >+ * css/CSSRegisteredProperty.h: Copied from Source/WebCore/css/DOMCSSNamespace.idl. >+ * css/DOMCSSNamespace.cpp: >+ (WebCore::DOMCSSNamespace::registerProperty): >+ * css/DOMCSSNamespace.h: >+ * css/DOMCSSNamespace.idl: >+ * css/DOMCSSPropertyDescriptor.h: Copied from Source/WebCore/css/DOMCSSNamespace.idl. >+ * css/DOMCSSPropertyDescriptor.idl: Added. >+ * dom/Document.cpp: >+ (WebCore::Document::registerCSSProperty): >+ * dom/Document.h: >+ (WebCore::Document::getCSSProperty const): >+ * page/RuntimeEnabledFeatures.h: >+ (WebCore::RuntimeEnabledFeatures::setCSSCustomPropertiesAndValuesEnabled): >+ (WebCore::RuntimeEnabledFeatures::cssCustomPropertiesAndValuesEnabled const): >+ > 2018-09-14 Ryan Haddad <ryanhaddad@apple.com> > > Unreviewed, attempt to fix the iOSMac build after r236015. >diff --git a/Source/WebKit/ChangeLog b/Source/WebKit/ChangeLog >index fceb8d877cf670eaa78b47d1b192494dc390fd1f..12db170c7e694af3abfae6625e2620b6d17b6f37 100644 >--- a/Source/WebKit/ChangeLog >+++ b/Source/WebKit/ChangeLog >@@ -1,3 +1,16 @@ >+2018-09-18 Justin Michaud <justin_michaud@apple.com> >+ >+ Implement CSS Custom Properties and Values Skeleton >+ https://bugs.webkit.org/show_bug.cgi?id=189694 >+ >+ Add feature flag for CSS custom properties and values api >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ * Shared/WebPreferences.yaml: >+ * WebProcess/InjectedBundle/InjectedBundle.cpp: >+ (WebKit::InjectedBundle::overrideBoolPreferenceForTestRunner): >+ > 2018-09-14 Alex Christensen <achristensen@webkit.org> > > Refactoring related to Safe Browsing >diff --git a/Source/WebCore/CMakeLists.txt b/Source/WebCore/CMakeLists.txt >index 29cef4ab89639588061cc3e7bc82bb59b4603389..814ea5f4200add00b9b023df43b97a8c69968255 100644 >--- a/Source/WebCore/CMakeLists.txt >+++ b/Source/WebCore/CMakeLists.txt >@@ -523,6 +523,7 @@ set(WebCore_NON_SVG_IDL_FILES > css/CSSStyleSheet.idl > css/CSSSupportsRule.idl > css/CSSUnknownRule.idl >+ css/DOMCSSPropertyDescriptor.idl > css/DOMMatrix.idl > css/DOMMatrix2DInit.idl > css/DOMMatrixInit.idl >diff --git a/Source/WebCore/DerivedSources.make b/Source/WebCore/DerivedSources.make >index e6a427de4ed40b9192e4038b41a11046c52fe5d2..a982bf698cb286ae05f657dc7cb9a4a8dbcf78bd 100644 >--- a/Source/WebCore/DerivedSources.make >+++ b/Source/WebCore/DerivedSources.make >@@ -439,6 +439,7 @@ JS_BINDING_IDLS = \ > $(WebCore)/css/CSSStyleSheet.idl \ > $(WebCore)/css/CSSSupportsRule.idl \ > $(WebCore)/css/CSSUnknownRule.idl \ >+ $(WebCore)/css/DOMCSSPropertyDescriptor.idl \ > $(WebCore)/css/DOMMatrix.idl \ > $(WebCore)/css/DOMMatrix2DInit.idl \ > $(WebCore)/css/DOMMatrixInit.idl \ >diff --git a/Source/WebCore/Sources.txt b/Source/WebCore/Sources.txt >index 789006d9ce0dd0ecde606ba3ad3af101aa92dca6..c606600bfbdfa71693654628f59f0cbd4eedf08d 100644 >--- a/Source/WebCore/Sources.txt >+++ b/Source/WebCore/Sources.txt >@@ -2512,6 +2512,7 @@ JSDocumentTimeline.cpp > JSDocumentTimelineOptions.cpp > JSDOMApplicationCache.cpp > JSDOMCSSNamespace.cpp >+JSDOMCSSPropertyDescriptor.cpp > JSDOMCache.cpp > JSDOMCacheStorage.cpp > JSDOMException.cpp >diff --git a/Source/WebCore/WebCore.xcodeproj/project.pbxproj b/Source/WebCore/WebCore.xcodeproj/project.pbxproj >index 684644f7aff7a45b7ace085498a6ebb4867ce1b2..f980ba604e0061a8a5fdbffb7b0b4a8e5ebc5c44 100644 >--- a/Source/WebCore/WebCore.xcodeproj/project.pbxproj >+++ b/Source/WebCore/WebCore.xcodeproj/project.pbxproj >@@ -1342,8 +1342,10 @@ > 4B2708C70AF19EE40065127F /* Pasteboard.h in Headers */ = {isa = PBXBuildFile; fileRef = 4B2708C50AF19EE40065127F /* Pasteboard.h */; settings = {ATTRIBUTES = (Private, ); }; }; > 4B3043CD0AE0373B00A82647 /* Editor.h in Headers */ = {isa = PBXBuildFile; fileRef = 4B3043CB0AE0373B00A82647 /* Editor.h */; settings = {ATTRIBUTES = (Private, ); }; }; > 4B3480940EEF50D400AC1B41 /* ImageSourceCG.h in Headers */ = {isa = PBXBuildFile; fileRef = 4B3480920EEF50D400AC1B41 /* ImageSourceCG.h */; }; >+ 4B5141D421502A780064DCCB /* CSSRegisteredProperty.h in Headers */ = {isa = PBXBuildFile; fileRef = 4B5141D221502A730064DCCB /* CSSRegisteredProperty.h */; settings = {ATTRIBUTES = (Private, ); }; }; > 4B6FA6F40C39E48C00087011 /* SmartReplace.h in Headers */ = {isa = PBXBuildFile; fileRef = 4B6FA6F20C39E48C00087011 /* SmartReplace.h */; settings = {ATTRIBUTES = (Private, ); }; }; > 4BAE95B10B2FA9CE00AED8A0 /* EditorDeleteAction.h in Headers */ = {isa = PBXBuildFile; fileRef = 4BAE95B00B2FA9CE00AED8A0 /* EditorDeleteAction.h */; settings = {ATTRIBUTES = (Private, ); }; }; >+ 4BCCF57D2150229C008355EB /* DOMCSSPropertyDescriptor.h in Headers */ = {isa = PBXBuildFile; fileRef = 4BCCF57B214C87B2008355EB /* DOMCSSPropertyDescriptor.h */; }; > 4E1959220A39DABA00220FE5 /* MediaFeatureNames.h in Headers */ = {isa = PBXBuildFile; fileRef = 4E1959200A39DABA00220FE5 /* MediaFeatureNames.h */; settings = {ATTRIBUTES = (Private, ); }; }; > 4E19592A0A39DACC00220FE5 /* MediaQuery.h in Headers */ = {isa = PBXBuildFile; fileRef = 4E1959240A39DACC00220FE5 /* MediaQuery.h */; settings = {ATTRIBUTES = (Private, ); }; }; > 4E19592C0A39DACC00220FE5 /* MediaQueryEvaluator.h in Headers */ = {isa = PBXBuildFile; fileRef = 4E1959260A39DACC00220FE5 /* MediaQueryEvaluator.h */; settings = {ATTRIBUTES = (Private, ); }; }; >@@ -7830,9 +7832,12 @@ > 4B3043CB0AE0373B00A82647 /* Editor.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = Editor.h; sourceTree = "<group>"; }; > 4B3480910EEF50D400AC1B41 /* ImageSourceCGMac.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = ImageSourceCGMac.mm; sourceTree = "<group>"; }; > 4B3480920EEF50D400AC1B41 /* ImageSourceCG.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ImageSourceCG.h; sourceTree = "<group>"; }; >+ 4B5141D221502A730064DCCB /* CSSRegisteredProperty.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CSSRegisteredProperty.h; sourceTree = "<group>"; }; > 4B6FA6F20C39E48C00087011 /* SmartReplace.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SmartReplace.h; sourceTree = "<group>"; }; > 4B6FA6F60C39E4A100087011 /* SmartReplaceCF.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SmartReplaceCF.cpp; sourceTree = "<group>"; }; > 4BAE95B00B2FA9CE00AED8A0 /* EditorDeleteAction.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = EditorDeleteAction.h; sourceTree = "<group>"; }; >+ 4BCCF579214C86A3008355EB /* DOMCSSPropertyDescriptor.idl */ = {isa = PBXFileReference; lastKnownFileType = text; path = DOMCSSPropertyDescriptor.idl; sourceTree = "<group>"; }; >+ 4BCCF57B214C87B2008355EB /* DOMCSSPropertyDescriptor.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = DOMCSSPropertyDescriptor.h; sourceTree = "<group>"; }; > 4E19591F0A39DABA00220FE5 /* MediaFeatureNames.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = MediaFeatureNames.cpp; sourceTree = "<group>"; }; > 4E1959200A39DABA00220FE5 /* MediaFeatureNames.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = MediaFeatureNames.h; sourceTree = "<group>"; }; > 4E1959230A39DACC00220FE5 /* MediaQuery.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = MediaQuery.cpp; sourceTree = "<group>"; }; >@@ -25653,6 +25658,7 @@ > 9362640A0DE1137D009D5A00 /* CSSReflectionDirection.h */, > BC5A12DD0DC0414800C9AFAD /* CSSReflectValue.cpp */, > BC5A12DE0DC0414800C9AFAD /* CSSReflectValue.h */, >+ 4B5141D221502A730064DCCB /* CSSRegisteredProperty.h */, > BC7D8FF11BD1A47900FFE540 /* CSSRevertValue.cpp */, > BC7D8FF21BD1A47900FFE540 /* CSSRevertValue.h */, > A80E6CDC0A1989CA007FB8C5 /* CSSRule.cpp */, >@@ -25725,6 +25731,8 @@ > FD677735195CAB200072E0D3 /* DOMCSSNamespace.cpp */, > FC9A0F72164094CF003D6B8D /* DOMCSSNamespace.h */, > FC9A0F73164094CF003D6B8D /* DOMCSSNamespace.idl */, >+ 4BCCF57B214C87B2008355EB /* DOMCSSPropertyDescriptor.h */, >+ 4BCCF579214C86A3008355EB /* DOMCSSPropertyDescriptor.idl */, > 836ACEC41ECA6654004BD012 /* DOMMatrix.cpp */, > 836ACEC51ECA6654004BD012 /* DOMMatrix.h */, > 836ACEC61ECA6654004BD012 /* DOMMatrix.idl */, >@@ -27649,6 +27657,7 @@ > FE271F672082DBE500A952D4 /* CSSPtrTag.h in Headers */, > 9362640B0DE1137D009D5A00 /* CSSReflectionDirection.h in Headers */, > BC5A12E00DC0414800C9AFAD /* CSSReflectValue.h in Headers */, >+ 4B5141D421502A780064DCCB /* CSSRegisteredProperty.h in Headers */, > BC7D8FF41BD1A47900FFE540 /* CSSRevertValue.h in Headers */, > A80E6D0D0A1989CA007FB8C5 /* CSSRule.h in Headers */, > A80E6CF20A1989CA007FB8C5 /* CSSRuleList.h in Headers */, >@@ -27809,6 +27818,7 @@ > 41FABD2D1F4DFE4A006A6C97 /* DOMCacheEngine.h in Headers */, > 41380C291F3436AC00155FDA /* DOMCacheStorage.h in Headers */, > FC9A0F75164094CF003D6B8D /* DOMCSSNamespace.h in Headers */, >+ 4BCCF57D2150229C008355EB /* DOMCSSPropertyDescriptor.h in Headers */, > 7AABA25A14BC613300AA9A11 /* DOMEditor.h in Headers */, > BC60D6E90D28D83400B9918F /* DOMException.h in Headers */, > 8399470C1F50B63E00E9D86B /* DOMFileSystem.h in Headers */, >diff --git a/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm b/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm >index 7f4ac10c9e8af8bdc6dbc865cc7bbfe4a642f3dc..8a1eda5627462a4da3ca9ce6a931294fabb648ee 100644 >--- a/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm >+++ b/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm >@@ -3097,7 +3097,7 @@ sub GeneratePropertiesHashTable > push(@operations, @{$interface->serializable->operations}) if $interface->serializable; > foreach my $operation (@operations) { > next if ($operation->extendedAttributes->{PrivateIdentifier} and not $operation->extendedAttributes->{PublicIdentifier}); >- next if ($operation->isStatic); >+ #next if ($operation->isStatic); > next if $operation->{overloadIndex} && $operation->{overloadIndex} > 1; > next if OperationShouldBeOnInstance($interface, $operation) != $isInstance; > next if $operation->name eq "[Symbol.Iterator]"; >@@ -3641,7 +3641,7 @@ sub ToMethodName > > sub GenerateRuntimeEnableConditionalStringForExposed > { >- my ($interface, $context, $conjuncts) = @_; >+ my ($interface, $context, $conjuncts, $globalObjectIsParam) = @_; > > assert("Must specify value for Exposed.") if $context->extendedAttributes->{Exposed} eq "VALUE_IS_MISSING"; > >@@ -3656,9 +3656,9 @@ sub GenerateRuntimeEnableConditionalStringForExposed > } > > if ($exposed eq "Window") { >- push(@$conjuncts, "jsCast<JSDOMGlobalObject*>(globalObject())->scriptExecutionContext()->isDocument()"); >+ push(@$conjuncts, "jsCast<JSDOMGlobalObject*>(" . ($globalObjectIsParam? "&globalObject" : "globalObject()") . ")->scriptExecutionContext()->isDocument()"); > } elsif ($exposed eq "Worker") { >- push(@$conjuncts, "jsCast<JSDOMGlobalObject*>(globalObject())->scriptExecutionContext()->isWorkerGlobalScope()"); >+ push(@$conjuncts, "jsCast<JSDOMGlobalObject*>(" . ($globalObjectIsParam? "&globalObject" : "globalObject()") . ")->scriptExecutionContext()->isWorkerGlobalScope()"); > } else { > assert("Unrecognized value '" . Dumper($context->extendedAttributes->{Exposed}) . "' for the Exposed extended attribute on '" . ref($context) . "'."); > } >@@ -3671,7 +3671,7 @@ sub GenerateRuntimeEnableConditionalStringForExposed > # (e.g. IDLInterface, IDLAttribute, IDLOperation, IDLIterable, etc.) > sub GenerateRuntimeEnableConditionalString > { >- my ($interface, $context) = @_; >+ my ($interface, $context, $globalObjectIsParam) = @_; > > my @conjuncts; > >@@ -3679,20 +3679,20 @@ sub GenerateRuntimeEnableConditionalString > AddToImplIncludes("ScriptExecutionContext.h"); > > if ($context->extendedAttributes->{ContextHasServiceWorkerScheme}) { >- push(@conjuncts, "(jsCast<JSDOMGlobalObject*>(globalObject())->scriptExecutionContext()->isSecureContext() || jsCast<JSDOMGlobalObject*>(globalObject())->scriptExecutionContext()->hasServiceWorkerScheme())"); >+ push(@conjuncts, "(jsCast<JSDOMGlobalObject*>(" . ($globalObjectIsParam? "&globalObject" : "globalObject()") . ")->scriptExecutionContext()->isSecureContext() || jsCast<JSDOMGlobalObject*>(" . ($globalObjectIsParam? "&globalObject" : "globalObject()") . ")->scriptExecutionContext()->hasServiceWorkerScheme())"); > } else { >- push(@conjuncts, "jsCast<JSDOMGlobalObject*>(globalObject())->scriptExecutionContext()->isSecureContext()"); >+ push(@conjuncts, "jsCast<JSDOMGlobalObject*>(" . ($globalObjectIsParam? "&globalObject" : "globalObject()") . ")->scriptExecutionContext()->isSecureContext()"); > } > } else { > if ($context->extendedAttributes->{ContextHasServiceWorkerScheme}) { > AddToImplIncludes("ScriptExecutionContext.h"); > >- push(@conjuncts, "jsCast<JSDOMGlobalObject*>(globalObject())->scriptExecutionContext()->hasServiceWorkerScheme()"); >+ push(@conjuncts, "jsCast<JSDOMGlobalObject*>(" . ($globalObjectIsParam? "&globalObject" : "globalObject()") . ")->scriptExecutionContext()->hasServiceWorkerScheme()"); > } > } > > if ($context->extendedAttributes->{Exposed}) { >- GenerateRuntimeEnableConditionalStringForExposed($interface, $context, \@conjuncts); >+ GenerateRuntimeEnableConditionalStringForExposed($interface, $context, \@conjuncts, $globalObjectIsParam); > } > > if ($context->extendedAttributes->{EnabledForWorld}) { >@@ -3713,7 +3713,7 @@ sub GenerateRuntimeEnableConditionalString > > my @flags = split(/&/, $context->extendedAttributes->{EnabledBySetting}); > foreach my $flag (@flags) { >- push(@conjuncts, "downcast<Document>(jsCast<JSDOMGlobalObject*>(globalObject())->scriptExecutionContext())->settings()." . ToMethodName($flag) . "Enabled()"); >+ push(@conjuncts, "downcast<Document>(jsCast<JSDOMGlobalObject*>(" . ($globalObjectIsParam? "&globalObject" : "globalObject()") . ")->scriptExecutionContext())->settings()." . ToMethodName($flag) . "Enabled()"); > } > } > >@@ -7244,6 +7244,38 @@ sub GenerateConstructorHelperMethods > } > push(@$outputArray, " reifyStaticProperties(vm, ${classForThis}, ${className}ConstructorTableValues, *this);\n") if ConstructorHasProperties($interface); > >+ # These are only used to get runtime enabled operations >+ my @hashKeys = (); >+ my @hashValue1 = (); >+ my @hashValue2 = (); >+ my @hashSpecials = (); >+ my %conditionals = (); >+ my %readWriteConditionals = (); >+ my @runtimeEnabledOperations = (); >+ my @runtimeEnabledAttributes = (); >+ >+ # Generate hash table for properties on the prototype to get runtime enabled operations. >+ my $numPrototypeProperties = GeneratePropertiesHashTable($className, $interface, 0, >+ \@hashKeys, \@hashSpecials, >+ \@hashValue1, \@hashValue2, >+ \%conditionals, \%readWriteConditionals, >+ \@runtimeEnabledOperations, \@runtimeEnabledAttributes); >+ >+ my @runtimeEnabledProperties = @runtimeEnabledOperations; >+ push(@runtimeEnabledProperties, @runtimeEnabledAttributes); >+ foreach my $operationOrAttribute (@runtimeEnabledProperties) { >+ my $conditionalString = $codeGenerator->GenerateConditionalString($operationOrAttribute); >+ push($outputArray, "#if ${conditionalString}\n") if $conditionalString; >+ my $runtimeEnableConditionalString = GenerateRuntimeEnableConditionalString($interface, $operationOrAttribute, "use global. instead of global()"); >+ my $name = $operationOrAttribute->name; >+ push(@$outputArray, " if (!${runtimeEnableConditionalString}) {\n"); >+ push(@$outputArray, " auto propertyName = Identifier::fromString(&vm, reinterpret_cast<const LChar*>(\"$name\"), strlen(\"$name\"));\n"); >+ push(@$outputArray, " VM::DeletePropertyModeScope scope(vm, VM::DeletePropertyMode::IgnoreConfigurable);\n"); >+ push(@$outputArray, " JSObject::deleteProperty(this, globalObject.globalExec(), propertyName);\n"); >+ push(@$outputArray, " }\n"); >+ push(@$outputArray, "#endif\n") if $conditionalString; >+ } >+ > push(@$outputArray, "}\n\n"); > > if (IsJSBuiltinConstructor($interface)) { >diff --git a/Source/WebCore/css/CSSRegisteredProperty.h b/Source/WebCore/css/CSSRegisteredProperty.h >new file mode 100644 >index 0000000000000000000000000000000000000000..e39fde8ddf9ff8fa91056d265a70ac0b0aed722f >--- /dev/null >+++ b/Source/WebCore/css/CSSRegisteredProperty.h >@@ -0,0 +1,41 @@ >+/* >+ * Copyright (C) 2018 Apple Inc. All rights reserved. >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions are >+ * met: >+ * >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. Redistributions in binary form must reproduce the above >+ * copyright notice, this list of conditions and the following disclaimer in >+ * the documentation and/or other materials provided with the distribution. >+ * 3. Neither the name of Motorola Mobility Inc. nor the names of its >+ * contributors may be used to endorse or promote products derived from this >+ * software without specific prior written permission. >+ * >+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS >+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT >+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR >+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT >+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, >+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT >+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, >+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY >+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT >+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE >+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. >+ */ >+ >+#pragma once >+ >+#include <wtf/text/WTFString.h> >+ >+namespace WebCore { >+ >+struct CSSRegisteredProperty { >+ String name; >+ /* TODO syntax, inherits, initialValue */ >+}; >+ >+} >diff --git a/Source/WebCore/css/DOMCSSNamespace.cpp b/Source/WebCore/css/DOMCSSNamespace.cpp >index 913523776965942f2f508623f65670a8a0aae0c0..d6f26c6aa59541db2d3cbb217011d7cd504abcaa 100644 >--- a/Source/WebCore/css/DOMCSSNamespace.cpp >+++ b/Source/WebCore/css/DOMCSSNamespace.cpp >@@ -33,6 +33,8 @@ > #include "CSSMarkup.h" > #include "CSSParser.h" > #include "CSSPropertyParser.h" >+#include "CSSRegisteredProperty.h" >+#include "Document.h" > #include "StyleProperties.h" > #include <wtf/text/StringBuilder.h> > #include <wtf/text/WTFString.h> >@@ -87,4 +89,10 @@ String DOMCSSNamespace::escape(const String& ident) > return builder.toString(); > } > >+void DOMCSSNamespace::registerProperty(Document& document, const DOMCSSPropertyDescriptor& descriptor) >+{ >+ CSSRegisteredProperty property { descriptor.name }; >+ document.registerCSSProperty(property); >+} >+ > } >diff --git a/Source/WebCore/css/DOMCSSNamespace.h b/Source/WebCore/css/DOMCSSNamespace.h >index 3b2e3870d25f811018c426ce6f80435e93db01ac..d3a8f38907071e27858881eb7671cb6b84d6804b 100644 >--- a/Source/WebCore/css/DOMCSSNamespace.h >+++ b/Source/WebCore/css/DOMCSSNamespace.h >@@ -29,6 +29,8 @@ > > #pragma once > >+#include "DOMCSSPropertyDescriptor.h" >+ > #include <wtf/Forward.h> > #include <wtf/RefCounted.h> > >@@ -41,6 +43,7 @@ public: > static bool supports(Document&, const String& property, const String& value); > static bool supports(Document&, const String& conditionText); > static String escape(const String& ident); >+ static void registerProperty(Document&, const DOMCSSPropertyDescriptor&); > }; > > } >diff --git a/Source/WebCore/css/DOMCSSNamespace.idl b/Source/WebCore/css/DOMCSSNamespace.idl >index 1f2d371f267114d18cfcb2c0db90bd971cdd16c1..c7ae7b5b4958d049def2e3dab2963b20d85a8bef 100644 >--- a/Source/WebCore/css/DOMCSSNamespace.idl >+++ b/Source/WebCore/css/DOMCSSNamespace.idl >@@ -34,4 +34,5 @@ > [CallWith=Document] static boolean supports(DOMString property, DOMString value); > [CallWith=Document] static boolean supports(DOMString conditionText); > static DOMString escape(DOMString ident); >+ [CallWith=Document,EnabledAtRuntime=CSSCustomPropertiesAndValues] static void registerProperty(DOMCSSPropertyDescriptor descriptor); > }; >diff --git a/Source/WebCore/css/DOMCSSPropertyDescriptor.h b/Source/WebCore/css/DOMCSSPropertyDescriptor.h >new file mode 100644 >index 0000000000000000000000000000000000000000..0189554cdca0e44eb474097a0144e3bec8356137 >--- /dev/null >+++ b/Source/WebCore/css/DOMCSSPropertyDescriptor.h >@@ -0,0 +1,41 @@ >+/* >+ * Copyright (C) 2018 Apple Inc. All rights reserved. >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions are >+ * met: >+ * >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. Redistributions in binary form must reproduce the above >+ * copyright notice, this list of conditions and the following disclaimer in >+ * the documentation and/or other materials provided with the distribution. >+ * 3. Neither the name of Motorola Mobility Inc. nor the names of its >+ * contributors may be used to endorse or promote products derived from this >+ * software without specific prior written permission. >+ * >+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS >+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT >+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR >+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT >+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, >+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT >+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, >+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY >+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT >+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE >+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. >+ */ >+ >+#pragma once >+ >+namespace WebCore { >+ >+struct DOMCSSPropertyDescriptor { >+ String name; >+ String syntax { "*" }; >+ bool inherits; >+ String initialValue; >+}; >+ >+} >diff --git a/Source/WebCore/css/DOMCSSPropertyDescriptor.idl b/Source/WebCore/css/DOMCSSPropertyDescriptor.idl >new file mode 100644 >index 0000000000000000000000000000000000000000..d88f907e03efaf74ed697ea5b43b88abdd4debf7 >--- /dev/null >+++ b/Source/WebCore/css/DOMCSSPropertyDescriptor.idl >@@ -0,0 +1,38 @@ >+/* >+* Copyright (C) 2018 Apple Inc. All rights reserved. >+* >+* Redistribution and use in source and binary forms, with or without >+* modification, are permitted provided that the following conditions are >+* met: >+* >+* 1. Redistributions of source code must retain the above copyright >+* notice, this list of conditions and the following disclaimer. >+* 2. Redistributions in binary form must reproduce the above >+* copyright notice, this list of conditions and the following disclaimer in >+* the documentation and/or other materials provided with the distribution. >+* 3. Neither the name of Motorola Mobility Inc. nor the names of its >+* contributors may be used to endorse or promote products derived from this >+* software without specific prior written permission. >+* >+* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS >+* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT >+* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR >+* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT >+* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, >+* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT >+* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, >+* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY >+* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT >+* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE >+* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. >+*/ >+ >+[ >+ JSGenerateToJSObject, >+ EnabledAtRuntime=CSSCustomPropertiesAndValues >+] dictionary DOMCSSPropertyDescriptor { >+ required DOMString name; >+ DOMString syntax = "*"; >+ required boolean inherits; >+ DOMString initialValue; >+}; >diff --git a/Source/WebCore/dom/Document.cpp b/Source/WebCore/dom/Document.cpp >index 51f660e21666cb72cb9914aad9385da2d9afbc61..228d55fa5ceaa9ea8b60497def3b8942d712beec 100644 >--- a/Source/WebCore/dom/Document.cpp >+++ b/Source/WebCore/dom/Document.cpp >@@ -8216,4 +8216,12 @@ String Document::signedPublicKeyAndChallengeString(unsigned keySizeIndex, const > return page->chrome().client().signedPublicKeyAndChallengeString(keySizeIndex, challengeString, url); > } > >+bool Document::registerCSSProperty(const CSSRegisteredProperty& prop) >+{ >+ if (m_CSSRegisteredPropertySet.contains(prop.name)) >+ return false; >+ m_CSSRegisteredPropertySet.add(prop.name, prop); >+ return true; >+} >+ > } // namespace WebCore >diff --git a/Source/WebCore/dom/Document.h b/Source/WebCore/dom/Document.h >index cd1a9630fc494d1c44423e238d8ebe687dacf15a..05c0080c228657f994e43ac00133f7efb92ad17c 100644 >--- a/Source/WebCore/dom/Document.h >+++ b/Source/WebCore/dom/Document.h >@@ -27,6 +27,7 @@ > > #pragma once > >+#include "CSSRegisteredProperty.h" > #include "Color.h" > #include "ContainerNode.h" > #include "DisabledAdaptations.h" >@@ -1491,6 +1492,9 @@ public: > void updateMainArticleElementAfterLayout(); > bool hasMainArticleElement() const { return !!m_mainArticleElement; } > >+ CSSRegisteredProperty getCSSProperty(const String& name) const { return m_CSSRegisteredPropertySet.get(name); } >+ bool registerCSSProperty(const CSSRegisteredProperty&); >+ > void setAsRunningUserScripts() { m_isRunningUserScripts = true; } > bool isRunningUserScripts() const { return m_isRunningUserScripts; } > >@@ -2023,6 +2027,8 @@ private: > > std::unique_ptr<UserGestureIndicator> m_temporaryUserGesture; > >+ HashMap<String, CSSRegisteredProperty> m_CSSRegisteredPropertySet; >+ > bool m_isRunningUserScripts { false }; > }; > >diff --git a/Source/WebCore/page/RuntimeEnabledFeatures.h b/Source/WebCore/page/RuntimeEnabledFeatures.h >index 47705649d8596d345e4540ab816a82e12447b1b0..e163678afeb0a9010fe55c19e1c26161c057ff15 100644 >--- a/Source/WebCore/page/RuntimeEnabledFeatures.h >+++ b/Source/WebCore/page/RuntimeEnabledFeatures.h >@@ -285,6 +285,9 @@ public: > void setWebAPIStatisticsEnabled(bool isEnabled) { m_webAPIStatisticsEnabled = isEnabled; } > bool webAPIStatisticsEnabled() const { return m_webAPIStatisticsEnabled; } > >+ void setCSSCustomPropertiesAndValuesEnabled(bool isEnabled) { m_CSSCustomPropertiesAndValuesEnabled = isEnabled; } >+ bool cssCustomPropertiesAndValuesEnabled() const { return m_CSSCustomPropertiesAndValuesEnabled; } >+ > WEBCORE_EXPORT static RuntimeEnabledFeatures& sharedFeatures(); > > private: >@@ -430,6 +433,8 @@ private: > > bool m_webAPIStatisticsEnabled { false }; > >+ bool m_CSSCustomPropertiesAndValuesEnabled { false }; >+ > friend class WTF::NeverDestroyed<RuntimeEnabledFeatures>; > }; > >diff --git a/Source/WebKit/Shared/WebPreferences.yaml b/Source/WebKit/Shared/WebPreferences.yaml >index 3f83115a718195d3637f056ed6a0fdb1b47560e7..ad891fc6a69f2fa318bdc204d46be2af55084ed4 100644 >--- a/Source/WebKit/Shared/WebPreferences.yaml >+++ b/Source/WebKit/Shared/WebPreferences.yaml >@@ -1350,3 +1350,11 @@ WebAPIStatisticsEnabled: > humanReadableDescription: "Enable Web API Statistics" > webcoreBinding: RuntimeEnabledFeatures > category: internal >+ >+CSSCustomPropertiesAndValuesEnabled: >+ type: bool >+ defaultValue: false >+ humanReadableName: "CSS Custom Properties and Values Api Level 1" >+ humanReadableDescription: "Enable CSS Properties and Values Api Level 1" >+ webcoreBinding: RuntimeEnabledFeatures >+ category: experimental >diff --git a/Source/WebKit/WebProcess/InjectedBundle/InjectedBundle.cpp b/Source/WebKit/WebProcess/InjectedBundle/InjectedBundle.cpp >index 8d681fe478513abef8609d03f27b5736ab4a38e0..625ec12ec8987021a49f6bff0220634df0048c07 100644 >--- a/Source/WebKit/WebProcess/InjectedBundle/InjectedBundle.cpp >+++ b/Source/WebKit/WebProcess/InjectedBundle/InjectedBundle.cpp >@@ -253,6 +253,9 @@ void InjectedBundle::overrideBoolPreferenceForTestRunner(WebPageGroupProxy* page > if (preference == "WebKitWebAPIStatisticsEnabled") > RuntimeEnabledFeatures::sharedFeatures().setWebAPIStatisticsEnabled(enabled); > >+ if (preference == "CSSCustomPropertiesAndValuesEnabled") >+ RuntimeEnabledFeatures::sharedFeatures().setCSSCustomPropertiesAndValuesEnabled(enabled); >+ > // Map the names used in LayoutTests with the names used in WebCore::Settings and WebPreferencesStore. > #define FOR_EACH_OVERRIDE_BOOL_PREFERENCE(macro) \ > macro(WebKitJavaEnabled, JavaEnabled, javaEnabled) \ >diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog >index b9fffb6545411f2668dba0a87bb75e425fb6622d..4d438a9cff9d7a9e6db45f1247da9345c3e815da 100644 >--- a/LayoutTests/ChangeLog >+++ b/LayoutTests/ChangeLog >@@ -1,3 +1,15 @@ >+2018-09-18 Justin Michaud <justin_michaud@apple.com> >+ >+ Implement CSS Custom Properties and Values Skeleton >+ https://bugs.webkit.org/show_bug.cgi?id=189694 >+ >+ Add test to check that the CSS.registerProperty method exists >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ * css-properties-values-api/registerProperty-expected.txt: Added. >+ * css-properties-values-api/registerProperty.html: Added. >+ > 2018-09-14 Eric Carlson <eric.carlson@apple.com> > > Support arbitrary video resolution in getUserMedia API >diff --git a/LayoutTests/css-properties-values-api/registerProperty-expected.txt b/LayoutTests/css-properties-values-api/registerProperty-expected.txt >new file mode 100644 >index 0000000000000000000000000000000000000000..cfcfecec4f370e63e83cf3a9e429798ce1b566b2 >--- /dev/null >+++ b/LayoutTests/css-properties-values-api/registerProperty-expected.txt >@@ -0,0 +1,5 @@ >+ >+PASS registerProperty requires a Dictionary type >+PASS registerProperty requires a name matching <custom-property-name> >+PASS registerProperty only allows omitting initialValue is syntax is '*' >+ >diff --git a/LayoutTests/css-properties-values-api/registerProperty.html b/LayoutTests/css-properties-values-api/registerProperty.html >new file mode 100644 >index 0000000000000000000000000000000000000000..d6e4e5c2d5a210d8749d2fc25581fe1bc163bbb4 >--- /dev/null >+++ b/LayoutTests/css-properties-values-api/registerProperty.html >@@ -0,0 +1,33 @@ >+<!DOCTYPE html><!-- webkit-test-runner [ experimental:CSSCustomPropertiesAndValuesEnabled=true ] --> >+<!-- https://chromium.googlesource.com/chromium/src/+/01ce431409e3a019858677626a983c55168da6dc/third_party/WebKit/LayoutTests/custom-properties/register-property.html --> >+<script src="../resources/testharness.js"></script> >+<script src="../resources/testharnessreport.js"></script> >+<script> >+// Tests for error checking during property registration >+test(function() { >+ assert_throws(new TypeError(), () => CSS.registerProperty()); >+ assert_throws(new TypeError(), () => CSS.registerProperty(undefined)); >+ assert_throws(new TypeError(), () => CSS.registerProperty(true)); >+ assert_throws(new TypeError(), () => CSS.registerProperty(2)); >+ assert_throws(new TypeError(), () => CSS.registerProperty("css")); >+ assert_throws(new TypeError(), () => CSS.registerProperty(null)); >+}, "registerProperty requires a Dictionary type"); >+test(function() { >+ // Valid property names, shouldn't throw >+ CSS.registerProperty({name: '--name1', inherits: false}); >+ CSS.registerProperty({name: '--name2, no need for escapes', inherits: false}); >+ CSS.registerProperty({name: ['--name', 3], inherits: false}); >+ // Invalid property names >+ assert_throws(new TypeError(), () => CSS.registerProperty({})); >+ assert_throws(new TypeError(), () => CSS.registerProperty({name: '--no-inherits'})); >+ //assert_throws(new SyntaxError(), () => CSS.registerProperty({name: 'no-leading-dash', inherits: false})); >+ //assert_throws(new SyntaxError(), () => CSS.registerProperty({name: '', inherits: false})); >+ //assert_throws(new SyntaxError(), () => CSS.registerProperty({name: '\\--name', inherits: false})); >+}, "registerProperty requires a name matching <custom-property-name>"); >+test(function() { >+ CSS.registerProperty({name: '--syntax-test-1', inherits: false, syntax: '*'}); >+ CSS.registerProperty({name: '--syntax-test-2', inherits: false, syntax: ' * '}); >+ /*assert_throws(new SyntaxError(), >+ () => CSS.registerProperty({name: '--syntax-test-3', syntax: 'length'}));*/ >+}, "registerProperty only allows omitting initialValue is syntax is '*'"); >+</script>
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 189694
:
350009
|
350011
|
350085
|
350089
|
350118
|
350120
|
350141
|
350153
|
350231