| Differences between
and this patch
- a/Source/WebCore/ChangeLog +73 lines
Lines 1-3 a/Source/WebCore/ChangeLog_sec1
1
2012-07-27  Tommy Widenflycht  <tommyw@google.com>
2
3
        Introduce a minimal RTCPeerConnection together with Dictionary changes
4
        https://bugs.webkit.org/show_bug.cgi?id=92380
5
6
        Reviewed by NOBODY (OOPS!).
7
8
        This patch introduces a shell RTCPeerConnection together with neccecary changes to
9
        Dictionary.
10
11
        The W3C specification can be found here:
12
        http://dev.w3.org/2011/webrtc/editor/webrtc.html#rtcpeerconnection
13
14
        Since Dictionaries can't be fully copied around adding
15
        get(const String& name, Vector<Dictionary>& result)
16
        isn't feasible so I have added a new ArrayValue class.
17
18
        Test: fast/mediastream/RTCPeerConnection.html
19
20
        * Modules/mediastream/DOMWindowMediaStream.idl:
21
        * Modules/mediastream/RTCPeerConnection.cpp: Added.
22
        (WebCore):
23
        (RTCIceServer):
24
        (WebCore::RTCIceServer::create):
25
        (WebCore::RTCIceServer::~RTCIceServer):
26
        (WebCore::RTCIceServer::uri):
27
        (WebCore::RTCIceServer::password):
28
        (WebCore::RTCIceServer::RTCIceServer):
29
        (RTCConfiguration):
30
        (WebCore::RTCConfiguration::create):
31
        (WebCore::RTCConfiguration::~RTCConfiguration):
32
        (WebCore::RTCConfiguration::appendServer):
33
        (WebCore::RTCConfiguration::numberOfServers):
34
        (WebCore::RTCConfiguration::server):
35
        (WebCore::RTCConfiguration::RTCConfiguration):
36
        (WebCore::RTCPeerConnection::parseConfiguration):
37
        (WebCore::RTCPeerConnection::create):
38
        (WebCore::RTCPeerConnection::RTCPeerConnection):
39
        (WebCore::RTCPeerConnection::~RTCPeerConnection):
40
        (WebCore::RTCPeerConnection::interfaceName):
41
        (WebCore::RTCPeerConnection::scriptExecutionContext):
42
        (WebCore::RTCPeerConnection::stop):
43
        (WebCore::RTCPeerConnection::eventTargetData):
44
        (WebCore::RTCPeerConnection::ensureEventTargetData):
45
        * Modules/mediastream/RTCPeerConnection.h: Added.
46
        (WebCore):
47
        (RTCPeerConnection):
48
        (WebCore::RTCPeerConnection::refEventTarget):
49
        (WebCore::RTCPeerConnection::derefEventTarget):
50
        * Modules/mediastream/RTCPeerConnection.idl: Added.
51
        * WebCore.gypi:
52
        * bindings/generic/RuntimeEnabledFeatures.h:
53
        (WebCore::RuntimeEnabledFeatures::webkitRTCPeerConnectionEnabled):
54
        * bindings/v8/ArrayValue.cpp: Added.
55
        (WebCore):
56
        (WebCore::ArrayValue::ArrayValue):
57
        (WebCore::ArrayValue::~ArrayValue):
58
        (WebCore::ArrayValue::operator=):
59
        (WebCore::ArrayValue::isArrayValue):
60
        (WebCore::ArrayValue::isUndefinedOrNull):
61
        (WebCore::ArrayValue::length):
62
        (WebCore::ArrayValue::get):
63
        * bindings/v8/ArrayValue.h: Added.
64
        (WebCore):
65
        (ArrayValue):
66
        * bindings/v8/Dictionary.cpp:
67
        (WebCore::Dictionary::get):
68
        (WebCore):
69
        * bindings/v8/Dictionary.h:
70
        (WebCore):
71
        (Dictionary):
72
        * dom/EventTargetFactory.in:
73
1
2012-07-26  Eric Seidel  <eric@webkit.org>
74
2012-07-26  Eric Seidel  <eric@webkit.org>
2
75
3
        2% of all samples running grid demo show up in StyleResolver::canShareStyleWithElement, 20% of those due to getAttribute instead of fastGetAttribute
76
        2% of all samples running grid demo show up in StyleResolver::canShareStyleWithElement, 20% of those due to getAttribute instead of fastGetAttribute
- a/Source/WebCore/Modules/mediastream/DOMWindowMediaStream.idl +1 lines
Lines 32-37 module window { a/Source/WebCore/Modules/mediastream/DOMWindowMediaStream.idl_sec1
32
    ] DOMWindowMediaStream {
32
    ] DOMWindowMediaStream {
33
        attribute [V8EnabledAtRuntime] MediaStreamConstructor webkitMediaStream;
33
        attribute [V8EnabledAtRuntime] MediaStreamConstructor webkitMediaStream;
34
        attribute [V8EnabledAtRuntime] PeerConnection00Constructor webkitPeerConnection00;
34
        attribute [V8EnabledAtRuntime] PeerConnection00Constructor webkitPeerConnection00;
35
        attribute [V8EnabledAtRuntime] RTCPeerConnectionConstructor webkitRTCPeerConnection;
35
        attribute SessionDescriptionConstructor SessionDescription;
36
        attribute SessionDescriptionConstructor SessionDescription;
36
        attribute IceCandidateConstructor IceCandidate;
37
        attribute IceCandidateConstructor IceCandidate;
37
        attribute MediaStreamEventConstructor MediaStreamEvent;
38
        attribute MediaStreamEventConstructor MediaStreamEvent;
- a/Source/WebCore/Modules/mediastream/RTCPeerConnection.cpp +178 lines
Line 0 a/Source/WebCore/Modules/mediastream/RTCPeerConnection.cpp_sec1
1
/*
2
 * Copyright (C) 2012 Google Inc. All rights reserved.
3
 *
4
 * Redistribution and use in source and binary forms, with or without
5
 * modification, are permitted provided that the following conditions
6
 * are met:
7
 *
8
 * 1. Redistributions of source code must retain the above copyright
9
 *    notice, this list of conditions and the following disclaimer.
10
 * 2. Redistributions in binary form must reproduce the above copyright
11
 *    notice, this list of conditions and the following disclaimer
12
 *    in the documentation and/or other materials provided with the
13
 *    distribution.
14
 * 3. Neither the name of Google Inc. nor the names of its contributors
15
 *    may be used to endorse or promote products derived from this
16
 *    software without specific prior written permission.
17
 *
18
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19
 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20
 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21
 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22
 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24
 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29
 */
30
31
#include "config.h"
32
33
#if ENABLE(MEDIA_STREAM)
34
35
#include "RTCPeerConnection.h"
36
37
#include "ArrayValue.h"
38
#include "ExceptionCode.h"
39
#include "KURL.h"
40
#include "ScriptExecutionContext.h"
41
42
namespace WebCore {
43
44
// FIXME: RTCIceServer and RTCConfigration are placed here temporarily.
45
// Their final place is in Source/WebCore/platform/mediastream.
46
class RTCIceServer : public RefCounted<RTCIceServer> {
47
public:
48
    static PassRefPtr<RTCIceServer> create(const KURL& uri, const String& credential) { return adoptRef(new RTCIceServer(uri, credential)); }
49
    virtual ~RTCIceServer() { }
50
51
    const KURL& uri() { return m_uri; }
52
    const String& credential() { return m_credential; }
53
54
private:
55
    RTCIceServer(const KURL& uri, const String& credential)
56
        : m_uri(uri)
57
        , m_credential(credential)
58
    {
59
    }
60
61
    KURL m_uri;
62
    String m_credential;
63
};
64
65
class RTCConfiguration : public RefCounted<RTCConfiguration> {
66
public:
67
    static PassRefPtr<RTCConfiguration> create() { return adoptRef(new RTCConfiguration()); }
68
    virtual ~RTCConfiguration() { }
69
70
    void appendServer(PassRefPtr<RTCIceServer> server) { m_servers.append(server); }
71
    size_t numberOfServers() { return m_servers.size(); }
72
    RTCIceServer* server(size_t index) { return m_servers[index].get(); }
73
74
private:
75
    RTCConfiguration() { }
76
77
    Vector<RefPtr<RTCIceServer> > m_servers;
78
};
79
80
PassRefPtr<RTCConfiguration> RTCPeerConnection::parseConfiguration(const Dictionary& configuration, ExceptionCode& ec)
81
{
82
    if (configuration.isUndefinedOrNull())
83
        return 0;
84
85
    ArrayValue iceServers;
86
    bool ok = configuration.get("iceServers", iceServers);
87
    if (!ok) {
88
        ec = TYPE_MISMATCH_ERR;
89
        return 0;
90
    }
91
92
    size_t numberOfServers;
93
    ok = iceServers.length(numberOfServers);
94
    if (!ok) {
95
        ec = TYPE_MISMATCH_ERR;
96
        return 0;
97
    }
98
99
    RefPtr<RTCConfiguration> rtcConfiguration = RTCConfiguration::create();
100
101
    for (size_t i = 0; i < numberOfServers; ++i) {
102
        Dictionary iceServer;
103
        ok = iceServers.get(i, iceServer);
104
        if (!ok) {
105
            ec = TYPE_MISMATCH_ERR;
106
            return 0;
107
        }
108
109
        String uri, credential;
110
        ok = iceServer.get("uri", uri);
111
        if (!ok) {
112
            ec = TYPE_MISMATCH_ERR;
113
            return 0;
114
        }
115
        KURL url(KURL(), uri);
116
        if (!url.isValid() || !(url.protocolIs("turn") || url.protocolIs("stun"))) {
117
            ec = TYPE_MISMATCH_ERR;
118
            return 0;
119
        }
120
121
        iceServer.get("credential", credential);
122
123
        rtcConfiguration->appendServer(RTCIceServer::create(url, credential));
124
    }
125
    return rtcConfiguration.release();
126
}
127
128
PassRefPtr<RTCPeerConnection> RTCPeerConnection::create(ScriptExecutionContext* context, const Dictionary& rtcConfiguration, const Dictionary&, ExceptionCode& ec)
129
{
130
    RefPtr<RTCConfiguration> configuration = parseConfiguration(rtcConfiguration, ec);
131
    if (ec)
132
        return 0;
133
134
    RefPtr<RTCPeerConnection> peerConnection = adoptRef(new RTCPeerConnection(context, configuration.release(), ec));
135
    if (ec)
136
        return 0;
137
138
    peerConnection->suspendIfNeeded();
139
    return peerConnection.release();
140
}
141
142
RTCPeerConnection::RTCPeerConnection(ScriptExecutionContext* context, PassRefPtr<RTCConfiguration>, ExceptionCode& ec)
143
    : ActiveDOMObject(context, this)
144
{
145
}
146
147
RTCPeerConnection::~RTCPeerConnection()
148
{
149
}
150
151
const AtomicString& RTCPeerConnection::interfaceName() const
152
{
153
    return eventNames().interfaceForRTCPeerConnection;
154
}
155
156
ScriptExecutionContext* RTCPeerConnection::scriptExecutionContext() const
157
{
158
    return ActiveDOMObject::scriptExecutionContext();
159
}
160
161
void RTCPeerConnection::stop()
162
{
163
    // FIXME: Make sure that this object stops posting events and releases resources at this stage.
164
}
165
166
EventTargetData* RTCPeerConnection::eventTargetData()
167
{
168
    return &m_eventTargetData;
169
}
170
171
EventTargetData* RTCPeerConnection::ensureEventTargetData()
172
{
173
    return &m_eventTargetData;
174
}
175
176
} // namespace WebCore
177
178
#endif // ENABLE(MEDIA_STREAM)
- a/Source/WebCore/Modules/mediastream/RTCPeerConnection.h +77 lines
Line 0 a/Source/WebCore/Modules/mediastream/RTCPeerConnection.h_sec1
1
/*
2
 * Copyright (C) 2012 Google Inc. All rights reserved.
3
 *
4
 * Redistribution and use in source and binary forms, with or without
5
 * modification, are permitted provided that the following conditions
6
 * are met:
7
 *
8
 * 1. Redistributions of source code must retain the above copyright
9
 *    notice, this list of conditions and the following disclaimer.
10
 * 2. Redistributions in binary form must reproduce the above copyright
11
 *    notice, this list of conditions and the following disclaimer
12
 *    in the documentation and/or other materials provided with the
13
 *    distribution.
14
 * 3. Neither the name of Google Inc. nor the names of its contributors
15
 *    may be used to endorse or promote products derived from this
16
 *    software without specific prior written permission.
17
 *
18
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19
 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20
 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21
 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22
 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24
 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29
 */
30
31
#ifndef RTCPeerConnection_h
32
#define RTCPeerConnection_h
33
34
#if ENABLE(MEDIA_STREAM)
35
36
#include "ActiveDOMObject.h"
37
#include "Dictionary.h"
38
#include "EventTarget.h"
39
#include "ExceptionBase.h"
40
#include <wtf/RefCounted.h>
41
42
namespace WebCore {
43
class RTCConfiguration;
44
45
class RTCPeerConnection : public RefCounted<RTCPeerConnection>, public EventTarget, public ActiveDOMObject {
46
public:
47
    static PassRefPtr<RTCPeerConnection> create(ScriptExecutionContext*, const Dictionary& rtcConfiguration, const Dictionary& mediaConstraints, ExceptionCode&);
48
    ~RTCPeerConnection();
49
50
    // EventTarget
51
    virtual const AtomicString& interfaceName() const OVERRIDE;
52
    virtual ScriptExecutionContext* scriptExecutionContext() const OVERRIDE;
53
54
    // ActiveDOMObject
55
    virtual void stop() OVERRIDE;
56
57
    using RefCounted<RTCPeerConnection>::ref;
58
    using RefCounted<RTCPeerConnection>::deref;
59
60
private:
61
    RTCPeerConnection(ScriptExecutionContext*, PassRefPtr<RTCConfiguration>, ExceptionCode&);
62
63
    static PassRefPtr<RTCConfiguration> parseConfiguration(const Dictionary& configuration, ExceptionCode&);
64
65
    // EventTarget implementation.
66
    virtual EventTargetData* eventTargetData();
67
    virtual EventTargetData* ensureEventTargetData();
68
    virtual void refEventTarget() { ref(); }
69
    virtual void derefEventTarget() { deref(); }
70
    EventTargetData m_eventTargetData;
71
};
72
73
} // namespace WebCore
74
75
#endif // ENABLE(MEDIA_STREAM)
76
77
#endif // RTCPeerConnection_h
- a/Source/WebCore/Modules/mediastream/RTCPeerConnection.idl +52 lines
Line 0 a/Source/WebCore/Modules/mediastream/RTCPeerConnection.idl_sec1
1
/*
2
 * Copyright (C) 2012 Google Inc. All rights reserved.
3
 *
4
 * Redistribution and use in source and binary forms, with or without
5
 * modification, are permitted provided that the following conditions
6
 * are met:
7
 *
8
 * 1. Redistributions of source code must retain the above copyright
9
 *    notice, this list of conditions and the following disclaimer.
10
 * 2. Redistributions in binary form must reproduce the above copyright
11
 *    notice, this list of conditions and the following disclaimer
12
 *    in the documentation and/or other materials provided with the
13
 *    distribution.
14
 * 3. Neither the name of Google Inc. nor the names of its contributors
15
 *    may be used to endorse or promote products derived from this
16
 *    software without specific prior written permission.
17
 *
18
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19
 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20
 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21
 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22
 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24
 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29
 */
30
31
module mediastream {
32
33
    interface [
34
        Conditional=MEDIA_STREAM,
35
        ActiveDOMObject,
36
        Constructor(in Dictionary rtcICEServers, in [Optional=DefaultIsUndefined] Dictionary mediaConstraints),
37
        ConstructorRaisesException,
38
        CallWith=ScriptExecutionContext,
39
        EventTarget
40
    ] RTCPeerConnection {
41
        // EventTarget interface
42
        void addEventListener(in DOMString type,
43
                              in EventListener listener,
44
                              in [Optional] boolean useCapture);
45
        void removeEventListener(in DOMString type,
46
                                 in EventListener listener,
47
                                 in [Optional] boolean useCapture);
48
        boolean dispatchEvent(in Event event)
49
            raises(EventException);
50
    };
51
52
}
- a/Source/WebCore/WebCore.gypi +5 lines
Lines 840-845 a/Source/WebCore/WebCore.gypi_sec1
840
            'Modules/mediastream/NavigatorUserMediaErrorCallback.idl',
840
            'Modules/mediastream/NavigatorUserMediaErrorCallback.idl',
841
            'Modules/mediastream/NavigatorUserMediaSuccessCallback.idl',
841
            'Modules/mediastream/NavigatorUserMediaSuccessCallback.idl',
842
            'Modules/mediastream/PeerConnection00.idl',
842
            'Modules/mediastream/PeerConnection00.idl',
843
            'Modules/mediastream/RTCPeerConnection.idl',
843
            'Modules/mediastream/SessionDescription.idl',
844
            'Modules/mediastream/SessionDescription.idl',
844
            'Modules/notifications/DOMWindowNotifications.idl',
845
            'Modules/notifications/DOMWindowNotifications.idl',
845
            'Modules/notifications/Notification.idl',
846
            'Modules/notifications/Notification.idl',
Lines 1566-1571 a/Source/WebCore/WebCore.gypi_sec2
1566
            'Modules/mediastream/NavigatorUserMediaSuccessCallback.h',
1567
            'Modules/mediastream/NavigatorUserMediaSuccessCallback.h',
1567
            'Modules/mediastream/PeerConnection00.cpp',
1568
            'Modules/mediastream/PeerConnection00.cpp',
1568
            'Modules/mediastream/PeerConnection00.h',
1569
            'Modules/mediastream/PeerConnection00.h',
1570
            'Modules/mediastream/RTCPeerConnection.cpp',
1571
            'Modules/mediastream/RTCPeerConnection.h',
1569
            'Modules/mediastream/SessionDescription.cpp',
1572
            'Modules/mediastream/SessionDescription.cpp',
1570
            'Modules/mediastream/SessionDescription.h',
1573
            'Modules/mediastream/SessionDescription.h',
1571
            'Modules/mediastream/UserMediaClient.h',
1574
            'Modules/mediastream/UserMediaClient.h',
Lines 2150-2155 a/Source/WebCore/WebCore.gypi_sec3
2150
            'bindings/objc/ObjCNodeFilterCondition.mm',
2153
            'bindings/objc/ObjCNodeFilterCondition.mm',
2151
            'bindings/objc/PublicDOMInterfaces.h',
2154
            'bindings/objc/PublicDOMInterfaces.h',
2152
            'bindings/objc/WebScriptObject.mm',
2155
            'bindings/objc/WebScriptObject.mm',
2156
            'bindings/v8/ArrayValue.cpp',
2157
            'bindings/v8/ArrayValue.h',
2153
            'bindings/v8/DOMData.cpp',
2158
            'bindings/v8/DOMData.cpp',
2154
            'bindings/v8/DOMData.h',
2159
            'bindings/v8/DOMData.h',
2155
            'bindings/v8/DOMDataStore.cpp',
2160
            'bindings/v8/DOMDataStore.cpp',
- a/Source/WebCore/bindings/generic/RuntimeEnabledFeatures.h +1 lines
Lines 188-193 public: a/Source/WebCore/bindings/generic/RuntimeEnabledFeatures.h_sec1
188
    static bool peerConnectionEnabled() { return isMediaStreamEnabled && isPeerConnectionEnabled; }
188
    static bool peerConnectionEnabled() { return isMediaStreamEnabled && isPeerConnectionEnabled; }
189
    static void setPeerConnectionEnabled(bool isEnabled) { isPeerConnectionEnabled = isEnabled; }
189
    static void setPeerConnectionEnabled(bool isEnabled) { isPeerConnectionEnabled = isEnabled; }
190
    static bool webkitPeerConnection00Enabled() { return peerConnectionEnabled(); }
190
    static bool webkitPeerConnection00Enabled() { return peerConnectionEnabled(); }
191
    static bool webkitRTCPeerConnectionEnabled() { return peerConnectionEnabled(); }
191
#endif
192
#endif
192
193
193
#if ENABLE(GAMEPAD)
194
#if ENABLE(GAMEPAD)
- a/Source/WebCore/bindings/v8/ArrayValue.cpp +72 lines
Line 0 a/Source/WebCore/bindings/v8/ArrayValue.cpp_sec1
1
/*
2
 * Copyright (C) 2012 Google Inc. All rights reserved.
3
 *
4
 * Redistribution and use in source and binary forms, with or without
5
 * modification, are permitted provided that the following conditions
6
 * are met:
7
 *
8
 * 1.  Redistributions of source code must retain the above copyright
9
 *     notice, this list of conditions and the following disclaimer.
10
 * 2.  Redistributions in binary form must reproduce the above copyright
11
 *     notice, this list of conditions and the following disclaimer in the
12
 *     documentation and/or other materials provided with the distribution.
13
 *
14
 * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
15
 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
16
 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
17
 * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
18
 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
19
 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
20
 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
21
 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
23
 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24
 */
25
26
#include "config.h"
27
#include "ArrayValue.h"
28
29
#include "Dictionary.h"
30
#include "V8Binding.h"
31
32
namespace WebCore {
33
34
ArrayValue& ArrayValue::operator=(const ArrayValue& other)
35
{
36
    m_array = other.m_array;
37
    return *this;
38
}
39
40
bool ArrayValue::isUndefinedOrNull() const
41
{
42
    if (m_array.IsEmpty())
43
        return true;
44
    return WebCore::isUndefinedOrNull(m_array);
45
}
46
47
bool ArrayValue::length(size_t& length) const
48
{
49
    if (isUndefinedOrNull())
50
        return false;
51
52
    length = m_array->Length();
53
    return true;
54
}
55
56
bool ArrayValue::get(size_t index, Dictionary& value) const
57
{
58
    if (isUndefinedOrNull())
59
        return false;
60
61
    if (index >= m_array->Length())
62
        return false;
63
64
    v8::Local<v8::Value> indexedValue = m_array->Get(v8UnsignedInteger(index));
65
    if (indexedValue.IsEmpty() || !indexedValue->IsObject())
66
        return false;
67
68
    value = Dictionary(indexedValue);
69
    return true;
70
}
71
72
} // namespace WebCore
- a/Source/WebCore/bindings/v8/ArrayValue.h +59 lines
Line 0 a/Source/WebCore/bindings/v8/ArrayValue.h_sec1
1
/*
2
 * Copyright (C) 2012 Google Inc. All rights reserved.
3
 *
4
 * Redistribution and use in source and binary forms, with or without
5
 * modification, are permitted provided that the following conditions
6
 * are met:
7
 *
8
 * 1.  Redistributions of source code must retain the above copyright
9
 *     notice, this list of conditions and the following disclaimer.
10
 * 2.  Redistributions in binary form must reproduce the above copyright
11
 *     notice, this list of conditions and the following disclaimer in the
12
 *     documentation and/or other materials provided with the distribution.
13
 *
14
 * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
15
 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
16
 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
17
 * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
18
 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
19
 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
20
 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
21
 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
23
 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24
 */
25
26
#ifndef ArrayValue_h
27
#define ArrayValue_h
28
29
#include <v8.h>
30
31
namespace WebCore {
32
33
class Dictionary;
34
35
class ArrayValue {
36
public:
37
    ArrayValue() { }
38
    ArrayValue(const v8::Local<v8::Array>& array) : m_array(array) { }
39
    ~ArrayValue() { }
40
41
    ArrayValue& operator=(const ArrayValue&);
42
43
    bool isUndefinedOrNull() const;
44
45
    bool length(size_t&) const;
46
    bool get(size_t index, Dictionary&) const;
47
48
private:
49
    // This object can only be used safely when stack allocated because of v8::Local.
50
    static void* operator new(size_t);
51
    static void* operator new[](size_t);
52
    static void operator delete(void *);
53
54
    v8::Local<v8::Array> m_array;
55
};
56
57
}
58
59
#endif // ArrayValue_h
- a/Source/WebCore/bindings/v8/Dictionary.cpp +14 lines
Lines 26-31 a/Source/WebCore/bindings/v8/Dictionary.cpp_sec1
26
#include "config.h"
26
#include "config.h"
27
#include "Dictionary.h"
27
#include "Dictionary.h"
28
28
29
#include "ArrayValue.h"
29
#include "DOMStringList.h"
30
#include "DOMStringList.h"
30
#include "V8Binding.h"
31
#include "V8Binding.h"
31
#include "V8DOMWindow.h"
32
#include "V8DOMWindow.h"
Lines 442-447 bool Dictionary::get(const String& key, Vector<String>& value) const a/Source/WebCore/bindings/v8/Dictionary.cpp_sec2
442
    return true;
443
    return true;
443
}
444
}
444
445
446
bool Dictionary::get(const String& key, ArrayValue& value) const
447
{
448
    v8::Local<v8::Value> v8Value;
449
    if (!getKey(key, v8Value))
450
        return false;
451
452
    if (!v8Value->IsArray())
453
        return false;
454
455
    value = ArrayValue(v8::Local<v8::Array>::Cast(v8Value));
456
    return true;
457
}
458
445
bool Dictionary::getOwnPropertiesAsStringHashMap(WTF::HashMap<String, String>& hashMap) const
459
bool Dictionary::getOwnPropertiesAsStringHashMap(WTF::HashMap<String, String>& hashMap) const
446
{
460
{
447
    if (!isObject())
461
    if (!isObject())
- a/Source/WebCore/bindings/v8/Dictionary.h +3 lines
Lines 38-43 a/Source/WebCore/bindings/v8/Dictionary.h_sec1
38
38
39
namespace WebCore {
39
namespace WebCore {
40
40
41
class ArrayValue;
41
class DOMWindow;
42
class DOMWindow;
42
class IDBKeyRange;
43
class IDBKeyRange;
43
class MediaKeyError;
44
class MediaKeyError;
Lines 86-91 public: a/Source/WebCore/bindings/v8/Dictionary.h_sec2
86
    bool get(const String&, HashSet<AtomicString>&) const;
87
    bool get(const String&, HashSet<AtomicString>&) const;
87
    bool get(const String&, Dictionary&) const;
88
    bool get(const String&, Dictionary&) const;
88
    bool get(const String&, Vector<String>&) const;
89
    bool get(const String&, Vector<String>&) const;
90
    bool get(const String&, ArrayValue&) const;
91
89
    bool getOwnPropertiesAsStringHashMap(WTF::HashMap<String, String>&) const;
92
    bool getOwnPropertiesAsStringHashMap(WTF::HashMap<String, String>&) const;
90
93
91
    bool getWithUndefinedOrNullCheck(const String&, String&) const;
94
    bool getWithUndefinedOrNullCheck(const String&, String&) const;
- a/Source/WebCore/dom/EventTargetFactory.in +1 lines
Lines 24-29 Node a/Source/WebCore/dom/EventTargetFactory.in_sec1
24
Notification conditional=NOTIFICATIONS|LEGACY_NOTIFICATIONS
24
Notification conditional=NOTIFICATIONS|LEGACY_NOTIFICATIONS
25
PeerConnection00 conditional=MEDIA_STREAM
25
PeerConnection00 conditional=MEDIA_STREAM
26
Performance conditional=WEB_TIMING
26
Performance conditional=WEB_TIMING
27
RTCPeerConnection conditional=MEDIA_STREAM
27
SharedWorker conditional=SHARED_WORKERS
28
SharedWorker conditional=SHARED_WORKERS
28
SharedWorkerContext conditional=SHARED_WORKERS
29
SharedWorkerContext conditional=SHARED_WORKERS
29
SourceBufferList conditional=MEDIA_SOURCE
30
SourceBufferList conditional=MEDIA_SOURCE
- a/LayoutTests/ChangeLog +10 lines
Lines 1-3 a/LayoutTests/ChangeLog_sec1
1
2012-07-27  Tommy Widenflycht  <tommyw@google.com>
2
3
        Introduce a minimal RTCPeerConnection together with Dictionary changes
4
        https://bugs.webkit.org/show_bug.cgi?id=92380
5
6
        Reviewed by NOBODY (OOPS!).
7
8
        * fast/mediastream/RTCPeerConnection-expected.txt: Added.
9
        * fast/mediastream/RTCPeerConnection.html: Added.
10
1
2012-07-26  Mikhail Pozdnyakov  <mikhail.pozdnyakov@intel.com>
11
2012-07-26  Mikhail Pozdnyakov  <mikhail.pozdnyakov@intel.com>
2
12
3
        [EFL] Gardening after r123634
13
        [EFL] Gardening after r123634
- a/LayoutTests/fast/mediastream/RTCPeerConnection-expected.txt +25 lines
Line 0 a/LayoutTests/fast/mediastream/RTCPeerConnection-expected.txt_sec1
1
Tests the RTCPeerConnection constructor.
2
3
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
4
5
6
PASS new webkitRTCPeerConnection(null); did not throw exception.
7
PASS new webkitRTCPeerConnection(null, null); did not throw exception.
8
PASS new webkitRTCPeerConnection(undefined); did not throw exception.
9
PASS new webkitRTCPeerConnection(undefined, undefined); did not throw exception.
10
PASS new webkitRTCPeerConnection({iceServers:[]}, null); did not throw exception.
11
PASS new webkitRTCPeerConnection({iceServers:[{uri:'stun:foo.com'}]}, null); did not throw exception.
12
PASS new webkitRTCPeerConnection({iceServers:[{uri:'turn:foo.com', credential:'x'}]}, null); did not throw exception.
13
PASS new webkitRTCPeerConnection({iceServers:[{uri:'turn:foo.com', credential:'x'},{uri:'stun:bar.com'}]}, null); did not throw exception.
14
PASS new webkitRTCPeerConnection(); threw exception TypeError: Not enough arguments.
15
PASS new webkitRTCPeerConnection(''); threw exception TypeError: Not an object..
16
PASS new webkitRTCPeerConnection(null, ''); threw exception TypeError: Not an object..
17
PASS new webkitRTCPeerConnection({fooServers:[]}, null); threw exception Error: TYPE_MISMATCH_ERR: DOM Exception 17.
18
PASS new webkitRTCPeerConnection({iceServers:true}, null); threw exception Error: TYPE_MISMATCH_ERR: DOM Exception 17.
19
PASS new webkitRTCPeerConnection({iceServers:[1, 2, 3]}, null); threw exception Error: TYPE_MISMATCH_ERR: DOM Exception 17.
20
PASS new webkitRTCPeerConnection({iceServers:[{}]}, null); threw exception Error: TYPE_MISMATCH_ERR: DOM Exception 17.
21
PASS new webkitRTCPeerConnection({iceServers:[{url:'foo'}]}, null); threw exception Error: TYPE_MISMATCH_ERR: DOM Exception 17.
22
PASS successfullyParsed is true
23
24
TEST COMPLETE
25
- a/LayoutTests/fast/mediastream/RTCPeerConnection.html +30 lines
Line 0 a/LayoutTests/fast/mediastream/RTCPeerConnection.html_sec1
1
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
2
<html>
3
<head>
4
<script src="../js/resources/js-test-pre.js"></script>
5
</head>
6
<body>
7
<script>
8
description("Tests the RTCPeerConnection constructor.");
9
10
shouldNotThrow("new webkitRTCPeerConnection(null);");
11
shouldNotThrow("new webkitRTCPeerConnection(null, null);");
12
shouldNotThrow("new webkitRTCPeerConnection(undefined);");
13
shouldNotThrow("new webkitRTCPeerConnection(undefined, undefined);");
14
shouldNotThrow("new webkitRTCPeerConnection({iceServers:[]}, null);");
15
shouldNotThrow("new webkitRTCPeerConnection({iceServers:[{uri:'stun:foo.com'}]}, null);");
16
shouldNotThrow("new webkitRTCPeerConnection({iceServers:[{uri:'turn:foo.com', credential:'x'}]}, null);");
17
shouldNotThrow("new webkitRTCPeerConnection({iceServers:[{uri:'turn:foo.com', credential:'x'},{uri:'stun:bar.com'}]}, null);");
18
19
shouldThrow("new webkitRTCPeerConnection();");
20
shouldThrow("new webkitRTCPeerConnection('');");
21
shouldThrow("new webkitRTCPeerConnection(null, '');");
22
shouldThrow("new webkitRTCPeerConnection({fooServers:[]}, null);");
23
shouldThrow("new webkitRTCPeerConnection({iceServers:true}, null);");
24
shouldThrow("new webkitRTCPeerConnection({iceServers:[1, 2, 3]}, null);");
25
shouldThrow("new webkitRTCPeerConnection({iceServers:[{}]}, null);");
26
shouldThrow("new webkitRTCPeerConnection({iceServers:[{url:'foo'}]}, null);");
27
</script>
28
<script src="../js/resources/js-test-post.js"></script>
29
</body>
30
</html>

Return to Bug 92380