Bug 591737 - Add pref for details and summary elements. r=bz

This commit is contained in:
Ting-Yu Lin
2016-01-20 23:20:43 +08:00
parent ef5a24eec8
commit edb31b5f99
13 changed files with 119 additions and 61 deletions

View File

@@ -6,12 +6,39 @@
#include "mozilla/dom/HTMLDetailsElement.h"
#include "mozilla/dom/HTMLDetailsElementBinding.h"
#include "mozilla/dom/HTMLUnknownElement.h"
#include "mozilla/Preferences.h"
NS_IMPL_NS_NEW_HTML_ELEMENT(Details)
// Expand NS_IMPL_NS_NEW_HTML_ELEMENT(Details) to add pref check.
nsGenericHTMLElement*
NS_NewHTMLDetailsElement(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo,
mozilla::dom::FromParser aFromParser)
{
if (!mozilla::dom::HTMLDetailsElement::IsDetailsEnabled()) {
return new mozilla::dom::HTMLUnknownElement(aNodeInfo);
}
return new mozilla::dom::HTMLDetailsElement(aNodeInfo);
}
namespace mozilla {
namespace dom {
bool
HTMLDetailsElement::IsDetailsEnabled()
{
static bool isDetailsEnabled = false;
static bool added = false;
if (!added) {
Preferences::AddBoolVarCache(&isDetailsEnabled,
"dom.details_element.enabled");
added = true;
}
return isDetailsEnabled;
}
HTMLDetailsElement::~HTMLDetailsElement()
{
}