зеркало из https://github.com/mozilla/gecko-dev.git
Bug 950659 - Remove nsIDOMMediaQueryList and nsIDOMMediaQueryListListener; r=bzbarsky
X-Git-Commit-ID: 8584a27a3b3f2a749273cf6c56057b0276854f3b
This commit is contained in:
Родитель
c652354cb3
Коммит
256bf7e59c
|
@ -209,7 +209,6 @@
|
|||
#include "mozilla/dom/FunctionBinding.h"
|
||||
#include "mozilla/dom/WindowBinding.h"
|
||||
#include "nsITabChild.h"
|
||||
#include "nsIDOMMediaQueryList.h"
|
||||
#include "mozilla/dom/MediaQueryList.h"
|
||||
#include "mozilla/dom/ScriptSettings.h"
|
||||
|
||||
|
@ -5053,11 +5052,10 @@ nsGlobalWindow::MatchMedia(const nsAString& aMediaQueryList,
|
|||
|
||||
NS_IMETHODIMP
|
||||
nsGlobalWindow::MatchMedia(const nsAString& aMediaQueryList,
|
||||
nsIDOMMediaQueryList** aResult)
|
||||
nsISupports** aResult)
|
||||
{
|
||||
ErrorResult rv;
|
||||
nsCOMPtr<nsIDOMMediaQueryList> mediaQueryList =
|
||||
MatchMedia(aMediaQueryList, rv);
|
||||
nsRefPtr<MediaQueryList> mediaQueryList = MatchMedia(aMediaQueryList, rv);
|
||||
mediaQueryList.forget(aResult);
|
||||
|
||||
return rv.ErrorCode();
|
||||
|
|
|
@ -22,7 +22,6 @@ XPIDL_SOURCES += [
|
|||
'nsIDOMHistory.idl',
|
||||
'nsIDOMJSWindow.idl',
|
||||
'nsIDOMLocation.idl',
|
||||
'nsIDOMMediaQueryList.idl',
|
||||
'nsIDOMModalContentWindow.idl',
|
||||
'nsIDOMNavigator.idl',
|
||||
'nsIDOMPkcs11.idl',
|
||||
|
|
|
@ -1,26 +0,0 @@
|
|||
/* vim: set shiftwidth=2 tabstop=8 autoindent cindent expandtab: */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "domstubs.idl"
|
||||
|
||||
interface nsIDOMMediaQueryListListener;
|
||||
|
||||
/* see http://dev.w3.org/csswg/cssom-view/#the-mediaquerylist-interface */
|
||||
|
||||
[scriptable, uuid(e0e49c52-915b-40f9-9cba-6026305cdf3e)]
|
||||
interface nsIDOMMediaQueryList : nsISupports
|
||||
{
|
||||
readonly attribute DOMString media;
|
||||
readonly attribute boolean matches;
|
||||
|
||||
void addListener(in nsIDOMMediaQueryListListener listener);
|
||||
void removeListener(in nsIDOMMediaQueryListListener listener);
|
||||
};
|
||||
|
||||
[scriptable, function, uuid(279a5cbd-5c15-475d-847b-e0de1624eb77)]
|
||||
interface nsIDOMMediaQueryListListener : nsISupports
|
||||
{
|
||||
void handleChange(in nsIDOMMediaQueryList mql);
|
||||
};
|
|
@ -9,7 +9,6 @@ interface nsIFrameRequestCallback;
|
|||
interface nsIControllers;
|
||||
interface nsIDOMBlob;
|
||||
interface nsIDOMLocation;
|
||||
interface nsIDOMMediaQueryList;
|
||||
interface nsIDOMOfflineResourceList;
|
||||
interface nsIDOMStorage;
|
||||
interface nsIPrompt;
|
||||
|
@ -265,7 +264,7 @@ interface nsIDOMWindow : nsISupports
|
|||
|
||||
// CSSOM-View
|
||||
// http://dev.w3.org/csswg/cssom-view/#extensions-to-the-window-interface
|
||||
nsIDOMMediaQueryList matchMedia(in DOMString media_query_list);
|
||||
nsISupports matchMedia(in DOMString media_query_list);
|
||||
|
||||
readonly attribute nsIDOMScreen screen;
|
||||
|
||||
|
|
|
@ -1858,14 +1858,8 @@ nsPresContext::MediaFeatureValuesChanged(StyleRebuildType aShouldRebuild,
|
|||
if (pusher.RePush(et)) {
|
||||
nsAutoMicroTask mt;
|
||||
MediaQueryList::HandleChangeData &d = notifyList[i];
|
||||
if (d.listener) {
|
||||
d.listener->HandleChange(d.mql);
|
||||
} else if (d.callback) {
|
||||
ErrorResult result;
|
||||
d.callback->Call(*d.mql, result);
|
||||
} else {
|
||||
MOZ_ASSERT(false, "How come we have no listener or callback?");
|
||||
}
|
||||
ErrorResult result;
|
||||
d.callback->Call(*d.mql, result);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -65,7 +65,6 @@ struct nsFontFaceRuleContainer;
|
|||
class nsObjectFrame;
|
||||
class nsTransitionManager;
|
||||
class nsAnimationManager;
|
||||
class nsIDOMMediaQueryList;
|
||||
class nsRefreshDriver;
|
||||
class nsIWidget;
|
||||
class nsDeviceContext;
|
||||
|
|
|
@ -39,7 +39,6 @@ NS_IMPL_CYCLE_COLLECTION_CLASS(MediaQueryList)
|
|||
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(MediaQueryList)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mPresContext)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mListeners)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mCallbacks)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_SCRIPT_OBJECTS
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
|
||||
|
@ -57,7 +56,6 @@ NS_IMPL_CYCLE_COLLECTION_TRACE_WRAPPERCACHE(MediaQueryList)
|
|||
|
||||
NS_INTERFACE_MAP_BEGIN(MediaQueryList)
|
||||
NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
|
||||
NS_INTERFACE_MAP_ENTRY(nsIDOMMediaQueryList)
|
||||
NS_INTERFACE_MAP_ENTRY(nsISupports)
|
||||
NS_INTERFACE_MAP_ENTRIES_CYCLE_COLLECTION(MediaQueryList)
|
||||
NS_INTERFACE_MAP_END
|
||||
|
@ -65,18 +63,10 @@ NS_INTERFACE_MAP_END
|
|||
NS_IMPL_CYCLE_COLLECTING_ADDREF(MediaQueryList)
|
||||
NS_IMPL_CYCLE_COLLECTING_RELEASE(MediaQueryList)
|
||||
|
||||
NS_IMETHODIMP
|
||||
void
|
||||
MediaQueryList::GetMedia(nsAString &aMedia)
|
||||
{
|
||||
mMediaList->GetText(aMedia);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
MediaQueryList::GetMatches(bool *aMatches)
|
||||
{
|
||||
*aMatches = Matches();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
bool
|
||||
|
@ -91,36 +81,6 @@ MediaQueryList::Matches()
|
|||
return mMatches;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
MediaQueryList::AddListener(nsIDOMMediaQueryListListener *aListener)
|
||||
{
|
||||
if (!aListener) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
if (!HasListeners()) {
|
||||
// When we have listeners, the pres context owns a reference to
|
||||
// this. This is a cyclic reference that can only be broken by
|
||||
// cycle collection.
|
||||
NS_ADDREF_THIS();
|
||||
}
|
||||
|
||||
if (!mMatchesValid) {
|
||||
NS_ABORT_IF_FALSE(!HasListeners(),
|
||||
"when listeners present, must keep mMatches current");
|
||||
RecomputeMatches();
|
||||
}
|
||||
|
||||
if (!mListeners.Contains(aListener)) {
|
||||
mListeners.AppendElement(aListener);
|
||||
if (!HasListeners()) {
|
||||
// Append failed; undo the AddRef above.
|
||||
NS_RELEASE_THIS();
|
||||
}
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
void
|
||||
MediaQueryList::AddListener(MediaQueryListListener& aListener)
|
||||
{
|
||||
|
@ -151,21 +111,6 @@ MediaQueryList::AddListener(MediaQueryListListener& aListener)
|
|||
}
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
MediaQueryList::RemoveListener(nsIDOMMediaQueryListListener *aListener)
|
||||
{
|
||||
bool removed = mListeners.RemoveElement(aListener);
|
||||
NS_ABORT_IF_FALSE(!mListeners.Contains(aListener),
|
||||
"duplicate occurrence of listeners");
|
||||
|
||||
if (removed && !HasListeners()) {
|
||||
// See NS_ADDREF_THIS() in AddListener.
|
||||
NS_RELEASE_THIS();
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
void
|
||||
MediaQueryList::RemoveListener(MediaQueryListListener& aListener)
|
||||
{
|
||||
|
@ -185,7 +130,6 @@ void
|
|||
MediaQueryList::RemoveAllListeners()
|
||||
{
|
||||
bool hadListeners = HasListeners();
|
||||
mListeners.Clear();
|
||||
mCallbacks.Clear();
|
||||
if (hadListeners) {
|
||||
// See NS_ADDREF_THIS() in AddListener.
|
||||
|
@ -213,13 +157,6 @@ MediaQueryList::MediumFeaturesChanged(NotifyList &aListenersToNotify)
|
|||
bool oldMatches = mMatches;
|
||||
RecomputeMatches();
|
||||
if (mMatches != oldMatches) {
|
||||
for (uint32_t i = 0, i_end = mListeners.Length(); i != i_end; ++i) {
|
||||
HandleChangeData *d = aListenersToNotify.AppendElement();
|
||||
if (d) {
|
||||
d->mql = this;
|
||||
d->listener = mListeners[i];
|
||||
}
|
||||
}
|
||||
for (uint32_t i = 0, i_end = mCallbacks.Length(); i != i_end; ++i) {
|
||||
HandleChangeData *d = aListenersToNotify.AppendElement();
|
||||
if (d) {
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
#ifndef mozilla_dom_MediaQueryList_h
|
||||
#define mozilla_dom_MediaQueryList_h
|
||||
|
||||
#include "nsIDOMMediaQueryList.h"
|
||||
#include "nsISupports.h"
|
||||
#include "nsCycleCollectionParticipant.h"
|
||||
#include "nsAutoPtr.h"
|
||||
#include "nsCOMPtr.h"
|
||||
|
@ -24,7 +24,7 @@ class nsMediaList;
|
|||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
class MediaQueryList MOZ_FINAL : public nsIDOMMediaQueryList,
|
||||
class MediaQueryList MOZ_FINAL : public nsISupports,
|
||||
public nsWrapperCache,
|
||||
public PRCList
|
||||
{
|
||||
|
@ -40,31 +40,27 @@ public:
|
|||
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
|
||||
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(MediaQueryList)
|
||||
|
||||
NS_DECL_NSIDOMMEDIAQUERYLIST
|
||||
|
||||
nsISupports* GetParentObject() const;
|
||||
|
||||
struct HandleChangeData {
|
||||
nsRefPtr<MediaQueryList> mql;
|
||||
nsCOMPtr<nsIDOMMediaQueryListListener> listener;
|
||||
nsCOMPtr<mozilla::dom::MediaQueryListListener> callback;
|
||||
};
|
||||
|
||||
typedef FallibleTArray< nsCOMPtr<nsIDOMMediaQueryListListener> > ListenerList;
|
||||
typedef FallibleTArray< nsRefPtr<mozilla::dom::MediaQueryListListener> > CallbackList;
|
||||
typedef FallibleTArray<HandleChangeData> NotifyList;
|
||||
|
||||
// Appends listeners that need notification to aListenersToNotify
|
||||
void MediumFeaturesChanged(NotifyList &aListenersToNotify);
|
||||
|
||||
bool HasListeners() const { return !mListeners.IsEmpty() || !mCallbacks.IsEmpty(); }
|
||||
bool HasListeners() const { return !mCallbacks.IsEmpty(); }
|
||||
|
||||
void RemoveAllListeners();
|
||||
|
||||
JSObject* WrapObject(JSContext* aCx, JS::Handle<JSObject*> aScope) MOZ_OVERRIDE;
|
||||
|
||||
// WebIDL methods
|
||||
// The XPCOM GetMedia method is good
|
||||
void GetMedia(nsAString& aMedia);
|
||||
bool Matches();
|
||||
void AddListener(mozilla::dom::MediaQueryListListener& aListener);
|
||||
void RemoveListener(mozilla::dom::MediaQueryListListener& aListener);
|
||||
|
@ -91,7 +87,6 @@ private:
|
|||
nsRefPtr<nsMediaList> mMediaList;
|
||||
bool mMatches;
|
||||
bool mMatchesValid;
|
||||
ListenerList mListeners;
|
||||
CallbackList mCallbacks;
|
||||
};
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче