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 "nsIDOMHTMLSourceElement.h"
|
|
|
|
#include "nsGenericHTMLElement.h"
|
2013-03-19 16:23:54 +04:00
|
|
|
#include "mozilla/dom/HTMLMediaElement.h"
|
2013-02-07 19:38:26 +04:00
|
|
|
|
2014-04-18 01:38:18 +04:00
|
|
|
class nsMediaList;
|
|
|
|
|
2013-02-07 19:38:26 +04:00
|
|
|
namespace mozilla {
|
|
|
|
namespace dom {
|
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
class HTMLSourceElement final : public nsGenericHTMLElement,
|
2015-03-27 21:52:19 +03:00
|
|
|
public nsIDOMHTMLSourceElement
|
2013-02-07 19:38:26 +04:00
|
|
|
{
|
|
|
|
public:
|
2014-09-02 04:49:25 +04: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
|
|
|
|
2014-04-18 01:38:18 +04:00
|
|
|
NS_IMPL_FROMCONTENT_HTML_WITH_TAG(HTMLSourceElement, source)
|
|
|
|
|
2013-02-07 19:38:26 +04:00
|
|
|
// nsIDOMHTMLSourceElement
|
|
|
|
NS_DECL_NSIDOMHTMLSOURCEELEMENT
|
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual nsresult Clone(mozilla::dom::NodeInfo* aNodeInfo, 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,
|
|
|
|
nsIContent* aBindingParent,
|
2015-03-21 19:28:04 +03:00
|
|
|
bool aCompileEventHandlers) 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
|
|
|
|
void GetSrc(nsString& aSrc)
|
|
|
|
{
|
|
|
|
GetURIAttr(nsGkAtoms::src, nullptr, aSrc);
|
|
|
|
}
|
|
|
|
void SetSrc(const nsAString& aSrc, mozilla::ErrorResult& rv)
|
|
|
|
{
|
|
|
|
SetHTMLAttr(nsGkAtoms::src, aSrc, rv);
|
|
|
|
}
|
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
2015-02-13 04:27:39 +03:00
|
|
|
void GetSrcset(DOMString& aSrcset)
|
2014-04-24 00:55:05 +04:00
|
|
|
{
|
|
|
|
GetHTMLAttr(nsGkAtoms::srcset, aSrcset);
|
|
|
|
}
|
|
|
|
void SetSrcset(const nsAString& aSrcset, mozilla::ErrorResult& rv)
|
|
|
|
{
|
|
|
|
SetHTMLAttr(nsGkAtoms::srcset, aSrcset, rv);
|
|
|
|
}
|
|
|
|
|
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:
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual void GetItemValueText(DOMString& text) override;
|
|
|
|
virtual void SetItemValueText(const nsAString& text) override;
|
2014-04-18 01:38:18 +04:00
|
|
|
|
|
|
|
virtual nsresult AfterSetAttr(int32_t aNameSpaceID, nsIAtom* aName,
|
|
|
|
const nsAttrValue* aValue,
|
2015-03-21 19:28:04 +03:00
|
|
|
bool aNotify) override;
|
2014-04-18 01:38:18 +04:00
|
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
nsRefPtr<nsMediaList> mMediaList;
|
2015-05-26 14:01:14 +03:00
|
|
|
nsRefPtr<MediaSource> mSrcMediaSource;
|
2013-02-07 19:38:26 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|
|
|
|
|
|
|
|
#endif // mozilla_dom_HTMLSourceElement_h
|