Pass ScriptExecutionContext by reference to from the bindings constructors
https://bugs.webkit.org/show_bug.cgi?id=123575
Reviewed by Andreas Kling.
Since we null check the ScriptExecutionContext before creating the c++ class,
we should be passing by reference.
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@158365 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog
index fb3e734..3047e7f 100644
--- a/Source/WebCore/ChangeLog
+++ b/Source/WebCore/ChangeLog
@@ -1,3 +1,13 @@
+2013-10-31 Sam Weinig <sam@webkit.org>
+
+ Pass ScriptExecutionContext by reference to from the bindings constructors
+ https://bugs.webkit.org/show_bug.cgi?id=123575
+
+ Reviewed by Andreas Kling.
+
+ Since we null check the ScriptExecutionContext before creating the c++ class,
+ we should be passing by reference.
+
2013-10-31 Zhuang Zhigang <zhuangzg@cn.fujitsu.com>
Paint the input tag of range type on WinCE port.
diff --git a/Source/WebCore/Modules/mediasource/MediaSource.cpp b/Source/WebCore/Modules/mediasource/MediaSource.cpp
index 279c529..5b3ff40 100644
--- a/Source/WebCore/Modules/mediasource/MediaSource.cpp
+++ b/Source/WebCore/Modules/mediasource/MediaSource.cpp
@@ -47,14 +47,14 @@
namespace WebCore {
-PassRefPtr<MediaSource> MediaSource::create(ScriptExecutionContext* context)
+PassRefPtr<MediaSource> MediaSource::create(ScriptExecutionContext& context)
{
RefPtr<MediaSource> mediaSource(adoptRef(new MediaSource(context)));
mediaSource->suspendIfNeeded();
return mediaSource.release();
}
-MediaSource::MediaSource(ScriptExecutionContext* context)
+MediaSource::MediaSource(ScriptExecutionContext& context)
: MediaSourceBase(context)
{
LOG(Media, "MediaSource::MediaSource %p", this);
diff --git a/Source/WebCore/Modules/mediasource/MediaSource.h b/Source/WebCore/Modules/mediasource/MediaSource.h
index f7ce8c1..066db6d 100644
--- a/Source/WebCore/Modules/mediasource/MediaSource.h
+++ b/Source/WebCore/Modules/mediasource/MediaSource.h
@@ -43,7 +43,7 @@
class MediaSource : public MediaSourceBase, public ScriptWrappable {
public:
- static PassRefPtr<MediaSource> create(ScriptExecutionContext*);
+ static PassRefPtr<MediaSource> create(ScriptExecutionContext&);
virtual ~MediaSource();
// MediaSource.idl methods
@@ -60,7 +60,7 @@
using RefCounted<MediaSourceBase>::deref;
private:
- explicit MediaSource(ScriptExecutionContext*);
+ explicit MediaSource(ScriptExecutionContext&);
// MediaSourceBase interface
virtual void onReadyStateChange(const AtomicString&, const AtomicString&) OVERRIDE;
diff --git a/Source/WebCore/Modules/mediasource/MediaSourceBase.cpp b/Source/WebCore/Modules/mediasource/MediaSourceBase.cpp
index 95baa27..c4e1d843 100644
--- a/Source/WebCore/Modules/mediasource/MediaSourceBase.cpp
+++ b/Source/WebCore/Modules/mediasource/MediaSourceBase.cpp
@@ -45,8 +45,8 @@
namespace WebCore {
-MediaSourceBase::MediaSourceBase(ScriptExecutionContext* context)
- : ActiveDOMObject(context)
+MediaSourceBase::MediaSourceBase(ScriptExecutionContext& context)
+ : ActiveDOMObject(&context)
, m_readyState(closedKeyword())
, m_asyncEventQueue(*this)
, m_attached(false)
diff --git a/Source/WebCore/Modules/mediasource/MediaSourceBase.h b/Source/WebCore/Modules/mediasource/MediaSourceBase.h
index 15844ae..1e38946 100644
--- a/Source/WebCore/Modules/mediasource/MediaSourceBase.h
+++ b/Source/WebCore/Modules/mediasource/MediaSourceBase.h
@@ -92,7 +92,7 @@
using RefCounted<MediaSourceBase>::deref;
protected:
- explicit MediaSourceBase(ScriptExecutionContext*);
+ explicit MediaSourceBase(ScriptExecutionContext&);
virtual void onReadyStateChange(const AtomicString& oldState, const AtomicString& newState) = 0;
virtual Vector<RefPtr<TimeRanges>> activeRanges() const = 0;
diff --git a/Source/WebCore/Modules/mediastream/AudioStreamTrack.cpp b/Source/WebCore/Modules/mediastream/AudioStreamTrack.cpp
index 9a08271..101b09c 100644
--- a/Source/WebCore/Modules/mediastream/AudioStreamTrack.cpp
+++ b/Source/WebCore/Modules/mediastream/AudioStreamTrack.cpp
@@ -35,27 +35,27 @@
namespace WebCore {
-RefPtr<AudioStreamTrack> AudioStreamTrack::create(ScriptExecutionContext* context, const Dictionary& audioConstraints)
+RefPtr<AudioStreamTrack> AudioStreamTrack::create(ScriptExecutionContext& context, const Dictionary& audioConstraints)
{
return adoptRef(new AudioStreamTrack(context, *MediaStreamTrackPrivate::create(0), &audioConstraints));
}
-RefPtr<AudioStreamTrack> AudioStreamTrack::create(ScriptExecutionContext* context, MediaStreamTrackPrivate& privateTrack)
+RefPtr<AudioStreamTrack> AudioStreamTrack::create(ScriptExecutionContext& context, MediaStreamTrackPrivate& privateTrack)
{
return adoptRef(new AudioStreamTrack(context, privateTrack, 0));
}
-RefPtr<AudioStreamTrack> AudioStreamTrack::create(MediaStreamTrack* track)
+RefPtr<AudioStreamTrack> AudioStreamTrack::create(MediaStreamTrack& track)
{
return adoptRef(new AudioStreamTrack(track));
}
-AudioStreamTrack::AudioStreamTrack(ScriptExecutionContext* context, MediaStreamTrackPrivate& privateTrack, const Dictionary* audioConstraints)
+AudioStreamTrack::AudioStreamTrack(ScriptExecutionContext& context, MediaStreamTrackPrivate& privateTrack, const Dictionary* audioConstraints)
: MediaStreamTrack(context, privateTrack, audioConstraints)
{
}
-AudioStreamTrack::AudioStreamTrack(MediaStreamTrack* track)
+AudioStreamTrack::AudioStreamTrack(MediaStreamTrack& track)
: MediaStreamTrack(track)
{
}
diff --git a/Source/WebCore/Modules/mediastream/AudioStreamTrack.h b/Source/WebCore/Modules/mediastream/AudioStreamTrack.h
index ea9fc9c..bef6ee4 100644
--- a/Source/WebCore/Modules/mediastream/AudioStreamTrack.h
+++ b/Source/WebCore/Modules/mediastream/AudioStreamTrack.h
@@ -39,17 +39,17 @@
class AudioStreamTrack FINAL : public MediaStreamTrack {
public:
- static RefPtr<AudioStreamTrack> create(ScriptExecutionContext*, const Dictionary&);
- static RefPtr<AudioStreamTrack> create(ScriptExecutionContext*, MediaStreamTrackPrivate&);
- static RefPtr<AudioStreamTrack> create(MediaStreamTrack*);
+ static RefPtr<AudioStreamTrack> create(ScriptExecutionContext&, const Dictionary&);
+ static RefPtr<AudioStreamTrack> create(ScriptExecutionContext&, MediaStreamTrackPrivate&);
+ static RefPtr<AudioStreamTrack> create(MediaStreamTrack&);
virtual ~AudioStreamTrack() { }
virtual const AtomicString& kind() const OVERRIDE;
private:
- AudioStreamTrack(ScriptExecutionContext*, MediaStreamTrackPrivate&, const Dictionary*);
- explicit AudioStreamTrack(MediaStreamTrack*);
+ AudioStreamTrack(ScriptExecutionContext&, MediaStreamTrackPrivate&, const Dictionary*);
+ explicit AudioStreamTrack(MediaStreamTrack&);
};
} // namespace WebCore
diff --git a/Source/WebCore/Modules/mediastream/MediaStream.cpp b/Source/WebCore/Modules/mediastream/MediaStream.cpp
index 9a68a1e..7e780c2 100644
--- a/Source/WebCore/Modules/mediastream/MediaStream.cpp
+++ b/Source/WebCore/Modules/mediastream/MediaStream.cpp
@@ -41,12 +41,12 @@
namespace WebCore {
-PassRefPtr<MediaStream> MediaStream::create(ScriptExecutionContext* context)
+PassRefPtr<MediaStream> MediaStream::create(ScriptExecutionContext& context)
{
return MediaStream::create(context, MediaStreamDescriptor::create(MediaStreamSourceVector(), MediaStreamSourceVector()));
}
-PassRefPtr<MediaStream> MediaStream::create(ScriptExecutionContext* context, PassRefPtr<MediaStream> stream)
+PassRefPtr<MediaStream> MediaStream::create(ScriptExecutionContext& context, PassRefPtr<MediaStream> stream)
{
ASSERT(stream);
@@ -62,7 +62,7 @@
return MediaStream::create(context, MediaStreamDescriptor::create(audioTracks, videoTracks));
}
-PassRefPtr<MediaStream> MediaStream::create(ScriptExecutionContext* context, const MediaStreamTrackVector& tracks)
+PassRefPtr<MediaStream> MediaStream::create(ScriptExecutionContext& context, const MediaStreamTrackVector& tracks)
{
Vector<RefPtr<MediaStreamTrackPrivate>> audioTracks;
Vector<RefPtr<MediaStreamTrackPrivate>> videoTracks;
@@ -77,13 +77,13 @@
return MediaStream::create(context, MediaStreamDescriptor::create(audioTracks, videoTracks));
}
-PassRefPtr<MediaStream> MediaStream::create(ScriptExecutionContext* context, PassRefPtr<MediaStreamDescriptor> streamDescriptor)
+PassRefPtr<MediaStream> MediaStream::create(ScriptExecutionContext& context, PassRefPtr<MediaStreamDescriptor> streamDescriptor)
{
return adoptRef(new MediaStream(context, streamDescriptor));
}
-MediaStream::MediaStream(ScriptExecutionContext* context, PassRefPtr<MediaStreamDescriptor> streamDescriptor)
- : ContextDestructionObserver(context)
+MediaStream::MediaStream(ScriptExecutionContext& context, PassRefPtr<MediaStreamDescriptor> streamDescriptor)
+ : ContextDestructionObserver(&context)
, m_descriptor(streamDescriptor)
, m_scheduledEventTimer(this, &MediaStream::scheduledEventTimerFired)
{
@@ -286,11 +286,11 @@
RefPtr<MediaStreamTrack> track;
switch (source->type()) {
case MediaStreamSource::Audio:
- track = AudioStreamTrack::create(scriptExecutionContext(), *MediaStreamTrackPrivate::create(source));
+ track = AudioStreamTrack::create(*scriptExecutionContext(), *MediaStreamTrackPrivate::create(source));
m_audioTracks.append(track);
break;
case MediaStreamSource::Video:
- track = VideoStreamTrack::create(scriptExecutionContext(), *MediaStreamTrackPrivate::create(source));
+ track = VideoStreamTrack::create(*scriptExecutionContext(), *MediaStreamTrackPrivate::create(source));
m_videoTracks.append(track);
break;
case MediaStreamSource::None:
diff --git a/Source/WebCore/Modules/mediastream/MediaStream.h b/Source/WebCore/Modules/mediastream/MediaStream.h
index 2b287b9..466db4b 100644
--- a/Source/WebCore/Modules/mediastream/MediaStream.h
+++ b/Source/WebCore/Modules/mediastream/MediaStream.h
@@ -46,10 +46,10 @@
class MediaStream FINAL : public RefCounted<MediaStream>, public URLRegistrable, public ScriptWrappable, public MediaStreamDescriptorClient, public EventTargetWithInlineData, public ContextDestructionObserver {
public:
- static PassRefPtr<MediaStream> create(ScriptExecutionContext*);
- static PassRefPtr<MediaStream> create(ScriptExecutionContext*, PassRefPtr<MediaStream>);
- static PassRefPtr<MediaStream> create(ScriptExecutionContext*, const MediaStreamTrackVector&);
- static PassRefPtr<MediaStream> create(ScriptExecutionContext*, PassRefPtr<MediaStreamDescriptor>);
+ static PassRefPtr<MediaStream> create(ScriptExecutionContext&);
+ static PassRefPtr<MediaStream> create(ScriptExecutionContext&, PassRefPtr<MediaStream>);
+ static PassRefPtr<MediaStream> create(ScriptExecutionContext&, const MediaStreamTrackVector&);
+ static PassRefPtr<MediaStream> create(ScriptExecutionContext&, PassRefPtr<MediaStreamDescriptor>);
virtual ~MediaStream();
String id() const { return m_descriptor->id(); }
@@ -82,7 +82,7 @@
virtual URLRegistry& registry() const OVERRIDE;
protected:
- MediaStream(ScriptExecutionContext*, PassRefPtr<MediaStreamDescriptor>);
+ MediaStream(ScriptExecutionContext&, PassRefPtr<MediaStreamDescriptor>);
// ContextDestructionObserver
virtual void contextDestroyed() OVERRIDE FINAL;
diff --git a/Source/WebCore/Modules/mediastream/MediaStreamTrack.cpp b/Source/WebCore/Modules/mediastream/MediaStreamTrack.cpp
index dd01e4c..6deabea 100644
--- a/Source/WebCore/Modules/mediastream/MediaStreamTrack.cpp
+++ b/Source/WebCore/Modules/mediastream/MediaStreamTrack.cpp
@@ -51,8 +51,8 @@
namespace WebCore {
-MediaStreamTrack::MediaStreamTrack(ScriptExecutionContext* context, MediaStreamTrackPrivate& privateTrack, const Dictionary* constraints)
- : ActiveDOMObject(context)
+MediaStreamTrack::MediaStreamTrack(ScriptExecutionContext& context, MediaStreamTrackPrivate& privateTrack, const Dictionary* constraints)
+ : ActiveDOMObject(&context)
, m_privateTrack(privateTrack)
, m_eventDispatchScheduled(false)
, m_stoppingTrack(false)
@@ -65,9 +65,9 @@
applyConstraints(*constraints);
}
-MediaStreamTrack::MediaStreamTrack(MediaStreamTrack* other)
- : ActiveDOMObject(other->scriptExecutionContext())
- , m_privateTrack(*other->privateTrack().clone())
+MediaStreamTrack::MediaStreamTrack(MediaStreamTrack& other)
+ : ActiveDOMObject(other.scriptExecutionContext())
+ , m_privateTrack(*other.privateTrack().clone())
, m_eventDispatchScheduled(false)
, m_stoppingTrack(false)
{
@@ -192,9 +192,9 @@
RefPtr<MediaStreamTrack> MediaStreamTrack::clone()
{
if (m_privateTrack->type() == MediaStreamSource::Audio)
- return AudioStreamTrack::create(this);
+ return AudioStreamTrack::create(*this);
- return VideoStreamTrack::create(this);
+ return VideoStreamTrack::create(*this);
}
void MediaStreamTrack::stopProducingData()
diff --git a/Source/WebCore/Modules/mediastream/MediaStreamTrack.h b/Source/WebCore/Modules/mediastream/MediaStreamTrack.h
index 1aef755..9203a07 100644
--- a/Source/WebCore/Modules/mediastream/MediaStreamTrack.h
+++ b/Source/WebCore/Modules/mediastream/MediaStreamTrack.h
@@ -105,8 +105,8 @@
using RefCounted<MediaStreamTrack>::deref;
protected:
- explicit MediaStreamTrack(MediaStreamTrack*);
- MediaStreamTrack(ScriptExecutionContext*, MediaStreamTrackPrivate&, const Dictionary*);
+ explicit MediaStreamTrack(MediaStreamTrack&);
+ MediaStreamTrack(ScriptExecutionContext&, MediaStreamTrackPrivate&, const Dictionary*);
void setSource(PassRefPtr<MediaStreamSource>);
diff --git a/Source/WebCore/Modules/mediastream/RTCPeerConnection.cpp b/Source/WebCore/Modules/mediastream/RTCPeerConnection.cpp
index 0c768d3..ef6097b 100644
--- a/Source/WebCore/Modules/mediastream/RTCPeerConnection.cpp
+++ b/Source/WebCore/Modules/mediastream/RTCPeerConnection.cpp
@@ -114,7 +114,7 @@
return rtcConfiguration.release();
}
-PassRefPtr<RTCPeerConnection> RTCPeerConnection::create(ScriptExecutionContext* context, const Dictionary& rtcConfiguration, const Dictionary& mediaConstraints, ExceptionCode& ec)
+PassRefPtr<RTCPeerConnection> RTCPeerConnection::create(ScriptExecutionContext& context, const Dictionary& rtcConfiguration, const Dictionary& mediaConstraints, ExceptionCode& ec)
{
RefPtr<RTCConfiguration> configuration = parseConfiguration(rtcConfiguration, ec);
if (ec)
@@ -132,17 +132,17 @@
return peerConnection.release();
}
-RTCPeerConnection::RTCPeerConnection(ScriptExecutionContext* context, PassRefPtr<RTCConfiguration> configuration, PassRefPtr<MediaConstraints> constraints, ExceptionCode& ec)
- : ActiveDOMObject(context)
+RTCPeerConnection::RTCPeerConnection(ScriptExecutionContext& context, PassRefPtr<RTCConfiguration> configuration, PassRefPtr<MediaConstraints> constraints, ExceptionCode& ec)
+ : ActiveDOMObject(&context)
, m_signalingState(SignalingStateStable)
, m_iceGatheringState(IceGatheringStateNew)
, m_iceConnectionState(IceConnectionStateNew)
, m_scheduledEventTimer(this, &RTCPeerConnection::scheduledEventTimerFired)
, m_stopped(false)
{
- Document* document = toDocument(m_scriptExecutionContext);
+ Document& document = toDocument(context);
- if (!document->frame()) {
+ if (!document.frame()) {
ec = NOT_SUPPORTED_ERR;
return;
}
@@ -153,7 +153,7 @@
return;
}
- document->frame()->loader().client().dispatchWillStartUsingPeerConnectionHandler(m_peerHandler.get());
+ document.frame()->loader().client().dispatchWillStartUsingPeerConnectionHandler(m_peerHandler.get());
if (!m_peerHandler->initialize(configuration, constraints)) {
ec = NOT_SUPPORTED_ERR;
diff --git a/Source/WebCore/Modules/mediastream/RTCPeerConnection.h b/Source/WebCore/Modules/mediastream/RTCPeerConnection.h
index 2c77ac5..df28244 100644
--- a/Source/WebCore/Modules/mediastream/RTCPeerConnection.h
+++ b/Source/WebCore/Modules/mediastream/RTCPeerConnection.h
@@ -60,7 +60,7 @@
class RTCPeerConnection FINAL : public RefCounted<RTCPeerConnection>, public ScriptWrappable, public RTCPeerConnectionHandlerClient, public EventTargetWithInlineData, public ActiveDOMObject {
public:
- static PassRefPtr<RTCPeerConnection> create(ScriptExecutionContext*, const Dictionary& rtcConfiguration, const Dictionary& mediaConstraints, ExceptionCode&);
+ static PassRefPtr<RTCPeerConnection> create(ScriptExecutionContext&, const Dictionary& rtcConfiguration, const Dictionary& mediaConstraints, ExceptionCode&);
~RTCPeerConnection();
void createOffer(PassRefPtr<RTCSessionDescriptionCallback>, PassRefPtr<RTCErrorCallback>, const Dictionary& mediaConstraints, ExceptionCode&);
@@ -130,7 +130,7 @@
using RefCounted<RTCPeerConnection>::deref;
private:
- RTCPeerConnection(ScriptExecutionContext*, PassRefPtr<RTCConfiguration>, PassRefPtr<MediaConstraints>, ExceptionCode&);
+ RTCPeerConnection(ScriptExecutionContext&, PassRefPtr<RTCConfiguration>, PassRefPtr<MediaConstraints>, ExceptionCode&);
static PassRefPtr<RTCConfiguration> parseConfiguration(const Dictionary& configuration, ExceptionCode&);
void scheduleDispatchEvent(PassRefPtr<Event>);
diff --git a/Source/WebCore/Modules/mediastream/VideoStreamTrack.cpp b/Source/WebCore/Modules/mediastream/VideoStreamTrack.cpp
index de77442..678474b 100644
--- a/Source/WebCore/Modules/mediastream/VideoStreamTrack.cpp
+++ b/Source/WebCore/Modules/mediastream/VideoStreamTrack.cpp
@@ -35,12 +35,12 @@
namespace WebCore {
-RefPtr<VideoStreamTrack> VideoStreamTrack::create(ScriptExecutionContext* context, const Dictionary& videoConstraints)
+RefPtr<VideoStreamTrack> VideoStreamTrack::create(ScriptExecutionContext& context, const Dictionary& videoConstraints)
{
return adoptRef(new VideoStreamTrack(context, *MediaStreamTrackPrivate::create(0), &videoConstraints));
}
-RefPtr<VideoStreamTrack> VideoStreamTrack::create(ScriptExecutionContext* context, MediaStreamTrackPrivate& privateTrack)
+RefPtr<VideoStreamTrack> VideoStreamTrack::create(ScriptExecutionContext& context, MediaStreamTrackPrivate& privateTrack)
{
return adoptRef(new VideoStreamTrack(context, privateTrack, 0));
}
@@ -50,7 +50,7 @@
return adoptRef(new VideoStreamTrack(track));
}
-VideoStreamTrack::VideoStreamTrack(ScriptExecutionContext* context, MediaStreamTrackPrivate& privateTrack, const Dictionary* videoConstraints)
+VideoStreamTrack::VideoStreamTrack(ScriptExecutionContext& context, MediaStreamTrackPrivate& privateTrack, const Dictionary* videoConstraints)
: MediaStreamTrack(context, privateTrack, videoConstraints)
{
}
diff --git a/Source/WebCore/Modules/mediastream/VideoStreamTrack.h b/Source/WebCore/Modules/mediastream/VideoStreamTrack.h
index be041b8..0f97d06 100644
--- a/Source/WebCore/Modules/mediastream/VideoStreamTrack.h
+++ b/Source/WebCore/Modules/mediastream/VideoStreamTrack.h
@@ -40,8 +40,8 @@
class VideoStreamTrack FINAL : public MediaStreamTrack {
public:
- static RefPtr<VideoStreamTrack> create(ScriptExecutionContext*, const Dictionary&);
- static RefPtr<VideoStreamTrack> create(ScriptExecutionContext*, MediaStreamTrackPrivate&);
+ static RefPtr<VideoStreamTrack> create(ScriptExecutionContext&, const Dictionary&);
+ static RefPtr<VideoStreamTrack> create(ScriptExecutionContext&, MediaStreamTrackPrivate&);
static RefPtr<VideoStreamTrack> create(MediaStreamTrack*);
virtual ~VideoStreamTrack() { }
@@ -49,7 +49,7 @@
virtual const AtomicString& kind() const OVERRIDE;
private:
- VideoStreamTrack(ScriptExecutionContext*, MediaStreamTrackPrivate&, const Dictionary*);
+ VideoStreamTrack(ScriptExecutionContext&, MediaStreamTrackPrivate&, const Dictionary*);
explicit VideoStreamTrack(MediaStreamTrack*);
};
diff --git a/Source/WebCore/Modules/notifications/Notification.cpp b/Source/WebCore/Modules/notifications/Notification.cpp
index f629ec7..dee967e 100644
--- a/Source/WebCore/Modules/notifications/Notification.cpp
+++ b/Source/WebCore/Modules/notifications/Notification.cpp
@@ -80,13 +80,13 @@
#endif
#if ENABLE(NOTIFICATIONS)
-Notification::Notification(ScriptExecutionContext* context, const String& title)
- : ActiveDOMObject(context)
+Notification::Notification(ScriptExecutionContext& context, const String& title)
+ : ActiveDOMObject(&context)
, m_title(title)
, m_state(Idle)
, m_taskTimer(adoptPtr(new Timer<Notification>(this, &Notification::taskTimerFired)))
{
- m_notificationCenter = DOMWindowNotifications::webkitNotifications(toDocument(context)->domWindow());
+ m_notificationCenter = DOMWindowNotifications::webkitNotifications(toDocument(context).domWindow());
ASSERT(m_notificationCenter->client());
m_taskTimer->startOneShot(0);
@@ -107,7 +107,7 @@
#endif
#if ENABLE(NOTIFICATIONS)
-PassRefPtr<Notification> Notification::create(ScriptExecutionContext* context, const String& title, const Dictionary& options)
+PassRefPtr<Notification> Notification::create(ScriptExecutionContext& context, const String& title, const Dictionary& options)
{
RefPtr<Notification> notification(adoptRef(new Notification(context, title)));
String argument;
@@ -120,7 +120,7 @@
if (options.get("dir", argument))
notification->setDir(argument);
if (options.get("icon", argument)) {
- URL iconURI = argument.isEmpty() ? URL() : context->completeURL(argument);
+ URL iconURI = argument.isEmpty() ? URL() : context.completeURL(argument);
if (!iconURI.isEmpty() && iconURI.isValid())
notification->setIconURL(iconURI);
}
diff --git a/Source/WebCore/Modules/notifications/Notification.h b/Source/WebCore/Modules/notifications/Notification.h
index f6ff6cf..90bbcd3 100644
--- a/Source/WebCore/Modules/notifications/Notification.h
+++ b/Source/WebCore/Modules/notifications/Notification.h
@@ -71,7 +71,7 @@
static PassRefPtr<Notification> create(const String& title, const String& body, const String& iconURI, ScriptExecutionContext*, ExceptionCode&, PassRefPtr<NotificationCenter> provider);
#endif
#if ENABLE(NOTIFICATIONS)
- static PassRefPtr<Notification> create(ScriptExecutionContext*, const String& title, const Dictionary& options);
+ static PassRefPtr<Notification> create(ScriptExecutionContext&, const String& title, const Dictionary& options);
#endif
virtual ~Notification();
@@ -143,7 +143,7 @@
Notification(const String& title, const String& body, const String& iconURI, ScriptExecutionContext*, ExceptionCode&, PassRefPtr<NotificationCenter>);
#endif
#if ENABLE(NOTIFICATIONS)
- Notification(ScriptExecutionContext*, const String& title);
+ Notification(ScriptExecutionContext&, const String& title);
#endif
void setBody(const String& body) { m_body = body; }
diff --git a/Source/WebCore/Modules/speech/SpeechSynthesisUtterance.cpp b/Source/WebCore/Modules/speech/SpeechSynthesisUtterance.cpp
index 186d446..470fe4b 100644
--- a/Source/WebCore/Modules/speech/SpeechSynthesisUtterance.cpp
+++ b/Source/WebCore/Modules/speech/SpeechSynthesisUtterance.cpp
@@ -30,13 +30,13 @@
namespace WebCore {
-PassRefPtr<SpeechSynthesisUtterance> SpeechSynthesisUtterance::create(ScriptExecutionContext* context, const String& text)
+PassRefPtr<SpeechSynthesisUtterance> SpeechSynthesisUtterance::create(ScriptExecutionContext& context, const String& text)
{
return adoptRef(new SpeechSynthesisUtterance(context, text));
}
-SpeechSynthesisUtterance::SpeechSynthesisUtterance(ScriptExecutionContext* context, const String& text)
- : ContextDestructionObserver(context)
+SpeechSynthesisUtterance::SpeechSynthesisUtterance(ScriptExecutionContext& context, const String& text)
+ : ContextDestructionObserver(&context)
, m_platformUtterance(PlatformSpeechSynthesisUtterance::create(this))
{
m_platformUtterance->setText(text);
diff --git a/Source/WebCore/Modules/speech/SpeechSynthesisUtterance.h b/Source/WebCore/Modules/speech/SpeechSynthesisUtterance.h
index 51ec345..d5415f2 100644
--- a/Source/WebCore/Modules/speech/SpeechSynthesisUtterance.h
+++ b/Source/WebCore/Modules/speech/SpeechSynthesisUtterance.h
@@ -39,7 +39,7 @@
class SpeechSynthesisUtterance FINAL : public PlatformSpeechSynthesisUtteranceClient, public RefCounted<SpeechSynthesisUtterance>, public ContextDestructionObserver, public EventTargetWithInlineData {
public:
- static PassRefPtr<SpeechSynthesisUtterance> create(ScriptExecutionContext*, const String&);
+ static PassRefPtr<SpeechSynthesisUtterance> create(ScriptExecutionContext&, const String&);
~SpeechSynthesisUtterance();
@@ -80,7 +80,7 @@
PlatformSpeechSynthesisUtterance* platformUtterance() const { return m_platformUtterance.get(); }
private:
- SpeechSynthesisUtterance(ScriptExecutionContext*, const String&);
+ SpeechSynthesisUtterance(ScriptExecutionContext&, const String&);
RefPtr<PlatformSpeechSynthesisUtterance> m_platformUtterance;
RefPtr<SpeechSynthesisVoice> m_voice;
diff --git a/Source/WebCore/Modules/webaudio/AudioContext.cpp b/Source/WebCore/Modules/webaudio/AudioContext.cpp
index b3034d3..e2d1947 100644
--- a/Source/WebCore/Modules/webaudio/AudioContext.cpp
+++ b/Source/WebCore/Modules/webaudio/AudioContext.cpp
@@ -107,11 +107,10 @@
const unsigned MaxHardwareContexts = 4;
unsigned AudioContext::s_hardwareContextCount = 0;
-PassRefPtr<AudioContext> AudioContext::create(Document* document, ExceptionCode& ec)
+PassRefPtr<AudioContext> AudioContext::create(Document& document, ExceptionCode& ec)
{
UNUSED_PARAM(ec);
- ASSERT(document);
ASSERT(isMainThread());
if (s_hardwareContextCount >= MaxHardwareContexts)
return 0;
@@ -122,8 +121,8 @@
}
// Constructor for rendering to the audio hardware.
-AudioContext::AudioContext(Document* document)
- : ActiveDOMObject(document)
+AudioContext::AudioContext(Document& document)
+ : ActiveDOMObject(&document)
, m_isStopScheduled(false)
, m_isInitialized(false)
, m_isAudioThreadFinished(false)
@@ -149,8 +148,8 @@
}
// Constructor for offline (non-realtime) rendering.
-AudioContext::AudioContext(Document* document, unsigned numberOfChannels, size_t numberOfFrames, float sampleRate)
- : ActiveDOMObject(document)
+AudioContext::AudioContext(Document& document, unsigned numberOfChannels, size_t numberOfFrames, float sampleRate)
+ : ActiveDOMObject(&document)
, m_isStopScheduled(false)
, m_isInitialized(false)
, m_isAudioThreadFinished(false)
diff --git a/Source/WebCore/Modules/webaudio/AudioContext.h b/Source/WebCore/Modules/webaudio/AudioContext.h
index c8ec098..d41a974 100644
--- a/Source/WebCore/Modules/webaudio/AudioContext.h
+++ b/Source/WebCore/Modules/webaudio/AudioContext.h
@@ -76,7 +76,7 @@
class AudioContext : public ActiveDOMObject, public ThreadSafeRefCounted<AudioContext>, public EventTargetWithInlineData, public MediaCanStartListener {
public:
// Create an AudioContext for rendering to the audio hardware.
- static PassRefPtr<AudioContext> create(Document*, ExceptionCode&);
+ static PassRefPtr<AudioContext> create(Document&, ExceptionCode&);
// Create an AudioContext for offline (non-realtime) rendering.
static PassRefPtr<AudioContext> createOfflineContext(Document*, unsigned numberOfChannels, size_t numberOfFrames, float sampleRate, ExceptionCode&);
@@ -265,8 +265,8 @@
void removeBehaviorRestriction(BehaviorRestrictions restriction) { m_restrictions &= ~restriction; }
protected:
- explicit AudioContext(Document*);
- AudioContext(Document*, unsigned numberOfChannels, size_t numberOfFrames, float sampleRate);
+ explicit AudioContext(Document&);
+ AudioContext(Document&, unsigned numberOfChannels, size_t numberOfFrames, float sampleRate);
static bool isSampleRateRangeGood(float sampleRate);
diff --git a/Source/WebCore/Modules/webaudio/OfflineAudioContext.cpp b/Source/WebCore/Modules/webaudio/OfflineAudioContext.cpp
index 2cdf5f4..50bfeb3 100644
--- a/Source/WebCore/Modules/webaudio/OfflineAudioContext.cpp
+++ b/Source/WebCore/Modules/webaudio/OfflineAudioContext.cpp
@@ -34,15 +34,15 @@
namespace WebCore {
-PassRefPtr<OfflineAudioContext> OfflineAudioContext::create(ScriptExecutionContext* context, unsigned numberOfChannels, size_t numberOfFrames, float sampleRate, ExceptionCode& ec)
+PassRefPtr<OfflineAudioContext> OfflineAudioContext::create(ScriptExecutionContext& context, unsigned numberOfChannels, size_t numberOfFrames, float sampleRate, ExceptionCode& ec)
{
// FIXME: add support for workers.
- if (!context || !context->isDocument()) {
+ if (!context.isDocument()) {
ec = NOT_SUPPORTED_ERR;
return 0;
}
- Document* document = toDocument(context);
+ Document& document = toDocument(context);
if (numberOfChannels > 10 || !isSampleRateRangeGood(sampleRate)) {
ec = SYNTAX_ERR;
@@ -54,7 +54,7 @@
return audioContext.release();
}
-OfflineAudioContext::OfflineAudioContext(Document* document, unsigned numberOfChannels, size_t numberOfFrames, float sampleRate)
+OfflineAudioContext::OfflineAudioContext(Document& document, unsigned numberOfChannels, size_t numberOfFrames, float sampleRate)
: AudioContext(document, numberOfChannels, numberOfFrames, sampleRate)
{
}
diff --git a/Source/WebCore/Modules/webaudio/OfflineAudioContext.h b/Source/WebCore/Modules/webaudio/OfflineAudioContext.h
index beb6bf5..35bbc96 100644
--- a/Source/WebCore/Modules/webaudio/OfflineAudioContext.h
+++ b/Source/WebCore/Modules/webaudio/OfflineAudioContext.h
@@ -31,12 +31,12 @@
class OfflineAudioContext : public AudioContext {
public:
- static PassRefPtr<OfflineAudioContext> create(ScriptExecutionContext*, unsigned numberOfChannels, size_t numberOfFrames, float sampleRate, ExceptionCode&);
+ static PassRefPtr<OfflineAudioContext> create(ScriptExecutionContext&, unsigned numberOfChannels, size_t numberOfFrames, float sampleRate, ExceptionCode&);
virtual ~OfflineAudioContext();
private:
- OfflineAudioContext(Document*, unsigned numberOfChannels, size_t numberOfFrames, float sampleRate);
+ OfflineAudioContext(Document&, unsigned numberOfChannels, size_t numberOfFrames, float sampleRate);
};
} // namespace WebCore
diff --git a/Source/WebCore/Modules/websockets/WebSocket.cpp b/Source/WebCore/Modules/websockets/WebSocket.cpp
index 077a6b6..72b192a 100644
--- a/Source/WebCore/Modules/websockets/WebSocket.cpp
+++ b/Source/WebCore/Modules/websockets/WebSocket.cpp
@@ -141,8 +141,8 @@
return ", ";
}
-WebSocket::WebSocket(ScriptExecutionContext* context)
- : ActiveDOMObject(context)
+WebSocket::WebSocket(ScriptExecutionContext& context)
+ : ActiveDOMObject(&context)
, m_state(CONNECTING)
, m_bufferedAmount(0)
, m_bufferedAmountAfterClose(0)
@@ -158,20 +158,20 @@
m_channel->disconnect();
}
-PassRefPtr<WebSocket> WebSocket::create(ScriptExecutionContext* context)
+PassRefPtr<WebSocket> WebSocket::create(ScriptExecutionContext& context)
{
RefPtr<WebSocket> webSocket(adoptRef(new WebSocket(context)));
webSocket->suspendIfNeeded();
return webSocket.release();
}
-PassRefPtr<WebSocket> WebSocket::create(ScriptExecutionContext* context, const String& url, ExceptionCode& ec)
+PassRefPtr<WebSocket> WebSocket::create(ScriptExecutionContext& context, const String& url, ExceptionCode& ec)
{
Vector<String> protocols;
return WebSocket::create(context, url, protocols, ec);
}
-PassRefPtr<WebSocket> WebSocket::create(ScriptExecutionContext* context, const String& url, const Vector<String>& protocols, ExceptionCode& ec)
+PassRefPtr<WebSocket> WebSocket::create(ScriptExecutionContext& context, const String& url, const Vector<String>& protocols, ExceptionCode& ec)
{
if (url.isNull()) {
ec = SYNTAX_ERR;
@@ -181,14 +181,14 @@
RefPtr<WebSocket> webSocket(adoptRef(new WebSocket(context)));
webSocket->suspendIfNeeded();
- webSocket->connect(context->completeURL(url), protocols, ec);
+ webSocket->connect(context.completeURL(url), protocols, ec);
if (ec)
return 0;
return webSocket.release();
}
-PassRefPtr<WebSocket> WebSocket::create(ScriptExecutionContext* context, const String& url, const String& protocol, ExceptionCode& ec)
+PassRefPtr<WebSocket> WebSocket::create(ScriptExecutionContext& context, const String& url, const String& protocol, ExceptionCode& ec)
{
Vector<String> protocols;
protocols.append(protocol);
diff --git a/Source/WebCore/Modules/websockets/WebSocket.h b/Source/WebCore/Modules/websockets/WebSocket.h
index 96ac5b5..689c2ef 100644
--- a/Source/WebCore/Modules/websockets/WebSocket.h
+++ b/Source/WebCore/Modules/websockets/WebSocket.h
@@ -55,10 +55,10 @@
static void setIsAvailable(bool);
static bool isAvailable();
static const char* subProtocolSeperator();
- static PassRefPtr<WebSocket> create(ScriptExecutionContext*);
- static PassRefPtr<WebSocket> create(ScriptExecutionContext*, const String& url, ExceptionCode&);
- static PassRefPtr<WebSocket> create(ScriptExecutionContext*, const String& url, const String& protocol, ExceptionCode&);
- static PassRefPtr<WebSocket> create(ScriptExecutionContext*, const String& url, const Vector<String>& protocols, ExceptionCode&);
+ static PassRefPtr<WebSocket> create(ScriptExecutionContext&);
+ static PassRefPtr<WebSocket> create(ScriptExecutionContext&, const String& url, ExceptionCode&);
+ static PassRefPtr<WebSocket> create(ScriptExecutionContext&, const String& url, const String& protocol, ExceptionCode&);
+ static PassRefPtr<WebSocket> create(ScriptExecutionContext&, const String& url, const Vector<String>& protocols, ExceptionCode&);
virtual ~WebSocket();
enum State {
@@ -113,7 +113,7 @@
virtual void didClose(unsigned long unhandledBufferedAmount, ClosingHandshakeCompletionStatus, unsigned short code, const String& reason) OVERRIDE;
private:
- explicit WebSocket(ScriptExecutionContext*);
+ explicit WebSocket(ScriptExecutionContext&);
// ActiveDOMObject functions.
virtual void contextDestroyed() OVERRIDE;
diff --git a/Source/WebCore/bindings/js/JSAudioContextCustom.cpp b/Source/WebCore/bindings/js/JSAudioContextCustom.cpp
index 2c8198c..e195ddf 100644
--- a/Source/WebCore/bindings/js/JSAudioContextCustom.cpp
+++ b/Source/WebCore/bindings/js/JSAudioContextCustom.cpp
@@ -55,7 +55,7 @@
if (!scriptExecutionContext->isDocument())
return throwVMError(exec, createReferenceError(exec, "AudioContext constructor called in a script execution context which is not a document"));
- Document* document = toDocument(scriptExecutionContext);
+ Document& document = toDocument(*scriptExecutionContext);
RefPtr<AudioContext> audioContext;
@@ -73,7 +73,7 @@
#if ENABLE(LEGACY_WEB_AUDIO)
// Constructor for offline (render-target) AudioContext which renders into an AudioBuffer.
// new AudioContext(in unsigned long numberOfChannels, in unsigned long numberOfFrames, in float sampleRate);
- document->addConsoleMessage(JSMessageSource, WarningMessageLevel,
+ document.addConsoleMessage(JSMessageSource, WarningMessageLevel,
"Deprecated AudioContext constructor: use OfflineAudioContext instead");
if (exec->argumentCount() < 3)
diff --git a/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm b/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm
index c197907..e0da3fc 100644
--- a/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm
+++ b/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm
@@ -4024,8 +4024,8 @@
my $numParameters = @{$function->parameters};
my ($dummy, $paramIndex) = GenerateParametersCheck($outputArray, $function, $interface, $numParameters, $interfaceName, "constructorCallback", undef, undef, undef);
- if ($codeGenerator->ExtendedAttributeContains($interface->extendedAttributes->{"ConstructorCallWith"}, "ScriptExecutionContext")) {
- push(@constructorArgList, "context");
+ if ($codeGenerator->ExtendedAttributeContains($interface->extendedAttributes->{"ConstructorCallWith"}, "ScriptExecutionContext") ) {
+ push(@constructorArgList, "*context");
push(@$outputArray, " ScriptExecutionContext* context = castedThis->scriptExecutionContext();\n");
push(@$outputArray, " if (!context)\n");
push(@$outputArray, " return throwVMError(exec, createReferenceError(exec, \"${interfaceName} constructor associated document is unavailable\"));\n");
diff --git a/Source/WebCore/bindings/scripts/test/JS/JSTestInterface.cpp b/Source/WebCore/bindings/scripts/test/JS/JSTestInterface.cpp
index 95199dd..a6b23267 100644
--- a/Source/WebCore/bindings/scripts/test/JS/JSTestInterface.cpp
+++ b/Source/WebCore/bindings/scripts/test/JS/JSTestInterface.cpp
@@ -147,7 +147,7 @@
ScriptExecutionContext* context = castedThis->scriptExecutionContext();
if (!context)
return throwVMError(exec, createReferenceError(exec, "TestInterface constructor associated document is unavailable"));
- RefPtr<TestInterface> object = TestInterface::create(context, str1, str2, ec);
+ RefPtr<TestInterface> object = TestInterface::create(*context, str1, str2, ec);
if (ec) {
setDOMException(exec, ec);
return JSValue::encode(JSValue());
diff --git a/Source/WebCore/dom/Document.h b/Source/WebCore/dom/Document.h
index 03b12fe..5789858 100644
--- a/Source/WebCore/dom/Document.h
+++ b/Source/WebCore/dom/Document.h
@@ -1618,6 +1618,18 @@
Element* eventTargetElementForDocument(Document*);
+inline Document& toDocument(ScriptExecutionContext& scriptExecutionContext)
+{
+ ASSERT_WITH_SECURITY_IMPLICATION(scriptExecutionContext.isDocument());
+ return static_cast<Document&>(scriptExecutionContext);
+}
+
+inline const Document& toDocument(const ScriptExecutionContext& scriptExecutionContext)
+{
+ ASSERT_WITH_SECURITY_IMPLICATION(scriptExecutionContext.isDocument());
+ return static_cast<const Document&>(scriptExecutionContext);
+}
+
inline Document* toDocument(ScriptExecutionContext* scriptExecutionContext)
{
ASSERT_WITH_SECURITY_IMPLICATION(!scriptExecutionContext || scriptExecutionContext->isDocument());
diff --git a/Source/WebCore/dom/MessageChannel.cpp b/Source/WebCore/dom/MessageChannel.cpp
index 73c016fb..04d64d8 100644
--- a/Source/WebCore/dom/MessageChannel.cpp
+++ b/Source/WebCore/dom/MessageChannel.cpp
@@ -32,9 +32,9 @@
namespace WebCore {
-MessageChannel::MessageChannel(ScriptExecutionContext* context)
- : m_port1(MessagePort::create(*context))
- , m_port2(MessagePort::create(*context))
+MessageChannel::MessageChannel(ScriptExecutionContext& context)
+ : m_port1(MessagePort::create(context))
+ , m_port2(MessagePort::create(context))
{
MessagePortChannel::createChannel(m_port1.get(), m_port2.get());
}
diff --git a/Source/WebCore/dom/MessageChannel.h b/Source/WebCore/dom/MessageChannel.h
index 3d6579b..5236dea 100644
--- a/Source/WebCore/dom/MessageChannel.h
+++ b/Source/WebCore/dom/MessageChannel.h
@@ -38,14 +38,14 @@
class MessageChannel : public RefCounted<MessageChannel> {
public:
- static PassRefPtr<MessageChannel> create(ScriptExecutionContext* context) { return adoptRef(new MessageChannel(context)); }
+ static PassRefPtr<MessageChannel> create(ScriptExecutionContext& context) { return adoptRef(new MessageChannel(context)); }
~MessageChannel();
MessagePort* port1() const { return m_port1.get(); }
MessagePort* port2() const { return m_port2.get(); }
private:
- explicit MessageChannel(ScriptExecutionContext*);
+ explicit MessageChannel(ScriptExecutionContext&);
RefPtr<MessagePort> m_port1;
RefPtr<MessagePort> m_port2;
diff --git a/Source/WebCore/fileapi/FileReader.cpp b/Source/WebCore/fileapi/FileReader.cpp
index 7989626..4647dd8 100644
--- a/Source/WebCore/fileapi/FileReader.cpp
+++ b/Source/WebCore/fileapi/FileReader.cpp
@@ -48,15 +48,15 @@
static const double progressNotificationIntervalMS = 50;
-PassRefPtr<FileReader> FileReader::create(ScriptExecutionContext* context)
+PassRefPtr<FileReader> FileReader::create(ScriptExecutionContext& context)
{
RefPtr<FileReader> fileReader(adoptRef(new FileReader(context)));
fileReader->suspendIfNeeded();
return fileReader.release();
}
-FileReader::FileReader(ScriptExecutionContext* context)
- : ActiveDOMObject(context)
+FileReader::FileReader(ScriptExecutionContext& context)
+ : ActiveDOMObject(&context)
, m_state(EMPTY)
, m_aborting(false)
, m_readType(FileReaderLoader::ReadAsBinaryString)
diff --git a/Source/WebCore/fileapi/FileReader.h b/Source/WebCore/fileapi/FileReader.h
index 47d2df6..5be150a 100644
--- a/Source/WebCore/fileapi/FileReader.h
+++ b/Source/WebCore/fileapi/FileReader.h
@@ -55,7 +55,7 @@
class FileReader FINAL : public RefCounted<FileReader>, public ActiveDOMObject, public EventTargetWithInlineData, public FileReaderLoaderClient {
public:
- static PassRefPtr<FileReader> create(ScriptExecutionContext*);
+ static PassRefPtr<FileReader> create(ScriptExecutionContext&);
virtual ~FileReader();
@@ -101,7 +101,7 @@
DEFINE_ATTRIBUTE_EVENT_LISTENER(loadend);
private:
- explicit FileReader(ScriptExecutionContext*);
+ explicit FileReader(ScriptExecutionContext&);
// ActiveDOMObject
virtual bool canSuspend() const OVERRIDE;
diff --git a/Source/WebCore/html/HTMLMediaElement.cpp b/Source/WebCore/html/HTMLMediaElement.cpp
index 534c612..f3b16b5 100644
--- a/Source/WebCore/html/HTMLMediaElement.cpp
+++ b/Source/WebCore/html/HTMLMediaElement.cpp
@@ -4936,7 +4936,7 @@
}
// Otherwise, let controller be a newly created MediaController.
- setController(MediaController::create(Node::scriptExecutionContext()));
+ setController(MediaController::create(document()));
}
MediaController* HTMLMediaElement::controller() const
diff --git a/Source/WebCore/html/MediaController.cpp b/Source/WebCore/html/MediaController.cpp
index 246d314..0fa7c24 100644
--- a/Source/WebCore/html/MediaController.cpp
+++ b/Source/WebCore/html/MediaController.cpp
@@ -38,12 +38,12 @@
using namespace WebCore;
-PassRefPtr<MediaController> MediaController::create(ScriptExecutionContext* context)
+PassRefPtr<MediaController> MediaController::create(ScriptExecutionContext& context)
{
return adoptRef(new MediaController(context));
}
-MediaController::MediaController(ScriptExecutionContext* context)
+MediaController::MediaController(ScriptExecutionContext& context)
: m_paused(false)
, m_defaultPlaybackRate(1)
, m_volume(1)
diff --git a/Source/WebCore/html/MediaController.h b/Source/WebCore/html/MediaController.h
index 7034ac6..b4ed1b6 100644
--- a/Source/WebCore/html/MediaController.h
+++ b/Source/WebCore/html/MediaController.h
@@ -45,7 +45,7 @@
class MediaController FINAL : public RefCounted<MediaController>, public MediaControllerInterface, public EventTargetWithInlineData {
public:
- static PassRefPtr<MediaController> create(ScriptExecutionContext*);
+ static PassRefPtr<MediaController> create(ScriptExecutionContext&);
virtual ~MediaController();
void addMediaElement(HTMLMediaElement*);
@@ -114,7 +114,7 @@
using RefCounted<MediaController>::deref;
private:
- explicit MediaController(ScriptExecutionContext*);
+ explicit MediaController(ScriptExecutionContext&);
void reportControllerState();
void updateReadyState();
void updatePlaybackState();
@@ -132,7 +132,7 @@
virtual void refEventTarget() OVERRIDE { ref(); }
virtual void derefEventTarget() OVERRIDE { deref(); }
virtual EventTargetInterface eventTargetInterface() const OVERRIDE { return MediaControllerEventTargetInterfaceType; }
- virtual ScriptExecutionContext* scriptExecutionContext() const OVERRIDE { return m_scriptExecutionContext; };
+ virtual ScriptExecutionContext* scriptExecutionContext() const OVERRIDE { return &m_scriptExecutionContext; };
friend class HTMLMediaElement;
friend class MediaControllerEventListener;
@@ -150,7 +150,7 @@
String m_mediaGroup;
bool m_closedCaptionsVisible;
std::unique_ptr<Clock> m_clock;
- ScriptExecutionContext* m_scriptExecutionContext;
+ ScriptExecutionContext& m_scriptExecutionContext;
Timer<MediaController> m_timeupdateTimer;
double m_previousTimeupdateTime;
};
diff --git a/Source/WebCore/html/track/InbandGenericTextTrack.cpp b/Source/WebCore/html/track/InbandGenericTextTrack.cpp
index f10c770..c486c11 100644
--- a/Source/WebCore/html/track/InbandGenericTextTrack.cpp
+++ b/Source/WebCore/html/track/InbandGenericTextTrack.cpp
@@ -150,7 +150,7 @@
if (m_cueMap.find(cueData.get()))
return;
- RefPtr<TextTrackCueGeneric> cue = TextTrackCueGeneric::create(scriptExecutionContext(), cueData->startTime(), cueData->endTime(), cueData->content());
+ RefPtr<TextTrackCueGeneric> cue = TextTrackCueGeneric::create(*scriptExecutionContext(), cueData->startTime(), cueData->endTime(), cueData->content());
updateCueFromCueData(cue.get(), cueData.get());
if (hasCue(cue.get(), TextTrackCue::IgnoreDuration)) {
LOG(Media, "InbandGenericTextTrack::addGenericCue ignoring already added cue: start=%.2f, end=%.2f, content=\"%s\"\n", cueData->startTime(), cueData->endTime(), cueData->content().utf8().data());
diff --git a/Source/WebCore/html/track/InbandWebVTTTextTrack.cpp b/Source/WebCore/html/track/InbandWebVTTTextTrack.cpp
index 28a79ad..d4ac780 100644
--- a/Source/WebCore/html/track/InbandWebVTTTextTrack.cpp
+++ b/Source/WebCore/html/track/InbandWebVTTTextTrack.cpp
@@ -64,7 +64,7 @@
m_webVTTParser->getNewCues(cues);
for (size_t i = 0; i < cues.size(); ++i) {
RefPtr<WebVTTCueData> cueData = cues[i];
- RefPtr<TextTrackCue> cue = TextTrackCue::create(scriptExecutionContext(), cueData->startTime(), cueData->endTime(), cueData->content());
+ RefPtr<TextTrackCue> cue = TextTrackCue::create(*scriptExecutionContext(), cueData->startTime(), cueData->endTime(), cueData->content());
cue->setId(cueData->id());
cue->setCueSettings(cueData->settings());
diff --git a/Source/WebCore/html/track/TextTrackCue.cpp b/Source/WebCore/html/track/TextTrackCue.cpp
index d8538ef..0e309f7 100644
--- a/Source/WebCore/html/track/TextTrackCue.cpp
+++ b/Source/WebCore/html/track/TextTrackCue.cpp
@@ -183,7 +183,7 @@
// ----------------------------
-TextTrackCue::TextTrackCue(ScriptExecutionContext* context, double start, double end, const String& content)
+TextTrackCue::TextTrackCue(ScriptExecutionContext& context, double start, double end, const String& content)
: m_startTime(start)
, m_endTime(end)
, m_content(content)
@@ -201,11 +201,11 @@
, m_isActive(false)
, m_pauseOnExit(false)
, m_snapToLines(true)
- , m_cueBackgroundBox(HTMLSpanElement::create(spanTag, *toDocument(context)))
+ , m_cueBackgroundBox(HTMLSpanElement::create(spanTag, toDocument(context)))
, m_displayTreeShouldChange(true)
, m_displayDirection(CSSValueLtr)
{
- ASSERT(m_scriptExecutionContext->isDocument());
+ ASSERT(m_scriptExecutionContext.isDocument());
// 4. If the text track cue writing direction is horizontal, then let
// writing-mode be 'horizontal-tb'. Otherwise, if the text track cue writing
@@ -500,7 +500,7 @@
void TextTrackCue::createWebVTTNodeTree()
{
if (!m_webVTTNodeTree)
- m_webVTTNodeTree = WebVTTParser::create(0, m_scriptExecutionContext)->createDocumentFragmentFromCueText(m_content);
+ m_webVTTNodeTree = WebVTTParser::create(0, &m_scriptExecutionContext)->createDocumentFragmentFromCueText(m_content);
}
void TextTrackCue::copyWebVTTNodeToDOMTree(ContainerNode* webVTTNode, ContainerNode* parent)
@@ -764,7 +764,7 @@
if (child->nodeName() == timestampTag) {
unsigned position = 0;
String timestamp = child->nodeValue();
- double currentTimestamp = WebVTTParser::create(0, m_scriptExecutionContext)->collectTimeStamp(timestamp, &position);
+ double currentTimestamp = WebVTTParser::create(0, &m_scriptExecutionContext)->collectTimeStamp(timestamp, &position);
ASSERT(currentTimestamp != -1);
if (currentTimestamp > movieTime)
diff --git a/Source/WebCore/html/track/TextTrackCue.h b/Source/WebCore/html/track/TextTrackCue.h
index 9a926d8..04c16a2 100644
--- a/Source/WebCore/html/track/TextTrackCue.h
+++ b/Source/WebCore/html/track/TextTrackCue.h
@@ -73,7 +73,7 @@
class TextTrackCue : public RefCounted<TextTrackCue>, public EventTargetWithInlineData {
public:
- static PassRefPtr<TextTrackCue> create(ScriptExecutionContext* context, double start, double end, const String& content)
+ static PassRefPtr<TextTrackCue> create(ScriptExecutionContext& context, double start, double end, const String& content)
{
return adoptRef(new TextTrackCue(context, start, end, content));
}
@@ -154,7 +154,7 @@
std::pair<double, double> getPositionCoordinates() const;
virtual EventTargetInterface eventTargetInterface() const OVERRIDE FINAL { return TextTrackCueEventTargetInterfaceType; }
- virtual ScriptExecutionContext* scriptExecutionContext() const OVERRIDE FINAL { return m_scriptExecutionContext; }
+ virtual ScriptExecutionContext* scriptExecutionContext() const OVERRIDE FINAL { return &m_scriptExecutionContext; }
std::pair<double, double> getCSSPosition() const;
@@ -203,9 +203,9 @@
using RefCounted<TextTrackCue>::deref;
protected:
- TextTrackCue(ScriptExecutionContext*, double start, double end, const String& content);
+ TextTrackCue(ScriptExecutionContext&, double start, double end, const String& content);
- Document& ownerDocument() { return *toDocument(m_scriptExecutionContext); }
+ Document& ownerDocument() { return toDocument(m_scriptExecutionContext); }
virtual PassRefPtr<TextTrackCueBox> createDisplayTree();
TextTrackCueBox* displayTreeInternal();
@@ -254,7 +254,7 @@
RefPtr<DocumentFragment> m_webVTTNodeTree;
TextTrack* m_track;
- ScriptExecutionContext* m_scriptExecutionContext;
+ ScriptExecutionContext& m_scriptExecutionContext;
bool m_isActive;
bool m_pauseOnExit;
diff --git a/Source/WebCore/html/track/TextTrackCueGeneric.cpp b/Source/WebCore/html/track/TextTrackCueGeneric.cpp
index e484f5c..454dd05 100644
--- a/Source/WebCore/html/track/TextTrackCueGeneric.cpp
+++ b/Source/WebCore/html/track/TextTrackCueGeneric.cpp
@@ -109,7 +109,7 @@
setInlineStyleProperty(CSSPropertyWordBreak, CSSValueNormal);
}
-TextTrackCueGeneric::TextTrackCueGeneric(ScriptExecutionContext* context, double start, double end, const String& content)
+TextTrackCueGeneric::TextTrackCueGeneric(ScriptExecutionContext& context, double start, double end, const String& content)
: TextTrackCue(context, start, end, content)
, m_baseFontSizeRelativeToVideoHeight(0)
, m_fontSizeMultiplier(0)
diff --git a/Source/WebCore/html/track/TextTrackCueGeneric.h b/Source/WebCore/html/track/TextTrackCueGeneric.h
index 12d4ca2..d0c97f2 100644
--- a/Source/WebCore/html/track/TextTrackCueGeneric.h
+++ b/Source/WebCore/html/track/TextTrackCueGeneric.h
@@ -36,9 +36,9 @@
class GenericCueData;
// A "generic" cue is a non-WebVTT cue, so it is not positioned/sized with the WebVTT logic.
-class TextTrackCueGeneric : public TextTrackCue {
+class TextTrackCueGeneric FINAL : public TextTrackCue {
public:
- static PassRefPtr<TextTrackCueGeneric> create(ScriptExecutionContext* context, double start, double end, const String& content)
+ static PassRefPtr<TextTrackCueGeneric> create(ScriptExecutionContext& context, double start, double end, const String& content)
{
return adoptRef(new TextTrackCueGeneric(context, start, end, content));
}
@@ -79,7 +79,7 @@
private:
virtual bool isOrderedBefore(const TextTrackCue*) const OVERRIDE;
- TextTrackCueGeneric(ScriptExecutionContext*, double start, double end, const String&);
+ TextTrackCueGeneric(ScriptExecutionContext&, double start, double end, const String&);
Color m_foregroundColor;
Color m_backgroundColor;
diff --git a/Source/WebCore/inspector/InspectorResourceAgent.cpp b/Source/WebCore/inspector/InspectorResourceAgent.cpp
index 921805fc..17b0d3a 100644
--- a/Source/WebCore/inspector/InspectorResourceAgent.cpp
+++ b/Source/WebCore/inspector/InspectorResourceAgent.cpp
@@ -593,7 +593,7 @@
void InspectorResourceAgent::replayXHR(ErrorString*, const String& requestId)
{
- RefPtr<XMLHttpRequest> xhr = XMLHttpRequest::create(m_pageAgent->mainFrame()->document());
+ RefPtr<XMLHttpRequest> xhr = XMLHttpRequest::create(*m_pageAgent->mainFrame()->document());
String actualRequestId = requestId;
XHRReplayData* xhrReplayData = m_resourcesData->xhrReplayData(requestId);
diff --git a/Source/WebCore/loader/TextTrackLoader.cpp b/Source/WebCore/loader/TextTrackLoader.cpp
index d67db32..157b929 100644
--- a/Source/WebCore/loader/TextTrackLoader.cpp
+++ b/Source/WebCore/loader/TextTrackLoader.cpp
@@ -217,7 +217,7 @@
m_cueParser->getNewCues(newCues);
for (size_t i = 0; i < newCues.size(); ++i) {
RefPtr<WebVTTCueData> data = newCues[i];
- RefPtr<TextTrackCue> cue = TextTrackCue::create(m_scriptExecutionContext, data->startTime(), data->endTime(), data->content());
+ RefPtr<TextTrackCue> cue = TextTrackCue::create(*m_scriptExecutionContext, data->startTime(), data->endTime(), data->content());
cue->setId(data->id());
cue->setCueSettings(data->settings());
outputCues.append(cue);
diff --git a/Source/WebCore/page/EventSource.cpp b/Source/WebCore/page/EventSource.cpp
index 5928c0e..3ffc12b 100644
--- a/Source/WebCore/page/EventSource.cpp
+++ b/Source/WebCore/page/EventSource.cpp
@@ -59,8 +59,8 @@
const unsigned long long EventSource::defaultReconnectDelay = 3000;
-inline EventSource::EventSource(ScriptExecutionContext* context, const URL& url, const Dictionary& eventSourceInit)
- : ActiveDOMObject(context)
+inline EventSource::EventSource(ScriptExecutionContext& context, const URL& url, const Dictionary& eventSourceInit)
+ : ActiveDOMObject(&context)
, m_url(url)
, m_withCredentials(false)
, m_state(CONNECTING)
@@ -73,14 +73,14 @@
eventSourceInit.get("withCredentials", m_withCredentials);
}
-PassRefPtr<EventSource> EventSource::create(ScriptExecutionContext* context, const String& url, const Dictionary& eventSourceInit, ExceptionCode& ec)
+PassRefPtr<EventSource> EventSource::create(ScriptExecutionContext& context, const String& url, const Dictionary& eventSourceInit, ExceptionCode& ec)
{
if (url.isEmpty()) {
ec = SYNTAX_ERR;
return 0;
}
- URL fullURL = context->completeURL(url);
+ URL fullURL = context.completeURL(url);
if (!fullURL.isValid()) {
ec = SYNTAX_ERR;
return 0;
@@ -88,11 +88,11 @@
// FIXME: Convert this to check the isolated world's Content Security Policy once webkit.org/b/104520 is solved.
bool shouldBypassMainWorldContentSecurityPolicy = false;
- if (context->isDocument()) {
- Document* document = toDocument(context);
- shouldBypassMainWorldContentSecurityPolicy = document->frame()->script().shouldBypassMainWorldContentSecurityPolicy();
+ if (context.isDocument()) {
+ Document& document = toDocument(context);
+ shouldBypassMainWorldContentSecurityPolicy = document.frame()->script().shouldBypassMainWorldContentSecurityPolicy();
}
- if (!shouldBypassMainWorldContentSecurityPolicy && !context->contentSecurityPolicy()->allowConnectToSource(fullURL)) {
+ if (!shouldBypassMainWorldContentSecurityPolicy && !context.contentSecurityPolicy()->allowConnectToSource(fullURL)) {
// FIXME: Should this be throwing an exception?
ec = SECURITY_ERR;
return 0;
diff --git a/Source/WebCore/page/EventSource.h b/Source/WebCore/page/EventSource.h
index fb7d9bd..cebc73a 100644
--- a/Source/WebCore/page/EventSource.h
+++ b/Source/WebCore/page/EventSource.h
@@ -51,7 +51,7 @@
class EventSource FINAL : public RefCounted<EventSource>, public EventTargetWithInlineData, private ThreadableLoaderClient, public ActiveDOMObject {
WTF_MAKE_FAST_ALLOCATED;
public:
- static PassRefPtr<EventSource> create(ScriptExecutionContext*, const String& url, const Dictionary&, ExceptionCode&);
+ static PassRefPtr<EventSource> create(ScriptExecutionContext&, const String& url, const Dictionary&, ExceptionCode&);
virtual ~EventSource();
static const unsigned long long defaultReconnectDelay;
@@ -79,7 +79,7 @@
virtual ScriptExecutionContext* scriptExecutionContext() const OVERRIDE { return ActiveDOMObject::scriptExecutionContext(); }
private:
- EventSource(ScriptExecutionContext*, const URL&, const Dictionary&);
+ EventSource(ScriptExecutionContext&, const URL&, const Dictionary&);
virtual void refEventTarget() OVERRIDE { ref(); }
virtual void derefEventTarget() OVERRIDE { deref(); }
diff --git a/Source/WebCore/workers/SharedWorker.cpp b/Source/WebCore/workers/SharedWorker.cpp
index 7fb9df3..634b4d0 100644
--- a/Source/WebCore/workers/SharedWorker.cpp
+++ b/Source/WebCore/workers/SharedWorker.cpp
@@ -64,7 +64,7 @@
RefPtr<SharedWorker> worker = adoptRef(new SharedWorker(context));
- RefPtr<MessageChannel> channel = MessageChannel::create(&context);
+ RefPtr<MessageChannel> channel = MessageChannel::create(context);
worker->m_port = channel->port1();
OwnPtr<MessagePortChannel> remotePort = channel->port2()->disentangle();
ASSERT(remotePort);
diff --git a/Source/WebCore/xml/XMLHttpRequest.cpp b/Source/WebCore/xml/XMLHttpRequest.cpp
index 2f9bbbc..48825e2 100644
--- a/Source/WebCore/xml/XMLHttpRequest.cpp
+++ b/Source/WebCore/xml/XMLHttpRequest.cpp
@@ -165,7 +165,7 @@
context->addConsoleMessage(JSMessageSource, ErrorMessageLevel, message);
}
-PassRefPtr<XMLHttpRequest> XMLHttpRequest::create(ScriptExecutionContext* context)
+PassRefPtr<XMLHttpRequest> XMLHttpRequest::create(ScriptExecutionContext& context)
{
RefPtr<XMLHttpRequest> xmlHttpRequest(adoptRef(new XMLHttpRequest(context)));
xmlHttpRequest->suspendIfNeeded();
@@ -173,8 +173,8 @@
return xmlHttpRequest.release();
}
-XMLHttpRequest::XMLHttpRequest(ScriptExecutionContext* context)
- : ActiveDOMObject(context)
+XMLHttpRequest::XMLHttpRequest(ScriptExecutionContext& context)
+ : ActiveDOMObject(&context)
, m_async(true)
, m_includeCredentials(false)
#if ENABLE(XHR_TIMEOUT)
diff --git a/Source/WebCore/xml/XMLHttpRequest.h b/Source/WebCore/xml/XMLHttpRequest.h
index 5f4220f..8925d2d 100644
--- a/Source/WebCore/xml/XMLHttpRequest.h
+++ b/Source/WebCore/xml/XMLHttpRequest.h
@@ -54,7 +54,7 @@
class XMLHttpRequest FINAL : public ScriptWrappable, public RefCounted<XMLHttpRequest>, public EventTargetWithInlineData, private ThreadableLoaderClient, public ActiveDOMObject {
WTF_MAKE_FAST_ALLOCATED;
public:
- static PassRefPtr<XMLHttpRequest> create(ScriptExecutionContext*);
+ static PassRefPtr<XMLHttpRequest> create(ScriptExecutionContext&);
~XMLHttpRequest();
// These exact numeric values are important because JS expects them.
@@ -158,7 +158,7 @@
using RefCounted<XMLHttpRequest>::deref;
private:
- explicit XMLHttpRequest(ScriptExecutionContext*);
+ explicit XMLHttpRequest(ScriptExecutionContext&);
// ActiveDOMObject
virtual void contextDestroyed() OVERRIDE;