Title: [209864] trunk
Revision
209864
Author
[email protected]
Date
2016-12-15 09:25:53 -0800 (Thu, 15 Dec 2016)

Log Message

Remove custom binding for MediaDevices
https://bugs.webkit.org/show_bug.cgi?id=165894

Reviewed by Eric Carlson.

Source/WebCore:

Removes the explicit code to parse the MediaStreamConstraints and
MediaTrackConstraints. Next step could be to change the internal
code to use the structs from bindings directly so we don't need
code to convert to an internal format.

* CMakeLists.txt: Added MediaTrackConstraints.idl and MediaTrackConstraints.cpp,
removed JSMediaDevicesCustom.cpp.

* DerivedSources.make: Added MediaTrackConstraints.idl.
Also sorted list of IDL files and fixed use of tabs.

* Modules/mediastream/MediaDevices.cpp:
(WebCore::createMediaConstraintsImpl): Added.
(WebCore::MediaDevices::getUserMedia): Changed this function to take arguments that
are generated by the bindings script, and call createMediaConstraintsImpl to convert
into the internal data structure.
* Modules/mediastream/MediaDevices.h: Added StreamConstraints struct and changed
getUserMedia to take that as specified in the IDL.
* Modules/mediastream/MediaDevices.idl: Added definition of the MediaStreamConstraints
dictionary. Removed [Custom] from getUserMedia.

* Modules/mediastream/MediaStream.cpp:
(WebCore::MediaStream::MediaStream): Pass a reference to addObserver.
(WebCore::MediaStream::~MediaStream): Pass a rference to removeObserver.
(WebCore::MediaStream::internalAddTrack): Ditto.
(WebCore::MediaStream::internalRemoveTrack): Ditto.

* Modules/mediastream/MediaStreamTrack.cpp:
(WebCore::createMediaConstraintsImpl): Added.
(WebCore::MediaStreamTrack::applyConstraints): Changed to take an optional
MediaTrackConstraints argument and call createMediaConstraintsImpl to convert
into the internal data structure. Also merged the multiple overloads of this
all into a single function, used auto to make the code easier to read, and
moved the code that stores new constrains into the success handling, since the
specification says that's the only case where we should store it.
(WebCore::MediaStreamTrack::addObserver): Take a reference instead of a pointer.
(WebCore::MediaStreamTrack::removeObserver): Ditto.
* Modules/mediastream/MediaStreamTrack.h: Removed many unneeded includes.
Changed getConstraints to return const MediaTrackConstraints&, applyConstraints
to take an optional MediaTrackConstraints, add/removeObserver to take a reference
rather than a pointer, and changed m_constraints to be a MediaTrackConstraints
instead of a RefPtr<MediaConstraints>.
* Modules/mediastream/MediaStreamTrack.idl: Removed [Custom] from getConstraints
and applyConstraints.

* Modules/mediastream/MediaTrackConstraints.cpp: Added.
(WebCore::set): Overloaded function to set constriaints in a
MediaTrackConstraintSetMap.
(WebCore::convertToInternalForm): Helper function that takes a
MediaTrackConstraintSet and turns it into a MediaTrackConstraintSetMap.
(WebCore::convertAdvancedToInternalForm): More of the same, but for vectors.
(WebCore::createMediaConstraintsImpl): Top level function. Calls the other
functions and then MediaConstraintsImpl::create.
* Modules/mediastream/MediaTrackConstraints.h: Added. Contains all the structures
and type definitions for the dictionaries defined in the IDL file, and also the
createMediaConstraintsImpl function declaration.
* Modules/mediastream/MediaTrackConstraints.idl: Added. Contains the
MediaTrackConstraints and all the other dictionaries and typedefs that are needed
to define that dictionary.
* Modules/mediastream/UserMediaRequest.cpp:
(WebCore::UserMediaRequest::start): Changed to not depend on MediaDevices::Promise.
(WebCore::UserMediaRequest::UserMediaRequest): Ditto.
(WebCore::isSecure): Rearranged to be easier to understand.
(WebCore::UserMediaRequest::start): Removed a local variable for simplicity.
(WebCore::UserMediaRequest::document): Removed a redundant null check.
* Modules/mediastream/UserMediaRequest.h: Reduced includes, changed to not depend
on MediaDevices::Promise, removing the reason to include MediaDevices.h.

* WebCore.xcodeproj/project.pbxproj: Updated to remove old files and add new ones.

* bindings/js/JSBindingsAllInOne.cpp: Removed JSMediaDevicesCustom.cpp.

* bindings/js/JSMediaDevicesCustom.cpp: Removed.
* bindings/js/JSMediaDevicesCustom.h: Removed.

* bindings/js/JSMediaStreamTrackCustom.cpp:
(WebCore::JSMediaStreamTrack::applyConstraints): Deleted.
(WebCore::JSMediaStreamTrack::getConstraints): Deleted.

* bindings/scripts/CodeGenerator.pm:
(ProcessDocument): Updated to allow multiple standalone dictionaries, as long as
the name of one of the dictionaries matches the name of the file.

* bindings/scripts/CodeGeneratorJS.pm:
(GenerateDictionary): Added "other dictionaries" argument so we can support
files with multiple dictionaries in them.
(GenerateDictionariesHeaderContent): Completed support for dictionaries that
are not named after a top level interface by added one more check for a missing
$interface in a place that otherwise would not handle it correctly.
(GenerateImplementation): Removed code that set $currentCachedAttribute and
$cacheIndex, since no was reading the value of either any longer.
(GenerateDictionaryHeader): Added "other dictionaries".
(GenerateDictionaryImplementation): Ditto.
(WriteData): Removed unnnecessarily indirect code that was using FileNamePrefix
and a local variable named $prefix instead of just writing "JS".

* bindings/scripts/generate-bindings.pl: Corrected the use of the fileparse
function from the Path::Basename module; after reading the documentation for
this it is clear that there is no need to first call basename, and fileparse
should also be used instead of basename.

* platform/mediastream/MediaConstraints.h: Removed unneeded includes.
(WebCore::StringConstraint::appendExact): Removed an incorrect use of clear
here that would mess up cases where there is supposed to be more than one
exact value.

* platform/mediastream/MediaStreamTrackPrivate.cpp: Remvoed unneeded includes.
(WebCore::MediaStreamTrackPrivate::clone): Removed code to copy m_constraints.
(WebCore::MediaStreamTrackPrivate::constraints): Deleted.
* platform/mediastream/MediaStreamTrackPrivate.h: Removed the constraints
function member and the m_constraints data member.

Source/WebKit2:

* WebProcess/MediaStream/UserMediaPermissionRequestManager.cpp:
Added include of MediaConstraintsImpl.h, now needed because we
removed some unneeded includes from the WebCore headers.

LayoutTests:

* fast/mediastream/MediaDevices-getUserMedia-expected.txt: Expect the exception the
generated bindings code throws, rather than the different one the hand-written binding
was throwing before.

Modified Paths

Added Paths

Removed Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (209863 => 209864)


--- trunk/LayoutTests/ChangeLog	2016-12-15 16:53:38 UTC (rev 209863)
+++ trunk/LayoutTests/ChangeLog	2016-12-15 17:25:53 UTC (rev 209864)
@@ -1,3 +1,14 @@
+2016-12-15  Darin Adler  <[email protected]>
+
+        Remove custom binding for MediaDevices
+        https://bugs.webkit.org/show_bug.cgi?id=165894
+
+        Reviewed by Eric Carlson.
+
+        * fast/mediastream/MediaDevices-getUserMedia-expected.txt: Expect the exception the
+        generated bindings code throws, rather than the different one the hand-written binding
+        was throwing before.
+
 2016-12-15  Youenn Fablet  <[email protected]>
 
         Sync web-platform-tests up to revision a4c2b37

Modified: trunk/LayoutTests/fast/mediastream/MediaDevices-getUserMedia-expected.txt (209863 => 209864)


--- trunk/LayoutTests/fast/mediastream/MediaDevices-getUserMedia-expected.txt	2016-12-15 16:53:38 UTC (rev 209863)
+++ trunk/LayoutTests/fast/mediastream/MediaDevices-getUserMedia-expected.txt	2016-12-15 17:25:53 UTC (rev 209864)
@@ -5,7 +5,7 @@
 
 PASS typeof navigator.mediaDevices.webkitGetUserMedia is 'undefined'
 PASS navigator.mediaDevices.getUserMedia({audio:true}).then(gotStream1); did not throw exception.
-PASS navigator.mediaDevices.getUserMedia() rejected with error: TypeError: Not enough arguments
+PASS navigator.mediaDevices.getUserMedia() rejected with error: TypeError: Type error
 PASS navigator.mediaDevices.getUserMedia({}) rejected with error: TypeError: Type error
 PASS navigator.mediaDevices.getUserMedia.apply(undefined) rejected with error: TypeError: Can only call MediaDevices.getUserMedia on instances of MediaDevices
 PASS Stream generated.

Modified: trunk/Source/WebCore/CMakeLists.txt (209863 => 209864)


--- trunk/Source/WebCore/CMakeLists.txt	2016-12-15 16:53:38 UTC (rev 209863)
+++ trunk/Source/WebCore/CMakeLists.txt	2016-12-15 17:25:53 UTC (rev 209864)
@@ -219,6 +219,7 @@
     Modules/mediastream/MediaStreamEvent.idl
     Modules/mediastream/MediaStreamTrack.idl
     Modules/mediastream/MediaStreamTrackEvent.idl
+    Modules/mediastream/MediaTrackConstraints.idl
     Modules/mediastream/MediaTrackSupportedConstraints.idl
     Modules/mediastream/NavigatorMediaDevices.idl
     Modules/mediastream/NavigatorUserMedia.idl
@@ -907,6 +908,7 @@
     Modules/mediastream/MediaStreamRegistry.cpp
     Modules/mediastream/MediaStreamTrack.cpp
     Modules/mediastream/MediaStreamTrackEvent.cpp
+    Modules/mediastream/MediaTrackConstraints.cpp
     Modules/mediastream/NavigatorMediaDevices.cpp
     Modules/mediastream/PeerConnectionBackend.cpp
     Modules/mediastream/RTCDTMFSender.cpp
@@ -1162,7 +1164,6 @@
     bindings/js/JSLazyEventListener.cpp
     bindings/js/JSLocationCustom.cpp
     bindings/js/JSMainThreadExecState.cpp
-    bindings/js/JSMediaDevicesCustom.cpp
     bindings/js/JSMediaKeySessionCustom.cpp
     bindings/js/JSMediaKeySystemAccessCustom.cpp
     bindings/js/JSMediaStreamTrackCustom.cpp

Modified: trunk/Source/WebCore/ChangeLog (209863 => 209864)


--- trunk/Source/WebCore/ChangeLog	2016-12-15 16:53:38 UTC (rev 209863)
+++ trunk/Source/WebCore/ChangeLog	2016-12-15 17:25:53 UTC (rev 209864)
@@ -1,3 +1,122 @@
+2016-12-15  Darin Adler  <[email protected]>
+
+        Remove custom binding for MediaDevices
+        https://bugs.webkit.org/show_bug.cgi?id=165894
+
+        Reviewed by Eric Carlson.
+
+        Removes the explicit code to parse the MediaStreamConstraints and
+        MediaTrackConstraints. Next step could be to change the internal
+        code to use the structs from bindings directly so we don't need
+        code to convert to an internal format.
+
+        * CMakeLists.txt: Added MediaTrackConstraints.idl and MediaTrackConstraints.cpp,
+        removed JSMediaDevicesCustom.cpp.
+
+        * DerivedSources.make: Added MediaTrackConstraints.idl.
+        Also sorted list of IDL files and fixed use of tabs.
+
+        * Modules/mediastream/MediaDevices.cpp:
+        (WebCore::createMediaConstraintsImpl): Added.
+        (WebCore::MediaDevices::getUserMedia): Changed this function to take arguments that
+        are generated by the bindings script, and call createMediaConstraintsImpl to convert
+        into the internal data structure.
+        * Modules/mediastream/MediaDevices.h: Added StreamConstraints struct and changed
+        getUserMedia to take that as specified in the IDL.
+        * Modules/mediastream/MediaDevices.idl: Added definition of the MediaStreamConstraints
+        dictionary. Removed [Custom] from getUserMedia.
+
+        * Modules/mediastream/MediaStream.cpp:
+        (WebCore::MediaStream::MediaStream): Pass a reference to addObserver.
+        (WebCore::MediaStream::~MediaStream): Pass a rference to removeObserver.
+        (WebCore::MediaStream::internalAddTrack): Ditto.
+        (WebCore::MediaStream::internalRemoveTrack): Ditto.
+
+        * Modules/mediastream/MediaStreamTrack.cpp:
+        (WebCore::createMediaConstraintsImpl): Added.
+        (WebCore::MediaStreamTrack::applyConstraints): Changed to take an optional
+        MediaTrackConstraints argument and call createMediaConstraintsImpl to convert
+        into the internal data structure. Also merged the multiple overloads of this
+        all into a single function, used auto to make the code easier to read, and
+        moved the code that stores new constrains into the success handling, since the
+        specification says that's the only case where we should store it.
+        (WebCore::MediaStreamTrack::addObserver): Take a reference instead of a pointer.
+        (WebCore::MediaStreamTrack::removeObserver): Ditto.
+        * Modules/mediastream/MediaStreamTrack.h: Removed many unneeded includes.
+        Changed getConstraints to return const MediaTrackConstraints&, applyConstraints
+        to take an optional MediaTrackConstraints, add/removeObserver to take a reference
+        rather than a pointer, and changed m_constraints to be a MediaTrackConstraints
+        instead of a RefPtr<MediaConstraints>.
+        * Modules/mediastream/MediaStreamTrack.idl: Removed [Custom] from getConstraints
+        and applyConstraints.
+
+        * Modules/mediastream/MediaTrackConstraints.cpp: Added.
+        (WebCore::set): Overloaded function to set constriaints in a
+        MediaTrackConstraintSetMap.
+        (WebCore::convertToInternalForm): Helper function that takes a
+        MediaTrackConstraintSet and turns it into a MediaTrackConstraintSetMap.
+        (WebCore::convertAdvancedToInternalForm): More of the same, but for vectors.
+        (WebCore::createMediaConstraintsImpl): Top level function. Calls the other
+        functions and then MediaConstraintsImpl::create.
+        * Modules/mediastream/MediaTrackConstraints.h: Added. Contains all the structures
+        and type definitions for the dictionaries defined in the IDL file, and also the
+        createMediaConstraintsImpl function declaration.
+        * Modules/mediastream/MediaTrackConstraints.idl: Added. Contains the
+        MediaTrackConstraints and all the other dictionaries and typedefs that are needed
+        to define that dictionary.
+        * Modules/mediastream/UserMediaRequest.cpp:
+        (WebCore::UserMediaRequest::start): Changed to not depend on MediaDevices::Promise.
+        (WebCore::UserMediaRequest::UserMediaRequest): Ditto.
+        (WebCore::isSecure): Rearranged to be easier to understand.
+        (WebCore::UserMediaRequest::start): Removed a local variable for simplicity.
+        (WebCore::UserMediaRequest::document): Removed a redundant null check.
+        * Modules/mediastream/UserMediaRequest.h: Reduced includes, changed to not depend
+        on MediaDevices::Promise, removing the reason to include MediaDevices.h.
+
+        * WebCore.xcodeproj/project.pbxproj: Updated to remove old files and add new ones.
+
+        * bindings/js/JSBindingsAllInOne.cpp: Removed JSMediaDevicesCustom.cpp.
+
+        * bindings/js/JSMediaDevicesCustom.cpp: Removed.
+        * bindings/js/JSMediaDevicesCustom.h: Removed.
+
+        * bindings/js/JSMediaStreamTrackCustom.cpp:
+        (WebCore::JSMediaStreamTrack::applyConstraints): Deleted.
+        (WebCore::JSMediaStreamTrack::getConstraints): Deleted.
+
+        * bindings/scripts/CodeGenerator.pm:
+        (ProcessDocument): Updated to allow multiple standalone dictionaries, as long as
+        the name of one of the dictionaries matches the name of the file.
+
+        * bindings/scripts/CodeGeneratorJS.pm:
+        (GenerateDictionary): Added "other dictionaries" argument so we can support
+        files with multiple dictionaries in them.
+        (GenerateDictionariesHeaderContent): Completed support for dictionaries that
+        are not named after a top level interface by added one more check for a missing
+        $interface in a place that otherwise would not handle it correctly.
+        (GenerateImplementation): Removed code that set $currentCachedAttribute and
+        $cacheIndex, since no was reading the value of either any longer.
+        (GenerateDictionaryHeader): Added "other dictionaries".
+        (GenerateDictionaryImplementation): Ditto.
+        (WriteData): Removed unnnecessarily indirect code that was using FileNamePrefix
+        and a local variable named $prefix instead of just writing "JS".
+
+        * bindings/scripts/generate-bindings.pl: Corrected the use of the fileparse
+        function from the Path::Basename module; after reading the documentation for
+        this it is clear that there is no need to first call basename, and fileparse
+        should also be used instead of basename.
+
+        * platform/mediastream/MediaConstraints.h: Removed unneeded includes.
+        (WebCore::StringConstraint::appendExact): Removed an incorrect use of clear
+        here that would mess up cases where there is supposed to be more than one
+        exact value.
+
+        * platform/mediastream/MediaStreamTrackPrivate.cpp: Remvoed unneeded includes.
+        (WebCore::MediaStreamTrackPrivate::clone): Removed code to copy m_constraints.
+        (WebCore::MediaStreamTrackPrivate::constraints): Deleted.
+        * platform/mediastream/MediaStreamTrackPrivate.h: Removed the constraints
+        function member and the m_constraints data member.
+
 2016-12-15  Dave Hyatt  <[email protected]>
 
         [CSS Parser] Enable CSS Deferred Parsing

Modified: trunk/Source/WebCore/DerivedSources.make (209863 => 209864)


--- trunk/Source/WebCore/DerivedSources.make	2016-12-15 16:53:38 UTC (rev 209863)
+++ trunk/Source/WebCore/DerivedSources.make	2016-12-15 17:25:53 UTC (rev 209864)
@@ -152,6 +152,7 @@
     $(WebCore)/Modules/mediastream/MediaStreamEvent.idl \
     $(WebCore)/Modules/mediastream/MediaStreamTrack.idl \
     $(WebCore)/Modules/mediastream/MediaStreamTrackEvent.idl \
+    $(WebCore)/Modules/mediastream/MediaTrackConstraints.idl \
     $(WebCore)/Modules/mediastream/MediaTrackSupportedConstraints.idl \
     $(WebCore)/Modules/mediastream/NavigatorMediaDevices.idl \
     $(WebCore)/Modules/mediastream/NavigatorUserMedia.idl \
@@ -254,6 +255,9 @@
     $(WebCore)/crypto/CryptoKeyPair.idl \
     $(WebCore)/crypto/CryptoKeyUsage.idl \
     $(WebCore)/crypto/JsonWebKey.idl \
+    $(WebCore)/crypto/RsaOtherPrimesInfo.idl \
+    $(WebCore)/crypto/SubtleCrypto.idl \
+    $(WebCore)/crypto/WebKitSubtleCrypto.idl \
     $(WebCore)/crypto/parameters/AesCbcParams.idl \
     $(WebCore)/crypto/parameters/AesKeyGenParams.idl \
     $(WebCore)/crypto/parameters/HmacKeyParams.idl \
@@ -261,9 +265,6 @@
     $(WebCore)/crypto/parameters/RsaHashedKeyGenParams.idl \
     $(WebCore)/crypto/parameters/RsaKeyGenParams.idl \
     $(WebCore)/crypto/parameters/RsaOaepParams.idl \
-    $(WebCore)/crypto/RsaOtherPrimesInfo.idl \
-    $(WebCore)/crypto/SubtleCrypto.idl \
-    $(WebCore)/crypto/WebKitSubtleCrypto.idl \
     $(WebCore)/css/CSSFontFaceLoadEvent.idl \
     $(WebCore)/css/CSSFontFaceRule.idl \
     $(WebCore)/css/CSSImportRule.idl \
@@ -270,7 +271,7 @@
     $(WebCore)/css/CSSKeyframeRule.idl \
     $(WebCore)/css/CSSKeyframesRule.idl \
     $(WebCore)/css/CSSMediaRule.idl \
-	$(WebCore)/css/CSSNamespaceRule.idl \
+    $(WebCore)/css/CSSNamespaceRule.idl \
     $(WebCore)/css/CSSPageRule.idl \
     $(WebCore)/css/CSSPrimitiveValue.idl \
     $(WebCore)/css/CSSRule.idl \
@@ -307,8 +308,8 @@
     $(WebCore)/dom/ChildNode.idl \
     $(WebCore)/dom/ClientRect.idl \
     $(WebCore)/dom/ClientRectList.idl \
+    $(WebCore)/dom/ClipboardEvent.idl \
     $(WebCore)/dom/Comment.idl \
-    $(WebCore)/dom/ClipboardEvent.idl \
     $(WebCore)/dom/CompositionEvent.idl \
     $(WebCore)/dom/CustomElementRegistry.idl \
     $(WebCore)/dom/CustomEvent.idl \

Modified: trunk/Source/WebCore/Modules/mediastream/MediaDevices.cpp (209863 => 209864)


--- trunk/Source/WebCore/Modules/mediastream/MediaDevices.cpp	2016-12-15 16:53:38 UTC (rev 209863)
+++ trunk/Source/WebCore/Modules/mediastream/MediaDevices.cpp	2016-12-15 17:25:53 UTC (rev 209864)
@@ -34,6 +34,7 @@
 #if ENABLE(MEDIA_STREAM)
 
 #include "Document.h"
+#include "MediaConstraintsImpl.h"
 #include "MediaDevicesRequest.h"
 #include "MediaTrackSupportedConstraints.h"
 #include "RealtimeMediaSourceCenter.h"
@@ -56,12 +57,24 @@
     return downcast<Document>(scriptExecutionContext());
 }
 
-ExceptionOr<void> MediaDevices::getUserMedia(Ref<MediaConstraintsImpl>&& audioConstraints, Ref<MediaConstraintsImpl>&& videoConstraints, Promise&& promise) const
+static Ref<MediaConstraintsImpl> createMediaConstraintsImpl(const Variant<bool, MediaTrackConstraints>& constraints)
 {
+    return WTF::switchOn(constraints,
+        [&] (bool constraints) {
+            return MediaConstraintsImpl::create({ }, { }, constraints);
+        },
+        [&] (const MediaTrackConstraints& constraints) {
+            return createMediaConstraintsImpl(constraints);
+        }
+    );
+}
+
+ExceptionOr<void> MediaDevices::getUserMedia(const StreamConstraints& constraints, Promise&& promise) const
+{
     auto* document = this->document();
     if (!document)
         return Exception { INVALID_STATE_ERR };
-    return UserMediaRequest::start(*document, WTFMove(audioConstraints), WTFMove(videoConstraints), WTFMove(promise));
+    return UserMediaRequest::start(*document, createMediaConstraintsImpl(constraints.audio), createMediaConstraintsImpl(constraints.video), WTFMove(promise));
 }
 
 void MediaDevices::enumerateDevices(EnumerateDevicesPromise&& promise) const

Modified: trunk/Source/WebCore/Modules/mediastream/MediaDevices.h (209863 => 209864)


--- trunk/Source/WebCore/Modules/mediastream/MediaDevices.h	2016-12-15 16:53:38 UTC (rev 209863)
+++ trunk/Source/WebCore/Modules/mediastream/MediaDevices.h	2016-12-15 17:25:53 UTC (rev 209864)
@@ -1,5 +1,6 @@
 /*
  * Copyright (C) 2015 Ericsson AB. All rights reserved.
+ * 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
@@ -34,12 +35,12 @@
 
 #include "ExceptionOr.h"
 #include "JSDOMPromise.h"
-#include "MediaDeviceInfo.h"
+#include "MediaTrackConstraints.h"
 
 namespace WebCore {
 
 class Document;
-class MediaConstraintsImpl;
+class MediaDeviceInfo;
 class MediaStream;
 class MediaTrackSupportedConstraints;
 
@@ -52,7 +53,11 @@
     using Promise = DOMPromise<IDLInterface<MediaStream>>;
     using EnumerateDevicesPromise = DOMPromise<IDLSequence<IDLInterface<MediaDeviceInfo>>>;
 
-    ExceptionOr<void> getUserMedia(Ref<MediaConstraintsImpl>&& audioConstraints, Ref<MediaConstraintsImpl>&& videoConstraints, Promise&&) const;
+    struct StreamConstraints {
+        Variant<bool, MediaTrackConstraints> video;
+        Variant<bool, MediaTrackConstraints> audio;
+    };
+    ExceptionOr<void> getUserMedia(const StreamConstraints&, Promise&&) const;
     void enumerateDevices(EnumerateDevicesPromise&&) const;
     RefPtr<MediaTrackSupportedConstraints> getSupportedConstraints();
 

Modified: trunk/Source/WebCore/Modules/mediastream/MediaDevices.idl (209863 => 209864)


--- trunk/Source/WebCore/Modules/mediastream/MediaDevices.idl	2016-12-15 16:53:38 UTC (rev 209863)
+++ trunk/Source/WebCore/Modules/mediastream/MediaDevices.idl	2016-12-15 17:25:53 UTC (rev 209864)
@@ -29,11 +29,16 @@
  */
 
 [
+    Conditional=MEDIA_STREAM,
     NoInterfaceObject,
-    Conditional=MEDIA_STREAM
 ] interface MediaDevices {
     MediaTrackSupportedConstraints getSupportedConstraints();
 
-    [Custom, MayThrowException, PrivateIdentifier, PublicIdentifier] Promise<MediaStream> getUserMedia(optional MediaStreamConstraints constraints);
+    [MayThrowException, PrivateIdentifier, PublicIdentifier] Promise<MediaStream> getUserMedia(optional MediaStreamConstraints constraints);
     Promise<sequence<MediaDeviceInfo>> enumerateDevices();
 };
+
+dictionary MediaStreamConstraints {
+    (boolean or MediaTrackConstraints) video = false;
+    (boolean or MediaTrackConstraints) audio = false;
+};

Modified: trunk/Source/WebCore/Modules/mediastream/MediaStream.cpp (209863 => 209864)


--- trunk/Source/WebCore/Modules/mediastream/MediaStream.cpp	2016-12-15 16:53:38 UTC (rev 209863)
+++ trunk/Source/WebCore/Modules/mediastream/MediaStream.cpp	2016-12-15 17:25:53 UTC (rev 209864)
@@ -72,7 +72,7 @@
     trackPrivates.reserveCapacity(tracks.size());
 
     for (auto& track : tracks) {
-        track->addObserver(this);
+        track->addObserver(*this);
         m_trackSet.add(track->id(), track);
         trackPrivates.append(&track->privateTrack());
     }
@@ -96,7 +96,7 @@
 
     for (auto& trackPrivate : m_private->tracks()) {
         auto track = MediaStreamTrack::create(context, *trackPrivate);
-        track->addObserver(this);
+        track->addObserver(*this);
         m_trackSet.add(track->id(), WTFMove(track));
     }
     document()->addAudioProducer(this);
@@ -110,7 +110,7 @@
     MediaStreamRegistry::shared().unregisterStream(*this);
     m_private->removeObserver(*this);
     for (auto& track : m_trackSet.values())
-        track->removeObserver(this);
+        track->removeObserver(*this);
     if (Document* document = this->document()) {
         document->removeAudioProducer(this);
         if (m_isWaitingUntilMediaCanStart)
@@ -215,7 +215,7 @@
 
     ASSERT(result.iterator->value);
     auto& track = *result.iterator->value;
-    track.addObserver(this);
+    track.addObserver(*this);
 
     if (streamModifier == StreamModifier::DomAPI)
         m_private->addTrack(&track.privateTrack(), MediaStreamPrivate::NotifyClientOption::DontNotify);
@@ -231,7 +231,7 @@
     if (!track)
         return false;
 
-    track->removeObserver(this);
+    track->removeObserver(*this);
 
     if (streamModifier == StreamModifier::DomAPI)
         m_private->removeTrack(track->privateTrack(), MediaStreamPrivate::NotifyClientOption::DontNotify);

Modified: trunk/Source/WebCore/Modules/mediastream/MediaStreamTrack.cpp (209863 => 209864)


--- trunk/Source/WebCore/Modules/mediastream/MediaStreamTrack.cpp	2016-12-15 16:53:38 UTC (rev 209863)
+++ trunk/Source/WebCore/Modules/mediastream/MediaStreamTrack.cpp	2016-12-15 17:25:53 UTC (rev 209864)
@@ -158,49 +158,40 @@
     return m_private->capabilities();
 }
 
-void MediaStreamTrack::applyConstraints(Ref<MediaConstraints>&& constraints, DOMPromise<void>&& promise)
+static Ref<MediaConstraintsImpl> createMediaConstraintsImpl(const std::optional<MediaTrackConstraints>& constraints)
 {
-    if (!constraints->isValid()) {
-        promise.reject(TypeError);
-        return;
-    }
+    if (!constraints)
+        return MediaConstraintsImpl::create({ }, { }, true);
+    return createMediaConstraintsImpl(constraints.value());
+}
 
-    m_constraints = WTFMove(constraints);
+void MediaStreamTrack::applyConstraints(const std::optional<MediaTrackConstraints>& constraints, DOMPromise<void>&& promise)
+{
     m_promise = WTFMove(promise);
 
-    applyConstraints(*m_constraints);
-}
-
-void MediaStreamTrack::applyConstraints(const MediaConstraints& constraints)
-{
     auto weakThis = createWeakPtr();
-    std::function<void(const String&, const String&)> failureHandler = [weakThis](const String& failedConstraint, const String& message) {
+    auto failureHandler = [weakThis] (const String& failedConstraint, const String& message) {
         if (!weakThis || !weakThis->m_promise)
             return;
-
         weakThis->m_promise->rejectType<IDLInterface<OverconstrainedError>>(OverconstrainedError::create(failedConstraint, message).get());
     };
-
-    std::function<void()> successHandler = [weakThis]() {
+    auto successHandler = [weakThis, constraints] () {
         if (!weakThis || !weakThis->m_promise)
             return;
-
         weakThis->m_promise->resolve();
+        weakThis->m_constraints = constraints.value_or(MediaTrackConstraints { });
     };
-
-    m_private->applyConstraints(constraints, successHandler, failureHandler);
+    m_private->applyConstraints(createMediaConstraintsImpl(constraints), successHandler, failureHandler);
 }
 
-void MediaStreamTrack::addObserver(MediaStreamTrack::Observer* observer)
+void MediaStreamTrack::addObserver(Observer& observer)
 {
-    m_observers.append(observer);
+    m_observers.append(&observer);
 }
 
-void MediaStreamTrack::removeObserver(MediaStreamTrack::Observer* observer)
+void MediaStreamTrack::removeObserver(Observer& observer)
 {
-    size_t pos = m_observers.find(observer);
-    if (pos != notFound)
-        m_observers.remove(pos);
+    m_observers.removeFirst(&observer);
 }
 
 void MediaStreamTrack::trackEnded(MediaStreamTrackPrivate&)

Modified: trunk/Source/WebCore/Modules/mediastream/MediaStreamTrack.h (209863 => 209864)


--- trunk/Source/WebCore/Modules/mediastream/MediaStreamTrack.h	2016-12-15 16:53:38 UTC (rev 209863)
+++ trunk/Source/WebCore/Modules/mediastream/MediaStreamTrack.h	2016-12-15 17:25:53 UTC (rev 209864)
@@ -33,13 +33,7 @@
 #include "EventTarget.h"
 #include "JSDOMPromise.h"
 #include "MediaStreamTrackPrivate.h"
-#include "RealtimeMediaSource.h"
-#include "ScriptWrappable.h"
-#include <wtf/Optional.h>
-#include <wtf/RefPtr.h>
-#include <wtf/Vector.h>
-#include <wtf/WeakPtr.h>
-#include <wtf/text/WTFString.h>
+#include "MediaTrackConstraints.h"
 
 namespace WebCore {
 
@@ -47,6 +41,8 @@
 class MediaConstraints;
 class MediaSourceSettings;
 
+struct MediaTrackConstraints;
+
 class MediaStreamTrack final : public RefCounted<MediaStreamTrack>, public ActiveDOMObject, public EventTargetWithInlineData, private MediaStreamTrackPrivate::Observer {
 public:
     class Observer {
@@ -80,8 +76,8 @@
     RefPtr<MediaSourceSettings> getSettings() const;
     RefPtr<RealtimeMediaSourceCapabilities> getCapabilities() const;
 
-    void applyConstraints(Ref<MediaConstraints>&&, DOMPromise<void>&&);
-    void applyConstraints(const MediaConstraints&);
+    const MediaTrackConstraints& getConstraints() const { return m_constraints; }
+    void applyConstraints(const std::optional<MediaTrackConstraints>&, DOMPromise<void>&&);
 
     RealtimeMediaSource& source() { return m_private->source(); }
     MediaStreamTrackPrivate& privateTrack() { return m_private.get(); }
@@ -88,16 +84,12 @@
 
     AudioSourceProvider* audioSourceProvider();
 
-    void addObserver(Observer*);
-    void removeObserver(Observer*);
+    void addObserver(Observer&);
+    void removeObserver(Observer&);
 
-    // EventTarget
-    EventTargetInterface eventTargetInterface() const final { return MediaStreamTrackEventTargetInterfaceType; }
-    ScriptExecutionContext* scriptExecutionContext() const final { return ActiveDOMObject::scriptExecutionContext(); }
+    using RefCounted::ref;
+    using RefCounted::deref;
 
-    using RefCounted<MediaStreamTrack>::ref;
-    using RefCounted<MediaStreamTrack>::deref;
-
 private:
     MediaStreamTrack(ScriptExecutionContext&, Ref<MediaStreamTrackPrivate>&&);
     explicit MediaStreamTrack(MediaStreamTrack&);
@@ -112,6 +104,8 @@
     // EventTarget
     void refEventTarget() final { ref(); }
     void derefEventTarget() final { deref(); }
+    EventTargetInterface eventTargetInterface() const final { return MediaStreamTrackEventTargetInterfaceType; }
+    ScriptExecutionContext* scriptExecutionContext() const final { return ActiveDOMObject::scriptExecutionContext(); }
 
     // MediaStreamTrackPrivate::Observer
     void trackEnded(MediaStreamTrackPrivate&) override;
@@ -124,7 +118,7 @@
     Vector<Observer*> m_observers;
     Ref<MediaStreamTrackPrivate> m_private;
 
-    RefPtr<MediaConstraints> m_constraints;
+    MediaTrackConstraints m_constraints;
     std::optional<DOMPromise<void>> m_promise;
     WeakPtrFactory<MediaStreamTrack> m_weakPtrFactory;
 

Modified: trunk/Source/WebCore/Modules/mediastream/MediaStreamTrack.idl (209863 => 209864)


--- trunk/Source/WebCore/Modules/mediastream/MediaStreamTrack.idl	2016-12-15 16:53:38 UTC (rev 209863)
+++ trunk/Source/WebCore/Modules/mediastream/MediaStreamTrack.idl	2016-12-15 17:25:53 UTC (rev 209864)
@@ -47,11 +47,10 @@
     MediaStreamTrack clone();
     [ImplementedAs=stopProducingData] void stop();
 
-    [Custom] MediaTrackConstraints getConstraints();
+    MediaTrackConstraints getConstraints();
     [Custom] MediaSourceSettings getSettings();
     [Custom] MediaTrackCapabilities getCapabilities();
-    [Custom] Promise<void> applyConstraints(optional MediaTrackConstraints constraints);
+    Promise<void> applyConstraints(optional MediaTrackConstraints constraints);
 
     attribute EventHandler onoverconstrained;
 };
-

Added: trunk/Source/WebCore/Modules/mediastream/MediaTrackConstraints.cpp (0 => 209864)


--- trunk/Source/WebCore/Modules/mediastream/MediaTrackConstraints.cpp	                        (rev 0)
+++ trunk/Source/WebCore/Modules/mediastream/MediaTrackConstraints.cpp	2016-12-15 17:25:53 UTC (rev 209864)
@@ -0,0 +1,200 @@
+/*
+ * 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.
+ */
+
+#include "config.h"
+#include "MediaTrackConstraints.h"
+
+#if ENABLE(MEDIA_STREAM)
+
+#include "MediaConstraintsImpl.h"
+
+namespace WebCore {
+
+enum class ConstraintSetType { Mandatory, Advanced };
+
+static void set(MediaTrackConstraintSetMap& map, ConstraintSetType setType, const char* typeAsString, MediaConstraintType type, const ConstrainLong& value)
+{
+    IntConstraint constraint(typeAsString, type);
+    WTF::switchOn(value,
+        [&] (int integer) {
+            if (setType == ConstraintSetType::Mandatory)
+                constraint.setIdeal(integer);
+            else
+                constraint.setExact(integer);
+        },
+        [&] (const ConstrainLongRange& range) {
+            if (range.min)
+                constraint.setMin(range.min.value());
+            if (range.max)
+                constraint.setMax(range.max.value());
+            if (range.exact)
+                constraint.setExact(range.exact.value());
+            if (range.ideal)
+                constraint.setIdeal(range.ideal.value());
+        }
+    );
+    map.set(type, WTFMove(constraint));
+}
+
+static void set(MediaTrackConstraintSetMap& map, ConstraintSetType setType, const char* typeAsString, MediaConstraintType type, const ConstrainDouble& value)
+{
+    DoubleConstraint constraint(typeAsString, type);
+    WTF::switchOn(value,
+        [&] (double number) {
+            if (setType == ConstraintSetType::Mandatory)
+                constraint.setIdeal(number);
+            else
+                constraint.setExact(number);
+        },
+        [&] (const ConstrainDoubleRange& range) {
+            if (range.min)
+                constraint.setMin(range.min.value());
+            if (range.max)
+                constraint.setMax(range.max.value());
+            if (range.exact)
+                constraint.setExact(range.exact.value());
+            if (range.ideal)
+                constraint.setIdeal(range.ideal.value());
+        }
+    );
+    map.set(type, WTFMove(constraint));
+}
+
+static void set(MediaTrackConstraintSetMap& map, ConstraintSetType setType, const char* typeAsString, MediaConstraintType type, const ConstrainBoolean& value)
+{
+    BooleanConstraint constraint(typeAsString, type);
+    WTF::switchOn(value,
+        [&] (bool boolean) {
+            if (setType == ConstraintSetType::Mandatory)
+                constraint.setIdeal(boolean);
+            else
+                constraint.setExact(boolean);
+        },
+        [&] (const ConstrainBooleanParameters& parameters) {
+            if (parameters.exact)
+                constraint.setExact(parameters.exact.value());
+            if (parameters.ideal)
+                constraint.setIdeal(parameters.ideal.value());
+        }
+    );
+    map.set(type, WTFMove(constraint));
+}
+
+static void set(MediaTrackConstraintSetMap& map, ConstraintSetType setType, const char* typeAsString, MediaConstraintType type, const ConstrainDOMString& value)
+{
+    StringConstraint constraint(typeAsString, type);
+    WTF::switchOn(value,
+        [&] (const String& string) {
+            if (setType == ConstraintSetType::Mandatory)
+                constraint.appendIdeal(string);
+            else
+                constraint.appendExact(string);
+        },
+        [&] (const Vector<String>& vector) {
+            if (setType == ConstraintSetType::Mandatory) {
+                for (auto& string : vector)
+                    constraint.appendIdeal(string);
+            } else {
+                for (auto& string : vector)
+                    constraint.appendExact(string);
+            }
+        },
+        [&] (const ConstrainDOMStringParameters& parameters) {
+            if (parameters.exact) {
+                WTF::switchOn(parameters.exact.value(),
+                    [&] (const String& string) {
+                        constraint.appendExact(string);
+                    },
+                    [&] (const Vector<String>& vector) {
+                        for (auto& string : vector)
+                            constraint.appendExact(string);
+                    }
+                );
+            }
+            if (parameters.ideal) {
+                WTF::switchOn(parameters.ideal.value(),
+                    [&] (const String& string) {
+                        constraint.appendIdeal(string);
+                    },
+                    [&] (const Vector<String>& vector) {
+                        for (auto& string : vector)
+                            constraint.appendIdeal(string);
+                    }
+                );
+            }
+        }
+    );
+    map.set(type, WTFMove(constraint));
+}
+
+template<typename T> static inline void set(MediaTrackConstraintSetMap& map, ConstraintSetType setType, const char* typeAsString, MediaConstraintType type, const std::optional<T>& value)
+{
+    if (!value)
+        return;
+    set(map, setType, typeAsString, type, value.value());
+}
+
+static MediaTrackConstraintSetMap convertToInternalForm(ConstraintSetType setType, const MediaTrackConstraintSet& constraintSet)
+{
+    MediaTrackConstraintSetMap result;
+    set(result, setType, "width", MediaConstraintType::Width, constraintSet.width);
+    set(result, setType, "height", MediaConstraintType::Height, constraintSet.height);
+    set(result, setType, "aspectRatio", MediaConstraintType::AspectRatio, constraintSet.aspectRatio);
+    set(result, setType, "frameRate", MediaConstraintType::FrameRate, constraintSet.frameRate);
+    set(result, setType, "facingMode", MediaConstraintType::FacingMode, constraintSet.facingMode);
+    set(result, setType, "volume", MediaConstraintType::Volume, constraintSet.volume);
+    set(result, setType, "sampleRate", MediaConstraintType::SampleRate, constraintSet.sampleRate);
+    set(result, setType, "sampleSize", MediaConstraintType::SampleSize, constraintSet.sampleSize);
+    set(result, setType, "echoCancellation", MediaConstraintType::EchoCancellation, constraintSet.echoCancellation);
+    // FIXME: add latency
+    // FIXME: add channelCount
+    set(result, setType, "deviceId", MediaConstraintType::DeviceId, constraintSet.deviceId);
+    set(result, setType, "groupId", MediaConstraintType::GroupId, constraintSet.groupId);
+    return result;
+}
+
+static Vector<MediaTrackConstraintSetMap> convertAdvancedToInternalForm(const Vector<MediaTrackConstraintSet>& vector)
+{
+    Vector<MediaTrackConstraintSetMap> result;
+    result.reserveInitialCapacity(vector.size());
+    for (auto& set : vector)
+        result.uncheckedAppend(convertToInternalForm(ConstraintSetType::Advanced, set));
+    return result;
+}
+
+static Vector<MediaTrackConstraintSetMap> convertAdvancedToInternalForm(const std::optional<Vector<MediaTrackConstraintSet>>& optionalVector)
+{
+    if (!optionalVector)
+        return { };
+    return convertAdvancedToInternalForm(optionalVector.value());
+}
+
+Ref<MediaConstraintsImpl> createMediaConstraintsImpl(const MediaTrackConstraints& constraints)
+{
+    return MediaConstraintsImpl::create(convertToInternalForm(ConstraintSetType::Mandatory, constraints), convertAdvancedToInternalForm(constraints.advanced), true);
+}
+
+}
+
+#endif

Added: trunk/Source/WebCore/Modules/mediastream/MediaTrackConstraints.h (0 => 209864)


--- trunk/Source/WebCore/Modules/mediastream/MediaTrackConstraints.h	                        (rev 0)
+++ trunk/Source/WebCore/Modules/mediastream/MediaTrackConstraints.h	2016-12-15 17:25:53 UTC (rev 209864)
@@ -0,0 +1,97 @@
+/*
+ * 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
+
+#if ENABLE(MEDIA_STREAM)
+
+#include <wtf/Optional.h>
+#include <wtf/Variant.h>
+#include <wtf/Vector.h>
+#include <wtf/text/WTFString.h>
+
+namespace WebCore {
+
+class MediaConstraintsImpl;
+
+struct DoubleRange {
+    std::optional<double> min;
+    std::optional<double> max;
+};
+
+struct LongRange {
+    std::optional<int> max;
+    std::optional<int> min;
+};
+
+struct ConstrainBooleanParameters {
+    std::optional<bool> exact;
+    std::optional<bool> ideal;
+};
+
+struct ConstrainDOMStringParameters {
+    std::optional<Variant<String, Vector<String>>> exact;
+    std::optional<Variant<String, Vector<String>>> ideal;
+};
+
+struct ConstrainDoubleRange : DoubleRange {
+    std::optional<double> exact;
+    std::optional<double> ideal;
+};
+
+struct ConstrainLongRange : LongRange {
+    std::optional<int> exact;
+    std::optional<int> ideal;
+};
+
+using ConstrainBoolean = Variant<bool, ConstrainBooleanParameters>;
+using ConstrainDOMString = Variant<String, Vector<String>, ConstrainDOMStringParameters>;
+using ConstrainDouble = Variant<double, ConstrainDoubleRange>;
+using ConstrainLong = Variant<int, ConstrainLongRange>;
+
+struct MediaTrackConstraintSet {
+    std::optional<ConstrainLong> width;
+    std::optional<ConstrainLong> height;
+    std::optional<ConstrainDouble> aspectRatio;
+    std::optional<ConstrainDouble> frameRate;
+    std::optional<ConstrainDOMString> facingMode;
+    std::optional<ConstrainDouble> volume;
+    std::optional<ConstrainLong> sampleRate;
+    std::optional<ConstrainLong> sampleSize;
+    std::optional<ConstrainBoolean> echoCancellation;
+    std::optional<ConstrainDouble> latency;
+    std::optional<ConstrainLong> channelCount;
+    std::optional<ConstrainDOMString> deviceId;
+    std::optional<ConstrainDOMString> groupId;
+};
+
+struct MediaTrackConstraints : MediaTrackConstraintSet {
+    std::optional<Vector<MediaTrackConstraintSet>> advanced;
+};
+
+Ref<MediaConstraintsImpl> createMediaConstraintsImpl(const MediaTrackConstraints&);
+
+}
+
+#endif

Added: trunk/Source/WebCore/Modules/mediastream/MediaTrackConstraints.idl (0 => 209864)


--- trunk/Source/WebCore/Modules/mediastream/MediaTrackConstraints.idl	                        (rev 0)
+++ trunk/Source/WebCore/Modules/mediastream/MediaTrackConstraints.idl	2016-12-15 17:25:53 UTC (rev 209864)
@@ -0,0 +1,91 @@
+/*
+ * 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.
+ */
+
+[
+    Conditional=MEDIA_STREAM,
+    JSGenerateToJSObject,
+] dictionary MediaTrackConstraints : MediaTrackConstraintSet {
+    sequence<MediaTrackConstraintSet> advanced;
+};
+
+[
+    JSGenerateToJSObject,
+] dictionary MediaTrackConstraintSet {
+    ConstrainLong width;
+    ConstrainLong height;
+    ConstrainDouble aspectRatio;
+    ConstrainDouble frameRate;
+    ConstrainDOMString facingMode;
+    ConstrainDouble volume;
+    ConstrainLong sampleRate;
+    ConstrainLong sampleSize;
+    ConstrainBoolean echoCancellation;
+    ConstrainDouble latency;
+    ConstrainLong channelCount;
+    ConstrainDOMString deviceId;
+    ConstrainDOMString groupId;
+};
+
+typedef (double or ConstrainDoubleRange) ConstrainDouble;
+typedef (long or ConstrainLongRange) ConstrainLong;
+typedef (boolean or ConstrainBooleanParameters) ConstrainBoolean;
+typedef (DOMString or sequence<DOMString> or ConstrainDOMStringParameters) ConstrainDOMString;
+
+[
+    JSGenerateToJSObject,
+] dictionary ConstrainBooleanParameters {
+    boolean exact;
+    boolean ideal;
+};
+
+[
+    JSGenerateToJSObject,
+] dictionary ConstrainDOMStringParameters {
+    (DOMString or sequence<DOMString>) exact;
+    (DOMString or sequence<DOMString>) ideal;
+};
+
+[
+    JSGenerateToJSObject,
+] dictionary ConstrainDoubleRange : DoubleRange {
+    double exact;
+    double ideal;
+};
+
+[
+    JSGenerateToJSObject,
+] dictionary ConstrainLongRange : LongRange {
+    long exact;
+    long ideal;
+};
+
+dictionary DoubleRange {
+    double max;
+    double min;
+};
+
+dictionary LongRange {
+    long max;
+    long min;
+};

Modified: trunk/Source/WebCore/Modules/mediastream/UserMediaRequest.cpp (209863 => 209864)


--- trunk/Source/WebCore/Modules/mediastream/UserMediaRequest.cpp	2016-12-15 16:53:38 UTC (rev 209863)
+++ trunk/Source/WebCore/Modules/mediastream/UserMediaRequest.cpp	2016-12-15 17:25:53 UTC (rev 209864)
@@ -36,24 +36,20 @@
 
 #if ENABLE(MEDIA_STREAM)
 
+#include "Document.h"
 #include "DocumentLoader.h"
 #include "ExceptionCode.h"
-#include "Frame.h"
 #include "JSMediaStream.h"
 #include "JSOverconstrainedError.h"
 #include "MainFrame.h"
-#include "MediaStream.h"
-#include "MediaStreamPrivate.h"
-#include "OverconstrainedError.h"
+#include "MediaConstraintsImpl.h"
 #include "RealtimeMediaSourceCenter.h"
-#include "SecurityOrigin.h"
 #include "Settings.h"
 #include "UserMediaController.h"
-#include <wtf/MainThread.h>
 
 namespace WebCore {
 
-ExceptionOr<void> UserMediaRequest::start(Document& document, Ref<MediaConstraintsImpl>&& audioConstraints, Ref<MediaConstraintsImpl>&& videoConstraints, MediaDevices::Promise&& promise)
+ExceptionOr<void> UserMediaRequest::start(Document& document, Ref<MediaConstraintsImpl>&& audioConstraints, Ref<MediaConstraintsImpl>&& videoConstraints, DOMPromise<IDLInterface<MediaStream>>&& promise)
 {
     auto* userMedia = UserMediaController::from(document.page());
     if (!userMedia)
@@ -68,7 +64,7 @@
     return { };
 }
 
-UserMediaRequest::UserMediaRequest(Document& document, UserMediaController& controller, Ref<MediaConstraintsImpl>&& audioConstraints, Ref<MediaConstraintsImpl>&& videoConstraints, MediaDevices::Promise&& promise)
+UserMediaRequest::UserMediaRequest(Document& document, UserMediaController& controller, Ref<MediaConstraintsImpl>&& audioConstraints, Ref<MediaConstraintsImpl>&& videoConstraints, DOMPromise<IDLInterface<MediaStream>>&& promise)
     : ContextDestructionObserver(&document)
     , m_audioConstraints(WTFMove(audioConstraints))
     , m_videoConstraints(WTFMove(videoConstraints))
@@ -85,7 +81,6 @@
 {
     if (!m_scriptExecutionContext)
         return nullptr;
-
     return m_scriptExecutionContext->securityOrigin();
 }
 
@@ -93,19 +88,15 @@
 {
     if (!m_scriptExecutionContext)
         return nullptr;
-
     return m_scriptExecutionContext->topOrigin();
 }
 
 static bool isSecure(DocumentLoader& documentLoader)
 {
-    if (!documentLoader.response().url().protocolIs("https"))
-        return false;
-
-    if (!documentLoader.response().certificateInfo() || documentLoader.response().certificateInfo()->containsNonRootSHA1SignedCertificate())
-        return false;
-
-    return true;
+    auto& response = documentLoader.response();
+    return response.url().protocolIs("https")
+        && response.certificateInfo()
+        && !response.certificateInfo()->containsNonRootSHA1SignedCertificate();
 }
 
 static bool canCallGetUserMedia(Document& document, String& errorMessage)
@@ -149,7 +140,6 @@
     }
 
     Document& document = downcast<Document>(*m_scriptExecutionContext);
-    DOMWindow& window = *document.domWindow();
 
     // 10.2 - 6.3 Optionally, e.g., based on a previously-established user preference, for security reasons,
     // or due to platform limitations, jump to the step labeled Permission Failure below.
@@ -156,7 +146,7 @@
     String errorMessage;
     if (!canCallGetUserMedia(document, errorMessage)) {
         deny(MediaAccessDenialReason::PermissionDenied, emptyString());
-        window.printErrorMessage(errorMessage);
+        document.domWindow()->printErrorMessage(errorMessage);
         return;
     }
 
@@ -230,7 +220,6 @@
 {
     ContextDestructionObserver::contextDestroyed();
     Ref<UserMediaRequest> protectedThis(*this);
-
     if (m_controller) {
         m_controller->cancelUserMediaAccessRequest(*this);
         m_controller = nullptr;
@@ -239,9 +228,6 @@
 
 Document* UserMediaRequest::document() const
 {
-    if (!m_scriptExecutionContext)
-        return nullptr;
-
     return downcast<Document>(m_scriptExecutionContext);
 }
 

Modified: trunk/Source/WebCore/Modules/mediastream/UserMediaRequest.h (209863 => 209864)


--- trunk/Source/WebCore/Modules/mediastream/UserMediaRequest.h	2016-12-15 16:53:38 UTC (rev 209863)
+++ trunk/Source/WebCore/Modules/mediastream/UserMediaRequest.h	2016-12-15 17:25:53 UTC (rev 209864)
@@ -35,20 +35,18 @@
 #if ENABLE(MEDIA_STREAM)
 
 #include "ActiveDOMObject.h"
-#include "Document.h"
-#include "MediaConstraintsImpl.h"
-#include "MediaDevices.h"
+#include "JSDOMPromise.h"
 
 namespace WebCore {
 
-class MediaConstraints;
-class MediaStreamPrivate;
+class MediaConstraintsImpl;
+class MediaStream;
+class SecurityOrigin;
 class UserMediaController;
-class SecurityOrigin;
 
 class UserMediaRequest : public RefCounted<UserMediaRequest>, private ContextDestructionObserver {
 public:
-    static ExceptionOr<void> start(Document&, Ref<MediaConstraintsImpl>&& audioConstraints, Ref<MediaConstraintsImpl>&& videoConstraints, MediaDevices::Promise&&);
+    static ExceptionOr<void> start(Document&, Ref<MediaConstraintsImpl>&& audioConstraints, Ref<MediaConstraintsImpl>&& videoConstraints, DOMPromise<IDLInterface<MediaStream>>&&);
 
     virtual ~UserMediaRequest();
 
@@ -74,7 +72,7 @@
     WEBCORE_EXPORT Document* document() const;
 
 private:
-    UserMediaRequest(Document&, UserMediaController&, Ref<MediaConstraintsImpl>&& audioConstraints, Ref<MediaConstraintsImpl>&& videoConstraints, MediaDevices::Promise&&);
+    UserMediaRequest(Document&, UserMediaController&, Ref<MediaConstraintsImpl>&& audioConstraints, Ref<MediaConstraintsImpl>&& videoConstraints, DOMPromise<IDLInterface<MediaStream>>&&);
 
     void contextDestroyed() final;
     
@@ -88,7 +86,7 @@
     String m_allowedAudioDeviceUID;
 
     UserMediaController* m_controller;
-    MediaDevices::Promise m_promise;
+    DOMPromise<IDLInterface<MediaStream>> m_promise;
     RefPtr<UserMediaRequest> m_protector;
 };
 

Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (209863 => 209864)


--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2016-12-15 16:53:38 UTC (rev 209863)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2016-12-15 17:25:53 UTC (rev 209864)
@@ -125,7 +125,6 @@
 		07277E5417D018CC0015534D /* JSMediaStreamTrackEvent.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 07277E4817D018CC0015534D /* JSMediaStreamTrackEvent.cpp */; };
 		07277E5517D018CC0015534D /* JSMediaStreamTrackEvent.h in Headers */ = {isa = PBXBuildFile; fileRef = 07277E4917D018CC0015534D /* JSMediaStreamTrackEvent.h */; };
 		072A70401D6E8F6200DF0AFC /* OverconstrainedErrorEvent.h in Headers */ = {isa = PBXBuildFile; fileRef = 072A703E1D6E8F6200DF0AFC /* OverconstrainedErrorEvent.h */; };
-		072A70431D7396B300DF0AFC /* JSMediaDevicesCustom.h in Headers */ = {isa = PBXBuildFile; fileRef = 072A70421D7396B200DF0AFC /* JSMediaDevicesCustom.h */; };
 		072AE1E5183C0741000A5988 /* PluginReplacement.h in Headers */ = {isa = PBXBuildFile; fileRef = 072AE1DF183C0741000A5988 /* PluginReplacement.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		072AE1E6183C0741000A5988 /* QuickTimePluginReplacement.mm in Sources */ = {isa = PBXBuildFile; fileRef = 072AE1E0183C0741000A5988 /* QuickTimePluginReplacement.mm */; };
 		072AE1E8183C0741000A5988 /* QuickTimePluginReplacement.h in Headers */ = {isa = PBXBuildFile; fileRef = 072AE1E2183C0741000A5988 /* QuickTimePluginReplacement.h */; };
@@ -989,7 +988,6 @@
 		1AFFC4591D5E866100267A66 /* PluginBlacklist.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AFFC44F1D5E7EC700267A66 /* PluginBlacklist.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		1B124D8D1D380B7000ECDFB0 /* MediaSampleAVFObjC.h in Headers */ = {isa = PBXBuildFile; fileRef = 1B124D8C1D380B7000ECDFB0 /* MediaSampleAVFObjC.h */; };
 		1B124D8F1D380BB600ECDFB0 /* MediaSampleAVFObjC.mm in Sources */ = {isa = PBXBuildFile; fileRef = 1B124D8E1D380BB600ECDFB0 /* MediaSampleAVFObjC.mm */; };
-		1B88DD131D5B9E5000E3B7A4 /* JSMediaDevicesCustom.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1B88DD121D5AD3B200E3B7A4 /* JSMediaDevicesCustom.cpp */; };
 		1BE5BFC21D515715001666D9 /* MediaConstraints.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1BE5BFC11D515715001666D9 /* MediaConstraints.cpp */; };
 		1BF9DB3C1D3973AD0026AEB7 /* MediaSample.h in Headers */ = {isa = PBXBuildFile; fileRef = CD641EC7181ED60100EE4C41 /* MediaSample.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		1C010700192594DF008A4201 /* InlineTextBoxStyle.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1C0106FE192594DF008A4201 /* InlineTextBoxStyle.cpp */; };
@@ -3261,6 +3259,10 @@
 		9327A94209968D1A0068A546 /* HTMLOptionsCollection.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9327A94109968D1A0068A546 /* HTMLOptionsCollection.cpp */; };
 		932AD70517EFA2C30038F8FF /* MainFrame.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 932AD70317EFA2C30038F8FF /* MainFrame.cpp */; };
 		932AD70617EFA2C40038F8FF /* MainFrame.h in Headers */ = {isa = PBXBuildFile; fileRef = 932AD70417EFA2C30038F8FF /* MainFrame.h */; settings = {ATTRIBUTES = (Private, ); }; };
+		932CC0B71DFFD158004C0F9F /* MediaTrackConstraints.h in Headers */ = {isa = PBXBuildFile; fileRef = 932CC0B61DFFD158004C0F9F /* MediaTrackConstraints.h */; };
+		932CC0D41DFFD667004C0F9F /* JSMediaTrackConstraints.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 932CC0D01DFFD667004C0F9F /* JSMediaTrackConstraints.cpp */; };
+		932CC0D51DFFD667004C0F9F /* JSMediaTrackConstraints.h in Headers */ = {isa = PBXBuildFile; fileRef = 932CC0D11DFFD667004C0F9F /* JSMediaTrackConstraints.h */; };
+		932CC0F71DFFDA1F004C0F9F /* MediaTrackConstraints.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 932CC0F61DFFDA1F004C0F9F /* MediaTrackConstraints.cpp */; };
 		932E16090AF578340025F408 /* FrameLoader.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 932E16080AF578340025F408 /* FrameLoader.cpp */; };
 		93309DD6099E64920056E581 /* AppendNodeCommand.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 93309D87099E64910056E581 /* AppendNodeCommand.cpp */; };
 		93309DD7099E64920056E581 /* AppendNodeCommand.h in Headers */ = {isa = PBXBuildFile; fileRef = 93309D88099E64910056E581 /* AppendNodeCommand.h */; };
@@ -7115,7 +7117,6 @@
 		072847E216EBC5B00043CFA4 /* PlatformTextTrack.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = PlatformTextTrack.h; sourceTree = "<group>"; };
 		072A703E1D6E8F6200DF0AFC /* OverconstrainedErrorEvent.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OverconstrainedErrorEvent.h; sourceTree = "<group>"; };
 		072A703F1D6E8F6200DF0AFC /* OverconstrainedErrorEvent.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = OverconstrainedErrorEvent.idl; sourceTree = "<group>"; };
-		072A70421D7396B200DF0AFC /* JSMediaDevicesCustom.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSMediaDevicesCustom.h; sourceTree = "<group>"; };
 		072AE1DF183C0741000A5988 /* PluginReplacement.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PluginReplacement.h; sourceTree = "<group>"; };
 		072AE1E0183C0741000A5988 /* QuickTimePluginReplacement.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = QuickTimePluginReplacement.mm; sourceTree = "<group>"; };
 		072AE1E1183C0741000A5988 /* QuickTimePluginReplacement.css */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.css; path = QuickTimePluginReplacement.css; sourceTree = "<group>"; };
@@ -8040,7 +8041,6 @@
 		1AFFC4561D5E83A700267A66 /* CFUtilitiesSPI.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CFUtilitiesSPI.h; sourceTree = "<group>"; };
 		1B124D8C1D380B7000ECDFB0 /* MediaSampleAVFObjC.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = MediaSampleAVFObjC.h; path = ../MediaSampleAVFObjC.h; sourceTree = "<group>"; };
 		1B124D8E1D380BB600ECDFB0 /* MediaSampleAVFObjC.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = MediaSampleAVFObjC.mm; sourceTree = "<group>"; };
-		1B88DD121D5AD3B200E3B7A4 /* JSMediaDevicesCustom.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = JSMediaDevicesCustom.cpp; sourceTree = "<group>"; };
 		1BE5BFC11D515715001666D9 /* MediaConstraints.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MediaConstraints.cpp; sourceTree = "<group>"; };
 		1C0106FE192594DF008A4201 /* InlineTextBoxStyle.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = InlineTextBoxStyle.cpp; sourceTree = "<group>"; };
 		1C0106FF192594DF008A4201 /* InlineTextBoxStyle.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = InlineTextBoxStyle.h; sourceTree = "<group>"; };
@@ -10814,6 +10814,11 @@
 		9327A94109968D1A0068A546 /* HTMLOptionsCollection.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = HTMLOptionsCollection.cpp; sourceTree = "<group>"; };
 		932AD70317EFA2C30038F8FF /* MainFrame.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MainFrame.cpp; sourceTree = "<group>"; };
 		932AD70417EFA2C30038F8FF /* MainFrame.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MainFrame.h; sourceTree = "<group>"; };
+		932CC0B61DFFD158004C0F9F /* MediaTrackConstraints.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MediaTrackConstraints.h; sourceTree = "<group>"; };
+		932CC0D01DFFD667004C0F9F /* JSMediaTrackConstraints.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSMediaTrackConstraints.cpp; sourceTree = "<group>"; };
+		932CC0D11DFFD667004C0F9F /* JSMediaTrackConstraints.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSMediaTrackConstraints.h; sourceTree = "<group>"; };
+		932CC0F01DFFD8D4004C0F9F /* MediaTrackConstraints.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = MediaTrackConstraints.idl; sourceTree = "<group>"; };
+		932CC0F61DFFDA1F004C0F9F /* MediaTrackConstraints.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MediaTrackConstraints.cpp; sourceTree = "<group>"; };
 		932E16080AF578340025F408 /* FrameLoader.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = FrameLoader.cpp; sourceTree = "<group>"; };
 		93309D87099E64910056E581 /* AppendNodeCommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = AppendNodeCommand.cpp; sourceTree = "<group>"; };
 		93309D88099E64910056E581 /* AppendNodeCommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AppendNodeCommand.h; sourceTree = "<group>"; };
@@ -15026,6 +15031,9 @@
 				07221B5717CEC32700848E51 /* MediaStreamTrackEvent.cpp */,
 				07221B5817CEC32700848E51 /* MediaStreamTrackEvent.h */,
 				07221B5917CEC32700848E51 /* MediaStreamTrackEvent.idl */,
+				932CC0F61DFFDA1F004C0F9F /* MediaTrackConstraints.cpp */,
+				932CC0B61DFFD158004C0F9F /* MediaTrackConstraints.h */,
+				932CC0F01DFFD8D4004C0F9F /* MediaTrackConstraints.idl */,
 				07C1C0E01BFB600100BD2256 /* MediaTrackSupportedConstraints.h */,
 				07C1C0E11BFB600100BD2256 /* MediaTrackSupportedConstraints.idl */,
 				5EA725CA1ACABCB500EAD17B /* NavigatorMediaDevices.cpp */,
@@ -15238,6 +15246,8 @@
 				07277E4717D018CC0015534D /* JSMediaStreamTrack.h */,
 				07277E4817D018CC0015534D /* JSMediaStreamTrackEvent.cpp */,
 				07277E4917D018CC0015534D /* JSMediaStreamTrackEvent.h */,
+				932CC0D01DFFD667004C0F9F /* JSMediaTrackConstraints.cpp */,
+				932CC0D11DFFD667004C0F9F /* JSMediaTrackConstraints.h */,
 				0787C4671BFBDF6F006DCD7F /* JSMediaTrackSupportedConstraints.cpp */,
 				0787C4681BFBDF6F006DCD7F /* JSMediaTrackSupportedConstraints.h */,
 				073BE33E17D17E01002BD431 /* JSNavigatorUserMedia.cpp */,
@@ -22024,8 +22034,6 @@
 				A7D0318D0E93540300E24ACD /* JSImageDataCustom.cpp */,
 				7A74ECBC101839DA00BF939E /* JSInspectorFrontendHostCustom.cpp */,
 				BCE1C43F0D9830F4003B02F2 /* JSLocationCustom.cpp */,
-				1B88DD121D5AD3B200E3B7A4 /* JSMediaDevicesCustom.cpp */,
-				072A70421D7396B200DF0AFC /* JSMediaDevicesCustom.h */,
 				AD726FE716D9F204003A4E6D /* JSMediaListCustom.h */,
 				07C59B6D17F794F6000FBCBB /* JSMediaStreamTrackCustom.cpp */,
 				07C1C0E61BFB90A700BD2256 /* JSMediaTrackSupportedConstraintsCustom.cpp */,
@@ -25522,6 +25530,7 @@
 				062287840B4DB322000C34DF /* FocusDirection.h in Headers */,
 				B6D9D23514EABD260090D75E /* FocusEvent.h in Headers */,
 				B2C3DA650D006CD600EF6F26 /* Font.h in Headers */,
+				932CC0B71DFFD158004C0F9F /* MediaTrackConstraints.h in Headers */,
 				1AC2D89D1B1E291F00D52E87 /* FontAntialiasingStateSaver.h in Headers */,
 				BCB92D4F1293550B00C8387F /* FontBaseline.h in Headers */,
 				B2C3DA630D006CD600EF6F26 /* FontCache.h in Headers */,
@@ -26213,7 +26222,6 @@
 				CDAB6D2E17C814EE00C60B34 /* JSMediaControlsHost.h in Headers */,
 				159741DB1B7D140100201C92 /* JSMediaDeviceInfo.h in Headers */,
 				15739BBB1B42012D00D258C1 /* JSMediaDevices.h in Headers */,
-				072A70431D7396B300DF0AFC /* JSMediaDevicesCustom.h in Headers */,
 				FD23A12613F5FA5900F67001 /* JSMediaElementAudioSourceNode.h in Headers */,
 				2D9BF7121DBFD914007A7D99 /* JSMediaEncryptedEvent.h in Headers */,
 				E44614190CD6826900FADA75 /* JSMediaError.h in Headers */,
@@ -28245,6 +28253,7 @@
 				9BAF3B2412C1A39800014BF1 /* WritingDirection.h in Headers */,
 				14476AA815DC4BB100305DB2 /* WritingMode.h in Headers */,
 				6565820209D1508D000E61D7 /* XLinkNames.h in Headers */,
+				932CC0D51DFFD667004C0F9F /* JSMediaTrackConstraints.h in Headers */,
 				830784B21C52EE2C00104D1D /* XMLDocument.h in Headers */,
 				00B9318813BA8DBA0035A948 /* XMLDocumentParser.h in Headers */,
 				00B9318C13BA8DCC0035A948 /* XMLDocumentParserScope.h in Headers */,
@@ -28935,6 +28944,7 @@
 				31BC742D1AAFF45C006B4340 /* CSSAnimationTriggerScrollValue.cpp in Sources */,
 				CAE9F90F146441F000C245B0 /* CSSAspectRatioValue.cpp in Sources */,
 				94DE5C811D7F3A1400164F2A /* CSSAtRuleID.cpp in Sources */,
+				932CC0F71DFFDA1F004C0F9F /* MediaTrackConstraints.cpp in Sources */,
 				FBD6AF8B15EF25E5008B7110 /* CSSBasicShapes.cpp in Sources */,
 				E16A84F914C85CCC002977DF /* CSSBorderImage.cpp in Sources */,
 				BC274B31140EBED800EADFA6 /* CSSBorderImageSliceValue.cpp in Sources */,
@@ -29841,6 +29851,7 @@
 				BC94D14E0C275C68006BC617 /* JSHistory.cpp in Sources */,
 				BCE7B1930D4E86960075A539 /* JSHistoryCustom.cpp in Sources */,
 				57E233691DCAB24300F28D01 /* JSHmacKeyParams.cpp in Sources */,
+				932CC0D41DFFD667004C0F9F /* JSMediaTrackConstraints.cpp in Sources */,
 				BC97E412109154FA0010D361 /* JSHTMLAllCollection.cpp in Sources */,
 				BC97E42C10915B060010D361 /* JSHTMLAllCollectionCustom.cpp in Sources */,
 				1A4A2DEF0A1B852A00C807F8 /* JSHTMLAnchorElement.cpp in Sources */,
@@ -29975,7 +29986,6 @@
 				CDAB6D2D17C814EE00C60B34 /* JSMediaControlsHost.cpp in Sources */,
 				159741DA1B7D13F900201C92 /* JSMediaDeviceInfo.cpp in Sources */,
 				15739BBA1B42012A00D258C1 /* JSMediaDevices.cpp in Sources */,
-				1B88DD131D5B9E5000E3B7A4 /* JSMediaDevicesCustom.cpp in Sources */,
 				FD23A12513F5FA5900F67001 /* JSMediaElementAudioSourceNode.cpp in Sources */,
 				2D9BF7101DBFD8CE007A7D99 /* JSMediaEncryptedEvent.cpp in Sources */,
 				E44614180CD6826900FADA75 /* JSMediaError.cpp in Sources */,

Modified: trunk/Source/WebCore/bindings/js/JSBindingsAllInOne.cpp (209863 => 209864)


--- trunk/Source/WebCore/bindings/js/JSBindingsAllInOne.cpp	2016-12-15 16:53:38 UTC (rev 209863)
+++ trunk/Source/WebCore/bindings/js/JSBindingsAllInOne.cpp	2016-12-15 17:25:53 UTC (rev 209864)
@@ -99,7 +99,6 @@
 #include "JSLazyEventListener.cpp"
 #include "JSLocationCustom.cpp"
 #include "JSMainThreadExecState.cpp"
-#include "JSMediaDevicesCustom.cpp"
 #include "JSMessageChannelCustom.cpp"
 #include "JSMessageEventCustom.cpp"
 #include "JSMessagePortCustom.cpp"

Deleted: trunk/Source/WebCore/bindings/js/JSMediaDevicesCustom.cpp (209863 => 209864)


--- trunk/Source/WebCore/bindings/js/JSMediaDevicesCustom.cpp	2016-12-15 16:53:38 UTC (rev 209863)
+++ trunk/Source/WebCore/bindings/js/JSMediaDevicesCustom.cpp	2016-12-15 17:25:53 UTC (rev 209864)
@@ -1,399 +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. ``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
- * 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.
- */
-
-#include "config.h"
-#include "JSMediaDevicesCustom.h"
-
-#if ENABLE(MEDIA_STREAM)
-
-#include "ArrayValue.h"
-#include "Dictionary.h"
-#include "ExceptionCode.h"
-#include "JSDOMPromise.h"
-#include "JSMediaDevices.h"
-#include "Logging.h"
-#include "MediaConstraintsImpl.h"
-#include "RealtimeMediaSourceCenter.h"
-#include "RealtimeMediaSourceSupportedConstraints.h"
-#include <wtf/HashMap.h>
-#include <wtf/Vector.h>
-
-using namespace JSC;
-
-namespace WebCore {
-
-enum class ConstraintSetType { Mandatory, Advanced };
-
-static void initializeStringConstraintWithList(StringConstraint& constraint, void (StringConstraint::*appendValue)(const String&), const ArrayValue& list)
-{
-    size_t size;
-    if (!list.length(size))
-        return;
-
-    for (size_t i = 0; i < size; ++i) {
-        String value;
-        if (list.get(i, value))
-            (constraint.*appendValue)(value);
-    }
-}
-
-static std::optional<StringConstraint> createStringConstraint(const Dictionary& mediaTrackConstraintSet, const String& name, MediaConstraintType type, ConstraintSetType constraintSetType)
-{
-    auto constraint = StringConstraint(name, type);
-
-    // Dictionary constraint value.
-    Dictionary dictionaryValue;
-    if (mediaTrackConstraintSet.get(name, dictionaryValue) && !dictionaryValue.isUndefinedOrNull()) {
-        ArrayValue exactArrayValue;
-        if (dictionaryValue.get("exact", exactArrayValue) && !exactArrayValue.isUndefinedOrNull())
-            initializeStringConstraintWithList(constraint, &StringConstraint::appendExact, exactArrayValue);
-        else {
-            String exactStringValue;
-            if (dictionaryValue.get("exact", exactStringValue))
-                constraint.setExact(exactStringValue);
-        }
-
-        ArrayValue idealArrayValue;
-        if (dictionaryValue.get("ideal", idealArrayValue) && !idealArrayValue.isUndefinedOrNull())
-            initializeStringConstraintWithList(constraint, &StringConstraint::appendIdeal, idealArrayValue);
-        else {
-            String idealStringValue;
-            if (!dictionaryValue.get("ideal", idealStringValue))
-                constraint.setIdeal(idealStringValue);
-        }
-
-        if (constraint.isEmpty()) {
-            LOG(Media, "createStringConstraint() - ignoring string constraint '%s' with dictionary value since it has no valid or supported key/value pairs.", name.utf8().data());
-            return std::nullopt;
-        }
-        
-        return WTFMove(constraint);
-    }
-
-    // Array constraint value.
-    ArrayValue arrayValue;
-    if (mediaTrackConstraintSet.get(name, arrayValue) && !arrayValue.isUndefinedOrNull()) {
-        initializeStringConstraintWithList(constraint, &StringConstraint::appendIdeal, arrayValue);
-
-        if (constraint.isEmpty()) {
-            LOG(Media, "createStringConstraint() - ignoring string constraint '%s' with array value since it is empty.", name.utf8().data());
-            return std::nullopt;
-        }
-
-        return WTFMove(constraint);
-    }
-
-    // Scalar constraint value.
-    String value;
-    if (mediaTrackConstraintSet.get(name, value)) {
-        if (constraintSetType == ConstraintSetType::Mandatory)
-            constraint.setIdeal(value);
-        else
-            constraint.setExact(value);
-        
-        return WTFMove(constraint);
-    }
-
-    // Invalid constraint value.
-    LOG(Media, "createStringConstraint() - ignoring string constraint '%s' since it has neither a dictionary nor sequence nor scalar value.", name.utf8().data());
-    return std::nullopt;
-}
-
-static std::optional<BooleanConstraint> createBooleanConstraint(const Dictionary& mediaTrackConstraintSet, const String& name, MediaConstraintType type, ConstraintSetType constraintSetType)
-{
-    auto constraint = BooleanConstraint(name, type);
-
-    // Dictionary constraint value.
-    Dictionary dictionaryValue;
-    if (mediaTrackConstraintSet.get(name, dictionaryValue) && !dictionaryValue.isUndefinedOrNull()) {
-        bool exactValue;
-        if (dictionaryValue.get("exact", exactValue))
-            constraint.setExact(exactValue);
-
-        bool idealValue;
-        if (dictionaryValue.get("ideal", idealValue))
-            constraint.setIdeal(idealValue);
-
-        if (constraint.isEmpty()) {
-            LOG(Media, "createBooleanConstraint() - ignoring boolean constraint '%s' with dictionary value since it has no valid or supported key/value pairs.", name.utf8().data());
-            return std::nullopt;
-        }
-
-        return WTFMove(constraint);
-    }
-
-    // Scalar constraint value.
-    bool value;
-    if (mediaTrackConstraintSet.get(name, value)) {
-        if (constraintSetType == ConstraintSetType::Mandatory)
-            constraint.setIdeal(value);
-        else
-            constraint.setExact(value);
-        
-        return WTFMove(constraint);
-    }
-
-    // Invalid constraint value.
-    LOG(Media, "createBooleanConstraint() - ignoring boolean constraint '%s' since it has neither a dictionary nor scalar value.", name.utf8().data());
-    return std::nullopt;
-}
-
-static std::optional<DoubleConstraint> createDoubleConstraint(const Dictionary& mediaTrackConstraintSet, const String& name, MediaConstraintType type, ConstraintSetType constraintSetType)
-{
-    auto constraint = DoubleConstraint(name, type);
-
-    // Dictionary constraint value.
-    Dictionary dictionaryValue;
-    if (mediaTrackConstraintSet.get(name, dictionaryValue) && !dictionaryValue.isUndefinedOrNull()) {
-        double minValue;
-        if (dictionaryValue.get("min", minValue))
-            constraint.setMin(minValue);
-
-        double maxValue;
-        if (dictionaryValue.get("max", maxValue))
-            constraint.setMax(maxValue);
-
-        double exactValue;
-        if (dictionaryValue.get("exact", exactValue))
-            constraint.setExact(exactValue);
-
-        double idealValue;
-        if (dictionaryValue.get("ideal", idealValue))
-            constraint.setIdeal(idealValue);
-
-        if (constraint.isEmpty()) {
-            LOG(Media, "createDoubleConstraint() - ignoring double constraint '%s' with dictionary value since it has no valid or supported key/value pairs.", name.utf8().data());
-            return std::nullopt;
-        }
-
-        return WTFMove(constraint);
-    }
-
-    // Scalar constraint value.
-    double value;
-    if (mediaTrackConstraintSet.get(name, value)) {
-        if (constraintSetType == ConstraintSetType::Mandatory)
-            constraint.setIdeal(value);
-        else
-            constraint.setExact(value);
-        
-        return WTFMove(constraint);
-    }
-
-    // Invalid constraint value.
-    LOG(Media, "createDoubleConstraint() - ignoring double constraint '%s' since it has neither a dictionary nor scalar value.", name.utf8().data());
-    return std::nullopt;
-}
-
-static std::optional<IntConstraint> createIntConstraint(const Dictionary& mediaTrackConstraintSet, const String& name, MediaConstraintType type, ConstraintSetType constraintSetType)
-{
-    auto constraint = IntConstraint(name, type);
-
-    // Dictionary constraint value.
-    Dictionary dictionaryValue;
-    if (mediaTrackConstraintSet.get(name, dictionaryValue) && !dictionaryValue.isUndefinedOrNull()) {
-        int minValue;
-        if (dictionaryValue.get("min", minValue))
-            constraint.setMin(minValue);
-
-        int maxValue;
-        if (dictionaryValue.get("max", maxValue))
-            constraint.setMax(maxValue);
-
-        int exactValue;
-        if (dictionaryValue.get("exact", exactValue))
-            constraint.setExact(exactValue);
-
-        int idealValue;
-        if (dictionaryValue.get("ideal", idealValue))
-            constraint.setIdeal(idealValue);
-
-        if (constraint.isEmpty()) {
-            LOG(Media, "createIntConstraint() - ignoring long constraint '%s' with dictionary value since it has no valid or supported key/value pairs.", name.utf8().data());
-            return std::nullopt;
-        }
-
-        return WTFMove(constraint);
-    }
-
-    // Scalar constraint value.
-    int value;
-    if (mediaTrackConstraintSet.get(name, value)) {
-        if (constraintSetType == ConstraintSetType::Mandatory)
-            constraint.setIdeal(value);
-        else
-            constraint.setExact(value);
-        
-        return WTFMove(constraint);
-    }
-
-    // Invalid constraint value.
-    LOG(Media, "createIntConstraint() - ignoring long constraint '%s' since it has neither a dictionary nor scalar value.", name.utf8().data());
-    return std::nullopt;
-}
-
-static void parseMediaTrackConstraintSetForKey(const Dictionary& mediaTrackConstraintSet, const String& name, MediaTrackConstraintSetMap& map, ConstraintSetType constraintSetType)
-{
-    MediaConstraintType constraintType = RealtimeMediaSourceSupportedConstraints::constraintFromName(name);
-    switch (constraintType) {
-    case MediaConstraintType::Width:
-        map.set(constraintType, createIntConstraint(mediaTrackConstraintSet, name, constraintType, constraintSetType));
-        break;
-    case MediaConstraintType::Height:
-        map.set(constraintType, createIntConstraint(mediaTrackConstraintSet, name, constraintType, constraintSetType));
-        break;
-    case MediaConstraintType::SampleRate:
-        map.set(constraintType, createIntConstraint(mediaTrackConstraintSet, name, constraintType, constraintSetType));
-        break;
-    case MediaConstraintType::SampleSize:
-        map.set(constraintType, createIntConstraint(mediaTrackConstraintSet, name, constraintType, constraintSetType));
-        break;
-
-    case MediaConstraintType::AspectRatio:
-        map.set(constraintType, createDoubleConstraint(mediaTrackConstraintSet, name, constraintType, constraintSetType));
-        break;
-    case MediaConstraintType::FrameRate:
-        map.set(constraintType, createDoubleConstraint(mediaTrackConstraintSet, name, constraintType, constraintSetType));
-        break;
-    case MediaConstraintType::Volume:
-        map.set(constraintType, createDoubleConstraint(mediaTrackConstraintSet, name, constraintType, constraintSetType));
-        break;
-
-    case MediaConstraintType::EchoCancellation:
-        map.set(constraintType, createBooleanConstraint(mediaTrackConstraintSet, name, constraintType, constraintSetType));
-        break;
-
-    case MediaConstraintType::FacingMode:
-        map.set(constraintType, createStringConstraint(mediaTrackConstraintSet, name, constraintType, constraintSetType));
-        break;
-    case MediaConstraintType::DeviceId:
-        map.set(constraintType, createStringConstraint(mediaTrackConstraintSet, name, constraintType, constraintSetType));
-        break;
-    case MediaConstraintType::GroupId:
-        map.set(constraintType, createStringConstraint(mediaTrackConstraintSet, name, constraintType, constraintSetType));
-        break;
-
-    case MediaConstraintType::Unknown:
-        LOG(Media, "parseMediaTrackConstraintSetForKey() - ignoring unsupported constraint '%s'.", name.utf8().data());
-        return;
-    }
-}
-
-static void parseAdvancedConstraints(const Dictionary& mediaTrackConstraints, Vector<MediaTrackConstraintSetMap>& advancedConstraints)
-{
-    ArrayValue sequenceOfMediaTrackConstraintSets;
-    if (!mediaTrackConstraints.get("advanced", sequenceOfMediaTrackConstraintSets) || sequenceOfMediaTrackConstraintSets.isUndefinedOrNull()) {
-        LOG(Media, "parseAdvancedConstraints() - value of advanced key is not a list.");
-        return;
-    }
-
-    size_t numberOfConstraintSets;
-    if (!sequenceOfMediaTrackConstraintSets.length(numberOfConstraintSets)) {
-        LOG(Media, "parseAdvancedConstraints() - ignoring empty advanced sequence of MediaTrackConstraintSets.");
-        return;
-    }
-
-    for (size_t i = 0; i < numberOfConstraintSets; ++i) {
-        Dictionary mediaTrackConstraintSet;
-        if (!sequenceOfMediaTrackConstraintSets.get(i, mediaTrackConstraintSet) || mediaTrackConstraintSet.isUndefinedOrNull()) {
-            LOG(Media, "parseAdvancedConstraints() - ignoring constraint set with index '%zu' in advanced list.", i);
-            continue;
-        }
-
-        MediaTrackConstraintSetMap map;
-
-        Vector<String> localKeys;
-        mediaTrackConstraintSet.getOwnPropertyNames(localKeys);
-        for (auto& localKey : localKeys)
-            parseMediaTrackConstraintSetForKey(mediaTrackConstraintSet, localKey, map, ConstraintSetType::Advanced);
-
-        if (!map.isEmpty())
-            advancedConstraints.append(WTFMove(map));
-    }
-}
-
-void parseMediaConstraintsDictionary(const Dictionary& mediaTrackConstraints, MediaTrackConstraintSetMap& mandatoryConstraints, Vector<MediaTrackConstraintSetMap>& advancedConstraints)
-{
-    if (mediaTrackConstraints.isUndefinedOrNull())
-        return;
-
-    Vector<String> keys;
-    mediaTrackConstraints.getOwnPropertyNames(keys);
-
-    for (auto& key : keys) {
-        if (key == "advanced")
-            parseAdvancedConstraints(mediaTrackConstraints, advancedConstraints);
-        else
-            parseMediaTrackConstraintSetForKey(mediaTrackConstraints, key, mandatoryConstraints, ConstraintSetType::Mandatory);
-    }
-}
-
-static void JSMediaDevicesGetUserMediaPromiseFunction(ExecState& state, Ref<DeferredPromise>&& promise)
-{
-    VM& vm = state.vm();
-    auto scope = DECLARE_THROW_SCOPE(vm);
-
-    if (UNLIKELY(state.argumentCount() < 1)) {
-        throwVMError(&state, scope, createNotEnoughArgumentsError(&state));
-        return;
-    }
-
-    auto constraintsDictionary = Dictionary(&state, state.uncheckedArgument(0));
-
-    MediaTrackConstraintSetMap mandatoryAudioConstraints;
-    Vector<MediaTrackConstraintSetMap> advancedAudioConstraints;
-    bool areAudioConstraintsValid = false;
-
-    Dictionary audioConstraintsDictionary;
-    if (constraintsDictionary.get("audio", audioConstraintsDictionary) && !audioConstraintsDictionary.isUndefinedOrNull()) {
-        parseMediaConstraintsDictionary(audioConstraintsDictionary, mandatoryAudioConstraints, advancedAudioConstraints);
-        areAudioConstraintsValid = true;
-    } else
-        constraintsDictionary.get("audio", areAudioConstraintsValid);
-
-    MediaTrackConstraintSetMap mandatoryVideoConstraints;
-    Vector<MediaTrackConstraintSetMap> advancedVideoConstraints;
-    bool areVideoConstraintsValid = false;
-
-    Dictionary videoConstraintsDictionary;
-    if (constraintsDictionary.get("video", videoConstraintsDictionary) && !videoConstraintsDictionary.isUndefinedOrNull()) {
-        parseMediaConstraintsDictionary(videoConstraintsDictionary, mandatoryVideoConstraints, advancedVideoConstraints);
-        areVideoConstraintsValid = true;
-    } else
-        constraintsDictionary.get("video", areVideoConstraintsValid);
-
-    auto audioConstraints = MediaConstraintsImpl::create(WTFMove(mandatoryAudioConstraints), WTFMove(advancedAudioConstraints), areAudioConstraintsValid);
-    auto videoConstraints = MediaConstraintsImpl::create(WTFMove(mandatoryVideoConstraints), WTFMove(advancedVideoConstraints), areVideoConstraintsValid);
-    propagateException(state, scope, castThisValue<JSMediaDevices>(state).wrapped().getUserMedia(WTFMove(audioConstraints), WTFMove(videoConstraints), WTFMove(promise)));
-}
-
-JSValue JSMediaDevices::getUserMedia(ExecState& state)
-{
-    return callPromiseFunction<JSMediaDevicesGetUserMediaPromiseFunction, PromiseExecutionScope::WindowOnly>(state);
-}
-
-}
-
-#endif

Deleted: trunk/Source/WebCore/bindings/js/JSMediaDevicesCustom.h (209863 => 209864)


--- trunk/Source/WebCore/bindings/js/JSMediaDevicesCustom.h	2016-12-15 16:53:38 UTC (rev 209863)
+++ trunk/Source/WebCore/bindings/js/JSMediaDevicesCustom.h	2016-12-15 17:25:53 UTC (rev 209864)
@@ -1,41 +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. ``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
- * 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
-
-#if ENABLE(MEDIA_STREAM)
-
-#include "MediaConstraints.h"
-#include <wtf/Vector.h>
-
-namespace WebCore {
-
-class Dictionary;
-
-void parseMediaConstraintsDictionary(const Dictionary&, MediaTrackConstraintSetMap&, Vector<MediaTrackConstraintSetMap>&);
-
-}
-
-#endif

Modified: trunk/Source/WebCore/bindings/js/JSMediaStreamTrackCustom.cpp (209863 => 209864)


--- trunk/Source/WebCore/bindings/js/JSMediaStreamTrackCustom.cpp	2016-12-15 16:53:38 UTC (rev 209863)
+++ trunk/Source/WebCore/bindings/js/JSMediaStreamTrackCustom.cpp	2016-12-15 17:25:53 UTC (rev 209864)
@@ -31,8 +31,6 @@
 #include "Dictionary.h"
 #include "ExceptionCode.h"
 #include "JSDOMBinding.h"
-#include "JSMediaDevicesCustom.h"
-#include "MediaConstraintsImpl.h"
 #include "MediaSourceSettings.h"
 #include "MediaStreamTrack.h"
 #include "WebCoreJSClientData.h"
@@ -166,40 +164,6 @@
     return object;
 }
 
-JSValue JSMediaStreamTrack::applyConstraints(ExecState& state)
-{
-    MediaTrackConstraintSetMap mandatoryConstraints;
-    Vector<MediaTrackConstraintSetMap> advancedConstraints;
-    bool valid = false;
-
-    if (state.argumentCount() >= 1) {
-        JSValue argument = state.uncheckedArgument(0);
-
-        JSVMClientData& clientData = *static_cast<JSVMClientData*>(state.vm().clientData);
-        putDirect(state.vm(), clientData.builtinNames().mediaStreamTrackConstraintsPrivateName(), argument, DontEnum);
-
-        auto constraintsDictionary = Dictionary(&state, argument);
-        if (!constraintsDictionary.isUndefinedOrNull())
-            parseMediaConstraintsDictionary(constraintsDictionary, mandatoryConstraints, advancedConstraints);
-        valid = !advancedConstraints.isEmpty() || !mandatoryConstraints.isEmpty();
-    }
-
-    auto deferredPromise = createDeferredPromise(state, domWindow());
-    auto promise = deferredPromise->promise();
-
-    auto constraints = MediaConstraintsImpl::create(WTFMove(mandatoryConstraints), WTFMove(advancedConstraints), valid);
-    wrapped().applyConstraints(WTFMove(constraints), WTFMove(deferredPromise));
-
-    return promise;
-}
-
-JSValue JSMediaStreamTrack::getConstraints(ExecState& state)
-{
-    JSVMClientData& clientData = *static_cast<JSVMClientData*>(state.vm().clientData);
-    JSValue result = getDirect(state.vm(), clientData.builtinNames().mediaStreamTrackConstraintsPrivateName());
-    return !result.isEmpty() ? result : jsUndefined();
-}
-
 } // namespace WebCore
 
 #endif

Modified: trunk/Source/WebCore/bindings/scripts/CodeGenerator.pm (209863 => 209864)


--- trunk/Source/WebCore/bindings/scripts/CodeGenerator.pm	2016-12-15 16:53:38 UTC (rev 209863)
+++ trunk/Source/WebCore/bindings/scripts/CodeGenerator.pm	2016-12-15 17:25:53 UTC (rev 209864)
@@ -28,6 +28,7 @@
 
 use strict;
 
+use File::Basename;
 use File::Find;
 use Carp qw<longmess>;
 use Data::Dumper;
@@ -203,11 +204,24 @@
 
     my $dictionaries = $useDocument->dictionaries;
     if (@$dictionaries) {
-        die "Multiple standalone dictionaries per document are not supported" if @$dictionaries > 1;
+        my $dictionary;
+        my $otherDictionaries;
+        if (@$dictionaries == 1) {
+            $dictionary = @$dictionaries[0];
+        } else {
+            my $primaryDictionaryName = fileparse($targetIdlFilePath, ".idl");
+            for my $candidate (@$dictionaries) {
+                if ($candidate->type->name eq $primaryDictionaryName) {
+                    $dictionary = $candidate;
+                } else {
+                    push @$otherDictionaries, $candidate;
+                }
+            }
+            die "Multiple dictionaries per document are only supported if one matches the filename" unless $dictionary;
+        }
 
-        my $dictionary = @$dictionaries[0];
         print "Generating $useGenerator bindings code for IDL dictionary \"" . $dictionary->type->name . "\"...\n" if $verbose;
-        $codeGenerator->GenerateDictionary($dictionary, $useDocument->enumerations);
+        $codeGenerator->GenerateDictionary($dictionary, $useDocument->enumerations, $otherDictionaries);
         $codeGenerator->WriteData($dictionary, $useOutputDir, $useOutputHeadersDir);
         return;
     }

Modified: trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm (209863 => 209864)


--- trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm	2016-12-15 16:53:38 UTC (rev 209863)
+++ trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm	2016-12-15 17:25:53 UTC (rev 209864)
@@ -50,7 +50,6 @@
 my %implIncludes = ();
 my @depsContent = ();
 my $numCachedAttributes = 0;
-my $currentCachedAttribute = 0;
 
 my $beginAppleCopyrightForHeaderFiles = <<END;
 // ------- Begin Apple Copyright -------
@@ -143,11 +142,11 @@
 
 sub GenerateDictionary
 {
-    my ($object, $dictionary, $enumerations) = @_;
+    my ($object, $dictionary, $enumerations, $otherDictionaries) = @_;
 
     my $className = GetDictionaryClassName($dictionary->type);
-    $object->GenerateDictionaryHeader($dictionary, $className, $enumerations);
-    $object->GenerateDictionaryImplementation($dictionary, $className, $enumerations);
+    $object->GenerateDictionaryHeader($dictionary, $className, $enumerations, $otherDictionaries);
+    $object->GenerateDictionaryImplementation($dictionary, $className, $enumerations, $otherDictionaries);
 }
 
 sub GenerateCallbackFunction
@@ -1224,7 +1223,7 @@
 
     my $result = "";
     foreach my $dictionary (@$allDictionaries) {
-        $headerIncludes{$interface->type->name . ".h"} = 1;
+        $headerIncludes{$interface->type->name . ".h"} = 1 if $interface;
         my $className = GetDictionaryClassName($dictionary->type, $interface);
         my $conditionalString = $codeGenerator->GenerateConditionalString($dictionary);
         $result .= GenerateDictionaryHeaderContent($dictionary, $className, $conditionalString);
@@ -3398,10 +3397,7 @@
                     push(@implContent, "    return JS" . $constructorType . "::getConstructor(state.vm(), thisObject.globalObject());\n");
                 }
             } else {
-                my $cacheIndex = 0;
                 if ($attribute->extendedAttributes->{CachedAttribute}) {
-                    $cacheIndex = $currentCachedAttribute;
-                    $currentCachedAttribute++;
                     push(@implContent, "    if (JSValue cachedValue = thisObject.m_" . $attribute->name . ".get())\n");
                     push(@implContent, "        return cachedValue;\n");
                 }
@@ -4537,7 +4533,7 @@
 
 sub GenerateDictionaryHeader
 {
-    my ($object, $dictionary, $className, $enumerations) = @_;
+    my ($object, $dictionary, $className, $enumerations, $otherDictionaries) = @_;
 
     # - Add default header template and header protection.
     push(@headerContentHeader, GenerateHeaderContentHeader($dictionary));
@@ -4548,6 +4544,7 @@
     push(@headerContent, "\nnamespace WebCore {\n\n");
     push(@headerContent, GenerateDictionaryHeaderContent($dictionary, $className));
     push(@headerContent, GenerateEnumerationsHeaderContent($dictionary, $enumerations));
+    push(@headerContent, GenerateDictionariesHeaderContent(undef, $otherDictionaries)) if $otherDictionaries;
     push(@headerContent, "} // namespace WebCore\n");
 
     my $conditionalString = $codeGenerator->GenerateConditionalString($dictionary);
@@ -4570,7 +4567,7 @@
 
 sub GenerateDictionaryImplementation
 {
-    my ($object, $dictionary, $className, $enumerations) = @_;
+    my ($object, $dictionary, $className, $enumerations, $otherDictionaries) = @_;
 
     # - Add default header template
     push(@implContentHeader, GenerateImplementationContentHeader($dictionary));
@@ -4577,8 +4574,9 @@
 
     push(@implContent, "\nusing namespace JSC;\n\n");
     push(@implContent, "namespace WebCore {\n\n");
+    push(@implContent, GenerateDictionaryImplementationContent($dictionary, $className));
     push(@implContent, GenerateEnumerationsImplementationContent($dictionary, $enumerations));
-    push(@implContent, GenerateDictionaryImplementationContent($dictionary, $className));
+    push(@implContent, GenerateDictionariesImplementationContent(undef, $otherDictionaries)) if $otherDictionaries;
     push(@implContent, "} // namespace WebCore\n");
 
     my $conditionalString = $codeGenerator->GenerateConditionalString($dictionary);
@@ -5603,10 +5601,9 @@
     my $outputDir = shift;
 
     my $name = $interface->type->name;
-    my $prefix = FileNamePrefix;
-    my $headerFileName = "$outputDir/$prefix$name.h";
-    my $implFileName = "$outputDir/$prefix$name.cpp";
-    my $depsFileName = "$outputDir/$prefix$name.dep";
+    my $headerFileName = "$outputDir/JS$name.h";
+    my $implFileName = "$outputDir/JS$name.cpp";
+    my $depsFileName = "$outputDir/JS$name.dep";
 
     # Update a .cpp file if the contents are changed.
     my $contents = join "", @implContentHeader;
@@ -5659,7 +5656,7 @@
     }
     foreach my $include (sort @includes) {
         # "JSClassName.h" is already included right after config.h.
-        next if $include eq "\"$prefix$name.h\"";
+        next if $include eq "\"JS$name.h\"";
         $contents .= "#include $include\n";
     }
 

Modified: trunk/Source/WebCore/bindings/scripts/generate-bindings.pl (209863 => 209864)


--- trunk/Source/WebCore/bindings/scripts/generate-bindings.pl	2016-12-15 16:53:38 UTC (rev 209863)
+++ trunk/Source/WebCore/bindings/scripts/generate-bindings.pl	2016-12-15 17:25:53 UTC (rev 209864)
@@ -82,7 +82,7 @@
 if ($verbose) {
     print "$generator: $targetIdlFile\n";
 }
-my $targetInterfaceName = fileparse(basename($targetIdlFile), ".idl");
+my $targetInterfaceName = fileparse($targetIdlFile, ".idl");
 
 my $idlFound = 0;
 my @supplementedIdlFiles;
@@ -100,7 +100,7 @@
     open FH, "< $supplementalDependencyFile" or die "Cannot open $supplementalDependencyFile\n";
     while (my $line = <FH>) {
         my ($idlFile, @followingIdlFiles) = split(/\s+/, $line);
-        if ($idlFile and basename($idlFile) eq basename($targetIdlFile)) {
+        if ($idlFile and fileparse($idlFile) eq fileparse($targetIdlFile)) {
             $idlFound = 1;
             @supplementedIdlFiles = sort @followingIdlFiles;
         }
@@ -112,7 +112,7 @@
     # dependency file) but should generate .h and .cpp files.
     if (!$idlFound and $additionalIdlFiles) {
         my @idlFiles = shellwords($additionalIdlFiles);
-        $idlFound = grep { $_ and basename($_) eq basename($targetIdlFile) } @idlFiles;
+        $idlFound = grep { $_ and fileparse($_) eq fileparse($targetIdlFile) } @idlFiles;
     }
 
     if (!$idlFound) {
@@ -130,13 +130,13 @@
 
 if ($idlAttributesFile) {
     my $idlAttributes = loadIDLAttributes($idlAttributesFile);
-    checkIDLAttributes($idlAttributes, $targetDocument, basename($targetIdlFile));
+    checkIDLAttributes($idlAttributes, $targetDocument, fileparse($targetIdlFile));
 }
 
 foreach my $idlFile (@supplementedIdlFiles) {
     next if $idlFile eq $targetIdlFile;
 
-    my $interfaceName = fileparse(basename($idlFile), ".idl");
+    my $interfaceName = fileparse($idlFile, ".idl");
     my $parser = IDLParser->new(!$verbose);
     my $document = $parser->Parse($idlFile, $defines, $preprocessor);
 
@@ -271,7 +271,7 @@
                 $idlAttributes{$name}{"VALUE_IS_MISSING"} = 1;
             }
         } else {
-            die "The format of " . basename($idlAttributesFile) . " is wrong: line $.\n";
+            die "The format of " . fileparse($idlAttributesFile) . " is wrong: line $.\n";
         }
     }
     close FH;

Modified: trunk/Source/WebCore/platform/mediastream/MediaConstraints.h (209863 => 209864)


--- trunk/Source/WebCore/platform/mediastream/MediaConstraints.h	2016-12-15 16:53:38 UTC (rev 209863)
+++ trunk/Source/WebCore/platform/mediastream/MediaConstraints.h	2016-12-15 17:25:53 UTC (rev 209864)
@@ -29,18 +29,12 @@
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#ifndef MediaConstraints_h
-#define MediaConstraints_h
+#pragma once
 
 #if ENABLE(MEDIA_STREAM)
 
 #include "RealtimeMediaSourceSupportedConstraints.h"
 #include <cstdlib>
-#include <wtf/HashMap.h>
-#include <wtf/RefCounted.h>
-#include <wtf/Variant.h>
-#include <wtf/text/StringHash.h>
-#include <wtf/text/WTFString.h>
 
 namespace WebCore {
 
@@ -495,7 +489,6 @@
 
     void appendExact(const String& value)
     {
-        m_exact.clear();
         m_exact.append(value);
     }
 
@@ -813,5 +806,3 @@
 SPECIALIZE_TYPE_TRAITS_MEDIACONSTRAINT(BooleanConstraint, isBoolean())
 
 #endif // ENABLE(MEDIA_STREAM)
-
-#endif // MediaConstraints_h

Modified: trunk/Source/WebCore/platform/mediastream/MediaStreamTrackPrivate.cpp (209863 => 209864)


--- trunk/Source/WebCore/platform/mediastream/MediaStreamTrackPrivate.cpp	2016-12-15 16:53:38 UTC (rev 209863)
+++ trunk/Source/WebCore/platform/mediastream/MediaStreamTrackPrivate.cpp	2016-12-15 17:25:53 UTC (rev 209864)
@@ -130,7 +130,6 @@
     auto clonedMediaStreamTrackPrivate = create(m_source.copyRef());
     clonedMediaStreamTrackPrivate->m_isEnabled = this->m_isEnabled;
     clonedMediaStreamTrackPrivate->m_isEnded = this->m_isEnded;
-    clonedMediaStreamTrackPrivate->m_constraints = this->m_constraints;
 
     return clonedMediaStreamTrackPrivate;
 }
@@ -140,11 +139,6 @@
     return m_source->type();
 }
 
-RefPtr<MediaConstraints> MediaStreamTrackPrivate::constraints() const
-{
-    return m_constraints;
-}
-
 const RealtimeMediaSourceSettings& MediaStreamTrackPrivate::settings() const
 {
     return m_source->settings();

Modified: trunk/Source/WebCore/platform/mediastream/MediaStreamTrackPrivate.h (209863 => 209864)


--- trunk/Source/WebCore/platform/mediastream/MediaStreamTrackPrivate.h	2016-12-15 16:53:38 UTC (rev 209863)
+++ trunk/Source/WebCore/platform/mediastream/MediaStreamTrackPrivate.h	2016-12-15 17:25:53 UTC (rev 209864)
@@ -24,14 +24,11 @@
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#ifndef MediaStreamTrackPrivate_h
-#define MediaStreamTrackPrivate_h
+#pragma once
 
 #if ENABLE(MEDIA_STREAM)
 
 #include "RealtimeMediaSource.h"
-#include <wtf/RefCounted.h>
-#include <wtf/text/AtomicString.h>
 
 namespace WebCore {
 
@@ -90,7 +87,6 @@
     const RealtimeMediaSourceSettings& settings() const;
     RefPtr<RealtimeMediaSourceCapabilities> capabilities() const;
 
-    RefPtr<MediaConstraints> constraints() const;
     void applyConstraints(const MediaConstraints&, RealtimeMediaSource::SuccessHandler, RealtimeMediaSource::FailureHandler);
 
     AudioSourceProvider* audioSourceProvider();
@@ -110,7 +106,6 @@
 
     Vector<Observer*> m_observers;
     Ref<RealtimeMediaSource> m_source;
-    RefPtr<MediaConstraints> m_constraints;
     RefPtr<RealtimeMediaSourcePreview> m_preview;
 
     String m_id;
@@ -123,5 +118,3 @@
 } // namespace WebCore
 
 #endif // ENABLE(MEDIA_STREAM)
-
-#endif // MediaStreamTrackPrivate_h

Modified: trunk/Source/WebKit2/ChangeLog (209863 => 209864)


--- trunk/Source/WebKit2/ChangeLog	2016-12-15 16:53:38 UTC (rev 209863)
+++ trunk/Source/WebKit2/ChangeLog	2016-12-15 17:25:53 UTC (rev 209864)
@@ -1,3 +1,14 @@
+2016-12-15  Darin Adler  <[email protected]>
+
+        Remove custom binding for MediaDevices
+        https://bugs.webkit.org/show_bug.cgi?id=165894
+
+        Reviewed by Eric Carlson.
+
+        * WebProcess/MediaStream/UserMediaPermissionRequestManager.cpp:
+        Added include of MediaConstraintsImpl.h, now needed because we
+        removed some unneeded includes from the WebCore headers.
+
 2016-12-15  Dave Hyatt  <[email protected]>
 
         [CSS Parser] Enable CSS Deferred Parsing

Modified: trunk/Source/WebKit2/WebProcess/MediaStream/UserMediaPermissionRequestManager.cpp (209863 => 209864)


--- trunk/Source/WebKit2/WebProcess/MediaStream/UserMediaPermissionRequestManager.cpp	2016-12-15 16:53:38 UTC (rev 209863)
+++ trunk/Source/WebKit2/WebProcess/MediaStream/UserMediaPermissionRequestManager.cpp	2016-12-15 17:25:53 UTC (rev 209864)
@@ -29,6 +29,7 @@
 #include <WebCore/Document.h>
 #include <WebCore/Frame.h>
 #include <WebCore/FrameLoader.h>
+#include <WebCore/MediaConstraintsImpl.h>
 #include <WebCore/SecurityOrigin.h>
 #include <WebCore/SecurityOriginData.h>
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to