Bug 870022 - Part 5.1 - Add HTMLPictureElement & atom. r=jst, sr=jst

This commit is contained in:
John Schoenick 2014-03-06 15:46:38 -08:00
parent 078d49e017
commit 0f66e36c1f
10 changed files with 129 additions and 0 deletions

View File

@ -2220,6 +2220,7 @@ GK_ATOM(menuitemradio, "menuitemradio")
GK_ATOM(mixed, "mixed")
GK_ATOM(multiline, "multiline")
GK_ATOM(password, "password")
GK_ATOM(picture, "picture")
GK_ATOM(posinset, "posinset")
GK_ATOM(presentation, "presentation")
GK_ATOM(progressbar, "progressbar")

View File

@ -0,0 +1,57 @@
/* -*- 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/. */
#include "mozilla/dom/HTMLPictureElement.h"
#include "mozilla/dom/HTMLPictureElementBinding.h"
#include "mozilla/dom/HTMLImageElement.h"
#include "mozilla/Preferences.h"
static const char *kPrefPictureEnabled = "dom.image.picture.enabled";
// Expand NS_IMPL_NS_NEW_HTML_ELEMENT(Picture) to add pref check.
nsGenericHTMLElement*
NS_NewHTMLPictureElement(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo,
mozilla::dom::FromParser aFromParser)
{
if (!mozilla::dom::HTMLPictureElement::IsPictureEnabled()) {
return new mozilla::dom::HTMLUnknownElement(aNodeInfo);
}
return new mozilla::dom::HTMLPictureElement(aNodeInfo);
}
namespace mozilla {
namespace dom {
HTMLPictureElement::HTMLPictureElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo)
: nsGenericHTMLElement(aNodeInfo)
{
}
HTMLPictureElement::~HTMLPictureElement()
{
}
NS_IMPL_ISUPPORTS_INHERITED(HTMLPictureElement, nsGenericHTMLElement,
nsIDOMHTMLPictureElement)
NS_IMPL_ELEMENT_CLONE(HTMLPictureElement)
bool
HTMLPictureElement::IsPictureEnabled()
{
return HTMLImageElement::IsSrcsetEnabled() &&
Preferences::GetBool(kPrefPictureEnabled, false);
}
JSObject*
HTMLPictureElement::WrapNode(JSContext* aCx)
{
return HTMLPictureElementBinding::Wrap(aCx, this);
}
} // namespace dom
} // namespace mozilla

View File

@ -0,0 +1,43 @@
/* -*- 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_HTMLPictureElement_h
#define mozilla_dom_HTMLPictureElement_h
#include "mozilla/Attributes.h"
#include "nsIDOMHTMLPictureElement.h"
#include "nsGenericHTMLElement.h"
#include "mozilla/dom/HTMLUnknownElement.h"
namespace mozilla {
namespace dom {
class HTMLPictureElement MOZ_FINAL : public nsGenericHTMLElement,
public nsIDOMHTMLPictureElement
{
public:
HTMLPictureElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo);
virtual ~HTMLPictureElement();
// nsISupports
NS_DECL_ISUPPORTS_INHERITED
// nsIDOMHTMLPictureElement
NS_DECL_NSIDOMHTMLPICTUREELEMENT
virtual nsresult Clone(mozilla::dom::NodeInfo* aNodeInfo, nsINode** aResult) const MOZ_OVERRIDE;
static bool IsPictureEnabled();
protected:
virtual JSObject* WrapNode(JSContext* aCx) MOZ_OVERRIDE;
};
} // namespace dom
} // namespace mozilla
#endif // mozilla_dom_HTMLPictureElement_h

View File

@ -47,6 +47,7 @@ EXPORTS.mozilla.dom += [
'HTMLOptionsCollection.h',
'HTMLOutputElement.h',
'HTMLParagraphElement.h',
'HTMLPictureElement.h',
'HTMLPreElement.h',
'HTMLProgressElement.h',
'HTMLScriptElement.h',
@ -118,6 +119,7 @@ UNIFIED_SOURCES += [
'HTMLOptionsCollection.cpp',
'HTMLOutputElement.cpp',
'HTMLParagraphElement.cpp',
'HTMLPictureElement.cpp',
'HTMLPreElement.cpp',
'HTMLProgressElement.cpp',
'HTMLPropertiesCollection.cpp',

View File

@ -1764,6 +1764,7 @@ NS_DECLARE_NS_NEW_HTML_ELEMENT(OptGroup)
NS_DECLARE_NS_NEW_HTML_ELEMENT(Option)
NS_DECLARE_NS_NEW_HTML_ELEMENT(Output)
NS_DECLARE_NS_NEW_HTML_ELEMENT(Paragraph)
NS_DECLARE_NS_NEW_HTML_ELEMENT(Picture)
NS_DECLARE_NS_NEW_HTML_ELEMENT(Pre)
NS_DECLARE_NS_NEW_HTML_ELEMENT(Progress)
NS_DECLARE_NS_NEW_HTML_ELEMENT(Script)

View File

@ -45,6 +45,7 @@ XPIDL_SOURCES += [
'nsIDOMHTMLOptionElement.idl',
'nsIDOMHTMLOptionsCollection.idl',
'nsIDOMHTMLParagraphElement.idl',
'nsIDOMHTMLPictureElement.idl',
'nsIDOMHTMLPreElement.idl',
'nsIDOMHTMLQuoteElement.idl',
'nsIDOMHTMLScriptElement.idl',

View File

@ -0,0 +1,12 @@
/* -*- 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/. */
#include "nsIDOMHTMLElement.idl"
[scriptable, uuid(e0e5ac7f-b969-494c-a61e-9d740e38abba)]
interface nsIDOMHTMLPictureElement : nsISupports
{
};

View File

@ -501,6 +501,8 @@ var interfaceNamesInGlobalScope =
"HTMLParamElement",
// IMPORTANT: Do not change this list without review from a DOM peer!
"HTMLPreElement",
// IMPORTANT: Do not change this list without review from a DOM peer!
{name: "HTMLPictureElement", pref: "dom.image.picture.enabled"},
// IMPORTANT: Do not change this list without review from a DOM peer!
"HTMLProgressElement",
// IMPORTANT: Do not change this list without review from a DOM peer!

View File

@ -0,0 +1,9 @@
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* 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/.
*/
[Pref="dom.image.picture.enabled"]
interface HTMLPictureElement : HTMLElement {
};

View File

@ -178,6 +178,7 @@ WEBIDL_FILES = [
'HTMLOutputElement.webidl',
'HTMLParagraphElement.webidl',
'HTMLParamElement.webidl',
'HTMLPictureElement.webidl',
'HTMLPreElement.webidl',
'HTMLProgressElement.webidl',
'HTMLPropertiesCollection.webidl',