2013-02-07 07:38:26 -08: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 13:43:41 -07:00
|
|
|
#include "mozilla/Attributes.h"
|
2013-02-07 07:38:26 -08:00
|
|
|
#include "nsIDOMHTMLSourceElement.h"
|
|
|
|
#include "nsGenericHTMLElement.h"
|
2013-03-19 05:23:54 -07:00
|
|
|
#include "mozilla/dom/HTMLMediaElement.h"
|
2013-02-07 07:38:26 -08:00
|
|
|
|
2014-04-17 14:38:18 -07:00
|
|
|
class nsMediaList;
|
|
|
|
|
2013-02-07 07:38:26 -08:00
|
|
|
namespace mozilla {
|
|
|
|
namespace dom {
|
|
|
|
|
2014-05-02 14:32:20 -07:00
|
|
|
class ResponsiveImageSelector;
|
2013-07-11 14:26:54 -07:00
|
|
|
class HTMLSourceElement MOZ_FINAL : public nsGenericHTMLElement,
|
|
|
|
public nsIDOMHTMLSourceElement
|
2013-02-07 07:38:26 -08:00
|
|
|
{
|
|
|
|
public:
|
2014-09-01 17:49:25 -07:00
|
|
|
explicit HTMLSourceElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo);
|
2013-02-07 07:38:26 -08:00
|
|
|
|
|
|
|
// nsISupports
|
|
|
|
NS_DECL_ISUPPORTS_INHERITED
|
|
|
|
|
2014-04-17 14:38:18 -07:00
|
|
|
NS_IMPL_FROMCONTENT_HTML_WITH_TAG(HTMLSourceElement, source)
|
|
|
|
|
2013-02-07 07:38:26 -08:00
|
|
|
// nsIDOMHTMLSourceElement
|
|
|
|
NS_DECL_NSIDOMHTMLSOURCEELEMENT
|
|
|
|
|
2014-06-19 19:01:40 -07:00
|
|
|
virtual nsresult Clone(mozilla::dom::NodeInfo* aNodeInfo, nsINode** aResult) const MOZ_OVERRIDE;
|
2013-02-07 07:38:26 -08:00
|
|
|
|
|
|
|
// Override BindToTree() so that we can trigger a load when we add a
|
|
|
|
// child source element.
|
2013-02-07 07:39:10 -08:00
|
|
|
virtual nsresult BindToTree(nsIDocument* aDocument, nsIContent* aParent,
|
|
|
|
nsIContent* aBindingParent,
|
2013-05-29 13:43:41 -07:00
|
|
|
bool aCompileEventHandlers) MOZ_OVERRIDE;
|
2013-02-07 07:38:26 -08:00
|
|
|
|
2014-04-17 14:38:18 -07:00
|
|
|
// If this element's media attr matches for its owner document. Returns true
|
|
|
|
// if no media attr was set.
|
|
|
|
bool MatchesCurrentMedia();
|
|
|
|
|
2013-02-07 07:39:10 -08:00
|
|
|
// WebIDL
|
|
|
|
void GetSrc(nsString& aSrc)
|
|
|
|
{
|
|
|
|
GetURIAttr(nsGkAtoms::src, nullptr, aSrc);
|
|
|
|
}
|
|
|
|
void SetSrc(const nsAString& aSrc, mozilla::ErrorResult& rv)
|
|
|
|
{
|
|
|
|
SetHTMLAttr(nsGkAtoms::src, aSrc, rv);
|
|
|
|
}
|
|
|
|
|
|
|
|
void GetType(nsString& aType)
|
|
|
|
{
|
|
|
|
GetHTMLAttr(nsGkAtoms::type, aType);
|
|
|
|
}
|
|
|
|
void SetType(const nsAString& aType, ErrorResult& rv)
|
|
|
|
{
|
|
|
|
SetHTMLAttr(nsGkAtoms::type, aType, rv);
|
|
|
|
}
|
|
|
|
|
2014-04-23 13:55:05 -07:00
|
|
|
void GetSrcset(nsString& aSrcset)
|
|
|
|
{
|
|
|
|
GetHTMLAttr(nsGkAtoms::srcset, aSrcset);
|
|
|
|
}
|
|
|
|
void SetSrcset(const nsAString& aSrcset, mozilla::ErrorResult& rv)
|
|
|
|
{
|
|
|
|
SetHTMLAttr(nsGkAtoms::srcset, aSrcset, rv);
|
|
|
|
}
|
|
|
|
|
|
|
|
void GetSizes(nsString& aSizes)
|
|
|
|
{
|
|
|
|
GetHTMLAttr(nsGkAtoms::sizes, aSizes);
|
|
|
|
}
|
|
|
|
void SetSizes(const nsAString& aSizes, mozilla::ErrorResult& rv)
|
|
|
|
{
|
|
|
|
SetHTMLAttr(nsGkAtoms::sizes, aSizes, rv);
|
|
|
|
}
|
|
|
|
|
2013-02-07 07:39:10 -08:00
|
|
|
void GetMedia(nsString& aMedia)
|
|
|
|
{
|
|
|
|
GetHTMLAttr(nsGkAtoms::media, aMedia);
|
|
|
|
}
|
|
|
|
void SetMedia(const nsAString& aMedia, mozilla::ErrorResult& rv)
|
|
|
|
{
|
|
|
|
SetHTMLAttr(nsGkAtoms::media, aMedia, rv);
|
|
|
|
}
|
|
|
|
|
|
|
|
protected:
|
2014-07-08 14:23:16 -07:00
|
|
|
virtual ~HTMLSourceElement();
|
|
|
|
|
2014-04-08 15:27:17 -07:00
|
|
|
virtual JSObject* WrapNode(JSContext* aCx) MOZ_OVERRIDE;
|
2013-02-07 07:39:10 -08:00
|
|
|
|
2013-02-07 07:38:26 -08:00
|
|
|
protected:
|
2013-05-29 13:43:41 -07:00
|
|
|
virtual void GetItemValueText(nsAString& text) MOZ_OVERRIDE;
|
|
|
|
virtual void SetItemValueText(const nsAString& text) MOZ_OVERRIDE;
|
2014-04-17 14:38:18 -07:00
|
|
|
|
|
|
|
virtual nsresult AfterSetAttr(int32_t aNameSpaceID, nsIAtom* aName,
|
|
|
|
const nsAttrValue* aValue,
|
|
|
|
bool aNotify) MOZ_OVERRIDE;
|
|
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
nsRefPtr<nsMediaList> mMediaList;
|
2013-02-07 07:38:26 -08:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|
|
|
|
|
|
|
|
#endif // mozilla_dom_HTMLSourceElement_h
|