summaryrefslogtreecommitdiff
path: root/dom/html
diff options
context:
space:
mode:
authorathenian200 <athenian200@outlook.com>2021-03-31 17:57:48 -0500
committerathenian200 <athenian200@outlook.com>2021-03-31 17:57:48 -0500
commit82cb11de19e8aa2b4dbee923e16cab6d35dd908d (patch)
tree632edd900d2f94f24c8d539da10fa778838de303 /dom/html
parentb969ea3b9ced3eac51cd94c3390742ab57a4e520 (diff)
downloaduxp-82cb11de19e8aa2b4dbee923e16cab6d35dd908d.tar.gz
Issue #1757 - Reinstate "dom.details_element.enabled" preference
The removal of this preference was botched, all other surrounding plumbing changes appear to be working okay. The ability to use prefs to control this stylesheet might be useful in the future, so perhaps this is one of those "if it ain't broke, don't fix it" bugs where leaving well enough alone in the first place would have been the best choice.
Diffstat (limited to 'dom/html')
-rw-r--r--dom/html/HTMLDetailsElement.cpp30
-rw-r--r--dom/html/HTMLDetailsElement.h2
-rw-r--r--dom/html/HTMLSummaryElement.cpp12
3 files changed, 42 insertions, 2 deletions
diff --git a/dom/html/HTMLDetailsElement.cpp b/dom/html/HTMLDetailsElement.cpp
index 9d4dd89c2a..74479b8d90 100644
--- a/dom/html/HTMLDetailsElement.cpp
+++ b/dom/html/HTMLDetailsElement.cpp
@@ -6,11 +6,39 @@
#include "mozilla/dom/HTMLDetailsElement.h"
#include "mozilla/dom/HTMLDetailsElementBinding.h"
-NS_IMPL_NS_NEW_HTML_ELEMENT(Details)
+#include "mozilla/dom/HTMLUnknownElement.h"
+#include "mozilla/Preferences.h"
+
+// 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 {
+/* static */ 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()
{
}
diff --git a/dom/html/HTMLDetailsElement.h b/dom/html/HTMLDetailsElement.h
index 4575ed888d..10e70784c6 100644
--- a/dom/html/HTMLDetailsElement.h
+++ b/dom/html/HTMLDetailsElement.h
@@ -23,6 +23,8 @@ class HTMLDetailsElement final : public nsGenericHTMLElement
public:
using NodeInfo = mozilla::dom::NodeInfo;
+ static bool IsDetailsEnabled();
+
explicit HTMLDetailsElement(already_AddRefed<NodeInfo>& aNodeInfo)
: nsGenericHTMLElement(aNodeInfo)
{
diff --git a/dom/html/HTMLSummaryElement.cpp b/dom/html/HTMLSummaryElement.cpp
index 42ead6b87f..ee3c07b20b 100644
--- a/dom/html/HTMLSummaryElement.cpp
+++ b/dom/html/HTMLSummaryElement.cpp
@@ -14,7 +14,17 @@
#include "mozilla/TextEvents.h"
#include "nsFocusManager.h"
-NS_IMPL_NS_NEW_HTML_ELEMENT(Summary)
+// Expand NS_IMPL_NS_NEW_HTML_ELEMENT(Summary) to add pref check.
+nsGenericHTMLElement*
+NS_NewHTMLSummaryElement(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::HTMLSummaryElement(aNodeInfo);
+}
namespace mozilla {
namespace dom {