Bug 1066383, rework custom html menu item handling to support contextmenu attribute in separate process, r=janv,mconley,peterv

This commit is contained in:
Neil Deakin
2014-12-16 11:21:11 -05:00
parent 7bdb01f0a1
commit c59b7336ca
21 changed files with 515 additions and 390 deletions

View File

@@ -9,11 +9,13 @@
#include "mozilla/EventDispatcher.h"
#include "mozilla/dom/HTMLMenuElementBinding.h"
#include "mozilla/dom/HTMLMenuItemElement.h"
#include "nsIMenuBuilder.h"
#include "nsAttrValueInlines.h"
#include "nsContentUtils.h"
#include "nsXULContextMenuBuilder.h"
#include "nsIURI.h"
#define HTMLMENUBUILDER_CONTRACTID "@mozilla.org/content/html-menu-builder;1"
NS_IMPL_NS_NEW_HTML_ELEMENT(Menu)
namespace mozilla {
@@ -97,12 +99,8 @@ HTMLMenuElement::CreateBuilder(nsIMenuBuilder** _retval)
{
NS_ENSURE_TRUE(nsContentUtils::IsCallerChrome(), NS_ERROR_DOM_SECURITY_ERR);
*_retval = nullptr;
if (mType == MENU_TYPE_CONTEXT) {
NS_ADDREF(*_retval = new nsXULContextMenuBuilder());
}
nsCOMPtr<nsIMenuBuilder> builder = CreateBuilder();
builder.swap(*_retval);
return NS_OK;
}
@@ -113,8 +111,9 @@ HTMLMenuElement::CreateBuilder()
return nullptr;
}
nsCOMPtr<nsIMenuBuilder> ret = new nsXULContextMenuBuilder();
return ret.forget();
nsCOMPtr<nsIMenuBuilder> builder = do_CreateInstance(HTMLMENUBUILDER_CONTRACTID);
NS_WARN_IF(!builder);
return builder.forget();
}
NS_IMETHODIMP