2015-05-03 22:32:37 +03:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
2013-02-07 19:38:26 +04:00
|
|
|
/* 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/. */
|
|
|
|
|
|
|
|
#ifndef mozilla_dom_HTMLSourceElement_h
|
|
|
|
#define mozilla_dom_HTMLSourceElement_h
|
|
|
|
|
2013-05-30 00:43:41 +04:00
|
|
|
#include "mozilla/Attributes.h"
|
2013-02-07 19:38:26 +04:00
|
|
|
#include "nsGenericHTMLElement.h"
|
2013-03-19 16:23:54 +04:00
|
|
|
#include "mozilla/dom/HTMLMediaElement.h"
|
2013-02-07 19:38:26 +04:00
|
|
|
|
2016-02-03 04:53:00 +03:00
|
|
|
class nsAttrValue;
|
2014-04-18 01:38:18 +04:00
|
|
|
|
2013-02-07 19:38:26 +04:00
|
|
|
namespace mozilla {
|
|
|
|
namespace dom {
|
|
|
|
|
2017-04-10 05:25:33 +03:00
|
|
|
class MediaList;
|
|
|
|
|
2017-10-28 01:00:42 +03:00
|
|
|
class HTMLSourceElement final : public nsGenericHTMLElement
|
2013-02-07 19:38:26 +04:00
|
|
|
{
|
|
|
|
public:
|
2018-09-21 23:45:49 +03:00
|
|
|
explicit HTMLSourceElement(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo);
|
2013-02-07 19:38:26 +04:00
|
|
|
|
|
|
|
// nsISupports
|
|
|
|
NS_DECL_ISUPPORTS_INHERITED
|
2015-05-26 14:01:14 +03:00
|
|
|
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(HTMLSourceElement,
|
|
|
|
nsGenericHTMLElement)
|
2013-02-07 19:38:26 +04:00
|
|
|
|
2018-03-22 00:39:04 +03:00
|
|
|
NS_IMPL_FROMNODE_HTML_WITH_TAG(HTMLSourceElement, source)
|
2014-04-18 01:38:18 +04:00
|
|
|
|
2018-08-09 02:58:44 +03:00
|
|
|
virtual nsresult Clone(dom::NodeInfo*, nsINode** aResult) const override;
|
2013-02-07 19:38:26 +04:00
|
|
|
|
|
|
|
// Override BindToTree() so that we can trigger a load when we add a
|
|
|
|
// child source element.
|
2013-02-07 19:39:10 +04:00
|
|
|
virtual nsresult BindToTree(nsIDocument* aDocument, nsIContent* aParent,
|
2018-07-31 21:18:38 +03:00
|
|
|
nsIContent* aBindingParent) override;
|
2013-02-07 19:38:26 +04:00
|
|
|
|
2014-04-18 01:38:18 +04:00
|
|
|
// If this element's media attr matches for its owner document. Returns true
|
|
|
|
// if no media attr was set.
|
|
|
|
bool MatchesCurrentMedia();
|
|
|
|
|
2014-12-11 02:53:00 +03:00
|
|
|
// True if a source tag would match the given media attribute for the
|
|
|
|
// specified document. Used by the preloader to determine valid <source> tags
|
|
|
|
// prior to DOM creation.
|
|
|
|
static bool WouldMatchMediaForDocument(const nsAString& aMediaStr,
|
|
|
|
const nsIDocument *aDocument);
|
|
|
|
|
2015-05-26 14:01:14 +03:00
|
|
|
// Return the MediaSource object if any associated with the src attribute
|
|
|
|
// when it was set.
|
|
|
|
MediaSource* GetSrcMediaSource() { return mSrcMediaSource; };
|
|
|
|
|
2013-02-07 19:39:10 +04:00
|
|
|
// WebIDL
|
2017-12-06 00:03:18 +03:00
|
|
|
void GetSrc(nsString& aSrc)
|
2013-02-07 19:39:10 +04:00
|
|
|
{
|
|
|
|
GetURIAttr(nsGkAtoms::src, nullptr, aSrc);
|
|
|
|
}
|
2017-12-21 01:43:18 +03:00
|
|
|
void SetSrc(const nsAString& aSrc, nsIPrincipal* aTriggeringPrincipal, mozilla::ErrorResult& rv)
|
2013-02-07 19:39:10 +04:00
|
|
|
{
|
2017-10-06 01:28:22 +03:00
|
|
|
SetHTMLAttr(nsGkAtoms::src, aSrc, aTriggeringPrincipal, rv);
|
|
|
|
}
|
|
|
|
|
|
|
|
nsIPrincipal* GetSrcTriggeringPrincipal() const
|
|
|
|
{
|
|
|
|
return mSrcTriggeringPrincipal;
|
2013-02-07 19:39:10 +04:00
|
|
|
}
|
|
|
|
|
2017-10-06 01:59:15 +03:00
|
|
|
nsIPrincipal* GetSrcsetTriggeringPrincipal() const
|
|
|
|
{
|
|
|
|
return mSrcsetTriggeringPrincipal;
|
|
|
|
}
|
|
|
|
|
2015-02-13 04:27:39 +03:00
|
|
|
void GetType(DOMString& aType)
|
2013-02-07 19:39:10 +04:00
|
|
|
{
|
|
|
|
GetHTMLAttr(nsGkAtoms::type, aType);
|
|
|
|
}
|
|
|
|
void SetType(const nsAString& aType, ErrorResult& rv)
|
|
|
|
{
|
|
|
|
SetHTMLAttr(nsGkAtoms::type, aType, rv);
|
|
|
|
}
|
|
|
|
|
2017-12-06 00:03:18 +03:00
|
|
|
void GetSrcset(DOMString& aSrcset)
|
2014-04-24 00:55:05 +04:00
|
|
|
{
|
|
|
|
GetHTMLAttr(nsGkAtoms::srcset, aSrcset);
|
|
|
|
}
|
2017-12-21 01:43:18 +03:00
|
|
|
void SetSrcset(const nsAString& aSrcset, nsIPrincipal* aTriggeringPrincipal, mozilla::ErrorResult& rv)
|
2014-04-24 00:55:05 +04:00
|
|
|
{
|
2017-10-06 01:59:15 +03:00
|
|
|
SetHTMLAttr(nsGkAtoms::srcset, aSrcset, aTriggeringPrincipal, rv);
|
2014-04-24 00:55:05 +04:00
|
|
|
}
|
|
|
|
|
2015-02-13 04:27:39 +03:00
|
|
|
void GetSizes(DOMString& aSizes)
|
2014-04-24 00:55:05 +04:00
|
|
|
{
|
|
|
|
GetHTMLAttr(nsGkAtoms::sizes, aSizes);
|
|
|
|
}
|
|
|
|
void SetSizes(const nsAString& aSizes, mozilla::ErrorResult& rv)
|
|
|
|
{
|
|
|
|
SetHTMLAttr(nsGkAtoms::sizes, aSizes, rv);
|
|
|
|
}
|
|
|
|
|
2015-02-13 04:27:39 +03:00
|
|
|
void GetMedia(DOMString& aMedia)
|
2013-02-07 19:39:10 +04:00
|
|
|
{
|
|
|
|
GetHTMLAttr(nsGkAtoms::media, aMedia);
|
|
|
|
}
|
|
|
|
void SetMedia(const nsAString& aMedia, mozilla::ErrorResult& rv)
|
|
|
|
{
|
|
|
|
SetHTMLAttr(nsGkAtoms::media, aMedia, rv);
|
|
|
|
}
|
|
|
|
|
|
|
|
protected:
|
2014-07-09 01:23:16 +04:00
|
|
|
virtual ~HTMLSourceElement();
|
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual JSObject* WrapNode(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override;
|
2013-02-07 19:39:10 +04:00
|
|
|
|
2013-02-07 19:38:26 +04:00
|
|
|
protected:
|
2017-10-03 01:05:19 +03:00
|
|
|
virtual nsresult AfterSetAttr(int32_t aNameSpaceID, nsAtom* aName,
|
2014-04-18 01:38:18 +04:00
|
|
|
const nsAttrValue* aValue,
|
2017-05-19 00:09:01 +03:00
|
|
|
const nsAttrValue* aOldValue,
|
2017-10-10 00:33:38 +03:00
|
|
|
nsIPrincipal* aMaybeScriptedPrincipal,
|
2015-03-21 19:28:04 +03:00
|
|
|
bool aNotify) override;
|
2014-04-18 01:38:18 +04:00
|
|
|
|
|
|
|
private:
|
2017-04-10 05:25:33 +03:00
|
|
|
RefPtr<MediaList> mMediaList;
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<MediaSource> mSrcMediaSource;
|
2016-02-03 04:53:00 +03:00
|
|
|
|
2017-10-06 01:28:22 +03:00
|
|
|
// The triggering principal for the src attribute.
|
|
|
|
nsCOMPtr<nsIPrincipal> mSrcTriggeringPrincipal;
|
|
|
|
|
2017-10-06 01:59:15 +03:00
|
|
|
// The triggering principal for the srcset attribute.
|
|
|
|
nsCOMPtr<nsIPrincipal> mSrcsetTriggeringPrincipal;
|
|
|
|
|
2017-04-10 05:25:33 +03:00
|
|
|
// Generates a new MediaList using the given input
|
2016-02-03 04:53:00 +03:00
|
|
|
void UpdateMediaList(const nsAttrValue* aValue);
|
2013-02-07 19:38:26 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|
|
|
|
|
|
|
|
#endif // mozilla_dom_HTMLSourceElement_h
|