Bug 1329568 - MediaMIMEType comparisons against others - r=jya

`==` and `!=` against other MediaMIMEType objects, and against MEDIAMIMETYPE
checked literals.
This will allow simple (and compile-time-checked!) tests like:
  if (contentType.Type() == MEDIAMIMETYPE("audio/mp4")) { ...

MozReview-Commit-ID: 5yMua5krOKD

--HG--
extra : rebase_source : bc1ade528841b5fd71278b827a94edc65e9a8898
This commit is contained in:
Gerald Squelart 2017-01-01 10:06:26 +11:00
Родитель 7c854f2bad
Коммит 650dcee293
1 изменённых файлов: 21 добавлений и 1 удалений

Просмотреть файл

@ -15,7 +15,7 @@ namespace mozilla {
// Class containing pointing at a media MIME "type/subtype" string literal.
// See IsMediaMIMEType for restrictions.
// Mainly used to help construct a MediaMIMEType through the statically-checked
// MEDIAMIMETYPE macro.
// MEDIAMIMETYPE macro, or to compare a MediaMIMEType to a literal.
class DependentMediaMIMEType
{
public:
@ -56,6 +56,26 @@ public:
// MIME "type/subtype", always lowercase.
const nsACString& AsString() const { return mMIMEType; }
// Comparison with DependentMediaMIMEType.
// Useful to compare to MEDIAMIMETYPE literals.
bool operator==(const DependentMediaMIMEType& aOther) const
{
return mMIMEType.Equals(aOther.AsDependentString());
}
bool operator!=(const DependentMediaMIMEType& aOther) const
{
return !mMIMEType.Equals(aOther.AsDependentString());
}
bool operator==(const MediaMIMEType& aOther) const
{
return mMIMEType.Equals(aOther.mMIMEType);
}
bool operator!=(const MediaMIMEType& aOther) const
{
return !mMIMEType.Equals(aOther.mMIMEType);
}
private:
friend Maybe<MediaMIMEType> MakeMediaMIMEType(const nsAString& aType);
friend class MediaExtendedMIMEType;