Bug 1427512 - Part 20: Remove nsIDOMMediaList. r=xidorn,jryans,bz
MozReview-Commit-ID: KKnTf7aFfjA
--- a/devtools/server/actors/object.js
+++ b/devtools/server/actors/object.js
@@ -1762,20 +1762,20 @@ DebuggerServer.ObjectActorPreviewers.Obj
return true;
},
function ArrayLike({obj, hooks}, grip, rawObj) {
if (isWorker || !rawObj ||
obj.class != "DOMStringList" &&
obj.class != "DOMTokenList" &&
obj.class != "CSSRuleList" &&
+ obj.class != "MediaList" &&
!(rawObj instanceof Ci.nsIDOMMozNamedAttrMap ||
rawObj instanceof Ci.nsIDOMCSSValueList ||
rawObj instanceof Ci.nsIDOMFileList ||
- rawObj instanceof Ci.nsIDOMMediaList ||
rawObj instanceof Ci.nsIDOMNodeList ||
rawObj instanceof Ci.nsIDOMStyleSheetList)) {
return false;
}
if (typeof rawObj.length != "number") {
return false;
}
--- a/dom/interfaces/base/domstubs.idl
+++ b/dom/interfaces/base/domstubs.idl
@@ -38,17 +38,16 @@ namespace dom {
class DOMException;
}
}
%}
// Style Sheets
interface nsIDOMStyleSheetList;
interface nsIDOMStyleSheet;
-interface nsIDOMMediaList;
// Base
interface nsIDOMWindow;
interface nsIDOMWindowCollection;
interface nsIDOMNavigator;
interface nsIDOMScreen;
// Events
--- a/dom/interfaces/stylesheets/moz.build
+++ b/dom/interfaces/stylesheets/moz.build
@@ -3,15 +3,14 @@
# 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/.
with Files("**"):
BUG_COMPONENT = ("Core", "DOM: CSS Object Model")
XPIDL_SOURCES += [
- 'nsIDOMMediaList.idl',
'nsIDOMStyleSheet.idl',
'nsIDOMStyleSheetList.idl',
]
XPIDL_MODULE = 'dom_stylesheets'
deleted file mode 100644
--- a/dom/interfaces/stylesheets/nsIDOMMediaList.idl
+++ /dev/null
@@ -1,28 +0,0 @@
-/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* 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"
-
-/**
- * The nsIDOMMediaList interface is a datatype for a list of media
- * types in the Document Object Model.
- *
- * For more information on this interface please see
- * http://www.w3.org/TR/DOM-Level-2-Style
- */
-
-[uuid(9b0c2ed7-111c-4824-adf9-ef0da6dad371)]
-interface nsIDOMMediaList : nsISupports
-{
- attribute DOMString mediaText;
- // raises(DOMException) on setting
-
- readonly attribute unsigned long length;
- DOMString item(in unsigned long index);
- void deleteMedium(in DOMString oldMedium)
- raises(DOMException);
- void appendMedium(in DOMString newMedium)
- raises(DOMException);
-};
--- a/dom/interfaces/stylesheets/nsIDOMStyleSheet.idl
+++ b/dom/interfaces/stylesheets/nsIDOMStyleSheet.idl
@@ -17,10 +17,9 @@
interface nsIDOMStyleSheet : nsISupports
{
readonly attribute DOMString type;
attribute boolean disabled;
readonly attribute nsIDOMNode ownerNode;
readonly attribute nsIDOMStyleSheet parentStyleSheet;
readonly attribute DOMString href;
readonly attribute DOMString title;
- readonly attribute nsIDOMMediaList media;
};
--- a/layout/style/CSSStyleSheet.cpp
+++ b/layout/style/CSSStyleSheet.cpp
@@ -20,17 +20,16 @@
#include "nsIDocument.h"
#include "nsPresContext.h"
#include "nsGkAtoms.h"
#include "nsQueryObject.h"
#include "nsString.h"
#include "nsStyleSet.h"
#include "nsTArray.h"
#include "mozilla/dom/CSSRuleList.h"
-#include "nsIDOMMediaList.h"
#include "nsIDOMNode.h"
#include "nsError.h"
#include "nsCSSParser.h"
#include "mozilla/css/Loader.h"
#include "nsNameSpaceManager.h"
#include "nsXMLNameSpaceMap.h"
#include "nsCOMPtr.h"
#include "nsContentUtils.h"
--- a/layout/style/MediaList.cpp
+++ b/layout/style/MediaList.cpp
@@ -15,17 +15,16 @@
#include "nsCSSParser.h"
#include "nsMediaList.h"
namespace mozilla {
namespace dom {
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(MediaList)
NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
- NS_INTERFACE_MAP_ENTRY(nsIDOMMediaList)
NS_INTERFACE_MAP_ENTRY(nsISupports)
NS_INTERFACE_MAP_END
NS_IMPL_CYCLE_COLLECTING_ADDREF(MediaList)
NS_IMPL_CYCLE_COLLECTING_RELEASE(MediaList)
NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE_0(MediaList)
@@ -83,55 +82,44 @@ MediaList::Create(
}
nsCSSParser parser;
RefPtr<nsMediaList> mediaList = new nsMediaList();
parser.ParseMediaList(aMedia, nullptr, 0, mediaList, aCallerType);
return mediaList.forget();
}
-NS_IMETHODIMP
+void
MediaList::GetMediaText(nsAString& aMediaText)
{
GetText(aMediaText);
- return NS_OK;
}
-NS_IMETHODIMP
+void
MediaList::SetMediaText(const nsAString& aMediaText)
{
- return DoMediaChange([&]() {
+ DoMediaChange([&]() {
SetText(aMediaText);
return NS_OK;
});
}
-NS_IMETHODIMP
-MediaList::GetLength(uint32_t* aLength)
-{
- NS_ENSURE_ARG_POINTER(aLength);
-
- *aLength = Length();
- return NS_OK;
-}
-
-NS_IMETHODIMP
+void
MediaList::Item(uint32_t aIndex, nsAString& aReturn)
{
bool dummy;
IndexedGetter(aIndex, dummy, aReturn);
- return NS_OK;
}
-NS_IMETHODIMP
-MediaList::DeleteMedium(const nsAString& aOldMedium)
+void
+MediaList::DeleteMedium(const nsAString& aOldMedium, ErrorResult& aRv)
{
- return DoMediaChange([&]() { return Delete(aOldMedium); });
+ aRv = DoMediaChange([&]() { return Delete(aOldMedium); });
}
-NS_IMETHODIMP
-MediaList::AppendMedium(const nsAString& aNewMedium)
+void
+MediaList::AppendMedium(const nsAString& aNewMedium, ErrorResult& aRv)
{
- return DoMediaChange([&]() { return Append(aNewMedium); });
+ aRv = DoMediaChange([&]() { return Append(aNewMedium); });
}
} // namespace dom
} // namespace mozilla
--- a/layout/style/MediaList.h
+++ b/layout/style/MediaList.h
@@ -8,17 +8,16 @@
#ifndef mozilla_dom_MediaList_h
#define mozilla_dom_MediaList_h
#include "mozilla/ErrorResult.h"
#include "mozilla/ServoUtils.h"
#include "mozilla/StyleBackendType.h"
-#include "nsIDOMMediaList.h"
#include "nsWrapperCache.h"
class nsIDocument;
class nsPresContext;
class nsMediaQueryResultCacheKey;
namespace mozilla {
class StyleSheet;
@@ -28,17 +27,17 @@ namespace dom {
// XXX This class doesn't use the branch dispatch approach that we use
// elsewhere for stylo, but instead just relies on virtual call.
// That's because this class should not be critical to performance,
// and using branch dispatch would make it much more complicated.
// Performance critical path should hold a subclass of this class
// directly. We may want to determine in the future whether the
// above is correct.
-class MediaList : public nsIDOMMediaList
+class MediaList : public nsISupports
, public nsWrapperCache
{
public:
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(MediaList)
/**
* Creates a MediaList backed by the given StyleBackendType.
@@ -58,32 +57,25 @@ public:
virtual bool Matches(nsPresContext* aPresContext) const = 0;
#ifdef DEBUG
virtual bool IsServo() const = 0;
#endif
void SetStyleSheet(StyleSheet* aSheet);
- NS_DECL_NSIDOMMEDIALIST
-
// WebIDL
- // XPCOM GetMediaText and SetMediaText are fine.
+ void GetMediaText(nsAString& aMediaText);
+ void SetMediaText(const nsAString& aMediaText);
virtual uint32_t Length() = 0;
virtual void IndexedGetter(uint32_t aIndex, bool& aFound,
nsAString& aReturn) = 0;
- // XPCOM Item is fine.
- void DeleteMedium(const nsAString& aMedium, ErrorResult& aRv)
- {
- aRv = DeleteMedium(aMedium);
- }
- void AppendMedium(const nsAString& aMedium, ErrorResult& aRv)
- {
- aRv = AppendMedium(aMedium);
- }
+ void Item(uint32_t aIndex, nsAString& aResult);
+ void DeleteMedium(const nsAString& aMedium, ErrorResult& aRv);
+ void AppendMedium(const nsAString& aMedium, ErrorResult& aRv);
protected:
virtual nsresult Delete(const nsAString& aOldMedium) = 0;
virtual nsresult Append(const nsAString& aNewMedium) = 0;
virtual ~MediaList() {
MOZ_ASSERT(!mStyleSheet, "Backpointer should have been cleared");
}
--- a/layout/style/ServoMediaRule.cpp
+++ b/layout/style/ServoMediaRule.cpp
@@ -96,17 +96,17 @@ ServoMediaRule::GetConditionText(nsAStri
{
Media()->GetMediaText(aConditionText);
}
void
ServoMediaRule::SetConditionText(const nsAString& aConditionText,
ErrorResult& aRv)
{
- aRv = Media()->SetMediaText(aConditionText);
+ Media()->SetMediaText(aConditionText);
}
/* virtual */ void
ServoMediaRule::GetCssTextImpl(nsAString& aCssText) const
{
Servo_MediaRule_GetCssText(mRawRule, &aCssText);
}
--- a/layout/style/StyleSheet.cpp
+++ b/layout/style/StyleSheet.cpp
@@ -372,23 +372,16 @@ StyleSheet::GetTitle(nsAString& aTitle)
NS_IMETHODIMP
StyleSheet::GetParentStyleSheet(nsIDOMStyleSheet** aParentStyleSheet)
{
NS_ENSURE_ARG_POINTER(aParentStyleSheet);
NS_IF_ADDREF(*aParentStyleSheet = GetParentStyleSheet());
return NS_OK;
}
-NS_IMETHODIMP
-StyleSheet::GetMedia(nsIDOMMediaList** aMedia)
-{
- NS_ADDREF(*aMedia = Media());
- return NS_OK;
-}
-
void
StyleSheet::WillDirty()
{
if (mInner->mComplete) {
EnsureUniqueInner();
}
}
--- a/layout/style/StyleSheet.h
+++ b/layout/style/StyleSheet.h
@@ -240,17 +240,16 @@ public:
// nsIDOMStyleSheet interface
NS_IMETHOD GetType(nsAString& aType) final;
NS_IMETHOD GetDisabled(bool* aDisabled) final;
NS_IMETHOD SetDisabled(bool aDisabled) final;
NS_IMETHOD GetOwnerNode(nsIDOMNode** aOwnerNode) final;
NS_IMETHOD GetParentStyleSheet(nsIDOMStyleSheet** aParentStyleSheet) final;
NS_IMETHOD GetHref(nsAString& aHref) final;
NS_IMETHOD GetTitle(nsAString& aTitle) final;
- NS_IMETHOD GetMedia(nsIDOMMediaList** aMedia) final;
// Changes to sheets should be inside of a WillDirty-DidDirty pair.
// However, the calls do not need to be matched; it's ok to call
// WillDirty and then make no change and skip the DidDirty call.
void WillDirty();
virtual void DidDirty() {}
// Called when a rule changes from CSSOM.
--- a/layout/style/nsCSSRules.cpp
+++ b/layout/style/nsCSSRules.cpp
@@ -328,28 +328,21 @@ MediaRule::GetConditionText(nsAString& a
AppendConditionText(aConditionText);
}
void
MediaRule::SetConditionText(const nsAString& aConditionText,
ErrorResult& aRv)
{
if (!mMedia) {
- RefPtr<nsMediaList> media = new nsMediaList();
- media->SetStyleSheet(GetStyleSheet());
- nsresult rv = media->SetMediaText(aConditionText);
- if (NS_SUCCEEDED(rv)) {
- mMedia = media;
- } else {
- aRv.Throw(rv);
- }
- return;
+ mMedia = new nsMediaList();
+ mMedia->SetStyleSheet(GetStyleSheet());
}
- aRv = mMedia->SetMediaText(aConditionText);
+ mMedia->SetMediaText(aConditionText);
}
// GroupRule interface
/* virtual */ bool
MediaRule::UseForPresentation(nsPresContext* aPresContext,
nsMediaQueryResultCacheKey& aKey)
{
if (mMedia) {
--- a/xpcom/reflect/xptinfo/ShimInterfaceInfo.cpp
+++ b/xpcom/reflect/xptinfo/ShimInterfaceInfo.cpp
@@ -45,17 +45,16 @@
#include "nsIDOMGeoPositionError.h"
#include "nsIDOMHistory.h"
#include "nsIDOMHTMLDocument.h"
#include "nsIDOMHTMLElement.h"
#include "nsIDOMHTMLFormElement.h"
#include "nsIDOMHTMLInputElement.h"
#include "nsIDOMHTMLMediaElement.h"
#include "nsIDOMKeyEvent.h"
-#include "nsIDOMMediaList.h"
#include "nsIDOMMouseEvent.h"
#include "nsIDOMMouseScrollEvent.h"
#include "nsIDOMMutationEvent.h"
#include "nsIDOMMozNamedAttrMap.h"
#include "nsIDOMNode.h"
#include "nsIDOMNodeIterator.h"
#include "nsIDOMNodeList.h"
#include "nsIDOMNotifyPaintEvent.h"
@@ -290,17 +289,16 @@ const ComponentsInterfaceShimEntry kComp
DEFINE_SHIM(History),
DEFINE_SHIM(HTMLDocument),
DEFINE_SHIM(HTMLElement),
DEFINE_SHIM(HTMLFormElement),
DEFINE_SHIM(HTMLInputElement),
DEFINE_SHIM(HTMLMediaElement),
DEFINE_SHIM(KeyEvent),
DEFINE_SHIM_WITH_CUSTOM_INTERFACE(nsIListBoxObject, ListBoxObject),
- DEFINE_SHIM(MediaList),
DEFINE_SHIM_WITH_CUSTOM_INTERFACE(nsIMenuBoxObject, MenuBoxObject),
DEFINE_SHIM(MouseEvent),
DEFINE_SHIM(MouseScrollEvent),
DEFINE_SHIM(MutationEvent),
DEFINE_SHIM_WITH_CUSTOM_INTERFACE(nsIDOMMozNamedAttrMap, NamedNodeMap),
DEFINE_SHIM(NodeIterator),
DEFINE_SHIM(NodeList),
DEFINE_SHIM(Node),