Bug 1372276 - Part 5: Remove HTML MenuBuilder; r?bz,smaug,snorp
MozReview-Commit-ID: KTzknrlIA23
--- a/browser/installer/package-manifest.in
+++ b/browser/installer/package-manifest.in
@@ -512,18 +512,16 @@
@RESPATH@/components/servicesComponents.manifest
@RESPATH@/components/cryptoComponents.manifest
@RESPATH@/components/TelemetryStartup.js
@RESPATH@/components/TelemetryStartup.manifest
@RESPATH@/components/XULStore.js
@RESPATH@/components/XULStore.manifest
@RESPATH@/components/recording-cmdline.js
@RESPATH@/components/recording-cmdline.manifest
-@RESPATH@/components/htmlMenuBuilder.js
-@RESPATH@/components/htmlMenuBuilder.manifest
@RESPATH@/components/NotificationStorage.js
@RESPATH@/components/NotificationStorage.manifest
@RESPATH@/components/Push.js
@RESPATH@/components/Push.manifest
@RESPATH@/components/PushComponents.js
@RESPATH@/components/remotebrowserutils.manifest
--- a/dom/bindings/Bindings.conf
+++ b/dom/bindings/Bindings.conf
@@ -1732,17 +1732,16 @@ addExternalIface('Cookie', nativeType='n
headerFile='nsICookie2.h', notflattened=True)
addExternalIface('Counter')
addExternalIface('RTCDataChannel', nativeType='nsIDOMDataChannel')
addExternalIface('HitRegionOptions', nativeType='nsISupports')
addExternalIface('imgINotificationObserver', nativeType='imgINotificationObserver')
addExternalIface('imgIRequest', nativeType='imgIRequest', notflattened=True)
addExternalIface('LoadInfo', nativeType='nsILoadInfo',
headerFile='nsILoadInfo.h', notflattened=True)
-addExternalIface('MenuBuilder', nativeType='nsIMenuBuilder', notflattened=True)
addExternalIface('XULControllers', nativeType='nsIControllers', notflattened=True)
addExternalIface('MozFrameLoader', nativeType='nsIFrameLoader', notflattened=True)
addExternalIface('MozObserver', nativeType='nsIObserver', notflattened=True)
addExternalIface('MozRDFCompositeDataSource', nativeType='nsIRDFCompositeDataSource',
notflattened=True)
addExternalIface('MozRDFResource', nativeType='nsIRDFResource', notflattened=True)
addExternalIface('MozTreeView', nativeType='nsITreeView',
headerFile='nsITreeView.h', notflattened=True)
--- a/dom/html/HTMLMenuElement.cpp
+++ b/dom/html/HTMLMenuElement.cpp
@@ -5,36 +5,25 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "mozilla/dom/HTMLMenuElement.h"
#include "mozilla/BasicEvents.h"
#include "mozilla/EventDispatcher.h"
#include "mozilla/dom/HTMLMenuElementBinding.h"
#include "mozilla/dom/HTMLMenuItemElement.h"
-#include "nsIMenuBuilder.h"
#include "nsAttrValueInlines.h"
#include "nsContentUtils.h"
#include "nsIURI.h"
-#define HTMLMENUBUILDER_CONTRACTID "@mozilla.org/content/html-menu-builder;1"
-
NS_IMPL_NS_NEW_HTML_ELEMENT(Menu)
namespace mozilla {
namespace dom {
-enum SeparatorType
-{
- ST_TRUE_INIT = -1,
- ST_FALSE = 0,
- ST_TRUE = 1
-};
-
-
HTMLMenuElement::HTMLMenuElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo)
: nsGenericHTMLElement(aNodeInfo)
{
}
HTMLMenuElement::~HTMLMenuElement()
{
@@ -43,34 +32,16 @@ HTMLMenuElement::~HTMLMenuElement()
NS_IMPL_ISUPPORTS_INHERITED(HTMLMenuElement, nsGenericHTMLElement,
nsIDOMHTMLMenuElement)
NS_IMPL_ELEMENT_CLONE(HTMLMenuElement)
NS_IMPL_BOOL_ATTR(HTMLMenuElement, Compact, compact)
-already_AddRefed<nsIMenuBuilder>
-HTMLMenuElement::CreateBuilder()
-{
- nsCOMPtr<nsIMenuBuilder> builder = do_CreateInstance(HTMLMENUBUILDER_CONTRACTID);
- NS_WARNING_ASSERTION(builder, "No builder available");
- return builder.forget();
-}
-
-void
-HTMLMenuElement::Build(nsIMenuBuilder* aBuilder)
-{
- if (!aBuilder) {
- return;
- }
-
- BuildSubmenu(EmptyString(), this, aBuilder);
-}
-
nsresult
HTMLMenuElement::AfterSetAttr(int32_t aNameSpaceID, nsIAtom* aName,
const nsAttrValue* aValue,
const nsAttrValue* aOldValue, bool aNotify)
{
return nsGenericHTMLElement::AfterSetAttr(aNameSpaceID, aName, aValue,
aOldValue, aNotify);
}
@@ -80,120 +51,16 @@ HTMLMenuElement::ParseAttribute(int32_t
nsIAtom* aAttribute,
const nsAString& aValue,
nsAttrValue& aResult)
{
return nsGenericHTMLElement::ParseAttribute(aNamespaceID, aAttribute, aValue,
aResult);
}
-void
-HTMLMenuElement::BuildSubmenu(const nsAString& aLabel,
- nsIContent* aContent,
- nsIMenuBuilder* aBuilder)
-{
- aBuilder->OpenContainer(aLabel);
-
- int8_t separator = ST_TRUE_INIT;
- TraverseContent(aContent, aBuilder, separator);
-
- if (separator == ST_TRUE) {
- aBuilder->UndoAddSeparator();
- }
-
- aBuilder->CloseContainer();
-}
-
-// static
-bool
-HTMLMenuElement::CanLoadIcon(nsIContent* aContent, const nsAString& aIcon)
-{
- if (aIcon.IsEmpty()) {
- return false;
- }
-
- nsIDocument* doc = aContent->OwnerDoc();
-
- nsCOMPtr<nsIURI> baseURI = aContent->GetBaseURI();
- nsCOMPtr<nsIURI> uri;
- nsContentUtils::NewURIWithDocumentCharset(getter_AddRefs(uri), aIcon, doc,
- baseURI);
-
- if (!uri) {
- return false;
- }
-
- return nsContentUtils::CanLoadImage(uri, aContent, doc,
- aContent->NodePrincipal());
-}
-
-void
-HTMLMenuElement::TraverseContent(nsIContent* aContent,
- nsIMenuBuilder* aBuilder,
- int8_t& aSeparator)
-{
- nsCOMPtr<nsIContent> child;
- for (child = aContent->GetFirstChild(); child;
- child = child->GetNextSibling()) {
- nsGenericHTMLElement* element = nsGenericHTMLElement::FromContent(child);
- if (!element) {
- continue;
- }
-
- if (child->IsHTMLElement(nsGkAtoms::menuitem)) {
- HTMLMenuItemElement* menuitem = HTMLMenuItemElement::FromContent(child);
-
- if (menuitem->IsHidden()) {
- continue;
- }
-
- nsAutoString label;
- menuitem->GetLabel(label);
- if (label.IsEmpty()) {
- continue;
- }
-
- nsAutoString icon;
- menuitem->GetIcon(icon);
-
- aBuilder->AddItemFor(menuitem, CanLoadIcon(child, icon));
-
- aSeparator = ST_FALSE;
- } else if (child->IsHTMLElement(nsGkAtoms::hr)) {
- aBuilder->AddSeparator();
- } else if (child->IsHTMLElement(nsGkAtoms::menu) && !element->IsHidden()) {
- if (child->HasAttr(kNameSpaceID_None, nsGkAtoms::label)) {
- nsAutoString label;
- child->GetAttr(kNameSpaceID_None, nsGkAtoms::label, label);
-
- BuildSubmenu(label, child, aBuilder);
-
- aSeparator = ST_FALSE;
- } else {
- AddSeparator(aBuilder, aSeparator);
-
- TraverseContent(child, aBuilder, aSeparator);
-
- AddSeparator(aBuilder, aSeparator);
- }
- }
- }
-}
-
-inline void
-HTMLMenuElement::AddSeparator(nsIMenuBuilder* aBuilder, int8_t& aSeparator)
-{
- if (aSeparator) {
- return;
- }
-
- aBuilder->AddSeparator();
- aSeparator = ST_TRUE;
-}
-
JSObject*
HTMLMenuElement::WrapNode(JSContext* aCx, JS::Handle<JSObject*> aGivenProto)
{
return HTMLMenuElementBinding::Wrap(aCx, this, aGivenProto);
}
} // namespace dom
} // namespace mozilla
--- a/dom/html/HTMLMenuElement.h
+++ b/dom/html/HTMLMenuElement.h
@@ -6,18 +6,16 @@
#ifndef mozilla_dom_HTMLMenuElement_h
#define mozilla_dom_HTMLMenuElement_h
#include "mozilla/Attributes.h"
#include "nsIDOMHTMLMenuElement.h"
#include "nsGenericHTMLElement.h"
-class nsIMenuBuilder;
-
namespace mozilla {
namespace dom {
class HTMLMenuElement final : public nsGenericHTMLElement,
public nsIDOMHTMLMenuElement
{
public:
explicit HTMLMenuElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo);
@@ -48,36 +46,18 @@ public:
{
return GetBoolAttr(nsGkAtoms::compact);
}
void SetCompact(bool aCompact, ErrorResult& aError)
{
SetHTMLBoolAttr(nsGkAtoms::compact, aCompact, aError);
}
- already_AddRefed<nsIMenuBuilder> CreateBuilder();
-
- void Build(nsIMenuBuilder* aBuilder);
-
protected:
virtual ~HTMLMenuElement();
virtual JSObject* WrapNode(JSContext *aCx, JS::Handle<JSObject*> aGivenProto) override;
-
-
-protected:
- static bool CanLoadIcon(nsIContent* aContent, const nsAString& aIcon);
-
- void BuildSubmenu(const nsAString& aLabel,
- nsIContent* aContent,
- nsIMenuBuilder* aBuilder);
-
- void TraverseContent(nsIContent* aContent,
- nsIMenuBuilder* aBuilder,
- int8_t& aSeparator);
-
- void AddSeparator(nsIMenuBuilder* aBuilder, int8_t& aSeparator);
};
} // namespace dom
} // namespace mozilla
#endif // mozilla_dom_HTMLMenuElement_h
deleted file mode 100644
--- a/dom/html/htmlMenuBuilder.js
+++ /dev/null
@@ -1,132 +0,0 @@
-/* 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/. */
-
-// This component is used to build the menus for the HTML contextmenu attribute.
-
-Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");
-
-const Cc = Components.classes;
-const Ci = Components.interfaces;
-
-// A global value that is used to identify each menu item. It is
-// incremented with each one that is found.
-var gGeneratedId = 1;
-
-function HTMLMenuBuilder() {
- this.currentNode = null;
- this.root = null;
- this.items = {};
- this.nestedStack = [];
-};
-
-// Building is done in two steps:
-// The first generates a hierarchical JS object that contains the menu structure.
-// This object is returned by toJSONString.
-//
-// The second step can take this structure and generate a XUL menu hierarchy or
-// other UI from this object. The default UI is done in PageMenu.jsm.
-//
-// When a multi-process browser is used, the first step is performed by the child
-// process and the second step is performed by the parent process.
-
-HTMLMenuBuilder.prototype =
-{
- classID: Components.ID("{51c65f5d-0de5-4edc-9058-60e50cef77f8}"),
- QueryInterface: XPCOMUtils.generateQI([Ci.nsIMenuBuilder]),
-
- currentNode: null,
- root: null,
- items: {},
- nestedStack: [],
-
- toJSONString: function() {
- return JSON.stringify(this.root);
- },
-
- openContainer: function(aLabel) {
- if (!this.currentNode) {
- this.root = {
- type: "menu",
- children: []
- };
- this.currentNode = this.root;
- }
- else {
- let parent = this.currentNode;
- this.currentNode = {
- type: "menu",
- label: aLabel,
- children: []
- };
- parent.children.push(this.currentNode);
- this.nestedStack.push(parent);
- }
- },
-
- addItemFor: function(aElement, aCanLoadIcon) {
- if (!("children" in this.currentNode)) {
- return;
- }
-
- let item = {
- type: "menuitem",
- label: aElement.label
- };
-
- let elementType = aElement.type;
- if (elementType == "checkbox" || elementType == "radio") {
- item.checkbox = true;
-
- if (aElement.checked) {
- item.checked = true;
- }
- }
-
- let icon = aElement.icon;
- if (icon.length > 0 && aCanLoadIcon) {
- item.icon = icon;
- }
-
- if (aElement.disabled) {
- item.disabled = true;
- }
-
- item.id = gGeneratedId++;
- this.currentNode.children.push(item);
-
- this.items[item.id] = aElement;
- },
-
- addSeparator: function() {
- if (!("children" in this.currentNode)) {
- return;
- }
-
- this.currentNode.children.push({ type: "separator"});
- },
-
- undoAddSeparator: function() {
- if (!("children" in this.currentNode)) {
- return;
- }
-
- let children = this.currentNode.children;
- if (children.length && children[children.length - 1].type == "separator") {
- children.pop();
- }
- },
-
- closeContainer: function() {
- this.currentNode = this.nestedStack.length ? this.nestedStack.pop() : this.root;
- },
-
- click: function(id) {
- let item = this.items[id];
- if (item) {
- item.click();
- }
- }
-};
-
-this.NSGetFactory = XPCOMUtils.generateNSGetFactory([HTMLMenuBuilder]);
deleted file mode 100644
--- a/dom/html/htmlMenuBuilder.manifest
+++ /dev/null
@@ -1,3 +0,0 @@
-component {51c65f5d-0de5-4edc-9058-60e50cef77f8} htmlMenuBuilder.js
-contract @mozilla.org/content/html-menu-builder;1 {51c65f5d-0de5-4edc-9058-60e50cef77f8}
-
--- a/dom/html/moz.build
+++ b/dom/html/moz.build
@@ -20,17 +20,16 @@ MOCHITEST_CHROME_MANIFESTS += [
]
BROWSER_CHROME_MANIFESTS += ['test/browser.ini']
XPIDL_SOURCES += [
'nsIDateTimeInputArea.idl',
'nsIFormSubmitObserver.idl',
'nsIImageDocument.idl',
- 'nsIMenuBuilder.idl',
]
XPIDL_MODULE = 'content_html'
EXPORTS += [
'nsGenericHTMLElement.h',
'nsHTMLDNSPrefetch.h',
'nsIConstraintValidation.h',
@@ -215,21 +214,16 @@ UNIFIED_SOURCES += [
'VideoDocument.cpp',
]
SOURCES += [
# Includes npapi.h.
'PluginDocument.cpp',
]
-EXTRA_COMPONENTS += [
- 'htmlMenuBuilder.js',
- 'htmlMenuBuilder.manifest'
-]
-
include('/ipc/chromium/chromium-config.mozbuild')
LOCAL_INCLUDES += [
'/caps',
'/docshell/base',
'/dom/base',
'/dom/canvas',
'/dom/html/input',
deleted file mode 100644
--- a/dom/html/nsIMenuBuilder.idl
+++ /dev/null
@@ -1,76 +0,0 @@
-/* -*- 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/. */
-
-#include "nsISupports.idl"
-
-interface nsIDOMHTMLMenuItemElement;
-
-/**
- * An interface used to construct native toolbar or context menus from <menu>
- */
-
-[scriptable, uuid(93F4A48F-D043-4F45-97FD-9771EA1AF976)]
-interface nsIMenuBuilder : nsISupports
-{
-
- /**
- * Create the top level menu or a submenu. The implementation should create
- * a new context for this menu, so all subsequent methods will add new items
- * to this newly created menu.
- */
- void openContainer(in DOMString aLabel);
-
- /**
- * Add a new menu item. All menu item details can be obtained from
- * the element. This method is not called for hidden elements or elements
- * with no or empty label. The icon should be loaded only if aCanLoadIcon
- * is true.
- */
- void addItemFor(in nsIDOMHTMLMenuItemElement aElement,
- in boolean aCanLoadIcon);
-
- /**
- * Create a new separator.
- */
- void addSeparator();
-
- /**
- * Remove last added separator.
- * Sometimes it's needed to remove last added separator, otherwise it's not
- * possible to implement the postprocessing in one pass.
- * See http://www.whatwg.org/specs/web-apps/current-work/multipage/interactive-elements.html#building-menus-and-toolbars
- */
- void undoAddSeparator();
-
- /**
- * Set the context to the parent menu.
- */
- void closeContainer();
-
- /**
- * Returns a JSON string representing the menu hierarchy. For a context menu,
- * it will be of the form:
- * {
- * type: "menu",
- * children: [
- * {
- * type: "menuitem",
- * label: "label",
- * icon: "image.png"
- * },
- * {
- * type: "separator",
- * },
- * ];
- */
- AString toJSONString();
-
- /**
- * Invoke the action of the menuitem with assigned id aGeneratedItemId.
- *
- * @param aGeneratedItemId the menuitem id
- */
- void click(in DOMString aGeneratedItemId);
-};
--- a/dom/webidl/HTMLMenuElement.webidl
+++ b/dom/webidl/HTMLMenuElement.webidl
@@ -7,42 +7,22 @@
* http://www.whatwg.org/specs/web-apps/current-work/#the-menu-element
* http://www.whatwg.org/specs/web-apps/current-work/#other-elements,-attributes-and-apis
*
* © Copyright 2004-2011 Apple Computer, Inc., Mozilla Foundation, and
* Opera Software ASA. You are granted a license to use, reproduce
* and create derivative works of this document.
*/
-interface MenuBuilder;
-
// http://www.whatwg.org/specs/web-apps/current-work/#the-menu-element
[HTMLConstructor]
interface HTMLMenuElement : HTMLElement {
};
// http://www.whatwg.org/specs/web-apps/current-work/#other-elements,-attributes-and-apis
partial interface HTMLMenuElement {
[CEReactions, SetterThrows]
attribute boolean compact;
};
// Mozilla specific stuff
partial interface HTMLMenuElement {
- /**
- * Creates a native menu builder. The builder type is dependent on menu type.
- * Currently, it returns the @mozilla.org/content/html-menu-builder;1
- * component. Toolbar menus are not yet supported (the method returns null).
- */
- [ChromeOnly]
- MenuBuilder? createBuilder();
-
- /*
- * Builds a menu by iterating over menu children.
- * See http://www.whatwg.org/specs/web-apps/current-work/multipage/interactive-elements.html#building-menus-and-toolbars
- * The caller can use a native builder by calling createBuilder() or provide
- * a custom builder that implements the nsIMenuBuilder interface.
- * A custom builder can be used for example to build native context menus
- * that are not defined using <menupopup>.
- */
- [ChromeOnly]
- void build(MenuBuilder aBuilder);
};
--- a/mobile/android/installer/package-manifest.in
+++ b/mobile/android/installer/package-manifest.in
@@ -357,18 +357,16 @@
#ifndef MOZ_GECKOVIEW_JAR
@BINPATH@/components/TelemetryStartup.js
@BINPATH@/components/TelemetryStartup.manifest
#endif
@BINPATH@/components/XULStore.js
@BINPATH@/components/XULStore.manifest
-@BINPATH@/components/htmlMenuBuilder.js
-@BINPATH@/components/htmlMenuBuilder.manifest
@BINPATH@/components/SystemMessageInternal.js
@BINPATH@/components/SystemMessageManager.js
@BINPATH@/components/SystemMessageCache.js
@BINPATH@/components/SystemMessageManager.manifest
#ifdef MOZ_WEBRTC
@BINPATH@/components/PeerConnection.js