Bug 866600 - Avoid using nsIDOMDocument::GetHidden; r=mounir

This commit is contained in:
Ms2ger 2013-05-05 09:03:15 +02:00
parent 634a0652fb
commit 6a31fab03c
3 changed files with 11 additions and 27 deletions

View File

@ -3252,16 +3252,10 @@ void HTMLMediaElement::SuspendOrResumeElement(bool aPauseElement, bool aSuspendE
void HTMLMediaElement::NotifyOwnerDocumentActivityChanged()
{
nsIDocument* ownerDoc = OwnerDoc();
if (UseAudioChannelService()) {
nsCOMPtr<nsIDOMDocument> domDoc = do_QueryInterface(OwnerDoc());
if (domDoc) {
bool hidden = false;
domDoc->GetHidden(&hidden);
// SetVisibilityState will update mChannelSuspended via the CanPlayChanged callback.
if (mPlayingThroughTheAudioChannel && mAudioChannelAgent) {
mAudioChannelAgent->SetVisibilityState(!hidden);
}
}
// SetVisibilityState will update mChannelSuspended via the CanPlayChanged callback.
if (UseAudioChannelService() && mPlayingThroughTheAudioChannel &&
mAudioChannelAgent) {
mAudioChannelAgent->SetVisibilityState(!ownerDoc->Hidden());
}
bool suspendEvents = !ownerDoc->IsActive() || !ownerDoc->IsVisible();
bool pauseElement = suspendEvents || mChannelSuspended;
@ -3729,13 +3723,7 @@ void HTMLMediaElement::UpdateAudioChannelPlayingState()
}
// Use a weak ref so the audio channel agent can't leak |this|.
mAudioChannelAgent->InitWithWeakCallback(mAudioChannelType, this);
nsCOMPtr<nsIDOMDocument> domDoc = do_QueryInterface(OwnerDoc());
if (domDoc) {
bool hidden = false;
domDoc->GetHidden(&hidden);
mAudioChannelAgent->SetVisibilityState(!hidden);
}
mAudioChannelAgent->SetVisibilityState(!OwnerDoc()->Hidden());
}
if (mPlayingThroughTheAudioChannel) {

View File

@ -812,9 +812,7 @@ Navigator::Vibrate(const JS::Value& aPattern, JSContext* cx)
}
gVibrateWindowListener = new VibrateWindowListener(win, doc);
nsCOMPtr<nsIDOMWindow> domWindow =
do_QueryInterface(static_cast<nsIDOMWindow*>(win));
hal::Vibrate(pattern, domWindow);
hal::Vibrate(pattern, win);
return NS_OK;
}

View File

@ -89,17 +89,15 @@ AssertMainProcess()
}
bool
WindowIsActive(nsIDOMWindow *window)
WindowIsActive(nsIDOMWindow* aWindow)
{
nsCOMPtr<nsPIDOMWindow> window = do_QueryInterface(aWindow);
NS_ENSURE_TRUE(window, false);
nsCOMPtr<nsIDOMDocument> doc;
window->GetDocument(getter_AddRefs(doc));
NS_ENSURE_TRUE(doc, false);
nsIDocument* document = window->GetDoc();
NS_ENSURE_TRUE(document, false);
bool hidden = true;
doc->GetHidden(&hidden);
return !hidden;
return !document->Hidden();
}
StaticAutoPtr<WindowIdentifier::IDArrayType> gLastIDToVibrate;