Changeset 209864 in webkit


Ignore:
Timestamp:
Dec 15, 2016 9:25:53 AM (7 years ago)
Author:
Darin Adler
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.

Location:
trunk
Files:
3 added
2 deleted
25 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r209861 r209864  
     12016-12-15  Darin Adler  <darin@apple.com>
     2
     3        Remove custom binding for MediaDevices
     4        https://bugs.webkit.org/show_bug.cgi?id=165894
     5
     6        Reviewed by Eric Carlson.
     7
     8        * fast/mediastream/MediaDevices-getUserMedia-expected.txt: Expect the exception the
     9        generated bindings code throws, rather than the different one the hand-written binding
     10        was throwing before.
     11
    1122016-12-15  Youenn Fablet  <youennf@gmail.com>
    213
  • trunk/LayoutTests/fast/mediastream/MediaDevices-getUserMedia-expected.txt

    r209082 r209864  
    66PASS typeof navigator.mediaDevices.webkitGetUserMedia is 'undefined'
    77PASS navigator.mediaDevices.getUserMedia({audio:true}).then(gotStream1); did not throw exception.
    8 PASS navigator.mediaDevices.getUserMedia() rejected with error: TypeError: Not enough arguments
     8PASS navigator.mediaDevices.getUserMedia() rejected with error: TypeError: Type error
    99PASS navigator.mediaDevices.getUserMedia({}) rejected with error: TypeError: Type error
    1010PASS navigator.mediaDevices.getUserMedia.apply(undefined) rejected with error: TypeError: Can only call MediaDevices.getUserMedia on instances of MediaDevices
  • trunk/Source/WebCore/CMakeLists.txt

    r209856 r209864  
    220220    Modules/mediastream/MediaStreamTrack.idl
    221221    Modules/mediastream/MediaStreamTrackEvent.idl
     222    Modules/mediastream/MediaTrackConstraints.idl
    222223    Modules/mediastream/MediaTrackSupportedConstraints.idl
    223224    Modules/mediastream/NavigatorMediaDevices.idl
     
    908909    Modules/mediastream/MediaStreamTrack.cpp
    909910    Modules/mediastream/MediaStreamTrackEvent.cpp
     911    Modules/mediastream/MediaTrackConstraints.cpp
    910912    Modules/mediastream/NavigatorMediaDevices.cpp
    911913    Modules/mediastream/PeerConnectionBackend.cpp
     
    11631165    bindings/js/JSLocationCustom.cpp
    11641166    bindings/js/JSMainThreadExecState.cpp
    1165     bindings/js/JSMediaDevicesCustom.cpp
    11661167    bindings/js/JSMediaKeySessionCustom.cpp
    11671168    bindings/js/JSMediaKeySystemAccessCustom.cpp
  • trunk/Source/WebCore/ChangeLog

    r209862 r209864  
     12016-12-15  Darin Adler  <darin@apple.com>
     2
     3        Remove custom binding for MediaDevices
     4        https://bugs.webkit.org/show_bug.cgi?id=165894
     5
     6        Reviewed by Eric Carlson.
     7
     8        Removes the explicit code to parse the MediaStreamConstraints and
     9        MediaTrackConstraints. Next step could be to change the internal
     10        code to use the structs from bindings directly so we don't need
     11        code to convert to an internal format.
     12
     13        * CMakeLists.txt: Added MediaTrackConstraints.idl and MediaTrackConstraints.cpp,
     14        removed JSMediaDevicesCustom.cpp.
     15
     16        * DerivedSources.make: Added MediaTrackConstraints.idl.
     17        Also sorted list of IDL files and fixed use of tabs.
     18
     19        * Modules/mediastream/MediaDevices.cpp:
     20        (WebCore::createMediaConstraintsImpl): Added.
     21        (WebCore::MediaDevices::getUserMedia): Changed this function to take arguments that
     22        are generated by the bindings script, and call createMediaConstraintsImpl to convert
     23        into the internal data structure.
     24        * Modules/mediastream/MediaDevices.h: Added StreamConstraints struct and changed
     25        getUserMedia to take that as specified in the IDL.
     26        * Modules/mediastream/MediaDevices.idl: Added definition of the MediaStreamConstraints
     27        dictionary. Removed [Custom] from getUserMedia.
     28
     29        * Modules/mediastream/MediaStream.cpp:
     30        (WebCore::MediaStream::MediaStream): Pass a reference to addObserver.
     31        (WebCore::MediaStream::~MediaStream): Pass a rference to removeObserver.
     32        (WebCore::MediaStream::internalAddTrack): Ditto.
     33        (WebCore::MediaStream::internalRemoveTrack): Ditto.
     34
     35        * Modules/mediastream/MediaStreamTrack.cpp:
     36        (WebCore::createMediaConstraintsImpl): Added.
     37        (WebCore::MediaStreamTrack::applyConstraints): Changed to take an optional
     38        MediaTrackConstraints argument and call createMediaConstraintsImpl to convert
     39        into the internal data structure. Also merged the multiple overloads of this
     40        all into a single function, used auto to make the code easier to read, and
     41        moved the code that stores new constrains into the success handling, since the
     42        specification says that's the only case where we should store it.
     43        (WebCore::MediaStreamTrack::addObserver): Take a reference instead of a pointer.
     44        (WebCore::MediaStreamTrack::removeObserver): Ditto.
     45        * Modules/mediastream/MediaStreamTrack.h: Removed many unneeded includes.
     46        Changed getConstraints to return const MediaTrackConstraints&, applyConstraints
     47        to take an optional MediaTrackConstraints, add/removeObserver to take a reference
     48        rather than a pointer, and changed m_constraints to be a MediaTrackConstraints
     49        instead of a RefPtr<MediaConstraints>.
     50        * Modules/mediastream/MediaStreamTrack.idl: Removed [Custom] from getConstraints
     51        and applyConstraints.
     52
     53        * Modules/mediastream/MediaTrackConstraints.cpp: Added.
     54        (WebCore::set): Overloaded function to set constriaints in a
     55        MediaTrackConstraintSetMap.
     56        (WebCore::convertToInternalForm): Helper function that takes a
     57        MediaTrackConstraintSet and turns it into a MediaTrackConstraintSetMap.
     58        (WebCore::convertAdvancedToInternalForm): More of the same, but for vectors.
     59        (WebCore::createMediaConstraintsImpl): Top level function. Calls the other
     60        functions and then MediaConstraintsImpl::create.
     61        * Modules/mediastream/MediaTrackConstraints.h: Added. Contains all the structures
     62        and type definitions for the dictionaries defined in the IDL file, and also the
     63        createMediaConstraintsImpl function declaration.
     64        * Modules/mediastream/MediaTrackConstraints.idl: Added. Contains the
     65        MediaTrackConstraints and all the other dictionaries and typedefs that are needed
     66        to define that dictionary.
     67        * Modules/mediastream/UserMediaRequest.cpp:
     68        (WebCore::UserMediaRequest::start): Changed to not depend on MediaDevices::Promise.
     69        (WebCore::UserMediaRequest::UserMediaRequest): Ditto.
     70        (WebCore::isSecure): Rearranged to be easier to understand.
     71        (WebCore::UserMediaRequest::start): Removed a local variable for simplicity.
     72        (WebCore::UserMediaRequest::document): Removed a redundant null check.
     73        * Modules/mediastream/UserMediaRequest.h: Reduced includes, changed to not depend
     74        on MediaDevices::Promise, removing the reason to include MediaDevices.h.
     75
     76        * WebCore.xcodeproj/project.pbxproj: Updated to remove old files and add new ones.
     77
     78        * bindings/js/JSBindingsAllInOne.cpp: Removed JSMediaDevicesCustom.cpp.
     79
     80        * bindings/js/JSMediaDevicesCustom.cpp: Removed.
     81        * bindings/js/JSMediaDevicesCustom.h: Removed.
     82
     83        * bindings/js/JSMediaStreamTrackCustom.cpp:
     84        (WebCore::JSMediaStreamTrack::applyConstraints): Deleted.
     85        (WebCore::JSMediaStreamTrack::getConstraints): Deleted.
     86
     87        * bindings/scripts/CodeGenerator.pm:
     88        (ProcessDocument): Updated to allow multiple standalone dictionaries, as long as
     89        the name of one of the dictionaries matches the name of the file.
     90
     91        * bindings/scripts/CodeGeneratorJS.pm:
     92        (GenerateDictionary): Added "other dictionaries" argument so we can support
     93        files with multiple dictionaries in them.
     94        (GenerateDictionariesHeaderContent): Completed support for dictionaries that
     95        are not named after a top level interface by added one more check for a missing
     96        $interface in a place that otherwise would not handle it correctly.
     97        (GenerateImplementation): Removed code that set $currentCachedAttribute and
     98        $cacheIndex, since no was reading the value of either any longer.
     99        (GenerateDictionaryHeader): Added "other dictionaries".
     100        (GenerateDictionaryImplementation): Ditto.
     101        (WriteData): Removed unnnecessarily indirect code that was using FileNamePrefix
     102        and a local variable named $prefix instead of just writing "JS".
     103
     104        * bindings/scripts/generate-bindings.pl: Corrected the use of the fileparse
     105        function from the Path::Basename module; after reading the documentation for
     106        this it is clear that there is no need to first call basename, and fileparse
     107        should also be used instead of basename.
     108
     109        * platform/mediastream/MediaConstraints.h: Removed unneeded includes.
     110        (WebCore::StringConstraint::appendExact): Removed an incorrect use of clear
     111        here that would mess up cases where there is supposed to be more than one
     112        exact value.
     113
     114        * platform/mediastream/MediaStreamTrackPrivate.cpp: Remvoed unneeded includes.
     115        (WebCore::MediaStreamTrackPrivate::clone): Removed code to copy m_constraints.
     116        (WebCore::MediaStreamTrackPrivate::constraints): Deleted.
     117        * platform/mediastream/MediaStreamTrackPrivate.h: Removed the constraints
     118        function member and the m_constraints data member.
     119
    11202016-12-15  Dave Hyatt  <hyatt@apple.com>
    2121
  • trunk/Source/WebCore/DerivedSources.make

    r209805 r209864  
    153153    $(WebCore)/Modules/mediastream/MediaStreamTrack.idl \
    154154    $(WebCore)/Modules/mediastream/MediaStreamTrackEvent.idl \
     155    $(WebCore)/Modules/mediastream/MediaTrackConstraints.idl \
    155156    $(WebCore)/Modules/mediastream/MediaTrackSupportedConstraints.idl \
    156157    $(WebCore)/Modules/mediastream/NavigatorMediaDevices.idl \
     
    255256    $(WebCore)/crypto/CryptoKeyUsage.idl \
    256257    $(WebCore)/crypto/JsonWebKey.idl \
     258    $(WebCore)/crypto/RsaOtherPrimesInfo.idl \
     259    $(WebCore)/crypto/SubtleCrypto.idl \
     260    $(WebCore)/crypto/WebKitSubtleCrypto.idl \
    257261    $(WebCore)/crypto/parameters/AesCbcParams.idl \
    258262    $(WebCore)/crypto/parameters/AesKeyGenParams.idl \
     
    262266    $(WebCore)/crypto/parameters/RsaKeyGenParams.idl \
    263267    $(WebCore)/crypto/parameters/RsaOaepParams.idl \
    264     $(WebCore)/crypto/RsaOtherPrimesInfo.idl \
    265     $(WebCore)/crypto/SubtleCrypto.idl \
    266     $(WebCore)/crypto/WebKitSubtleCrypto.idl \
    267268    $(WebCore)/css/CSSFontFaceLoadEvent.idl \
    268269    $(WebCore)/css/CSSFontFaceRule.idl \
     
    271272    $(WebCore)/css/CSSKeyframesRule.idl \
    272273    $(WebCore)/css/CSSMediaRule.idl \
    273         $(WebCore)/css/CSSNamespaceRule.idl \
     274    $(WebCore)/css/CSSNamespaceRule.idl \
    274275    $(WebCore)/css/CSSPageRule.idl \
    275276    $(WebCore)/css/CSSPrimitiveValue.idl \
     
    308309    $(WebCore)/dom/ClientRect.idl \
    309310    $(WebCore)/dom/ClientRectList.idl \
     311    $(WebCore)/dom/ClipboardEvent.idl \
    310312    $(WebCore)/dom/Comment.idl \
    311     $(WebCore)/dom/ClipboardEvent.idl \
    312313    $(WebCore)/dom/CompositionEvent.idl \
    313314    $(WebCore)/dom/CustomElementRegistry.idl \
  • trunk/Source/WebCore/Modules/mediastream/MediaDevices.cpp

    r208663 r209864  
    3535
    3636#include "Document.h"
     37#include "MediaConstraintsImpl.h"
    3738#include "MediaDevicesRequest.h"
    3839#include "MediaTrackSupportedConstraints.h"
     
    5758}
    5859
    59 ExceptionOr<void> MediaDevices::getUserMedia(Ref<MediaConstraintsImpl>&& audioConstraints, Ref<MediaConstraintsImpl>&& videoConstraints, Promise&& promise) const
     60static Ref<MediaConstraintsImpl> createMediaConstraintsImpl(const Variant<bool, MediaTrackConstraints>& constraints)
     61{
     62    return WTF::switchOn(constraints,
     63        [&] (bool constraints) {
     64            return MediaConstraintsImpl::create({ }, { }, constraints);
     65        },
     66        [&] (const MediaTrackConstraints& constraints) {
     67            return createMediaConstraintsImpl(constraints);
     68        }
     69    );
     70}
     71
     72ExceptionOr<void> MediaDevices::getUserMedia(const StreamConstraints& constraints, Promise&& promise) const
    6073{
    6174    auto* document = this->document();
    6275    if (!document)
    6376        return Exception { INVALID_STATE_ERR };
    64     return UserMediaRequest::start(*document, WTFMove(audioConstraints), WTFMove(videoConstraints), WTFMove(promise));
     77    return UserMediaRequest::start(*document, createMediaConstraintsImpl(constraints.audio), createMediaConstraintsImpl(constraints.video), WTFMove(promise));
    6578}
    6679
  • trunk/Source/WebCore/Modules/mediastream/MediaDevices.h

    r209390 r209864  
    11/*
    22 * Copyright (C) 2015 Ericsson AB. All rights reserved.
     3 * Copyright (C) 2016 Apple Inc. All rights reserved.
    34 *
    45 * Redistribution and use in source and binary forms, with or without
     
    3536#include "ExceptionOr.h"
    3637#include "JSDOMPromise.h"
    37 #include "MediaDeviceInfo.h"
     38#include "MediaTrackConstraints.h"
    3839
    3940namespace WebCore {
    4041
    4142class Document;
    42 class MediaConstraintsImpl;
     43class MediaDeviceInfo;
    4344class MediaStream;
    4445class MediaTrackSupportedConstraints;
     
    5354    using EnumerateDevicesPromise = DOMPromise<IDLSequence<IDLInterface<MediaDeviceInfo>>>;
    5455
    55     ExceptionOr<void> getUserMedia(Ref<MediaConstraintsImpl>&& audioConstraints, Ref<MediaConstraintsImpl>&& videoConstraints, Promise&&) const;
     56    struct StreamConstraints {
     57        Variant<bool, MediaTrackConstraints> video;
     58        Variant<bool, MediaTrackConstraints> audio;
     59    };
     60    ExceptionOr<void> getUserMedia(const StreamConstraints&, Promise&&) const;
    5661    void enumerateDevices(EnumerateDevicesPromise&&) const;
    5762    RefPtr<MediaTrackSupportedConstraints> getSupportedConstraints();
  • trunk/Source/WebCore/Modules/mediastream/MediaDevices.idl

    r209752 r209864  
    3030
    3131[
     32    Conditional=MEDIA_STREAM,
    3233    NoInterfaceObject,
    33     Conditional=MEDIA_STREAM
    3434] interface MediaDevices {
    3535    MediaTrackSupportedConstraints getSupportedConstraints();
    3636
    37     [Custom, MayThrowException, PrivateIdentifier, PublicIdentifier] Promise<MediaStream> getUserMedia(optional MediaStreamConstraints constraints);
     37    [MayThrowException, PrivateIdentifier, PublicIdentifier] Promise<MediaStream> getUserMedia(optional MediaStreamConstraints constraints);
    3838    Promise<sequence<MediaDeviceInfo>> enumerateDevices();
    3939};
     40
     41dictionary MediaStreamConstraints {
     42    (boolean or MediaTrackConstraints) video = false;
     43    (boolean or MediaTrackConstraints) audio = false;
     44};
  • trunk/Source/WebCore/Modules/mediastream/MediaStream.cpp

    r208778 r209864  
    7373
    7474    for (auto& track : tracks) {
    75         track->addObserver(this);
     75        track->addObserver(*this);
    7676        m_trackSet.add(track->id(), track);
    7777        trackPrivates.append(&track->privateTrack());
     
    9797    for (auto& trackPrivate : m_private->tracks()) {
    9898        auto track = MediaStreamTrack::create(context, *trackPrivate);
    99         track->addObserver(this);
     99        track->addObserver(*this);
    100100        m_trackSet.add(track->id(), WTFMove(track));
    101101    }
     
    111111    m_private->removeObserver(*this);
    112112    for (auto& track : m_trackSet.values())
    113         track->removeObserver(this);
     113        track->removeObserver(*this);
    114114    if (Document* document = this->document()) {
    115115        document->removeAudioProducer(this);
     
    216216    ASSERT(result.iterator->value);
    217217    auto& track = *result.iterator->value;
    218     track.addObserver(this);
     218    track.addObserver(*this);
    219219
    220220    if (streamModifier == StreamModifier::DomAPI)
     
    232232        return false;
    233233
    234     track->removeObserver(this);
     234    track->removeObserver(*this);
    235235
    236236    if (streamModifier == StreamModifier::DomAPI)
  • trunk/Source/WebCore/Modules/mediastream/MediaStreamTrack.cpp

    r209446 r209864  
    159159}
    160160
    161 void MediaStreamTrack::applyConstraints(Ref<MediaConstraints>&& constraints, DOMPromise<void>&& promise)
    162 {
    163     if (!constraints->isValid()) {
    164         promise.reject(TypeError);
    165         return;
    166     }
    167 
    168     m_constraints = WTFMove(constraints);
     161static Ref<MediaConstraintsImpl> createMediaConstraintsImpl(const std::optional<MediaTrackConstraints>& constraints)
     162{
     163    if (!constraints)
     164        return MediaConstraintsImpl::create({ }, { }, true);
     165    return createMediaConstraintsImpl(constraints.value());
     166}
     167
     168void MediaStreamTrack::applyConstraints(const std::optional<MediaTrackConstraints>& constraints, DOMPromise<void>&& promise)
     169{
    169170    m_promise = WTFMove(promise);
    170171
    171     applyConstraints(*m_constraints);
    172 }
    173 
    174 void MediaStreamTrack::applyConstraints(const MediaConstraints& constraints)
    175 {
    176172    auto weakThis = createWeakPtr();
    177     std::function<void(const String&, const String&)> failureHandler = [weakThis](const String& failedConstraint, const String& message) {
     173    auto failureHandler = [weakThis] (const String& failedConstraint, const String& message) {
    178174        if (!weakThis || !weakThis->m_promise)
    179175            return;
    180 
    181176        weakThis->m_promise->rejectType<IDLInterface<OverconstrainedError>>(OverconstrainedError::create(failedConstraint, message).get());
    182177    };
    183 
    184     std::function<void()> successHandler = [weakThis]() {
     178    auto successHandler = [weakThis, constraints] () {
    185179        if (!weakThis || !weakThis->m_promise)
    186180            return;
    187 
    188181        weakThis->m_promise->resolve();
     182        weakThis->m_constraints = constraints.value_or(MediaTrackConstraints { });
    189183    };
    190 
    191     m_private->applyConstraints(constraints, successHandler, failureHandler);
    192 }
    193 
    194 void MediaStreamTrack::addObserver(MediaStreamTrack::Observer* observer)
    195 {
    196     m_observers.append(observer);
    197 }
    198 
    199 void MediaStreamTrack::removeObserver(MediaStreamTrack::Observer* observer)
    200 {
    201     size_t pos = m_observers.find(observer);
    202     if (pos != notFound)
    203         m_observers.remove(pos);
     184    m_private->applyConstraints(createMediaConstraintsImpl(constraints), successHandler, failureHandler);
     185}
     186
     187void MediaStreamTrack::addObserver(Observer& observer)
     188{
     189    m_observers.append(&observer);
     190}
     191
     192void MediaStreamTrack::removeObserver(Observer& observer)
     193{
     194    m_observers.removeFirst(&observer);
    204195}
    205196
  • trunk/Source/WebCore/Modules/mediastream/MediaStreamTrack.h

    r209446 r209864  
    3434#include "JSDOMPromise.h"
    3535#include "MediaStreamTrackPrivate.h"
    36 #include "RealtimeMediaSource.h"
    37 #include "ScriptWrappable.h"
    38 #include <wtf/Optional.h>
    39 #include <wtf/RefPtr.h>
    40 #include <wtf/Vector.h>
    41 #include <wtf/WeakPtr.h>
    42 #include <wtf/text/WTFString.h>
     36#include "MediaTrackConstraints.h"
    4337
    4438namespace WebCore {
     
    4741class MediaConstraints;
    4842class MediaSourceSettings;
     43
     44struct MediaTrackConstraints;
    4945
    5046class MediaStreamTrack final : public RefCounted<MediaStreamTrack>, public ActiveDOMObject, public EventTargetWithInlineData, private MediaStreamTrackPrivate::Observer {
     
    8177    RefPtr<RealtimeMediaSourceCapabilities> getCapabilities() const;
    8278
    83     void applyConstraints(Ref<MediaConstraints>&&, DOMPromise<void>&&);
    84     void applyConstraints(const MediaConstraints&);
     79    const MediaTrackConstraints& getConstraints() const { return m_constraints; }
     80    void applyConstraints(const std::optional<MediaTrackConstraints>&, DOMPromise<void>&&);
    8581
    8682    RealtimeMediaSource& source() { return m_private->source(); }
     
    8985    AudioSourceProvider* audioSourceProvider();
    9086
    91     void addObserver(Observer*);
    92     void removeObserver(Observer*);
     87    void addObserver(Observer&);
     88    void removeObserver(Observer&);
    9389
    94     // EventTarget
    95     EventTargetInterface eventTargetInterface() const final { return MediaStreamTrackEventTargetInterfaceType; }
    96     ScriptExecutionContext* scriptExecutionContext() const final { return ActiveDOMObject::scriptExecutionContext(); }
    97 
    98     using RefCounted<MediaStreamTrack>::ref;
    99     using RefCounted<MediaStreamTrack>::deref;
     90    using RefCounted::ref;
     91    using RefCounted::deref;
    10092
    10193private:
     
    113105    void refEventTarget() final { ref(); }
    114106    void derefEventTarget() final { deref(); }
     107    EventTargetInterface eventTargetInterface() const final { return MediaStreamTrackEventTargetInterfaceType; }
     108    ScriptExecutionContext* scriptExecutionContext() const final { return ActiveDOMObject::scriptExecutionContext(); }
    115109
    116110    // MediaStreamTrackPrivate::Observer
     
    125119    Ref<MediaStreamTrackPrivate> m_private;
    126120
    127     RefPtr<MediaConstraints> m_constraints;
     121    MediaTrackConstraints m_constraints;
    128122    std::optional<DOMPromise<void>> m_promise;
    129123    WeakPtrFactory<MediaStreamTrack> m_weakPtrFactory;
  • trunk/Source/WebCore/Modules/mediastream/MediaStreamTrack.idl

    r208474 r209864  
    4848    [ImplementedAs=stopProducingData] void stop();
    4949
    50     [Custom] MediaTrackConstraints getConstraints();
     50    MediaTrackConstraints getConstraints();
    5151    [Custom] MediaSourceSettings getSettings();
    5252    [Custom] MediaTrackCapabilities getCapabilities();
    53     [Custom] Promise<void> applyConstraints(optional MediaTrackConstraints constraints);
     53    Promise<void> applyConstraints(optional MediaTrackConstraints constraints);
    5454
    5555    attribute EventHandler onoverconstrained;
    5656};
    57 
  • trunk/Source/WebCore/Modules/mediastream/UserMediaRequest.cpp

    r209390 r209864  
    3737#if ENABLE(MEDIA_STREAM)
    3838
     39#include "Document.h"
    3940#include "DocumentLoader.h"
    4041#include "ExceptionCode.h"
    41 #include "Frame.h"
    4242#include "JSMediaStream.h"
    4343#include "JSOverconstrainedError.h"
    4444#include "MainFrame.h"
    45 #include "MediaStream.h"
    46 #include "MediaStreamPrivate.h"
    47 #include "OverconstrainedError.h"
     45#include "MediaConstraintsImpl.h"
    4846#include "RealtimeMediaSourceCenter.h"
    49 #include "SecurityOrigin.h"
    5047#include "Settings.h"
    5148#include "UserMediaController.h"
    52 #include <wtf/MainThread.h>
    5349
    5450namespace WebCore {
    5551
    56 ExceptionOr<void> UserMediaRequest::start(Document& document, Ref<MediaConstraintsImpl>&& audioConstraints, Ref<MediaConstraintsImpl>&& videoConstraints, MediaDevices::Promise&& promise)
     52ExceptionOr<void> UserMediaRequest::start(Document& document, Ref<MediaConstraintsImpl>&& audioConstraints, Ref<MediaConstraintsImpl>&& videoConstraints, DOMPromise<IDLInterface<MediaStream>>&& promise)
    5753{
    5854    auto* userMedia = UserMediaController::from(document.page());
     
    6965}
    7066
    71 UserMediaRequest::UserMediaRequest(Document& document, UserMediaController& controller, Ref<MediaConstraintsImpl>&& audioConstraints, Ref<MediaConstraintsImpl>&& videoConstraints, MediaDevices::Promise&& promise)
     67UserMediaRequest::UserMediaRequest(Document& document, UserMediaController& controller, Ref<MediaConstraintsImpl>&& audioConstraints, Ref<MediaConstraintsImpl>&& videoConstraints, DOMPromise<IDLInterface<MediaStream>>&& promise)
    7268    : ContextDestructionObserver(&document)
    7369    , m_audioConstraints(WTFMove(audioConstraints))
     
    8682    if (!m_scriptExecutionContext)
    8783        return nullptr;
    88 
    8984    return m_scriptExecutionContext->securityOrigin();
    9085}
     
    9489    if (!m_scriptExecutionContext)
    9590        return nullptr;
    96 
    9791    return m_scriptExecutionContext->topOrigin();
    9892}
     
    10094static bool isSecure(DocumentLoader& documentLoader)
    10195{
    102     if (!documentLoader.response().url().protocolIs("https"))
    103         return false;
    104 
    105     if (!documentLoader.response().certificateInfo() || documentLoader.response().certificateInfo()->containsNonRootSHA1SignedCertificate())
    106         return false;
    107 
    108     return true;
     96    auto& response = documentLoader.response();
     97    return response.url().protocolIs("https")
     98        && response.certificateInfo()
     99        && !response.certificateInfo()->containsNonRootSHA1SignedCertificate();
    109100}
    110101
     
    150141
    151142    Document& document = downcast<Document>(*m_scriptExecutionContext);
    152     DOMWindow& window = *document.domWindow();
    153143
    154144    // 10.2 - 6.3 Optionally, e.g., based on a previously-established user preference, for security reasons,
     
    157147    if (!canCallGetUserMedia(document, errorMessage)) {
    158148        deny(MediaAccessDenialReason::PermissionDenied, emptyString());
    159         window.printErrorMessage(errorMessage);
     149        document.domWindow()->printErrorMessage(errorMessage);
    160150        return;
    161151    }
     
    231221    ContextDestructionObserver::contextDestroyed();
    232222    Ref<UserMediaRequest> protectedThis(*this);
    233 
    234223    if (m_controller) {
    235224        m_controller->cancelUserMediaAccessRequest(*this);
     
    240229Document* UserMediaRequest::document() const
    241230{
    242     if (!m_scriptExecutionContext)
    243         return nullptr;
    244 
    245231    return downcast<Document>(m_scriptExecutionContext);
    246232}
  • trunk/Source/WebCore/Modules/mediastream/UserMediaRequest.h

    r208730 r209864  
    3636
    3737#include "ActiveDOMObject.h"
    38 #include "Document.h"
    39 #include "MediaConstraintsImpl.h"
    40 #include "MediaDevices.h"
     38#include "JSDOMPromise.h"
    4139
    4240namespace WebCore {
    4341
    44 class MediaConstraints;
    45 class MediaStreamPrivate;
     42class MediaConstraintsImpl;
     43class MediaStream;
     44class SecurityOrigin;
    4645class UserMediaController;
    47 class SecurityOrigin;
    4846
    4947class UserMediaRequest : public RefCounted<UserMediaRequest>, private ContextDestructionObserver {
    5048public:
    51     static ExceptionOr<void> start(Document&, Ref<MediaConstraintsImpl>&& audioConstraints, Ref<MediaConstraintsImpl>&& videoConstraints, MediaDevices::Promise&&);
     49    static ExceptionOr<void> start(Document&, Ref<MediaConstraintsImpl>&& audioConstraints, Ref<MediaConstraintsImpl>&& videoConstraints, DOMPromise<IDLInterface<MediaStream>>&&);
    5250
    5351    virtual ~UserMediaRequest();
     
    7573
    7674private:
    77     UserMediaRequest(Document&, UserMediaController&, Ref<MediaConstraintsImpl>&& audioConstraints, Ref<MediaConstraintsImpl>&& videoConstraints, MediaDevices::Promise&&);
     75    UserMediaRequest(Document&, UserMediaController&, Ref<MediaConstraintsImpl>&& audioConstraints, Ref<MediaConstraintsImpl>&& videoConstraints, DOMPromise<IDLInterface<MediaStream>>&&);
    7876
    7977    void contextDestroyed() final;
     
    8987
    9088    UserMediaController* m_controller;
    91     MediaDevices::Promise m_promise;
     89    DOMPromise<IDLInterface<MediaStream>> m_promise;
    9290    RefPtr<UserMediaRequest> m_protector;
    9391};
  • trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj

    r209826 r209864  
    126126                07277E5517D018CC0015534D /* JSMediaStreamTrackEvent.h in Headers */ = {isa = PBXBuildFile; fileRef = 07277E4917D018CC0015534D /* JSMediaStreamTrackEvent.h */; };
    127127                072A70401D6E8F6200DF0AFC /* OverconstrainedErrorEvent.h in Headers */ = {isa = PBXBuildFile; fileRef = 072A703E1D6E8F6200DF0AFC /* OverconstrainedErrorEvent.h */; };
    128                 072A70431D7396B300DF0AFC /* JSMediaDevicesCustom.h in Headers */ = {isa = PBXBuildFile; fileRef = 072A70421D7396B200DF0AFC /* JSMediaDevicesCustom.h */; };
    129128                072AE1E5183C0741000A5988 /* PluginReplacement.h in Headers */ = {isa = PBXBuildFile; fileRef = 072AE1DF183C0741000A5988 /* PluginReplacement.h */; settings = {ATTRIBUTES = (Private, ); }; };
    130129                072AE1E6183C0741000A5988 /* QuickTimePluginReplacement.mm in Sources */ = {isa = PBXBuildFile; fileRef = 072AE1E0183C0741000A5988 /* QuickTimePluginReplacement.mm */; };
     
    990989                1B124D8D1D380B7000ECDFB0 /* MediaSampleAVFObjC.h in Headers */ = {isa = PBXBuildFile; fileRef = 1B124D8C1D380B7000ECDFB0 /* MediaSampleAVFObjC.h */; };
    991990                1B124D8F1D380BB600ECDFB0 /* MediaSampleAVFObjC.mm in Sources */ = {isa = PBXBuildFile; fileRef = 1B124D8E1D380BB600ECDFB0 /* MediaSampleAVFObjC.mm */; };
    992                 1B88DD131D5B9E5000E3B7A4 /* JSMediaDevicesCustom.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1B88DD121D5AD3B200E3B7A4 /* JSMediaDevicesCustom.cpp */; };
    993991                1BE5BFC21D515715001666D9 /* MediaConstraints.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1BE5BFC11D515715001666D9 /* MediaConstraints.cpp */; };
    994992                1BF9DB3C1D3973AD0026AEB7 /* MediaSample.h in Headers */ = {isa = PBXBuildFile; fileRef = CD641EC7181ED60100EE4C41 /* MediaSample.h */; settings = {ATTRIBUTES = (Private, ); }; };
     
    32623260                932AD70517EFA2C30038F8FF /* MainFrame.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 932AD70317EFA2C30038F8FF /* MainFrame.cpp */; };
    32633261                932AD70617EFA2C40038F8FF /* MainFrame.h in Headers */ = {isa = PBXBuildFile; fileRef = 932AD70417EFA2C30038F8FF /* MainFrame.h */; settings = {ATTRIBUTES = (Private, ); }; };
     3262                932CC0B71DFFD158004C0F9F /* MediaTrackConstraints.h in Headers */ = {isa = PBXBuildFile; fileRef = 932CC0B61DFFD158004C0F9F /* MediaTrackConstraints.h */; };
     3263                932CC0D41DFFD667004C0F9F /* JSMediaTrackConstraints.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 932CC0D01DFFD667004C0F9F /* JSMediaTrackConstraints.cpp */; };
     3264                932CC0D51DFFD667004C0F9F /* JSMediaTrackConstraints.h in Headers */ = {isa = PBXBuildFile; fileRef = 932CC0D11DFFD667004C0F9F /* JSMediaTrackConstraints.h */; };
     3265                932CC0F71DFFDA1F004C0F9F /* MediaTrackConstraints.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 932CC0F61DFFDA1F004C0F9F /* MediaTrackConstraints.cpp */; };
    32643266                932E16090AF578340025F408 /* FrameLoader.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 932E16080AF578340025F408 /* FrameLoader.cpp */; };
    32653267                93309DD6099E64920056E581 /* AppendNodeCommand.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 93309D87099E64910056E581 /* AppendNodeCommand.cpp */; };
     
    71167118                072A703E1D6E8F6200DF0AFC /* OverconstrainedErrorEvent.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OverconstrainedErrorEvent.h; sourceTree = "<group>"; };
    71177119                072A703F1D6E8F6200DF0AFC /* OverconstrainedErrorEvent.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = OverconstrainedErrorEvent.idl; sourceTree = "<group>"; };
    7118                 072A70421D7396B200DF0AFC /* JSMediaDevicesCustom.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSMediaDevicesCustom.h; sourceTree = "<group>"; };
    71197120                072AE1DF183C0741000A5988 /* PluginReplacement.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PluginReplacement.h; sourceTree = "<group>"; };
    71207121                072AE1E0183C0741000A5988 /* QuickTimePluginReplacement.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = QuickTimePluginReplacement.mm; sourceTree = "<group>"; };
     
    80418042                1B124D8C1D380B7000ECDFB0 /* MediaSampleAVFObjC.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = MediaSampleAVFObjC.h; path = ../MediaSampleAVFObjC.h; sourceTree = "<group>"; };
    80428043                1B124D8E1D380BB600ECDFB0 /* MediaSampleAVFObjC.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = MediaSampleAVFObjC.mm; sourceTree = "<group>"; };
    8043                 1B88DD121D5AD3B200E3B7A4 /* JSMediaDevicesCustom.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = JSMediaDevicesCustom.cpp; sourceTree = "<group>"; };
    80448044                1BE5BFC11D515715001666D9 /* MediaConstraints.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MediaConstraints.cpp; sourceTree = "<group>"; };
    80458045                1C0106FE192594DF008A4201 /* InlineTextBoxStyle.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = InlineTextBoxStyle.cpp; sourceTree = "<group>"; };
     
    1081510815                932AD70317EFA2C30038F8FF /* MainFrame.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MainFrame.cpp; sourceTree = "<group>"; };
    1081610816                932AD70417EFA2C30038F8FF /* MainFrame.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MainFrame.h; sourceTree = "<group>"; };
     10817                932CC0B61DFFD158004C0F9F /* MediaTrackConstraints.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MediaTrackConstraints.h; sourceTree = "<group>"; };
     10818                932CC0D01DFFD667004C0F9F /* JSMediaTrackConstraints.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSMediaTrackConstraints.cpp; sourceTree = "<group>"; };
     10819                932CC0D11DFFD667004C0F9F /* JSMediaTrackConstraints.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSMediaTrackConstraints.h; sourceTree = "<group>"; };
     10820                932CC0F01DFFD8D4004C0F9F /* MediaTrackConstraints.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = MediaTrackConstraints.idl; sourceTree = "<group>"; };
     10821                932CC0F61DFFDA1F004C0F9F /* MediaTrackConstraints.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MediaTrackConstraints.cpp; sourceTree = "<group>"; };
    1081710822                932E16080AF578340025F408 /* FrameLoader.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = FrameLoader.cpp; sourceTree = "<group>"; };
    1081810823                93309D87099E64910056E581 /* AppendNodeCommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = AppendNodeCommand.cpp; sourceTree = "<group>"; };
     
    1502715032                                07221B5817CEC32700848E51 /* MediaStreamTrackEvent.h */,
    1502815033                                07221B5917CEC32700848E51 /* MediaStreamTrackEvent.idl */,
     15034                                932CC0F61DFFDA1F004C0F9F /* MediaTrackConstraints.cpp */,
     15035                                932CC0B61DFFD158004C0F9F /* MediaTrackConstraints.h */,
     15036                                932CC0F01DFFD8D4004C0F9F /* MediaTrackConstraints.idl */,
    1502915037                                07C1C0E01BFB600100BD2256 /* MediaTrackSupportedConstraints.h */,
    1503015038                                07C1C0E11BFB600100BD2256 /* MediaTrackSupportedConstraints.idl */,
     
    1523915247                                07277E4817D018CC0015534D /* JSMediaStreamTrackEvent.cpp */,
    1524015248                                07277E4917D018CC0015534D /* JSMediaStreamTrackEvent.h */,
     15249                                932CC0D01DFFD667004C0F9F /* JSMediaTrackConstraints.cpp */,
     15250                                932CC0D11DFFD667004C0F9F /* JSMediaTrackConstraints.h */,
    1524115251                                0787C4671BFBDF6F006DCD7F /* JSMediaTrackSupportedConstraints.cpp */,
    1524215252                                0787C4681BFBDF6F006DCD7F /* JSMediaTrackSupportedConstraints.h */,
     
    2202522035                                7A74ECBC101839DA00BF939E /* JSInspectorFrontendHostCustom.cpp */,
    2202622036                                BCE1C43F0D9830F4003B02F2 /* JSLocationCustom.cpp */,
    22027                                 1B88DD121D5AD3B200E3B7A4 /* JSMediaDevicesCustom.cpp */,
    22028                                 072A70421D7396B200DF0AFC /* JSMediaDevicesCustom.h */,
    2202922037                                AD726FE716D9F204003A4E6D /* JSMediaListCustom.h */,
    2203022038                                07C59B6D17F794F6000FBCBB /* JSMediaStreamTrackCustom.cpp */,
     
    2552325531                                B6D9D23514EABD260090D75E /* FocusEvent.h in Headers */,
    2552425532                                B2C3DA650D006CD600EF6F26 /* Font.h in Headers */,
     25533                                932CC0B71DFFD158004C0F9F /* MediaTrackConstraints.h in Headers */,
    2552525534                                1AC2D89D1B1E291F00D52E87 /* FontAntialiasingStateSaver.h in Headers */,
    2552625535                                BCB92D4F1293550B00C8387F /* FontBaseline.h in Headers */,
     
    2621426223                                159741DB1B7D140100201C92 /* JSMediaDeviceInfo.h in Headers */,
    2621526224                                15739BBB1B42012D00D258C1 /* JSMediaDevices.h in Headers */,
    26216                                 072A70431D7396B300DF0AFC /* JSMediaDevicesCustom.h in Headers */,
    2621726225                                FD23A12613F5FA5900F67001 /* JSMediaElementAudioSourceNode.h in Headers */,
    2621826226                                2D9BF7121DBFD914007A7D99 /* JSMediaEncryptedEvent.h in Headers */,
     
    2824628254                                14476AA815DC4BB100305DB2 /* WritingMode.h in Headers */,
    2824728255                                6565820209D1508D000E61D7 /* XLinkNames.h in Headers */,
     28256                                932CC0D51DFFD667004C0F9F /* JSMediaTrackConstraints.h in Headers */,
    2824828257                                830784B21C52EE2C00104D1D /* XMLDocument.h in Headers */,
    2824928258                                00B9318813BA8DBA0035A948 /* XMLDocumentParser.h in Headers */,
     
    2893628945                                CAE9F90F146441F000C245B0 /* CSSAspectRatioValue.cpp in Sources */,
    2893728946                                94DE5C811D7F3A1400164F2A /* CSSAtRuleID.cpp in Sources */,
     28947                                932CC0F71DFFDA1F004C0F9F /* MediaTrackConstraints.cpp in Sources */,
    2893828948                                FBD6AF8B15EF25E5008B7110 /* CSSBasicShapes.cpp in Sources */,
    2893928949                                E16A84F914C85CCC002977DF /* CSSBorderImage.cpp in Sources */,
     
    2984229852                                BCE7B1930D4E86960075A539 /* JSHistoryCustom.cpp in Sources */,
    2984329853                                57E233691DCAB24300F28D01 /* JSHmacKeyParams.cpp in Sources */,
     29854                                932CC0D41DFFD667004C0F9F /* JSMediaTrackConstraints.cpp in Sources */,
    2984429855                                BC97E412109154FA0010D361 /* JSHTMLAllCollection.cpp in Sources */,
    2984529856                                BC97E42C10915B060010D361 /* JSHTMLAllCollectionCustom.cpp in Sources */,
     
    2997629987                                159741DA1B7D13F900201C92 /* JSMediaDeviceInfo.cpp in Sources */,
    2997729988                                15739BBA1B42012A00D258C1 /* JSMediaDevices.cpp in Sources */,
    29978                                 1B88DD131D5B9E5000E3B7A4 /* JSMediaDevicesCustom.cpp in Sources */,
    2997929989                                FD23A12513F5FA5900F67001 /* JSMediaElementAudioSourceNode.cpp in Sources */,
    2998029990                                2D9BF7101DBFD8CE007A7D99 /* JSMediaEncryptedEvent.cpp in Sources */,
  • trunk/Source/WebCore/bindings/js/JSBindingsAllInOne.cpp

    r209674 r209864  
    100100#include "JSLocationCustom.cpp"
    101101#include "JSMainThreadExecState.cpp"
    102 #include "JSMediaDevicesCustom.cpp"
    103102#include "JSMessageChannelCustom.cpp"
    104103#include "JSMessageEventCustom.cpp"
  • trunk/Source/WebCore/bindings/js/JSMediaStreamTrackCustom.cpp

    r208124 r209864  
    3232#include "ExceptionCode.h"
    3333#include "JSDOMBinding.h"
    34 #include "JSMediaDevicesCustom.h"
    35 #include "MediaConstraintsImpl.h"
    3634#include "MediaSourceSettings.h"
    3735#include "MediaStreamTrack.h"
     
    167165}
    168166
    169 JSValue JSMediaStreamTrack::applyConstraints(ExecState& state)
    170 {
    171     MediaTrackConstraintSetMap mandatoryConstraints;
    172     Vector<MediaTrackConstraintSetMap> advancedConstraints;
    173     bool valid = false;
    174 
    175     if (state.argumentCount() >= 1) {
    176         JSValue argument = state.uncheckedArgument(0);
    177 
    178         JSVMClientData& clientData = *static_cast<JSVMClientData*>(state.vm().clientData);
    179         putDirect(state.vm(), clientData.builtinNames().mediaStreamTrackConstraintsPrivateName(), argument, DontEnum);
    180 
    181         auto constraintsDictionary = Dictionary(&state, argument);
    182         if (!constraintsDictionary.isUndefinedOrNull())
    183             parseMediaConstraintsDictionary(constraintsDictionary, mandatoryConstraints, advancedConstraints);
    184         valid = !advancedConstraints.isEmpty() || !mandatoryConstraints.isEmpty();
    185     }
    186 
    187     auto deferredPromise = createDeferredPromise(state, domWindow());
    188     auto promise = deferredPromise->promise();
    189 
    190     auto constraints = MediaConstraintsImpl::create(WTFMove(mandatoryConstraints), WTFMove(advancedConstraints), valid);
    191     wrapped().applyConstraints(WTFMove(constraints), WTFMove(deferredPromise));
    192 
    193     return promise;
    194 }
    195 
    196 JSValue JSMediaStreamTrack::getConstraints(ExecState& state)
    197 {
    198     JSVMClientData& clientData = *static_cast<JSVMClientData*>(state.vm().clientData);
    199     JSValue result = getDirect(state.vm(), clientData.builtinNames().mediaStreamTrackConstraintsPrivateName());
    200     return !result.isEmpty() ? result : jsUndefined();
    201 }
    202 
    203167} // namespace WebCore
    204168
  • trunk/Source/WebCore/bindings/scripts/CodeGenerator.pm

    r209752 r209864  
    2929use strict;
    3030
     31use File::Basename;
    3132use File::Find;
    3233use Carp qw<longmess>;
     
    204205    my $dictionaries = $useDocument->dictionaries;
    205206    if (@$dictionaries) {
    206         die "Multiple standalone dictionaries per document are not supported" if @$dictionaries > 1;
    207 
    208         my $dictionary = @$dictionaries[0];
     207        my $dictionary;
     208        my $otherDictionaries;
     209        if (@$dictionaries == 1) {
     210            $dictionary = @$dictionaries[0];
     211        } else {
     212            my $primaryDictionaryName = fileparse($targetIdlFilePath, ".idl");
     213            for my $candidate (@$dictionaries) {
     214                if ($candidate->type->name eq $primaryDictionaryName) {
     215                    $dictionary = $candidate;
     216                } else {
     217                    push @$otherDictionaries, $candidate;
     218                }
     219            }
     220            die "Multiple dictionaries per document are only supported if one matches the filename" unless $dictionary;
     221        }
     222
    209223        print "Generating $useGenerator bindings code for IDL dictionary \"" . $dictionary->type->name . "\"...\n" if $verbose;
    210         $codeGenerator->GenerateDictionary($dictionary, $useDocument->enumerations);
     224        $codeGenerator->GenerateDictionary($dictionary, $useDocument->enumerations, $otherDictionaries);
    211225        $codeGenerator->WriteData($dictionary, $useOutputDir, $useOutputHeadersDir);
    212226        return;
  • trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm

    r209752 r209864  
    5151my @depsContent = ();
    5252my $numCachedAttributes = 0;
    53 my $currentCachedAttribute = 0;
    5453
    5554my $beginAppleCopyrightForHeaderFiles = <<END;
     
    144143sub GenerateDictionary
    145144{
    146     my ($object, $dictionary, $enumerations) = @_;
     145    my ($object, $dictionary, $enumerations, $otherDictionaries) = @_;
    147146
    148147    my $className = GetDictionaryClassName($dictionary->type);
    149     $object->GenerateDictionaryHeader($dictionary, $className, $enumerations);
    150     $object->GenerateDictionaryImplementation($dictionary, $className, $enumerations);
     148    $object->GenerateDictionaryHeader($dictionary, $className, $enumerations, $otherDictionaries);
     149    $object->GenerateDictionaryImplementation($dictionary, $className, $enumerations, $otherDictionaries);
    151150}
    152151
     
    12251224    my $result = "";
    12261225    foreach my $dictionary (@$allDictionaries) {
    1227         $headerIncludes{$interface->type->name . ".h"} = 1;
     1226        $headerIncludes{$interface->type->name . ".h"} = 1 if $interface;
    12281227        my $className = GetDictionaryClassName($dictionary->type, $interface);
    12291228        my $conditionalString = $codeGenerator->GenerateConditionalString($dictionary);
     
    33993398                }
    34003399            } else {
    3401                 my $cacheIndex = 0;
    34023400                if ($attribute->extendedAttributes->{CachedAttribute}) {
    3403                     $cacheIndex = $currentCachedAttribute;
    3404                     $currentCachedAttribute++;
    34053401                    push(@implContent, "    if (JSValue cachedValue = thisObject.m_" . $attribute->name . ".get())\n");
    34063402                    push(@implContent, "        return cachedValue;\n");
     
    45384534sub GenerateDictionaryHeader
    45394535{
    4540     my ($object, $dictionary, $className, $enumerations) = @_;
     4536    my ($object, $dictionary, $className, $enumerations, $otherDictionaries) = @_;
    45414537
    45424538    # - Add default header template and header protection.
     
    45494545    push(@headerContent, GenerateDictionaryHeaderContent($dictionary, $className));
    45504546    push(@headerContent, GenerateEnumerationsHeaderContent($dictionary, $enumerations));
     4547    push(@headerContent, GenerateDictionariesHeaderContent(undef, $otherDictionaries)) if $otherDictionaries;
    45514548    push(@headerContent, "} // namespace WebCore\n");
    45524549
     
    45714568sub GenerateDictionaryImplementation
    45724569{
    4573     my ($object, $dictionary, $className, $enumerations) = @_;
     4570    my ($object, $dictionary, $className, $enumerations, $otherDictionaries) = @_;
    45744571
    45754572    # - Add default header template
     
    45784575    push(@implContent, "\nusing namespace JSC;\n\n");
    45794576    push(@implContent, "namespace WebCore {\n\n");
     4577    push(@implContent, GenerateDictionaryImplementationContent($dictionary, $className));
    45804578    push(@implContent, GenerateEnumerationsImplementationContent($dictionary, $enumerations));
    4581     push(@implContent, GenerateDictionaryImplementationContent($dictionary, $className));
     4579    push(@implContent, GenerateDictionariesImplementationContent(undef, $otherDictionaries)) if $otherDictionaries;
    45824580    push(@implContent, "} // namespace WebCore\n");
    45834581
     
    56045602
    56055603    my $name = $interface->type->name;
    5606     my $prefix = FileNamePrefix;
    5607     my $headerFileName = "$outputDir/$prefix$name.h";
    5608     my $implFileName = "$outputDir/$prefix$name.cpp";
    5609     my $depsFileName = "$outputDir/$prefix$name.dep";
     5604    my $headerFileName = "$outputDir/JS$name.h";
     5605    my $implFileName = "$outputDir/JS$name.cpp";
     5606    my $depsFileName = "$outputDir/JS$name.dep";
    56105607
    56115608    # Update a .cpp file if the contents are changed.
     
    56605657    foreach my $include (sort @includes) {
    56615658        # "JSClassName.h" is already included right after config.h.
    5662         next if $include eq "\"$prefix$name.h\"";
     5659        next if $include eq "\"JS$name.h\"";
    56635660        $contents .= "#include $include\n";
    56645661    }
  • trunk/Source/WebCore/bindings/scripts/generate-bindings.pl

    r208134 r209864  
    8383    print "$generator: $targetIdlFile\n";
    8484}
    85 my $targetInterfaceName = fileparse(basename($targetIdlFile), ".idl");
     85my $targetInterfaceName = fileparse($targetIdlFile, ".idl");
    8686
    8787my $idlFound = 0;
     
    101101    while (my $line = <FH>) {
    102102        my ($idlFile, @followingIdlFiles) = split(/\s+/, $line);
    103         if ($idlFile and basename($idlFile) eq basename($targetIdlFile)) {
     103        if ($idlFile and fileparse($idlFile) eq fileparse($targetIdlFile)) {
    104104            $idlFound = 1;
    105105            @supplementedIdlFiles = sort @followingIdlFiles;
     
    113113    if (!$idlFound and $additionalIdlFiles) {
    114114        my @idlFiles = shellwords($additionalIdlFiles);
    115         $idlFound = grep { $_ and basename($_) eq basename($targetIdlFile) } @idlFiles;
     115        $idlFound = grep { $_ and fileparse($_) eq fileparse($targetIdlFile) } @idlFiles;
    116116    }
    117117
     
    131131if ($idlAttributesFile) {
    132132    my $idlAttributes = loadIDLAttributes($idlAttributesFile);
    133     checkIDLAttributes($idlAttributes, $targetDocument, basename($targetIdlFile));
     133    checkIDLAttributes($idlAttributes, $targetDocument, fileparse($targetIdlFile));
    134134}
    135135
     
    137137    next if $idlFile eq $targetIdlFile;
    138138
    139     my $interfaceName = fileparse(basename($idlFile), ".idl");
     139    my $interfaceName = fileparse($idlFile, ".idl");
    140140    my $parser = IDLParser->new(!$verbose);
    141141    my $document = $parser->Parse($idlFile, $defines, $preprocessor);
     
    272272            }
    273273        } else {
    274             die "The format of " . basename($idlAttributesFile) . " is wrong: line $.\n";
     274            die "The format of " . fileparse($idlAttributesFile) . " is wrong: line $.\n";
    275275        }
    276276    }
  • trunk/Source/WebCore/platform/mediastream/MediaConstraints.h

    r208985 r209864  
    3030 */
    3131
    32 #ifndef MediaConstraints_h
    33 #define MediaConstraints_h
     32#pragma once
    3433
    3534#if ENABLE(MEDIA_STREAM)
     
    3736#include "RealtimeMediaSourceSupportedConstraints.h"
    3837#include <cstdlib>
    39 #include <wtf/HashMap.h>
    40 #include <wtf/RefCounted.h>
    41 #include <wtf/Variant.h>
    42 #include <wtf/text/StringHash.h>
    43 #include <wtf/text/WTFString.h>
    4438
    4539namespace WebCore {
     
    496490    void appendExact(const String& value)
    497491    {
    498         m_exact.clear();
    499492        m_exact.append(value);
    500493    }
     
    814807
    815808#endif // ENABLE(MEDIA_STREAM)
    816 
    817 #endif // MediaConstraints_h
  • trunk/Source/WebCore/platform/mediastream/MediaStreamTrackPrivate.cpp

    r208851 r209864  
    131131    clonedMediaStreamTrackPrivate->m_isEnabled = this->m_isEnabled;
    132132    clonedMediaStreamTrackPrivate->m_isEnded = this->m_isEnded;
    133     clonedMediaStreamTrackPrivate->m_constraints = this->m_constraints;
    134133
    135134    return clonedMediaStreamTrackPrivate;
     
    139138{
    140139    return m_source->type();
    141 }
    142 
    143 RefPtr<MediaConstraints> MediaStreamTrackPrivate::constraints() const
    144 {
    145     return m_constraints;
    146140}
    147141
  • trunk/Source/WebCore/platform/mediastream/MediaStreamTrackPrivate.h

    r208851 r209864  
    2525 */
    2626
    27 #ifndef MediaStreamTrackPrivate_h
    28 #define MediaStreamTrackPrivate_h
     27#pragma once
    2928
    3029#if ENABLE(MEDIA_STREAM)
    3130
    3231#include "RealtimeMediaSource.h"
    33 #include <wtf/RefCounted.h>
    34 #include <wtf/text/AtomicString.h>
    3532
    3633namespace WebCore {
     
    9188    RefPtr<RealtimeMediaSourceCapabilities> capabilities() const;
    9289
    93     RefPtr<MediaConstraints> constraints() const;
    9490    void applyConstraints(const MediaConstraints&, RealtimeMediaSource::SuccessHandler, RealtimeMediaSource::FailureHandler);
    9591
     
    111107    Vector<Observer*> m_observers;
    112108    Ref<RealtimeMediaSource> m_source;
    113     RefPtr<MediaConstraints> m_constraints;
    114109    RefPtr<RealtimeMediaSourcePreview> m_preview;
    115110
     
    124119
    125120#endif // ENABLE(MEDIA_STREAM)
    126 
    127 #endif // MediaStreamTrackPrivate_h
  • trunk/Source/WebKit2/ChangeLog

    r209862 r209864  
     12016-12-15  Darin Adler  <darin@apple.com>
     2
     3        Remove custom binding for MediaDevices
     4        https://bugs.webkit.org/show_bug.cgi?id=165894
     5
     6        Reviewed by Eric Carlson.
     7
     8        * WebProcess/MediaStream/UserMediaPermissionRequestManager.cpp:
     9        Added include of MediaConstraintsImpl.h, now needed because we
     10        removed some unneeded includes from the WebCore headers.
     11
    1122016-12-15  Dave Hyatt  <hyatt@apple.com>
    213
  • trunk/Source/WebKit2/WebProcess/MediaStream/UserMediaPermissionRequestManager.cpp

    r209512 r209864  
    3030#include <WebCore/Frame.h>
    3131#include <WebCore/FrameLoader.h>
     32#include <WebCore/MediaConstraintsImpl.h>
    3233#include <WebCore/SecurityOrigin.h>
    3334#include <WebCore/SecurityOriginData.h>
Note: See TracChangeset for help on using the changeset viewer.