2013-02-07 15:38:26 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim:set ts=2 sw=2 sts=2 et cindent: */
|
|
|
|
/* 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-29 20:43:41 +00:00
|
|
|
#include "mozilla/Attributes.h"
|
2013-02-07 15:38:26 +00:00
|
|
|
#include "nsIDOMHTMLSourceElement.h"
|
|
|
|
#include "nsGenericHTMLElement.h"
|
2013-03-19 12:23:54 +00:00
|
|
|
#include "mozilla/dom/HTMLMediaElement.h"
|
2013-02-07 15:38:26 +00:00
|
|
|
|
2014-04-17 21:38:18 +00:00
|
|
|
class nsMediaList;
|
|
|
|
|
2013-02-07 15:38:26 +00:00
|
|
|
namespace mozilla {
|
|
|
|
namespace dom {
|
|
|
|
|
2015-03-21 16:28:04 +00:00
|
|
|
class HTMLSourceElement final : public nsGenericHTMLElement,
|
2015-03-27 18:52:19 +00:00
|
|
|
public nsIDOMHTMLSourceElement
|
2013-02-07 15:38:26 +00:00
|
|
|
{
|
|
|
|
public:
|
2014-09-02 00:49:25 +00:00
|
|
|
explicit HTMLSourceElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo);
|
2013-02-07 15:38:26 +00:00
|
|
|
|
|
|
|
// nsISupports
|
|
|
|
NS_DECL_ISUPPORTS_INHERITED
|
|
|
|
|
2014-04-17 21:38:18 +00:00
|
|
|
NS_IMPL_FROMCONTENT_HTML_WITH_TAG(HTMLSourceElement, source)
|
|
|
|
|
2013-02-07 15:38:26 +00:00
|
|
|
// nsIDOMHTMLSourceElement
|
|
|
|
NS_DECL_NSIDOMHTMLSOURCEELEMENT
|
|
|
|
|
2015-03-21 16:28:04 +00:00
|
|
|
virtual nsresult Clone(mozilla::dom::NodeInfo* aNodeInfo, nsINode** aResult) const override;
|
2013-02-07 15:38:26 +00:00
|
|
|
|
|
|
|
// Override BindToTree() so that we can trigger a load when we add a
|
|
|
|
// child source element.
|
2013-02-07 15:39:10 +00:00
|
|
|
virtual nsresult BindToTree(nsIDocument* aDocument, nsIContent* aParent,
|
|
|
|
nsIContent* aBindingParent,
|
2015-03-21 16:28:04 +00:00
|
|
|
bool aCompileEventHandlers) override;
|
2013-02-07 15:38:26 +00:00
|
|
|
|
2014-04-17 21:38:18 +00:00
|
|
|
// If this element's media attr matches for its owner document. Returns true
|
|
|
|
// if no media attr was set.
|
|
|
|
bool MatchesCurrentMedia();
|
|
|
|
|
2014-12-10 23:53:00 +00: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);
|
|
|
|
|
2013-02-07 15:39:10 +00: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 01:27:39 +00:00
|
|
|
void GetType(DOMString& aType)
|
2013-02-07 15:39:10 +00:00
|
|
|
{
|
|
|
|
GetHTMLAttr(nsGkAtoms::type, aType);
|
|
|
|
}
|
|
|
|
void SetType(const nsAString& aType, ErrorResult& rv)
|
|
|
|
{
|
|
|
|
SetHTMLAttr(nsGkAtoms::type, aType, rv);
|
|
|
|
}
|
|
|
|
|
2015-02-13 01:27:39 +00:00
|
|
|
void GetSrcset(DOMString& aSrcset)
|
2014-04-23 20:55:05 +00:00
|
|
|
{
|
|
|
|
GetHTMLAttr(nsGkAtoms::srcset, aSrcset);
|
|
|
|
}
|
|
|
|
void SetSrcset(const nsAString& aSrcset, mozilla::ErrorResult& rv)
|
|
|
|
{
|
|
|
|
SetHTMLAttr(nsGkAtoms::srcset, aSrcset, rv);
|
|
|
|
}
|
|
|
|
|
2015-02-13 01:27:39 +00:00
|
|
|
void GetSizes(DOMString& aSizes)
|
2014-04-23 20:55:05 +00:00
|
|
|
{
|
|
|
|
GetHTMLAttr(nsGkAtoms::sizes, aSizes);
|
|
|
|
}
|
|
|
|
void SetSizes(const nsAString& aSizes, mozilla::ErrorResult& rv)
|
|
|
|
{
|
|
|
|
SetHTMLAttr(nsGkAtoms::sizes, aSizes, rv);
|
|
|
|
}
|
|
|
|
|
2015-02-13 01:27:39 +00:00
|
|
|
void GetMedia(DOMString& aMedia)
|
2013-02-07 15:39:10 +00:00
|
|
|
{
|
|
|
|
GetHTMLAttr(nsGkAtoms::media, aMedia);
|
|
|
|
}
|
|
|
|
void SetMedia(const nsAString& aMedia, mozilla::ErrorResult& rv)
|
|
|
|
{
|
|
|
|
SetHTMLAttr(nsGkAtoms::media, aMedia, rv);
|
|
|
|
}
|
|
|
|
|
|
|
|
protected:
|
2014-07-08 21:23:16 +00:00
|
|
|
virtual ~HTMLSourceElement();
|
|
|
|
|
2015-03-21 16:28:04 +00:00
|
|
|
virtual JSObject* WrapNode(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override;
|
2013-02-07 15:39:10 +00:00
|
|
|
|
2013-02-07 15:38:26 +00:00
|
|
|
protected:
|
2015-03-21 16:28:04 +00:00
|
|
|
virtual void GetItemValueText(DOMString& text) override;
|
|
|
|
virtual void SetItemValueText(const nsAString& text) override;
|
2014-04-17 21:38:18 +00:00
|
|
|
|
|
|
|
virtual nsresult AfterSetAttr(int32_t aNameSpaceID, nsIAtom* aName,
|
|
|
|
const nsAttrValue* aValue,
|
2015-03-21 16:28:04 +00:00
|
|
|
bool aNotify) override;
|
2014-04-17 21:38:18 +00:00
|
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
nsRefPtr<nsMediaList> mMediaList;
|
2013-02-07 15:38:26 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|
|
|
|
|
|
|
|
#endif // mozilla_dom_HTMLSourceElement_h
|