summarylogtreecommitdiffstats
path: root/unity-menubar.patch
diff options
context:
space:
mode:
Diffstat (limited to 'unity-menubar.patch')
-rw-r--r--unity-menubar.patch695
1 files changed, 352 insertions, 343 deletions
diff --git a/unity-menubar.patch b/unity-menubar.patch
index e43298b7e5d4..531c28f1017b 100644
--- a/unity-menubar.patch
+++ b/unity-menubar.patch
@@ -1,23 +1,26 @@
--- a/browser/base/content/browser-menubar.inc
+++ b/browser/base/content/browser-menubar.inc
-@@ -5,7 +5,11 @@
-
- <menubar id="main-menubar"
- onpopupshowing="if (event.target.parentNode.parentNode == this &amp;&amp;
+@@ -7,7 +7,12 @@
+ # On macOS, we don't track whether activation of the native menubar happened
+ # with the keyboard.
+ #ifndef XP_MACOSX
+- onpopupshowing="if (event.target.parentNode.parentNode == this)
++ onpopupshowing="if (event.target.parentNode.parentNode == this &amp;&amp;
+#ifdef MOZ_WIDGET_GTK
+ document.documentElement.getAttribute('shellshowingmenubar') != 'true')
+#else
- !('@mozilla.org/widget/nativemenuservice;1' in Cc))
++ true)
+#endif
this.setAttribute('openedwithkey',
- event.target.parentNode.openedWithKey);">
- <menu id="file-menu" data-l10n-id="menu-file">
+ event.target.parentNode.openedWithKey);"
+ #endif
--- a/browser/base/content/browser.js
+++ b/browser/base/content/browser.js
-@@ -6801,11 +6801,17 @@ function onViewToolbarsPopupShowing(aEve
-
+@@ -6466,11 +6466,18 @@ function onViewToolbarsPopupShowing(aEve
+ MozXULElement.insertFTLIfNeeded("browser/toolbarContextMenu.ftl");
+ let firstMenuItem = aInsertPoint || popup.firstElementChild;
let toolbarNodes = gNavToolbox.querySelectorAll("toolbar");
-
++
+ let shellShowingMenubar = document.documentElement.getAttribute("shellshowingmenubar") == "true";
+
for (let toolbar of toolbarNodes) {
@@ -29,23 +32,22 @@
+ continue;
+ }
+
- let menuItem = document.createXULElement("menuitem");
- let hidingAttribute =
- toolbar.getAttribute("type") == "menubar" ? "autohide" : "collapsed";
---- a/browser/components/places/content/places.xul
-+++ b/browser/components/places/content/places.xul
-@@ -166,7 +166,7 @@
- <toolbarbutton type="menu" class="tabbable"
- onpopupshowing="document.getElementById('placeContent').focus()"
+ if (toolbar.id == "PersonalToolbar") {
+ let menu = BookmarkingUI.buildBookmarksToolbarSubmenu(toolbar);
+ popup.insertBefore(menu, firstMenuItem);
+--- a/browser/components/places/content/places.xhtml
++++ b/browser/components/places/content/places.xhtml
+@@ -165,6 +165,7 @@
#else
-- <menubar id="placesMenu">
-+ <menubar id="placesMenu" _moz-menubarkeeplocal="true">
- <menu accesskey="&organize.accesskey;" class="menu-iconic"
+ <menubar id="placesMenu">
+ <menu class="menu-iconic" data-l10n-id="places-organize-button"
++ _moz-menubarkeeplocal="true"
#endif
- id="organizeButton" label="&organize.label;"
+ id="organizeButton">
+ <menupopup id="organizeButtonPopup">
--- a/dom/xul/XULPopupElement.cpp
+++ b/dom/xul/XULPopupElement.cpp
-@@ -156,6 +156,10 @@ void XULPopupElement::GetState(nsString&
+@@ -208,6 +208,10 @@ void XULPopupElement::GetState(nsString&
// set this here in case there's no frame for the popup
aState.AssignLiteral("closed");
@@ -53,10 +55,10 @@
+ nsAutoString nativeState;
+#endif
+
- nsMenuPopupFrame* menuPopupFrame = do_QueryFrame(GetPrimaryFrame());
- if (menuPopupFrame) {
- switch (menuPopupFrame->PopupState()) {
-@@ -179,6 +183,11 @@ void XULPopupElement::GetState(nsString&
+ if (nsXULPopupManager* pm = nsXULPopupManager::GetInstance()) {
+ switch (pm->GetPopupState(this)) {
+ case ePopupShown:
+@@ -230,6 +234,11 @@ void XULPopupElement::GetState(nsString&
break;
}
}
@@ -70,90 +72,83 @@
nsINode* XULPopupElement::GetTriggerNode() const {
--- a/dom/xul/moz.build
+++ b/dom/xul/moz.build
-@@ -77,6 +77,11 @@ LOCAL_INCLUDES += [
+@@ -82,4 +82,9 @@ LOCAL_INCLUDES += [
- include('/ipc/chromium/chromium-config.mozbuild')
+ include("/ipc/chromium/chromium-config.mozbuild")
-+if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'gtk':
++if CONFIG["MOZ_WIDGET_TOOLKIT"] == "gtk":
+ LOCAL_INCLUDES += [
-+ '/widget/gtk',
++ "/widget/gtk",
+ ]
+
- FINAL_LIBRARY = 'xul'
-
- if CONFIG['CC_TYPE'] in ('clang', 'gcc'):
+ FINAL_LIBRARY = "xul"
--- a/layout/build/moz.build
+++ b/layout/build/moz.build
-@@ -70,6 +70,10 @@ elif CONFIG['MOZ_WIDGET_TOOLKIT'] == 'an
- '/dom/system',
- '/dom/system/android',
+@@ -70,6 +70,10 @@ elif CONFIG["MOZ_WIDGET_TOOLKIT"] == "an
+ "/dom/system",
+ "/dom/system/android",
]
-+elif CONFIG['MOZ_WIDGET_TOOLKIT'] == 'gtk':
++elif CONFIG["MOZ_WIDGET_TOOLKIT"] == "gtk":
+ LOCAL_INCLUDES += [
-+ '/widget/gtk',
++ "/widget/gtk",
+ ]
XPCOM_MANIFESTS += [
- 'components.conf',
+ "components.conf",
--- a/modules/libpref/init/all.js
+++ b/modules/libpref/init/all.js
-@@ -327,6 +327,9 @@ pref("dom.inputevent.datatransfer.enable
+@@ -311,6 +311,9 @@ pref("dom.mouseevent.click.hack.use_lega
+ // Fastback caching - if this pref is negative, then we calculate the number
// of content viewers to cache based on the amount of available memory.
pref("browser.sessionhistory.max_total_viewers", -1);
-
+#ifdef MOZ_WIDGET_GTK
+pref("ui.use_unity_menubar", true);
+#endif
- pref("ui.click_hold_context_menus", false);
- // 0 = false, 1 = true, 2 = autodetect.
- pref("ui.android.mouse_as_touch", 1);
+
+ // min font device pixel size at which to turn on high quality
+ pref("browser.display.auto_quality_min_font_size", 20);
--- a/toolkit/content/xul.css
+++ b/toolkit/content/xul.css
-@@ -212,6 +212,18 @@ toolbar[type="menubar"] {
+@@ -229,6 +229,13 @@ toolbox {
+ }
}
- %endif
-+%ifdef MOZ_WIDGET_GTK
-+window[shellshowingmenubar="true"] menubar {
++@media (-moz-platform: linux) {
++*|*:root[shellshowingmenubar="true"]
++toolbar[type="menubar"]:not([customizing="true"]) {
+ display: none !important;
+}
-+
-+window[shellshowingmenubar="true"]
-+toolbar[type="menubar"]:not([customizing="true"]) {
-+ min-height: 0 !important;
-+ border: 0 !important;
+}
-+%endif
+
toolbarspring {
-moz-box-flex: 1000;
}
--- a/widget/gtk/moz.build
+++ b/widget/gtk/moz.build
-@@ -53,6 +53,15 @@ UNIFIED_SOURCES += [
- ]
+@@ -77,6 +77,15 @@ UNIFIED_SOURCES += [
SOURCES += [
-+ 'nsDbusmenu.cpp',
-+ 'nsMenu.cpp', # conflicts with X11 headers
-+ 'nsMenuBar.cpp',
-+ 'nsMenuContainer.cpp',
-+ 'nsMenuItem.cpp',
-+ 'nsMenuObject.cpp',
-+ 'nsMenuSeparator.cpp',
-+ 'nsNativeMenuDocListener.cpp',
-+ 'nsNativeMenuService.cpp',
- 'nsWindow.cpp', # conflicts with X11 headers
- ]
-
-@@ -129,6 +138,7 @@ FINAL_LIBRARY = 'xul'
- LOCAL_INCLUDES += [
- '/layout/base',
- '/layout/generic',
-+ '/layout/style',
- '/layout/xul',
- '/other-licenses/atk-1.0',
- '/widget',
+ "MediaKeysEventSourceFactory.cpp",
++ "nsDbusmenu.cpp",
++ "nsMenu.cpp", # conflicts with X11 headers
++ "nsMenuBar.cpp",
++ "nsMenuContainer.cpp",
++ "nsMenuItem.cpp",
++ "nsMenuObject.cpp",
++ "nsMenuSeparator.cpp",
++ "nsNativeMenuDocListener.cpp",
++ "nsNativeMenuService.cpp",
+ "nsNativeThemeGTK.cpp", # conflicts with X11 headers
+ "nsWindow.cpp", # conflicts with X11 headers
+ "WaylandVsyncSource.cpp", # conflicts with X11 headers
+@@ -152,6 +161,7 @@ LOCAL_INCLUDES += [
+ "/layout/base",
+ "/layout/forms",
+ "/layout/generic",
++ "/layout/style",
+ "/layout/xul",
+ "/other-licenses/atk-1.0",
+ "/third_party/cups/include",
--- /dev/null
+++ b/widget/gtk/nsDbusmenu.cpp
@@ -0,0 +1,61 @@
@@ -324,7 +319,7 @@
+#endif /* __nsDbusmenu_h__ */
--- /dev/null
+++ b/widget/gtk/nsMenu.cpp
-@@ -0,0 +1,844 @@
+@@ -0,0 +1,795 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/* vim:expandtab:shiftwidth=4:tabstop=4:
+ */
@@ -339,13 +334,9 @@
+#include "mozilla/Assertions.h"
+#include "mozilla/ComputedStyleInlines.h"
+#include "mozilla/EventDispatcher.h"
-+#include "mozilla/GuardObjects.h"
+#include "mozilla/MouseEvents.h"
-+#include "mozilla/Move.h"
+#include "mozilla/PresShell.h"
+#include "mozilla/PresShellInlines.h"
-+#include "nsAutoPtr.h"
-+#include "nsBindingManager.h"
+#include "nsComponentManagerUtils.h"
+#include "nsContentUtils.h"
+#include "nsCSSValue.h"
@@ -358,8 +349,6 @@
+#include "nsString.h"
+#include "nsStyleStruct.h"
+#include "nsThreadUtils.h"
-+#include "nsXBLBinding.h"
-+#include "nsXBLService.h"
+
+#include "nsNativeMenuDocListener.h"
+
@@ -442,45 +431,6 @@
+ EventDispatcher::Dispatch(aTarget, nullptr, &event);
+}
+
-+static void
-+AttachXBLBindings(nsIContent *aContent)
-+{
-+ dom::Document *doc = aContent->OwnerDoc();
-+ PresShell *shell = doc->GetPresShell();
-+ if (!shell) {
-+ return;
-+ }
-+
-+ RefPtr<ComputedStyle> style =
-+ shell->StyleSet()->ResolveStyleLazily(*aContent->AsElement());
-+
-+ if (!style) {
-+ return;
-+ }
-+
-+ const auto& binding = style->StyleDisplay()->mBinding;
-+ if (binding.IsNone()) {
-+ return;
-+ }
-+
-+ nsXBLService* xbl = nsXBLService::GetInstance();
-+ if (!xbl) {
-+ return;
-+ }
-+
-+ RefPtr<nsXBLBinding> pendingBinding;
-+ const auto& url = binding.AsUrl();
-+ nsresult rv = xbl->LoadBindings(aContent->AsElement(),
-+ url.GetURI(),
-+ url.ExtraData().Principal(),
-+ getter_AddRefs(pendingBinding));
-+ if ((NS_FAILED(rv) && rv != NS_ERROR_XBL_BLOCKED) || !pendingBinding) {
-+ return;
-+ }
-+
-+ doc->BindingManager()->AddToAttachedQueue(pendingBinding);
-+}
-+
+void
+nsMenu::SetPopupState(EPopupState aState)
+{
@@ -493,13 +443,13 @@
+ nsAutoString state;
+ switch (aState) {
+ case ePopupState_Showing:
-+ state.Assign(NS_LITERAL_STRING("showing"));
++ state.Assign(u"showing"_ns);
+ break;
+ case ePopupState_Open:
-+ state.Assign(NS_LITERAL_STRING("open"));
++ state.Assign(u"open"_ns);
+ break;
+ case ePopupState_Hiding:
-+ state.Assign(NS_LITERAL_STRING("hiding"));
++ state.Assign(u"hiding"_ns);
+ break;
+ default:
+ break;
@@ -537,12 +487,12 @@
+
+ nsAutoCString event(name);
+
-+ if (event.Equals(NS_LITERAL_CSTRING("closed"))) {
++ if (event.Equals("closed"_ns)) {
+ self->OnClose();
+ return;
+ }
+
-+ if (event.Equals(NS_LITERAL_CSTRING("opened"))) {
++ if (event.Equals("opened"_ns)) {
+ self->OnOpen();
+ return;
+ }
@@ -606,7 +556,7 @@
+ DispatchMouseEvent(mPopupContent, eXULPopupShowing);
+
+ ContentNode()->AsElement()->SetAttr(kNameSpaceID_None, nsGkAtoms::open,
-+ NS_LITERAL_STRING("true"), true);
++ u"true"_ns, true);
+ }
+
+ if (!self) {
@@ -690,8 +640,6 @@
+ return;
+ }
+
-+ AttachXBLBindings(mPopupContent);
-+
+ DocListener()->RegisterForContentChanges(mPopupContent, this);
+}
+
@@ -816,12 +764,10 @@
+ mNeedsUpdate = true;
+
+ MaybeAddPlaceholderItem();
-+
-+ AttachXBLBindings(ContentNode());
+}
+
+void
-+nsMenu::Update(ComputedStyle *aComputedStyle)
++nsMenu::Update(const ComputedStyle *aComputedStyle)
+{
+ if (mNeedsUpdate) {
+ mNeedsUpdate = false;
@@ -873,10 +819,10 @@
+ UpdateLabel();
+ } else if (aAttribute == nsGkAtoms::hidden ||
+ aAttribute == nsGkAtoms::collapsed) {
-+ RefPtr<ComputedStyle> style = GetComputedStyle();
++ RefPtr<const ComputedStyle> style = GetComputedStyle();
+ UpdateVisibility(style);
+ } else if (aAttribute == nsGkAtoms::image) {
-+ RefPtr<ComputedStyle> style = GetComputedStyle();
++ RefPtr<const ComputedStyle> style = GetComputedStyle();
+ UpdateIcon(style);
+ }
+}
@@ -1122,7 +1068,7 @@
+
+ OnOpen();
+
-+ mOpenDelayTimer = do_CreateInstance(NS_TIMER_CONTRACTID);
++ mOpenDelayTimer = NS_NewTimer();
+ if (!mOpenDelayTimer) {
+ return;
+ }
@@ -1264,7 +1210,7 @@
+ nsIContent *aChild);
+
+ void InitializeNativeData() override;
-+ void Update(mozilla::ComputedStyle *aComputedStyle) override;
++ void Update(const mozilla::ComputedStyle *aComputedStyle) override;
+ nsMenuObject::PropertyFlags SupportedProperties() const override;
+
+ void OnAttributeChanged(nsIContent *aContent, nsAtom *aAttribute) override;
@@ -1297,7 +1243,7 @@
+#endif /* __nsMenu_h__ */
--- /dev/null
+++ b/widget/gtk/nsMenuBar.cpp
-@@ -0,0 +1,550 @@
+@@ -0,0 +1,548 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/* vim:expandtab:shiftwidth=4:tabstop=4:
+ */
@@ -1312,9 +1258,7 @@
+#include "mozilla/dom/Event.h"
+#include "mozilla/dom/KeyboardEvent.h"
+#include "mozilla/dom/KeyboardEventBinding.h"
-+#include "mozilla/Move.h"
+#include "mozilla/Preferences.h"
-+#include "nsAutoPtr.h"
+#include "nsContentUtils.h"
+#include "nsIDOMEventListener.h"
+#include "nsIRunnable.h"
@@ -1416,9 +1360,9 @@
+ nsAutoString type;
+ aEvent->GetType(type);
+
-+ if (type.Equals(NS_LITERAL_STRING("focus"))) {
++ if (type.Equals(u"focus"_ns)) {
+ mOwner->Focus();
-+ } else if (type.Equals(NS_LITERAL_STRING("blur"))) {
++ } else if (type.Equals(u"blur"_ns)) {
+ mOwner->Blur();
+ }
+
@@ -1427,11 +1371,11 @@
+ return NS_OK;
+ }
+
-+ if (type.Equals(NS_LITERAL_STRING("keypress"))) {
++ if (type.Equals(u"keypress"_ns)) {
+ return mOwner->Keypress(keyEvent);
-+ } else if (type.Equals(NS_LITERAL_STRING("keydown"))) {
++ } else if (type.Equals(u"keydown"_ns)) {
+ return mOwner->KeyDown(keyEvent);
-+ } else if (type.Equals(NS_LITERAL_STRING("keyup"))) {
++ } else if (type.Equals(u"keyup"_ns)) {
+ return mOwner->KeyUp(keyEvent);
+ }
+
@@ -1472,7 +1416,7 @@
+ g_object_ref(mTopLevel);
+
+ nsAutoCString path;
-+ path.Append(NS_LITERAL_CSTRING("/com/canonical/menu/"));
++ path.Append("/com/canonical/menu/"_ns);
+ char xid[10];
+ sprintf(xid, "%X", static_cast<uint32_t>(
+ GDK_WINDOW_XID(gtk_widget_get_window(mTopLevel))));
@@ -1530,19 +1474,19 @@
+void
+nsMenuBar::DisconnectDocumentEventListeners()
+{
-+ mDocument->RemoveEventListener(NS_LITERAL_STRING("focus"),
++ mDocument->RemoveEventListener(u"focus"_ns,
+ mEventListener,
+ true);
-+ mDocument->RemoveEventListener(NS_LITERAL_STRING("blur"),
++ mDocument->RemoveEventListener(u"blur"_ns,
+ mEventListener,
+ true);
-+ mDocument->RemoveEventListener(NS_LITERAL_STRING("keypress"),
++ mDocument->RemoveEventListener(u"keypress"_ns,
+ mEventListener,
+ false);
-+ mDocument->RemoveEventListener(NS_LITERAL_STRING("keydown"),
++ mDocument->RemoveEventListener(u"keydown"_ns,
+ mEventListener,
+ false);
-+ mDocument->RemoveEventListener(NS_LITERAL_STRING("keyup"),
++ mDocument->RemoveEventListener(u"keyup"_ns,
+ mEventListener,
+ false);
+}
@@ -1552,7 +1496,7 @@
+{
+ ContentNode()->OwnerDoc()->GetRootElement()->SetAttr(
+ kNameSpaceID_None, nsGkAtoms::shellshowingmenubar,
-+ aShowing ? NS_LITERAL_STRING("true") : NS_LITERAL_STRING("false"),
++ aShowing ? u"true"_ns : u"false"_ns,
+ true);
+}
+
@@ -1561,7 +1505,7 @@
+{
+ ContentNode()->AsElement()->SetAttr(kNameSpaceID_None,
+ nsGkAtoms::openedwithkey,
-+ NS_LITERAL_STRING("false"), true);
++ u"false"_ns, true);
+}
+
+void
@@ -1639,7 +1583,7 @@
+
+ ContentNode()->AsElement()->SetAttr(kNameSpaceID_None,
+ nsGkAtoms::openedwithkey,
-+ NS_LITERAL_STRING("true"), true);
++ u"true"_ns, true);
+ static_cast<nsMenu *>(found)->OpenMenu();
+
+ aEvent->StopPropagation();
@@ -1806,26 +1750,26 @@
+
+ mIsActive = true;
+
-+ mDocument->AddEventListener(NS_LITERAL_STRING("focus"),
++ mDocument->AddEventListener(u"focus"_ns,
+ mEventListener,
+ true);
-+ mDocument->AddEventListener(NS_LITERAL_STRING("blur"),
++ mDocument->AddEventListener(u"blur"_ns,
+ mEventListener,
+ true);
-+ mDocument->AddEventListener(NS_LITERAL_STRING("keypress"),
++ mDocument->AddEventListener(u"keypress"_ns,
+ mEventListener,
+ false);
-+ mDocument->AddEventListener(NS_LITERAL_STRING("keydown"),
++ mDocument->AddEventListener(u"keydown"_ns,
+ mEventListener,
+ false);
-+ mDocument->AddEventListener(NS_LITERAL_STRING("keyup"),
++ mDocument->AddEventListener(u"keyup"_ns,
+ mEventListener,
+ false);
+
+ // Clear this. Not sure if we really need to though
+ ContentNode()->AsElement()->SetAttr(kNameSpaceID_None,
+ nsGkAtoms::openedwithkey,
-+ NS_LITERAL_STRING("false"), true);
++ u"false"_ns, true);
+
+ DocListener()->Start();
+ Build();
@@ -1964,7 +1908,7 @@
+#endif /* __nsMenuBar_h__ */
--- /dev/null
+++ b/widget/gtk/nsMenuContainer.cpp
-@@ -0,0 +1,171 @@
+@@ -0,0 +1,170 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/* vim:expandtab:shiftwidth=4:tabstop=4:
+ */
@@ -1973,7 +1917,6 @@
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+#include "mozilla/DebugOnly.h"
-+#include "mozilla/Move.h"
+#include "nsGkAtoms.h"
+#include "nsIContent.h"
+
@@ -2104,7 +2047,7 @@
+ index));
+ }
+
-+ MOZ_ALWAYS_TRUE(mChildren.InsertElementAt(index, std::move(aChild)));
++ mChildren.InsertElementAt(index, std::move(aChild));
+}
+
+void
@@ -2118,7 +2061,7 @@
+ aChild->GetNativeData()));
+ }
+
-+ MOZ_ALWAYS_TRUE(mChildren.AppendElement(std::move(aChild)));
++ mChildren.AppendElement(std::move(aChild));
+}
+
+bool
@@ -2211,7 +2154,7 @@
+#endif /* __nsMenuContainer_h__ */
--- /dev/null
+++ b/widget/gtk/nsMenuItem.cpp
-@@ -0,0 +1,764 @@
+@@ -0,0 +1,766 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/* vim:expandtab:shiftwidth=4:tabstop=4:
+ */
@@ -2225,10 +2168,8 @@
+#include "mozilla/dom/Element.h"
+#include "mozilla/dom/KeyboardEventBinding.h"
+#include "mozilla/dom/XULCommandEvent.h"
-+#include "mozilla/Move.h"
+#include "mozilla/Preferences.h"
+#include "mozilla/TextEvents.h"
-+#include "nsAutoPtr.h"
+#include "nsContentUtils.h"
+#include "nsCRT.h"
+#include "nsGkAtoms.h"
@@ -2560,22 +2501,22 @@
+ ContentNode()->AsElement()->SetAttr(kNameSpaceID_None,
+ nsGkAtoms::checked,
+ mIsChecked ?
-+ NS_LITERAL_STRING("false")
-+ : NS_LITERAL_STRING("true"),
++ u"false"_ns
++ : u"true"_ns,
+ true);
+ }
+
+ dom::Document *doc = ContentNode()->OwnerDoc();
+ ErrorResult rv;
+ RefPtr<dom::Event> event =
-+ doc->CreateEvent(NS_LITERAL_STRING("xulcommandevent"),
++ doc->CreateEvent(u"xulcommandevent"_ns,
+ dom::CallerType::System, rv);
+ if (!rv.Failed()) {
+ RefPtr<dom::XULCommandEvent> command = event->AsXULCommandEvent();
+ if (command) {
-+ command->InitCommandEvent(NS_LITERAL_STRING("command"), true, true,
++ command->InitCommandEvent(u"command"_ns, true, true,
+ nsGlobalWindowInner::Cast(doc->GetInnerWindow()),
-+ 0, false, false, false, false, nullptr, 0, rv);
++ 0, false, false, false, false, 0, nullptr, 0, rv);
+ if (!rv.Failed()) {
+ event->SetTrusted(true);
+ ContentNode()->DispatchEvent(*event, rv);
@@ -2795,6 +2736,10 @@
+ for (uint32_t i = 0; i < count; ++i) {
+ nsIContent *sibling = parent->GetChildAt_Deprecated(i);
+
++ if (sibling->IsComment()) {
++ continue;
++ }
++
+ nsAutoString otherName;
+ sibling->AsElement()->GetAttr(kNameSpaceID_None, nsGkAtoms::name,
+ otherName);
@@ -2845,7 +2790,7 @@
+ eCaseMatters)) {
+ ContentNode()->AsElement()->SetAttr(kNameSpaceID_None,
+ nsGkAtoms::disabled,
-+ NS_LITERAL_STRING("true"), true);
++ u"true"_ns, true);
+ } else {
+ ContentNode()->AsElement()->UnsetAttr(kNameSpaceID_None,
+ nsGkAtoms::disabled, true);
@@ -2858,7 +2803,7 @@
+}
+
+void
-+nsMenuItem::Update(ComputedStyle *aComputedStyle)
++nsMenuItem::Update(const ComputedStyle *aComputedStyle)
+{
+ if (mNeedsUpdate) {
+ mNeedsUpdate = false;
@@ -2933,10 +2878,10 @@
+ UpdateState();
+ } else if (aAttribute == nsGkAtoms::hidden ||
+ aAttribute == nsGkAtoms::collapsed) {
-+ RefPtr<ComputedStyle> style = GetComputedStyle();
++ RefPtr<const ComputedStyle> style = GetComputedStyle();
+ UpdateVisibility(style);
+ } else if (aAttribute == nsGkAtoms::image) {
-+ RefPtr<ComputedStyle> style = GetComputedStyle();
++ RefPtr<const ComputedStyle> style = GetComputedStyle();
+ UpdateIcon(style);
+ }
+ } else if (aContent == mKeyContent &&
@@ -3043,7 +2988,7 @@
+
+ void InitializeNativeData() override;
+ void UpdateContentAttributes() override;
-+ void Update(mozilla::ComputedStyle *aComputedStyle) override;
++ void Update(const mozilla::ComputedStyle *aComputedStyle) override;
+ bool IsCompatibleWithNativeData(DbusmenuMenuitem *aNativeData) const override;
+ nsMenuObject::PropertyFlags SupportedProperties() const override;
+
@@ -3061,7 +3006,7 @@
+#endif /* __nsMenuItem_h__ */
--- /dev/null
+++ b/widget/gtk/nsMenuObject.cpp
-@@ -0,0 +1,664 @@
+@@ -0,0 +1,653 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/* vim:expandtab:shiftwidth=4:tabstop=4:
+ */
@@ -3081,6 +3026,7 @@
+#include "mozilla/Preferences.h"
+#include "mozilla/PresShell.h"
+#include "mozilla/PresShellInlines.h"
++#include "mozilla/GRefPtr.h"
+#include "nsAttrValue.h"
+#include "nsComputedDOMStyle.h"
+#include "nsContentUtils.h"
@@ -3136,7 +3082,7 @@
+
+ nsMenuObjectIconLoader(nsMenuObject *aOwner) : mOwner(aOwner) { };
+
-+ void LoadIcon(ComputedStyle *aComputedStyle);
++ void LoadIcon(const ComputedStyle *aComputedStyle);
+ void Destroy();
+
+private:
@@ -3145,21 +3091,20 @@
+ nsMenuObject *mOwner;
+ RefPtr<imgRequestProxy> mImageRequest;
+ nsCOMPtr<nsIURI> mURI;
-+ nsIntRect mImageRect;
+};
+
+NS_IMPL_ISUPPORTS(nsMenuObjectIconLoader, imgINotificationObserver)
+
-+NS_IMETHODIMP
++void
+nsMenuObjectIconLoader::Notify(imgIRequest *aProxy,
+ int32_t aType, const nsIntRect *aRect)
+{
+ if (!mOwner) {
-+ return NS_OK;
++ return;
+ }
+
+ if (aProxy != mImageRequest) {
-+ return NS_ERROR_FAILURE;
++ return;
+ }
+
+ if (aType == imgINotificationObserver::LOAD_COMPLETE) {
@@ -3168,7 +3113,7 @@
+ (status & imgIRequest::STATUS_ERROR)) {
+ mImageRequest->Cancel(NS_BINDING_ABORTED);
+ mImageRequest = nullptr;
-+ return NS_ERROR_FAILURE;
++ return;
+ }
+
+ nsCOMPtr<imgIContainer> image;
@@ -3180,27 +3125,23 @@
+ image->GetWidth(&width);
+ image->GetHeight(&height);
+ image->RequestDecodeForSize(nsIntSize(width, height), imgIContainer::FLAG_NONE);
-+ return NS_OK;
++ return;
+ }
+
+ if (aType == imgINotificationObserver::DECODE_COMPLETE) {
+ mImageRequest->Cancel(NS_BINDING_ABORTED);
+ mImageRequest = nullptr;
-+ return NS_OK;
++ return;
+ }
+
+ if (aType != imgINotificationObserver::FRAME_COMPLETE) {
-+ return NS_OK;
++ return;
+ }
+
+ nsCOMPtr<imgIContainer> img;
+ mImageRequest->GetImage(getter_AddRefs(img));
+ if (!img) {
-+ return NS_ERROR_FAILURE;
-+ }
-+
-+ if (!mImageRect.IsEmpty()) {
-+ img = ImageOps::Clip(img, mImageRect);
++ return;
+ }
+
+ int32_t width, height;
@@ -3209,7 +3150,7 @@
+
+ if (width <= 0 || height <= 0) {
+ mOwner->ClearIcon();
-+ return NS_OK;
++ return;
+ }
+
+ if (width > 100 || height > 100) {
@@ -3218,27 +3159,25 @@
+ // GDbus helpfully aborts the application. Thank you :)
+ NS_WARNING("Icon data too large");
+ mOwner->ClearIcon();
-+ return NS_OK;
++ return;
+ }
+
-+ GdkPixbuf *pixbuf = nsImageToPixbuf::ImageToPixbuf(img);
++ RefPtr<GdkPixbuf> pixbuf = nsImageToPixbuf::ImageToPixbuf(img);
+ if (pixbuf) {
+ dbusmenu_menuitem_property_set_image(mOwner->GetNativeData(),
+ DBUSMENU_MENUITEM_PROP_ICON_DATA,
+ pixbuf);
-+ g_object_unref(pixbuf);
+ }
+
-+ return NS_OK;
++ return;
+}
+
+void
-+nsMenuObjectIconLoader::LoadIcon(ComputedStyle *aComputedStyle)
++nsMenuObjectIconLoader::LoadIcon(const ComputedStyle *aComputedStyle)
+{
+ dom::Document *doc = mOwner->ContentNode()->OwnerDoc();
+
+ nsCOMPtr<nsIURI> uri;
-+ nsIntRect imageRect;
+ imgRequestProxy *imageRequest = nullptr;
+
+ nsAutoString uriString;
@@ -3258,12 +3197,9 @@
+ }
+
+ const nsStyleList *list = aComputedStyle->StyleList();
-+ imageRequest = list->GetListStyleImage();
++ imageRequest = list->mListStyleImage.GetImageRequest();
+ if (imageRequest) {
+ imageRequest->GetURI(getter_AddRefs(uri));
-+ auto& rect = list->mImageRegion.AsRect();
-+ imageRect = rect.ToLayoutRect().ToNearestPixels(
-+ pc->AppUnitsPerDevPixel());
+ }
+ }
+
@@ -3281,7 +3217,7 @@
+
+ bool same;
+ if (mURI && NS_SUCCEEDED(mURI->Equals(uri, &same)) && same &&
-+ (!imageRequest || imageRect == mImageRect)) {
++ !imageRequest) {
+ return;
+ }
+
@@ -3293,10 +3229,8 @@
+ mURI = uri;
+
+ if (imageRequest) {
-+ mImageRect = imageRect;
+ imageRequest->Clone(this, nullptr, getter_AddRefs(mImageRequest));
+ } else {
-+ mImageRect.SetEmpty();
+ nsCOMPtr<nsILoadGroup> loadGroup = doc->GetDocumentLoadGroup();
+ RefPtr<imgLoader> loader =
+ nsContentUtils::GetImgLoaderForDocument(doc);
@@ -3309,7 +3243,7 @@
+ nullptr, 0, loadGroup, this, nullptr, nullptr,
+ nsIRequest::LOAD_NORMAL, nullptr,
+ nsIContentPolicy::TYPE_IMAGE, EmptyString(),
-+ false, getter_AddRefs(mImageRequest));
++ false, false, 0, getter_AddRefs(mImageRequest));
+ }
+}
+
@@ -3499,14 +3433,14 @@
+}
+
+void
-+nsMenuObject::UpdateVisibility(ComputedStyle *aComputedStyle)
++nsMenuObject::UpdateVisibility(const ComputedStyle *aComputedStyle)
+{
+ bool vis = true;
+
+ if (aComputedStyle &&
+ (aComputedStyle->StyleDisplay()->mDisplay == StyleDisplay::None ||
+ aComputedStyle->StyleVisibility()->mVisible ==
-+ NS_STYLE_VISIBILITY_COLLAPSE)) {
++ StyleVisibility::Collapse)) {
+ vis = false;
+ }
+
@@ -3530,7 +3464,7 @@
+}
+
+void
-+nsMenuObject::UpdateIcon(ComputedStyle *aComputedStyle)
++nsMenuObject::UpdateIcon(const ComputedStyle *aComputedStyle)
+{
+ if (ShouldShowIcon()) {
+ if (!mIconLoader) {
@@ -3548,12 +3482,12 @@
+ }
+}
+
-+already_AddRefed<ComputedStyle>
++already_AddRefed<const ComputedStyle>
+nsMenuObject::GetComputedStyle()
+{
-+ RefPtr<ComputedStyle> style =
++ RefPtr<const ComputedStyle> style =
+ nsComputedDOMStyle::GetComputedStyleNoFlush(
-+ mContent->AsElement(), nullptr);
++ mContent->AsElement());
+
+ return style.forget();
+}
@@ -3581,7 +3515,7 @@
+}
+
+void
-+nsMenuObject::Update(ComputedStyle *aComputedStyle)
++nsMenuObject::Update(const ComputedStyle *aComputedStyle)
+{
+}
+
@@ -3685,7 +3619,7 @@
+
+ UpdateContentAttributes();
+
-+ RefPtr<ComputedStyle> style = GetComputedStyle();
++ RefPtr<const ComputedStyle> style = GetComputedStyle();
+ Update(style);
+}
+
@@ -3817,11 +3751,11 @@
+ };
+
+ void UpdateLabel();
-+ void UpdateVisibility(mozilla::ComputedStyle *aComputedStyle);
++ void UpdateVisibility(const mozilla::ComputedStyle *aComputedStyle);
+ void UpdateSensitivity();
-+ void UpdateIcon(mozilla::ComputedStyle *aComputedStyle);
++ void UpdateIcon(const mozilla::ComputedStyle *aComputedStyle);
+
-+ already_AddRefed<mozilla::ComputedStyle> GetComputedStyle();
++ already_AddRefed<const mozilla::ComputedStyle> GetComputedStyle();
+
+private:
+ friend class nsMenuObjectIconLoader;
@@ -3848,7 +3782,7 @@
+ // Update properties that should be refreshed when the container opens.
+ // This should be implemented by subclasses that have properties which
+ // need refreshing
-+ virtual void Update(mozilla::ComputedStyle *aComputedStyle);
++ virtual void Update(const mozilla::ComputedStyle *aComputedStyle);
+
+ bool ShouldShowIcon() const;
+ void ClearIcon();
@@ -3900,7 +3834,7 @@
+#endif /* __nsMenuObject_h__ */
--- /dev/null
+++ b/widget/gtk/nsMenuSeparator.cpp
-@@ -0,0 +1,84 @@
+@@ -0,0 +1,82 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/* vim:expandtab:shiftwidth=4:tabstop=4:
+ */
@@ -3909,8 +3843,6 @@
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+#include "mozilla/Assertions.h"
-+#include "mozilla/Move.h"
-+#include "nsAutoPtr.h"
+#include "nsCRT.h"
+#include "nsGkAtoms.h"
+
@@ -3930,7 +3862,7 @@
+}
+
+void
-+nsMenuSeparator::Update(ComputedStyle *aComputedStyle)
++nsMenuSeparator::Update(const ComputedStyle *aComputedStyle)
+{
+ UpdateVisibility(aComputedStyle);
+}
@@ -3963,7 +3895,7 @@
+
+ if (aAttribute == nsGkAtoms::hidden ||
+ aAttribute == nsGkAtoms::collapsed) {
-+ RefPtr<ComputedStyle> style = GetComputedStyle();
++ RefPtr<const ComputedStyle> style = GetComputedStyle();
+ UpdateVisibility(style);
+ }
+}
@@ -4017,7 +3949,7 @@
+
+private:
+ void InitializeNativeData() override;
-+ void Update(mozilla::ComputedStyle *aComputedStyle) override;
++ void Update(const mozilla::ComputedStyle *aComputedStyle) override;
+ bool IsCompatibleWithNativeData(DbusmenuMenuitem *aNativeData) const override;
+ nsMenuObject::PropertyFlags SupportedProperties() const override;
+
@@ -4027,7 +3959,7 @@
+#endif /* __nsMenuSeparator_h__ */
--- /dev/null
+++ b/widget/gtk/nsNativeMenuDocListener.cpp
-@@ -0,0 +1,350 @@
+@@ -0,0 +1,347 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/* vim:expandtab:shiftwidth=4:tabstop=4:
+ */
@@ -4061,11 +3993,9 @@
+{
+public:
+ DispatchHelper(nsNativeMenuDocListener *aListener,
-+ nsIContent *aContent
-+ MOZ_GUARD_OBJECT_NOTIFIER_PARAM) :
++ nsIContent *aContent) :
+ mObserver(nullptr)
+ {
-+ MOZ_GUARD_OBJECT_NOTIFIER_INIT;
+ if (aContent == aListener->mLastSource) {
+ mObserver = aListener->mLastTarget;
+ } else {
@@ -4085,7 +4015,6 @@
+
+private:
+ nsNativeMenuChangeObserver *mObserver;
-+ MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER
+};
+
+NS_IMPL_ISUPPORTS(nsNativeMenuDocListener, nsIMutationObserver)
@@ -4109,7 +4038,7 @@
+ return;
+ }
+
-+ MutationRecord *m = *mPendingMutations.AppendElement(new MutationRecord);
++ MutationRecord *m = mPendingMutations.AppendElement(MakeUnique<MutationRecord>())->get();
+ m->mType = MutationRecord::eAttributeChanged;
+ m->mTarget = aElement;
+ m->mAttribute = aAttribute;
@@ -4140,7 +4069,7 @@
+ return;
+ }
+
-+ MutationRecord *m = *mPendingMutations.AppendElement(new MutationRecord);
++ MutationRecord *m = mPendingMutations.AppendElement(MakeUnique<MutationRecord>())->get();
+ m->mType = MutationRecord::eContentInserted;
+ m->mTarget = container;
+ m->mChild = aChild;
@@ -4163,7 +4092,7 @@
+ return;
+ }
+
-+ MutationRecord *m = *mPendingMutations.AppendElement(new MutationRecord);
++ MutationRecord *m = mPendingMutations.AppendElement(MakeUnique<MutationRecord>())->get();
+ m->mType = MutationRecord::eContentRemoved;
+ m->mTarget = container;
+ m->mChild = aChild;
@@ -4172,7 +4101,7 @@
+}
+
+void
-+nsNativeMenuDocListener::NodeWillBeDestroyed(const nsINode *aNode)
++nsNativeMenuDocListener::NodeWillBeDestroyed(nsINode *aNode)
+{
+ mDocument = nullptr;
+}
@@ -4233,7 +4162,7 @@
+ bool inUpdateSequence = false;
+
+ while (mPendingMutations.Length() > 0) {
-+ MutationRecord *m = mPendingMutations[0];
++ MutationRecord *m = mPendingMutations[0].get();
+
+ if (m->mTarget != currentTarget) {
+ if (inUpdateSequence) {
@@ -4334,7 +4263,7 @@
+ MOZ_ASSERT(!mContentToObserverTable.Get(aContent, &old) || old == aObserver,
+ "Multiple observers for the same content node are not supported");
+
-+ mContentToObserverTable.Put(aContent, aObserver);
++ mContentToObserverTable.InsertOrUpdate(aContent, aObserver);
+}
+
+void
@@ -4380,7 +4309,7 @@
+}
--- /dev/null
+++ b/widget/gtk/nsNativeMenuDocListener.h
-@@ -0,0 +1,157 @@
+@@ -0,0 +1,152 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/* vim:expandtab:shiftwidth=4:tabstop=4:
+ */
@@ -4392,10 +4321,9 @@
+#define __nsNativeMenuDocListener_h__
+
+#include "mozilla/Attributes.h"
-+#include "mozilla/GuardObjects.h"
+#include "mozilla/RefPtr.h"
-+#include "nsAutoPtr.h"
-+#include "nsDataHashtable.h"
++#include "mozilla/UniquePtr.h"
++#include "nsTHashMap.h"
+#include "nsStubMutationObserver.h"
+#include "nsTArray.h"
+
@@ -4447,9 +4375,8 @@
+ class MOZ_STACK_CLASS BlockUpdatesScope
+ {
+ public:
-+ BlockUpdatesScope(MOZ_GUARD_OBJECT_NOTIFIER_ONLY_PARAM)
++ BlockUpdatesScope()
+ {
-+ MOZ_GUARD_OBJECT_NOTIFIER_INIT;
+ nsNativeMenuDocListener::AddUpdateBlocker();
+ }
+
@@ -4457,9 +4384,6 @@
+ {
+ nsNativeMenuDocListener::RemoveUpdateBlocker();
+ }
-+
-+ private:
-+ MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER
+ };
+
+private:
@@ -4505,8 +4429,8 @@
+ mozilla::dom::Document *mDocument;
+ nsIContent *mLastSource;
+ nsNativeMenuChangeObserver *mLastTarget;
-+ nsTArray<nsAutoPtr<MutationRecord> > mPendingMutations;
-+ nsDataHashtable<nsPtrHashKey<nsIContent>, nsNativeMenuChangeObserver *> mContentToObserverTable;
++ nsTArray<mozilla::UniquePtr<MutationRecord> > mPendingMutations;
++ nsTHashMap<nsPtrHashKey<nsIContent>, nsNativeMenuChangeObserver *> mContentToObserverTable;
+
+ static uint32_t sUpdateBlockersCount;
+};
@@ -4540,7 +4464,7 @@
+#endif /* __nsNativeMenuDocListener_h__ */
--- /dev/null
+++ b/widget/gtk/nsNativeMenuService.cpp
-@@ -0,0 +1,505 @@
+@@ -0,0 +1,478 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/* vim:expandtab:shiftwidth=4:tabstop=4:
+ */
@@ -4548,11 +4472,10 @@
+ * 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 "mozilla/dom/Element.h"
+#include "mozilla/Assertions.h"
-+#include "mozilla/Move.h"
+#include "mozilla/Preferences.h"
+#include "mozilla/UniquePtr.h"
-+#include "nsAutoPtr.h"
+#include "nsCOMPtr.h"
+#include "nsCRT.h"
+#include "nsGtkUtils.h"
@@ -4579,32 +4502,6 @@
+extern PangoLayout* gPangoLayout;
+extern nsNativeMenuDocListenerTArray* gPendingListeners;
+
-+#if not GLIB_CHECK_VERSION(2,26,0)
-+enum GBusType {
-+ G_BUS_TYPE_STARTER = -1,
-+ G_BUS_TYPE_NONE = 0,
-+ G_BUS_TYPE_SYSTEM = 1,
-+ G_BUS_TYPE_SESSION = 2
-+};
-+
-+enum GDBusProxyFlags {
-+ G_DBUS_PROXY_FLAGS_NONE = 0,
-+ G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES = 1 << 0,
-+ G_DBUS_PROXY_FLAGS_DO_NOT_CONNECT_SIGNALS = 1 << 1,
-+ G_DBUS_PROXY_FLAGS_DO_NOT_AUTO_START = 1 << 2,
-+ G_DBUS_PROXY_FLAGS_GET_INVALIDATED_PROPERTIES = 1 << 3
-+};
-+
-+enum GDBusCallFlags {
-+ G_DBUS_CALL_FLAGS_NONE = 0,
-+ G_DBUS_CALL_FLAGS_NO_AUTO_START = 1 << 0
-+};
-+
-+typedef _GDBusInterfaceInfo GDBusInterfaceInfo;
-+typedef _GDBusProxy GDBusProxy;
-+typedef _GVariant GVariant;
-+#endif
-+
+#undef g_dbus_proxy_new_for_bus
+#undef g_dbus_proxy_new_for_bus_finish
+#undef g_dbus_proxy_call
@@ -4811,7 +4708,7 @@
+ }
+
+ GCancellable *cancellable = g_cancellable_new();
-+ mMenuBarRegistrationCancellables.Put(aMenuBar, cancellable);
++ mMenuBarRegistrationCancellables.InsertOrUpdate(aMenuBar, cancellable);
+
+ // We keep a weak ref because we can't assume that GDBus cancellation
+ // is reliable (see https://launchpad.net/bugs/953562)
@@ -5048,7 +4945,7 @@
+}
--- /dev/null
+++ b/widget/gtk/nsNativeMenuService.h
-@@ -0,0 +1,84 @@
+@@ -0,0 +1,85 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/* vim:expandtab:shiftwidth=4:tabstop=4:
+ */
@@ -5061,7 +4958,7 @@
+
+#include "mozilla/Attributes.h"
+#include "nsCOMPtr.h"
-+#include "nsDataHashtable.h"
++#include "nsTHashMap.h"
+#include "nsINativeMenuService.h"
+#include "nsTArray.h"
+
@@ -5072,8 +4969,9 @@
+class nsMenuBar;
+
+/*
-+ * The main native menu service singleton. nsWebShellWindow calls in to this when
-+ * a new top level window is created.
++ * The main native menu service singleton.
++ * NativeMenuSupport::CreateNativeMenuBar calls in to this when a new top level
++ * window is created.
+ *
+ * Menubars are owned by their nsWindow. This service holds a weak reference to
+ * each menubar for the purpose of re-registering them with the shell if it
@@ -5126,7 +5024,7 @@
+ GDBusProxy *mDbusProxy;
+ bool mOnline;
+ nsTArray<nsMenuBar *> mMenuBars;
-+ nsDataHashtable<nsPtrHashKey<nsMenuBar>, GCancellable*> mMenuBarRegistrationCancellables;
++ nsTHashMap<nsPtrHashKey<nsMenuBar>, GCancellable*> mMenuBarRegistrationCancellables;
+
+ static bool sShutdown;
+ static nsNativeMenuService *sService;
@@ -5135,16 +5033,8 @@
+#endif /* __nsNativeMenuService_h__ */
--- a/widget/gtk/nsWindow.cpp
+++ b/widget/gtk/nsWindow.cpp
-@@ -73,6 +73,7 @@
-
- #include "mozilla/Assertions.h"
- #include "mozilla/Likely.h"
-+#include "mozilla/Move.h"
- #include "mozilla/Preferences.h"
- #include "nsIPrefService.h"
- #include "nsIServiceManager.h"
-@@ -5192,6 +5193,10 @@ void nsWindow::HideWindowChrome(bool aSh
- SetWindowDecoration(aShouldHide ? eBorderStyle_none : mBorderStyle);
+@@ -7060,6 +7060,10 @@ void nsWindow::HideWindowChrome(bool aSh
+ SetWindowDecoration(aShouldHide ? BorderStyle::None : mBorderStyle);
}
+void nsWindow::SetMenuBar(UniquePtr<nsMenuBar> aMenuBar) {
@@ -5153,62 +5043,36 @@
+
bool nsWindow::CheckForRollup(gdouble aMouseX, gdouble aMouseY, bool aIsWheel,
bool aAlwaysRollup) {
- nsIRollupListener* rollupListener = GetActiveRollupListener();
+ LOG("nsWindow::CheckForRollup() aAlwaysRollup %d", aAlwaysRollup);
--- a/widget/gtk/nsWindow.h
+++ b/widget/gtk/nsWindow.h
-@@ -38,6 +38,8 @@
-
+@@ -26,6 +26,8 @@
+ #include "nsRefPtrHashtable.h"
#include "IMContextWrapper.h"
+#include "nsMenuBar.h"
+
- #undef LOG
- #ifdef MOZ_LOGGING
-
-@@ -171,6 +173,8 @@ class nsWindow final : public nsBaseWidg
- nsIScreen* aTargetScreen = nullptr) override;
- virtual void HideWindowChrome(bool aShouldHide) override;
+ #ifdef ACCESSIBILITY
+ # include "mozilla/a11y/LocalAccessible.h"
+ #endif
+@@ -172,6 +174,8 @@ class nsWindow final : public nsBaseWidg
+ nsresult MakeFullScreen(bool aFullScreen) override;
+ void HideWindowChrome(bool aShouldHide) override;
+ void SetMenuBar(mozilla::UniquePtr<nsMenuBar> aMenuBar);
+
/**
* GetLastUserInputTime returns a timestamp for the most recent user input
* event. This is intended for pointer grab requests (including drags).
-@@ -638,6 +642,8 @@ class nsWindow final : public nsBaseWidg
+@@ -824,6 +828,8 @@ class nsWindow final : public nsBaseWidg
- mozilla::UniquePtr<mozilla::CurrentX11TimeGetter> mCurrentTimeGetter;
- static CSDSupportLevel sCSDSupportLevel;
-+
-+ mozilla::UniquePtr<nsMenuBar> mMenuBar;
- };
+ static bool sTransparentMainWindow;
- #endif /* __nsWindow_h__ */
---- a/widget/moz.build
-+++ b/widget/moz.build
-@@ -69,9 +69,9 @@ elif toolkit == 'cocoa':
- 'nsITouchBarInput.idl',
- 'nsITouchBarUpdater.idl',
- ]
-- EXPORTS += [
-- 'nsINativeMenuService.h',
-- ]
++ mozilla::UniquePtr<nsMenuBar> mMenuBar;
+
-+if toolkit in ('cocoa', 'gtk'):
-+ EXPORTS += ['nsINativeMenuService.h']
-
- TEST_DIRS += ['tests']
-
---- a/xpfe/appshell/nsWebShellWindow.cpp
-+++ b/xpfe/appshell/nsWebShellWindow.cpp
-@@ -70,7 +70,7 @@
+ #ifdef ACCESSIBILITY
+ RefPtr<mozilla::a11y::LocalAccessible> mRootAccessible;
- #include "gfxPlatform.h"
-
--#ifdef XP_MACOSX
-+#if defined(XP_MACOSX) || defined(MOZ_WIDGET_GTK)
- # include "nsINativeMenuService.h"
- # define USE_NATIVE_MENUS
- #endif
--- /dev/null
+++ b/xpcom/ds/NativeMenuAtoms.py
@@ -0,0 +1,9 @@
@@ -5224,30 +5088,30 @@
--- a/xpcom/ds/StaticAtoms.py
+++ b/xpcom/ds/StaticAtoms.py
@@ -7,6 +7,7 @@
- from Atom import Atom, InheritingAnonBoxAtom, NonInheritingAnonBoxAtom
- from Atom import PseudoElementAtom
+ PseudoElementAtom,
+ )
from HTMLAtoms import HTML_PARSER_ATOMS
+from NativeMenuAtoms import NATIVE_MENU_ATOMS
- import sys
# Static atom definitions, used to generate nsGkAtomList.h.
-@@ -2481,7 +2482,7 @@ STATIC_ATOMS = [
+ #
+@@ -2529,7 +2530,7 @@ STATIC_ATOMS = [
InheritingAnonBoxAtom("AnonBox_mozSVGForeignContent", ":-moz-svg-foreign-content"),
InheritingAnonBoxAtom("AnonBox_mozSVGText", ":-moz-svg-text"),
# END ATOMS
-] + HTML_PARSER_ATOMS
+] + HTML_PARSER_ATOMS + NATIVE_MENU_ATOMS
+ # fmt: on
- def verify():
--- a/widget/gtk/components.conf
+++ b/widget/gtk/components.conf
-@@ -82,6 +82,14 @@ Classes = [
- 'headers': ['/widget/gtk/nsApplicationChooser.h'],
- 'processes': ProcessSelector.MAIN_PROCESS_ONLY,
+@@ -76,6 +76,14 @@ Classes = [
+ 'headers': ['/widget/gtk/nsUserIdleServiceGTK.h'],
+ 'constructor': 'nsUserIdleServiceGTK::GetInstance',
},
+ {
-+ 'cid': '{0B3FE5AA-BC72-4303-85AE-76365DF1251D}',
++ 'cid': '{0b3fe5aa-bc72-4303-85ae-76365df1251d}',
+ 'contract_ids': ['@mozilla.org/widget/nativemenuservice;1'],
+ 'singleton': True,
+ 'type': 'nsNativeMenuService',
@@ -5256,4 +5120,149 @@
+ },
]
- if defined('MOZ_X11'):
+ if defined('NS_PRINTING'):
+--- a/xpfe/appshell/AppWindow.cpp
++++ b/xpfe/appshell/AppWindow.cpp
+@@ -80,7 +80,7 @@
+
+ #include "mozilla/dom/DocumentL10n.h"
+
+-#ifdef XP_MACOSX
++#if defined(XP_MACOSX) || defined(MOZ_WIDGET_GTK)
+ # include "mozilla/widget/NativeMenuSupport.h"
+ # define USE_NATIVE_MENUS
+ #endif
+--- a/widget/gtk/NativeMenuSupport.cpp
++++ b/widget/gtk/NativeMenuSupport.cpp
+@@ -7,6 +7,8 @@
+
+ #include "MainThreadUtils.h"
+ #include "NativeMenuGtk.h"
++#include "nsINativeMenuService.h"
++#include "nsServiceManagerUtils.h"
+
+ namespace mozilla::widget {
+
+@@ -14,7 +16,14 @@ void NativeMenuSupport::CreateNativeMenu
+ dom::Element* aMenuBarElement) {
+ MOZ_RELEASE_ASSERT(NS_IsMainThread(),
+ "Attempting to create native menu bar on wrong thread!");
+- // TODO
++
++ nsCOMPtr<nsINativeMenuService> nms =
++ do_GetService("@mozilla.org/widget/nativemenuservice;1");
++ if (!nms) {
++ return;
++ }
++
++ nms->CreateNativeMenuBar(aParent, aMenuBarElement);
+ }
+
+ already_AddRefed<NativeMenu> NativeMenuSupport::CreateNativeContextMenu(
+--- /dev/null
++++ b/widget/gtk/NativeMenuSupport.h
+@@ -0,0 +1,31 @@
++/* -*- Mode: C++; 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/. */
++
++#ifndef mozilla_widget_NativeMenuSupport_h
++#define mozilla_widget_NativeMenuSupport_h
++
++class nsIWidget;
++
++namespace mozilla {
++
++namespace dom {
++class Element;
++}
++
++namespace widget {
++
++class NativeMenuSupport final {
++public:
++ // Given a top-level window widget and a menu bar DOM node, sets up native
++ // menus. Once created, native menus are controlled via the DOM, including
++ // destruction.
++ static void CreateNativeMenuBar(nsIWidget* aParent,
++ dom::Element* aMenuBarElement);
++};
++
++} // namespace widget
++} // namespace mozilla
++
++#endif // mozilla_widget_NativeMenuSupport_h
+--- a/widget/moz.build
++++ b/widget/moz.build
+@@ -157,6 +157,11 @@ EXPORTS += [
+ "PuppetWidget.h",
+ ]
+
++if toolkit == "gtk":
++ EXPORTS += [
++ "nsINativeMenuService.h",
++ ]
++
+ EXPORTS.mozilla += [
+ "BasicEvents.h",
+ "ColorScheme.h",
+--- /dev/null
++++ b/widget/nsINativeMenuService.h
+@@ -0,0 +1,39 @@
++/* -*- Mode: C++; 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/. */
++
++#ifndef nsINativeMenuService_h_
++#define nsINativeMenuService_h_
++
++#include "nsISupports.h"
++
++class nsIWidget;
++class nsIContent;
++namespace mozilla {
++namespace dom {
++class Element;
++}
++} // namespace mozilla
++
++// {90DF88F9-F084-4EF3-829A-49496E636DED}
++#define NS_INATIVEMENUSERVICE_IID \
++ { \
++ 0x90DF88F9, 0xF084, 0x4EF3, { \
++ 0x82, 0x9A, 0x49, 0x49, 0x6E, 0x63, 0x6D, 0xED \
++ } \
++ }
++
++class nsINativeMenuService : public nsISupports {
++ public:
++ NS_DECLARE_STATIC_IID_ACCESSOR(NS_INATIVEMENUSERVICE_IID)
++ // Given a top-level window widget and a menu bar DOM node, sets up native
++ // menus. Once created, native menus are controlled via the DOM, including
++ // destruction.
++ NS_IMETHOD CreateNativeMenuBar(nsIWidget* aParent,
++ mozilla::dom::Element* aMenuBarNode) = 0;
++};
++
++NS_DEFINE_STATIC_IID_ACCESSOR(nsINativeMenuService, NS_INATIVEMENUSERVICE_IID)
++
++#endif // nsINativeMenuService_h_
+--- a/widget/nsWidgetsCID.h
++++ b/widget/nsWidgetsCID.h
+@@ -66,6 +66,14 @@
+ // Menus
+ //-----------------------------------------------------------
+
++// {0B3FE5AA-BC72-4303-85AE-76365DF1251D}
++#define NS_NATIVEMENUSERVICE_CID \
++ { \
++ 0x0B3FE5AA, 0xBC72, 0x4303, { \
++ 0x85, 0xAE, 0x76, 0x36, 0x5D, 0xF1, 0x25, 0x1D \
++ } \
++ }
++
+ // {F6CD4F21-53AF-11d2-8DC4-00609703C14E}
+ #define NS_POPUPMENU_CID \
+ { \