Source/WebCore/ChangeLog

112017-02-17 Youenn Fablet <youenn@apple.com>
22
 3 [WebRTC] Support modern RTCStatsReport
 4 https://bugs.webkit.org/show_bug.cgi?id=166916
 5 <rdar://problem/30293780>
 6
 7 Reviewed by NOBODY (OOPS!).
 8
 9 Updating binding generator and IDL parser to handle maplike.
 10 Covered by binding tests.
 11
 12 Added support for maplike binding from JS wrapper to DOM class.
 13 The principle is to have the JSXX wrapper having a @backingMap slot containing a Map.
 14 All maplike methods are forwarded to the corresponding Map methods.
 15 The XX object is responsible to add key/value pairs using a helper routine.
 16 The creation of the Map is done at creation of the JSXX wrapper.
 17
 18 DOM class is interacting with the map through DOMMapLike.
 19 Extracted DOMGuarded from DOM promise implementation.
 20 This allows reusing this code for DOMMapLike.
 21
 22 Covered by binding tests and manual tests.
 23
 24 * CMakeLists.txt:
 25 * DerivedSources.make:
 26 * Modules/mediastream/RTCStatsReport.h:
 27 (WebCore::RTCStatsReport::InboundRTPStreamStats::InboundRTPStreamStats):
 28 (WebCore::RTCStatsReport::OutboundRTPStreamStats::OutboundRTPStreamStats):
 29 (WebCore::RTCStatsReport::create):
 30 (WebCore::RTCStatsReport::synchronizeBackingMap):
 31 (WebCore::RTCStatsReport::backingMap):
 32 (WebCore::RTCStatsReport::addStats):
 33 * Modules/mediastream/RTCStatsReport.idl:
 34 * Modules/mediastream/libwebrtc/LibWebRTCMediaEndpoint.cpp:
 35 (WebCore::fromStdString):
 36 (WebCore::fillRTCStats):
 37 (WebCore::fillRTCRTPStreamStats):
 38 (WebCore::fillInboundRTPStreamStats):
 39 (WebCore::fillOutboundRTPStreamStats):
 40 (WebCore::LibWebRTCMediaEndpoint::StatsCollector::OnStatsDelivered):
 41 * Modules/mediastream/libwebrtc/LibWebRTCPeerConnectionBackend.h:
 42 * WebCore.xcodeproj/project.pbxproj:
 43 * bindings/js/JSDOMBindingInternals.js: Added.
 44 (mapLikeForEach):
 45 * bindings/js/JSDOMGlobalObject.cpp:
 46 (WebCore::JSDOMGlobalObject::visitChildren):
 47 * bindings/js/JSDOMGlobalObject.h:
 48 * bindings/js/JSDOMGuardedObject.cpp: Added.
 49 (WebCore::DOMGuardedObject::DOMGuardedObject):
 50 (WebCore::DOMGuardedObject::~DOMGuardedObject):
 51 (WebCore::DOMGuardedObject::clear):
 52 (WebCore::DOMGuardedObject::contextDestroyed):
 53 * bindings/js/JSDOMGuardedObject.h: Added.
 54 (WebCore::DOMGuardedObject::isSuspended):
 55 (WebCore::DOMGuardedObject::visitAggregate):
 56 (WebCore::DOMGuardedObject::guardedObject):
 57 (WebCore::DOMGuardedObject::globalObject):
 58 (WebCore::DOMGuardedObject::isEmpty):
 59 (WebCore::DOMGuarded::DOMGuarded):
 60 (WebCore::DOMGuarded::guarded):
 61 * bindings/js/JSDOMMapLike.cpp: Added.
 62 (WebCore::getBackingMap):
 63 (WebCore::initializeBackingMap):
 64 (WebCore::createBackingMap):
 65 (WebCore::forwardAttributeGetterToBackingMap):
 66 (WebCore::forwardFunctionCallToBackingMap):
 67 (WebCore::forwardForEachCallToBackingMap):
 68 * bindings/js/JSDOMMapLike.h: Added.
 69 (WebCore::DOMMapLike::set):
 70 (WebCore::synchronizeBackingMap):
 71 (WebCore::forwardSizeToMapLike):
 72 (WebCore::forwardEntriesToMapLike):
 73 (WebCore::forwardKeysToMapLike):
 74 (WebCore::forwardValuesToMapLike):
 75 (WebCore::forwardClearToMapLike):
 76 (WebCore::forwardForEachToMapLike):
 77 (WebCore::forwardHasToMapLike):
 78 (WebCore::forwardAddToMapLike):
 79 (WebCore::forwardDeleteToMapLike):
 80 * bindings/js/JSDOMPromise.cpp:
 81 (WebCore::DeferredPromise::promise):
 82 (WebCore::DeferredPromise::reject):
 83 * bindings/js/JSDOMPromise.h:
 84 (WebCore::DeferredPromise::resolve):
 85 (WebCore::DeferredPromise::resolveWithNewlyCreated):
 86 (WebCore::DeferredPromise::reject):
 87 (WebCore::DeferredPromise::resolveWithCallback):
 88 (WebCore::DeferredPromise::rejectWithCallback):
 89 (WebCore::DeferredPromise::DeferredPromise):
 90 (WebCore::DeferredPromise::deferred):
 91 * bindings/js/WebCoreBuiltinNames.h:
 92 * bindings/scripts/CodeGeneratorJS.pm:
 93 (PrototypeFunctionCount):
 94 (GeneratePropertiesHashTable):
 95 (InterfaceNeedsIterator):
 96 (GenerateImplementation):
 97 (GenerateParametersCheck):
 98 * bindings/scripts/IDLParser.pm:
 99 (assert):
 100 (parseAttributeOrOperationOrIterator):
 101 (parseSerializer):
 102 (parseAttributeOrOperationRest):
 103 (parseAttribute):
 104 (parseAttributeRest):
 105 (parseOperationOrIterator):
 106 (parseOptionalIterableInterface):
 107 (parseMapLikeRest):
 108 (parseMapLikeProperties):
 109 (parseOperationRest):
 110 (applyMemberList):
 111 * bindings/scripts/test/JS/JSMapLike.cpp: Added.
 112 * bindings/scripts/test/JS/JSMapLike.h: Added.
 113 * bindings/scripts/test/JS/JSReadOnlyMapLike.cpp: Added.
 114 * bindings/scripts/test/JS/JSReadOnlyMapLike.h: Added.
 115 * bindings/scripts/test/TestMapLike.idl: Added.
 116 * bindings/scripts/test/TestReadOnlyMapLike.idl: Added.
 117
 1182017-02-17 Youenn Fablet <youenn@apple.com>
 119
3120 [WebRTC][Mac] Activate libwebrtc
4121 https://bugs.webkit.org/show_bug.cgi?id=167293
5122

Source/ThirdParty/libwebrtc/Source/webrtc/api/stats/rtcstats_objects.h

1414#include <string>
1515
1616#include "webrtc/api/stats/rtcstats.h"
 17#include "webrtc/base/export.h"
1718
1819namespace webrtc {
1920

@@class RTCRTPStreamStats : public RTCStats {
301302// https://w3c.github.io/webrtc-stats/#inboundrtpstats-dict*
302303// TODO(hbos): Finish implementation and support the remote case
303304// |is_remote = true|. Tracking bug crbug.com/657855
304 class RTCInboundRTPStreamStats final : public RTCRTPStreamStats {
 305class WEBRTC_EXPORT RTCInboundRTPStreamStats final : public RTCRTPStreamStats {
305306 public:
306307 WEBRTC_RTCSTATS_DECL();
307308

@@class RTCInboundRTPStreamStats final : public RTCRTPStreamStats {
343344// https://w3c.github.io/webrtc-stats/#outboundrtpstats-dict*
344345// TODO(hbos): Finish implementation and support the remote case
345346// |is_remote = true|. Tracking bug crbug.com/657856
346 class RTCOutboundRTPStreamStats final : public RTCRTPStreamStats {
 347class WEBRTC_EXPORT RTCOutboundRTPStreamStats final : public RTCRTPStreamStats {
347348 public:
348349 WEBRTC_RTCSTATS_DECL();
349350

Source/ThirdParty/libwebrtc/Source/webrtc/api/stats/rtcstatsreport.h

1717#include <vector>
1818
1919#include "webrtc/api/stats/rtcstats.h"
 20#include "webrtc/base/export.h"
2021#include "webrtc/base/refcount.h"
2122#include "webrtc/base/scoped_ref_ptr.h"
2223

@@namespace webrtc {
2425
2526// A collection of stats.
2627// This is accessible as a map from |RTCStats::id| to |RTCStats|.
27 class RTCStatsReport : public rtc::RefCountInterface {
 28class WEBRTC_EXPORT RTCStatsReport : public rtc::RefCountInterface {
2829 public:
2930 typedef std::map<std::string, std::unique_ptr<const RTCStats>> StatsMap;
3031

Source/WebCore/CMakeLists.txt

@@set(WebCore_SOURCES
921921 Modules/mediastream/RTCRtpSender.cpp
922922 Modules/mediastream/RTCRtpTransceiver.cpp
923923 Modules/mediastream/RTCSessionDescription.cpp
924  Modules/mediastream/RTCStatsReport.cpp
925924 Modules/mediastream/RTCTrackEvent.cpp
926925 Modules/mediastream/SDPProcessor.cpp
927926 Modules/mediastream/UserMediaController.cpp

@@set(WebCore_SOURCES
11071106 bindings/js/JSDOMExceptionHandling.cpp
11081107 bindings/js/JSDOMGlobalObject.cpp
11091108 bindings/js/JSDOMGlobalObjectTask.cpp
 1109 bindings/js/JSDOMGuardedObject.cpp
 1110 bindings/js/JSDOMMapLike.cpp
11101111 bindings/js/JSDOMPromise.cpp
11111112 bindings/js/JSDOMStringMapCustom.cpp
11121113 bindings/js/JSDOMWindowBase.cpp

@@set(WebCore_BUILTINS_SOURCES
36813682 ${WEBCORE_DIR}/Modules/streams/StreamInternals.js
36823683 ${WEBCORE_DIR}/Modules/streams/WritableStream.js
36833684 ${WEBCORE_DIR}/Modules/streams/WritableStreamInternals.js
 3685 ${WEBCORE_DIR}/bindings/js/JSDOMBindingInternals.js
36843686 ${WEBCORE_DIR}/xml/XMLHttpRequest.js
36853687)
36863688

Source/WebCore/DerivedSources.make

@@WebCore_BUILTINS_SOURCES = \
13551355 $(WebCore)/Modules/streams/StreamInternals.js \
13561356 $(WebCore)/Modules/streams/WritableStream.js \
13571357 $(WebCore)/Modules/streams/WritableStreamInternals.js \
 1358 $(WebCore)/bindings/js/JSDOMBindingInternals.js \
13581359 $(WebCore)/xml/XMLHttpRequest.js \
13591360#
13601361

Source/WebCore/Modules/mediastream/RTCStatsReport.cpp

1 
2 /*
3  * Copyright (C) 2012 Google Inc. All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
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 INC. 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 INC. 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 ON
21  * 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 THIS
23  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24  */
25 
26 #include "config.h"
27 #include "RTCStatsReport.h"
28 
29 #if ENABLE(WEB_RTC)
30 
31 namespace WebCore {
32 
33 } // namespace WebCore
34 
35 #endif // ENABLE(WEB_RTC)

Source/WebCore/Modules/mediastream/RTCStatsReport.h

11/*
22 * Copyright (C) 2012 Google Inc. All rights reserved.
 3 * Copyright (C) 2017 Apple Inc. All rights reserved.
34 *
45 * Redistribution and use in source and binary forms, with or without
56 * modification, are permitted provided that the following conditions

2425
2526#pragma once
2627
27 #include <wtf/Ref.h>
28 #include <wtf/RefCounted.h>
 28#include "JSDOMMapLike.h"
2929
3030namespace WebCore {
3131

@@class RTCStatsReport : public RefCounted<RTCStatsReport> {
3333public:
3434 static Ref<RTCStatsReport> create() { return adoptRef(*new RTCStatsReport); }
3535
 36 void synchronizeBackingMap(Ref<DOMMapLike>&& mapLike) { m_mapLike = WTFMove(mapLike); }
 37 DOMMapLike* backingMap() { return m_mapLike.get(); }
 38
 39 template<typename Value> void addStats(typename Value::ParameterType&& value) { m_mapLike->set<IDLDOMString, Value>(value.id, std::forward<typename Value::ParameterType>(value)); }
 40
 41
 42 enum class Type {
 43 Codec,
 44 InboundRtp,
 45 OutboundRtp,
 46 PeerConnection,
 47 DataChannel,
 48 Track,
 49 Transport,
 50 CandidatePair,
 51 LocalCandidate,
 52 RemoteCandidate,
 53 Certificate
 54 };
 55 struct Stats {
 56 unsigned long long timestamp;
 57 Type type;
 58 String id;
 59 };
 60
 61 struct RTCRTPStreamStats : Stats {
 62 String ssrc;
 63 String associateStatsId;
 64 bool isRemote { false };
 65 String mediaType;
 66
 67 String mediaTrackId;
 68 String transportId;
 69 String codecId;
 70 unsigned long firCount { 0 };
 71 unsigned long pliCount { 0 };
 72 unsigned long nackCount { 0 };
 73 unsigned long sliCount { 0 };
 74 unsigned long long qpSum { 0 };
 75 };
 76
 77 struct InboundRTPStreamStats : RTCRTPStreamStats {
 78 InboundRTPStreamStats() { type = RTCStatsReport::Type::InboundRtp; }
 79
 80 String ssrc;
 81 String associateStatsId;
 82 bool isRemote { false };
 83 String mediaType;
 84 String mediaTrackId;
 85 String transportId;
 86 String codecId;
 87 unsigned long firCount { 0 };
 88 unsigned long pliCount { 0 };
 89 unsigned long nackCount { 0 };
 90 unsigned long sliCount { 0 };
 91 unsigned long long qpSum { 0 };
 92 unsigned long packetsReceived { 0 };
 93 unsigned long long bytesReceived { 0 };
 94 unsigned long packetsLost { 0 };
 95 double jitter { 0 };
 96 double fractionLost { 0 };
 97 unsigned long packetsDiscarded { 0 };
 98 unsigned long packetsRepaired { 0 };
 99 unsigned long burstPacketsLost { 0 };
 100 unsigned long burstPacketsDiscarded { 0 };
 101 unsigned long burstLossCount { 0 };
 102 unsigned long burstDiscardCount { 0 };
 103 double burstLossRate { 0 };
 104 double burstDiscardRate { 0 };
 105 double gapLossRate { 0 };
 106 double gapDiscardRate { 0 };
 107 unsigned long framesDecoded { 0 };
 108 };
 109
 110 struct OutboundRTPStreamStats : RTCRTPStreamStats {
 111 OutboundRTPStreamStats() { type = RTCStatsReport::Type::OutboundRtp; }
 112
 113 unsigned long packetsSent { 0 };
 114 unsigned long long bytesSent { 0 };
 115 double targetBitrate { 0 };
 116 double roundTripTime { 0 };
 117 unsigned long framesEncoded { 0 };
 118 };
 119
36120private:
37121 RTCStatsReport() = default;
 122
 123private:
 124 RefPtr<DOMMapLike> m_mapLike;
38125};
39126
40127} // namespace WebCore

Source/WebCore/Modules/mediastream/RTCStatsReport.idl

2727 Conditional=WEB_RTC,
2828 ImplementationLacksVTable,
2929] interface RTCStatsReport {
30  // FIXME: Make it setlike
31  //readonly maplike<DOMString, object>;
 30 readonly maplike<DOMString, object>;
 31};
 32
 33enum RTCStatsType {
 34 "codec",
 35 "inbound-rtp",
 36 "outbound-rtp",
 37 "peer-connection",
 38 "data-channel",
 39 "track",
 40 "transport",
 41 "candidate-pair",
 42 "local-candidate",
 43 "remote-candidate",
 44 "certificate"
 45};
 46
 47dictionary RTCStats {
 48 unsigned long long timestamp;
 49 RTCStatsType type;
 50 DOMString id;
 51
 52};
 53
 54dictionary RTCRTPStreamStats : RTCStats {
 55 DOMString ssrc;
 56 DOMString associateStatsId;
 57 boolean isRemote = false;
 58 DOMString mediaType;
 59 DOMString mediaTrackId;
 60 DOMString transportId;
 61 DOMString codecId;
 62 unsigned long firCount;
 63 unsigned long pliCount;
 64 unsigned long nackCount;
 65 unsigned long sliCount;
 66 unsigned long long qpSum;
 67};
 68
 69[ JSGenerateToJSObject ]
 70dictionary RTCInboundRTPStreamStats : RTCRTPStreamStats {
 71 unsigned long packetsReceived;
 72 unsigned long long bytesReceived;
 73 unsigned long packetsLost;
 74 double jitter;
 75 double fractionLost;
 76 unsigned long packetsDiscarded;
 77 unsigned long packetsRepaired;
 78 unsigned long burstPacketsLost;
 79 unsigned long burstPacketsDiscarded;
 80 unsigned long burstLossCount;
 81 unsigned long burstDiscardCount;
 82 double burstLossRate;
 83 double burstDiscardRate;
 84 double gapLossRate;
 85 double gapDiscardRate;
 86 unsigned long framesDecoded;
 87};
 88
 89[ JSGenerateToJSObject ]
 90dictionary RTCOutboundRTPStreamStats : RTCRTPStreamStats {
 91 unsigned long packetsSent;
 92 unsigned long long bytesSent;
 93 double targetBitrate;
 94 double roundTripTime;
 95 unsigned long framesEncoded;
3296};

Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCMediaEndpoint.cpp

2828#if USE(LIBWEBRTC)
2929
3030#include "EventNames.h"
 31#include "JSDOMConvert.h"
 32#include "JSRTCStatsReport.h"
3133#include "LibWebRTCDataChannelHandler.h"
3234#include "LibWebRTCPeerConnectionBackend.h"
3335#include "LibWebRTCProvider.h"

3941#include "RTCIceCandidate.h"
4042#include "RTCPeerConnection.h"
4143#include "RTCSessionDescription.h"
 44#include "RTCStatsReport.h"
4245#include "RTCTrackEvent.h"
4346#include "RealtimeIncomingAudioSource.h"
4447#include "RealtimeIncomingVideoSource.h"

@@LibWebRTCMediaEndpoint::StatsCollector::StatsCollector(LibWebRTCMediaEndpoint& e
227230 m_id = track->id();
228231}
229232
230 void LibWebRTCMediaEndpoint::StatsCollector::OnStatsDelivered(const rtc::scoped_refptr<const webrtc::RTCStatsReport>& report)
231 {
232  callOnMainThread([protectedThis = rtc::scoped_refptr<LibWebRTCMediaEndpoint::StatsCollector>(this), report] {
 233static inline String fromStdString(const std::string& value)
 234{
 235 return String(value.data(), value.length());
 236}
 237
 238static inline void fillRTCStats(RTCStatsReport::Stats& stats, const webrtc::RTCStats& rtcStats)
 239{
 240 stats.timestamp = rtcStats.timestamp_us();
 241 stats.id = fromStdString(rtcStats.id());
 242}
 243
 244static inline void fillRTCRTPStreamStats(RTCStatsReport::RTCRTPStreamStats& stats, const webrtc::RTCRTPStreamStats& rtcStats)
 245{
 246 fillRTCStats(stats, rtcStats);
 247 if (rtcStats.ssrc.is_defined())
 248 stats.ssrc = fromStdString(*rtcStats.ssrc);
 249 if (rtcStats.associate_stats_id.is_defined())
 250 stats.associateStatsId = fromStdString(*rtcStats.associate_stats_id);
 251 if (rtcStats.is_remote.is_defined())
 252 stats.isRemote = *rtcStats.is_remote;
 253 if (rtcStats.media_type.is_defined())
 254 stats.mediaType = fromStdString(*rtcStats.media_type);
 255 if (rtcStats.media_track_id.is_defined())
 256 stats.mediaTrackId = fromStdString(*rtcStats.media_track_id);
 257 if (rtcStats.transport_id.is_defined())
 258 stats.transportId = fromStdString(*rtcStats.transport_id);
 259 if (rtcStats.codec_id.is_defined())
 260 stats.codecId = fromStdString(*rtcStats.codec_id);
 261 if (rtcStats.fir_count.is_defined())
 262 stats.firCount = *rtcStats.fir_count;
 263 if (rtcStats.pli_count.is_defined())
 264 stats.pliCount = *rtcStats.pli_count;
 265 if (rtcStats.nack_count.is_defined())
 266 stats.nackCount = *rtcStats.nack_count;
 267 if (rtcStats.sli_count.is_defined())
 268 stats.sliCount = *rtcStats.sli_count;
 269 // FIXME: Set qpSum
 270 stats.qpSum = 0;
 271}
 272
 273static inline void fillInboundRTPStreamStats(RTCStatsReport::InboundRTPStreamStats& stats, const webrtc::RTCInboundRTPStreamStats& rtcStats)
 274{
 275 fillRTCRTPStreamStats(stats, rtcStats);
 276 if (rtcStats.packets_received.is_defined())
 277 stats.packetsReceived = *rtcStats.packets_received;
 278 if (rtcStats.bytes_received.is_defined())
 279 stats.bytesReceived = *rtcStats.bytes_received;
 280 if (rtcStats.packets_lost.is_defined())
 281 stats.packetsLost = *rtcStats.packets_lost;
 282 if (rtcStats.jitter.is_defined())
 283 stats.jitter = *rtcStats.jitter;
 284 if (rtcStats.fraction_lost.is_defined())
 285 stats.fractionLost = *rtcStats.fraction_lost;
 286 if (rtcStats.packets_discarded.is_defined())
 287 stats.packetsDiscarded = *rtcStats.packets_discarded;
 288 if (rtcStats.packets_repaired.is_defined())
 289 stats.packetsRepaired = *rtcStats.packets_repaired;
 290 if (rtcStats.burst_packets_lost.is_defined())
 291 stats.burstPacketsLost = *rtcStats.burst_packets_lost;
 292 if (rtcStats.burst_packets_discarded.is_defined())
 293 stats.burstPacketsDiscarded = *rtcStats.burst_packets_discarded;
 294 if (rtcStats.burst_loss_count.is_defined())
 295 stats.burstLossCount = *rtcStats.burst_loss_count;
 296 if (rtcStats.burst_discard_count.is_defined())
 297 stats.burstDiscardCount = *rtcStats.burst_discard_count;
 298 if (rtcStats.burst_loss_rate.is_defined())
 299 stats.burstLossRate = *rtcStats.burst_loss_rate;
 300 if (rtcStats.burst_discard_rate.is_defined())
 301 stats.burstDiscardRate = *rtcStats.burst_discard_rate;
 302 if (rtcStats.gap_loss_rate.is_defined())
 303 stats.gapLossRate = *rtcStats.gap_loss_rate;
 304 if (rtcStats.gap_discard_rate.is_defined())
 305 stats.gapDiscardRate = *rtcStats.gap_discard_rate;
 306 // FIXME: Set framesDecoded
 307 stats.framesDecoded = 0;
 308}
 309
 310static inline void fillOutboundRTPStreamStats(RTCStatsReport::OutboundRTPStreamStats& stats, const webrtc::RTCOutboundRTPStreamStats& rtcStats)
 311{
 312 fillRTCRTPStreamStats(stats, rtcStats);
 313
 314 if (rtcStats.packets_sent.is_defined())
 315 stats.packetsSent = *rtcStats.packets_sent;
 316 if (rtcStats.bytes_sent.is_defined())
 317 stats.bytesSent = *rtcStats.bytes_sent;
 318 if (rtcStats.target_bitrate.is_defined())
 319 stats.targetBitrate = *rtcStats.target_bitrate;
 320 if (rtcStats.round_trip_time.is_defined())
 321 stats.roundTripTime = *rtcStats.round_trip_time;
 322 // FIXME: Set framesEncoded
 323 stats.framesEncoded = 0;
 324}
 325
 326void LibWebRTCMediaEndpoint::StatsCollector::OnStatsDelivered(const rtc::scoped_refptr<const webrtc::RTCStatsReport>& rtcReport)
 327{
 328 callOnMainThread([protectedThis = rtc::scoped_refptr<LibWebRTCMediaEndpoint::StatsCollector>(this), rtcReport] {
233329 if (protectedThis->m_endpoint.isStopped())
234330 return;
235331
236  // FIXME: Fulfill promise with the report
237  UNUSED_PARAM(report);
 332 auto report = RTCStatsReport::create();
 333 protectedThis->m_endpoint.m_peerConnectionBackend.getStatsSucceeded(protectedThis->m_promise, report.copyRef());
 334 ASSERT(report->backingMap());
238335
239  protectedThis->m_endpoint.m_peerConnectionBackend.getStatsFailed(protectedThis->m_promise, Exception { TypeError, ASCIILiteral("Stats API is not yet implemented") });
 336 for (const auto& rtcStats : *rtcReport) {
 337 if (rtcStats.type() == webrtc::RTCInboundRTPStreamStats::kType) {
 338 RTCStatsReport::InboundRTPStreamStats stats;
 339 fillInboundRTPStreamStats(stats, static_cast<const webrtc::RTCInboundRTPStreamStats&>(rtcStats));
 340 report->addStats<IDLDictionary<RTCStatsReport::InboundRTPStreamStats>>(WTFMove(stats));
 341 return;
 342 }
 343 if (rtcStats.type() == webrtc::RTCOutboundRTPStreamStats::kType) {
 344 RTCStatsReport::OutboundRTPStreamStats stats;
 345 fillOutboundRTPStreamStats(stats, static_cast<const webrtc::RTCOutboundRTPStreamStats&>(rtcStats));
 346 report->addStats<IDLDictionary<RTCStatsReport::OutboundRTPStreamStats>>(WTFMove(stats));
 347 return;
 348 }
 349 }
240350 });
241351}
242352

Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCPeerConnectionBackend.h

@@namespace WebCore {
3838class LibWebRTCMediaEndpoint;
3939class RTCRtpReceiver;
4040class RTCSessionDescription;
41 class RTCstatsReport;
 41class RTCStatsReport;
4242class RealtimeOutgoingAudioSource;
4343class RealtimeOutgoingVideoSource;
4444

Source/WebCore/WebCore.xcodeproj/project.pbxproj

192192 078E090A17D14CEE00420AA1 /* RTCIceCandidateEvent.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 07221B7417CEC32700848E51 /* RTCIceCandidateEvent.cpp */; };
193193 078E090B17D14CEE00420AA1 /* RTCPeerConnection.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 07221B7717CEC32700848E51 /* RTCPeerConnection.cpp */; };
194194 078E090C17D14CEE00420AA1 /* RTCSessionDescription.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 07221B7A17CEC32700848E51 /* RTCSessionDescription.cpp */; };
195  078E090E17D14CEE00420AA1 /* RTCStatsReport.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 07221B8317CEC32700848E51 /* RTCStatsReport.cpp */; };
196195 078E091217D14CEE00420AA1 /* UserMediaController.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 07221B8E17CEC32700848E51 /* UserMediaController.cpp */; };
197196 078E091317D14CEE00420AA1 /* UserMediaRequest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 07221B9017CEC32700848E51 /* UserMediaRequest.cpp */; };
198197 078E091417D14D1C00420AA1 /* MediaConstraintsImpl.h in Headers */ = {isa = PBXBuildFile; fileRef = 07221B4B17CEC32700848E51 /* MediaConstraintsImpl.h */; settings = {ATTRIBUTES = (Private, ); }; };

15611560 4162A4581011464700DFF3ED /* JSDedicatedWorkerGlobalScope.h in Headers */ = {isa = PBXBuildFile; fileRef = 4162A4561011464700DFF3ED /* JSDedicatedWorkerGlobalScope.h */; };
15621561 416E29A6102FA962007FC14E /* WorkerReportingProxy.h in Headers */ = {isa = PBXBuildFile; fileRef = 416E29A5102FA962007FC14E /* WorkerReportingProxy.h */; };
15631562 416E6FE81BBD12DF000A3F64 /* ReadableStreamInternalsBuiltins.h in Headers */ = {isa = PBXBuildFile; fileRef = 9B03D8061BB3110D00B764D9 /* ReadableStreamInternalsBuiltins.h */; settings = {ATTRIBUTES = (Private, ); }; };
 1563 416E6FE81BBD12DF000A3F65 /* JSDOMBindingInternalsBuiltins.h in Headers */ = {isa = PBXBuildFile; fileRef = 9B03D8061BB3110D00B764DA /* JSDOMBindingInternalsBuiltins.h */; settings = {ATTRIBUTES = (Private, ); }; };
15641564 416E6FE81BBD12DF000A6023 /* FetchInternalsBuiltins.h in Headers */ = {isa = PBXBuildFile; fileRef = 9B03D8061BB3110D00B764B9 /* FetchInternalsBuiltins.h */; settings = {ATTRIBUTES = (Private, ); }; };
15651565 416E6FE81BBD12DF000A6033 /* StreamInternalsBuiltins.h in Headers */ = {isa = PBXBuildFile; fileRef = 9B03D8061BB3110D00B764C9 /* StreamInternalsBuiltins.h */; settings = {ATTRIBUTES = (Private, ); }; };
15661566 416E6FE81BBD12DF000A6043 /* ReadableByteStreamInternalsBuiltins.h in Headers */ = {isa = PBXBuildFile; fileRef = 9B03D8061BB3110D00B73F64 /* ReadableByteStreamInternalsBuiltins.h */; settings = {ATTRIBUTES = (Private, ); }; };

15941594 419BC2DF1685329900D64D6D /* VisitedLinkState.h in Headers */ = {isa = PBXBuildFile; fileRef = 419BC2DD1685329900D64D6D /* VisitedLinkState.h */; };
15951595 419BE7591BC7F42B00E1C85B /* WebCoreBuiltinNames.h in Headers */ = {isa = PBXBuildFile; fileRef = 419BE7521BC7F3DB00E1C85B /* WebCoreBuiltinNames.h */; };
15961596 41A1B00E1E526579007F3769 /* LibWebRTCProvider.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 41A1B00D1E52656E007F3769 /* LibWebRTCProvider.cpp */; };
 1597 41A1B01C1E54239B007F3769 /* JSDOMGuardedObject.h in Headers */ = {isa = PBXBuildFile; fileRef = 41A1B01A1E542396007F3769 /* JSDOMGuardedObject.h */; settings = {ATTRIBUTES = (Private, ); }; };
 1598 41A1B01D1E54239E007F3769 /* JSDOMGuardedObject.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 41A1B01B1E542396007F3769 /* JSDOMGuardedObject.cpp */; };
15971599 41A3D58E101C152D00316D07 /* DedicatedWorkerThread.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 41A3D58C101C152D00316D07 /* DedicatedWorkerThread.cpp */; };
15981600 41A3D58F101C152D00316D07 /* DedicatedWorkerThread.h in Headers */ = {isa = PBXBuildFile; fileRef = 41A3D58D101C152D00316D07 /* DedicatedWorkerThread.h */; };
15991601 41ABE67B1D0580DB006D862D /* CrossOriginPreflightChecker.h in Headers */ = {isa = PBXBuildFile; fileRef = 41ABE67A1D0580D5006D862D /* CrossOriginPreflightChecker.h */; };

16061608 41CF8BE71D46226700707DC9 /* FetchBodyConsumer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 41CF8BE41D46222000707DC9 /* FetchBodyConsumer.cpp */; };
16071609 41D015CA0F4B5C71004A662F /* ContentType.h in Headers */ = {isa = PBXBuildFile; fileRef = 41D015C80F4B5C71004A662F /* ContentType.h */; };
16081610 41D015CB0F4B5C71004A662F /* ContentType.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 41D015C90F4B5C71004A662F /* ContentType.cpp */; };
 1611 41DEFCB51E56C1BD000D9E5F /* JSDOMMapLike.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 41DEFCB31E56C1B9000D9E5F /* JSDOMMapLike.cpp */; };
 1612 41DEFCB61E56C1BD000D9E5F /* JSDOMMapLike.h in Headers */ = {isa = PBXBuildFile; fileRef = 41DEFCB41E56C1B9000D9E5F /* JSDOMMapLike.h */; };
16091613 41E1B1D00FF5986900576B3B /* AbstractWorker.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 41E1B1CA0FF5986900576B3B /* AbstractWorker.cpp */; };
16101614 41E1B1D10FF5986900576B3B /* AbstractWorker.h in Headers */ = {isa = PBXBuildFile; fileRef = 41E1B1CB0FF5986900576B3B /* AbstractWorker.h */; };
16111615 41E408391DCB748900EFCE19 /* PeerConnectionBackend.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 41E408381DCB747900EFCE19 /* PeerConnectionBackend.cpp */; };

72067210 07221B7A17CEC32700848E51 /* RTCSessionDescription.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RTCSessionDescription.cpp; sourceTree = "<group>"; };
72077211 07221B7B17CEC32700848E51 /* RTCSessionDescription.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RTCSessionDescription.h; sourceTree = "<group>"; };
72087212 07221B7C17CEC32700848E51 /* RTCSessionDescription.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = RTCSessionDescription.idl; sourceTree = "<group>"; };
7209  07221B8317CEC32700848E51 /* RTCStatsReport.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RTCStatsReport.cpp; sourceTree = "<group>"; };
72107213 07221B8417CEC32700848E51 /* RTCStatsReport.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RTCStatsReport.h; sourceTree = "<group>"; };
72117214 07221B8517CEC32700848E51 /* RTCStatsReport.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = RTCStatsReport.idl; sourceTree = "<group>"; };
72127215 07221B8D17CEC32700848E51 /* UserMediaClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UserMediaClient.h; sourceTree = "<group>"; };

88568859 41A023ED1A39DB7900F722CF /* ReadableStream.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = ReadableStream.idl; sourceTree = "<group>"; };
88578860 41A023ED1A39DB7900F722DF /* WritableStream.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = WritableStream.idl; sourceTree = "<group>"; };
88588861 41A1B00D1E52656E007F3769 /* LibWebRTCProvider.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = LibWebRTCProvider.cpp; path = libwebrtc/LibWebRTCProvider.cpp; sourceTree = "<group>"; };
 8862 41A1B01A1E542396007F3769 /* JSDOMGuardedObject.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSDOMGuardedObject.h; sourceTree = "<group>"; };
 8863 41A1B01B1E542396007F3769 /* JSDOMGuardedObject.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSDOMGuardedObject.cpp; sourceTree = "<group>"; };
88598864 41A3D58C101C152D00316D07 /* DedicatedWorkerThread.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DedicatedWorkerThread.cpp; sourceTree = "<group>"; };
88608865 41A3D58D101C152D00316D07 /* DedicatedWorkerThread.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DedicatedWorkerThread.h; sourceTree = "<group>"; };
88618866 41ABE6791D0580D5006D862D /* CrossOriginPreflightChecker.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CrossOriginPreflightChecker.cpp; sourceTree = "<group>"; };

88718876 41D015C80F4B5C71004A662F /* ContentType.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ContentType.h; sourceTree = "<group>"; };
88728877 41D015C90F4B5C71004A662F /* ContentType.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ContentType.cpp; sourceTree = "<group>"; };
88738878 41D51BB21E4E2E8100131A5B /* LibWebRTCAudioFormat.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = LibWebRTCAudioFormat.h; path = libwebrtc/LibWebRTCAudioFormat.h; sourceTree = "<group>"; };
 8879 41DEFCB21E56C1B9000D9E5F /* JSDOMBindingInternals.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; path = JSDOMBindingInternals.js; sourceTree = "<group>"; };
 8880 41DEFCB31E56C1B9000D9E5F /* JSDOMMapLike.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSDOMMapLike.cpp; sourceTree = "<group>"; };
 8881 41DEFCB41E56C1B9000D9E5F /* JSDOMMapLike.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSDOMMapLike.h; sourceTree = "<group>"; };
88748882 41E1B1CA0FF5986900576B3B /* AbstractWorker.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = AbstractWorker.cpp; sourceTree = "<group>"; };
88758883 41E1B1CB0FF5986900576B3B /* AbstractWorker.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AbstractWorker.h; sourceTree = "<group>"; };
88768884 41E1B1CC0FF5986900576B3B /* AbstractWorker.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = AbstractWorker.idl; sourceTree = "<group>"; };

1162511633 9908B0FD1BCAD07D00ED0F45 /* FetchInternalsBuiltins.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = FetchInternalsBuiltins.cpp; sourceTree = "<group>"; };
1162611634 9908B0FD1BCAD07D00ED0F55 /* StreamInternalsBuiltins.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = StreamInternalsBuiltins.cpp; sourceTree = "<group>"; };
1162711635 9908B0FD1BCAD07D00ED0F65 /* ReadableStreamInternalsBuiltins.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ReadableStreamInternalsBuiltins.cpp; sourceTree = "<group>"; };
 11636 9908B0FD1BCAD07D00ED0F66 /* JSDOMBindingInternalsBuiltins.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSDOMBindingInternalsBuiltins.cpp; sourceTree = "<group>"; };
1162811637 9908B0FD1BCAD07D00ED0F75 /* WritableStreamInternalsBuiltins.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WritableStreamInternalsBuiltins.cpp; sourceTree = "<group>"; };
1162911638 9908B0FD1BCAD07D00ED3F64 /* ReadableByteStreamInternalsBuiltins.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ReadableByteStreamInternalsBuiltins.cpp; sourceTree = "<group>"; };
1163011639 9908B0FE1BCAD07D00ED0F65 /* ReadableStreamDefaultReaderBuiltins.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ReadableStreamDefaultReaderBuiltins.cpp; sourceTree = "<group>"; };

1167211681 9B03D8061BB3110D00B764C9 /* StreamInternalsBuiltins.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = StreamInternalsBuiltins.h; sourceTree = "<group>"; };
1167311682 9B03D8061BB3110D00B764D8 /* ReadableStreamBuiltins.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ReadableStreamBuiltins.h; sourceTree = "<group>"; };
1167411683 9B03D8061BB3110D00B764D9 /* ReadableStreamInternalsBuiltins.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ReadableStreamInternalsBuiltins.h; sourceTree = "<group>"; };
 11684 9B03D8061BB3110D00B764DA /* JSDOMBindingInternalsBuiltins.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSDOMBindingInternalsBuiltins.h; sourceTree = "<group>"; };
1167511685 9B03D8061BB3110D00B764E8 /* WritableStreamBuiltins.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WritableStreamBuiltins.h; sourceTree = "<group>"; };
1167611686 9B03D8061BB3110D00B764E9 /* WritableStreamInternalsBuiltins.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WritableStreamInternalsBuiltins.h; sourceTree = "<group>"; };
1167711687 9B0FE8731D9E02DF004A8ACB /* DocumentOrShadowRoot.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = DocumentOrShadowRoot.idl; sourceTree = "<group>"; };

1539015400 07221B7A17CEC32700848E51 /* RTCSessionDescription.cpp */,
1539115401 07221B7B17CEC32700848E51 /* RTCSessionDescription.h */,
1539215402 07221B7C17CEC32700848E51 /* RTCSessionDescription.idl */,
15393  07221B8317CEC32700848E51 /* RTCStatsReport.cpp */,
1539415403 07221B8417CEC32700848E51 /* RTCStatsReport.h */,
1539515404 07221B8517CEC32700848E51 /* RTCStatsReport.idl */,
1539615405 5E2C43641BCEE3720001E2BC /* RTCTrackEvent.cpp */,

1788317892 9908B0FF1BCAD07D00ED0F65 /* ReadableStreamDefaultReaderBuiltins.h */,
1788417893 9908B0FD1BCAD07D00ED0F65 /* ReadableStreamInternalsBuiltins.cpp */,
1788517894 9B03D8061BB3110D00B764D9 /* ReadableStreamInternalsBuiltins.h */,
 17895 9908B0FD1BCAD07D00ED0F66 /* JSDOMBindingInternalsBuiltins.cpp */,
 17896 9B03D8061BB3110D00B764DA /* JSDOMBindingInternalsBuiltins.h */,
1788617897 5E2C43751BCF9A0B0001E2BC /* RTCPeerConnectionBuiltins.cpp */,
1788717898 5E2C43761BCF9A0B0001E2BC /* RTCPeerConnectionBuiltins.h */,
1788817899 5E2C43781BCF9A0B0001E2BC /* RTCPeerConnectionInternalsBuiltins.cpp */,

2239822409 9BD4E9151C462872005065BC /* JSCustomElementInterface.h */,
2239922410 93B70D4809EB0C7C009D8468 /* JSDOMBinding.h */,
2240022411 7C45C9C61E3E8ABA00AAB558 /* JSDOMBindingCaller.h */,
 22412 41DEFCB21E56C1B9000D9E5F /* JSDOMBindingInternals.js */,
2240122413 7C45C9CA1E3E8D2E00AAB558 /* JSDOMBindingSecurity.cpp */,
2240222414 7C45C9C91E3E8CD700AAB558 /* JSDOMBindingSecurity.h */,
2240322415 7C45C9CC1E3E8F0800AAB558 /* JSDOMExceptionHandling.cpp */,

2240622418 E1C36C020EB076D6007410BC /* JSDOMGlobalObject.h */,
2240722419 7C2BDD3B17C7F98B0038FF15 /* JSDOMGlobalObjectTask.cpp */,
2240822420 7C2BDD3C17C7F98B0038FF15 /* JSDOMGlobalObjectTask.h */,
 22421 41A1B01A1E542396007F3769 /* JSDOMGuardedObject.h */,
 22422 41A1B01B1E542396007F3769 /* JSDOMGuardedObject.cpp */,
2240922423 4138F8551D253EEE001CB61E /* JSDOMIterator.cpp */,
2241022424 4138F8561D253EEE001CB61E /* JSDOMIterator.h */,
 22425 41DEFCB31E56C1B9000D9E5F /* JSDOMMapLike.cpp */,
 22426 41DEFCB41E56C1B9000D9E5F /* JSDOMMapLike.h */,
2241122427 E172AF8D1811BC3700FBADB9 /* JSDOMPromise.cpp */,
2241222428 E172AF8E1811BC3700FBADB9 /* JSDOMPromise.h */,
2241322429 BC6932710D7E293900AE44D1 /* JSDOMWindowBase.cpp */,

2552425540 43EDD67F1B485DBF00640E75 /* CombinedFiltersAlphabet.h in Headers */,
2552525541 26E944D91AC4B2DD007B85B5 /* CombinedURLFilters.h in Headers */,
2552625542 A584FE351864D5AF00843B10 /* CommandLineAPIHost.h in Headers */,
 25543 41DEFCB61E56C1BD000D9E5F /* JSDOMMapLike.h in Headers */,
2552725544 A584FE2C1863870F00843B10 /* CommandLineAPIModule.h in Headers */,
2552825545 A584FE2618637DAB00843B10 /* CommandLineAPIModuleSource.h in Headers */,
2552925546 6550B6A2099DF0270090D781 /* Comment.h in Headers */,

2719227209 89B5EAA211E8003D00F2367E /* LineEnding.h in Headers */,
2719327210 FFEFAB2A18380DA000514534 /* LineLayoutState.h in Headers */,
2719427211 FFDBC047183D27B700407109 /* LineWidth.h in Headers */,
 27212 41A1B01C1E54239B007F3769 /* JSDOMGuardedObject.h in Headers */,
2719527213 A7AD2F880EC89D07008AB002 /* LinkHash.h in Headers */,
2719627214 CBA9DC0B1DF44DF40005675C /* LinkHeader.h in Headers */,
2719727215 5143B2631DDD15200014FAC6 /* LinkIcon.h in Headers */,

2767727695 416E6FE81BBD12DF000A6043 /* ReadableByteStreamInternalsBuiltins.h in Headers */,
2767827696 416E6FE91BBD12E5000A6043 /* ReadableStreamBuiltins.h in Headers */,
2767927697 416E6FE81BBD12DF000A3F64 /* ReadableStreamInternalsBuiltins.h in Headers */,
 27698 416E6FE81BBD12DF000A3F65 /* JSDOMBindingInternalsBuiltins.h in Headers */,
2768027699 FD31603C12B0267600C1A359 /* RealtimeAnalyser.h in Headers */,
2768127700 41103AAD1E39791000769F03 /* RealtimeIncomingAudioSource.h in Headers */,
2768227701 4A4F65711AA997F100E38CDD /* RealtimeMediaSource.h in Headers */,

2958929608 31288E720E3005D6003619AE /* CSSKeyframeRule.cpp in Sources */,
2959029609 31288E740E3005D6003619AE /* CSSKeyframesRule.cpp in Sources */,
2959129610 BC772E16133162C2001EC9CE /* CSSLineBoxContainValue.cpp in Sources */,
 29611 41DEFCB51E56C1BD000D9E5F /* JSDOMMapLike.cpp in Sources */,
2959229612 946D37491D6D06280077084F /* CSSMarkup.cpp in Sources */,
2959329613 A80E6CFC0A1989CA007FB8C5 /* CSSMediaRule.cpp in Sources */,
2959429614 314BE3A31B30F6D100141982 /* CSSNamedImageValue.cpp in Sources */,

3160631626 5E5E2B131CFC3E70000C0D85 /* RTCRtpTransceiver.cpp in Sources */,
3160731627 078E090C17D14CEE00420AA1 /* RTCSessionDescription.cpp in Sources */,
3160831628 073BE34E17D180B2002BD431 /* RTCSessionDescriptionDescriptor.cpp in Sources */,
31609  078E090E17D14CEE00420AA1 /* RTCStatsReport.cpp in Sources */,
3161031629 5E2C43671BCEE3770001E2BC /* RTCTrackEvent.cpp in Sources */,
3161131630 5824ABA21AE81116009074B7 /* RubyElement.cpp in Sources */,
3161231631 5824ABA61AE81384009074B7 /* RubyTextElement.cpp in Sources */,

3173931758 9444CBD31D860C8B0073A074 /* SizesCalcParser.cpp in Sources */,
3174031759 49E911CC0EF86D47009D0CAF /* SkewTransformOperation.cpp in Sources */,
3174131760 4150F9F212B6E0E70008C860 /* SliderThumbElement.cpp in Sources */,
 31761 41A1B01D1E54239E007F3769 /* JSDOMGuardedObject.cpp in Sources */,
3174231762 9B532EA31BA928570038A827 /* SlotAssignment.cpp in Sources */,
3174331763 4B6FA6F70C39E4A100087011 /* SmartReplaceCF.cpp in Sources */,
3174431764 E4AFD00B0DAF335400F5F55C /* SMILTime.cpp in Sources */,

Source/WebCore/bindings/js/JSDOMBindingInternals.js

 1/*
 2 * Copyright (C) 2017 Apple Inc.
 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 * 1. Redistributions of source code must retain the above copyright
 8 * notice, this list of conditions and the following disclaimer.
 9 * 2. Redistributions in binary form must reproduce the above copyright
 10 * notice, this list of conditions and the following disclaimer in the
 11 * documentation and/or other materials provided with the distribution.
 12 *
 13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
 14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
 17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
 18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
 19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
 20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
 21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 24 */
 25
 26// @internal
 27
 28function mapLikeForEach(callback)
 29{
 30 "use strict";
 31 this.@backingMap.forEach((value, key, map) => {
 32 callback(value, key, this);
 33 });
 34}

Source/WebCore/bindings/js/JSDOMGlobalObject.cpp

@@void JSDOMGlobalObject::visitChildren(JSCell* cell, SlotVisitor& visitor)
191191 JSDOMGlobalObject* thisObject = jsCast<JSDOMGlobalObject*>(cell);
192192 ASSERT_GC_OBJECT_INHERITS(thisObject, info());
193193 Base::visitChildren(thisObject, visitor);
194 
 194
195195 {
196196 auto locker = holdLock(thisObject->m_gcLock);
197 
 197
198198 for (auto& structure : thisObject->structures(locker).values())
199199 visitor.append(structure);
200 
 200
201201 for (auto& constructor : thisObject->constructors(locker).values())
202202 visitor.append(constructor);
203 
204  for (auto& deferredPromise : thisObject->deferredPromises(locker))
205  deferredPromise->visitAggregate(visitor);
 203
 204 for (auto& guarded : thisObject->guardedObjects(locker))
 205 guarded->visitAggregate(visitor);
206206 }
207207
208208 thisObject->m_builtinInternalFunctions.visit(visitor);

Source/WebCore/bindings/js/JSDOMGlobalObject.h

3434
3535namespace WebCore {
3636
37  class DeferredPromise;
 37 class DOMGuardedObject;
3838 class Document;
3939 class Event;
4040 class DOMWrapperWorld;

@@namespace WebCore {
4242
4343 typedef HashMap<const JSC::ClassInfo*, JSC::WriteBarrier<JSC::Structure>> JSDOMStructureMap;
4444 typedef HashMap<const JSC::ClassInfo*, JSC::WriteBarrier<JSC::JSObject>> JSDOMConstructorMap;
45  typedef HashSet<DeferredPromise*> DeferredPromiseSet;
 45 typedef HashSet<DOMGuardedObject*> DOMGuardedObjectSet;
4646
4747 class WEBCORE_EXPORT JSDOMGlobalObject : public JSC::JSGlobalObject {
4848 typedef JSC::JSGlobalObject Base;

@@namespace WebCore {
5656
5757 public:
5858 Lock& gcLock() { return m_gcLock; }
59 
 59
6060 JSDOMStructureMap& structures(const AbstractLocker&) { return m_structures; }
6161 JSDOMConstructorMap& constructors(const AbstractLocker&) { return m_constructors; }
6262
63  DeferredPromiseSet& deferredPromises(const AbstractLocker&) { return m_deferredPromises; }
 63 DOMGuardedObjectSet& guardedObjects(const AbstractLocker&) { return m_guardedObjects; }
6464
6565 ScriptExecutionContext* scriptExecutionContext() const;
6666

@@namespace WebCore {
9494 protected:
9595 JSDOMStructureMap m_structures;
9696 JSDOMConstructorMap m_constructors;
97  DeferredPromiseSet m_deferredPromises;
 97 DOMGuardedObjectSet m_guardedObjects;
9898
9999 Event* m_currentEvent;
100100 Ref<DOMWrapperWorld> m_world;

Source/WebCore/bindings/js/JSDOMGuardedObject.cpp

 1/*
 2 * Copyright (C) 2017 Apple 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 * 1. Redistributions of source code must retain the above copyright
 8 * notice, this list of conditions and the following disclaimer.
 9 * 2. Redistributions in binary form must reproduce the above copyright
 10 * notice, this list of conditions and the following disclaimer in the
 11 * documentation and/or other materials provided with the distribution.
 12 *
 13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
 14 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
 15 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
 17 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 18 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 19 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 20 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 21 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 22 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
 23 * THE POSSIBILITY OF SUCH DAMAGE.
 24 */
 25
 26#include "config.h"
 27#include "JSDOMGuardedObject.h"
 28
 29using namespace JSC;
 30
 31namespace WebCore {
 32
 33DOMGuardedObject::DOMGuardedObject(JSDOMGlobalObject& globalObject, JSCell& guarded)
 34 : ActiveDOMCallback(globalObject.scriptExecutionContext())
 35 , m_guarded(&guarded)
 36 , m_globalObject(&globalObject)
 37{
 38 auto locker = lockDuringMarking(globalObject.vm().heap, globalObject.gcLock());
 39 globalObject.vm().heap.writeBarrier(&globalObject, &guarded);
 40 globalObject.guardedObjects(locker).add(this);
 41}
 42
 43DOMGuardedObject::~DOMGuardedObject()
 44{
 45 clear();
 46}
 47
 48void DOMGuardedObject::clear()
 49{
 50 ASSERT(!m_guarded || m_globalObject);
 51 if (m_guarded && m_globalObject) {
 52 auto locker = lockDuringMarking(m_globalObject->vm().heap, m_globalObject->gcLock());
 53 m_globalObject->guardedObjects(locker).remove(this);
 54 }
 55 m_guarded.clear();
 56}
 57
 58void DOMGuardedObject::contextDestroyed()
 59{
 60 ActiveDOMCallback::contextDestroyed();
 61 clear();
 62}
 63
 64}

Source/WebCore/bindings/js/JSDOMGuardedObject.h

 1/*
 2 * Copyright (C) 2017 Apple 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 * 1. Redistributions of source code must retain the above copyright
 8 * notice, this list of conditions and the following disclaimer.
 9 * 2. Redistributions in binary form must reproduce the above copyright
 10 * notice, this list of conditions and the following disclaimer in the
 11 * documentation and/or other materials provided with the distribution.
 12 *
 13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
 14 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
 15 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
 17 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 18 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 19 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 20 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 21 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 22 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
 23 * THE POSSIBILITY OF SUCH DAMAGE.
 24 */
 25
 26#pragma once
 27
 28#include "ActiveDOMCallback.h"
 29#include "JSDOMGlobalObject.h"
 30#include <heap/HeapInlines.h>
 31#include <heap/StrongInlines.h>
 32#include <runtime/JSCell.h>
 33
 34namespace WebCore {
 35
 36class DOMGuardedObject : public RefCounted<DOMGuardedObject>, public ActiveDOMCallback {
 37public:
 38 ~DOMGuardedObject();
 39
 40 bool isSuspended() { return !m_guarded || !canInvokeCallback(); } // The wrapper world has gone away or active DOM objects have been suspended.
 41
 42 void visitAggregate(JSC::SlotVisitor& visitor) { visitor.append(m_guarded); }
 43
 44 JSC::JSValue guardedObject() const { return m_guarded.get(); }
 45 JSDOMGlobalObject* globalObject() const { return m_globalObject.get(); }
 46
 47protected:
 48 DOMGuardedObject(JSDOMGlobalObject&, JSC::JSCell&);
 49
 50 void clear();
 51 void contextDestroyed() override;
 52 bool isEmpty() { return !m_guarded; }
 53
 54 JSC::Weak<JSC::JSCell> m_guarded;
 55 JSC::Weak<JSDOMGlobalObject> m_globalObject;
 56};
 57
 58template <typename T> class DOMGuarded : public DOMGuardedObject {
 59protected:
 60 DOMGuarded(JSDOMGlobalObject& globalObject, T& guarded) : DOMGuardedObject(globalObject, guarded) { }
 61 T* guarded() const { return JSC::jsDynamicCast<T*>(globalObject()->vm(), guardedObject()); }
 62};
 63
 64} // namespace WebCore

Source/WebCore/bindings/js/JSDOMMapLike.cpp

 1/*
 2 * Copyright (C) 2017 Apple 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 * 1. Redistributions of source code must retain the above copyright
 8 * notice, this list of conditions and the following disclaimer.
 9 * 2. Redistributions in binary form must reproduce the above copyright
 10 * notice, this list of conditions and the following disclaimer in the
 11 * documentation and/or other materials provided with the distribution.
 12 *
 13 * THIS SOFTWARE IS PROVIDED BY CANON INC. ``AS IS'' AND ANY
 14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL CANON INC. OR
 17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
 18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
 19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
 20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
 21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 24 */
 25
 26#include "config.h"
 27#include "JSDOMMapLike.h"
 28
 29#include "WebCoreJSClientData.h"
 30
 31namespace WebCore {
 32
 33static inline JSC::JSObject& getBackingMap(JSC::ExecState& state, JSC::JSObject& mapLike)
 34{
 35 auto& vm = state.vm();
 36 auto backingMap = mapLike.get(&state, static_cast<JSVMClientData*>(vm.clientData)->builtinNames().backingMapPrivateName());
 37 return *JSC::asObject(backingMap);
 38}
 39
 40void initializeBackingMap(JSC::VM& vm, JSC::JSObject& mapLike, JSC::JSMap& backingMap)
 41{
 42 mapLike.putDirect(vm, static_cast<JSVMClientData*>(vm.clientData)->builtinNames().backingMapPrivateName(), &backingMap, JSC::DontEnum);
 43}
 44
 45JSC::JSMap& createBackingMap(JSC::ExecState& state, JSC::JSGlobalObject& globalObject, JSC::JSObject& mapLike)
 46{
 47 auto& vm = state.vm();
 48
 49 ASSERT(mapLike.get(&state, static_cast<JSVMClientData*>(vm.clientData)->builtinNames().backingMapPrivateName()).isUndefined());
 50 auto backingMap = JSC::JSMap::create(&state, vm, globalObject.mapStructure());
 51 mapLike.putDirect(vm, static_cast<JSVMClientData*>(vm.clientData)->builtinNames().backingMapPrivateName(), backingMap, JSC::DontEnum);
 52 return *backingMap;
 53}
 54
 55JSC::JSValue forwardAttributeGetterToBackingMap(JSC::ExecState& state, JSC::JSObject& mapLike, const JSC::Identifier& attributeName)
 56{
 57 return getBackingMap(state, mapLike).get(&state, attributeName);
 58}
 59
 60JSC::JSValue forwardFunctionCallToBackingMap(JSC::ExecState& state, JSC::JSObject& mapLike, const JSC::Identifier& functionName)
 61{
 62 auto& backingMap = getBackingMap(state, mapLike);
 63
 64 JSC::JSValue function = backingMap.get(&state, functionName);
 65 ASSERT(function);
 66
 67 JSC::CallData callData;
 68 JSC::CallType callType = JSC::getCallData(function, callData);
 69 ASSERT(callType != JSC::CallType::None);
 70 JSC::MarkedArgumentBuffer arguments;
 71 for (size_t cptr = 0; cptr < state.argumentCount(); ++cptr)
 72 arguments.append(state.uncheckedArgument(cptr));
 73 return JSC::call(&state, function, callType, callData, &backingMap, arguments);
 74}
 75
 76JSC::JSValue forwardForEachCallToBackingMap(JSC::ExecState& state, JSDOMGlobalObject& globalObject, JSC::JSObject& mapLike)
 77{
 78 auto* function = globalObject.builtinInternalFunctions().jsDOMBindingInternals().m_mapLikeForEachFunction.get();
 79 ASSERT(function);
 80
 81 getBackingMap(state, mapLike);
 82
 83
 84 JSC::CallData callData;
 85 JSC::CallType callType = JSC::getCallData(function, callData);
 86 ASSERT(callType != JSC::CallType::None);
 87 JSC::MarkedArgumentBuffer arguments;
 88 for (size_t cptr = 0; cptr < state.argumentCount(); ++cptr)
 89 arguments.append(state.uncheckedArgument(cptr));
 90 return JSC::call(&state, function, callType, callData, &mapLike, arguments);
 91}
 92
 93}

Source/WebCore/bindings/js/JSDOMMapLike.h

 1/*
 2 * Copyright (C) 2017 Apple 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 * 1. Redistributions of source code must retain the above copyright
 8 * notice, this list of conditions and the following disclaimer.
 9 * 2. Redistributions in binary form must reproduce the above copyright
 10 * notice, this list of conditions and the following disclaimer in the
 11 * documentation and/or other materials provided with the distribution.
 12 *
 13 * THIS SOFTWARE IS PROVIDED BY CANON INC. ``AS IS'' AND ANY
 14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL CANON INC. OR
 17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
 18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
 19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
 20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
 21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 24 */
 25
 26#pragma once
 27
 28#include "ActiveDOMCallback.h"
 29#include "JSDOMBinding.h"
 30#include "JSDOMConvert.h"
 31#include "JSDOMGuardedObject.h"
 32#include "ScriptExecutionContext.h"
 33#include <builtins/BuiltinNames.h>
 34#include <runtime/CommonIdentifiers.h>
 35#include <runtime/JSMap.h>
 36
 37namespace WebCore {
 38
 39JSC::JSMap& createBackingMap(JSC::ExecState&, JSC::JSGlobalObject&, JSC::JSObject&);
 40void initializeBackingMap(JSC::VM&, JSC::JSObject&, JSC::JSMap&);
 41JSC::JSValue forwardAttributeGetterToBackingMap(JSC::ExecState&, JSC::JSObject&, const JSC::Identifier&);
 42JSC::JSValue forwardFunctionCallToBackingMap(JSC::ExecState&, JSC::JSObject&, const JSC::Identifier&);
 43JSC::JSValue forwardForEachCallToBackingMap(JSC::ExecState&, JSDOMGlobalObject&, JSC::JSObject&);
 44
 45template<typename WrapperClass> void synchronizeBackingMap(JSC::ExecState&, JSDOMGlobalObject&, WrapperClass&);
 46template<typename WrapperClass> JSC::JSValue forwardSizeToMapLike(JSC::ExecState&, WrapperClass&);
 47template<typename WrapperClass> JSC::JSValue forwardEntriesToMapLike(JSC::ExecState&, WrapperClass&);
 48template<typename WrapperClass> JSC::JSValue forwardKeysToMapLike(JSC::ExecState&, WrapperClass&);
 49template<typename WrapperClass> JSC::JSValue forwardValuesToMapLike(JSC::ExecState&, WrapperClass&);
 50template<typename WrapperClass> JSC::JSValue forwardClearToMapLike(JSC::ExecState&, WrapperClass&);
 51template<typename WrapperClass, typename Callback> JSC::JSValue forwardForEachToMapLike(JSC::ExecState&, WrapperClass&, Callback&&);
 52template<typename WrapperClass, typename ItemType> JSC::JSValue forwardGetToMapLike(JSC::ExecState&, WrapperClass&, ItemType&&);
 53template<typename WrapperClass, typename ItemType> JSC::JSValue forwardHasToMapLike(JSC::ExecState&, WrapperClass&, ItemType&&);
 54template<typename WrapperClass, typename ItemType> JSC::JSValue forwardAddToMapLike(JSC::ExecState&, WrapperClass&, ItemType&&);
 55template<typename WrapperClass, typename ItemType> JSC::JSValue forwardDeleteToMapLike(JSC::ExecState&, WrapperClass&, ItemType&&);
 56
 57class DOMMapLike final : public DOMGuarded<JSC::JSMap> {
 58public:
 59 static Ref<DOMMapLike> create(JSDOMGlobalObject& globalObject, JSC::JSMap& map) { return adoptRef(*new DOMMapLike(globalObject, map)); }
 60
 61 template<typename Key, typename Value> void set(typename Key::ParameterType&&, typename Value::ParameterType&&);
 62
 63 JSC::JSMap* backingMap() { return guarded(); }
 64
 65protected:
 66 DOMMapLike(JSDOMGlobalObject& globalObject, JSC::JSMap& map) : DOMGuarded<JSC::JSMap>(globalObject, map) { }
 67};
 68
 69template<typename Key, typename Value> inline void DOMMapLike::set(typename Key::ParameterType&& key, typename Value::ParameterType&& value)
 70{
 71 if (isEmpty())
 72 return;
 73 auto* state = globalObject()->globalExec();
 74 JSC::JSLockHolder locker(state);
 75 backingMap()->set(state,
 76 toJS<Key>(*state, *globalObject(), std::forward<typename Key::ParameterType>(key)),
 77 toJS<Value>(*state, *globalObject(), std::forward<typename Value::ParameterType>(value)));
 78}
 79
 80template<typename WrapperClass> inline void synchronizeBackingMap(JSC::ExecState& state, JSDOMGlobalObject& globalObject, WrapperClass& mapLike)
 81{
 82 auto backingMap = mapLike.wrapped().backingMap();
 83 if (backingMap) {
 84 ASSERT(backingMap->backingMap());
 85 initializeBackingMap(state.vm(), mapLike, *backingMap->backingMap());
 86 return;
 87 }
 88 auto& map = createBackingMap(state, globalObject, mapLike);
 89 mapLike.wrapped().synchronizeBackingMap(DOMMapLike::create(globalObject, map));
 90}
 91
 92template<typename WrapperClass> inline JSC::JSValue forwardSizeToMapLike(JSC::ExecState& state, WrapperClass& mapLike)
 93{
 94 return forwardAttributeGetterToBackingMap(state, mapLike, state.propertyNames().size);
 95}
 96
 97template<typename WrapperClass> inline JSC::JSValue forwardEntriesToMapLike(JSC::ExecState& state, WrapperClass& mapLike)
 98{
 99 return forwardFunctionCallToBackingMap(state, mapLike, state.propertyNames().builtinNames().entriesPublicName());
 100}
 101
 102template<typename WrapperClass> inline JSC::JSValue forwardKeysToMapLike(JSC::ExecState& state, WrapperClass& mapLike)
 103{
 104 return forwardFunctionCallToBackingMap(state, mapLike, state.propertyNames().builtinNames().keysPublicName());
 105}
 106
 107template<typename WrapperClass> inline JSC::JSValue forwardValuesToMapLike(JSC::ExecState& state, WrapperClass& mapLike)
 108{
 109 return forwardFunctionCallToBackingMap(state, mapLike, state.propertyNames().builtinNames().valuesPublicName());
 110}
 111
 112template<typename WrapperClass> inline JSC::JSValue forwardClearToMapLike(JSC::ExecState& state, WrapperClass& mapLike)
 113{
 114 mapLike.wrapped().clear();
 115 return forwardFunctionCallToBackingMap(state, mapLike, state.vm().propertyNames->clear);
 116}
 117
 118template<typename WrapperClass, typename Callback> inline JSC::JSValue forwardForEachToMapLike(JSC::ExecState& state, WrapperClass& mapLike, Callback&&)
 119{
 120 return forwardForEachCallToBackingMap(state, *mapLike.globalObject(), mapLike);
 121}
 122
 123template<typename WrapperClass, typename ItemType> inline JSC::JSValue forwardGetToMapLike(JSC::ExecState& state, WrapperClass& mapLike, ItemType&&)
 124{
 125 return forwardFunctionCallToBackingMap(state, mapLike, state.propertyNames().builtinNames().getPublicName());
 126}
 127
 128template<typename WrapperClass, typename ItemType> inline JSC::JSValue forwardHasToMapLike(JSC::ExecState& state, WrapperClass& mapLike, ItemType&&)
 129{
 130 return forwardFunctionCallToBackingMap(state, mapLike, state.propertyNames().builtinNames().hasPublicName());
 131}
 132
 133template<typename WrapperClass, typename ItemType> inline JSC::JSValue forwardAddToMapLike(JSC::ExecState& state, WrapperClass& mapLike, ItemType&& item)
 134{
 135 if (mapLike.wrapped().addFromMapLike(std::forward<ItemType>(item)))
 136 forwardFunctionCallToBackingMap(state, mapLike, state.vm().propertyNames->add);
 137 return &mapLike;
 138}
 139
 140template<typename WrapperClass, typename ItemType> inline JSC::JSValue forwardDeleteToMapLike(JSC::ExecState& state, WrapperClass& mapLike, ItemType&& item)
 141{
 142 auto isDeleted = mapLike.wrapped().remove(std::forward<ItemType>(item));
 143 UNUSED_PARAM(isDeleted);
 144 auto result = forwardFunctionCallToBackingMap(state, mapLike, state.vm().propertyNames->deleteKeyword);
 145 ASSERT_UNUSED(result, result.asBoolean() == isDeleted);
 146 return result;
 147}
 148
 149}

Source/WebCore/bindings/js/JSDOMPromise.cpp

@@using namespace JSC;
3838
3939namespace WebCore {
4040
41 DeferredPromise::DeferredPromise(JSDOMGlobalObject& globalObject, JSPromiseDeferred& promiseDeferred)
42  : ActiveDOMCallback(globalObject.scriptExecutionContext())
43  , m_deferred(&promiseDeferred)
44  , m_globalObject(&globalObject)
45 {
46  auto locker = lockDuringMarking(globalObject.vm().heap, globalObject.gcLock());
47  globalObject.vm().heap.writeBarrier(&globalObject, &promiseDeferred);
48  globalObject.deferredPromises(locker).add(this);
49 }
50 
51 DeferredPromise::~DeferredPromise()
52 {
53  clear();
54 }
55 
56 void DeferredPromise::clear()
57 {
58  ASSERT(!m_deferred || m_globalObject);
59  if (m_deferred && m_globalObject) {
60  auto locker = lockDuringMarking(m_globalObject->vm().heap, m_globalObject->gcLock());
61  m_globalObject->deferredPromises(locker).remove(this);
62  }
63  m_deferred.clear();
64 }
65 
66 void DeferredPromise::contextDestroyed()
67 {
68  ActiveDOMCallback::contextDestroyed();
69  clear();
70 }
71 
7241JSC::JSValue DeferredPromise::promise() const
7342{
74  ASSERT(m_deferred);
75  return m_deferred->promise();
 43 ASSERT(deferred());
 44 return deferred()->promise();
7645}
7746
7847void DeferredPromise::callFunction(ExecState& exec, JSValue function, JSValue resolution)

@@void DeferredPromise::reject()
9766 if (isSuspended())
9867 return;
9968
100  ASSERT(m_deferred);
 69 ASSERT(deferred());
10170 ASSERT(m_globalObject);
10271 auto& state = *m_globalObject->globalExec();
10372 JSC::JSLockHolder locker(&state);

@@void DeferredPromise::reject(std::nullptr_t)
10978 if (isSuspended())
11079 return;
11180
112  ASSERT(m_deferred);
 81 ASSERT(deferred());
11382 ASSERT(m_globalObject);
11483 auto& state = *m_globalObject->globalExec();
11584 JSC::JSLockHolder locker(&state);

@@void DeferredPromise::reject(Exception&& exception)
12190 if (isSuspended())
12291 return;
12392
124  ASSERT(m_deferred);
 93 ASSERT(deferred());
12594 ASSERT(m_globalObject);
12695 auto& state = *m_globalObject->globalExec();
12796 JSC::JSLockHolder locker(&state);

@@void DeferredPromise::reject(ExceptionCode ec, const String& message)
133102 if (isSuspended())
134103 return;
135104
136  ASSERT(m_deferred);
 105 ASSERT(deferred());
137106 ASSERT(m_globalObject);
138107 JSC::ExecState* state = m_globalObject->globalExec();
139108 JSC::JSLockHolder locker(state);

@@void DeferredPromise::reject(const JSC::PrivateName& privateName)
145114 if (isSuspended())
146115 return;
147116
148  ASSERT(m_deferred);
 117 ASSERT(deferred());
149118 ASSERT(m_globalObject);
150119 JSC::ExecState* state = m_globalObject->globalExec();
151120 JSC::JSLockHolder locker(state);

Source/WebCore/bindings/js/JSDOMPromise.h

2525
2626#pragma once
2727
28 #include "ActiveDOMCallback.h"
2928#include "JSDOMConvert.h"
30 #include <heap/StrongInlines.h>
 29#include "JSDOMGuardedObject.h"
3130#include <runtime/JSPromiseDeferred.h>
3231
3332namespace WebCore {
3433
35 class DeferredPromise : public RefCounted<DeferredPromise>, public ActiveDOMCallback {
 34class DeferredPromise : public DOMGuarded<JSC::JSPromiseDeferred> {
3635public:
3736 static Ref<DeferredPromise> create(JSDOMGlobalObject& globalObject, JSC::JSPromiseDeferred& deferred)
3837 {
3938 return adoptRef(*new DeferredPromise(globalObject, deferred));
4039 }
4140
42  ~DeferredPromise();
43 
44  template<class IDLType>
 41 template<class IDLType>
4542 void resolve(typename IDLType::ParameterType value)
4643 {
4744 if (isSuspended())
4845 return;
49  ASSERT(m_deferred);
50  ASSERT(m_globalObject);
51  JSC::ExecState* exec = m_globalObject->globalExec();
 46 ASSERT(deferred());
 47 ASSERT(globalObject());
 48 JSC::ExecState* exec = globalObject()->globalExec();
5249 JSC::JSLockHolder locker(exec);
53  resolve(*exec, toJS<IDLType>(*exec, *m_globalObject.get(), std::forward<typename IDLType::ParameterType>(value)));
 50 resolve(*exec, toJS<IDLType>(*exec, *globalObject(), std::forward<typename IDLType::ParameterType>(value)));
5451 }
5552
5653 void resolve()
5754 {
5855 if (isSuspended())
5956 return;
60  ASSERT(m_deferred);
61  ASSERT(m_globalObject);
62  JSC::ExecState* exec = m_globalObject->globalExec();
 57 ASSERT(deferred());
 58 ASSERT(globalObject());
 59 JSC::ExecState* exec = globalObject()->globalExec();
6360 JSC::JSLockHolder locker(exec);
6461 resolve(*exec, JSC::jsUndefined());
6562 }

@@public:
6966 {
7067 if (isSuspended())
7168 return;
72  ASSERT(m_deferred);
73  ASSERT(m_globalObject);
74  JSC::ExecState* exec = m_globalObject->globalExec();
 69 ASSERT(deferred());
 70 ASSERT(globalObject());
 71 JSC::ExecState* exec = globalObject()->globalExec();
7572 JSC::JSLockHolder locker(exec);
76  resolve(*exec, toJSNewlyCreated<IDLType>(*exec, *m_globalObject.get(), std::forward<typename IDLType::ParameterType>(value)));
 73 resolve(*exec, toJSNewlyCreated<IDLType>(*exec, *globalObject(), std::forward<typename IDLType::ParameterType>(value)));
7774 }
7875
79  template<class IDLType>
 76 template<class IDLType>
8077 void reject(typename IDLType::ParameterType value)
8178 {
8279 if (isSuspended())
8380 return;
84  ASSERT(m_deferred);
85  ASSERT(m_globalObject);
86  JSC::ExecState* exec = m_globalObject->globalExec();
 81 ASSERT(deferred());
 82 ASSERT(globalObject());
 83 JSC::ExecState* exec = globalObject()->globalExec();
8784 JSC::JSLockHolder locker(exec);
88  reject(*exec, toJS<IDLType>(*exec, *m_globalObject.get(), std::forward<typename IDLType::ParameterType>(value)));
 85 reject(*exec, toJS<IDLType>(*exec, *globalObject(), std::forward<typename IDLType::ParameterType>(value)));
8986 }
9087
9188 void reject();

@@public:
9996 {
10097 if (isSuspended())
10198 return;
102  ASSERT(m_deferred);
103  ASSERT(m_globalObject);
104  JSC::ExecState* exec = m_globalObject->globalExec();
 99 ASSERT(deferred());
 100 ASSERT(globalObject());
 101 JSC::ExecState* exec = globalObject()->globalExec();
105102 JSC::JSLockHolder locker(exec);
106  resolve(*exec, callback(*exec, *m_globalObject.get()));
 103 resolve(*exec, callback(*exec, *globalObject()));
107104 }
108105
109106 template<typename Callback>

@@public:
111108 {
112109 if (isSuspended())
113110 return;
114  ASSERT(m_deferred);
115  ASSERT(m_globalObject);
116  JSC::ExecState* exec = m_globalObject->globalExec();
 111 ASSERT(deferred());
 112 ASSERT(globalObject());
 113 JSC::ExecState* exec = globalObject()->globalExec();
117114 JSC::JSLockHolder locker(exec);
118  reject(*exec, callback(*exec, *m_globalObject.get()));
 115 reject(*exec, callback(*exec, *globalObject()));
119116 }
120117
121118 JSC::JSValue promise() const;
122119
123  bool isSuspended() { return !m_deferred || !canInvokeCallback(); } // The wrapper world has gone away or active DOM objects have been suspended.
124  JSDOMGlobalObject* globalObject() { return m_globalObject.get(); }
125 
126  void visitAggregate(JSC::SlotVisitor& visitor) { visitor.append(m_deferred); }
127 
128120private:
129  DeferredPromise(JSDOMGlobalObject&, JSC::JSPromiseDeferred&);
 121 DeferredPromise(JSDOMGlobalObject& globalObject, JSC::JSPromiseDeferred& deferred) : DOMGuarded<JSC::JSPromiseDeferred>(globalObject, deferred) { }
130122
131  void clear();
132  void contextDestroyed() override;
 123 JSC::JSPromiseDeferred* deferred() const { return guarded(); }
133124
134125 void callFunction(JSC::ExecState&, JSC::JSValue function, JSC::JSValue resolution);
135  void resolve(JSC::ExecState& state, JSC::JSValue resolution) { callFunction(state, m_deferred->resolve(), resolution); }
136  void reject(JSC::ExecState& state, JSC::JSValue resolution) { callFunction(state, m_deferred->reject(), resolution); }
137 
138  JSC::Weak<JSC::JSPromiseDeferred> m_deferred;
139  JSC::Weak<JSDOMGlobalObject> m_globalObject;
 126 void resolve(JSC::ExecState& state, JSC::JSValue resolution) { callFunction(state, deferred()->resolve(), resolution); }
 127 void reject(JSC::ExecState& state, JSC::JSValue resolution) { callFunction(state, deferred()->reject(), resolution); }
140128};
141129
142130class DOMPromiseBase {

Source/WebCore/bindings/js/WebCoreBuiltinNames.h

@@namespace WebCore {
3434 macro(addTrack) \
3535 macro(appendFromJS) \
3636 macro(autoAllocateChunkSize) \
 37 macro(backingMap) \
3738 macro(body) \
3839 macro(cancel) \
3940 macro(cloneForJS) \

Source/WebCore/bindings/scripts/CodeGeneratorJS.pm

@@sub PrototypeFunctionCount
10641064 }
10651065
10661066 $count += scalar @{$interface->iterable->functions} if $interface->iterable;
 1067 $count += scalar @{$interface->mapLike->functions} if $interface->mapLike;
10671068 $count += scalar @{$interface->serializable->functions} if $interface->serializable;
10681069
10691070 return $count;

@@sub GeneratePropertiesHashTable
22812282
22822283 return 0 if !$propertyCount;
22832284
2284  foreach my $attribute (@{$interface->attributes}) {
 2285 my @attributes = @{$interface->attributes};
 2286 push(@attributes, @{$interface->mapLike->attributes}) if $interface->mapLike;
 2287
 2288 foreach my $attribute (@attributes) {
22852289 next if ($attribute->isStatic);
22862290 next if AttributeShouldBeOnInstance($interface, $attribute) != $isInstance;
22872291

@@sub GeneratePropertiesHashTable
23222326
23232327 my @functions = @{$interface->functions};
23242328 push(@functions, @{$interface->iterable->functions}) if IsKeyValueIterableInterface($interface);
 2329 push(@functions, @{$interface->mapLike->functions}) if $interface->mapLike;
23252330 push(@functions, @{$interface->serializable->functions}) if $interface->serializable;
23262331 foreach my $function (@functions) {
23272332 next if ($function->extendedAttributes->{PrivateIdentifier} and not $function->extendedAttributes->{PublicIdentifier});

@@sub GetAttributeWithName
29882993sub InterfaceNeedsIterator
29892994{
29902995 my ($interface) = @_;
2991 
 2996
 2997 # FIXME: This should return 1 for maplike once we support them.
 2998 return 1 if $interface->mapLike;
 2999
29923000 return 1 if $interface->iterable;
29933001 if (GetIndexedGetterFunction($interface)) {
29943002 my $lengthAttribute = GetAttributeWithName($interface, "length");
29953003 return 1 if $lengthAttribute and $codeGenerator->IsIntegerType($lengthAttribute->type);
29963004 }
2997  # FIXME: This should return 1 for maplike and setlike once we support them.
29983005 return 0;
29993006}
30003007

@@sub GenerateImplementation
30403047
30413048 my @functions = @{$interface->functions};
30423049 push(@functions, @{$interface->iterable->functions}) if IsKeyValueIterableInterface($interface);
 3050 push(@functions, @{$interface->mapLike->functions}) if $interface->mapLike;
30433051 push(@functions, @{$interface->serializable->functions}) if $interface->serializable;
30443052
 3053 my @attributes = @{$interface->attributes};
 3054 push(@attributes, @{$interface->mapLike->attributes}) if $interface->mapLike;
 3055
30453056 my $numConstants = @{$interface->constants};
30463057 my $numFunctions = @functions;
3047  my $numAttributes = @{$interface->attributes};
 3058 my $numAttributes = @attributes;
30483059
30493060 if ($numFunctions > 0) {
30503061 my $inAppleCopyright = 0;

@@sub GenerateImplementation
30903101 if ($numAttributes > 0 || NeedsConstructorProperty($interface)) {
30913102 push(@implContent, "// Attributes\n\n");
30923103
3093  foreach my $attribute (@{$interface->attributes}) {
 3104 foreach my $attribute (@attributes) {
30943105 next if $attribute->extendedAttributes->{ForwardDeclareInHeader};
30953106 next if IsJSBuiltin($interface, $attribute);
30963107

@@sub GenerateImplementation
31043115 }
31053116 push(@implContent, "#endif\n") if $conditionalString;
31063117 }
3107 
 3118
31083119 if (NeedsConstructorProperty($interface)) {
31093120 my $getter = "js" . $interfaceName . "Constructor";
31103121 push(@implContent, "JSC::EncodedJSValue ${getter}(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);\n");

@@sub GenerateImplementation
33583369 if (IsKeyValueIterableInterface($interface)) {
33593370 my $functionName = GetFunctionName($interface, $className, @{$interface->iterable->functions}[0]);
33603371 push(@implContent, " putDirect(vm, vm.propertyNames->iteratorSymbol, JSFunction::create(vm, globalObject(), 0, ASCIILiteral(\"[Symbol.Iterator]\"), $functionName), DontEnum);\n");
 3372 } elsif ($interface->mapLike) {
 3373 push(@implContent, " putDirect(vm, vm.propertyNames->iteratorSymbol, getDirect(vm, vm.propertyNames->builtinNames().valuesPublicName()), DontEnum);\n");
33613374 } else {
33623375 AddToImplIncludes("<builtins/BuiltinNames.h>");
33633376 push(@implContent, " putDirect(vm, vm.propertyNames->iteratorSymbol, globalObject()->arrayPrototype()->getDirect(vm, vm.propertyNames->builtinNames().valuesPrivateName()), DontEnum);\n");

@@sub GenerateImplementation
34333446 push(@implContent, " putDirect(vm, vm.propertyNames->valueOf, globalObject()->objectProtoValueOfFunction(), DontDelete | ReadOnly | DontEnum);\n");
34343447 push(@implContent, " putDirect(vm, vm.propertyNames->toPrimitiveSymbol, jsUndefined(), DontDelete | ReadOnly | DontEnum);\n");
34353448 }
 3449 push(@implContent, " synchronizeBackingMap(*globalObject()->globalExec(), *globalObject(), *this);\n") if $interface->mapLike;
34363450
34373451 # Support for RuntimeEnabled attributes on instances.
34383452 foreach my $attribute (@{$interface->attributes}) {

@@sub GenerateImplementation
35863600
35873601 $numAttributes = $numAttributes + 1 if NeedsConstructorProperty($interface);
35883602 if ($numAttributes > 0) {
3589  foreach my $attribute (@{$interface->attributes}) {
 3603 foreach my $attribute (@attributes) {
35903604 next if IsJSBuiltin($interface, $attribute);
35913605
35923606 my $name = $attribute->name;

@@sub GenerateImplementation
36953709 unshift(@arguments, "impl") if !$attribute->isStatic;
36963710 } elsif ($attribute->isStatic) {
36973711 $functionName = "${interfaceName}::${functionName}";
 3712 } elsif ($attribute->isMapLike) {
 3713 my $ucPropertyName = $codeGenerator->WK_ucfirst($functionName);
 3714 $functionName = "forward" . $codeGenerator->WK_ucfirst($functionName) . "ToMapLike";
 3715 push(@arguments, "state");
 3716 push(@arguments, "thisObject");
36983717 } else {
36993718 $functionName = "impl.${functionName}";
37003719 }
37013720
37023721 unshift(@arguments, @callWithArgs);
37033722 my $jsType = NativeToJSValueUsingReferences($attribute, $interface, "${functionName}(" . join(", ", @arguments) . ")", "thisObject");
3704  push(@implContent, " auto& impl = thisObject.wrapped();\n") if !$attribute->isStatic;
 3723 push(@implContent, " auto& impl = thisObject.wrapped();\n") unless $attribute->isStatic or $attribute->isMapLike;
37053724 push(@implContent, " JSValue result = $jsType;\n");
37063725
37073726 push(@implContent, " thisObject.m_" . $attribute->name . ".set(state.vm(), &thisObject, result);\n") if $attribute->extendedAttributes->{CachedAttribute};

@@sub GenerateImplementation
37763795 push(@implContent, "}\n\n");
37773796 }
37783797
3779  foreach my $attribute (@{$interface->attributes}) {
 3798 foreach my $attribute (@attributes) {
37803799 if (!IsReadonly($attribute)) {
37813800 next if IsJSBuiltin($interface, $attribute);
37823801

@@sub GenerateImplementation
39513970 # Functions
39523971 if ($numFunctions > 0) {
39533972 my $inAppleCopyright = 0;
3954  foreach my $function (@{$interface->functions}) {
 3973 foreach my $function (@functions) {
39553974 next if IsJSBuiltin($interface, $function);
 3975 next if $function->isIterable;
 3976 next if $function->isSerializer;
39563977 if ($function->extendedAttributes->{AppleCopyright}) {
39573978 if (!$inAppleCopyright) {
39583979 push(@implContent, $beginAppleCopyrightForSourceFiles);

@@END
40804101 if ($isCustom) {
40814102 push(@implContent, " return JSValue::encode(castedThis->" . $functionImplementationName . "(*state));\n");
40824103 } else {
4083  push(@implContent, " auto& impl = castedThis->wrapped();\n");
 4104 push(@implContent, " auto& impl = castedThis->wrapped();\n") unless $function->isMapLike;
40844105
40854106 GenerateArgumentsCountCheck(\@implContent, $function, $interface);
40864107

@@END
41704191
41714192 GenerateImplementationIterableFunctions($interface) if $interface->iterable;
41724193 GenerateSerializerFunction($interface, $className) if $interface->serializable;
 4194 AddToImplIncludes("JSDOMMapLike.h") if $interface->mapLike;
41734195
41744196 if ($needsVisitChildren) {
41754197 push(@implContent, "void ${className}::visitChildren(JSCell* cell, SlotVisitor& visitor)\n");

@@sub GenerateParametersCheck
46404662
46414663 if ($implementedBy) {
46424664 AddToImplIncludes("${implementedBy}.h", $conditional);
4643  unshift(@arguments, "impl") if !$function->isStatic;
 4665 unshift(@arguments, "impl") unless $function->isStatic;
46444666 $functionName = "WebCore::${implementedBy}::${functionImplementationName}";
46454667 } elsif ($function->isStatic) {
46464668 $functionName = "${interfaceName}::${functionImplementationName}";
 4669 } elsif ($function->isMapLike) {
 4670 $functionName = "forward" . $codeGenerator->WK_ucfirst($function->name) ."ToMapLike";
 4671 push(@arguments, "*state");
 4672 push(@arguments, "*castedThis");
46474673 } else {
46484674 $functionName = "impl.${functionImplementationName}";
46494675 }

Source/WebCore/bindings/scripts/IDLParser.pm

@@struct( IDLInterface => {
6060 constants => '@', # List of 'IDLConstant'
6161 functions => '@', # List of 'IDLOperation'
6262 anonymousFunctions => '@', # List of 'IDLOperation'
63  attributes => '@', # List of 'IDLAttribute'
 63 attributes => '@', # List of 'IDLAttribute'
6464 constructors => '@', # Constructors, list of 'IDLOperation'
6565 customConstructors => '@', # Custom constructors, list of 'IDLOperation'
6666 isException => '$', # Used for exception interfaces
6767 isCallback => '$', # Used for callback interfaces
6868 isPartial => '$', # Used for partial interfaces
6969 iterable => '$', # Used for iterable interfaces
 70 mapLike => '$', # Used for mapLike interfaces
7071 serializable => '$', # Used for serializable interfaces
7172 extendedAttributes => '$',
7273});

@@struct( IDLOperation => {
8788 type => 'IDLType', # Return type
8889 arguments => '@', # List of 'IDLArgument'
8990 isStatic => '$',
 91 isIterable => '$',
 92 isSerializer => '$',
 93 isMapLike => '$',
9094 specials => '@',
9195 extendedAttributes => '$',
9296});

@@struct( IDLAttribute => {
97101 name => '$',
98102 type => 'IDLType',
99103 isStatic => '$',
 104 isMapLike => '$',
100105 isStringifier => '$',
101106 isReadOnly => '$',
102107 extendedAttributes => '$',

@@struct( IDLIterable => {
111116 extendedAttributes => '$',
112117});
113118
 119# https://heycam.github.io/webidl/#es-maplike
 120struct( IDLMapLike => {
 121 isReadOnly => '$',
 122 keyType => 'IDLType',
 123 valueType => 'IDLType',
 124 attributes => '@', # MapLike attributes (size)
 125 functions => '@', # MapLike functions (entries, keys, values, forEach, get, has and if not readonly, delete, set and clear)
 126 extendedAttributes => '$',
 127});
 128
114129# https://heycam.github.io/webidl/#idl-serializers
115130struct( IDLSerializable => {
116131 attributes => '@', # List of attributes to serialize

@@sub new {
194209sub assert
195210{
196211 my $message = shift;
197 
 212
198213 my $mess = longmess();
199214 print Dumper($mess);
200215

@@sub cloneType
420435 return $clonedType;
421436}
422437
423 my $nextAttribute_1 = '^(attribute|inherit|readonly)$';
 438my $nextAttribute_1 = '^(attribute|inherit)$';
424439my $nextPrimitiveType_1 = '^(int|long|short|unsigned)$';
425440my $nextPrimitiveType_2 = '^(double|float|unrestricted)$';
426441my $nextArgumentList_1 = '^(\(|ByteString|DOMString|USVString|Date|\[|any|boolean|byte|double|float|in|long|object|octet|optional|sequence|short|unrestricted|unsigned)$';

@@my $nextType_1 = '^(ByteString|DOMString|USVString|Date|any|boolean|byte|double|
436451my $nextSpecials_1 = '^(creator|deleter|getter|legacycaller|setter)$';
437452my $nextDefinitions_1 = '^(callback|dictionary|enum|exception|interface|partial|typedef)$';
438453my $nextExceptionMembers_1 = '^(\(|ByteString|DOMString|USVString|Date|\[|any|boolean|byte|const|double|float|long|object|octet|optional|sequence|short|unrestricted|unsigned)$';
439 my $nextAttributeRest_1 = '^(attribute|readonly)$';
440454my $nextInterfaceMembers_1 = '^(\(|ByteString|DOMString|USVString|Date|any|attribute|boolean|byte|const|creator|deleter|double|float|getter|inherit|legacycaller|long|object|octet|readonly|sequence|serializer|setter|short|static|stringifier|unrestricted|unsigned|void)$';
441455my $nextSingleType_1 = '^(ByteString|DOMString|USVString|Date|boolean|byte|double|float|long|object|octet|sequence|short|unrestricted|unsigned)$';
442456my $nextArgumentName_1 = '^(attribute|callback|const|creator|deleter|dictionary|enum|exception|getter|implements|inherit|interface|legacycaller|partial|serializer|setter|static|stringifier|typedef|unrestricted)$';

@@sub parseAttributeOrOperationOrIterator
11401154 if ($next->value() eq "serializer") {
11411155 return $self->parseSerializer($extendedAttributeList);
11421156 }
 1157
11431158 if ($next->value() =~ /$nextAttributeOrOperation_1/) {
11441159 my $qualifier = $self->parseQualifier();
1145  my $newDataNode = $self->parseAttributeOrOperationRest($extendedAttributeList);
 1160 my $isReadOnly = $self->parseReadOnly();
 1161 my $newDataNode = $self->parseAttributeOrOperationRest($extendedAttributeList, $isReadOnly);
11461162 if (defined($newDataNode)) {
11471163 $newDataNode->isStatic(1) if $qualifier eq "static";
11481164 $newDataNode->isStringifier(1) if $qualifier eq "stringifier";
11491165 }
11501166 return $newDataNode;
11511167 }
 1168 my $isReadOnly = $self->parseReadOnly();
 1169 $next = $self->nextToken();
11521170 if ($next->value() =~ /$nextAttribute_1/) {
1153  return $self->parseAttribute($extendedAttributeList);
 1171 return $self->parseAttribute($extendedAttributeList, $isReadOnly);
11541172 }
11551173 if ($next->type() == IdentifierToken || $next->value() =~ /$nextAttributeOrOperation_2/) {
1156  return $self->parseOperationOrIterator($extendedAttributeList);
 1174 return $self->parseOperationOrIterator($extendedAttributeList, $isReadOnly);
11571175 }
11581176 $self->assertUnexpectedToken($next->value(), __LINE__);
11591177}

@@sub parseSerializer
11781196 my $toJSONFunction = IDLOperation->new();
11791197 $toJSONFunction->name("toJSON");
11801198 $toJSONFunction->extendedAttributes($extendedAttributeList);
 1199 $toJSONFunction->isSerializer(1);
11811200 push(@{$newDataNode->functions}, $toJSONFunction);
11821201
11831202 $self->assertTokenValue($self->getToken(), ";", __LINE__);

@@sub parseAttributeOrOperationRest
13151334{
13161335 my $self = shift;
13171336 my $extendedAttributeList = shift;
 1337 my $isReadOnly = shift;
13181338
13191339 my $next = $self->nextToken();
1320  if ($next->value() =~ /$nextAttributeRest_1/) {
1321  return $self->parseAttributeRest($extendedAttributeList);
 1340 if ($next->value() eq "attribute") {
 1341 return $self->parseAttributeRest($extendedAttributeList, $isReadOnly);
13221342 }
13231343 if ($next->value() eq ";") {
13241344 $self->assertTokenValue($self->getToken(), ";", __LINE__);

@@sub parseAttribute
13391359{
13401360 my $self = shift;
13411361 my $extendedAttributeList = shift;
 1362 my $isReadOnly = shift;
13421363
13431364 my $next = $self->nextToken();
13441365 if ($next->value() =~ /$nextAttribute_1/) {
13451366 $self->parseInherit();
1346  return $self->parseAttributeRest($extendedAttributeList);
 1367 return $self->parseAttributeRest($extendedAttributeList, $isReadOnly);
13471368 }
13481369 $self->assertUnexpectedToken($next->value(), __LINE__);
13491370}

@@sub parseAttributeRest
13521373{
13531374 my $self = shift;
13541375 my $extendedAttributeList = shift;
 1376 my $isReadOnly = shift;
13551377
13561378 my $next = $self->nextToken();
1357  if ($next->value() =~ /$nextAttributeRest_1/) {
 1379 if ($next->value() eq "attribute") {
13581380 my $newDataNode = IDLAttribute->new();
1359  $newDataNode->isReadOnly($self->parseReadOnly());
 1381 $newDataNode->isReadOnly($isReadOnly);
13601382
13611383 $self->assertTokenValue($self->getToken(), "attribute", __LINE__);
1362 
 1384
13631385 my $type = $self->parseType();
13641386 $newDataNode->type($type);
13651387

@@sub parseOperationOrIterator
14051427{
14061428 my $self = shift;
14071429 my $extendedAttributeList = shift;
 1430 my $isReadOnly = shift;
14081431
14091432 my $next = $self->nextToken();
14101433 if ($next->value() =~ /$nextSpecials_1/) {

@@sub parseOperationOrIterator
14131436 if ($next->value() eq "iterable") {
14141437 return $self->parseIterableRest($extendedAttributeList);
14151438 }
 1439 if ($next->value() eq "maplike") {
 1440 return $self->parseMapLikeRest($extendedAttributeList, $isReadOnly);
 1441 }
14161442 if ($next->type() == IdentifierToken || $next->value() =~ /$nextAttributeOrOperationRest_1/) {
14171443 my $returnType = $self->parseReturnType();
14181444 my $next = $self->nextToken();

@@sub parseOptionalIterableInterface
15081534 my $self = shift;
15091535 my $extendedAttributeList = shift;
15101536
 1537 my $newDataNode = IDLIterable->new();
 1538 $newDataNode->extendedAttributes($extendedAttributeList);
 1539
 1540 $self->assertTokenValue($self->getToken(), "<", __LINE__);
 1541 my $type1 = $self->parseType();
 1542
 1543 if ($self->nextToken()->value() eq ",") {
 1544 $self->assertTokenValue($self->getToken(), ",", __LINE__);
 1545
 1546 my $type2 = $self->parseType();
 1547 $newDataNode->isKeyValue(1);
 1548 $newDataNode->keyType($type1);
 1549 $newDataNode->valueType($type2);
 1550 } else {
 1551 $newDataNode->isKeyValue(0);
 1552 $newDataNode->valueType($type1);
 1553 }
 1554 $self->assertTokenValue($self->getToken(), ">", __LINE__);
 1555
15111556 my $symbolIteratorFunction = IDLOperation->new();
15121557 $symbolIteratorFunction->name("[Symbol.Iterator]");
15131558 $symbolIteratorFunction->extendedAttributes($extendedAttributeList);
 1559 $symbolIteratorFunction->isIterable(1);
15141560
15151561 my $entriesFunction = IDLOperation->new();
15161562 $entriesFunction->name("entries");
15171563 $entriesFunction->extendedAttributes($extendedAttributeList);
 1564 $entriesFunction->isIterable(1);
15181565
15191566 my $keysFunction = IDLOperation->new();
15201567 $keysFunction->name("keys");
15211568 $keysFunction->extendedAttributes($extendedAttributeList);
 1569 $keysFunction->isIterable(1);
15221570
15231571 my $valuesFunction = IDLOperation->new();
15241572 $valuesFunction->name("values");
15251573 $valuesFunction->extendedAttributes($extendedAttributeList);
 1574 $valuesFunction->isIterable(1);
15261575
15271576 my $forEachFunction = IDLOperation->new();
15281577 $forEachFunction->name("forEach");
15291578 $forEachFunction->extendedAttributes($extendedAttributeList);
 1579 $forEachFunction->isIterable(1);
15301580 my $forEachArgument = IDLArgument->new();
15311581 $forEachArgument->name("callback");
15321582 $forEachArgument->type(makeSimpleType("any"));
15331583 push(@{$forEachFunction->arguments}, ($forEachArgument));
15341584
1535  my $newDataNode = IDLIterable->new();
1536  $newDataNode->extendedAttributes($extendedAttributeList);
15371585 push(@{$newDataNode->functions}, $symbolIteratorFunction);
15381586 push(@{$newDataNode->functions}, $entriesFunction);
15391587 push(@{$newDataNode->functions}, $keysFunction);
15401588 push(@{$newDataNode->functions}, $valuesFunction);
15411589 push(@{$newDataNode->functions}, $forEachFunction);
15421590
1543  $self->assertTokenValue($self->getToken(), "<", __LINE__);
1544  my $type1 = $self->parseType();
 1591 return $newDataNode;
 1592}
15451593
1546  if ($self->nextToken()->value() eq ",") {
1547  $self->assertTokenValue($self->getToken(), ",", __LINE__);
 1594sub parseMapLikeRest
 1595{
 1596 my $self = shift;
 1597 my $extendedAttributeList = shift;
 1598 my $isReadOnly = shift;
15481599
1549  my $type2 = $self->parseType();
1550  $newDataNode->isKeyValue(1);
1551  $newDataNode->keyType($type1);
1552  $newDataNode->valueType($type2);
1553  } else {
1554  $newDataNode->isKeyValue(0);
1555  $newDataNode->valueType($type1);
 1600 my $next = $self->nextToken();
 1601 if ($next->value() eq "maplike") {
 1602 $self->assertTokenValue($self->getToken(), "maplike", __LINE__);
 1603 my $mapLikeNode = $self->parseMapLikeProperties($extendedAttributeList, $isReadOnly);
 1604 $self->assertTokenValue($self->getToken(), ";", __LINE__);
 1605 return $mapLikeNode;
15561606 }
 1607 $self->assertUnexpectedToken($next->value(), __LINE__);
 1608}
 1609
 1610sub parseMapLikeProperties
 1611{
 1612 my $self = shift;
 1613 my $extendedAttributeList = shift;
 1614 my $isReadOnly = shift;
 1615
 1616 my $newDataNode = IDLMapLike->new();
 1617 $newDataNode->extendedAttributes($extendedAttributeList);
 1618 $newDataNode->isReadOnly($isReadOnly);
 1619
 1620 $self->assertTokenValue($self->getToken(), "<", __LINE__);
 1621 $newDataNode->keyType($self->parseType());
 1622 $self->assertTokenValue($self->getToken(), ",", __LINE__);
 1623 $newDataNode->valueType($self->parseType());
15571624 $self->assertTokenValue($self->getToken(), ">", __LINE__);
15581625
 1626 my $notEnumerableExtendedAttributeList = $extendedAttributeList;
 1627 $notEnumerableExtendedAttributeList->{NotEnumerable} = 1;
 1628
 1629 my $sizeAttribute = IDLAttribute->new();
 1630 $sizeAttribute->name("size");
 1631 $sizeAttribute->isMapLike(1);
 1632 $sizeAttribute->extendedAttributes($extendedAttributeList);
 1633 $sizeAttribute->isReadOnly(1);
 1634 $sizeAttribute->type(makeSimpleType("any"));
 1635 push(@{$newDataNode->attributes}, $sizeAttribute);
 1636
 1637 my $getFunction = IDLOperation->new();
 1638 $getFunction->name("get");
 1639 $getFunction->isMapLike(1);
 1640 my $getArgument = IDLArgument->new();
 1641 $getArgument->name("key");
 1642 $getArgument->type($newDataNode->keyType);
 1643 $getArgument->extendedAttributes($extendedAttributeList);
 1644 push(@{$getFunction->arguments}, ($getArgument));
 1645 $getFunction->extendedAttributes($notEnumerableExtendedAttributeList);
 1646 $getFunction->type(makeSimpleType("any"));
 1647
 1648 my $hasFunction = IDLOperation->new();
 1649 $hasFunction->name("has");
 1650 $hasFunction->isMapLike(1);
 1651 my $hasArgument = IDLArgument->new();
 1652 $hasArgument->name("key");
 1653 $hasArgument->type($newDataNode->keyType);
 1654 $hasArgument->extendedAttributes($extendedAttributeList);
 1655 push(@{$hasFunction->arguments}, ($hasArgument));
 1656 $hasFunction->extendedAttributes($notEnumerableExtendedAttributeList);
 1657 $hasFunction->type(makeSimpleType("any"));
 1658
 1659 my $entriesFunction = IDLOperation->new();
 1660 $entriesFunction->name("entries");
 1661 $entriesFunction->isMapLike(1);
 1662 $entriesFunction->extendedAttributes($notEnumerableExtendedAttributeList);
 1663 $entriesFunction->type(makeSimpleType("any"));
 1664
 1665 my $keysFunction = IDLOperation->new();
 1666 $keysFunction->name("keys");
 1667 $keysFunction->isMapLike(1);
 1668 $keysFunction->extendedAttributes($notEnumerableExtendedAttributeList);
 1669 $keysFunction->type(makeSimpleType("any"));
 1670
 1671 my $valuesFunction = IDLOperation->new();
 1672 $valuesFunction->name("values");
 1673 $valuesFunction->isMapLike(1);
 1674 $valuesFunction->extendedAttributes($extendedAttributeList);
 1675 $valuesFunction->extendedAttributes->{NotEnumerable} = 1;
 1676 $valuesFunction->type(makeSimpleType("any"));
 1677
 1678 my $forEachFunction = IDLOperation->new();
 1679 $forEachFunction->name("forEach");
 1680 $forEachFunction->isMapLike(1);
 1681 $forEachFunction->extendedAttributes({});
 1682 $forEachFunction->type(makeSimpleType("any"));
 1683 my $forEachArgument = IDLArgument->new();
 1684 $forEachArgument->name("callback");
 1685 $forEachArgument->type(makeSimpleType("any"));
 1686 $forEachArgument->extendedAttributes($extendedAttributeList);
 1687 push(@{$forEachFunction->arguments}, ($forEachArgument));
 1688
 1689 push(@{$newDataNode->functions}, $getFunction);
 1690 push(@{$newDataNode->functions}, $hasFunction);
 1691 push(@{$newDataNode->functions}, $entriesFunction);
 1692 push(@{$newDataNode->functions}, $keysFunction);
 1693 push(@{$newDataNode->functions}, $valuesFunction);
 1694 push(@{$newDataNode->functions}, $forEachFunction);
 1695
 1696 return $newDataNode if $isReadOnly;
 1697
 1698 my $addFunction = IDLOperation->new();
 1699 $addFunction->name("add");
 1700 $addFunction->isMapLike(1);
 1701 my $addArgument = IDLArgument->new();
 1702 $addArgument->name("key");
 1703 $addArgument->type($newDataNode->keyType);
 1704 $addArgument->extendedAttributes($extendedAttributeList);
 1705 push(@{$addFunction->arguments}, ($addArgument));
 1706 $addFunction->extendedAttributes($notEnumerableExtendedAttributeList);
 1707 $addFunction->type(makeSimpleType("any"));
 1708
 1709 my $clearFunction = IDLOperation->new();
 1710 $clearFunction->name("clear");
 1711 $clearFunction->isMapLike(1);
 1712 $clearFunction->extendedAttributes($notEnumerableExtendedAttributeList);
 1713 $clearFunction->type(makeSimpleType("void"));
 1714
 1715 my $deleteFunction = IDLOperation->new();
 1716 $deleteFunction->name("delete");
 1717 $deleteFunction->isMapLike(1);
 1718 my $deleteArgument = IDLArgument->new();
 1719 $deleteArgument->name("key");
 1720 $deleteArgument->type($newDataNode->keyType);
 1721 $deleteArgument->extendedAttributes($extendedAttributeList);
 1722 push(@{$deleteFunction->arguments}, ($deleteArgument));
 1723 $deleteFunction->extendedAttributes($notEnumerableExtendedAttributeList);
 1724 $deleteFunction->type(makeSimpleType("any"));
 1725
 1726 push(@{$newDataNode->functions}, $addFunction);
 1727 push(@{$newDataNode->functions}, $clearFunction);
 1728 push(@{$newDataNode->functions}, $deleteFunction);
 1729
15591730 return $newDataNode;
15601731}
15611732

@@sub parseOperationRest
15701741
15711742 my $name = $self->parseOptionalIdentifier();
15721743 $newDataNode->name(identifierRemoveNullablePrefix($name));
1573 
 1744
15741745 $self->assertTokenValue($self->getToken(), "(", $name, __LINE__);
1575 
 1746
15761747 push(@{$newDataNode->arguments}, @{$self->parseArgumentList()});
1577 
 1748
15781749 $self->assertTokenValue($self->getToken(), ")", __LINE__);
15791750 $self->assertTokenValue($self->getToken(), ";", __LINE__);
1580 
 1751
15811752 $newDataNode->extendedAttributes($extendedAttributeList);
15821753 return $newDataNode;
15831754 }

@@sub applyMemberList
23932564 $interface->iterable($item);
23942565 next;
23952566 }
 2567 if (ref($item) eq "IDLMapLike") {
 2568 $interface->mapLike($item);
 2569 next;
 2570 }
23962571 if (ref($item) eq "IDLOperation") {
23972572 if ($item->name eq "") {
23982573 push(@{$interface->anonymousFunctions}, $item);

Source/WebCore/bindings/scripts/test/JS/JSMapLike.cpp

 1/*
 2 This file is part of the WebKit open source project.
 3 This file has been generated by generate-bindings.pl. DO NOT MODIFY!
 4
 5 This library is free software; you can redistribute it and/or
 6 modify it under the terms of the GNU Library General Public
 7 License as published by the Free Software Foundation; either
 8 version 2 of the License, or (at your option) any later version.
 9
 10 This library is distributed in the hope that it will be useful,
 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 13 Library General Public License for more details.
 14
 15 You should have received a copy of the GNU Library General Public License
 16 along with this library; see the file COPYING.LIB. If not, write to
 17 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
 18 Boston, MA 02110-1301, USA.
 19*/
 20
 21#include "config.h"
 22#include "JSMapLike.h"
 23
 24#include "JSDOMBinding.h"
 25#include "JSDOMBindingCaller.h"
 26#include "JSDOMConstructorNotConstructable.h"
 27#include "JSDOMConvert.h"
 28#include "JSDOMExceptionHandling.h"
 29#include "JSDOMMapLike.h"
 30#include "JSDOMWrapperCache.h"
 31#include <runtime/Error.h>
 32#include <runtime/FunctionPrototype.h>
 33#include <wtf/GetPtr.h>
 34
 35using namespace JSC;
 36
 37namespace WebCore {
 38
 39// Functions
 40
 41JSC::EncodedJSValue JSC_HOST_CALL jsMapLikePrototypeFunctionGet(JSC::ExecState*);
 42JSC::EncodedJSValue JSC_HOST_CALL jsMapLikePrototypeFunctionHas(JSC::ExecState*);
 43JSC::EncodedJSValue JSC_HOST_CALL jsMapLikePrototypeFunctionEntries(JSC::ExecState*);
 44JSC::EncodedJSValue JSC_HOST_CALL jsMapLikePrototypeFunctionKeys(JSC::ExecState*);
 45JSC::EncodedJSValue JSC_HOST_CALL jsMapLikePrototypeFunctionValues(JSC::ExecState*);
 46JSC::EncodedJSValue JSC_HOST_CALL jsMapLikePrototypeFunctionForEach(JSC::ExecState*);
 47JSC::EncodedJSValue JSC_HOST_CALL jsMapLikePrototypeFunctionAdd(JSC::ExecState*);
 48JSC::EncodedJSValue JSC_HOST_CALL jsMapLikePrototypeFunctionClear(JSC::ExecState*);
 49JSC::EncodedJSValue JSC_HOST_CALL jsMapLikePrototypeFunctionDelete(JSC::ExecState*);
 50
 51// Attributes
 52
 53JSC::EncodedJSValue jsMapLikeSize(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
 54JSC::EncodedJSValue jsMapLikeConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
 55bool setJSMapLikeConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue);
 56
 57class JSMapLikePrototype : public JSC::JSNonFinalObject {
 58public:
 59 using Base = JSC::JSNonFinalObject;
 60 static JSMapLikePrototype* create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure)
 61 {
 62 JSMapLikePrototype* ptr = new (NotNull, JSC::allocateCell<JSMapLikePrototype>(vm.heap)) JSMapLikePrototype(vm, globalObject, structure);
 63 ptr->finishCreation(vm);
 64 return ptr;
 65 }
 66
 67 DECLARE_INFO;
 68 static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
 69 {
 70 return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info());
 71 }
 72
 73private:
 74 JSMapLikePrototype(JSC::VM& vm, JSC::JSGlobalObject*, JSC::Structure* structure)
 75 : JSC::JSNonFinalObject(vm, structure)
 76 {
 77 }
 78
 79 void finishCreation(JSC::VM&);
 80};
 81
 82using JSMapLikeConstructor = JSDOMConstructorNotConstructable<JSMapLike>;
 83
 84template<> JSValue JSMapLikeConstructor::prototypeForStructure(JSC::VM& vm, const JSDOMGlobalObject& globalObject)
 85{
 86 UNUSED_PARAM(vm);
 87 return globalObject.functionPrototype();
 88}
 89
 90template<> void JSMapLikeConstructor::initializeProperties(VM& vm, JSDOMGlobalObject& globalObject)
 91{
 92 putDirect(vm, vm.propertyNames->prototype, JSMapLike::prototype(vm, &globalObject), DontDelete | ReadOnly | DontEnum);
 93 putDirect(vm, vm.propertyNames->name, jsNontrivialString(&vm, String(ASCIILiteral("MapLike"))), ReadOnly | DontEnum);
 94 putDirect(vm, vm.propertyNames->length, jsNumber(0), ReadOnly | DontEnum);
 95}
 96
 97template<> const ClassInfo JSMapLikeConstructor::s_info = { "MapLike", &Base::s_info, 0, CREATE_METHOD_TABLE(JSMapLikeConstructor) };
 98
 99/* Hash table for prototype */
 100
 101static const HashTableValue JSMapLikePrototypeTableValues[] =
 102{
 103 { "constructor", DontEnum, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsMapLikeConstructor), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSMapLikeConstructor) } },
 104 { "size", DontEnum | ReadOnly | CustomAccessor, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsMapLikeSize), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
 105 { "get", DontEnum | JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsMapLikePrototypeFunctionGet), (intptr_t) (1) } },
 106 { "has", DontEnum | JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsMapLikePrototypeFunctionHas), (intptr_t) (1) } },
 107 { "entries", DontEnum | JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsMapLikePrototypeFunctionEntries), (intptr_t) (0) } },
 108 { "keys", DontEnum | JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsMapLikePrototypeFunctionKeys), (intptr_t) (0) } },
 109 { "values", DontEnum | JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsMapLikePrototypeFunctionValues), (intptr_t) (0) } },
 110 { "forEach", JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsMapLikePrototypeFunctionForEach), (intptr_t) (1) } },
 111 { "add", DontEnum | JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsMapLikePrototypeFunctionAdd), (intptr_t) (1) } },
 112 { "clear", DontEnum | JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsMapLikePrototypeFunctionClear), (intptr_t) (0) } },
 113 { "delete", DontEnum | JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsMapLikePrototypeFunctionDelete), (intptr_t) (1) } },
 114};
 115
 116const ClassInfo JSMapLikePrototype::s_info = { "MapLikePrototype", &Base::s_info, 0, CREATE_METHOD_TABLE(JSMapLikePrototype) };
 117
 118void JSMapLikePrototype::finishCreation(VM& vm)
 119{
 120 Base::finishCreation(vm);
 121 reifyStaticProperties(vm, JSMapLikePrototypeTableValues, *this);
 122 putDirect(vm, vm.propertyNames->iteratorSymbol, getDirect(vm, vm.propertyNames->builtinNames().valuesPublicName()), DontEnum);
 123}
 124
 125const ClassInfo JSMapLike::s_info = { "MapLike", &Base::s_info, 0, CREATE_METHOD_TABLE(JSMapLike) };
 126
 127JSMapLike::JSMapLike(Structure* structure, JSDOMGlobalObject& globalObject, Ref<MapLike>&& impl)
 128 : JSDOMWrapper<MapLike>(structure, globalObject, WTFMove(impl))
 129{
 130}
 131
 132void JSMapLike::finishCreation(VM& vm)
 133{
 134 Base::finishCreation(vm);
 135 ASSERT(inherits(vm, info()));
 136
 137 synchronizeBackingMap(*globalObject()->globalExec(), *globalObject(), *this);
 138}
 139
 140JSObject* JSMapLike::createPrototype(VM& vm, JSGlobalObject* globalObject)
 141{
 142 return JSMapLikePrototype::create(vm, globalObject, JSMapLikePrototype::createStructure(vm, globalObject, globalObject->objectPrototype()));
 143}
 144
 145JSObject* JSMapLike::prototype(VM& vm, JSGlobalObject* globalObject)
 146{
 147 return getDOMPrototype<JSMapLike>(vm, globalObject);
 148}
 149
 150void JSMapLike::destroy(JSC::JSCell* cell)
 151{
 152 JSMapLike* thisObject = static_cast<JSMapLike*>(cell);
 153 thisObject->JSMapLike::~JSMapLike();
 154}
 155
 156template<> inline JSMapLike* BindingCaller<JSMapLike>::castForAttribute(ExecState& state, EncodedJSValue thisValue)
 157{
 158 return jsDynamicDowncast<JSMapLike*>(state.vm(), JSValue::decode(thisValue));
 159}
 160
 161template<> inline JSMapLike* BindingCaller<JSMapLike>::castForOperation(ExecState& state)
 162{
 163 return jsDynamicDowncast<JSMapLike*>(state.vm(), state.thisValue());
 164}
 165
 166static inline JSValue jsMapLikeSizeGetter(ExecState&, JSMapLike&, ThrowScope& throwScope);
 167
 168EncodedJSValue jsMapLikeSize(ExecState* state, EncodedJSValue thisValue, PropertyName)
 169{
 170 return BindingCaller<JSMapLike>::attribute<jsMapLikeSizeGetter>(state, thisValue, "size");
 171}
 172
 173static inline JSValue jsMapLikeSizeGetter(ExecState& state, JSMapLike& thisObject, ThrowScope& throwScope)
 174{
 175 UNUSED_PARAM(throwScope);
 176 UNUSED_PARAM(state);
 177 JSValue result = toJS<IDLAny>(forwardSizeToMapLike(state, thisObject));
 178 return result;
 179}
 180
 181EncodedJSValue jsMapLikeConstructor(ExecState* state, EncodedJSValue thisValue, PropertyName)
 182{
 183 VM& vm = state->vm();
 184 auto throwScope = DECLARE_THROW_SCOPE(vm);
 185 JSMapLikePrototype* domObject = jsDynamicDowncast<JSMapLikePrototype*>(vm, JSValue::decode(thisValue));
 186 if (UNLIKELY(!domObject))
 187 return throwVMTypeError(state, throwScope);
 188 return JSValue::encode(JSMapLike::getConstructor(state->vm(), domObject->globalObject()));
 189}
 190
 191bool setJSMapLikeConstructor(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue)
 192{
 193 VM& vm = state->vm();
 194 auto throwScope = DECLARE_THROW_SCOPE(vm);
 195 JSValue value = JSValue::decode(encodedValue);
 196 JSMapLikePrototype* domObject = jsDynamicDowncast<JSMapLikePrototype*>(vm, JSValue::decode(thisValue));
 197 if (UNLIKELY(!domObject)) {
 198 throwVMTypeError(state, throwScope);
 199 return false;
 200 }
 201 // Shadowing a built-in constructor
 202 return domObject->putDirect(state->vm(), state->propertyNames().constructor, value);
 203}
 204
 205JSValue JSMapLike::getConstructor(VM& vm, const JSGlobalObject* globalObject)
 206{
 207 return getDOMConstructor<JSMapLikeConstructor>(vm, *jsCast<const JSDOMGlobalObject*>(globalObject));
 208}
 209
 210static inline JSC::EncodedJSValue jsMapLikePrototypeFunctionGetCaller(JSC::ExecState*, JSMapLike*, JSC::ThrowScope&);
 211
 212EncodedJSValue JSC_HOST_CALL jsMapLikePrototypeFunctionGet(ExecState* state)
 213{
 214 return BindingCaller<JSMapLike>::callOperation<jsMapLikePrototypeFunctionGetCaller>(state, "get");
 215}
 216
 217static inline JSC::EncodedJSValue jsMapLikePrototypeFunctionGetCaller(JSC::ExecState* state, JSMapLike* castedThis, JSC::ThrowScope& throwScope)
 218{
 219 UNUSED_PARAM(state);
 220 UNUSED_PARAM(throwScope);
 221 if (UNLIKELY(state->argumentCount() < 1))
 222 return throwVMError(state, throwScope, createNotEnoughArgumentsError(state));
 223 auto key = convert<IDLDOMString>(*state, state->uncheckedArgument(0), StringConversionConfiguration::Normal);
 224 RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
 225 return JSValue::encode(toJS<IDLAny>(forwardGetToMapLike(*state, *castedThis, WTFMove(key))));
 226}
 227
 228static inline JSC::EncodedJSValue jsMapLikePrototypeFunctionHasCaller(JSC::ExecState*, JSMapLike*, JSC::ThrowScope&);
 229
 230EncodedJSValue JSC_HOST_CALL jsMapLikePrototypeFunctionHas(ExecState* state)
 231{
 232 return BindingCaller<JSMapLike>::callOperation<jsMapLikePrototypeFunctionHasCaller>(state, "has");
 233}
 234
 235static inline JSC::EncodedJSValue jsMapLikePrototypeFunctionHasCaller(JSC::ExecState* state, JSMapLike* castedThis, JSC::ThrowScope& throwScope)
 236{
 237 UNUSED_PARAM(state);
 238 UNUSED_PARAM(throwScope);
 239 if (UNLIKELY(state->argumentCount() < 1))
 240 return throwVMError(state, throwScope, createNotEnoughArgumentsError(state));
 241 auto key = convert<IDLDOMString>(*state, state->uncheckedArgument(0), StringConversionConfiguration::Normal);
 242 RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
 243 return JSValue::encode(toJS<IDLAny>(forwardHasToMapLike(*state, *castedThis, WTFMove(key))));
 244}
 245
 246static inline JSC::EncodedJSValue jsMapLikePrototypeFunctionEntriesCaller(JSC::ExecState*, JSMapLike*, JSC::ThrowScope&);
 247
 248EncodedJSValue JSC_HOST_CALL jsMapLikePrototypeFunctionEntries(ExecState* state)
 249{
 250 return BindingCaller<JSMapLike>::callOperation<jsMapLikePrototypeFunctionEntriesCaller>(state, "entries");
 251}
 252
 253static inline JSC::EncodedJSValue jsMapLikePrototypeFunctionEntriesCaller(JSC::ExecState* state, JSMapLike* castedThis, JSC::ThrowScope& throwScope)
 254{
 255 UNUSED_PARAM(state);
 256 UNUSED_PARAM(throwScope);
 257 return JSValue::encode(toJS<IDLAny>(forwardEntriesToMapLike(*state, *castedThis)));
 258}
 259
 260static inline JSC::EncodedJSValue jsMapLikePrototypeFunctionKeysCaller(JSC::ExecState*, JSMapLike*, JSC::ThrowScope&);
 261
 262EncodedJSValue JSC_HOST_CALL jsMapLikePrototypeFunctionKeys(ExecState* state)
 263{
 264 return BindingCaller<JSMapLike>::callOperation<jsMapLikePrototypeFunctionKeysCaller>(state, "keys");
 265}
 266
 267static inline JSC::EncodedJSValue jsMapLikePrototypeFunctionKeysCaller(JSC::ExecState* state, JSMapLike* castedThis, JSC::ThrowScope& throwScope)
 268{
 269 UNUSED_PARAM(state);
 270 UNUSED_PARAM(throwScope);
 271 return JSValue::encode(toJS<IDLAny>(forwardKeysToMapLike(*state, *castedThis)));
 272}
 273
 274static inline JSC::EncodedJSValue jsMapLikePrototypeFunctionValuesCaller(JSC::ExecState*, JSMapLike*, JSC::ThrowScope&);
 275
 276EncodedJSValue JSC_HOST_CALL jsMapLikePrototypeFunctionValues(ExecState* state)
 277{
 278 return BindingCaller<JSMapLike>::callOperation<jsMapLikePrototypeFunctionValuesCaller>(state, "values");
 279}
 280
 281static inline JSC::EncodedJSValue jsMapLikePrototypeFunctionValuesCaller(JSC::ExecState* state, JSMapLike* castedThis, JSC::ThrowScope& throwScope)
 282{
 283 UNUSED_PARAM(state);
 284 UNUSED_PARAM(throwScope);
 285 return JSValue::encode(toJS<IDLAny>(forwardValuesToMapLike(*state, *castedThis)));
 286}
 287
 288static inline JSC::EncodedJSValue jsMapLikePrototypeFunctionForEachCaller(JSC::ExecState*, JSMapLike*, JSC::ThrowScope&);
 289
 290EncodedJSValue JSC_HOST_CALL jsMapLikePrototypeFunctionForEach(ExecState* state)
 291{
 292 return BindingCaller<JSMapLike>::callOperation<jsMapLikePrototypeFunctionForEachCaller>(state, "forEach");
 293}
 294
 295static inline JSC::EncodedJSValue jsMapLikePrototypeFunctionForEachCaller(JSC::ExecState* state, JSMapLike* castedThis, JSC::ThrowScope& throwScope)
 296{
 297 UNUSED_PARAM(state);
 298 UNUSED_PARAM(throwScope);
 299 if (UNLIKELY(state->argumentCount() < 1))
 300 return throwVMError(state, throwScope, createNotEnoughArgumentsError(state));
 301 auto callback = convert<IDLAny>(*state, state->uncheckedArgument(0));
 302 RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
 303 return JSValue::encode(toJS<IDLAny>(forwardForEachToMapLike(*state, *castedThis, WTFMove(callback))));
 304}
 305
 306static inline JSC::EncodedJSValue jsMapLikePrototypeFunctionAddCaller(JSC::ExecState*, JSMapLike*, JSC::ThrowScope&);
 307
 308EncodedJSValue JSC_HOST_CALL jsMapLikePrototypeFunctionAdd(ExecState* state)
 309{
 310 return BindingCaller<JSMapLike>::callOperation<jsMapLikePrototypeFunctionAddCaller>(state, "add");
 311}
 312
 313static inline JSC::EncodedJSValue jsMapLikePrototypeFunctionAddCaller(JSC::ExecState* state, JSMapLike* castedThis, JSC::ThrowScope& throwScope)
 314{
 315 UNUSED_PARAM(state);
 316 UNUSED_PARAM(throwScope);
 317 if (UNLIKELY(state->argumentCount() < 1))
 318 return throwVMError(state, throwScope, createNotEnoughArgumentsError(state));
 319 auto key = convert<IDLDOMString>(*state, state->uncheckedArgument(0), StringConversionConfiguration::Normal);
 320 RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
 321 return JSValue::encode(toJS<IDLAny>(forwardAddToMapLike(*state, *castedThis, WTFMove(key))));
 322}
 323
 324static inline JSC::EncodedJSValue jsMapLikePrototypeFunctionClearCaller(JSC::ExecState*, JSMapLike*, JSC::ThrowScope&);
 325
 326EncodedJSValue JSC_HOST_CALL jsMapLikePrototypeFunctionClear(ExecState* state)
 327{
 328 return BindingCaller<JSMapLike>::callOperation<jsMapLikePrototypeFunctionClearCaller>(state, "clear");
 329}
 330
 331static inline JSC::EncodedJSValue jsMapLikePrototypeFunctionClearCaller(JSC::ExecState* state, JSMapLike* castedThis, JSC::ThrowScope& throwScope)
 332{
 333 UNUSED_PARAM(state);
 334 UNUSED_PARAM(throwScope);
 335 forwardClearToMapLike(*state, *castedThis);
 336 return JSValue::encode(jsUndefined());
 337}
 338
 339static inline JSC::EncodedJSValue jsMapLikePrototypeFunctionDeleteCaller(JSC::ExecState*, JSMapLike*, JSC::ThrowScope&);
 340
 341EncodedJSValue JSC_HOST_CALL jsMapLikePrototypeFunctionDelete(ExecState* state)
 342{
 343 return BindingCaller<JSMapLike>::callOperation<jsMapLikePrototypeFunctionDeleteCaller>(state, "delete");
 344}
 345
 346static inline JSC::EncodedJSValue jsMapLikePrototypeFunctionDeleteCaller(JSC::ExecState* state, JSMapLike* castedThis, JSC::ThrowScope& throwScope)
 347{
 348 UNUSED_PARAM(state);
 349 UNUSED_PARAM(throwScope);
 350 if (UNLIKELY(state->argumentCount() < 1))
 351 return throwVMError(state, throwScope, createNotEnoughArgumentsError(state));
 352 auto key = convert<IDLDOMString>(*state, state->uncheckedArgument(0), StringConversionConfiguration::Normal);
 353 RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
 354 return JSValue::encode(toJS<IDLAny>(forwardDeleteToMapLike(*state, *castedThis, WTFMove(key))));
 355}
 356
 357bool JSMapLikeOwner::isReachableFromOpaqueRoots(JSC::Handle<JSC::Unknown> handle, void*, SlotVisitor& visitor)
 358{
 359 UNUSED_PARAM(handle);
 360 UNUSED_PARAM(visitor);
 361 return false;
 362}
 363
 364void JSMapLikeOwner::finalize(JSC::Handle<JSC::Unknown> handle, void* context)
 365{
 366 auto* jsMapLike = static_cast<JSMapLike*>(handle.slot()->asCell());
 367 auto& world = *static_cast<DOMWrapperWorld*>(context);
 368 uncacheWrapper(world, &jsMapLike->wrapped(), jsMapLike);
 369}
 370
 371#if ENABLE(BINDING_INTEGRITY)
 372#if PLATFORM(WIN)
 373#pragma warning(disable: 4483)
 374extern "C" { extern void (*const __identifier("??_7MapLike@WebCore@@6B@")[])(); }
 375#else
 376extern "C" { extern void* _ZTVN7WebCore7MapLikeE[]; }
 377#endif
 378#endif
 379
 380JSC::JSValue toJSNewlyCreated(JSC::ExecState*, JSDOMGlobalObject* globalObject, Ref<MapLike>&& impl)
 381{
 382
 383#if ENABLE(BINDING_INTEGRITY)
 384 void* actualVTablePointer = *(reinterpret_cast<void**>(impl.ptr()));
 385#if PLATFORM(WIN)
 386 void* expectedVTablePointer = reinterpret_cast<void*>(__identifier("??_7MapLike@WebCore@@6B@"));
 387#else
 388 void* expectedVTablePointer = &_ZTVN7WebCore7MapLikeE[2];
 389#if COMPILER(CLANG)
 390 // If this fails MapLike does not have a vtable, so you need to add the
 391 // ImplementationLacksVTable attribute to the interface definition
 392 static_assert(__is_polymorphic(MapLike), "MapLike is not polymorphic");
 393#endif
 394#endif
 395 // If you hit this assertion you either have a use after free bug, or
 396 // MapLike has subclasses. If MapLike has subclasses that get passed
 397 // to toJS() we currently require MapLike you to opt out of binding hardening
 398 // by adding the SkipVTableValidation attribute to the interface IDL definition
 399 RELEASE_ASSERT(actualVTablePointer == expectedVTablePointer);
 400#endif
 401 return createWrapper<MapLike>(globalObject, WTFMove(impl));
 402}
 403
 404JSC::JSValue toJS(JSC::ExecState* state, JSDOMGlobalObject* globalObject, MapLike& impl)
 405{
 406 return wrap(state, globalObject, impl);
 407}
 408
 409MapLike* JSMapLike::toWrapped(JSC::VM& vm, JSC::JSValue value)
 410{
 411 if (auto* wrapper = jsDynamicDowncast<JSMapLike*>(vm, value))
 412 return &wrapper->wrapped();
 413 return nullptr;
 414}
 415
 416}

Source/WebCore/bindings/scripts/test/JS/JSMapLike.h

 1/*
 2 This file is part of the WebKit open source project.
 3 This file has been generated by generate-bindings.pl. DO NOT MODIFY!
 4
 5 This library is free software; you can redistribute it and/or
 6 modify it under the terms of the GNU Library General Public
 7 License as published by the Free Software Foundation; either
 8 version 2 of the License, or (at your option) any later version.
 9
 10 This library is distributed in the hope that it will be useful,
 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 13 Library General Public License for more details.
 14
 15 You should have received a copy of the GNU Library General Public License
 16 along with this library; see the file COPYING.LIB. If not, write to
 17 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
 18 Boston, MA 02110-1301, USA.
 19*/
 20
 21#pragma once
 22
 23#include "JSDOMWrapper.h"
 24#include "MapLike.h"
 25#include <wtf/NeverDestroyed.h>
 26
 27namespace WebCore {
 28
 29class JSMapLike : public JSDOMWrapper<MapLike> {
 30public:
 31 using Base = JSDOMWrapper<MapLike>;
 32 static JSMapLike* create(JSC::Structure* structure, JSDOMGlobalObject* globalObject, Ref<MapLike>&& impl)
 33 {
 34 JSMapLike* ptr = new (NotNull, JSC::allocateCell<JSMapLike>(globalObject->vm().heap)) JSMapLike(structure, *globalObject, WTFMove(impl));
 35 ptr->finishCreation(globalObject->vm());
 36 return ptr;
 37 }
 38
 39 static JSC::JSObject* createPrototype(JSC::VM&, JSC::JSGlobalObject*);
 40 static JSC::JSObject* prototype(JSC::VM&, JSC::JSGlobalObject*);
 41 static MapLike* toWrapped(JSC::VM&, JSC::JSValue);
 42 static void destroy(JSC::JSCell*);
 43
 44 DECLARE_INFO;
 45
 46 static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
 47 {
 48 return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info());
 49 }
 50
 51 static JSC::JSValue getConstructor(JSC::VM&, const JSC::JSGlobalObject*);
 52protected:
 53 JSMapLike(JSC::Structure*, JSDOMGlobalObject&, Ref<MapLike>&&);
 54
 55 void finishCreation(JSC::VM&);
 56};
 57
 58class JSMapLikeOwner : public JSC::WeakHandleOwner {
 59public:
 60 virtual bool isReachableFromOpaqueRoots(JSC::Handle<JSC::Unknown>, void* context, JSC::SlotVisitor&);
 61 virtual void finalize(JSC::Handle<JSC::Unknown>, void* context);
 62};
 63
 64inline JSC::WeakHandleOwner* wrapperOwner(DOMWrapperWorld&, MapLike*)
 65{
 66 static NeverDestroyed<JSMapLikeOwner> owner;
 67 return &owner.get();
 68}
 69
 70inline void* wrapperKey(MapLike* wrappableObject)
 71{
 72 return wrappableObject;
 73}
 74
 75JSC::JSValue toJS(JSC::ExecState*, JSDOMGlobalObject*, MapLike&);
 76inline JSC::JSValue toJS(JSC::ExecState* state, JSDOMGlobalObject* globalObject, MapLike* impl) { return impl ? toJS(state, globalObject, *impl) : JSC::jsNull(); }
 77JSC::JSValue toJSNewlyCreated(JSC::ExecState*, JSDOMGlobalObject*, Ref<MapLike>&&);
 78inline JSC::JSValue toJSNewlyCreated(JSC::ExecState* state, JSDOMGlobalObject* globalObject, RefPtr<MapLike>&& impl) { return impl ? toJSNewlyCreated(state, globalObject, impl.releaseNonNull()) : JSC::jsNull(); }
 79
 80template<> struct JSDOMWrapperConverterTraits<MapLike> {
 81 using WrapperClass = JSMapLike;
 82 using ToWrappedReturnType = MapLike*;
 83};
 84
 85} // namespace WebCore

Source/WebCore/bindings/scripts/test/JS/JSReadOnlyMapLike.cpp

 1/*
 2 This file is part of the WebKit open source project.
 3 This file has been generated by generate-bindings.pl. DO NOT MODIFY!
 4
 5 This library is free software; you can redistribute it and/or
 6 modify it under the terms of the GNU Library General Public
 7 License as published by the Free Software Foundation; either
 8 version 2 of the License, or (at your option) any later version.
 9
 10 This library is distributed in the hope that it will be useful,
 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 13 Library General Public License for more details.
 14
 15 You should have received a copy of the GNU Library General Public License
 16 along with this library; see the file COPYING.LIB. If not, write to
 17 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
 18 Boston, MA 02110-1301, USA.
 19*/
 20
 21#include "config.h"
 22#include "JSReadOnlyMapLike.h"
 23
 24#include "JSDOMBinding.h"
 25#include "JSDOMBindingCaller.h"
 26#include "JSDOMConstructorNotConstructable.h"
 27#include "JSDOMConvert.h"
 28#include "JSDOMExceptionHandling.h"
 29#include "JSDOMMapLike.h"
 30#include "JSDOMWrapperCache.h"
 31#include <runtime/Error.h>
 32#include <runtime/FunctionPrototype.h>
 33#include <wtf/GetPtr.h>
 34
 35using namespace JSC;
 36
 37namespace WebCore {
 38
 39// Functions
 40
 41JSC::EncodedJSValue JSC_HOST_CALL jsReadOnlyMapLikePrototypeFunctionGet(JSC::ExecState*);
 42JSC::EncodedJSValue JSC_HOST_CALL jsReadOnlyMapLikePrototypeFunctionHas(JSC::ExecState*);
 43JSC::EncodedJSValue JSC_HOST_CALL jsReadOnlyMapLikePrototypeFunctionEntries(JSC::ExecState*);
 44JSC::EncodedJSValue JSC_HOST_CALL jsReadOnlyMapLikePrototypeFunctionKeys(JSC::ExecState*);
 45JSC::EncodedJSValue JSC_HOST_CALL jsReadOnlyMapLikePrototypeFunctionValues(JSC::ExecState*);
 46JSC::EncodedJSValue JSC_HOST_CALL jsReadOnlyMapLikePrototypeFunctionForEach(JSC::ExecState*);
 47
 48// Attributes
 49
 50JSC::EncodedJSValue jsReadOnlyMapLikeSize(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
 51JSC::EncodedJSValue jsReadOnlyMapLikeConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
 52bool setJSReadOnlyMapLikeConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue);
 53
 54class JSReadOnlyMapLikePrototype : public JSC::JSNonFinalObject {
 55public:
 56 using Base = JSC::JSNonFinalObject;
 57 static JSReadOnlyMapLikePrototype* create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure)
 58 {
 59 JSReadOnlyMapLikePrototype* ptr = new (NotNull, JSC::allocateCell<JSReadOnlyMapLikePrototype>(vm.heap)) JSReadOnlyMapLikePrototype(vm, globalObject, structure);
 60 ptr->finishCreation(vm);
 61 return ptr;
 62 }
 63
 64 DECLARE_INFO;
 65 static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
 66 {
 67 return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info());
 68 }
 69
 70private:
 71 JSReadOnlyMapLikePrototype(JSC::VM& vm, JSC::JSGlobalObject*, JSC::Structure* structure)
 72 : JSC::JSNonFinalObject(vm, structure)
 73 {
 74 }
 75
 76 void finishCreation(JSC::VM&);
 77};
 78
 79using JSReadOnlyMapLikeConstructor = JSDOMConstructorNotConstructable<JSReadOnlyMapLike>;
 80
 81template<> JSValue JSReadOnlyMapLikeConstructor::prototypeForStructure(JSC::VM& vm, const JSDOMGlobalObject& globalObject)
 82{
 83 UNUSED_PARAM(vm);
 84 return globalObject.functionPrototype();
 85}
 86
 87template<> void JSReadOnlyMapLikeConstructor::initializeProperties(VM& vm, JSDOMGlobalObject& globalObject)
 88{
 89 putDirect(vm, vm.propertyNames->prototype, JSReadOnlyMapLike::prototype(vm, &globalObject), DontDelete | ReadOnly | DontEnum);
 90 putDirect(vm, vm.propertyNames->name, jsNontrivialString(&vm, String(ASCIILiteral("ReadOnlyMapLike"))), ReadOnly | DontEnum);
 91 putDirect(vm, vm.propertyNames->length, jsNumber(0), ReadOnly | DontEnum);
 92}
 93
 94template<> const ClassInfo JSReadOnlyMapLikeConstructor::s_info = { "ReadOnlyMapLike", &Base::s_info, 0, CREATE_METHOD_TABLE(JSReadOnlyMapLikeConstructor) };
 95
 96/* Hash table for prototype */
 97
 98static const HashTableValue JSReadOnlyMapLikePrototypeTableValues[] =
 99{
 100 { "constructor", DontEnum, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsReadOnlyMapLikeConstructor), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSReadOnlyMapLikeConstructor) } },
 101 { "size", DontEnum | ReadOnly | CustomAccessor, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsReadOnlyMapLikeSize), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
 102 { "get", DontEnum | JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsReadOnlyMapLikePrototypeFunctionGet), (intptr_t) (1) } },
 103 { "has", DontEnum | JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsReadOnlyMapLikePrototypeFunctionHas), (intptr_t) (1) } },
 104 { "entries", DontEnum | JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsReadOnlyMapLikePrototypeFunctionEntries), (intptr_t) (0) } },
 105 { "keys", DontEnum | JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsReadOnlyMapLikePrototypeFunctionKeys), (intptr_t) (0) } },
 106 { "values", DontEnum | JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsReadOnlyMapLikePrototypeFunctionValues), (intptr_t) (0) } },
 107 { "forEach", JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsReadOnlyMapLikePrototypeFunctionForEach), (intptr_t) (1) } },
 108};
 109
 110const ClassInfo JSReadOnlyMapLikePrototype::s_info = { "ReadOnlyMapLikePrototype", &Base::s_info, 0, CREATE_METHOD_TABLE(JSReadOnlyMapLikePrototype) };
 111
 112void JSReadOnlyMapLikePrototype::finishCreation(VM& vm)
 113{
 114 Base::finishCreation(vm);
 115 reifyStaticProperties(vm, JSReadOnlyMapLikePrototypeTableValues, *this);
 116 putDirect(vm, vm.propertyNames->iteratorSymbol, getDirect(vm, vm.propertyNames->builtinNames().valuesPublicName()), DontEnum);
 117}
 118
 119const ClassInfo JSReadOnlyMapLike::s_info = { "ReadOnlyMapLike", &Base::s_info, 0, CREATE_METHOD_TABLE(JSReadOnlyMapLike) };
 120
 121JSReadOnlyMapLike::JSReadOnlyMapLike(Structure* structure, JSDOMGlobalObject& globalObject, Ref<ReadOnlyMapLike>&& impl)
 122 : JSDOMWrapper<ReadOnlyMapLike>(structure, globalObject, WTFMove(impl))
 123{
 124}
 125
 126void JSReadOnlyMapLike::finishCreation(VM& vm)
 127{
 128 Base::finishCreation(vm);
 129 ASSERT(inherits(vm, info()));
 130
 131 synchronizeBackingMap(*globalObject()->globalExec(), *globalObject(), *this);
 132}
 133
 134JSObject* JSReadOnlyMapLike::createPrototype(VM& vm, JSGlobalObject* globalObject)
 135{
 136 return JSReadOnlyMapLikePrototype::create(vm, globalObject, JSReadOnlyMapLikePrototype::createStructure(vm, globalObject, globalObject->objectPrototype()));
 137}
 138
 139JSObject* JSReadOnlyMapLike::prototype(VM& vm, JSGlobalObject* globalObject)
 140{
 141 return getDOMPrototype<JSReadOnlyMapLike>(vm, globalObject);
 142}
 143
 144void JSReadOnlyMapLike::destroy(JSC::JSCell* cell)
 145{
 146 JSReadOnlyMapLike* thisObject = static_cast<JSReadOnlyMapLike*>(cell);
 147 thisObject->JSReadOnlyMapLike::~JSReadOnlyMapLike();
 148}
 149
 150template<> inline JSReadOnlyMapLike* BindingCaller<JSReadOnlyMapLike>::castForAttribute(ExecState& state, EncodedJSValue thisValue)
 151{
 152 return jsDynamicDowncast<JSReadOnlyMapLike*>(state.vm(), JSValue::decode(thisValue));
 153}
 154
 155template<> inline JSReadOnlyMapLike* BindingCaller<JSReadOnlyMapLike>::castForOperation(ExecState& state)
 156{
 157 return jsDynamicDowncast<JSReadOnlyMapLike*>(state.vm(), state.thisValue());
 158}
 159
 160static inline JSValue jsReadOnlyMapLikeSizeGetter(ExecState&, JSReadOnlyMapLike&, ThrowScope& throwScope);
 161
 162EncodedJSValue jsReadOnlyMapLikeSize(ExecState* state, EncodedJSValue thisValue, PropertyName)
 163{
 164 return BindingCaller<JSReadOnlyMapLike>::attribute<jsReadOnlyMapLikeSizeGetter>(state, thisValue, "size");
 165}
 166
 167static inline JSValue jsReadOnlyMapLikeSizeGetter(ExecState& state, JSReadOnlyMapLike& thisObject, ThrowScope& throwScope)
 168{
 169 UNUSED_PARAM(throwScope);
 170 UNUSED_PARAM(state);
 171 JSValue result = toJS<IDLAny>(forwardSizeToMapLike(state, thisObject));
 172 return result;
 173}
 174
 175EncodedJSValue jsReadOnlyMapLikeConstructor(ExecState* state, EncodedJSValue thisValue, PropertyName)
 176{
 177 VM& vm = state->vm();
 178 auto throwScope = DECLARE_THROW_SCOPE(vm);
 179 JSReadOnlyMapLikePrototype* domObject = jsDynamicDowncast<JSReadOnlyMapLikePrototype*>(vm, JSValue::decode(thisValue));
 180 if (UNLIKELY(!domObject))
 181 return throwVMTypeError(state, throwScope);
 182 return JSValue::encode(JSReadOnlyMapLike::getConstructor(state->vm(), domObject->globalObject()));
 183}
 184
 185bool setJSReadOnlyMapLikeConstructor(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue)
 186{
 187 VM& vm = state->vm();
 188 auto throwScope = DECLARE_THROW_SCOPE(vm);
 189 JSValue value = JSValue::decode(encodedValue);
 190 JSReadOnlyMapLikePrototype* domObject = jsDynamicDowncast<JSReadOnlyMapLikePrototype*>(vm, JSValue::decode(thisValue));
 191 if (UNLIKELY(!domObject)) {
 192 throwVMTypeError(state, throwScope);
 193 return false;
 194 }
 195 // Shadowing a built-in constructor
 196 return domObject->putDirect(state->vm(), state->propertyNames().constructor, value);
 197}
 198
 199JSValue JSReadOnlyMapLike::getConstructor(VM& vm, const JSGlobalObject* globalObject)
 200{
 201 return getDOMConstructor<JSReadOnlyMapLikeConstructor>(vm, *jsCast<const JSDOMGlobalObject*>(globalObject));
 202}
 203
 204static inline JSC::EncodedJSValue jsReadOnlyMapLikePrototypeFunctionGetCaller(JSC::ExecState*, JSReadOnlyMapLike*, JSC::ThrowScope&);
 205
 206EncodedJSValue JSC_HOST_CALL jsReadOnlyMapLikePrototypeFunctionGet(ExecState* state)
 207{
 208 return BindingCaller<JSReadOnlyMapLike>::callOperation<jsReadOnlyMapLikePrototypeFunctionGetCaller>(state, "get");
 209}
 210
 211static inline JSC::EncodedJSValue jsReadOnlyMapLikePrototypeFunctionGetCaller(JSC::ExecState* state, JSReadOnlyMapLike* castedThis, JSC::ThrowScope& throwScope)
 212{
 213 UNUSED_PARAM(state);
 214 UNUSED_PARAM(throwScope);
 215 if (UNLIKELY(state->argumentCount() < 1))
 216 return throwVMError(state, throwScope, createNotEnoughArgumentsError(state));
 217 auto key = convert<IDLDOMString>(*state, state->uncheckedArgument(0), StringConversionConfiguration::Normal);
 218 RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
 219 return JSValue::encode(toJS<IDLAny>(forwardGetToMapLike(*state, *castedThis, WTFMove(key))));
 220}
 221
 222static inline JSC::EncodedJSValue jsReadOnlyMapLikePrototypeFunctionHasCaller(JSC::ExecState*, JSReadOnlyMapLike*, JSC::ThrowScope&);
 223
 224EncodedJSValue JSC_HOST_CALL jsReadOnlyMapLikePrototypeFunctionHas(ExecState* state)
 225{
 226 return BindingCaller<JSReadOnlyMapLike>::callOperation<jsReadOnlyMapLikePrototypeFunctionHasCaller>(state, "has");
 227}
 228
 229static inline JSC::EncodedJSValue jsReadOnlyMapLikePrototypeFunctionHasCaller(JSC::ExecState* state, JSReadOnlyMapLike* castedThis, JSC::ThrowScope& throwScope)
 230{
 231 UNUSED_PARAM(state);
 232 UNUSED_PARAM(throwScope);
 233 if (UNLIKELY(state->argumentCount() < 1))
 234 return throwVMError(state, throwScope, createNotEnoughArgumentsError(state));
 235 auto key = convert<IDLDOMString>(*state, state->uncheckedArgument(0), StringConversionConfiguration::Normal);
 236 RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
 237 return JSValue::encode(toJS<IDLAny>(forwardHasToMapLike(*state, *castedThis, WTFMove(key))));
 238}
 239
 240static inline JSC::EncodedJSValue jsReadOnlyMapLikePrototypeFunctionEntriesCaller(JSC::ExecState*, JSReadOnlyMapLike*, JSC::ThrowScope&);
 241
 242EncodedJSValue JSC_HOST_CALL jsReadOnlyMapLikePrototypeFunctionEntries(ExecState* state)
 243{
 244 return BindingCaller<JSReadOnlyMapLike>::callOperation<jsReadOnlyMapLikePrototypeFunctionEntriesCaller>(state, "entries");
 245}
 246
 247static inline JSC::EncodedJSValue jsReadOnlyMapLikePrototypeFunctionEntriesCaller(JSC::ExecState* state, JSReadOnlyMapLike* castedThis, JSC::ThrowScope& throwScope)
 248{
 249 UNUSED_PARAM(state);
 250 UNUSED_PARAM(throwScope);
 251 return JSValue::encode(toJS<IDLAny>(forwardEntriesToMapLike(*state, *castedThis)));
 252}
 253
 254static inline JSC::EncodedJSValue jsReadOnlyMapLikePrototypeFunctionKeysCaller(JSC::ExecState*, JSReadOnlyMapLike*, JSC::ThrowScope&);
 255
 256EncodedJSValue JSC_HOST_CALL jsReadOnlyMapLikePrototypeFunctionKeys(ExecState* state)
 257{
 258 return BindingCaller<JSReadOnlyMapLike>::callOperation<jsReadOnlyMapLikePrototypeFunctionKeysCaller>(state, "keys");
 259}
 260
 261static inline JSC::EncodedJSValue jsReadOnlyMapLikePrototypeFunctionKeysCaller(JSC::ExecState* state, JSReadOnlyMapLike* castedThis, JSC::ThrowScope& throwScope)
 262{
 263 UNUSED_PARAM(state);
 264 UNUSED_PARAM(throwScope);
 265 return JSValue::encode(toJS<IDLAny>(forwardKeysToMapLike(*state, *castedThis)));
 266}
 267
 268static inline JSC::EncodedJSValue jsReadOnlyMapLikePrototypeFunctionValuesCaller(JSC::ExecState*, JSReadOnlyMapLike*, JSC::ThrowScope&);
 269
 270EncodedJSValue JSC_HOST_CALL jsReadOnlyMapLikePrototypeFunctionValues(ExecState* state)
 271{
 272 return BindingCaller<JSReadOnlyMapLike>::callOperation<jsReadOnlyMapLikePrototypeFunctionValuesCaller>(state, "values");
 273}
 274
 275static inline JSC::EncodedJSValue jsReadOnlyMapLikePrototypeFunctionValuesCaller(JSC::ExecState* state, JSReadOnlyMapLike* castedThis, JSC::ThrowScope& throwScope)
 276{
 277 UNUSED_PARAM(state);
 278 UNUSED_PARAM(throwScope);
 279 return JSValue::encode(toJS<IDLAny>(forwardValuesToMapLike(*state, *castedThis)));
 280}
 281
 282static inline JSC::EncodedJSValue jsReadOnlyMapLikePrototypeFunctionForEachCaller(JSC::ExecState*, JSReadOnlyMapLike*, JSC::ThrowScope&);
 283
 284EncodedJSValue JSC_HOST_CALL jsReadOnlyMapLikePrototypeFunctionForEach(ExecState* state)
 285{
 286 return BindingCaller<JSReadOnlyMapLike>::callOperation<jsReadOnlyMapLikePrototypeFunctionForEachCaller>(state, "forEach");
 287}
 288
 289static inline JSC::EncodedJSValue jsReadOnlyMapLikePrototypeFunctionForEachCaller(JSC::ExecState* state, JSReadOnlyMapLike* castedThis, JSC::ThrowScope& throwScope)
 290{
 291 UNUSED_PARAM(state);
 292 UNUSED_PARAM(throwScope);
 293 if (UNLIKELY(state->argumentCount() < 1))
 294 return throwVMError(state, throwScope, createNotEnoughArgumentsError(state));
 295 auto callback = convert<IDLAny>(*state, state->uncheckedArgument(0));
 296 RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
 297 return JSValue::encode(toJS<IDLAny>(forwardForEachToMapLike(*state, *castedThis, WTFMove(callback))));
 298}
 299
 300bool JSReadOnlyMapLikeOwner::isReachableFromOpaqueRoots(JSC::Handle<JSC::Unknown> handle, void*, SlotVisitor& visitor)
 301{
 302 UNUSED_PARAM(handle);
 303 UNUSED_PARAM(visitor);
 304 return false;
 305}
 306
 307void JSReadOnlyMapLikeOwner::finalize(JSC::Handle<JSC::Unknown> handle, void* context)
 308{
 309 auto* jsReadOnlyMapLike = static_cast<JSReadOnlyMapLike*>(handle.slot()->asCell());
 310 auto& world = *static_cast<DOMWrapperWorld*>(context);
 311 uncacheWrapper(world, &jsReadOnlyMapLike->wrapped(), jsReadOnlyMapLike);
 312}
 313
 314#if ENABLE(BINDING_INTEGRITY)
 315#if PLATFORM(WIN)
 316#pragma warning(disable: 4483)
 317extern "C" { extern void (*const __identifier("??_7ReadOnlyMapLike@WebCore@@6B@")[])(); }
 318#else
 319extern "C" { extern void* _ZTVN7WebCore15ReadOnlyMapLikeE[]; }
 320#endif
 321#endif
 322
 323JSC::JSValue toJSNewlyCreated(JSC::ExecState*, JSDOMGlobalObject* globalObject, Ref<ReadOnlyMapLike>&& impl)
 324{
 325
 326#if ENABLE(BINDING_INTEGRITY)
 327 void* actualVTablePointer = *(reinterpret_cast<void**>(impl.ptr()));
 328#if PLATFORM(WIN)
 329 void* expectedVTablePointer = reinterpret_cast<void*>(__identifier("??_7ReadOnlyMapLike@WebCore@@6B@"));
 330#else
 331 void* expectedVTablePointer = &_ZTVN7WebCore15ReadOnlyMapLikeE[2];
 332#if COMPILER(CLANG)
 333 // If this fails ReadOnlyMapLike does not have a vtable, so you need to add the
 334 // ImplementationLacksVTable attribute to the interface definition
 335 static_assert(__is_polymorphic(ReadOnlyMapLike), "ReadOnlyMapLike is not polymorphic");
 336#endif
 337#endif
 338 // If you hit this assertion you either have a use after free bug, or
 339 // ReadOnlyMapLike has subclasses. If ReadOnlyMapLike has subclasses that get passed
 340 // to toJS() we currently require ReadOnlyMapLike you to opt out of binding hardening
 341 // by adding the SkipVTableValidation attribute to the interface IDL definition
 342 RELEASE_ASSERT(actualVTablePointer == expectedVTablePointer);
 343#endif
 344 return createWrapper<ReadOnlyMapLike>(globalObject, WTFMove(impl));
 345}
 346
 347JSC::JSValue toJS(JSC::ExecState* state, JSDOMGlobalObject* globalObject, ReadOnlyMapLike& impl)
 348{
 349 return wrap(state, globalObject, impl);
 350}
 351
 352ReadOnlyMapLike* JSReadOnlyMapLike::toWrapped(JSC::VM& vm, JSC::JSValue value)
 353{
 354 if (auto* wrapper = jsDynamicDowncast<JSReadOnlyMapLike*>(vm, value))
 355 return &wrapper->wrapped();
 356 return nullptr;
 357}
 358
 359}

Source/WebCore/bindings/scripts/test/JS/JSReadOnlyMapLike.h

 1/*
 2 This file is part of the WebKit open source project.
 3 This file has been generated by generate-bindings.pl. DO NOT MODIFY!
 4
 5 This library is free software; you can redistribute it and/or
 6 modify it under the terms of the GNU Library General Public
 7 License as published by the Free Software Foundation; either
 8 version 2 of the License, or (at your option) any later version.
 9
 10 This library is distributed in the hope that it will be useful,
 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 13 Library General Public License for more details.
 14
 15 You should have received a copy of the GNU Library General Public License
 16 along with this library; see the file COPYING.LIB. If not, write to
 17 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
 18 Boston, MA 02110-1301, USA.
 19*/
 20
 21#pragma once
 22
 23#include "JSDOMWrapper.h"
 24#include "ReadOnlyMapLike.h"
 25#include <wtf/NeverDestroyed.h>
 26
 27namespace WebCore {
 28
 29class JSReadOnlyMapLike : public JSDOMWrapper<ReadOnlyMapLike> {
 30public:
 31 using Base = JSDOMWrapper<ReadOnlyMapLike>;
 32 static JSReadOnlyMapLike* create(JSC::Structure* structure, JSDOMGlobalObject* globalObject, Ref<ReadOnlyMapLike>&& impl)
 33 {
 34 JSReadOnlyMapLike* ptr = new (NotNull, JSC::allocateCell<JSReadOnlyMapLike>(globalObject->vm().heap)) JSReadOnlyMapLike(structure, *globalObject, WTFMove(impl));
 35 ptr->finishCreation(globalObject->vm());
 36 return ptr;
 37 }
 38
 39 static JSC::JSObject* createPrototype(JSC::VM&, JSC::JSGlobalObject*);
 40 static JSC::JSObject* prototype(JSC::VM&, JSC::JSGlobalObject*);
 41 static ReadOnlyMapLike* toWrapped(JSC::VM&, JSC::JSValue);
 42 static void destroy(JSC::JSCell*);
 43
 44 DECLARE_INFO;
 45
 46 static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
 47 {
 48 return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info());
 49 }
 50
 51 static JSC::JSValue getConstructor(JSC::VM&, const JSC::JSGlobalObject*);
 52protected:
 53 JSReadOnlyMapLike(JSC::Structure*, JSDOMGlobalObject&, Ref<ReadOnlyMapLike>&&);
 54
 55 void finishCreation(JSC::VM&);
 56};
 57
 58class JSReadOnlyMapLikeOwner : public JSC::WeakHandleOwner {
 59public:
 60 virtual bool isReachableFromOpaqueRoots(JSC::Handle<JSC::Unknown>, void* context, JSC::SlotVisitor&);
 61 virtual void finalize(JSC::Handle<JSC::Unknown>, void* context);
 62};
 63
 64inline JSC::WeakHandleOwner* wrapperOwner(DOMWrapperWorld&, ReadOnlyMapLike*)
 65{
 66 static NeverDestroyed<JSReadOnlyMapLikeOwner> owner;
 67 return &owner.get();
 68}
 69
 70inline void* wrapperKey(ReadOnlyMapLike* wrappableObject)
 71{
 72 return wrappableObject;
 73}
 74
 75JSC::JSValue toJS(JSC::ExecState*, JSDOMGlobalObject*, ReadOnlyMapLike&);
 76inline JSC::JSValue toJS(JSC::ExecState* state, JSDOMGlobalObject* globalObject, ReadOnlyMapLike* impl) { return impl ? toJS(state, globalObject, *impl) : JSC::jsNull(); }
 77JSC::JSValue toJSNewlyCreated(JSC::ExecState*, JSDOMGlobalObject*, Ref<ReadOnlyMapLike>&&);
 78inline JSC::JSValue toJSNewlyCreated(JSC::ExecState* state, JSDOMGlobalObject* globalObject, RefPtr<ReadOnlyMapLike>&& impl) { return impl ? toJSNewlyCreated(state, globalObject, impl.releaseNonNull()) : JSC::jsNull(); }
 79
 80template<> struct JSDOMWrapperConverterTraits<ReadOnlyMapLike> {
 81 using WrapperClass = JSReadOnlyMapLike;
 82 using ToWrappedReturnType = ReadOnlyMapLike*;
 83};
 84
 85} // namespace WebCore

Source/WebCore/bindings/scripts/test/TestMapLike.idl

 1/*
 2 * Copyright (C) 2017 Apple 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 * 1. Redistributions of source code must retain the above copyright
 8 * notice, this list of conditions and the following disclaimer.
 9 * 2. Redistributions in binary form must reproduce the above copyright
 10 * notice, this list of conditions and the following disclaimer in the
 11 * documentation and/or other materials provided with the distribution.
 12 *
 13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
 14 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
 15 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
 17 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 18 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 19 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 20 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 21 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 22 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
 23 * THE POSSIBILITY OF SUCH DAMAGE.
 24 */
 25interface MapLike {
 26 maplike<DOMString, DOMString>;
 27};

Source/WebCore/bindings/scripts/test/TestReadOnlyMapLike.idl

 1/*
 2 * Copyright (C) 2017 Apple 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 * 1. Redistributions of source code must retain the above copyright
 8 * notice, this list of conditions and the following disclaimer.
 9 * 2. Redistributions in binary form must reproduce the above copyright
 10 * notice, this list of conditions and the following disclaimer in the
 11 * documentation and/or other materials provided with the distribution.
 12 *
 13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
 14 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
 15 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
 17 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 18 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 19 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 20 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 21 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 22 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
 23 * THE POSSIBILITY OF SUCH DAMAGE.
 24 */
 25
 26interface ReadOnlyMapLike {
 27 readonly maplike<DOMString, DOMString>;
 28};