Bug 1325878: Simplify MediaList creation. r?xidorn
MozReview-Commit-ID: Jre50YpuD7F
--- a/dom/html/HTMLSourceElement.cpp
+++ b/dom/html/HTMLSourceElement.cpp
@@ -70,31 +70,32 @@ HTMLSourceElement::WouldMatchMediaForDoc
{
if (aMedia.IsEmpty()) {
return true;
}
nsIPresShell* presShell = aDocument->GetShell();
nsPresContext* pctx = presShell ? presShell->GetPresContext() : nullptr;
- RefPtr<MediaList> mediaList = MediaList::Create(*aDocument, aMedia);
+ RefPtr<MediaList> mediaList =
+ MediaList::Create(aDocument->GetStyleBackendType(), aMedia);
return pctx && mediaList->Matches(*pctx, nullptr);
}
void
HTMLSourceElement::UpdateMediaList(const nsAttrValue* aValue)
{
mMediaList = nullptr;
nsString mediaStr;
if (!aValue || (mediaStr = aValue->GetStringValue()).IsEmpty()) {
return;
}
nsCSSParser cssParser;
- mMediaList = MediaList::Create(*OwnerDoc(), mediaStr);
+ mMediaList = MediaList::Create(OwnerDoc()->GetStyleBackendType(), mediaStr);
}
nsresult
HTMLSourceElement::AfterSetAttr(int32_t aNameSpaceID, nsIAtom* aName,
const nsAttrValue* aValue, bool aNotify)
{
// If we are associated with a <picture> with a valid <img>, notify it of
// responsive parameter changes
--- a/layout/style/MediaList.cpp
+++ b/layout/style/MediaList.cpp
@@ -67,25 +67,17 @@ MediaList::DoMediaChange(Func aCallback)
/* XXXldb Pass something meaningful? */
if (doc) {
doc->StyleRuleChanged(mStyleSheet, nullptr);
}
return rv;
}
/* static */ already_AddRefed<MediaList>
-MediaList::Create(const nsIDocument& aDocument,
- const nsAString& aMedia)
-{
- return Create(aDocument.GetStyleBackendType(), aMedia);
-}
-
-/* static */ already_AddRefed<MediaList>
-MediaList::Create(StyleBackendType aBackendType,
- const nsAString& aMedia)
+MediaList::Create(StyleBackendType aBackendType, const nsAString& aMedia)
{
if (aBackendType == StyleBackendType::Servo) {
RefPtr<ServoMediaList> mediaList = new ServoMediaList(aMedia);
return mediaList.forget();
}
nsCSSParser parser;
RefPtr<nsMediaList> mediaList = new nsMediaList();
--- a/layout/style/MediaList.h
+++ b/layout/style/MediaList.h
@@ -41,29 +41,16 @@ public:
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(MediaList)
/**
* Creates a MediaList backed by the given StyleBackendType.
*/
static already_AddRefed<MediaList> Create(StyleBackendType,
const nsAString& aMedia);
- /**
- * Creates a MediaList backed by the given StyleBackendType.
- */
- static already_AddRefed<MediaList> Create(StyleBackendType aBackendType) {
- return Create(aBackendType, nsString());
- }
-
- /**
- * Creates a MediaList backed by the StyleBackendType of the document.
- */
- static already_AddRefed<MediaList> Create(const nsIDocument& aDocument,
- const nsAString& aMedia);
-
virtual already_AddRefed<MediaList> Clone() = 0;
JSObject* WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) final;
nsISupports* GetParentObject() const { return nullptr; }
virtual void GetText(nsAString& aMediaText) = 0;
virtual void SetText(const nsAString& aMediaText) = 0;
virtual bool Matches(nsPresContext& aPresContext,
--- a/layout/style/StyleSheet.cpp
+++ b/layout/style/StyleSheet.cpp
@@ -686,17 +686,17 @@ StyleSheet::DropMedia()
mMedia = nullptr;
}
}
dom::MediaList*
StyleSheet::Media()
{
if (!mMedia) {
- mMedia = dom::MediaList::Create(mType);
+ mMedia = dom::MediaList::Create(mType, nsString());
mMedia->SetStyleSheet(this);
}
return mMedia;
}
// nsWrapperCache