Title: [200547] trunk
Revision
200547
Author
[email protected]
Date
2016-05-07 14:14:20 -0700 (Sat, 07 May 2016)

Log Message

Next step on dictionary bindings, along with other bindings refinements
https://bugs.webkit.org/show_bug.cgi?id=157451

Reviewed by Chris Dumez.

Source/WebCore:

Converted one dictionary, the one passed to the constructor in FontFace.

* WebCore.xcodeproj/project.pbxproj: Updated for name change of JSDOMBuild.h to
JSDOMConvert.h and also let Xcode update a file type.

* bindings/js/JSDOMBinding.cpp:
(WebCore::propertyValue): Added.
* bindings/js/JSDOMBinding.h: Use pragma once. Remove unnecessary forward declaration.
Move all declarations to the top of the file, separating them from definitions. This
is a small step toward better overview of what's in this file and paves the way for
future simplifications and improvements we can make after we observe patterns.
Also removed a couple unused functions.

* bindings/js/JSDOMConvert.h: Renamed from JSDOMBuild.h.
Renamed function templates from build to convert. Added convertOptional.

* bindings/js/ReadableStreamController.cpp:
(WebCore::callFunction): Use auto and remove some unneeded namespacing.
(WebCore::ReadableStreamController::invoke): Ditto. Also remove use of helper function
getPropertyFromObject, since this was the only call site and it was not very helpful.
(WebCore::ReadableStreamController::isControlledReadableStreamLocked): Ditto.
(WebCore::createReadableStream): Ditto.
(WebCore::getReadableStreamReader): Ditto.

* bindings/scripts/CodeGeneratorJS.pm:
(GenerateEnumerationImplementationContent): Updated for name change from build to
convert and JSDOMBuild.h to JSDOMConvert.h.
(GenerateDictionaryImplementationContent): Ditto. Also added code to handle optional
and added explicit exception checking, using local variables. Not clear longer term
if the local variable approach is OK since this will unnecessarily change types like
const String& to String.
(GenerateParametersCheck): Removed local variable $optional and use $parameter->isOptional
directly consistently. This is slightly clearer because the old code used a mix of the
two, and also is a better pattern for when we refactor this into smaller functions.
Note that this function name is not good any more--this is a lot more then parameter checks.
(GetNativeType): Return appropriate name for dictionary types.
(JSValueToNative): Updated for name change from build to convert and JSDOMBuild.h to
JSDOMConvert.h.

* bindings/scripts/test/JS/JSTestObj.cpp:
* bindings/scripts/test/JS/JSTestTypedefs.cpp:
Regenerated results.

* bindings/scripts/test/TestObj.idl: Added another dictionary test case, just a copy
of the current state of the one in FontFace.idl.

* css/CSSFontFace.cpp:
(WebCore::CSSFontFace::setUnicodeRange): Update for simplified UnicodeRange struct.
(WebCore::CSSFontFace::setFeatureSettings): Fix to correctly handle being called
with "normal". Also fix so it doesn't call fontPropertyChanged if nothing changed.
Also got rid of return value, which had no real value: it was returning false for
some bad inputs, but others would just lead to assertions, and the real reason this
was OK is that this function is only passed known-valid values.

* css/CSSFontFace.h: Used prama once. Tweaked formatting. Removed return value from
the setFeatureSettings function. Changed UnicodeRange to be struct with public data
members instead a struct with a constructor and getter functions.

* css/CSSFontSelector.cpp:
(WebCore::CSSFontSelector::addFontFaceRule): Updated since setFeatureSettings no
longer has a boolean return value.

* css/CSSSegmentedFontFace.cpp:
(WebCore::appendFontWithInvalidUnicodeRangeIfLoading): Updated for simplified
UnicodeRange struct.

* css/FontFace.cpp:
(WebCore::valueFromDictionary): Deleted.
(WebCore::FontFace::create): Updated to take the descriptors as a struct instead of
a WebCore::Dictionary. Also made that argument optional as specified in the current
specification draft.
(WebCore::FontFace::setFeatureSettings): Updated since setFeatureSettings no longer
has a boolean return value.
(WebCore::FontFace::unicodeRange): Updated for simplified UnicodeRange struct.

* css/FontFace.h: Used pragma once. Removed unneeded includes and forward declarations.
Derived privately from CSSFontFace::Client. Added a FontFace::Descriptors struct and
used it as an argument to the create function as described above.

* css/FontFace.idl: Added FontFaceDescriptors and changed the argument to the
constructor to be an optional FontFaceDescriptors instead of a Dictionary.

Tools:

* Scripts/do-webcore-rename: Use this to rename JSDOMBuild.h to JSDOMConvert.h.
Also skip test expectations in a directory that this was modifying unnecessarily.

Modified Paths

Added Paths

Removed Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (200546 => 200547)


--- trunk/Source/WebCore/ChangeLog	2016-05-07 20:04:27 UTC (rev 200546)
+++ trunk/Source/WebCore/ChangeLog	2016-05-07 21:14:20 UTC (rev 200547)
@@ -1,3 +1,92 @@
+2016-05-07  Darin Adler  <[email protected]>
+
+        Next step on dictionary bindings, along with other bindings refinements
+        https://bugs.webkit.org/show_bug.cgi?id=157451
+
+        Reviewed by Chris Dumez.
+
+        Converted one dictionary, the one passed to the constructor in FontFace.
+
+        * WebCore.xcodeproj/project.pbxproj: Updated for name change of JSDOMBuild.h to
+        JSDOMConvert.h and also let Xcode update a file type.
+
+        * bindings/js/JSDOMBinding.cpp:
+        (WebCore::propertyValue): Added.
+        * bindings/js/JSDOMBinding.h: Use pragma once. Remove unnecessary forward declaration.
+        Move all declarations to the top of the file, separating them from definitions. This
+        is a small step toward better overview of what's in this file and paves the way for
+        future simplifications and improvements we can make after we observe patterns.
+        Also removed a couple unused functions.
+
+        * bindings/js/JSDOMConvert.h: Renamed from JSDOMBuild.h.
+        Renamed function templates from build to convert. Added convertOptional.
+
+        * bindings/js/ReadableStreamController.cpp:
+        (WebCore::callFunction): Use auto and remove some unneeded namespacing.
+        (WebCore::ReadableStreamController::invoke): Ditto. Also remove use of helper function
+        getPropertyFromObject, since this was the only call site and it was not very helpful.
+        (WebCore::ReadableStreamController::isControlledReadableStreamLocked): Ditto.
+        (WebCore::createReadableStream): Ditto.
+        (WebCore::getReadableStreamReader): Ditto.
+
+        * bindings/scripts/CodeGeneratorJS.pm:
+        (GenerateEnumerationImplementationContent): Updated for name change from build to
+        convert and JSDOMBuild.h to JSDOMConvert.h.
+        (GenerateDictionaryImplementationContent): Ditto. Also added code to handle optional
+        and added explicit exception checking, using local variables. Not clear longer term
+        if the local variable approach is OK since this will unnecessarily change types like
+        const String& to String.
+        (GenerateParametersCheck): Removed local variable $optional and use $parameter->isOptional
+        directly consistently. This is slightly clearer because the old code used a mix of the
+        two, and also is a better pattern for when we refactor this into smaller functions.
+        Note that this function name is not good any more--this is a lot more then parameter checks.
+        (GetNativeType): Return appropriate name for dictionary types.
+        (JSValueToNative): Updated for name change from build to convert and JSDOMBuild.h to
+        JSDOMConvert.h.
+
+        * bindings/scripts/test/JS/JSTestObj.cpp:
+        * bindings/scripts/test/JS/JSTestTypedefs.cpp:
+        Regenerated results.
+
+        * bindings/scripts/test/TestObj.idl: Added another dictionary test case, just a copy
+        of the current state of the one in FontFace.idl.
+
+        * css/CSSFontFace.cpp:
+        (WebCore::CSSFontFace::setUnicodeRange): Update for simplified UnicodeRange struct.
+        (WebCore::CSSFontFace::setFeatureSettings): Fix to correctly handle being called
+        with "normal". Also fix so it doesn't call fontPropertyChanged if nothing changed.
+        Also got rid of return value, which had no real value: it was returning false for
+        some bad inputs, but others would just lead to assertions, and the real reason this
+        was OK is that this function is only passed known-valid values.
+
+        * css/CSSFontFace.h: Used prama once. Tweaked formatting. Removed return value from
+        the setFeatureSettings function. Changed UnicodeRange to be struct with public data
+        members instead a struct with a constructor and getter functions.
+
+        * css/CSSFontSelector.cpp:
+        (WebCore::CSSFontSelector::addFontFaceRule): Updated since setFeatureSettings no
+        longer has a boolean return value.
+
+        * css/CSSSegmentedFontFace.cpp:
+        (WebCore::appendFontWithInvalidUnicodeRangeIfLoading): Updated for simplified
+        UnicodeRange struct.
+
+        * css/FontFace.cpp:
+        (WebCore::valueFromDictionary): Deleted.
+        (WebCore::FontFace::create): Updated to take the descriptors as a struct instead of
+        a WebCore::Dictionary. Also made that argument optional as specified in the current
+        specification draft.
+        (WebCore::FontFace::setFeatureSettings): Updated since setFeatureSettings no longer
+        has a boolean return value.
+        (WebCore::FontFace::unicodeRange): Updated for simplified UnicodeRange struct.
+
+        * css/FontFace.h: Used pragma once. Removed unneeded includes and forward declarations.
+        Derived privately from CSSFontFace::Client. Added a FontFace::Descriptors struct and
+        used it as an argument to the create function as described above.
+
+        * css/FontFace.idl: Added FontFaceDescriptors and changed the argument to the
+        constructor to be an optional FontFaceDescriptors instead of a Dictionary.
+
 2016-05-07  Youenn Fablet  <[email protected]>
 
         Rework FontFace promise attribute handling

Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (200546 => 200547)


--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2016-05-07 20:04:27 UTC (rev 200546)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2016-05-07 21:14:20 UTC (rev 200547)
@@ -3515,6 +3515,7 @@
 		9307F1130AF2C8BE00DBA31A /* DOMNodeInternal.h in Copy Generated Headers */ = {isa = PBXBuildFile; fileRef = 85B498FA0ADB340200925CBB /* DOMNodeInternal.h */; };
 		9307F1D70AF2D59000DBA31A /* HitTestResult.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9307F1D50AF2D59000DBA31A /* HitTestResult.cpp */; };
 		9307F1D80AF2D59000DBA31A /* HitTestResult.h in Headers */ = {isa = PBXBuildFile; fileRef = 9307F1D60AF2D59000DBA31A /* HitTestResult.h */; settings = {ATTRIBUTES = (Private, ); }; };
+		930841341CDDB15500B0958C /* JSDOMConvert.h in Headers */ = {isa = PBXBuildFile; fileRef = 930841331CDDB15500B0958C /* JSDOMConvert.h */; };
 		930908910AF7EDE40081DF01 /* HitTestRequest.h in Headers */ = {isa = PBXBuildFile; fileRef = 930908900AF7EDE40081DF01 /* HitTestRequest.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		930C90DD19CF965300D6C21A /* InlineIterator.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 930C90DC19CF965300D6C21A /* InlineIterator.cpp */; };
 		93153BDA14181F7A00FCF5BE /* [email protected] in Resources */ = {isa = PBXBuildFile; fileRef = 93153BD914181F7A00FCF5BE /* [email protected] */; };
@@ -9666,7 +9667,7 @@
 		51741D0B0B07259A00ED442C /* BackForwardClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BackForwardClient.h; sourceTree = "<group>"; };
 		51741D0D0B07259A00ED442C /* HistoryItem.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = HistoryItem.h; sourceTree = "<group>"; };
 		51741D0E0B07259A00ED442C /* HistoryItem.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = HistoryItem.cpp; sourceTree = "<group>"; };
-		51748FA21CC6EEEB00728D84 /* WorkerGlobalScopeConstructors.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file; path = WorkerGlobalScopeConstructors.idl; sourceTree = "<group>"; };
+		51748FA21CC6EEEB00728D84 /* WorkerGlobalScopeConstructors.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = WorkerGlobalScopeConstructors.idl; sourceTree = "<group>"; };
 		5174E20810A1F44F00F95E6F /* PopStateEvent.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PopStateEvent.h; sourceTree = "<group>"; };
 		5174E20B10A1F49A00F95E6F /* PopStateEvent.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = PopStateEvent.idl; sourceTree = "<group>"; };
 		51771DFC1BDB475600CAE8E4 /* MemoryObjectStore.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MemoryObjectStore.cpp; sourceTree = "<group>"; };
@@ -11163,6 +11164,7 @@
 		9307061309E0CA8200B17FE4 /* DerivedSources.make */ = {isa = PBXFileReference; explicitFileType = sourcecode.make; fileEncoding = 4; lineEnding = 0; path = DerivedSources.make; sourceTree = "<group>"; usesTabs = 1; xcLanguageSpecificationIdentifier = xcode.lang.simpleColoring; };
 		9307F1D50AF2D59000DBA31A /* HitTestResult.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = HitTestResult.cpp; sourceTree = "<group>"; };
 		9307F1D60AF2D59000DBA31A /* HitTestResult.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = HitTestResult.h; sourceTree = "<group>"; };
+		930841331CDDB15500B0958C /* JSDOMConvert.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSDOMConvert.h; sourceTree = "<group>"; };
 		930908900AF7EDE40081DF01 /* HitTestRequest.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = HitTestRequest.h; sourceTree = "<group>"; };
 		930C90DC19CF965300D6C21A /* InlineIterator.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = InlineIterator.cpp; sourceTree = "<group>"; };
 		93153BD914181F7A00FCF5BE /* [email protected] */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "[email protected]"; sourceTree = "<group>"; };
@@ -22302,6 +22304,7 @@
 				93B70D4709EB0C7C009D8468 /* JSDOMBinding.cpp */,
 				93B70D4809EB0C7C009D8468 /* JSDOMBinding.h */,
 				413C2C331BC29A7B0075204C /* JSDOMConstructor.h */,
+				930841331CDDB15500B0958C /* JSDOMConvert.h */,
 				E1C36CBC0EB08062007410BC /* JSDOMGlobalObject.cpp */,
 				E1C36C020EB076D6007410BC /* JSDOMGlobalObject.h */,
 				7C2BDD3B17C7F98B0038FF15 /* JSDOMGlobalObjectTask.cpp */,
@@ -25480,6 +25483,7 @@
 				BC80C9880CD294EE00A0B7B3 /* CSSTimingFunctionValue.h in Headers */,
 				9AB1F38018E2489A00534743 /* CSSToLengthConversionData.h in Headers */,
 				A882DA231593848D000115ED /* CSSToStyleMap.h in Headers */,
+				930841341CDDB15500B0958C /* JSDOMConvert.h in Headers */,
 				371F53E90D2704F900ECE0D5 /* CSSUnicodeRangeValue.h in Headers */,
 				DD7CDF250A23CF9800069928 /* CSSUnknownRule.h in Headers */,
 				BC7D8FF01BD03B6400FFE540 /* CSSUnsetValue.h in Headers */,

Modified: trunk/Source/WebCore/bindings/js/JSDOMBinding.cpp (200546 => 200547)


--- trunk/Source/WebCore/bindings/js/JSDOMBinding.cpp	2016-05-07 20:04:27 UTC (rev 200546)
+++ trunk/Source/WebCore/bindings/js/JSDOMBinding.cpp	2016-05-07 21:14:20 UTC (rev 200547)
@@ -32,6 +32,7 @@
 #include "Frame.h"
 #include "HTMLParserIdioms.h"
 #include "IDBDatabaseException.h"
+#include "JSDOMConvert.h"
 #include "JSDOMWindowCustom.h"
 #include "JSExceptionBase.h"
 #include "SecurityOrigin.h"
@@ -839,4 +840,9 @@
     return CallType::Host;
 }
 
+JSValue propertyValue(ExecState& state, JSValue value, const char* propertyName)
+{
+    return value.get(&state, Identifier::fromString(&state, propertyName));
+}
+
 } // namespace WebCore

Modified: trunk/Source/WebCore/bindings/js/JSDOMBinding.h (200546 => 200547)


--- trunk/Source/WebCore/bindings/js/JSDOMBinding.h	2016-05-07 20:04:27 UTC (rev 200546)
+++ trunk/Source/WebCore/bindings/js/JSDOMBinding.h	2016-05-07 21:14:20 UTC (rev 200547)
@@ -21,8 +21,7 @@
  *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
  */
 
-#ifndef JSDOMBinding_h
-#define JSDOMBinding_h
+#pragma once
 
 #include "JSDOMGlobalObject.h"
 #include "JSDOMWrapper.h"
@@ -55,7 +54,6 @@
 // and function definitions below, even for template and inline functions.
 
 namespace JSC {
-class HashEntry;
 class JSFunction;
 }
 
@@ -69,6 +67,9 @@
 class Node;
 
 struct ExceptionCodeWithMessage;
+
+typedef int ExceptionCode;
+
 struct ExceptionDetails {
     String message;
     int lineNumber { 0 };
@@ -76,8 +77,35 @@
     String sourceURL;
 };
 
-typedef int ExceptionCode;
+// Base class for all constructor objects in the JSC bindings.
+class DOMConstructorObject : public JSDOMObject {
+public:
+    typedef JSDOMObject Base;
+    static const unsigned StructureFlags = Base::StructureFlags | JSC::ImplementsHasInstance | JSC::ImplementsDefaultHasInstance | JSC::TypeOfShouldCallGetCallData;
+    static JSC::Structure* createStructure(JSC::VM&, JSC::JSGlobalObject*, JSC::JSValue);
 
+protected:
+    DOMConstructorObject(JSC::Structure*, JSDOMGlobalObject&);
+
+    static String className(const JSObject*);
+    static JSC::CallType getCallData(JSCell*, JSC::CallData&);
+};
+
+class DOMConstructorJSBuiltinObject : public DOMConstructorObject {
+public:
+    typedef DOMConstructorObject Base;
+
+protected:
+    DOMConstructorJSBuiltinObject(JSC::Structure*, JSDOMGlobalObject&);
+    static void visitChildren(JSC::JSCell*, JSC::SlotVisitor&);
+
+    JSC::JSFunction* initializeFunction();
+    void setInitializeFunction(JSC::VM&, JSC::JSFunction&);
+
+private:
+    JSC::WriteBarrier<JSC::JSFunction> m_initializeFunction;
+};
+
 DOMWindow& callerDOMWindow(JSC::ExecState*);
 DOMWindow& activeDOMWindow(JSC::ExecState*);
 DOMWindow& firstDOMWindow(JSC::ExecState*);
@@ -100,47 +128,210 @@
 WEBCORE_EXPORT JSC::EncodedJSValue throwGetterTypeError(JSC::ExecState&, const char* interfaceName, const char* attributeName);
 WEBCORE_EXPORT JSC::EncodedJSValue throwThisTypeError(JSC::ExecState&, const char* interfaceName, const char* functionName);
 
-// Base class for all constructor objects in the JSC bindings.
-class DOMConstructorObject : public JSDOMObject {
-public:
-    typedef JSDOMObject Base;
-    static const unsigned StructureFlags = Base::StructureFlags | JSC::ImplementsHasInstance | JSC::ImplementsDefaultHasInstance | JSC::TypeOfShouldCallGetCallData;
+WEBCORE_EXPORT JSC::Structure* getCachedDOMStructure(JSDOMGlobalObject&, const JSC::ClassInfo*);
+WEBCORE_EXPORT JSC::Structure* cacheDOMStructure(JSDOMGlobalObject&, JSC::Structure*, const JSC::ClassInfo*);
 
-    static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
-    {
-        return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info());
-    }
+template<typename WrapperClass> JSC::Structure* getDOMStructure(JSC::VM&, JSDOMGlobalObject&);
+template<typename WrapperClass> JSC::Structure* deprecatedGetDOMStructure(JSC::ExecState*);
+template<typename WrapperClass> JSC::JSObject* getDOMPrototype(JSC::VM&, JSC::JSGlobalObject*);
 
-protected:
-    DOMConstructorObject(JSC::Structure* structure, JSDOMGlobalObject& globalObject)
-        : JSDOMObject(structure, globalObject)
-    {
-    }
+void callFunctionWithCurrentArguments(JSC::ExecState&, JSC::JSObject& thisObject, JSC::JSFunction&);
 
-    static String className(const JSObject*) { return ASCIILiteral("Function"); }
-    static JSC::CallType getCallData(JSCell*, JSC::CallData&);
-};
+template<typename JSClass> JSC::EncodedJSValue createJSBuiltin(JSC::ExecState&, JSC::JSFunction& initializeFunction, JSDOMGlobalObject&);
 
-class DOMConstructorJSBuiltinObject : public DOMConstructorObject {
-public:
-    typedef DOMConstructorObject Base;
+JSC::WeakHandleOwner* wrapperOwner(DOMWrapperWorld&, JSC::ArrayBuffer*);
+void* wrapperKey(JSC::ArrayBuffer*);
 
-protected:
-    DOMConstructorJSBuiltinObject(JSC::Structure* structure, JSDOMGlobalObject& globalObject)
-        : DOMConstructorObject(structure, globalObject) { }
+JSDOMObject* getInlineCachedWrapper(DOMWrapperWorld&, void*);
+JSDOMObject* getInlineCachedWrapper(DOMWrapperWorld&, ScriptWrappable*);
+JSC::JSArrayBuffer* getInlineCachedWrapper(DOMWrapperWorld&, JSC::ArrayBuffer*);
 
-    static void visitChildren(JSC::JSCell*, JSC::SlotVisitor&);
+bool setInlineCachedWrapper(DOMWrapperWorld&, void*, JSDOMObject*, JSC::WeakHandleOwner*);
+bool setInlineCachedWrapper(DOMWrapperWorld&, ScriptWrappable*, JSDOMObject* wrapper, JSC::WeakHandleOwner* wrapperOwner);
+bool setInlineCachedWrapper(DOMWrapperWorld&, JSC::ArrayBuffer*, JSC::JSArrayBuffer* wrapper, JSC::WeakHandleOwner* wrapperOwner);
 
-    JSC::JSFunction* initializeFunction() { return m_initializeFunction.get(); }
-    void setInitializeFunction(JSC::VM& vm, JSC::JSFunction& function) { m_initializeFunction.set(vm, this, &function); }
+bool clearInlineCachedWrapper(DOMWrapperWorld&, void*, JSDOMObject*);
+bool clearInlineCachedWrapper(DOMWrapperWorld&, ScriptWrappable*, JSDOMObject* wrapper);
+bool clearInlineCachedWrapper(DOMWrapperWorld&, JSC::ArrayBuffer*, JSC::JSArrayBuffer* wrapper);
 
-private:
-    JSC::WriteBarrier<JSC::JSFunction> m_initializeFunction;
+#define CREATE_DOM_WRAPPER(globalObject, className, object) createWrapper<JS##className>(globalObject, static_cast<className*>(object))
+
+template<typename DOMClass> JSC::JSObject* getCachedWrapper(DOMWrapperWorld&, DOMClass*);
+template<typename DOMClass, typename WrapperClass> void cacheWrapper(DOMWrapperWorld&, DOMClass*, WrapperClass*);
+template<typename DOMClass, typename WrapperClass> void uncacheWrapper(DOMWrapperWorld&, DOMClass*, WrapperClass*);
+
+template<typename WrapperClass, typename DOMClass> JSDOMObject* createWrapper(JSDOMGlobalObject*, DOMClass*);
+template<typename WrapperClass, typename DOMClass> JSC::JSValue wrap(JSDOMGlobalObject*, DOMClass&);
+template<typename WrapperClass, typename DOMClass> JSC::JSValue getExistingWrapper(JSDOMGlobalObject*, DOMClass*);
+template<typename WrapperClass, typename DOMClass> JSC::JSValue createNewWrapper(JSDOMGlobalObject*, DOMClass*);
+
+void addImpureProperty(const AtomicString&);
+
+const JSC::HashTable& getHashTableForGlobalData(JSC::VM&, const JSC::HashTable& staticTable);
+
+WEBCORE_EXPORT void reportException(JSC::ExecState*, JSC::JSValue exception, CachedScript* = nullptr);
+WEBCORE_EXPORT void reportException(JSC::ExecState*, JSC::Exception*, CachedScript* = nullptr, ExceptionDetails* = nullptr);
+void reportCurrentException(JSC::ExecState*);
+
+JSC::JSValue createDOMException(JSC::ExecState*, ExceptionCode);
+
+// Convert a DOM implementation exception code into a _javascript_ exception in the execution state.
+WEBCORE_EXPORT void setDOMException(JSC::ExecState*, ExceptionCode);
+void setDOMException(JSC::ExecState*, const ExceptionCodeWithMessage&);
+
+JSC::JSValue jsString(JSC::ExecState*, const URL&); // empty if the URL is null
+
+JSC::JSValue jsStringOrNull(JSC::ExecState*, const String&); // null if the string is null
+JSC::JSValue jsStringOrNull(JSC::ExecState*, const URL&); // null if the URL is null
+
+JSC::JSValue jsStringOrUndefined(JSC::ExecState*, const String&); // undefined if the string is null
+JSC::JSValue jsStringOrUndefined(JSC::ExecState*, const URL&); // undefined if the URL is null
+
+// See _javascript_Core for explanation: Should be used for any string that is already owned by another
+// object, to let the engine know that collecting the JSString wrapper is unlikely to save memory.
+JSC::JSValue jsOwnedStringOrNull(JSC::ExecState*, const String&);
+
+String propertyNameToString(JSC::PropertyName);
+
+AtomicString propertyNameToAtomicString(JSC::PropertyName);
+
+// FIXME: This is only used by legacy code and should go away. Use valueToStringTreatingNullAsEmptyString() instead.
+String valueToStringWithNullCheck(JSC::ExecState*, JSC::JSValue); // null if the value is null
+
+String valueToStringTreatingNullAsEmptyString(JSC::ExecState*, JSC::JSValue);
+String valueToStringWithUndefinedOrNullCheck(JSC::ExecState*, JSC::JSValue); // null if the value is null or undefined
+
+template<typename T> JSC::JSValue toNullableJSNumber(Optional<T>); // null if the optional is null
+
+int32_t finiteInt32Value(JSC::JSValue, JSC::ExecState*, bool& okay);
+
+// The following functions convert values to integers as per the WebIDL specification.
+// The conversion fails if the value cannot be converted to a number or, if EnforceRange is specified,
+// the value is outside the range of the destination integer type.
+
+enum IntegerConversionConfiguration { NormalConversion, EnforceRange, Clamp };
+
+WEBCORE_EXPORT int32_t toInt32EnforceRange(JSC::ExecState*, JSC::JSValue);
+WEBCORE_EXPORT uint32_t toUInt32EnforceRange(JSC::ExecState*, JSC::JSValue);
+
+WEBCORE_EXPORT int32_t toInt32Clamp(JSC::ExecState*, JSC::JSValue);
+WEBCORE_EXPORT uint32_t toUInt32Clamp(JSC::ExecState*, JSC::JSValue);
+
+WEBCORE_EXPORT int8_t toInt8(JSC::ExecState*, JSC::JSValue, IntegerConversionConfiguration);
+WEBCORE_EXPORT uint8_t toUInt8(JSC::ExecState*, JSC::JSValue, IntegerConversionConfiguration);
+
+WEBCORE_EXPORT int16_t toInt16(JSC::ExecState*, JSC::JSValue, IntegerConversionConfiguration);
+WEBCORE_EXPORT uint16_t toUInt16(JSC::ExecState*, JSC::JSValue, IntegerConversionConfiguration);
+
+int32_t toInt32(JSC::ExecState*, JSC::JSValue, IntegerConversionConfiguration);
+uint32_t toUInt32(JSC::ExecState*, JSC::JSValue, IntegerConversionConfiguration);
+
+WEBCORE_EXPORT int64_t toInt64(JSC::ExecState*, JSC::JSValue, IntegerConversionConfiguration);
+WEBCORE_EXPORT uint64_t toUInt64(JSC::ExecState*, JSC::JSValue, IntegerConversionConfiguration);
+
+// Returns a Date instance for the specified value, or NaN if the date is not a number.
+JSC::JSValue jsDateOrNaN(JSC::ExecState*, double);
+
+// Returns a Date instance for the specified value, or null if the value is NaN or infinity.
+JSC::JSValue jsDateOrNull(JSC::ExecState*, double);
+
+// NaN if the value can't be converted to a date.
+double valueToDate(JSC::ExecState*, JSC::JSValue);
+
+// Validates that the passed object is a sequence type per section 4.1.13 of the WebIDL spec.
+JSC::JSObject* toJSSequence(JSC::ExecState*, JSC::JSValue, unsigned& length);
+
+JSC::JSValue toJS(JSC::ExecState*, JSDOMGlobalObject*, JSC::ArrayBuffer*);
+JSC::JSValue toJS(JSC::ExecState*, JSDOMGlobalObject*, JSC::ArrayBufferView*);
+JSC::JSValue toJS(JSC::ExecState*, JSC::JSGlobalObject*, JSC::ArrayBufferView*);
+template<typename T> JSC::JSValue toJS(JSC::ExecState*, JSDOMGlobalObject*, RefPtr<T>);
+template<typename T> JSC::JSValue toJS(JSC::ExecState*, JSDOMGlobalObject*, PassRefPtr<T>);
+template<typename T> JSC::JSValue toJS(JSC::ExecState*, JSDOMGlobalObject*, const Vector<T>&);
+template<typename T> JSC::JSValue toJS(JSC::ExecState*, JSDOMGlobalObject*, const Vector<RefPtr<T>>&);
+JSC::JSValue toJS(JSC::ExecState*, JSDOMGlobalObject*, const String&);
+
+JSC::JSValue toJSIterator(JSC::ExecState&, JSDOMGlobalObject&, JSC::JSValue);
+template<typename T> JSC::JSValue toJSIterator(JSC::ExecState&, JSDOMGlobalObject&, const T&);
+
+JSC::JSValue toJSIteratorEnd(JSC::ExecState&);
+
+template<typename T, size_t inlineCapacity> JSC::JSValue jsArray(JSC::ExecState*, JSDOMGlobalObject*, const Vector<T, inlineCapacity>&);
+template<typename T, size_t inlineCapacity> JSC::JSValue jsArray(JSC::ExecState*, JSDOMGlobalObject*, const Vector<T, inlineCapacity>*);
+WEBCORE_EXPORT JSC::JSValue jsArray(JSC::ExecState*, JSDOMGlobalObject*, PassRefPtr<DOMStringList>);
+
+template<typename Value1, typename Value2> JSC::JSValue jsPair(JSC::ExecState&, JSDOMGlobalObject*, const Value1&, const Value2&);
+
+RefPtr<JSC::ArrayBufferView> toArrayBufferView(JSC::JSValue);
+RefPtr<JSC::Int8Array> toInt8Array(JSC::JSValue);
+RefPtr<JSC::Int16Array> toInt16Array(JSC::JSValue);
+RefPtr<JSC::Int32Array> toInt32Array(JSC::JSValue);
+RefPtr<JSC::Uint8Array> toUint8Array(JSC::JSValue);
+RefPtr<JSC::Uint8ClampedArray> toUint8ClampedArray(JSC::JSValue);
+RefPtr<JSC::Uint16Array> toUint16Array(JSC::JSValue);
+RefPtr<JSC::Uint32Array> toUint32Array(JSC::JSValue);
+RefPtr<JSC::Float32Array> toFloat32Array(JSC::JSValue);
+RefPtr<JSC::Float64Array> toFloat64Array(JSC::JSValue);
+
+template<typename T, typename JSType> Vector<RefPtr<T>> toRefPtrNativeArray(JSC::ExecState*, JSC::JSValue, T* (*)(JSC::JSValue));
+template<typename T> Vector<T> toNativeArray(JSC::ExecState*, JSC::JSValue);
+template<typename T> Vector<T> toNativeArguments(JSC::ExecState*, size_t startIndex = 0);
+
+bool shouldAllowAccessToNode(JSC::ExecState*, Node*);
+bool shouldAllowAccessToFrame(JSC::ExecState*, Frame*);
+bool shouldAllowAccessToFrame(JSC::ExecState*, Frame*, String& message);
+bool shouldAllowAccessToDOMWindow(JSC::ExecState*, DOMWindow&, String& message);
+
+enum SecurityReportingOption { DoNotReportSecurityError, ReportSecurityError };
+
+class BindingSecurity {
+public:
+    static bool shouldAllowAccessToNode(JSC::ExecState*, Node*);
+    static bool shouldAllowAccessToDOMWindow(JSC::ExecState*, DOMWindow&, SecurityReportingOption = ReportSecurityError);
+    static bool shouldAllowAccessToFrame(JSC::ExecState*, Frame*, SecurityReportingOption = ReportSecurityError);
 };
 
-WEBCORE_EXPORT JSC::Structure* getCachedDOMStructure(JSDOMGlobalObject&, const JSC::ClassInfo*);
-WEBCORE_EXPORT JSC::Structure* cacheDOMStructure(JSDOMGlobalObject&, JSC::Structure*, const JSC::ClassInfo*);
+void printErrorMessageForFrame(Frame*, const String& message);
 
+String propertyNameToString(JSC::PropertyName);
+AtomicString propertyNameToAtomicString(JSC::PropertyName);
+
+template<typename DOMClass> const JSC::HashTableValue* getStaticValueSlotEntryWithoutCaching(JSC::ExecState*, JSC::PropertyName);
+template<JSC::NativeFunction, int length> JSC::EncodedJSValue nonCachingStaticFunctionGetter(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
+
+JSC::JSValue propertyValue(JSC::ExecState&, JSC::JSValue, const char* propertyName);
+
+// Inline functions and template definitions.
+
+inline JSC::Structure* DOMConstructorObject::createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
+{
+    return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info());
+}
+
+inline DOMConstructorObject::DOMConstructorObject(JSC::Structure* structure, JSDOMGlobalObject& globalObject)
+    : JSDOMObject(structure, globalObject)
+{
+}
+
+inline String DOMConstructorObject::className(const JSObject*)
+{
+    return ASCIILiteral("Function");
+}
+
+inline DOMConstructorJSBuiltinObject::DOMConstructorJSBuiltinObject(JSC::Structure* structure, JSDOMGlobalObject& globalObject)
+    : DOMConstructorObject(structure, globalObject)
+{
+}
+
+inline JSC::JSFunction* DOMConstructorJSBuiltinObject::initializeFunction()
+{
+    return m_initializeFunction.get();
+}
+
+inline void DOMConstructorJSBuiltinObject::setInitializeFunction(JSC::VM& vm, JSC::JSFunction& function)
+{
+    m_initializeFunction.set(vm, this, &function);
+}
+
 inline JSDOMGlobalObject* deprecatedGlobalObjectForPrototype(JSC::ExecState* exec)
 {
     // FIXME: Callers to this function should be using the global object
@@ -167,8 +358,6 @@
     return JSC::jsCast<JSC::JSObject*>(asObject(getDOMStructure<WrapperClass>(vm, *JSC::jsCast<JSDOMGlobalObject*>(globalObject))->storedPrototype()));
 }
 
-void callFunctionWithCurrentArguments(JSC::ExecState&, JSC::JSObject& thisObject, JSC::JSFunction&);
-
 template<typename JSClass> inline JSC::EncodedJSValue createJSBuiltin(JSC::ExecState& state, JSC::JSFunction& initializeFunction, JSDOMGlobalObject& globalObject)
 {
     JSC::JSObject* object = JSClass::create(getDOMStructure<JSClass>(globalObject.vm(), globalObject), &globalObject);
@@ -258,7 +447,6 @@
     weakRemove(world.m_wrappers, wrapperKey(domObject), wrapper);
 }
 
-#define CREATE_DOM_WRAPPER(globalObject, className, object) createWrapper<JS##className>(globalObject, static_cast<className*>(object))
 template<typename WrapperClass, typename DOMClass> inline JSDOMObject* createWrapper(JSDOMGlobalObject* globalObject, DOMClass* node)
 {
     ASSERT(node);
@@ -288,44 +476,6 @@
     return createWrapper<WrapperClass>(globalObject, domObject);
 }
 
-void addImpureProperty(const AtomicString&);
-
-const JSC::HashTable& getHashTableForGlobalData(JSC::VM&, const JSC::HashTable& staticTable);
-
-WEBCORE_EXPORT void reportException(JSC::ExecState*, JSC::JSValue exception, CachedScript* = nullptr);
-WEBCORE_EXPORT void reportException(JSC::ExecState*, JSC::Exception*, CachedScript* = nullptr, ExceptionDetails* = nullptr);
-void reportCurrentException(JSC::ExecState*);
-
-JSC::JSValue createDOMException(JSC::ExecState*, ExceptionCode);
-
-// Convert a DOM implementation exception code into a _javascript_ exception in the execution state.
-WEBCORE_EXPORT void setDOMException(JSC::ExecState*, ExceptionCode);
-void setDOMException(JSC::ExecState*, const ExceptionCodeWithMessage&);
-
-JSC::JSValue jsString(JSC::ExecState*, const URL&); // empty if the URL is null
-
-JSC::JSValue jsStringOrNull(JSC::ExecState*, const String&); // null if the string is null
-JSC::JSValue jsStringOrNull(JSC::ExecState*, const URL&); // null if the URL is null
-
-JSC::JSValue jsStringOrUndefined(JSC::ExecState*, const String&); // undefined if the string is null
-JSC::JSValue jsStringOrUndefined(JSC::ExecState*, const URL&); // undefined if the URL is null
-
-// See _javascript_Core for explanation: Should be used for any string that is already owned by another
-// object, to let the engine know that collecting the JSString wrapper is unlikely to save memory.
-JSC::JSValue jsOwnedStringOrNull(JSC::ExecState*, const String&);
-
-String propertyNameToString(JSC::PropertyName);
-
-AtomicString propertyNameToAtomicString(JSC::PropertyName);
-
-// FIXME: This is only used by legacy code and should go away. Use valueToStringTreatingNullAsEmptyString() instead.
-String valueToStringWithNullCheck(JSC::ExecState*, JSC::JSValue); // null if the value is null
-
-String valueToStringTreatingNullAsEmptyString(JSC::ExecState*, JSC::JSValue);
-String valueToStringWithUndefinedOrNullCheck(JSC::ExecState*, JSC::JSValue); // null if the value is null or undefined
-
-template<typename T> JSC::JSValue toNullableJSNumber(Optional<T>); // null if the optional is null
-
 inline int32_t finiteInt32Value(JSC::JSValue value, JSC::ExecState* exec, bool& okay)
 {
     double number = value.toNumber(exec);
@@ -333,24 +483,6 @@
     return JSC::toInt32(number);
 }
 
-enum IntegerConversionConfiguration {
-    NormalConversion,
-    EnforceRange,
-    Clamp
-};
-
-WEBCORE_EXPORT int32_t toInt32EnforceRange(JSC::ExecState*, JSC::JSValue);
-WEBCORE_EXPORT uint32_t toUInt32EnforceRange(JSC::ExecState*, JSC::JSValue);
-
-WEBCORE_EXPORT int32_t toInt32Clamp(JSC::ExecState*, JSC::JSValue);
-WEBCORE_EXPORT uint32_t toUInt32Clamp(JSC::ExecState*, JSC::JSValue);
-
-WEBCORE_EXPORT int8_t toInt8(JSC::ExecState*, JSC::JSValue, IntegerConversionConfiguration);
-WEBCORE_EXPORT uint8_t toUInt8(JSC::ExecState*, JSC::JSValue, IntegerConversionConfiguration);
-
-WEBCORE_EXPORT int16_t toInt16(JSC::ExecState*, JSC::JSValue, IntegerConversionConfiguration);
-WEBCORE_EXPORT uint16_t toUInt16(JSC::ExecState*, JSC::JSValue, IntegerConversionConfiguration);
-
 /*
     Convert a value to an integer as per <http://www.w3.org/TR/WebIDL/>.
     The conversion fails if the value cannot be converted to a number or,
@@ -383,18 +515,6 @@
     return value.toUInt32(exec);
 }
 
-WEBCORE_EXPORT int64_t toInt64(JSC::ExecState*, JSC::JSValue, IntegerConversionConfiguration);
-WEBCORE_EXPORT uint64_t toUInt64(JSC::ExecState*, JSC::JSValue, IntegerConversionConfiguration);
-
-// Returns a Date instance for the specified value, or NaN if the date is not a number.
-JSC::JSValue jsDateOrNaN(JSC::ExecState*, double);
-
-// Returns a Date instance for the specified value, or null if the value is NaN or infinity.
-JSC::JSValue jsDateOrNull(JSC::ExecState*, double);
-
-// NaN if the value can't be converted to a date.
-double valueToDate(JSC::ExecState*, JSC::JSValue);
-
 // Validates that the passed object is a sequence type per section 4.1.13 of the WebIDL spec.
 inline JSC::JSObject* toJSSequence(JSC::ExecState* exec, JSC::JSValue value, unsigned& length)
 {
@@ -550,8 +670,6 @@
     return constructArray(&state, 0, globalObject, args);
 }
 
-WEBCORE_EXPORT JSC::JSValue jsArray(JSC::ExecState*, JSDOMGlobalObject*, PassRefPtr<DOMStringList>);
-
 inline RefPtr<JSC::ArrayBufferView> toArrayBufferView(JSC::JSValue value)
 {
     auto* wrapper = JSC::jsDynamicCast<JSC::JSArrayBufferView*>(value);
@@ -575,7 +693,7 @@
 template<> struct NativeValueTraits<String> {
     static inline bool nativeValue(JSC::ExecState* exec, JSC::JSValue jsValue, String& indexedValue)
     {
-        indexedValue = jsValue.toString(exec)->value(exec);
+        indexedValue = jsValue.toWTFString(exec);
         return true;
     }
 };
@@ -657,7 +775,7 @@
     return result;
 }
 
-template<typename T> Vector<T> toNativeArguments(JSC::ExecState* exec, size_t startIndex = 0)
+template<typename T> Vector<T> toNativeArguments(JSC::ExecState* exec, size_t startIndex)
 {
     size_t length = exec->argumentCount();
     ASSERT(startIndex <= length);
@@ -675,13 +793,6 @@
     return result;
 }
 
-bool shouldAllowAccessToNode(JSC::ExecState*, Node*);
-bool shouldAllowAccessToFrame(JSC::ExecState*, Frame*);
-bool shouldAllowAccessToFrame(JSC::ExecState*, Frame*, String& message);
-bool shouldAllowAccessToDOMWindow(JSC::ExecState*, DOMWindow&, String& message);
-
-void printErrorMessageForFrame(Frame*, const String& message);
-
 inline String propertyNameToString(JSC::PropertyName propertyName)
 {
     ASSERT(!propertyName.isSymbol());
@@ -707,40 +818,14 @@
     return nullptr;
 }
 
-template<JSC::NativeFunction nativeFunction, int length>
-JSC::EncodedJSValue nonCachingStaticFunctionGetter(JSC::ExecState* exec, JSC::EncodedJSValue, JSC::PropertyName propertyName)
+template<JSC::NativeFunction nativeFunction, int length> JSC::EncodedJSValue nonCachingStaticFunctionGetter(JSC::ExecState* exec, JSC::EncodedJSValue, JSC::PropertyName propertyName)
 {
     return JSC::JSValue::encode(JSC::JSFunction::create(exec->vm(), exec->lexicalGlobalObject(), length, propertyName.publicName(), nativeFunction));
 }
 
-enum SecurityReportingOption {
-    DoNotReportSecurityError,
-    ReportSecurityError,
-};
-
-class BindingSecurity {
-public:
-    static bool shouldAllowAccessToNode(JSC::ExecState*, Node*);
-    static bool shouldAllowAccessToDOMWindow(JSC::ExecState*, DOMWindow&, SecurityReportingOption = ReportSecurityError);
-    static bool shouldAllowAccessToFrame(JSC::ExecState*, Frame*, SecurityReportingOption = ReportSecurityError);
-};
-
-inline JSC::JSValue getPropertyFromObject(JSC::ExecState& exec, JSC::JSObject& object, const char* identifier)
-{
-    return object.get(&exec, JSC::Identifier::fromString(&exec, identifier));
-}
-
-inline void setPropertyToObject(JSC::ExecState& exec, JSC::JSObject& object, const char* name, JSC::JSValue value)
-{
-    JSC::PutPropertySlot propertySlot(&object);
-    JSC::JSObject::put(&object, &exec, JSC::Identifier::fromString(&exec, name), value, propertySlot);
-}
-
 template<typename T> inline JSC::JSValue toNullableJSNumber(Optional<T> optionalNumber)
 {
     return optionalNumber ? JSC::jsNumber(optionalNumber.value()) : JSC::jsNull();
 }
 
 } // namespace WebCore
-
-#endif // JSDOMBinding_h

Deleted: trunk/Source/WebCore/bindings/js/JSDOMBuild.h (200546 => 200547)


--- trunk/Source/WebCore/bindings/js/JSDOMBuild.h	2016-05-07 20:04:27 UTC (rev 200546)
+++ trunk/Source/WebCore/bindings/js/JSDOMBuild.h	2016-05-07 21:14:20 UTC (rev 200547)
@@ -1,52 +0,0 @@
-/*
-
-Copyright (C) 2016 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.
-
-THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS 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 APPLE INC. OR ITS 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 "JSDOMBinding.h"
-
-namespace WebCore {
-
-template<typename T> T build(JSC::ExecState&, JSC::JSValue);
-template<typename T, unsigned characterCount> T build(JSC::ExecState&, JSC::JSValue, const char (&propertyName)[characterCount]);
-enum class ShouldAllowNonFinite { No, Yes };
-template<typename T> T build(JSC::ExecState&, JSC::JSValue, ShouldAllowNonFinite);
-
-template<typename T, unsigned characterCount> inline T build(JSC::ExecState& state, JSC::JSValue value, const char (&propertyName)[characterCount])
-{
-    return build<T>(state, value.get(&state, JSC::Identifier::fromString(&state, propertyName)));
-}
-
-template<typename T> inline T build(JSC::ExecState& state, JSC::JSValue value, ShouldAllowNonFinite allowNonFinite)
-{
-    static_assert(std::is_same<T, float>::value || std::is_same<T, double>::value, "Should be called with converting to float or double");
-    double number = value.toNumber(&state);
-    if (allowNonFinite == ShouldAllowNonFinite::No && UNLIKELY(!std::isfinite(number)))
-        throwNonFiniteTypeError(state);
-    return static_cast<T>(number);
-}
-
-}

Copied: trunk/Source/WebCore/bindings/js/JSDOMConvert.h (from rev 200546, trunk/Source/WebCore/bindings/js/JSDOMBuild.h) (0 => 200547)


--- trunk/Source/WebCore/bindings/js/JSDOMConvert.h	                        (rev 0)
+++ trunk/Source/WebCore/bindings/js/JSDOMConvert.h	2016-05-07 21:14:20 UTC (rev 200547)
@@ -0,0 +1,65 @@
+/*
+
+Copyright (C) 2016 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.
+
+THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS 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 APPLE INC. OR ITS 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 "JSDOMBinding.h"
+
+namespace WebCore {
+
+enum class ShouldAllowNonFinite { No, Yes };
+
+template<typename T> T convert(JSC::ExecState&, JSC::JSValue);
+template<typename T> T convert(JSC::ExecState&, JSC::JSValue, ShouldAllowNonFinite);
+
+template<typename T> Optional<T> convertOptional(JSC::ExecState&, JSC::JSValue);
+template<typename T, typename U> T convertOptional(JSC::ExecState&, JSC::JSValue, U&& defaultValue);
+
+template<typename T> Optional<T> inline convertOptional(JSC::ExecState& state, JSC::JSValue value)
+{
+    return value.isUndefined() ? Nullopt : convert<T>(state, value);
+}
+
+template<typename T, typename U> inline T convertOptional(JSC::ExecState& state, JSC::JSValue value, U&& defaultValue)
+{
+    return value.isUndefined() ? std::forward<U>(defaultValue) : convert<T>(state, value);
+}
+
+template<> inline String convert<String>(JSC::ExecState& state, JSC::JSValue value)
+{
+    return value.toWTFString(&state);
+}
+
+template<typename T> inline T convert(JSC::ExecState& state, JSC::JSValue value, ShouldAllowNonFinite allowNonFinite)
+{
+    static_assert(std::is_same<T, float>::value || std::is_same<T, double>::value, "Should be called with converting to float or double");
+    double number = value.toNumber(&state);
+    if (allowNonFinite == ShouldAllowNonFinite::No && UNLIKELY(!std::isfinite(number)))
+        throwNonFiniteTypeError(state);
+    return static_cast<T>(number);
+}
+
+}

Modified: trunk/Source/WebCore/bindings/js/ReadableStreamController.cpp (200546 => 200547)


--- trunk/Source/WebCore/bindings/js/ReadableStreamController.cpp	2016-05-07 20:04:27 UTC (rev 200546)
+++ trunk/Source/WebCore/bindings/js/ReadableStreamController.cpp	2016-05-07 21:14:20 UTC (rev 200547)
@@ -41,15 +41,15 @@
 static inline JSC::JSValue callFunction(JSC::ExecState& state, JSC::JSValue jsFunction, JSC::JSValue thisValue, const JSC::ArgList& arguments)
 {
     JSC::CallData callData;
-    JSC::CallType callType = JSC::getCallData(jsFunction, callData);
-    return JSC::call(&state, jsFunction, callType, callData, thisValue, arguments);
+    auto callType = JSC::getCallData(jsFunction, callData);
+    return call(&state, jsFunction, callType, callData, thisValue, arguments);
 }
 
 JSC::JSValue ReadableStreamController::invoke(JSC::ExecState& state, JSC::JSObject& object, const char* propertyName, JSC::JSValue parameter)
 {
     JSC::JSLockHolder lock(&state);
 
-    JSC::JSValue function = getPropertyFromObject(state, object, propertyName);
+    auto function = object.get(&state, JSC::Identifier::fromString(&state, propertyName));
     if (state.hadException())
         return JSC::jsUndefined();
 
@@ -67,18 +67,18 @@
 
 bool ReadableStreamController::isControlledReadableStreamLocked() const
 {
-    JSC::ExecState& state = *globalObject()->globalExec();
+    auto& state = *globalObject()->globalExec();
     JSC::JSLockHolder lock(&state);
 
-    JSVMClientData& clientData = *static_cast<JSVMClientData*>(state.vm().clientData);
-    JSC::JSValue readableStream = m_jsController->get(&state, clientData.builtinNames().controlledReadableStreamPrivateName());
+    auto& clientData = *static_cast<JSVMClientData*>(state.vm().clientData);
+    auto readableStream = m_jsController->get(&state, clientData.builtinNames().controlledReadableStreamPrivateName());
     ASSERT(!state.hadException());
 
-    JSC::JSValue isLocked = globalObject()->builtinInternalFunctions().readableStreamInternals().m_isReadableStreamLockedFunction.get();
+    auto isLocked = globalObject()->builtinInternalFunctions().readableStreamInternals().m_isReadableStreamLockedFunction.get();
 
     JSC::MarkedArgumentBuffer arguments;
     arguments.append(readableStream);
-    JSC::JSValue result = callFunction(state, isLocked, JSC::jsUndefined(), arguments);
+    auto result = callFunction(state, isLocked, JSC::jsUndefined(), arguments);
     ASSERT(!state.hadException());
 
     return result.isTrue();
@@ -88,29 +88,29 @@
 {
     JSC::JSLockHolder lock(&state);
 
-    JSC::JSValue jsSource = source ? toJS(&state, globalObject, source) : JSC::jsUndefined();
+    auto jsSource = source ? toJS(&state, globalObject, source) : JSC::jsUndefined();
     JSC::Strong<JSC::Unknown> protect(state.vm(), jsSource);
 
     JSC::MarkedArgumentBuffer arguments;
     arguments.append(jsSource);
 
-    JSC::JSValue constructor = JSReadableStream::getConstructor(state.vm(), globalObject);
+    auto constructor = JSReadableStream::getConstructor(state.vm(), globalObject);
 
     JSC::ConstructData constructData;
-    JSC::ConstructType constructType = JSC::getConstructData(constructor, constructData);
+    auto constructType = JSC::getConstructData(constructor, constructData);
     ASSERT(constructType != JSC::ConstructType::None);
 
-    return JSC::construct(&state, constructor, constructType, constructData, arguments);
+    return construct(&state, constructor, constructType, constructData, arguments);
 }
 
 JSC::JSValue getReadableStreamReader(JSC::ExecState& state, JSC::JSValue readableStream)
 {
     ASSERT(readableStream.isObject());
 
-    JSC::JSValue getReader = readableStream.getObject()->get(&state, JSC::Identifier::fromString(&state, "getReader"));
+    auto getReader = readableStream.getObject()->get(&state, JSC::Identifier::fromString(&state, "getReader"));
     ASSERT(!state.hadException());
 
-    JSC::JSValue reader = callFunction(state, getReader, readableStream, JSC::MarkedArgumentBuffer());
+    auto reader = callFunction(state, getReader, readableStream, JSC::MarkedArgumentBuffer());
     ASSERT(!state.hadException());
 
     return reader;

Modified: trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm (200546 => 200547)


--- trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm	2016-05-07 20:04:27 UTC (rev 200546)
+++ trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm	2016-05-07 21:14:20 UTC (rev 200547)
@@ -916,9 +916,9 @@
         $result .= "}\n\n";
 
         # FIXME: A little ugly to have this be a side effect instead of a return value.
-        AddToImplIncludes("JSDOMBuild.h");
+        AddToImplIncludes("JSDOMConvert.h");
 
-        $result .= "template<> $className build<$className>(ExecState& state, JSValue value)\n";
+        $result .= "template<> $className convert<$className>(ExecState& state, JSValue value)\n";
         $result .= "{\n";
         $result .= "    auto result = parse<$className>(state, value);\n";
         $result .= "    if (UNLIKELY(!result)) {\n";
@@ -959,17 +959,30 @@
         my $className = GetDictionaryClassName($interface, $name);
 
         # FIXME: A little ugly to have this be a side effect instead of a return value.
-        AddToImplIncludes("JSDOMBuild.h");
+        AddToImplIncludes("JSDOMConvert.h");
 
-        $result .= "template<> $className build<$className>(ExecState& state, JSValue value)\n";
+        $result .= "template<> $className convert<$className>(ExecState& state, JSValue value)\n";
         $result .= "{\n";
-        $result .= "    return { \n";
-
+        my $needExceptionCheck = 0;
         foreach my $member (@{$dictionary->members}) {
-            $result .= "        build<" . GetNativeTypeFromSignature($interface, $member) . ">(state, value, \"" . $member->name . "\"),\n";
+            if ($needExceptionCheck) {
+                $result .= "    if (UNLIKELY(state.hadException()))\n";
+                $result .= "        return { };\n";
+            }
+            # FIXME: Eventually we will want this to call JSValueToNative.
+            my $function = $member->isOptional ? "convertOptional" : "convert";
+            my $defaultValueWithLeadingComma = $member->isOptional ? ", " . $member->default : "";
+            $result .= "    auto " . $member->name . " = " . $function . "<" . GetNativeTypeFromSignature($interface, $member) . ">"
+                . "(state, propertyValue(state, value, \"" . $member->name . "\")" . $defaultValueWithLeadingComma . ");\n";
+            $needExceptionCheck = 1;
         }
-
-        $result .= "    };\n";
+        $result .= "    return { ";
+        my $comma = "";
+        foreach my $member (@{$dictionary->members}) {
+            $result .= $comma . "WTFMove(" . $member->name . ")";
+            $comma = ", ";
+        }
+        $result .= " };\n";
         $result .= "}\n\n";
 
         $result .= "#endif\n\n" if $conditionalString;
@@ -3586,11 +3599,10 @@
     my $argsIndex = 0;
     foreach my $parameter (@{$function->parameters}) {
         my $argType = $parameter->type;
-        my $optional = $parameter->isOptional;
 
-        die "Optional parameters of non-nullable wrapper types are not supported" if $optional && !$parameter->isNullable && $codeGenerator->IsWrapperType($argType);
+        die "Optional parameters of non-nullable wrapper types are not supported" if $parameter->isOptional && !$parameter->isNullable && $codeGenerator->IsWrapperType($argType);
 
-        if ($optional && !defined($parameter->default)) {
+        if ($parameter->isOptional && !defined($parameter->default)) {
             # As per Web IDL, optional dictionary parameters are always considered to have a default value of an empty dictionary, unless otherwise specified.
             $parameter->default("[]") if $argType eq "Dictionary";
             
@@ -3623,7 +3635,7 @@
         } elsif ($codeGenerator->IsCallbackInterface($argType)) {
             my $callbackClassName = GetCallbackClassName($argType);
             $implIncludes{"$callbackClassName.h"} = 1;
-            if ($optional) {
+            if ($parameter->isOptional) {
                 push(@$outputArray, "    RefPtr<$argType> $name;\n");
                 push(@$outputArray, "    if (!state->argument($argsIndex).isUndefinedOrNull()) {\n");
                 if ($codeGenerator->IsFunctionOnlyCallbackInterface($argType)) {
@@ -3740,7 +3752,7 @@
                 my $inner;
                 my $nativeType = GetNativeTypeFromSignature($interface, $parameter);
 
-                if ($optional && defined($parameter->default) && !WillConvertUndefinedToDefaultParameterValue($parameter->type, $parameter->default)) {
+                if ($parameter->isOptional && defined($parameter->default) && !WillConvertUndefinedToDefaultParameterValue($parameter->type, $parameter->default)) {
                     my $defaultValue = $parameter->default;
 
                     # String-related optimizations.
@@ -3762,7 +3774,7 @@
 
                     $outer = "state->argument($argsIndex).isUndefined() ? $defaultValue : ";
                     $inner = "state->uncheckedArgument($argsIndex)";
-                } elsif ($optional && !defined($parameter->default)) {
+                } elsif ($parameter->isOptional && !defined($parameter->default)) {
                     # Use WTF::Optional<>() for optional parameters that are missing or undefined and that do not have
                     # a default value in the IDL.
                     $outer = "state->argument($argsIndex).isUndefined() ? Optional<$nativeType>() : ";
@@ -4255,6 +4267,7 @@
     return $nativeType{$type} if exists $nativeType{$type};
 
     return GetEnumerationClassName($interface, $type) if $codeGenerator->IsEnumType($type);
+    return GetDictionaryClassName($interface, $type) if $codeGenerator->IsDictionaryType($type);
 
     my $tearOffType = $codeGenerator->GetSVGTypeNeedingTearOff($type);
     return "${tearOffType}*" if $tearOffType;
@@ -4404,11 +4417,11 @@
     return ("$value.toBoolean(state)", 1) if $type eq "boolean";
 
     if ($codeGenerator->IsFloatingPointType($type)) {
-        AddToImplIncludes("JSDOMBuild.h");
-        return ("build<double>(*state, $value, ShouldAllowNonFinite::No)", 1) if $type eq "double";
-        return ("build<double>(*state, $value, ShouldAllowNonFinite::Yes)", 1) if $type eq "unrestricted double";
-        return ("build<float>(*state, $value, ShouldAllowNonFinite::No)", 1) if $type eq "float";
-        return ("build<float>(*state, $value, ShouldAllowNonFinite::Yes)", 1) if $type eq "unrestricted float";
+        AddToImplIncludes("JSDOMConvert.h");
+        return ("convert<double>(*state, $value, ShouldAllowNonFinite::No)", 1) if $type eq "double";
+        return ("convert<double>(*state, $value, ShouldAllowNonFinite::Yes)", 1) if $type eq "unrestricted double";
+        return ("convert<float>(*state, $value, ShouldAllowNonFinite::No)", 1) if $type eq "float";
+        return ("convert<float>(*state, $value, ShouldAllowNonFinite::Yes)", 1) if $type eq "unrestricted float";
         die "Unhandled floating point type: " . $type;
     }
 
@@ -4416,7 +4429,7 @@
 
     return ("to$type($value)", 1) if $codeGenerator->IsTypedArrayType($type);
     return ("parse<" . GetEnumerationClassName($interface, $type) . ">(*state, $value)", 1) if $codeGenerator->IsEnumType($type);
-    return ("build<" . GetDictionaryClassName($interface, $type) . ">(*state, $value)", 1) if $codeGenerator->IsDictionaryType($type);
+    return ("convert<" . GetDictionaryClassName($interface, $type) . ">(*state, $value)", 1) if $codeGenerator->IsDictionaryType($type);
 
     AddToImplIncludes("JS$type.h", $conditional);
 

Modified: trunk/Source/WebCore/bindings/scripts/test/JS/JSTestObj.cpp (200546 => 200547)


--- trunk/Source/WebCore/bindings/scripts/test/JS/JSTestObj.cpp	2016-05-07 20:04:27 UTC (rev 200546)
+++ trunk/Source/WebCore/bindings/scripts/test/JS/JSTestObj.cpp	2016-05-07 21:14:20 UTC (rev 200547)
@@ -29,8 +29,8 @@
 #include "Frame.h"
 #include "HTMLNames.h"
 #include "JSDOMBinding.h"
-#include "JSDOMBuild.h"
 #include "JSDOMConstructor.h"
+#include "JSDOMConvert.h"
 #include "JSDOMIterator.h"
 #include "JSDOMPromise.h"
 #include "JSDOMStringList.h"
@@ -124,7 +124,7 @@
     return Nullopt;
 }
 
-template<> TestObj::EnumType build<TestObj::EnumType>(ExecState& state, JSValue value)
+template<> TestObj::EnumType convert<TestObj::EnumType>(ExecState& state, JSValue value)
 {
     auto result = parse<TestObj::EnumType>(state, value);
     if (UNLIKELY(!result)) {
@@ -174,7 +174,7 @@
     return Nullopt;
 }
 
-template<> TestObj::Optional build<TestObj::Optional>(ExecState& state, JSValue value)
+template<> TestObj::Optional convert<TestObj::Optional>(ExecState& state, JSValue value)
 {
     auto result = parse<TestObj::Optional>(state, value);
     if (UNLIKELY(!result)) {
@@ -214,7 +214,7 @@
     return Nullopt;
 }
 
-template<> TestObj::EnumA build<TestObj::EnumA>(ExecState& state, JSValue value)
+template<> TestObj::EnumA convert<TestObj::EnumA>(ExecState& state, JSValue value)
 {
     auto result = parse<TestObj::EnumA>(state, value);
     if (UNLIKELY(!result)) {
@@ -256,7 +256,7 @@
     return Nullopt;
 }
 
-template<> TestObj::EnumB build<TestObj::EnumB>(ExecState& state, JSValue value)
+template<> TestObj::EnumB convert<TestObj::EnumB>(ExecState& state, JSValue value)
 {
     auto result = parse<TestObj::EnumB>(state, value);
     if (UNLIKELY(!result)) {
@@ -298,7 +298,7 @@
     return Nullopt;
 }
 
-template<> TestObj::EnumC build<TestObj::EnumC>(ExecState& state, JSValue value)
+template<> TestObj::EnumC convert<TestObj::EnumC>(ExecState& state, JSValue value)
 {
     auto result = parse<TestObj::EnumC>(state, value);
     if (UNLIKELY(!result)) {
@@ -342,7 +342,7 @@
     return Nullopt;
 }
 
-template<> TestObj::Kind build<TestObj::Kind>(ExecState& state, JSValue value)
+template<> TestObj::Kind convert<TestObj::Kind>(ExecState& state, JSValue value)
 {
     auto result = parse<TestObj::Kind>(state, value);
     if (UNLIKELY(!result)) {
@@ -384,7 +384,7 @@
     return Nullopt;
 }
 
-template<> TestObj::Size build<TestObj::Size>(ExecState& state, JSValue value)
+template<> TestObj::Size convert<TestObj::Size>(ExecState& state, JSValue value)
 {
     auto result = parse<TestObj::Size>(state, value);
     if (UNLIKELY(!result)) {
@@ -426,7 +426,7 @@
     return Nullopt;
 }
 
-template<> TestObj::Confidence build<TestObj::Confidence>(ExecState& state, JSValue value)
+template<> TestObj::Confidence convert<TestObj::Confidence>(ExecState& state, JSValue value)
 {
     auto result = parse<TestObj::Confidence>(state, value);
     if (UNLIKELY(!result)) {
@@ -468,7 +468,7 @@
     return Nullopt;
 }
 
-template<> TestObj::ShadowRootMode build<TestObj::ShadowRootMode>(ExecState& state, JSValue value)
+template<> TestObj::ShadowRootMode convert<TestObj::ShadowRootMode>(ExecState& state, JSValue value)
 {
     auto result = parse<TestObj::ShadowRootMode>(state, value);
     if (UNLIKELY(!result)) {
@@ -483,13 +483,33 @@
     return "\"open\", \"closed\"";
 }
 
-template<> TestObj::ShadowRootInit build<TestObj::ShadowRootInit>(ExecState& state, JSValue value)
+template<> TestObj::ShadowRootInit convert<TestObj::ShadowRootInit>(ExecState& state, JSValue value)
 {
-    return { 
-        build<TestObj::ShadowRootMode>(state, value, "mode"),
-    };
+    auto mode = convert<TestObj::ShadowRootMode>(state, propertyValue(state, value, "mode"));
+    return { WTFMove(mode) };
 }
 
+template<> TestObj::FontFaceDescriptors convert<TestObj::FontFaceDescriptors>(ExecState& state, JSValue value)
+{
+    auto style = convertOptional<String>(state, propertyValue(state, value, "style"), "normal");
+    if (state.hadException())
+        return { };
+    auto weight = convertOptional<String>(state, propertyValue(state, value, "weight"), "normal");
+    if (state.hadException())
+        return { };
+    auto stretch = convertOptional<String>(state, propertyValue(state, value, "stretch"), "normal");
+    if (state.hadException())
+        return { };
+    auto unicodeRange = convertOptional<String>(state, propertyValue(state, value, "unicodeRange"), "U+0-10FFFF");
+    if (state.hadException())
+        return { };
+    auto variant = convertOptional<String>(state, propertyValue(state, value, "variant"), "normal");
+    if (state.hadException())
+        return { };
+    auto featureSettings = convertOptional<String>(state, propertyValue(state, value, "featureSettings"), "normal");
+    return { WTFMove(style), WTFMove(weight), WTFMove(stretch), WTFMove(unicodeRange), WTFMove(variant), WTFMove(featureSettings) };
+}
+
 // Functions
 
 #if ENABLE(TEST_FEATURE)
@@ -3630,7 +3650,7 @@
         return throwSetterTypeError(*state, "TestObj", "strictFloat");
     }
     auto& impl = castedThis->wrapped();
-    auto nativeValue = build<float>(*state, value, ShouldAllowNonFinite::Yes);
+    auto nativeValue = convert<float>(*state, value, ShouldAllowNonFinite::Yes);
     if (UNLIKELY(state->hadException()))
         return false;
     impl.setStrictFloat(WTFMove(nativeValue));
@@ -4688,7 +4708,7 @@
         return throwThisTypeError(*state, "TestObj", "methodWithOptionalDoubleIsNaN");
     ASSERT_GC_OBJECT_INHERITS(castedThis, JSTestObj::info());
     auto& impl = castedThis->wrapped();
-    auto number = build<double>(*state, state->argument(0), ShouldAllowNonFinite::Yes);
+    auto number = convert<double>(*state, state->argument(0), ShouldAllowNonFinite::Yes);
     if (UNLIKELY(state->hadException()))
         return JSValue::encode(jsUndefined());
     impl.methodWithOptionalDoubleIsNaN(WTFMove(number));
@@ -4703,7 +4723,7 @@
         return throwThisTypeError(*state, "TestObj", "methodWithOptionalFloatIsNaN");
     ASSERT_GC_OBJECT_INHERITS(castedThis, JSTestObj::info());
     auto& impl = castedThis->wrapped();
-    auto number = build<float>(*state, state->argument(0), ShouldAllowNonFinite::Yes);
+    auto number = convert<float>(*state, state->argument(0), ShouldAllowNonFinite::Yes);
     if (UNLIKELY(state->hadException()))
         return JSValue::encode(jsUndefined());
     impl.methodWithOptionalFloatIsNaN(WTFMove(number));
@@ -5692,7 +5712,7 @@
     auto str = state->argument(0).toWTFString(state);
     if (UNLIKELY(state->hadException()))
         return JSValue::encode(jsUndefined());
-    auto a = build<float>(*state, state->argument(1), ShouldAllowNonFinite::Yes);
+    auto a = convert<float>(*state, state->argument(1), ShouldAllowNonFinite::Yes);
     if (UNLIKELY(state->hadException()))
         return JSValue::encode(jsUndefined());
     auto b = toInt32(state, state->argument(2), NormalConversion);
@@ -5784,7 +5804,7 @@
     auto& impl = castedThis->wrapped();
     if (UNLIKELY(state->argumentCount() < 1))
         return throwVMError(state, createNotEnoughArgumentsError(state));
-    auto head = build<double>(*state, state->argument(0), ShouldAllowNonFinite::Yes);
+    auto head = convert<double>(*state, state->argument(0), ShouldAllowNonFinite::Yes);
     if (UNLIKELY(state->hadException()))
         return JSValue::encode(jsUndefined());
     Vector<double> tail = toNativeArguments<double>(state, 1);
@@ -5827,7 +5847,7 @@
     auto& impl = castedThis->wrapped();
     if (UNLIKELY(state->argumentCount() < 2))
         return throwVMError(state, createNotEnoughArgumentsError(state));
-    auto a = build<float>(*state, state->argument(0), ShouldAllowNonFinite::Yes);
+    auto a = convert<float>(*state, state->argument(0), ShouldAllowNonFinite::Yes);
     if (UNLIKELY(state->hadException()))
         return JSValue::encode(jsUndefined());
     auto b = toInt32(state, state->argument(1), NormalConversion);
@@ -5871,7 +5891,7 @@
     auto& impl = castedThis->wrapped();
     if (UNLIKELY(state->argumentCount() < 1))
         return throwVMError(state, createNotEnoughArgumentsError(state));
-    auto a = build<float>(*state, state->argument(0), ShouldAllowNonFinite::No);
+    auto a = convert<float>(*state, state->argument(0), ShouldAllowNonFinite::No);
     if (UNLIKELY(state->hadException()))
         return JSValue::encode(jsUndefined());
     impl.testPromiseFunctionWithFloatArgument(WTFMove(a), DeferredWrapper(state, castedThis->globalObject(), promiseDeferred));
@@ -5935,7 +5955,7 @@
     auto& impl = castedThis->wrapped();
     if (UNLIKELY(state->argumentCount() < 1))
         return throwVMError(state, createNotEnoughArgumentsError(state));
-    auto a = build<float>(*state, state->argument(0), ShouldAllowNonFinite::No);
+    auto a = convert<float>(*state, state->argument(0), ShouldAllowNonFinite::No);
     if (UNLIKELY(state->hadException()))
         return JSValue::encode(jsUndefined());
     impl.testPromiseOverloadedFunction(WTFMove(a), DeferredWrapper(state, castedThis->globalObject(), promiseDeferred));
@@ -6029,7 +6049,7 @@
     auto& impl = castedThis->wrapped();
     if (UNLIKELY(state->argumentCount() < 1))
         return throwVMError(state, createNotEnoughArgumentsError(state));
-    auto init = build<TestObj::ShadowRootInit>(*state, state->argument(0));
+    auto init = convert<TestObj::ShadowRootInit>(*state, state->argument(0));
     if (UNLIKELY(state->hadException()))
         return JSValue::encode(jsUndefined());
     impl.attachShadowRoot(WTFMove(init));

Modified: trunk/Source/WebCore/bindings/scripts/test/JS/JSTestTypedefs.cpp (200546 => 200547)


--- trunk/Source/WebCore/bindings/scripts/test/JS/JSTestTypedefs.cpp	2016-05-07 20:04:27 UTC (rev 200546)
+++ trunk/Source/WebCore/bindings/scripts/test/JS/JSTestTypedefs.cpp	2016-05-07 21:14:20 UTC (rev 200547)
@@ -24,8 +24,8 @@
 #include "DOMStringList.h"
 #include "ExceptionCode.h"
 #include "JSDOMBinding.h"
-#include "JSDOMBuild.h"
 #include "JSDOMConstructor.h"
+#include "JSDOMConvert.h"
 #include "JSDOMStringList.h"
 #include "JSSVGPoint.h"
 #include "JSSerializedScriptValue.h"
@@ -481,19 +481,19 @@
     auto& impl = castedThis->wrapped();
     if (UNLIKELY(state->argumentCount() < 3))
         return throwVMError(state, createNotEnoughArgumentsError(state));
-    auto width = build<float>(*state, state->argument(0), ShouldAllowNonFinite::Yes);
+    auto width = convert<float>(*state, state->argument(0), ShouldAllowNonFinite::Yes);
     if (UNLIKELY(state->hadException()))
         return JSValue::encode(jsUndefined());
-    auto height = build<float>(*state, state->argument(1), ShouldAllowNonFinite::Yes);
+    auto height = convert<float>(*state, state->argument(1), ShouldAllowNonFinite::Yes);
     if (UNLIKELY(state->hadException()))
         return JSValue::encode(jsUndefined());
-    auto blur = build<float>(*state, state->argument(2), ShouldAllowNonFinite::Yes);
+    auto blur = convert<float>(*state, state->argument(2), ShouldAllowNonFinite::Yes);
     if (UNLIKELY(state->hadException()))
         return JSValue::encode(jsUndefined());
     auto color = state->argument(3).isUndefined() ? String() : state->uncheckedArgument(3).toWTFString(state);
     if (UNLIKELY(state->hadException()))
         return JSValue::encode(jsUndefined());
-    auto alpha = state->argument(4).isUndefined() ? Optional<float>() : build<float>(*state, state->uncheckedArgument(4), ShouldAllowNonFinite::Yes);
+    auto alpha = state->argument(4).isUndefined() ? Optional<float>() : convert<float>(*state, state->uncheckedArgument(4), ShouldAllowNonFinite::Yes);
     if (UNLIKELY(state->hadException()))
         return JSValue::encode(jsUndefined());
     impl.setShadow(WTFMove(width), WTFMove(height), WTFMove(blur), WTFMove(color), WTFMove(alpha));

Modified: trunk/Source/WebCore/bindings/scripts/test/TestObj.idl (200546 => 200547)


--- trunk/Source/WebCore/bindings/scripts/test/TestObj.idl	2016-05-07 20:04:27 UTC (rev 200546)
+++ trunk/Source/WebCore/bindings/scripts/test/TestObj.idl	2016-05-07 21:14:20 UTC (rev 200547)
@@ -381,3 +381,12 @@
 dictionary ShadowRootInit {
     required ShadowRootMode mode;
 };
+
+dictionary FontFaceDescriptors {
+    DOMString style = "normal";
+    DOMString weight = "normal";
+    DOMString stretch = "normal";
+    DOMString unicodeRange = "U+0-10FFFF";
+    DOMString variant = "normal";
+    DOMString featureSettings = "normal";
+};

Modified: trunk/Source/WebCore/css/CSSFontFace.cpp (200546 => 200547)


--- trunk/Source/WebCore/css/CSSFontFace.cpp	2016-05-07 20:04:27 UTC (rev 200546)
+++ trunk/Source/WebCore/css/CSSFontFace.cpp	2016-05-07 21:14:20 UTC (rev 200547)
@@ -209,8 +209,8 @@
     m_ranges.clear();
     auto& list = downcast<CSSValueList>(unicodeRange);
     for (auto& rangeValue : list) {
-        CSSUnicodeRangeValue& range = downcast<CSSUnicodeRangeValue>(rangeValue.get());
-        m_ranges.append(UnicodeRange(range.from(), range.to()));
+        auto& range = downcast<CSSUnicodeRangeValue>(rangeValue.get());
+        m_ranges.append({ range.from(), range.to() });
     }
 
     iterateClients(m_clients, [&](Client& client) {
@@ -223,6 +223,7 @@
 bool CSSFontFace::setVariantLigatures(CSSValue& variantLigatures)
 {
     auto ligatures = extractFontVariantLigatures(variantLigatures);
+
     m_variantSettings.commonLigatures = ligatures.commonLigatures;
     m_variantSettings.discretionaryLigatures = ligatures.discretionaryLigatures;
     m_variantSettings.historicalLigatures = ligatures.historicalLigatures;
@@ -239,6 +240,7 @@
 {
     if (!is<CSSPrimitiveValue>(variantPosition))
         return false;
+
     m_variantSettings.position = downcast<CSSPrimitiveValue>(variantPosition);
 
     iterateClients(m_clients, [&](Client& client) {
@@ -252,6 +254,7 @@
 {
     if (!is<CSSPrimitiveValue>(variantCaps))
         return false;
+
     m_variantSettings.caps = downcast<CSSPrimitiveValue>(variantCaps);
 
     iterateClients(m_clients, [&](Client& client) {
@@ -264,6 +267,7 @@
 bool CSSFontFace::setVariantNumeric(CSSValue& variantNumeric)
 {
     auto numeric = extractFontVariantNumeric(variantNumeric);
+
     m_variantSettings.numericFigure = numeric.figure;
     m_variantSettings.numericSpacing = numeric.spacing;
     m_variantSettings.numericFraction = numeric.fraction;
@@ -281,6 +285,7 @@
 {
     if (!is<CSSPrimitiveValue>(variantAlternates))
         return false;
+
     m_variantSettings.alternates = downcast<CSSPrimitiveValue>(variantAlternates);
 
     iterateClients(m_clients, [&](Client& client) {
@@ -293,6 +298,7 @@
 bool CSSFontFace::setVariantEastAsian(CSSValue& variantEastAsian)
 {
     auto eastAsian = extractFontVariantEastAsian(variantEastAsian);
+
     m_variantSettings.eastAsianVariant = eastAsian.variant;
     m_variantSettings.eastAsianWidth = eastAsian.width;
     m_variantSettings.eastAsianRuby = eastAsian.ruby;
@@ -304,23 +310,29 @@
     return true;
 }
 
-bool CSSFontFace::setFeatureSettings(CSSValue& featureSettings)
+void CSSFontFace::setFeatureSettings(CSSValue& featureSettings)
 {
-    if (!is<CSSValueList>(featureSettings))
-        return false;
+    // Can only call this with a primitive value of normal, or a value list containing font feature values.
+    ASSERT(is<CSSPrimitiveValue>(featureSettings) || is<CSSValueList>(featureSettings));
 
-    m_featureSettings = FontFeatureSettings();
-    auto& list = downcast<CSSValueList>(featureSettings);
-    for (auto& rangeValue : list) {
-        CSSFontFeatureValue& feature = downcast<CSSFontFeatureValue>(rangeValue.get());
-        m_featureSettings.insert(FontFeature(feature.tag(), feature.value()));
+    FontFeatureSettings settings;
+
+    if (is<CSSValueList>(featureSettings)) {
+        auto& list = downcast<CSSValueList>(featureSettings);
+        for (auto& rangeValue : list) {
+            auto& feature = downcast<CSSFontFeatureValue>(rangeValue.get());
+            settings.insert({ feature.tag(), feature.value() });
+        }
     }
 
+    if (m_featureSettings == settings)
+        return;
+
+    m_featureSettings = WTFMove(settings);
+
     iterateClients(m_clients, [&](Client& client) {
         client.fontPropertyChanged(*this);
     });
-
-    return true;
 }
 
 bool CSSFontFace::allSourcesFailed() const

Modified: trunk/Source/WebCore/css/CSSFontFace.h (200546 => 200547)


--- trunk/Source/WebCore/css/CSSFontFace.h	2016-05-07 20:04:27 UTC (rev 200546)
+++ trunk/Source/WebCore/css/CSSFontFace.h	2016-05-07 21:14:20 UTC (rev 200547)
@@ -23,8 +23,7 @@
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#ifndef CSSFontFace_h
-#define CSSFontFace_h
+#pragma once
 
 #include "CSSFontFaceRule.h"
 #include "FontFeatureSettings.h"
@@ -61,6 +60,8 @@
     }
     virtual ~CSSFontFace();
 
+    // FIXME: These functions don't need to have boolean return values.
+    // Callers only call this with known-valid CSS values.
     bool setFamilies(CSSValue&);
     bool setStyle(CSSValue&);
     bool setWeight(CSSValue&);
@@ -71,7 +72,7 @@
     bool setVariantNumeric(CSSValue&);
     bool setVariantAlternates(CSSValue&);
     bool setVariantEastAsian(CSSValue&);
-    bool setFeatureSettings(CSSValue&);
+    void setFeatureSettings(CSSValue&);
 
     enum class Status;
     struct UnicodeRange;
@@ -109,8 +110,8 @@
     public:
         virtual ~Client() { }
         virtual void fontLoaded(CSSFontFace&) { }
-        virtual void fontStateChanged(CSSFontFace&, Status oldState, Status newState) { UNUSED_PARAM(oldState); UNUSED_PARAM(newState); }
-        virtual void fontPropertyChanged(CSSFontFace&, CSSValueList* oldFamilies = nullptr) { UNUSED_PARAM(oldFamilies); }
+        virtual void fontStateChanged(CSSFontFace&, Status /*oldState*/, Status /*newState*/) { }
+        virtual void fontPropertyChanged(CSSFontFace&, CSSValueList* /*oldFamilies*/ = nullptr) { }
         virtual void ref() = 0;
         virtual void deref() = 0;
     };
@@ -124,27 +125,11 @@
     //              ||   //  \\   ||
     //              \/  \/    \/  \/
     //             Success    Failure
-    enum class Status {
-        Pending,
-        Loading,
-        TimedOut,
-        Success,
-        Failure
-    };
+    enum class Status { Pending, Loading, TimedOut, Success, Failure };
 
     struct UnicodeRange {
-        UnicodeRange(UChar32 from, UChar32 to)
-            : m_from(from)
-            , m_to(to)
-        {
-        }
-
-        UChar32 from() const { return m_from; }
-        UChar32 to() const { return m_to; }
-
-    private:
-        UChar32 m_from;
-        UChar32 m_to;
+        UChar32 from;
+        UChar32 to;
     };
 
     // We don't guarantee that the FontFace wrapper will be the same every time you ask for it.
@@ -177,5 +162,3 @@
 };
 
 }
-
-#endif

Modified: trunk/Source/WebCore/css/CSSFontSelector.cpp (200546 => 200547)


--- trunk/Source/WebCore/css/CSSFontSelector.cpp	2016-05-07 20:04:27 UTC (rev 200546)
+++ trunk/Source/WebCore/css/CSSFontSelector.cpp	2016-05-07 21:14:20 UTC (rev 200547)
@@ -159,8 +159,8 @@
         return;
     if (variantEastAsian && !fontFace->setVariantEastAsian(*variantEastAsian))
         return;
-    if (featureSettings && !fontFace->setFeatureSettings(*featureSettings))
-        return;
+    if (featureSettings)
+        fontFace->setFeatureSettings(*featureSettings);
 
     CSSFontFace::appendSources(fontFace, srcList, m_document, isInitiatingElementInUserAgentShadowTree);
     if (fontFace->allSourcesFailed())

Modified: trunk/Source/WebCore/css/CSSSegmentedFontFace.cpp (200546 => 200547)


--- trunk/Source/WebCore/css/CSSSegmentedFontFace.cpp	2016-05-07 20:04:27 UTC (rev 200546)
+++ trunk/Source/WebCore/css/CSSSegmentedFontFace.cpp	2016-05-07 21:14:20 UTC (rev 200547)
@@ -62,18 +62,17 @@
 static void appendFontWithInvalidUnicodeRangeIfLoading(FontRanges& ranges, Ref<Font>&& font, const Vector<CSSFontFace::UnicodeRange>& unicodeRanges)
 {
     if (font->isLoading()) {
-        ranges.appendRange(FontRanges::Range(0, 0, WTFMove(font)));
+        ranges.appendRange({ 0, 0, WTFMove(font) });
         return;
     }
 
-    unsigned numRanges = unicodeRanges.size();
-    if (!numRanges) {
-        ranges.appendRange(FontRanges::Range(0, 0x7FFFFFFF, WTFMove(font)));
+    if (unicodeRanges.isEmpty()) {
+        ranges.appendRange({ 0, 0x7FFFFFFF, WTFMove(font) });
         return;
     }
 
-    for (unsigned j = 0; j < numRanges; ++j)
-        ranges.appendRange(FontRanges::Range(unicodeRanges[j].from(), unicodeRanges[j].to(), font.copyRef()));
+    for (auto& range : unicodeRanges)
+        ranges.appendRange({ range.from, range.to, font.copyRef() });
 }
 
 FontRanges CSSSegmentedFontFace::fontRanges(const FontDescription& fontDescription)

Modified: trunk/Source/WebCore/css/FontFace.cpp (200546 => 200547)


--- trunk/Source/WebCore/css/FontFace.cpp	2016-05-07 20:04:27 UTC (rev 200546)
+++ trunk/Source/WebCore/css/FontFace.cpp	2016-05-07 21:14:20 UTC (rev 200547)
@@ -26,81 +26,56 @@
 #include "config.h"
 #include "FontFace.h"
 
-#include "CSSFontFace.h"
 #include "CSSFontFeatureValue.h"
-#include "CSSFontSelector.h"
 #include "CSSUnicodeRangeValue.h"
-#include "CSSValue.h"
 #include "CSSValuePool.h"
-#include "Dictionary.h"
 #include "Document.h"
-#include "ExceptionCode.h"
 #include "FontVariantBuilder.h"
-#include "JSDOMCoreException.h"
 #include "JSFontFace.h"
-#include "ScriptExecutionContext.h"
 #include "StyleProperties.h"
-#include <wtf/text/StringBuilder.h>
 
 namespace WebCore {
 
-static inline Optional<String> valueFromDictionary(const Dictionary& dictionary, const char* key)
+RefPtr<FontFace> FontFace::create(JSC::ExecState& state, Document& document, const String& family, JSC::JSValue source, const Optional<Descriptors>& descriptors, ExceptionCode& ec)
 {
-    String result;
-    dictionary.get(key, result);
-    return result.isNull() ? Nullopt : Optional<String>(result);
-}
+    auto result = adoptRef(*new FontFace(document.fontSelector()));
 
-RefPtr<FontFace> FontFace::create(JSC::ExecState& execState, ScriptExecutionContext& context, const String& family, JSC::JSValue source, const Dictionary& descriptors, ExceptionCode& ec)
-{
-    if (!context.isDocument()) {
-        ec = TypeError;
-        return nullptr;
-    }
-
-    Ref<FontFace> result = adoptRef(*new FontFace(downcast<Document>(context).fontSelector()));
-
     ec = 0;
     result->setFamily(family, ec);
     if (ec)
         return nullptr;
 
     if (source.isString()) {
-        String sourceString = source.toString(&execState)->value(&execState);
-        auto value = FontFace::parseString(sourceString, CSSPropertySrc);
+        auto value = FontFace::parseString(source.getString(&state), CSSPropertySrc);
         if (!is<CSSValueList>(value.get())) {
             ec = SYNTAX_ERR;
             return nullptr;
         }
-        CSSFontFace::appendSources(result->backing(), downcast<CSSValueList>(*value), &downcast<Document>(context), false);
+        CSSFontFace::appendSources(result->backing(), downcast<CSSValueList>(*value), &document, false);
     }
 
-    if (auto style = valueFromDictionary(descriptors, "style"))
-        result->setStyle(style.value(), ec);
-    if (ec)
-        return nullptr;
-    if (auto style = valueFromDictionary(descriptors, "weight"))
-        result->setWeight(style.value(), ec);
-    if (ec)
-        return nullptr;
-    if (auto style = valueFromDictionary(descriptors, "stretch"))
-        result->setStretch(style.value(), ec);
-    if (ec)
-        return nullptr;
-    if (auto style = valueFromDictionary(descriptors, "unicodeRange"))
-        result->setUnicodeRange(style.value(), ec);
-    if (ec)
-        return nullptr;
-    if (auto style = valueFromDictionary(descriptors, "variant"))
-        result->setVariant(style.value(), ec);
-    if (ec)
-        return nullptr;
-    if (auto style = valueFromDictionary(descriptors, "featureSettings"))
-        result->setFeatureSettings(style.value(), ec);
-    if (ec)
-        return nullptr;
+    if (descriptors) {
+        result->setStyle(descriptors->style, ec);
+        if (ec)
+            return nullptr;
+        result->setWeight(descriptors->weight, ec);
+        if (ec)
+            return nullptr;
+        result->setStretch(descriptors->stretch, ec);
+        if (ec)
+            return nullptr;
+        result->setUnicodeRange(descriptors->unicodeRange, ec);
+        if (ec)
+            return nullptr;
+        result->setVariant(descriptors->variant, ec);
+        if (ec)
+            return nullptr;
+        result->setFeatureSettings(descriptors->featureSettings, ec);
+        if (ec)
+            return nullptr;
+    }
 
-    return result.ptr();
+    return WTFMove(result);
 }
 
 Ref<FontFace> FontFace::create(CSSFontFace& face)
@@ -109,10 +84,8 @@
 }
 
 FontFace::FontFace(CSSFontSelector& fontSelector)
-    : m_weakPtrFactory(this)
-    , m_backing(CSSFontFace::create(&fontSelector, nullptr, this))
+    : FontFace(CSSFontFace::create(&fontSelector, nullptr, this))
 {
-    m_backing->addClient(*this);
 }
 
 FontFace::FontFace(CSSFontFace& face)
@@ -134,9 +107,8 @@
 
 RefPtr<CSSValue> FontFace::parseString(const String& string, CSSPropertyID propertyID)
 {
-    Ref<MutableStyleProperties> style = MutableStyleProperties::create();
-    auto result = CSSParser::parseValue(style.ptr(), propertyID, string, true, CSSStrictMode, nullptr);
-    if (result == CSSParser::ParseResult::Error)
+    auto style = MutableStyleProperties::create();
+    if (CSSParser::parseValue(style.ptr(), propertyID, string, true, CSSStrictMode, nullptr) == CSSParser::ParseResult::Error)
         return nullptr;
     return style->getPropertyCSSValue(propertyID);
 }
@@ -184,56 +156,64 @@
 
 void FontFace::setVariant(const String& variant, ExceptionCode& ec)
 {
-    Ref<MutableStyleProperties> style = MutableStyleProperties::create();
+    auto style = MutableStyleProperties::create();
     auto result = CSSParser::parseValue(style.ptr(), CSSPropertyFontVariant, variant, true, CSSStrictMode, nullptr);
-    if (result != CSSParser::ParseResult::Error) {
-        FontVariantSettings backup = m_backing->variantSettings();
-        auto normal = CSSValuePool::singleton().createIdentifierValue(CSSValueNormal);
-        bool success = true;
-        if (auto value = style->getPropertyCSSValue(CSSPropertyFontVariantLigatures))
-            success &= m_backing->setVariantLigatures(*value);
-        else
-            m_backing->setVariantLigatures(normal);
+    if (result == CSSParser::ParseResult::Error) {
+        ec = SYNTAX_ERR;
+        return;
+    }
 
-        if (auto value = style->getPropertyCSSValue(CSSPropertyFontVariantPosition))
-            success &= m_backing->setVariantPosition(*value);
-        else
-            m_backing->setVariantPosition(normal);
+    // FIXME: Would be much better to stage the new settings and set them all at once
+    // instead of this dance where we make a backup and revert to it if something fails.
+    FontVariantSettings backup = m_backing->variantSettings();
 
-        if (auto value = style->getPropertyCSSValue(CSSPropertyFontVariantCaps))
-            success &= m_backing->setVariantCaps(*value);
-        else
-            m_backing->setVariantCaps(normal);
+    auto normal = CSSValuePool::singleton().createIdentifierValue(CSSValueNormal);
+    bool success = true;
 
-        if (auto value = style->getPropertyCSSValue(CSSPropertyFontVariantNumeric))
-            success &= m_backing->setVariantNumeric(*value);
-        else
-            m_backing->setVariantNumeric(normal);
+    if (auto value = style->getPropertyCSSValue(CSSPropertyFontVariantLigatures))
+        success &= m_backing->setVariantLigatures(*value);
+    else
+        m_backing->setVariantLigatures(normal);
 
-        if (auto value = style->getPropertyCSSValue(CSSPropertyFontVariantAlternates))
-            success &= m_backing->setVariantAlternates(*value);
-        else
-            m_backing->setVariantAlternates(normal);
+    if (auto value = style->getPropertyCSSValue(CSSPropertyFontVariantPosition))
+        success &= m_backing->setVariantPosition(*value);
+    else
+        m_backing->setVariantPosition(normal);
 
-        if (auto value = style->getPropertyCSSValue(CSSPropertyFontVariantEastAsian))
-            success &= m_backing->setVariantEastAsian(*value);
-        else
-            m_backing->setVariantEastAsian(normal);
+    if (auto value = style->getPropertyCSSValue(CSSPropertyFontVariantCaps))
+        success &= m_backing->setVariantCaps(*value);
+    else
+        m_backing->setVariantCaps(normal);
 
-        if (success)
-            return;
+    if (auto value = style->getPropertyCSSValue(CSSPropertyFontVariantNumeric))
+        success &= m_backing->setVariantNumeric(*value);
+    else
+        m_backing->setVariantNumeric(normal);
+
+    if (auto value = style->getPropertyCSSValue(CSSPropertyFontVariantAlternates))
+        success &= m_backing->setVariantAlternates(*value);
+    else
+        m_backing->setVariantAlternates(normal);
+
+    if (auto value = style->getPropertyCSSValue(CSSPropertyFontVariantEastAsian))
+        success &= m_backing->setVariantEastAsian(*value);
+    else
+        m_backing->setVariantEastAsian(normal);
+
+    if (!success) {
         m_backing->setVariantSettings(backup);
+        ec = SYNTAX_ERR;
     }
-    ec = SYNTAX_ERR;
 }
 
 void FontFace::setFeatureSettings(const String& featureSettings, ExceptionCode& ec)
 {
-    bool success = false;
-    if (auto value = parseString(featureSettings, CSSPropertyFontFeatureSettings))
-        success = m_backing->setFeatureSettings(*value);
-    if (!success)
+    auto value = parseString(featureSettings, CSSPropertyFontFeatureSettings);
+    if (!value) {
         ec = SYNTAX_ERR;
+        return;
+    }
+    m_backing->setFeatureSettings(*value);
 }
 
 String FontFace::family() const
@@ -290,7 +270,7 @@
         return "U+0-10FFFF";
     RefPtr<CSSValueList> values = CSSValueList::createCommaSeparated();
     for (auto& range : m_backing->ranges())
-        values->append(CSSUnicodeRangeValue::create(range.from(), range.to()));
+        values->append(CSSUnicodeRangeValue::create(range.from, range.to));
     return values->cssText();
 }
 

Modified: trunk/Source/WebCore/css/FontFace.h (200546 => 200547)


--- trunk/Source/WebCore/css/FontFace.h	2016-05-07 20:04:27 UTC (rev 200546)
+++ trunk/Source/WebCore/css/FontFace.h	2016-05-07 21:14:20 UTC (rev 200547)
@@ -23,28 +23,26 @@
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#ifndef FontFace_h
-#define FontFace_h
+#pragma once
 
 #include "CSSFontFace.h"
 #include "CSSPropertyNames.h"
 #include "JSDOMPromise.h"
-#include <wtf/RefCounted.h>
-#include <wtf/RefPtr.h>
 #include <wtf/WeakPtr.h>
-#include <wtf/text/WTFString.h>
 
 namespace WebCore {
 
-class CSSFontFace;
-class CSSValue;
-class Dictionary;
-
-using ExceptionCode = int;
-
-class FontFace final : public RefCounted<FontFace>, public CSSFontFace::Client {
+class FontFace final : public RefCounted<FontFace>, private CSSFontFace::Client {
 public:
-    static RefPtr<FontFace> create(JSC::ExecState&, ScriptExecutionContext&, const String& family, JSC::JSValue source, const Dictionary& descriptors, ExceptionCode&);
+    struct Descriptors {
+        String style;
+        String weight;
+        String stretch;
+        String unicodeRange;
+        String variant;
+        String featureSettings;
+    };
+    static RefPtr<FontFace> create(JSC::ExecState&, Document&, const String& family, JSC::JSValue source, const Optional<Descriptors>&, ExceptionCode&);
     static Ref<FontFace> create(CSSFontFace&);
     virtual ~FontFace();
 
@@ -76,17 +74,16 @@
 
     static RefPtr<CSSValue> parseString(const String&, CSSPropertyID);
 
-    void fontStateChanged(CSSFontFace&, CSSFontFace::Status oldState, CSSFontFace::Status newState) override;
+    void fontStateChanged(CSSFontFace&, CSSFontFace::Status oldState, CSSFontFace::Status newState) final;
 
     WeakPtr<FontFace> createWeakPtr() const;
 
-    // CSSFontFace::Client needs to be able to be held in a RefPtr.
-    void ref() override { RefCounted<FontFace>::ref(); }
-    void deref() override { RefCounted<FontFace>::deref(); }
+    void ref() final { RefCounted::ref(); }
+    void deref() final { RefCounted::deref(); }
 
 private:
-    FontFace(CSSFontSelector&);
-    FontFace(CSSFontFace&);
+    explicit FontFace(CSSFontSelector&);
+    explicit FontFace(CSSFontFace&);
 
     WeakPtrFactory<FontFace> m_weakPtrFactory;
     Ref<CSSFontFace> m_backing;
@@ -94,5 +91,3 @@
 };
 
 }
-
-#endif

Modified: trunk/Source/WebCore/css/FontFace.idl (200546 => 200547)


--- trunk/Source/WebCore/css/FontFace.idl	2016-05-07 20:04:27 UTC (rev 200546)
+++ trunk/Source/WebCore/css/FontFace.idl	2016-05-07 21:14:20 UTC (rev 200547)
@@ -30,10 +30,19 @@
     "error"
 };
 
+dictionary FontFaceDescriptors {
+    DOMString style = "normal";
+    DOMString weight = "normal";
+    DOMString stretch = "normal";
+    DOMString unicodeRange = "U+0-10FFFF";
+    DOMString variant = "normal";
+    DOMString featureSettings = "normal";
+};
+
 [
-    ConstructorCallWith=ScriptExecutionContext&ScriptState,
+    ConstructorCallWith=Document&ScriptState,
     ConstructorRaisesException,
-    Constructor(DOMString family, any source, Dictionary descriptors)
+    Constructor(DOMString family, any source, optional FontFaceDescriptors descriptors)
 ] interface FontFace {
     [SetterRaisesException] attribute DOMString family;
     [SetterRaisesException] attribute DOMString style;

Modified: trunk/Tools/ChangeLog (200546 => 200547)


--- trunk/Tools/ChangeLog	2016-05-07 20:04:27 UTC (rev 200546)
+++ trunk/Tools/ChangeLog	2016-05-07 21:14:20 UTC (rev 200547)
@@ -1,3 +1,13 @@
+2016-05-07  Darin Adler  <[email protected]>
+
+        Next step on dictionary bindings, along with other bindings refinements
+        https://bugs.webkit.org/show_bug.cgi?id=157451
+
+        Reviewed by Chris Dumez.
+
+        * Scripts/do-webcore-rename: Use this to rename JSDOMBuild.h to JSDOMConvert.h.
+        Also skip test expectations in a directory that this was modifying unnecessarily.
+
 2016-05-06  Simon Fraser  <[email protected]>
 
         Enable IOS_TEXT_AUTOSIZING on Mac and make it testable

Modified: trunk/Tools/Scripts/do-webcore-rename (200546 => 200547)


--- trunk/Tools/Scripts/do-webcore-rename	2016-05-07 20:04:27 UTC (rev 200546)
+++ trunk/Tools/Scripts/do-webcore-rename	2016-05-07 21:14:20 UTC (rev 200547)
@@ -62,6 +62,7 @@
 }
 
 my @directoriesToIgnoreList = (
+    "expected",
     "icu",
 );
 my %directoriesToIgnore = map { $_ => 1 } @directoriesToIgnoreList;
@@ -98,7 +99,7 @@
 my $isDOMTypeRename = 0;
 my %renames = (
     # Renames go here in the form of:
-    "CaseFoldingHash" => "ASCIICaseInsensitiveHash",
+    "JSDOMBuild" => "JSDOMConvert",
 );
 
 my %renamesContemplatedForTheFuture = (
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to