Make <menuitem> pref-controlled and disable by default.

master
Fedor 2021-02-07 17:33:21 +02:00
parent e57592c1ba
commit 6a6db2ef0f
12 changed files with 31 additions and 16 deletions

View File

@ -137,9 +137,9 @@ HTMLMenuElement::ParseAttribute(int32_t aNamespaceID,
const nsAString& aValue, const nsAString& aValue,
nsAttrValue& aResult) nsAttrValue& aResult)
{ {
if (aNamespaceID == kNameSpaceID_None && aAttribute == nsGkAtoms::type) { if (aNamespaceID == kNameSpaceID_None && aAttribute == nsGkAtoms::type &&
bool success = aResult.ParseEnumValue(aValue, kMenuTypeTable, Preferences::GetBool("dom.menuitem.enabled")) {
false); bool success = aResult.ParseEnumValue(aValue, kMenuTypeTable, false);
if (success) { if (success) {
mType = aResult.GetEnumValue(); mType = aResult.GetEnumValue();
} else { } else {

View File

@ -7,12 +7,21 @@
#include "mozilla/BasicEvents.h" #include "mozilla/BasicEvents.h"
#include "mozilla/EventDispatcher.h" #include "mozilla/EventDispatcher.h"
#include "mozilla/Preferences.h"
#include "mozilla/dom/HTMLMenuItemElementBinding.h" #include "mozilla/dom/HTMLMenuItemElementBinding.h"
#include "mozilla/dom/HTMLUnknownElement.h"
#include "nsAttrValueInlines.h" #include "nsAttrValueInlines.h"
#include "nsContentUtils.h" #include "nsContentUtils.h"
nsGenericHTMLElement*
NS_IMPL_NS_NEW_HTML_ELEMENT_CHECK_PARSER(MenuItem) NS_NewHTMLMenuItemElement(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo,
mozilla::dom::FromParser aFromParser) {
if (mozilla::Preferences::GetBool("dom.menuitem.enabled")) {
return new mozilla::dom::HTMLMenuItemElement(aNodeInfo, aFromParser);
} else {
return new mozilla::dom::HTMLUnknownElement(aNodeInfo);
}
}
namespace mozilla { namespace mozilla {
namespace dom { namespace dom {

View File

@ -4,6 +4,9 @@ const kPage = "http://example.org/browser/" +
"dom/html/test/file_content_contextmenu.html"; "dom/html/test/file_content_contextmenu.html";
add_task(function* () { add_task(function* () {
yield SpecialPowers.pushPrefEnv({
set: [["dom.menuitem.enabled", true]],
});
yield BrowserTestUtils.withNewTab({ yield BrowserTestUtils.withNewTab({
gBrowser, gBrowser,
url: kPage url: kPage

View File

@ -1,4 +1,6 @@
[DEFAULT] [DEFAULT]
prefs =
dom.menuitem.enabled=true # only for test_bug617528.html
support-files = support-files =
347174transform.xsl 347174transform.xsl
347174transformable.xml 347174transformable.xml

View File

@ -496,8 +496,6 @@ var interfaceNamesInGlobalScope =
"HTMLMediaElement", "HTMLMediaElement",
// IMPORTANT: Do not change this list without review from a DOM peer! // IMPORTANT: Do not change this list without review from a DOM peer!
"HTMLMenuElement", "HTMLMenuElement",
// IMPORTANT: Do not change this list without review from a DOM peer!
"HTMLMenuItemElement",
// IMPORTANT: Do not change this list without review from a DOM peer! // IMPORTANT: Do not change this list without review from a DOM peer!
"HTMLMetaElement", "HTMLMetaElement",
// IMPORTANT: Do not change this list without review from a DOM peer! // IMPORTANT: Do not change this list without review from a DOM peer!

View File

@ -71,7 +71,6 @@
['map', 'Map'], ['map', 'Map'],
['mark', ''], ['mark', ''],
['menu', 'Menu'], ['menu', 'Menu'],
['menuitem', 'MenuItem'],
['meta', 'Meta'], ['meta', 'Meta'],
['meter', 'Meter'], ['meter', 'Meter'],
['nav', ''], ['nav', ''],

View File

@ -82,6 +82,7 @@ interface GlobalEventHandlers {
attribute EventHandler onseeked; attribute EventHandler onseeked;
attribute EventHandler onseeking; attribute EventHandler onseeking;
attribute EventHandler onselect; attribute EventHandler onselect;
[Pref="dom.menuitem.enabled"]
attribute EventHandler onshow; attribute EventHandler onshow;
//(Not implemented)attribute EventHandler onsort; //(Not implemented)attribute EventHandler onsort;
attribute EventHandler onstalled; attribute EventHandler onstalled;

View File

@ -49,10 +49,8 @@ interface HTMLElement : Element {
attribute DOMString contentEditable; attribute DOMString contentEditable;
[Pure] [Pure]
readonly attribute boolean isContentEditable; readonly attribute boolean isContentEditable;
[Pure] [Pure, Pref="dom.menuitem.enabled"]
readonly attribute HTMLMenuElement? contextMenu; readonly attribute HTMLMenuElement? contextMenu;
//[SetterThrows]
// attribute HTMLMenuElement? contextMenu;
[CEReactions, SetterThrows, Pure] [CEReactions, SetterThrows, Pure]
attribute boolean spellcheck; attribute boolean spellcheck;

View File

@ -17,9 +17,9 @@ interface MenuBuilder;
// http://www.whatwg.org/specs/web-apps/current-work/#the-menu-element // http://www.whatwg.org/specs/web-apps/current-work/#the-menu-element
[HTMLConstructor] [HTMLConstructor]
interface HTMLMenuElement : HTMLElement { interface HTMLMenuElement : HTMLElement {
[CEReactions, SetterThrows] [CEReactions, SetterThrows, Pref="dom.menuitem.enabled"]
attribute DOMString type; attribute DOMString type;
[CEReactions, SetterThrows] [CEReactions, SetterThrows, Pref="dom.menuitem.enabled"]
attribute DOMString label; attribute DOMString label;
}; };

View File

@ -12,7 +12,7 @@
*/ */
// http://www.whatwg.org/specs/web-apps/current-work/#the-menuitem-element // http://www.whatwg.org/specs/web-apps/current-work/#the-menuitem-element
[HTMLConstructor] [HTMLConstructor, Pref="dom.menuitem.enabled"]
interface HTMLMenuItemElement : HTMLElement { interface HTMLMenuItemElement : HTMLElement {
[CEReactions, SetterThrows] [CEReactions, SetterThrows]
attribute DOMString type; attribute DOMString type;

View File

@ -576,8 +576,10 @@ ul, menu, dir {
padding-inline-start: 40px; padding-inline-start: 40px;
} }
menu[type="context"] { @supports -moz-bool-pref("dom.menuitem.enabled") {
display: none !important; menu[type="context"] {
display: none !important;
}
} }
ol { ol {

View File

@ -4978,6 +4978,9 @@ pref("dom.mozInputMethod.enabled", false);
// Enable mapped array buffer by default. // Enable mapped array buffer by default.
pref("dom.mapped_arraybuffer.enabled", true); pref("dom.mapped_arraybuffer.enabled", true);
// Whether <menuitem> is a thing or not.
pref("dom.menuitem.enabled", false);
#ifdef MOZ_SAFE_BROWSING #ifdef MOZ_SAFE_BROWSING
// The tables used for Safebrowsing phishing and malware checks. // The tables used for Safebrowsing phishing and malware checks.
pref("urlclassifier.malwareTable", "goog-malware-shavar,goog-unwanted-shavar,test-malware-simple,test-unwanted-simple"); pref("urlclassifier.malwareTable", "goog-malware-shavar,goog-unwanted-shavar,test-malware-simple,test-unwanted-simple");