Bug 894104 - Part 3: remove TextTrackCue's mGlobal. r=bz

From 095c76c72dd5915b2fa8ec74f4e2b0b45de244f1 Mon Sep 17 00:00:00 2001
Since we keep a document reference we no longer need the
separate global. It was only used in GetParentObject() and
we can return nullptr there (meaning 'use whatever magic global')
or return the document instead, which is what this patch does.
This commit is contained in:
Ralph Giles 2013-07-18 15:01:48 -07:00
parent 86c975913d
commit 05565a4994
2 changed files with 10 additions and 14 deletions

View File

@ -17,8 +17,7 @@
namespace mozilla {
namespace dom {
NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE_5(TextTrackCue,
mGlobal,
NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE_4(TextTrackCue,
mDocument,
mTrack,
mTrackElement,
@ -47,8 +46,7 @@ TextTrackCue::TextTrackCue(nsISupports* aGlobal,
double aEndTime,
const nsAString& aText,
ErrorResult& aRv)
: mGlobal(aGlobal)
, mText(aText)
: mText(aText)
, mStartTime(aStartTime)
, mEndTime(aEndTime)
, mHead(nullptr)
@ -57,7 +55,7 @@ TextTrackCue::TextTrackCue(nsISupports* aGlobal,
SetDefaultCueSettings();
MOZ_ASSERT(aGlobal);
SetIsDOMBinding();
if (NS_FAILED(StashDocument())) {
if (NS_FAILED(StashDocument(aGlobal))) {
aRv.Throw(NS_ERROR_DOM_INVALID_STATE_ERR);
}
}
@ -69,8 +67,7 @@ TextTrackCue::TextTrackCue(nsISupports* aGlobal,
HTMLTrackElement* aTrackElement,
webvtt_node* head,
ErrorResult& aRv)
: mGlobal(aGlobal)
, mText(aText)
: mText(aText)
, mStartTime(aStartTime)
, mEndTime(aEndTime)
, mTrackElement(aTrackElement)
@ -81,7 +78,7 @@ TextTrackCue::TextTrackCue(nsISupports* aGlobal,
SetDefaultCueSettings();
MOZ_ASSERT(aGlobal);
SetIsDOMBinding();
if (NS_FAILED(StashDocument())) {
if (NS_FAILED(StashDocument(aGlobal))) {
aRv.Throw(NS_ERROR_DOM_INVALID_STATE_ERR);
}
}
@ -97,9 +94,9 @@ TextTrackCue::~TextTrackCue()
* even when unlinked during discard/teardown.
*/
nsresult
TextTrackCue::StashDocument()
TextTrackCue::StashDocument(nsISupports* aGlobal)
{
nsCOMPtr<nsPIDOMWindow> window(do_QueryInterface(mGlobal));
nsCOMPtr<nsPIDOMWindow> window(do_QueryInterface(aGlobal));
if (!window) {
return NS_ERROR_NO_INTERFACE;
}

View File

@ -54,9 +54,9 @@ public:
virtual JSObject* WrapObject(JSContext* aCx,
JS::Handle<JSObject*> aScope) MOZ_OVERRIDE;
nsISupports* GetParentObject()
nsINode* GetParentObject()
{
return mGlobal;
return mDocument;
}
TextTrack* GetTrack() const
@ -322,9 +322,8 @@ private:
void CueChanged();
void SetDefaultCueSettings();
void CreateCueOverlay();
nsresult StashDocument();
nsresult StashDocument(nsISupports* aGlobal);
nsCOMPtr<nsISupports> mGlobal;
nsRefPtr<nsIDocument> mDocument;
nsString mText;
double mStartTime;