diff -u firefox-11.0+build1/debian/changelog firefox-11.0+build1/debian/changelog --- firefox-11.0+build1/debian/changelog +++ firefox-11.0+build1/debian/changelog @@ -1,3 +1,45 @@ +firefox (11.0+build1-0ubuntu2) precise; urgency=low + + * Update globalmenu-extension to 3.0.1 + - Reduce our memory footprint a bit, which wasn't really a lot anyway + - Avoid the use of the component manager for accessing commonly used + services, where "commonly used" means "accessed when building every + menu item". This should save some CPU cycles when building or + refreshing menus + - Try to recycle menuitems when they are removed from a menu by + adding contiguous blocks of removed items to a "free list" which + is emptied asynchronously, and reusing the items in this list when + new items are added in place of the removed items. This means that + refreshing the history menu contents when the menu is opened no + longer alters the menu structure, but results in a shifting of + properties between existing nodes instead. This has a few benefits: + + With no layout changes, unity-panel-service doesn't request + the entire menu structure, which significantly reduces dbus traffic + and makes it much faster to refresh the menu contents + + The size of the menu doesn't change when it is refreshed, which + eliminates the flicker that used to occur when opening the history + menu. + + The HUD can refresh our menus now without triggering layout updates + (assuming that menu layout really hasn't changed, eg, by adding + a bookmark) + - Remove all use of the global observer service for sending our own + internal notifications around + - Clean up the way we ensure that the correct edit commands are + enabled by just installing our own popupshowing handler rather + than using an additional notification to fix things up after the + default handler runs + - Get rid of a static initializer + - Don't support older than Firefox 11 + - Fix some GError leaks + - Hide the internal menu when creating a native menu, rather than + waiting for confirmation that the native menu is registered + successfully. We don't try to create a native menu if we don't + find a menu service to register the menu with anyway + - Keep menu contents updated whilst the menu is open, rather than + just whilst it is opening + + -- Chris Coulson Mon, 02 Apr 2012 08:30:28 +0100 + firefox (11.0+build1-0ubuntu1) precise; urgency=low * New upstream stable release (FIREFOX_11_0_BUILD1) diff -u firefox-11.0+build1/debian/globalmenu/makefiles.sh firefox-11.0+build1/debian/globalmenu/makefiles.sh --- firefox-11.0+build1/debian/globalmenu/makefiles.sh +++ firefox-11.0+build1/debian/globalmenu/makefiles.sh @@ -39,6 +39,6 @@ extensions/globalmenu/Makefile +extensions/globalmenu/build/Makefile extensions/globalmenu/chrome/Makefile -extensions/globalmenu/components/Makefile -extensions/globalmenu/components/public/Makefile -extensions/globalmenu/components/src/Makefile +extensions/globalmenu/public/Makefile +extensions/globalmenu/src/Makefile " diff -u firefox-11.0+build1/debian/globalmenu/Makefile.in firefox-11.0+build1/debian/globalmenu/Makefile.in --- firefox-11.0+build1/debian/globalmenu/Makefile.in +++ firefox-11.0+build1/debian/globalmenu/Makefile.in @@ -44,8 +44,10 @@ MODULE = globalmenu DIRS = \ - components \ + public \ + src \ chrome \ + build \ $(NULL) XPI_NAME = globalmenu diff -u firefox-11.0+build1/debian/globalmenu/install.rdf firefox-11.0+build1/debian/globalmenu/install.rdf --- firefox-11.0+build1/debian/globalmenu/install.rdf +++ firefox-11.0+build1/debian/globalmenu/install.rdf @@ -4,15 +4,15 @@ xmlns:em="http://www.mozilla.org/2004/em-rdf#"> globalmenu@ubuntu.com - 2.0.4 + 3.0.1 true {ec8030f7-c20a-464f-9b0e-13a3a9e97384} - 6.0 - 12.* + 11.0 + 14.0a1 @@ -20,8 +20,8 @@ {3550f703-e582-4d05-9a08-453d09bdfdc6} - 6.0 - 12.* + 11.0 + 14.0a1 reverted: --- firefox-11.0+build1/debian/globalmenu/components/Makefile.in +++ firefox-11.0+build1.orig/debian/globalmenu/components/Makefile.in @@ -1,54 +0,0 @@ -# ***** BEGIN LICENSE BLOCK ***** -# Version: MPL 1.1/GPL 2.0/LGPL 2.1 -# -# The contents of this file are subject to the Mozilla Public License Version -# 1.1 (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# http://www.mozilla.org/MPL/ -# -# Software distributed under the License is distributed on an "AS IS" basis, -# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License -# for the specific language governing rights and limitations under the -# License. -# -# The Original Code is mozilla.org code. -# -# The Initial Developer of the Original Code is -# Netscape Communications Corporation. -# Portions created by the Initial Developer are Copyright (C) 2001 -# the Initial Developer. All Rights Reserved. -# -# Contributor(s): -# Chris Coulson -# -# Alternatively, the contents of this file may be used under the terms of -# either the GNU General Public License Version 2 or later (the "GPL"), or -# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), -# in which case the provisions of the GPL or the LGPL are applicable instead -# of those above. If you wish to allow use of your version of this file only -# under the terms of either the GPL or the LGPL, and not to allow others to -# use your version of this file under the terms of the MPL, indicate your -# decision by deleting the provisions above and replace them with the notice -# and other provisions required by the GPL or the LGPL. If you do not delete -# the provisions above, a recipient may use your version of this file under -# the terms of any one of the MPL, the GPL or the LGPL. -# -# ***** END LICENSE BLOCK ***** - -DEPTH = ../../.. -topsrcdir = @top_srcdir@ -srcdir = @srcdir@ -VPATH = @srcdir@ - -include $(DEPTH)/config/autoconf.mk - -MODULE = globalmenu - -DIRS = \ - public \ - src \ - $(NULL) - -XPI_NAME = globalmenu - -include $(topsrcdir)/config/rules.mk reverted: --- firefox-11.0+build1/debian/globalmenu/components/src/uGlobalMenuItem.h +++ firefox-11.0+build1.orig/debian/globalmenu/components/src/uGlobalMenuItem.h @@ -1,104 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is globalmenu-extension. - * - * The Initial Developer of the Original Code is - * Canonical Ltd. - * Portions created by the Initial Developer are Copyright (C) 2010 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * Chris Coulson - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -#ifndef _U_GLOBALMENUITEM_H -#define _U_GLOBALMENUITEM_H - -#include -#include -#include - -#include - -#include "uGlobalMenuObject.h" -#include "uMenuChangeObserver.h" - -class nsIContent; -class uGlobalMenuDocListener; -class uGlobalMenuBar; - -enum uMenuItemType { - Normal, - CheckBox, - Radio -}; - -class uGlobalMenuItem: public uGlobalMenuObject, - public uMenuChangeObserver -{ -public: - NS_DECL_UMENUCHANGEOBSERVER - - static uGlobalMenuObject* Create(uGlobalMenuObject *aParent, - uGlobalMenuDocListener *aListener, - nsIContent *aContent, - uGlobalMenuBar *aMenuBar); - - void AboutToShowNotify(); - -private: - uGlobalMenuItem(); - - nsresult Init(uGlobalMenuObject *aParent, - uGlobalMenuDocListener *aListener, - nsIContent *aContent, - uGlobalMenuBar *aMenuBar); - ~uGlobalMenuItem(); - - PRUint32 GetKeyCode(nsAString &aKeyName); - PRUint32 MozKeyCodeToGdkKeyCode(PRUint32 aMozKeyCode); - void SyncAccelFromContent(); - void SyncProperties(); - void SyncTypeAndStateFromContent(); - nsresult ConstructDbusMenuItem(); - static void ItemActivatedCallback(DbusmenuMenuitem *menuItem, - PRUint32 timeStamp, - void *data); - void Activate(); - void UncheckSiblings(); - - nsCOMPtr mCommandContent; - nsCOMPtr mKeyContent; - PRUint32 mHandlerID; - PRPackedBool mIsToggle; - PRPackedBool mToggleState; - uMenuItemType mType; -}; - - -#endif reverted: --- firefox-11.0+build1/debian/globalmenu/components/src/uGlobalMenuUtils.cpp +++ firefox-11.0+build1.orig/debian/globalmenu/components/src/uGlobalMenuUtils.cpp @@ -1,82 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is globalmenu-extension. - * - * The Initial Developer of the Original Code is - * Canonical Ltd. - * Portions created by the Initial Developer are Copyright (C) 2010 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * Chris Coulson - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -#include -#include - -#include "uGlobalMenuObject.h" -#include "uGlobalMenu.h" -#include "uGlobalMenuItem.h" -#include "uGlobalMenuSeparator.h" -#include "uGlobalMenuDummy.h" -#include "uGlobalMenuDocListener.h" -#include "uGlobalMenuBar.h" -#include "uWidgetAtoms.h" - -#include "uDebug.h" - -uGlobalMenuObject* -NewGlobalMenuItem(uGlobalMenuObject *aParent, - uGlobalMenuDocListener *aListener, - nsIContent *aContent, - uGlobalMenuBar *aMenuBar) -{ - TRACE_WITH_CONTENT(aContent); - - if (!aContent->IsXUL()) { - return uGlobalMenuDummy::Create(); - } - - uGlobalMenuObject *menuitem = nsnull; - if (aContent->Tag() == uWidgetAtoms::menu) { - menuitem = uGlobalMenu::Create(aParent, aListener, aContent, aMenuBar); - } else if (aContent->Tag() == uWidgetAtoms::menuitem) { - menuitem = uGlobalMenuItem::Create(aParent, aListener, aContent, aMenuBar); - } else if (aContent->Tag() == uWidgetAtoms::menuseparator) { - menuitem = uGlobalMenuSeparator::Create(aParent, aListener, aContent, aMenuBar); - } - - if (!menuitem) { - // We didn't recognize the tag, or initialization failed. We'll - // insert an invisible dummy node so that the indices between the - // XUL menuand the GlobalMenu stay in sync. - menuitem = uGlobalMenuDummy::Create(); - } - - return menuitem; -} reverted: --- firefox-11.0+build1/debian/globalmenu/components/src/uGlobalMenuModule.cpp +++ firefox-11.0+build1.orig/debian/globalmenu/components/src/uGlobalMenuModule.cpp @@ -1,71 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is mozilla.org code. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * Suresh Duddu - * Chris Coulson - * - * Alternatively, the contents of this file may be used under the terms of - * either of the GNU General Public License Version 2 or later (the "GPL"), - * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -#include "nsIClassInfoImpl.h" -#include "mozilla/ModuleUtils.h" -#include "uGlobalMenuService.h" -#include "uGlobalMenuLoader.h" - -NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(uGlobalMenuService, Init) -NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(uGlobalMenuLoader, Init) - -NS_DEFINE_NAMED_CID(U_GLOBALMENUSERVICE_CID); -NS_DEFINE_NAMED_CID(U_GLOBALMENULOADER_CID); - -static const mozilla::Module::CIDEntry kGlobalMenuCIDs[] = { - { &kU_GLOBALMENUSERVICE_CID, false, NULL, uGlobalMenuServiceConstructor }, - { &kU_GLOBALMENULOADER_CID, false, NULL, uGlobalMenuLoaderConstructor }, - { NULL } -}; - -static const mozilla::Module::ContractIDEntry kGlobalMenuContracts[] = { - { U_GLOBALMENUSERVICE_CONTRACTID, &kU_GLOBALMENUSERVICE_CID }, - { U_GLOBALMENULOADER_CONTRACTID, &kU_GLOBALMENULOADER_CID }, - { NULL } -}; - -static const mozilla::Module kGlobalMenuModule = { - mozilla::Module::kVersion, - kGlobalMenuCIDs, - kGlobalMenuContracts -}; - -// The following line implements the one-and-only "NSModule" symbol exported from this -// shared library. -NSMODULE_DEFN(uGlobalMenuModule) = &kGlobalMenuModule; reverted: --- firefox-11.0+build1/debian/globalmenu/components/src/Makefile.in +++ firefox-11.0+build1.orig/debian/globalmenu/components/src/Makefile.in @@ -1,103 +0,0 @@ -# ***** BEGIN LICENSE BLOCK ***** -# Version: MPL 1.1/GPL 2.0/LGPL 2.1 -# -# The contents of this file are subject to the Mozilla Public License Version -# 1.1 (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# http://www.mozilla.org/MPL/ -# -# Software distributed under the License is distributed on an "AS IS" basis, -# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License -# for the specific language governing rights and limitations under the -# License. -# -# The Original Code is mozilla.org code. -# -# The Initial Developer of the Original Code is -# Netscape Communications Corporation. -# Portions created by the Initial Developer are Copyright (C) 2001 -# the Initial Developer. All Rights Reserved. -# -# Contributor(s): -# Chris Coulson -# -# Alternatively, the contents of this file may be used under the terms of -# either the GNU General Public License Version 2 or later (the "GPL"), or -# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), -# in which case the provisions of the GPL or the LGPL are applicable instead -# of those above. If you wish to allow use of your version of this file only -# under the terms of either the GPL or the LGPL, and not to allow others to -# use your version of this file under the terms of the MPL, indicate your -# decision by deleting the provisions above and replace them with the notice -# and other provisions required by the GPL or the LGPL. If you do not delete -# the provisions above, a recipient may use your version of this file under -# the terms of any one of the MPL, the GPL or the LGPL. -# -# ***** END LICENSE BLOCK ***** - -DEPTH = ../../../.. -topsrcdir = @top_srcdir@ -srcdir = @srcdir@ -VPATH = @srcdir@ - -include $(DEPTH)/config/autoconf.mk - -IS_COMPONENT = 1 -MODULE = globalmenu -LIBRARY_NAME = globalmenu -MODULE_NAME = uGlobalMenuModule -#USE_STATIC_LIBS = 1 -#EXPORT_LIBRARY = 1 - -XPI_NAME = globalmenu - -CPPSRCS = \ - uGlobalMenuModule.cpp \ - uGlobalMenuLoader.cpp \ - uGlobalMenuService.cpp \ - uGlobalMenuUtils.cpp \ - uGlobalMenuBar.cpp \ - uGlobalMenuSeparator.cpp \ - uGlobalMenuItem.cpp \ - uGlobalMenuDummy.cpp \ - uGlobalMenu.cpp \ - uGlobalMenuDocListener.cpp \ - uGlobalMenuObject.cpp \ - uWidgetAtoms.cpp \ - uDebug.cpp \ - $(NULL) - -ifneq (extensions, $(MOZ_BUILD_APP)) -# Support in-tree builds where we need to figure this out for ourselves -MOZILLA_BRANCH_MAJOR_VERSION=$(shell echo $(MOZILLA_VERSION) | sed -e 's/[ab].*//' -e 's/^\([0-9]*\)\.*\([0-9]*\)\.*\([0-9]*\).*/\1/;') -MOZILLA_BRANCH_MINOR_VERSION=$(shell echo $(MOZILLA_VERSION) | sed -e 's/[ab].*//' -e 's/^\([0-9]*\)\.*\([0-9]*\)\.*\([0-9]*\).*/\2/;') -MOZILLA_BRANCH_MICRO_VERSION=$(shell echo $(MOZILLA_VERSION) | sed -e 's/[ab].*//' -e 's/^\([0-9]*\)\.*\([0-9]*\)\.*\([0-9]*\).*/\3/;') - -ifeq (,$(MOZILLA_BRANCH_MINRO_VERSION)) -MOZILLA_BRANCH_MINOR_VERSION=0 -endif -ifeq (,$(MOZILLA_BRANCH_MICRO_VERSION)) -MOZILLA_BRANCH_MICRO_VERSION=0 -endif -endif - -EXTRA_DSO_LDOPTS += $(XPCOM_GLUE_LDOPTS) \ - $(NSPR_LIBS) \ - $(DBUSMENU_LIBS) \ - $(MOZ_GTK2_LIBS) \ - $(NULL) - -include $(topsrcdir)/config/rules.mk - -CXXFLAGS += $(DBUSMENU_CFLAGS) \ - $(MOZ_GTK2_CFLAGS) \ - $(NULL) - -ifneq (extensions, $(MOZ_BUILD_APP)) -CXXFLAGS += -DMOZILLA_BRANCH_MAJOR_VERSION="$(MOZILLA_BRANCH_MAJOR_VERSION)" \ - -DMOZILLA_BRANCH_MINOR_VERSION="$(MOZILLA_BRANCH_MINOR_VERSION)" \ - -DMOZILLA_BRANCH_MICRO_VERSION="$(MOZILLA_BRANCH_MICRO_VERSION)" -endif - -libs:: - @$(PYTHON) $(MOZILLA_DIR)/config/buildlist.py $(FINAL_TARGET)/components/components.manifest "category profile-after-change uGlobalMenuLoader @canonical.com/globalmenu-loader;1" reverted: --- firefox-11.0+build1/debian/globalmenu/components/src/uWidgetAtoms.h +++ firefox-11.0+build1.orig/debian/globalmenu/components/src/uWidgetAtoms.h @@ -1,58 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is mozilla.org code. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * Original Author: Mike Pinkerton (pinkerton@netscape.com) - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -#ifndef _U_WIDGETATOMS_H -#define _U_WIDGETATOMS_H - -#include "prtypes.h" -#include "nscore.h" - -class nsIAtom; - -class uWidgetAtoms { -public: - - static nsresult RegisterAtoms(); - -#define WIDGET_ATOM(_name, _value) static nsIAtom* _name; -#include "uWidgetAtomList.h" -#undef WIDGET_ATOM - -}; - -#endif reverted: --- firefox-11.0+build1/debian/globalmenu/components/src/uGlobalMenuSeparator.cpp +++ firefox-11.0+build1.orig/debian/globalmenu/components/src/uGlobalMenuSeparator.cpp @@ -1,185 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is globalmenu-extension. - * - * The Initial Developer of the Original Code is - * Canonical Ltd. - * Portions created by the Initial Developer are Copyright (C) 2010 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * Chris Coulson - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -#include -#include -#include - -#include -#include - -#include "uGlobalMenuSeparator.h" -#include "uGlobalMenuBar.h" -#include "uGlobalMenu.h" -#include "uWidgetAtoms.h" - -#include "uDebug.h" - -nsresult -uGlobalMenuSeparator::ConstructDbusMenuItem() -{ - mDbusMenuItem = dbusmenu_menuitem_new(); - if (!mDbusMenuItem) - return NS_ERROR_OUT_OF_MEMORY; - - dbusmenu_menuitem_property_set(mDbusMenuItem, - DBUSMENU_MENUITEM_PROP_TYPE, - "separator"); - - UpdateInfoFromContentClass(); - SyncVisibilityFromContent(); - - return NS_OK; -} - -nsresult -uGlobalMenuSeparator::Init(uGlobalMenuObject *aParent, - uGlobalMenuDocListener *aListener, - nsIContent *aContent, - uGlobalMenuBar *aMenuBar) -{ - NS_ENSURE_ARG(aParent); - NS_ENSURE_ARG(aListener); - NS_ENSURE_ARG(aContent); - NS_ENSURE_ARG(aMenuBar); - - mParent = aParent; - mListener = aListener; - mContent = aContent; - mMenuBar = aMenuBar; - - nsresult rv = mListener->RegisterForContentChanges(mContent, this); - NS_ENSURE_SUCCESS(rv, rv); - - return ConstructDbusMenuItem(); -} - -uGlobalMenuSeparator::uGlobalMenuSeparator(): uGlobalMenuObject(MenuSeparator) -{ - MOZ_COUNT_CTOR(uGlobalMenuSeparator); -} - -uGlobalMenuSeparator::~uGlobalMenuSeparator() -{ - if (mListener) { - mListener->UnregisterForContentChanges(mContent, this); - } - - if (mDbusMenuItem) - g_object_unref(mDbusMenuItem); - - MOZ_COUNT_DTOR(uGlobalMenuSeparator); -} - -/*static*/ uGlobalMenuObject* -uGlobalMenuSeparator::Create(uGlobalMenuObject *aParent, - uGlobalMenuDocListener *aListener, - nsIContent *aContent, - uGlobalMenuBar *aMenuBar) -{ - TRACE_WITH_CONTENT(aContent); - - uGlobalMenuSeparator *menuitem = new uGlobalMenuSeparator(); - if (!menuitem) { - return nsnull; - } - - if (NS_FAILED(menuitem->Init(aParent, aListener, aContent, aMenuBar))) { - delete menuitem; - return nsnull; - } - - return static_cast(menuitem); -} - -void -uGlobalMenuSeparator::AboutToShowNotify() -{ - if (IsDirty()) { - UpdateInfoFromContentClass(); - SyncVisibilityFromContent(); - - ClearInvalid(); - } else { - UpdateVisibility(); - } -} - -void -uGlobalMenuSeparator::ObserveAttributeChanged(nsIDocument *aDocument, - nsIContent *aContent, - nsIAtom *aAttribute) -{ - NS_ASSERTION(aContent == mContent, "Received an event that wasn't meant for us!"); - - if (IsDirty()) { - return; - } - - if (mParent->GetType() == Menu && - !(static_cast(mParent))->IsOpening()) { - Invalidate(); - return; - } - - if (aAttribute == uWidgetAtoms::hidden || - aAttribute == uWidgetAtoms::collapsed) { - SyncVisibilityFromContent(); - } else if (aAttribute == uWidgetAtoms::_class) { - UpdateInfoFromContentClass(); - SyncVisibilityFromContent(); - } -} - -void -uGlobalMenuSeparator::ObserveContentRemoved(nsIDocument *aDocument, - nsIContent *aContainer, - nsIContent *aChild, - PRInt32 aIndexInContainer) -{ - NS_ASSERTION(0, "We can't remove content from a menuseparator!"); -} - -void -uGlobalMenuSeparator::ObserveContentInserted(nsIDocument *aDocument, - nsIContent *aContainer, - nsIContent *aChild, - PRInt32 aIndexInContainer) -{ - NS_ASSERTION(0, "We can't insert content in to a menuseparator!"); -} reverted: --- firefox-11.0+build1/debian/globalmenu/components/src/uWidgetAtoms.cpp +++ firefox-11.0+build1.orig/debian/globalmenu/components/src/uWidgetAtoms.cpp @@ -1,81 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is mozilla.org code. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * Original Author: Mike Pinkerton (pinkerton@netscape.com) - * Chris Coulson - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -#include -#include -#include -#include -#include -#include -#include - -#define WIDGET_ATOM(_name, _value) nsIAtom* uWidgetAtoms::_name = 0; -#include "uWidgetAtomList.h" -#undef WIDGET_ATOM - -struct uWidgetAtom { - const char *raw; - nsIAtom **atom; -}; - -static const uWidgetAtom atoms[] = { -#define WIDGET_ATOM(_name, _value) { _value, &uWidgetAtoms::_name }, -#include "uWidgetAtomList.h" -#undef WIDGET_ATOM -}; - -nsresult -uWidgetAtoms::RegisterAtoms() -{ - nsCOMPtr as = - do_GetService("@mozilla.org/atom-service;1"); - NS_ENSURE_TRUE(as, NS_ERROR_OUT_OF_MEMORY); - - nsAutoString aAtomStr; - nsCAutoString cAtomStr; - - for (PRUint32 i = 0; i < NS_ARRAY_LENGTH(atoms); i++) { - cAtomStr = atoms[i].raw; - CopyUTF8toUTF16(cAtomStr, aAtomStr); - nsresult rv = as->GetAtom(aAtomStr, atoms[i].atom); - NS_ENSURE_SUCCESS(rv, rv); - } - - return NS_OK; -} reverted: --- firefox-11.0+build1/debian/globalmenu/components/src/uDebug.cpp +++ firefox-11.0+build1.orig/debian/globalmenu/components/src/uDebug.cpp @@ -1,43 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is globalmenu-extension. - * - * The Initial Developer of the Original Code is - * Canonical Ltd. - * Portions created by the Initial Developer are Copyright (C) 2010 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * Chris Coulson - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -#include "uDebug.h" - -#ifdef DEBUG_chrisccoulson -PRUint32 FunctionTracer::sDepth = 0; -#endif reverted: --- firefox-11.0+build1/debian/globalmenu/components/src/uGlobalMenuSeparator.h +++ firefox-11.0+build1.orig/debian/globalmenu/components/src/uGlobalMenuSeparator.h @@ -1,75 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is globalmenu-extension. - * - * The Initial Developer of the Original Code is - * Canonical Ltd. - * Portions created by the Initial Developer are Copyright (C) 2010 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * Chris Coulson - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -#ifndef _U_GLOBALMENUSEPARATOR_H -#define _U_GLOBALMENUSEPARATOR_H - -#include "uGlobalMenuObject.h" -#include "uMenuChangeObserver.h" - -class nsIContent; -class uGlobalMenuDocListener; -class uGlobalMenuBar; - -class uGlobalMenuSeparator: public uGlobalMenuObject, - public uMenuChangeObserver -{ -public: - NS_DECL_UMENUCHANGEOBSERVER - - static uGlobalMenuObject* Create(uGlobalMenuObject *aParent, - uGlobalMenuDocListener *aListener, - nsIContent *aContent, - uGlobalMenuBar *aMenuBar); - - void AboutToShowNotify(); - -private: - uGlobalMenuSeparator(); - - nsresult Init(uGlobalMenuObject *aParent, - uGlobalMenuDocListener *aListener, - nsIContent *aContent, - uGlobalMenuBar *aMenuBar); - ~uGlobalMenuSeparator(); - - nsresult ConstructDbusMenuItem(); -}; - - -#endif reverted: --- firefox-11.0+build1/debian/globalmenu/components/src/uGlobalMenuDummy.cpp +++ firefox-11.0+build1.orig/debian/globalmenu/components/src/uGlobalMenuDummy.cpp @@ -1,136 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is globalmenu-extension. - * - * The Initial Developer of the Original Code is - * Canonical Ltd. - * Portions created by the Initial Developer are Copyright (C) 2010 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * Chris Coulson - * Mike Conley - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -#include -#include -#include - -#include -#include - -#include "uGlobalMenuDummy.h" -#include "uGlobalMenuBar.h" -#include "uWidgetAtoms.h" - -#include "uDebug.h" - -nsresult -uGlobalMenuDummy::ConstructDbusMenuItem() -{ - mDbusMenuItem = dbusmenu_menuitem_new(); - if (!mDbusMenuItem) - return NS_ERROR_OUT_OF_MEMORY; - - dbusmenu_menuitem_property_set_bool(mDbusMenuItem, - DBUSMENU_MENUITEM_PROP_VISIBLE, - FALSE); - - return NS_OK; -} - -uGlobalMenuDummy::uGlobalMenuDummy(): - uGlobalMenuObject(MenuDummy) -{ - MOZ_COUNT_CTOR(uGlobalMenuDummy); -} - -uGlobalMenuDummy::~uGlobalMenuDummy() -{ - - if (mDbusMenuItem) - g_object_unref(mDbusMenuItem); - - MOZ_COUNT_DTOR(uGlobalMenuDummy); -} - -nsresult -uGlobalMenuDummy::Init() -{ - mParent = nsnull; - mMenuBar = nsnull; - - return ConstructDbusMenuItem(); -} - -/*static*/ uGlobalMenuObject* -uGlobalMenuDummy::Create() -{ - TRACE(); - - uGlobalMenuDummy *menuitem = new uGlobalMenuDummy(); - if (!menuitem) { - return nsnull; - } - - if (NS_FAILED(menuitem->Init())) { - delete menuitem; - return nsnull; - } - - return static_cast(menuitem); -} - -// GlobalMenuDummy is inert, and does not observe/react to content -// changes. The following methods are included simply to fill out -// the interface. -void -uGlobalMenuDummy::ObserveAttributeChanged(nsIDocument *aDocument, - nsIContent *aContent, - nsIAtom *aAttribute) -{ - -} - -void -uGlobalMenuDummy::ObserveContentRemoved(nsIDocument *aDocument, - nsIContent *aContainer, - nsIContent *aChild, - PRInt32 aIndexInContainer) -{ - -} - -void -uGlobalMenuDummy::ObserveContentInserted(nsIDocument *aDocument, - nsIContent *aContainer, - nsIContent *aChild, - PRInt32 aIndexInContainer) -{ - -} reverted: --- firefox-11.0+build1/debian/globalmenu/components/src/uGlobalMenuLoader.h +++ firefox-11.0+build1.orig/debian/globalmenu/components/src/uGlobalMenuLoader.h @@ -1,77 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is globalmenu-extension. - * - * The Initial Developer of the Original Code is - * Canonical Ltd. - * Portions created by the Initial Developer are Copyright (C) 2010 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * Chris Coulson - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -#include -#include -#include -#include - -#include "uIGlobalMenuService.h" - -#define U_GLOBALMENULOADER_CID \ -{ 0x1e8f2f48, 0xe0a8, 0x4649, { 0x98, 0xef, 0x13, 0x22, 0xc0, 0x3f, 0xf0, 0x8e } } - -#define U_GLOBALMENULOADER_CONTRACTID "@canonical.com/globalmenu-loader;1" - -class nsIXULWindow; -class nsIDocShell; -class nsIWidget; - -class uGlobalMenuLoader: public nsIObserver, - public nsIWindowMediatorListener, - public nsIWebProgressListener, - public nsSupportsWeakReference -{ -public: - NS_DECL_ISUPPORTS - NS_DECL_NSIOBSERVER - NS_DECL_NSIWINDOWMEDIATORLISTENER - NS_DECL_NSIWEBPROGRESSLISTENER - - uGlobalMenuLoader() { }; - ~uGlobalMenuLoader(); - nsresult Init(); - -private: - void RegisterAllMenus(); - void RegisterMenuForWindow(nsIXULWindow *aWindow); - PRBool RegisterMenu(nsIWidget *aWindow, - nsIDocShell *aDocShell); - - nsCOMPtr mService; -}; reverted: --- firefox-11.0+build1/debian/globalmenu/components/src/uGlobalMenuDummy.h +++ firefox-11.0+build1.orig/debian/globalmenu/components/src/uGlobalMenuDummy.h @@ -1,68 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is globalmenu-extension. - * - * The Initial Developer of the Original Code is - * Canonical Ltd. - * Portions created by the Initial Developer are Copyright (C) 2010 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * Chris Coulson - * Mike Conley - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -#ifndef _U_GLOBALMENUDUMMY_H -#define _U_GLOBALMENUDUMMY_H - -#include "uGlobalMenuObject.h" -#include "uMenuChangeObserver.h" - -class nsIContent; -class uGlobalMenuDocListener; - -class uGlobalMenuDummy: public uGlobalMenuObject, - public uMenuChangeObserver -{ -public: - NS_DECL_UMENUCHANGEOBSERVER - - static uGlobalMenuObject* Create(); - -private: - uGlobalMenuDummy(); - - nsresult Init(); - - ~uGlobalMenuDummy(); - - nsresult ConstructDbusMenuItem(); -}; - - -#endif reverted: --- firefox-11.0+build1/debian/globalmenu/components/src/uGlobalMenu.h +++ firefox-11.0+build1.orig/debian/globalmenu/components/src/uGlobalMenu.h @@ -1,116 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is globalmenu-extension. - * - * The Initial Developer of the Original Code is - * Canonical Ltd. - * Portions created by the Initial Developer are Copyright (C) 2010 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * Chris Coulson - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -#ifndef _U_GLOBALMENU_H -#define _U_GLOBALMENU_H - -#include -#include -#include -#include -#include - -#include - -#include "uGlobalMenuObject.h" -#include "uMenuChangeObserver.h" - -class uGlobalMenuItem; -class uGlobalMenuBar; -class uGlobalMenuDocListener; - -class uGlobalMenu: public uGlobalMenuObject, - public uMenuChangeObserver -{ -public: - NS_DECL_UMENUCHANGEOBSERVER - - static uGlobalMenuObject* Create(uGlobalMenuObject *aParent, - uGlobalMenuDocListener *aListener, - nsIContent *aContent, - uGlobalMenuBar *aMenuBar); - - ~uGlobalMenu(); - - PRBool CanOpen(); - void OpenMenu(); - void AboutToShowNotify(); - PRBool IsOpening() { return !!mOpening; } - -private: - uGlobalMenu(); - - // Initialize the menu structure - nsresult Init(uGlobalMenuObject *aParent, - uGlobalMenuDocListener *aListener, - nsIContent *aContent, - uGlobalMenuBar *aMenuBar); - PRBool InsertMenuObjectAt(uGlobalMenuObject *menuObj, - PRUint32 index); - PRBool AppendMenuObject(uGlobalMenuObject *menuObj); - PRBool RemoveMenuObjectAt(PRUint32 index); - nsresult ConstructDbusMenuItem(); - nsresult Build(); - void SyncProperties(); - void GetMenuPopupFromMenu(nsIContent **aResult); - static PRBool MenuAboutToOpenCallback(DbusmenuMenuitem *menu, - void *data); - static PRBool MenuEventCallback(DbusmenuMenuitem *menu, - const gchar *name, - GVariant *value, - guint timestamp, - void *data); - void AboutToOpen(); - void OnOpen(); - void OnClose(); - void Activate(); - void Deactivate(); - void SetNeedsRebuild() { mNeedsRebuild = PR_TRUE; } - void ClearNeedsRebuild() { mNeedsRebuild = PR_FALSE; } - PRBool DoesNeedRebuild() { return !!mNeedsRebuild; } - - nsCOMPtr mPopupContent; - nsTArray< nsAutoPtr > mMenuObjects; - PRUint32 mOpenHandlerID; - PRUint32 mEventHandlerID; - PRPackedBool mOpening; - PRPackedBool mNeedsRebuild; - PRPackedBool mPrimed; -}; - -#endif reverted: --- firefox-11.0+build1/debian/globalmenu/components/src/uGlobalMenuUtils.h +++ firefox-11.0+build1.orig/debian/globalmenu/components/src/uGlobalMenuUtils.h @@ -1,104 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is globalmenu-extension. - * - * The Initial Developer of the Original Code is - * Canonical Ltd. - * Portions created by the Initial Developer are Copyright (C) 2010 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * Chris Coulson - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -#ifndef _U_GLOBALMENUFACTORY_H -#define _U_GLOBALMENUFACTORY_H - -#include - -class uGlobalMenuObject; -class uGlobalMenuDocListener; -class nsIContent; -class uGlobalMenuBar; -class nsIAtom; - -class uGlobalMenuRequestAutoCanceller -{ -public: - static uGlobalMenuRequestAutoCanceller* Create() - { - uGlobalMenuRequestAutoCanceller *canceller = - new uGlobalMenuRequestAutoCanceller(); - if (!canceller) { - return nsnull; - } - - if (!canceller->Init()) { - delete canceller; - canceller = nsnull; - } - - return canceller; - } - - GCancellable* GetCancellable() - { - return mCancellable; - } - - void Destroy() - { - if (mCancellable) { - g_object_unref(mCancellable); - mCancellable = nsnull; - } - } - - ~uGlobalMenuRequestAutoCanceller() - { - if (mCancellable) { - g_cancellable_cancel(mCancellable); - g_object_unref(mCancellable); - } - } -private: - uGlobalMenuRequestAutoCanceller() { }; - PRBool Init() - { - mCancellable = g_cancellable_new(); - return mCancellable ? PR_TRUE : PR_FALSE; - } - - GCancellable *mCancellable; -}; - -uGlobalMenuObject* NewGlobalMenuItem(uGlobalMenuObject *aParent, - uGlobalMenuDocListener *aListener, - nsIContent *aContent, - uGlobalMenuBar *aMenuBar); -#endif reverted: --- firefox-11.0+build1/debian/globalmenu/components/src/uGlobalMenuDocListener.cpp +++ firefox-11.0+build1.orig/debian/globalmenu/components/src/uGlobalMenuDocListener.cpp @@ -1,312 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is mozilla.org code. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * Josh Aas - * Thomas K. Dyas - * Chris Coulson - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -#include -#include -#include -#include -#include -#include -#include - -#include "uGlobalMenuDocListener.h" - -#include "uDebug.h" - -NS_IMPL_ISUPPORTS1(uGlobalMenuDocListener, nsIMutationObserver) - -nsresult -uGlobalMenuDocListener::Init(nsIContent *rootNode) -{ - NS_ENSURE_ARG(rootNode); - -#if MOZILLA_BRANCH_MAJOR_VERSION >= 10 - mDocument = rootNode->OwnerDoc(); -#else - mDocument = rootNode->GetOwnerDoc(); -#endif - if (!mDocument) - return NS_ERROR_FAILURE; - mDocument->AddMutationObserver(this); - - return NS_OK; -} - -void -uGlobalMenuDocListener::Destroy() -{ - if (mDocument) { - mDocument->RemoveMutationObserver(this); - } -} - -uGlobalMenuDocListener::uGlobalMenuDocListener() : -#ifdef DEBUG_chrisccoulson - mCount(0), -#endif - mDocument(nsnull) -{ - mContentToObserverTable.Init(); -} - -uGlobalMenuDocListener::~uGlobalMenuDocListener() -{ - NS_ASSERTION(mCount == 0, "Some nodes forgot to unregister listeners"); -} - -void -uGlobalMenuDocListener::CharacterDataWillChange(nsIDocument *aDocument, - nsIContent *aContent, - CharacterDataChangeInfo *aInfo) -{ - -} - -void -uGlobalMenuDocListener::CharacterDataChanged(nsIDocument *aDocument, - nsIContent *aContent, - CharacterDataChangeInfo *aInfo) -{ - -} - -void -uGlobalMenuDocListener::AttributeWillChange(nsIDocument *aDocument, - mozilla::dom::Element *aElement, - PRInt32 aNameSpaceID, - nsIAtom *aAttribute, - PRInt32 aModType) -{ - -} - -void -uGlobalMenuDocListener::AttributeChanged(nsIDocument *aDocument, - mozilla::dom::Element *aElement, - PRInt32 aNameSpaceID, - nsIAtom *aAttribute, - PRInt32 aModType) -{ - if (!aElement) - return; - - nsTArray listeners; - GetListeners(aElement, listeners); - - for (PRUint32 i = 0; i < listeners.Length(); i++) { - listeners[i]->ObserveAttributeChanged(aDocument, aElement, aAttribute); - } -} - -void -uGlobalMenuDocListener::ContentAppended(nsIDocument *aDocument, - nsIContent *aContainer, - nsIContent *aFirstNewContent, - PRInt32 aNewIndexInContainer) -{ - for (nsIContent* cur = aFirstNewContent; cur; cur = cur->GetNextSibling()) { - ContentInserted(aDocument, aContainer, cur, aNewIndexInContainer); - aNewIndexInContainer++; - } -} - -void -uGlobalMenuDocListener::ContentInserted(nsIDocument *aDocument, - nsIContent *aContainer, - nsIContent *aChild, - PRInt32 aIndexInContainer) -{ - if (!aContainer) - return; - - nsTArray listeners; - GetListeners(aContainer, listeners); - - for (PRUint32 i = 0; i < listeners.Length(); i++) { - listeners[i]->ObserveContentInserted(aDocument, aContainer, aChild, - aIndexInContainer); - } - - if (listeners.Length() == 0) { - for (PRUint32 i = 0; i < mGlobalObservers.Length(); i++) { - mGlobalObservers[i]->ObserveContentInserted(aDocument, aContainer, - aChild, aIndexInContainer); - } - } -} - -void -uGlobalMenuDocListener::ContentRemoved(nsIDocument *aDocument, - nsIContent *aContainer, - nsIContent *aChild, - PRInt32 aIndexInContainer, - nsIContent *aPreviousSibling) -{ - if (!aContainer) - return; - - nsTArray listeners; - GetListeners(aContainer, listeners); - - for (PRUint32 i = 0; i < listeners.Length(); i++) { - listeners[i]->ObserveContentRemoved(aDocument, aContainer, aChild, - aIndexInContainer); - } - - if (listeners.Length() == 0) { - for (PRUint32 i = 0; i < mGlobalObservers.Length(); i++) { - mGlobalObservers[i]->ObserveContentRemoved(aDocument, aContainer, aChild, - aIndexInContainer); - } - } -} - -void -uGlobalMenuDocListener::NodeWillBeDestroyed(const nsINode *aNode) -{ - mDocument = nsnull; -} - -void -uGlobalMenuDocListener::ParentChainChanged(nsIContent *aContent) -{ - -} - -nsresult -uGlobalMenuDocListener::RegisterForContentChanges(nsIContent *aContent, - uMenuChangeObserver *aMenuObject) -{ - NS_ENSURE_ARG(aContent); - NS_ENSURE_ARG(aMenuObject); - - nsTArray *listeners; - if (!mContentToObserverTable.Get(aContent, &listeners)) { - listeners = new nsTArray(); - mContentToObserverTable.Put(aContent, listeners); - } - - for (PRUint32 i = 0; i < listeners->Length(); i++) { - if (listeners->ElementAt(i) == aMenuObject) { - return NS_ERROR_FAILURE; - } - } - - listeners->AppendElement(aMenuObject); -#ifdef DEBUG_chrisccoulson - mCount++; -#endif - return NS_OK; -} - -nsresult -uGlobalMenuDocListener::UnregisterForContentChanges(nsIContent *aContent, - uMenuChangeObserver *aMenuObject) -{ - NS_ENSURE_ARG(aContent); - NS_ENSURE_ARG(aMenuObject); - - nsTArray *listeners; - if (!mContentToObserverTable.Get(aContent, &listeners)) { - return NS_ERROR_FAILURE; - } - - PRUint32 length = listeners->Length(); - for (PRUint32 i = 0; i < length; i++) { - if (listeners->ElementAt(i) == aMenuObject) { - listeners->RemoveElementAt(i); -#ifdef DEBUG_chrisccoulson - mCount--; -#endif - } - } - - nsresult rv = listeners->Length() < length ? NS_OK : NS_ERROR_FAILURE; - - if (listeners->Length() == 0) { - mContentToObserverTable.Remove(aContent); - } - - return rv; -} - -nsresult -uGlobalMenuDocListener::RegisterForAllChanges(uMenuChangeObserver *aMenuObject) -{ - NS_ENSURE_ARG(aMenuObject); - - PRUint32 count = mGlobalObservers.Length(); - for (PRUint32 i = 0; i < count; i ++) { - if (mGlobalObservers[i] == aMenuObject) { - // Don't add more than once - return NS_ERROR_FAILURE; - } - } - - mGlobalObservers.AppendElement(aMenuObject); - return NS_OK; -} - -nsresult -uGlobalMenuDocListener::UnregisterForAllChanges(uMenuChangeObserver *aMenuObject) -{ - NS_ENSURE_ARG(aMenuObject); - - PRUint32 count = mGlobalObservers.Length(); - for (PRUint32 i = 0; i < count; i++) { - if (mGlobalObservers[i] == aMenuObject) { - mGlobalObservers.RemoveElementAt(i); - return NS_OK; - } - } - - return NS_ERROR_FAILURE; -} - -void -uGlobalMenuDocListener::GetListeners(nsIContent *aContent, - nsTArray& _result) -{ - nsTArray *listeners; - if (mContentToObserverTable.Get(aContent, &listeners)) { - _result.ReplaceElementsAt(0, _result.Length(), listeners->Elements(), - listeners->Length()); - } -} reverted: --- firefox-11.0+build1/debian/globalmenu/components/src/uGlobalMenuService.cpp +++ firefox-11.0+build1.orig/debian/globalmenu/components/src/uGlobalMenuService.cpp @@ -1,430 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is globalmenu-extension. - * - * The Initial Developer of the Original Code is - * Canonical Ltd. - * Portions created by the Initial Developer are Copyright (C) 2010 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * Chris Coulson - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -#include "uGlobalMenuService.h" -#include "uWidgetAtoms.h" - -#include "uDebug.h" -#include "compat.h" - -class RegisterWindowCbData -{ -public: - RegisterWindowCbData(uGlobalMenuBar *aMenu, - uGlobalMenuRequestAutoCanceller *aCanceller): - mMenu(aMenu), - mCanceller(aCanceller) - { - mCancellable = mCanceller->GetCancellable(); - if (mCancellable) { - g_object_ref(mCancellable); - mID = g_cancellable_connect(mCancellable, G_CALLBACK(Cancelled), this, nsnull); - } - } - - static void Cancelled(GCancellable *aCancellable, - gpointer userdata) - { - RegisterWindowCbData *cbdata = - static_cast(userdata); - - // If the request was cancelled, then invalidate pointers to objects - // that might not exist anymore - - cbdata->mMenu = nsnull; - cbdata->mCanceller = nsnull; - } - - uGlobalMenuBar* GetMenuBar() { return mMenu; } - - ~RegisterWindowCbData() - { - if (mCancellable) { - g_cancellable_disconnect(mCancellable, mID); - g_object_unref(mCancellable); - } - } - -private: - uGlobalMenuBar *mMenu; - GCancellable *mCancellable; - uGlobalMenuRequestAutoCanceller *mCanceller; - PRUint32 mID; -}; - -NS_IMPL_ISUPPORTS2(uGlobalMenuService, uIGlobalMenuService, nsIWindowMediatorListener) - -/*static*/ void -uGlobalMenuService::ProxyCreatedCallback(GObject *object, - GAsyncResult *res, - gpointer userdata) -{ - uGlobalMenuService *self = static_cast(userdata); - - GError *error = NULL; - GDBusProxy *proxy = g_dbus_proxy_new_for_bus_finish(res, &error); - - if (error && g_error_matches(error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) { - // We should only get cancelled if the service was destroyed. - // In this case, it is no longer safe to proceed - return; - } - - self->mCancellable->Destroy(); - self->mCancellable = nsnull; - - self->mDbusProxy = proxy; - - if (!proxy) { - NS_WARNING("Failed to create proxy for AppMenu registrar"); - self->SetOnline(PR_FALSE); - return; - } - - self->mNOCHandlerID = g_signal_connect(self->mDbusProxy, "notify::g-name-owner", - G_CALLBACK(NameOwnerChangedCallback), - userdata); - - char *owner = g_dbus_proxy_get_name_owner(self->mDbusProxy); - self->SetOnline(owner ? PR_TRUE : PR_FALSE); - - if (error) { - g_error_free(error); - } - g_free(owner); -} - -/*static*/ void -uGlobalMenuService::NameOwnerChangedCallback(GObject *object, - GParamSpec *pspec, - gpointer userdata) -{ - uGlobalMenuService *self = static_cast(userdata); - - char *owner = g_dbus_proxy_get_name_owner(self->mDbusProxy); - self->SetOnline(owner ? PR_TRUE : PR_FALSE); - g_free(owner); -} - -/*static*/ void -uGlobalMenuService::RegisterWindowCallback(GObject *object, - GAsyncResult *res, - gpointer userdata) -{ - RegisterWindowCbData *data = - static_cast(userdata); - - uGlobalMenuBar *menu = data->GetMenuBar(); - GDBusProxy *proxy = G_DBUS_PROXY(object); - - GError *error = NULL; - // RegisterWindowCbData owns a reference to the proxy - GVariant *result = g_dbus_proxy_call_finish(proxy, res, &error); - if (result) { - g_variant_unref(result); - } - - if (error && g_error_matches(error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) { - // The call is cancelled if uGlobalMenuService goes away or the - // panel service goes offline. In either case, the menu has now - // been destroyed - delete data; - return; - } - - if (menu && !PR_GetEnv("GLOBAL_MENU_DEBUG")) { - // This check is probably bogus. menu should only be invalid if - // the request was cancelled, in which case, we should have - // returned already - menu->SetMenuBarRegistered(error ? PR_FALSE : PR_TRUE); - } - - if (error) { - g_error_free(error); - } - - delete data; -} - -void -uGlobalMenuService::DestroyMenus() -{ - PRUint32 count = mMenus.Length(); - for (PRUint32 j = 0; j < count; j++) { - mMenus.RemoveElementAt(0); - } -} - -void -uGlobalMenuService::DestroyMenuForWidget(nsIWidget *aWidget) -{ - for (PRUint32 i = 0; i < mMenus.Length(); i++) { - if (mMenus[i]->WidgetHasSameToplevelWindow(aWidget)) { - mMenus.RemoveElementAt(i); - return; - } - } -} - -void -uGlobalMenuService::SetOnline(PRBool aOnline) -{ - if (mOnline != !!aOnline) { - mOnline = !!aOnline; - nsCOMPtr os = - do_GetService("@mozilla.org/observer-service;1"); - if (os) { - os->NotifyObservers(nsnull, mOnline ? "native-menu-service:online" : "native-menu-service:offline", 0); - } - - if (!mOnline) { - DestroyMenus(); - } - } -} - -PRBool -uGlobalMenuService::WidgetHasGlobalMenu(nsIWidget *aWidget) -{ - for (PRUint32 i = 0; i < mMenus.Length(); i++) { - if (mMenus[i]->WidgetHasSameToplevelWindow(aWidget)) - return PR_TRUE; - } - return PR_FALSE; -} - -nsresult -uGlobalMenuService::Init() -{ - nsresult rv; - rv = uWidgetAtoms::RegisterAtoms(); - NS_ENSURE_SUCCESS(rv, rv); - - mCancellable = uGlobalMenuRequestAutoCanceller::Create(); - - GDBusProxyFlags flags = static_cast( - G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES | - G_DBUS_PROXY_FLAGS_DO_NOT_CONNECT_SIGNALS | - G_DBUS_PROXY_FLAGS_DO_NOT_AUTO_START); - - g_dbus_proxy_new_for_bus(G_BUS_TYPE_SESSION, - flags, - NULL, - "com.canonical.AppMenu.Registrar", - "/com/canonical/AppMenu/Registrar", - "com.canonical.AppMenu.Registrar", - mCancellable->GetCancellable(), - ProxyCreatedCallback, - this); - - nsCOMPtr wm = - do_GetService("@mozilla.org/appshell/window-mediator;1"); - NS_ENSURE_TRUE(wm, NS_ERROR_OUT_OF_MEMORY); - - wm->AddListener(this); - return rv; -} - -uGlobalMenuService::~uGlobalMenuService() -{ - nsCOMPtr wm = - do_GetService("@mozilla.org/appshell/window-mediator;1"); - - if (wm) { - wm->RemoveListener(this); - } - - if (mDbusProxy) { - g_signal_handler_disconnect(mDbusProxy, mNOCHandlerID); - g_object_unref(mDbusProxy); - } -} - -NS_IMETHODIMP -uGlobalMenuService::CreateGlobalMenuBar(nsIWidget *aParent, - nsIContent *aMenuBarNode) -{ - NS_ENSURE_ARG(aParent); - NS_ENSURE_ARG(aMenuBarNode); - - NS_ENSURE_TRUE(mOnline, NS_ERROR_FAILURE); - - // Sanity check to make sure we don't register more than one menu - // for each top-level window - if (WidgetHasGlobalMenu(aParent)) - return NS_ERROR_FAILURE; - - uGlobalMenuBar *menu = uGlobalMenuBar::Create(aParent, aMenuBarNode); - NS_ENSURE_TRUE(menu, NS_ERROR_FAILURE); - - mMenus.AppendElement(menu); - - return NS_OK; -} - -/* [noscript, notxpcom] void registerGlobalMenuBar (in uGlobalMenuBarPtr menuBar); */ -NS_IMETHODIMP_(void) -uGlobalMenuService::RegisterGlobalMenuBar(uGlobalMenuBar *aMenuBar, - uGlobalMenuRequestAutoCanceller *aCanceller) -{ - if (mOnline != PR_TRUE) - return; - - if (!aMenuBar) - return; - - if (!aCanceller) { - return; - } - - PRUint32 xid = aMenuBar->GetWindowID(); - nsCAutoString path(aMenuBar->GetMenuPath()); - if (xid == 0 || path.IsEmpty()) - return; - - RegisterWindowCbData *data = - new RegisterWindowCbData(aMenuBar, - aCanceller); - if (!data) { - return; - } - - g_dbus_proxy_call(mDbusProxy, - "RegisterWindow", - g_variant_new("(uo)", xid, path.get()), - G_DBUS_CALL_FLAGS_NONE, - -1, - aCanceller->GetCancellable(), - RegisterWindowCallback, - data); -} - -/* void registerNotification (in nsIObserver observer); */ -NS_IMETHODIMP -uGlobalMenuService::RegisterNotification(nsIObserver *aObserver) -{ - NS_ENSURE_ARG(aObserver); - - nsCOMPtr os = - do_GetService("@mozilla.org/observer-service;1"); - NS_ENSURE_TRUE(os, NS_ERROR_OUT_OF_MEMORY); - - nsresult rv; - rv = os->AddObserver(aObserver, "native-menu-service:online", MOZ_API_FALSE); - NS_ENSURE_SUCCESS(rv, rv); - - rv = os->AddObserver(aObserver, "native-menu-service:offline", MOZ_API_FALSE); - NS_ENSURE_SUCCESS(rv, rv); - - rv = os->AddObserver(aObserver, "native-menu-service:popup-open", MOZ_API_FALSE); - return rv; -} - -/* void unregisterNotification (in nsIObserver observer); */ -NS_IMETHODIMP -uGlobalMenuService::UnregisterNotification(nsIObserver *aObserver) -{ - NS_ENSURE_ARG(aObserver); - - nsCOMPtr os = - do_GetService("@mozilla.org/observer-service;1"); - NS_ENSURE_TRUE(os, NS_ERROR_OUT_OF_MEMORY); - - nsresult rv; - rv = os->RemoveObserver(aObserver, "native-menu-service:online"); - NS_ENSURE_SUCCESS(rv, rv); - - rv = os->RemoveObserver(aObserver, "native-menu-service:offline"); - NS_ENSURE_SUCCESS(rv, rv); - - rv = os->RemoveObserver(aObserver, "native-menu-service:popup-open"); - return rv; -} - -/* readonly attribute boolean online; */ -NS_IMETHODIMP -uGlobalMenuService::GetOnline(MOZ_API_BOOL *online) -{ - NS_ENSURE_ARG_POINTER(online); - *online = !!mOnline; - return NS_OK; -} - -NS_IMETHODIMP -uGlobalMenuService::OnWindowTitleChange(nsIXULWindow *window, - const PRUnichar *newTitle) -{ - return NS_ERROR_NOT_IMPLEMENTED; -} - -NS_IMETHODIMP -uGlobalMenuService::OnOpenWindow(nsIXULWindow *window) -{ - return NS_ERROR_NOT_IMPLEMENTED; -} - -NS_IMETHODIMP -uGlobalMenuService::OnCloseWindow(nsIXULWindow *window) -{ - nsCOMPtr baseWindow = do_QueryInterface(window); - NS_ENSURE_TRUE(baseWindow, NS_ERROR_INVALID_ARG); - - nsCOMPtr widget; - baseWindow->GetMainWidget(getter_AddRefs(widget)); - NS_ENSURE_TRUE(widget, NS_ERROR_FAILURE); - - DestroyMenuForWidget(widget); - - return NS_OK; -} reverted: --- firefox-11.0+build1/debian/globalmenu/components/src/uMenuChangeObserver.h +++ firefox-11.0+build1.orig/debian/globalmenu/components/src/uMenuChangeObserver.h @@ -1,80 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- - * - * ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is Mozilla Communicator. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corp. - * Portions created by the Initial Developer are Copyright (C) 1999 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * Mike Pinkerton - * Josh Aas (decomtaminate) - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -#ifndef _U_MENUCHANGEOBSERVER_H -#define _U_MENUCHANGEOBSERVER_H - -class nsIContent; -class nsIDocument; -class nsIAtom; - -#define NS_DECL_UMENUCHANGEOBSERVER \ -void ObserveAttributeChanged(nsIDocument *aDocument, nsIContent *aContent, nsIAtom *aAttribute); \ -void ObserveContentRemoved(nsIDocument *aDocument, nsIContent *aContainer, nsIContent *aChild, PRInt32 aIndexInContainer); \ -void ObserveContentInserted(nsIDocument *aDocument, nsIContent *aContainer, nsIContent *aChild, PRInt32 aIndexInContainer); - -// Something that wants to be alerted to changes in attributes or changes in -// its corresponding content object. -// -// This interface is used by our menu code so we only have to have one -// nsIDocumentObserver. -// -// Any class that implements this interface must take care to unregister itself -// on deletion. -class uMenuChangeObserver -{ -public: - // XXX use dom::Element - virtual void ObserveAttributeChanged(nsIDocument *aDocument, - nsIContent *aContent, - nsIAtom *aAttribute)=0; - - virtual void ObserveContentRemoved(nsIDocument *aDocument, - nsIContent *aContainer, - nsIContent *aChild, - PRInt32 aIndexInContainer)=0; - - virtual void ObserveContentInserted(nsIDocument *aDocument, - nsIContent *aContainer, - nsIContent *aChild, - PRInt32 aIndexInContainer)=0; -}; - -#endif reverted: --- firefox-11.0+build1/debian/globalmenu/components/src/uGlobalMenuObject.h +++ firefox-11.0+build1.orig/debian/globalmenu/components/src/uGlobalMenuObject.h @@ -1,174 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is globalmenu-extension. - * - * The Initial Developer of the Original Code is - * Canonical Ltd. - * Portions created by the Initial Developer are Copyright (C) 2010 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * Chris Coulson - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -#ifndef _U_GLOBALMENUBASE_H -#define _U_GLOBALMENUBASE_H - -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -#include "uGlobalMenuDocListener.h" - -enum uMenuObjectType { - MenuBar, - Menu, - MenuItem, - MenuSeparator, - MenuDummy -}; - -class uGlobalMenuObject; -class uGlobalMenuBar; - -#define UGM_BLOCK_EVENTS_FOR_CURRENT_SCOPE() \ - uGlobalMenuObjectEventBlocker _event_blocker(this); -#define UGM_ENSURE_EVENTS_UNBLOCKED() \ - if (mEventsBlocked) { \ - DEBUG_WITH_THIS_MENUOBJECT("Events are blocked on this node"); \ - return; \ - } - -class uGlobalMenuIconLoader: public imgIDecoderObserver, - public nsRunnable -{ - friend class uGlobalMenuObject; -public: - NS_DECL_ISUPPORTS - NS_DECL_IMGIDECODEROBSERVER - NS_DECL_IMGICONTAINEROBSERVER - NS_DECL_NSIRUNNABLE - - void LoadIcon(); - - uGlobalMenuIconLoader(uGlobalMenuObject *aMenuItem): - mMenuItem(aMenuItem) { }; - ~uGlobalMenuIconLoader() { }; - -protected: - void Destroy(); - -private: - void ClearIcon(); - PRBool ShouldShowIcon(); - - PRBool mIconLoaded; - uGlobalMenuObject *mMenuItem; - nsCOMPtr mContent; - nsCOMPtr mIconRequest; - nsIntRect mImageRect; - static PRPackedBool sImagesInMenus; - static nsCOMPtr sLoader; -}; - -class uGlobalMenuObject -{ - friend class uGlobalMenuIconLoader; - friend class uGlobalMenuObjectEventBlocker; -public: - uGlobalMenuObject (uMenuObjectType aType): mDbusMenuItem(nsnull), - mListener(nsnull), - mParent(nsnull), - mType(aType), - mEventsBlocked(PR_FALSE), - mDirty(PR_FALSE) - { }; - DbusmenuMenuitem* GetDbusMenuItem() { return mDbusMenuItem; } - uGlobalMenuObject* GetParent() { return mParent; } - uMenuObjectType GetType() { return mType; } - void GetContent(nsIContent **_retval); - virtual void AboutToShowNotify() { }; - virtual ~uGlobalMenuObject() { }; - -protected: - void SyncLabelFromContent(nsIContent *aContent); - void SyncLabelFromContent(); - void SyncVisibilityFromContent(); - void SyncSensitivityFromContent(nsIContent *aContent); - void SyncSensitivityFromContent(); - void SyncIconFromContent(); - void UpdateInfoFromContentClass(); - void UpdateVisibility(); - void DestroyIconLoader(); - PRBool WithFavicon() { return !!mWithFavicon; } - PRBool IsHidden(); - void Invalidate() { mDirty = PR_TRUE; } - void ClearInvalid() { mDirty = PR_FALSE; } - PRBool IsDirty() { return !!mDirty; } - - nsCOMPtr mContent; - DbusmenuMenuitem *mDbusMenuItem; - nsRefPtr mListener; - uGlobalMenuObject *mParent; - uMenuObjectType mType; - uGlobalMenuBar *mMenuBar; - PRPackedBool mContentVisible; - PRPackedBool mEventsBlocked; - -private: - PRBool ShouldShowOnlyForKb() { return !!mShowOnlyForKb; } - - nsRefPtr mIconLoader; - PRPackedBool mWithFavicon; - PRPackedBool mShowOnlyForKb; - PRPackedBool mDirty; -}; - -class uGlobalMenuObjectEventBlocker -{ -public: - uGlobalMenuObjectEventBlocker(uGlobalMenuObject *aMenuObject): - mMenuObject(aMenuObject) - { - mMenuObject->mEventsBlocked = PR_TRUE; - } - - ~uGlobalMenuObjectEventBlocker() { mMenuObject->mEventsBlocked = PR_FALSE; } - -private: - uGlobalMenuObject *mMenuObject; -}; - -#endif reverted: --- firefox-11.0+build1/debian/globalmenu/components/src/uGlobalMenuBar.h +++ firefox-11.0+build1.orig/debian/globalmenu/components/src/uGlobalMenuBar.h @@ -1,156 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is globalmenu-extension. - * - * The Initial Developer of the Original Code is - * Canonical Ltd. - * Portions created by the Initial Developer are Copyright (C) 2010 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * Chris Coulson - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -#ifndef _U_GLOBALMENUBAR_H -#define _U_GLOBALMENUBAR_H - -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -#include "uMenuChangeObserver.h" -#include "uGlobalMenuObject.h" -#include "uGlobalMenuUtils.h" - -// Meh. X.h defines this -#ifdef KeyPress -# undef KeyPress -#endif - -class nsIObserver; -class nsIWidget; -class nsIDOMEvent; -class uGlobalMenuService; -class uGlobalMenu; -class uGlobalMenuBar; -class nsIDOMKeyEvent; - -class uGlobalMenuBarListener: public nsIDOMEventListener -{ -public: - NS_DECL_ISUPPORTS - NS_DECL_NSIDOMEVENTLISTENER - - uGlobalMenuBarListener(uGlobalMenuBar *aMenuBar): - mMenuBar(aMenuBar) { }; - ~uGlobalMenuBarListener() { }; - -private: - uGlobalMenuBar *mMenuBar; -}; - -class uGlobalMenuBar: public uGlobalMenuObject, - public uMenuChangeObserver -{ - friend class uGlobalMenuBarListener; -public: - NS_DECL_UMENUCHANGEOBSERVER - - static uGlobalMenuBar* Create(nsIWidget *aWindow, - nsIContent *aMenuBar); - ~uGlobalMenuBar(); - - // Return the native ID of the window - PRUint32 GetWindowID(); - - // Returns the path of the menubar on the session bus - const char* GetMenuPath(); - - // Checks if the menubar shares the same top level window as the - // specified nsIWidget - PRBool WidgetHasSameToplevelWindow(nsIWidget *aWidget); - - // Returns whether the menu was opened via a keyboard shortcut - PRBool OpenedByKeyboard() { return !!mOpenedByKeyboard; } - - // Called from the menu service. Used to hide the DOM element for the menubar - void SetMenuBarRegistered(PRBool aRegistered); - - PRBool IsRegistered() { return mCancellable == nsnull; } - -protected: - void Focus(); - void Blur(); - nsresult KeyPress(nsIDOMEvent *aKeyEvent); - nsresult KeyUp(nsIDOMEvent *aKeyEvent); - nsresult KeyDown(nsIDOMEvent *aKeyEvent); -private: - uGlobalMenuBar(); - // Initialize the menu structure - nsresult Init(nsIWidget *aWindow, - nsIContent *aMenuBar); - - GtkWidget* WidgetToGTKWindow(nsIWidget *aWidget); - nsresult Build(); - PRUint32 GetModifiersFromEvent(nsIDOMKeyEvent *aKeyEvent); - PRBool ShouldHandleKeyEvent(nsIDOMEvent *aKeyEvent); - - PRBool RemoveMenuObjectAt(PRUint32 index); - PRBool InsertMenuObjectAt(uGlobalMenuObject *menu, - PRUint32 index); - PRBool AppendMenuObject(uGlobalMenuObject *menu); - PRBool ShouldParentStayVisible(nsIContent *aContent); - PRBool IsParentOfMenuBar(nsIContent *aContent); - void SetXULMenuBarHidden(PRBool hidden); - - DbusmenuServer *mServer; - GtkWidget *mTopLevel; - nsCString mPath; - - nsCOMPtr mHiddenElement; - nsCOMPtr mDocTarget; - PRPackedBool mRestoreHidden; - PRPackedBool mXULMenuHidden; - nsRefPtr mEventListener; - PRInt32 mAccessKey; - PRUint32 mAccessKeyMask; - PRPackedBool mOpenedByKeyboard; - nsAutoPtr mCancellable; - - // Should probably have a container class and subclass that - nsTArray< nsAutoPtr > mMenuObjects; -}; - -#endif reverted: --- firefox-11.0+build1/debian/globalmenu/components/src/uGlobalMenuLoader.cpp +++ firefox-11.0+build1.orig/debian/globalmenu/components/src/uGlobalMenuLoader.cpp @@ -1,317 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is globalmenu-extension. - * - * The Initial Developer of the Original Code is - * Canonical Ltd. - * Portions created by the Initial Developer are Copyright (C) 2010 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * Chris Coulson - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "uIGlobalMenuService.h" -#include "uGlobalMenuLoader.h" - -#include "uDebug.h" -#include "compat.h" - -// XXX: The sole purpose of this class is to listen for new nsIXULWindows -// and do the task that xpfe/appshell/src/nsWebShellWindow.cpp -// would be doing if this extension were part of Mozilla core. The reason -// it is an entirely separate entity is so that the menubar service -// implementation is as close as possible to how it might look inside Mozilla - -void -uGlobalMenuLoader::RegisterMenuForWindow(nsIXULWindow *aWindow) -{ - nsCOMPtr baseWindow = do_QueryInterface(aWindow); - if (!baseWindow) - return; - - nsCOMPtr mainWidget; - baseWindow->GetMainWidget(getter_AddRefs(mainWidget)); - if (!mainWidget) - return; - - nsCOMPtr docShell; - aWindow->GetDocShell(getter_AddRefs(docShell)); - if (!docShell) - return; - - PRBool res = RegisterMenu(mainWidget, docShell); - - if (!res) { - // If we've been called off a window open event from the window mediator, - // then the document probably hasn't loaded yet. To fix this, we set up a progress - // listener on the docshell, so we can do the actual menu load once the - // document has finished loading - nsCOMPtr progress = do_GetInterface(docShell); - if (progress) { - progress->AddProgressListener(this, nsIWebProgress::NOTIFY_STATE_NETWORK); - } - } -} - -PRBool -uGlobalMenuLoader::RegisterMenu(nsIWidget *aWindow, - nsIDocShell *aDocShell) -{ - nsCOMPtr cv; - aDocShell->GetContentViewer(getter_AddRefs(cv)); - if (!cv) - return PR_FALSE; - - nsIDocument *doc = cv->GetDocument(); - nsCOMPtr domDoc = do_QueryInterface(doc); - if (!domDoc) - return PR_FALSE; - - nsresult rv; - nsCOMPtr elements; - rv = domDoc->GetElementsByTagNameNS(NS_LITERAL_STRING("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"), - NS_LITERAL_STRING("menubar"), - getter_AddRefs(elements)); - if (NS_FAILED(rv) || !elements) - return PR_TRUE; - - nsCOMPtr menubar; - elements->Item(0, getter_AddRefs(menubar)); - if (!menubar) - return PR_TRUE; - - nsCOMPtr menubarContent = do_QueryInterface(menubar); - // XXX: Should we do anything with errors here? - mService->CreateGlobalMenuBar(aWindow, menubarContent); - - return PR_TRUE; -} - -void -uGlobalMenuLoader::RegisterAllMenus() -{ - nsCOMPtr wm = - do_GetService("@mozilla.org/appshell/window-mediator;1"); - if (!wm) { - return; - } - - nsCOMPtr iter; - wm->GetXULWindowEnumerator(nsnull, getter_AddRefs(iter)); - if (!iter) { - return; - } - - MOZ_API_BOOL hasMore; - iter->HasMoreElements(&hasMore); - - while (hasMore) { - nsCOMPtr elem; - iter->GetNext(getter_AddRefs(elem)); - iter->HasMoreElements(&hasMore); - if (!elem) - continue; - - nsCOMPtr xulWindow = do_QueryInterface(elem); - if (!xulWindow) - continue; - - RegisterMenuForWindow(xulWindow); - } -} - -NS_IMPL_ISUPPORTS3(uGlobalMenuLoader, nsIObserver, nsIWebProgressListener, nsISupportsWeakReference) - -nsresult -uGlobalMenuLoader::Init() -{ - mService = do_GetService("@canonical.com/globalmenu-service;1"); - NS_ENSURE_TRUE(mService, NS_ERROR_OUT_OF_MEMORY); - - mService->RegisterNotification(this); - - nsCOMPtr wm = - do_GetService("@mozilla.org/appshell/window-mediator;1"); - NS_ENSURE_TRUE(wm, NS_ERROR_OUT_OF_MEMORY); - - wm->AddListener(this); - - MOZ_API_BOOL online; - mService->GetOnline(&online); - if (online) { - RegisterAllMenus(); - } - - return NS_OK; -} - -uGlobalMenuLoader::~uGlobalMenuLoader() -{ - mService->UnregisterNotification(this); - - nsCOMPtr wm = - do_GetService("@mozilla.org/appshell/window-mediator;1"); - - if (wm) { - wm->RemoveListener(this); - } -} - -NS_IMETHODIMP -uGlobalMenuLoader::Observe(nsISupports *aSubject, - const char *aTopic, - const PRUnichar *aData) -{ - if (strcmp(aTopic, "native-menu-service:online") == 0) { - RegisterAllMenus(); - } - - return NS_OK; -} - -/* void onWindowTitleChange (in nsIXULWindow window, in wstring newTitle); */ -NS_IMETHODIMP -uGlobalMenuLoader::OnWindowTitleChange(nsIXULWindow *window, - const PRUnichar *newTitle) -{ - return NS_ERROR_NOT_IMPLEMENTED; -} - -/* void onOpenWindow (in nsIXULWindow window); */ -NS_IMETHODIMP -uGlobalMenuLoader::OnOpenWindow(nsIXULWindow *window) -{ - RegisterMenuForWindow(window); - return NS_OK; -} - -/* void onCloseWindow (in nsIXULWindow window); */ -NS_IMETHODIMP -uGlobalMenuLoader::OnCloseWindow(nsIXULWindow *window) -{ - return NS_ERROR_NOT_IMPLEMENTED; -} - -NS_IMETHODIMP -uGlobalMenuLoader::OnStateChange(nsIWebProgress *aWebProgress, - nsIRequest *aRequest, - PRUint32 aStateFlags, - nsresult aStatus) -{ - // Borrowed from nsWebShellWindow.cpp - - // If the notification is not about a document finishing, then just - // ignore it... - if (!(aStateFlags & nsIWebProgressListener::STATE_STOP) || - !(aStateFlags & nsIWebProgressListener::STATE_IS_NETWORK)) { - return NS_OK; - } - - // If this document notification is for a frame then ignore it... - nsCOMPtr eventWin; - aWebProgress->GetDOMWindow(getter_AddRefs(eventWin)); - nsCOMPtr eventPWin(do_QueryInterface(eventWin)); - if (eventPWin) { - nsPIDOMWindow *rootPWin = eventPWin->GetPrivateRoot(); - if (eventPWin != rootPWin) - return NS_OK; - } - - aWebProgress->RemoveProgressListener(this); - - nsCOMPtr baseWindow = do_GetInterface(aWebProgress); - if (baseWindow) { - nsCOMPtr parentWidget; - baseWindow->GetParentWidget(getter_AddRefs(parentWidget)); - - nsCOMPtr docShell = do_GetInterface(aWebProgress); - if (docShell && parentWidget) { - RegisterMenu(parentWidget, docShell); - } - } - - return NS_OK; -} - -NS_IMETHODIMP -uGlobalMenuLoader::OnProgressChange(nsIWebProgress *aWebProgress, - nsIRequest *aRequest, - PRInt32 aCurSelfProgress, - PRInt32 aMaxSelfProgress, - PRInt32 aCurTotalProgress, - PRInt32 aMaxTotalProgress) -{ - return NS_ERROR_NOT_IMPLEMENTED; -} - -NS_IMETHODIMP -uGlobalMenuLoader::OnLocationChange(nsIWebProgress *aWebProgress, - nsIRequest *aRequest, -#if MOZILLA_BRANCH_MAJOR_VERSION <= 10 - nsIURI *aLocation) -#else - nsIURI *aLocation, - PRUint32 aFlags) -#endif -{ - return NS_ERROR_NOT_IMPLEMENTED; -} - -NS_IMETHODIMP -uGlobalMenuLoader::OnStatusChange(nsIWebProgress *aWebProgress, - nsIRequest *aRequest, - nsresult aStatus, - const PRUnichar *aMessage) -{ - return NS_ERROR_NOT_IMPLEMENTED; -} - -NS_IMETHODIMP -uGlobalMenuLoader::OnSecurityChange(nsIWebProgress *aWebProgress, - nsIRequest *aRequest, - PRUint32 aState) -{ - return NS_ERROR_NOT_IMPLEMENTED; -} reverted: --- firefox-11.0+build1/debian/globalmenu/components/src/compat.h +++ firefox-11.0+build1.orig/debian/globalmenu/components/src/compat.h @@ -1,51 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is globalmenu-extension. - * - * The Initial Developer of the Original Code is - * Canonical Ltd. - * Portions created by the Initial Developer are Copyright (C) 2010 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * Chris Coulson - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -#if MOZILLA_BRANCH_MAJOR_VERSION >= 10 -# define MOZ_API_BOOL bool -# define MOZ_API_TRUE true -# define MOZ_API_FALSE false -#else -# define MOZ_API_BOOL PRBool -# define MOZ_API_TRUE PR_TRUE -# define MOZ_API_FALSE PR_FALSE -#endif - -#if MOZILLA_BRANCH_MAJOR_VERSION >= 11 -# define nsIDOMNSElement nsIDOMElement -#endif reverted: --- firefox-11.0+build1/debian/globalmenu/components/src/uGlobalMenuDocListener.h +++ firefox-11.0+build1.orig/debian/globalmenu/components/src/uGlobalMenuDocListener.h @@ -1,85 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is mozilla.org code. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * Josh Aas - * Thomas K. Dyas - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -#ifndef _U_GLOBALMENUDOCLISTENER_H -#define _U_GLOBALMENUDOCLISTENER_H - -#include -#include -#include -#include - -#include "uMenuChangeObserver.h" - -#ifdef DEBUG -#define DEBUG_chrisccoulson -#endif - -class nsIContent; -class nsIDocument; - -class uGlobalMenuDocListener: public nsIMutationObserver -{ -public: - NS_DECL_ISUPPORTS - NS_DECL_NSIMUTATIONOBSERVER - - uGlobalMenuDocListener(); - nsresult Init(nsIContent *rootNode); - nsresult RegisterForContentChanges(nsIContent *aContent, - uMenuChangeObserver *aMenuObject); - nsresult UnregisterForContentChanges(nsIContent *aContent, - uMenuChangeObserver *aMenuObject); - nsresult RegisterForAllChanges(uMenuChangeObserver *aMenuObject); - nsresult UnregisterForAllChanges(uMenuChangeObserver *aMenuObject); - void Destroy(); - ~uGlobalMenuDocListener(); - -private: - void GetListeners(nsIContent *aContent, nsTArray& _result); - - nsIDocument *mDocument; - nsClassHashtable, nsTArray > mContentToObserverTable; - nsTArray mGlobalObservers; -#ifdef DEBUG_chrisccoulson - PRUint32 mCount; -#endif -}; - -#endif reverted: --- firefox-11.0+build1/debian/globalmenu/components/src/uGlobalMenuService.h +++ firefox-11.0+build1.orig/debian/globalmenu/components/src/uGlobalMenuService.h @@ -1,98 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is globalmenu-extension. - * - * The Initial Developer of the Original Code is - * Canonical Ltd. - * Portions created by the Initial Developer are Copyright (C) 2010 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * Chris Coulson - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -#ifndef _U_GLOBALMENUSERVICE_H -#define _U_GLOBALMENUSERVICE_H - -#include -#include -#include -#include - -#include -#include - -#include "uGlobalMenuBar.h" -#include "uIGlobalMenuService.h" -#include "uGlobalMenuUtils.h" - -#define U_GLOBALMENUSERVICE_CID \ -{ 0xa9e41684, 0xbf71, 0x46e3, { 0x93, 0xbf, 0x3c, 0xda, 0x1e, 0xc6, 0x16, 0x49 } } - -#define U_GLOBALMENUSERVICE_CONTRACTID "@canonical.com/globalmenu-service;1" - -class nsIWidget; - -class uGlobalMenuService: public uIGlobalMenuService, - public nsIWindowMediatorListener -{ -public: - NS_DECL_ISUPPORTS - NS_DECL_UIGLOBALMENUSERVICE - NS_DECL_NSIWINDOWMEDIATORLISTENER - - uGlobalMenuService() : mOnline(PR_FALSE), - mDbusProxy(NULL), - mCancellable(NULL) { }; - nsresult Init(); - - ~uGlobalMenuService(); - -private: - void SetOnline(PRBool aOnline); - static void ProxyCreatedCallback(GObject *object, - GAsyncResult *res, - gpointer userdata); - static void NameOwnerChangedCallback(GObject *object, - GParamSpec *pspec, - gpointer userdata); - static void RegisterWindowCallback(GObject *object, - GAsyncResult *res, - gpointer userdata); - PRBool WidgetHasGlobalMenu(nsIWidget *aWidget); - void DestroyMenus(); - void DestroyMenuForWidget(nsIWidget *aWidget); - - PRPackedBool mOnline; - GDBusProxy *mDbusProxy; - nsAutoPtr mCancellable; - PRUint32 mNOCHandlerID; - nsTArray< nsAutoPtr > mMenus; -}; - -#endif reverted: --- firefox-11.0+build1/debian/globalmenu/components/src/uGlobalMenuBar.cpp +++ firefox-11.0+build1.orig/debian/globalmenu/components/src/uGlobalMenuBar.cpp @@ -1,696 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is globalmenu-extension. - * - * The Initial Developer of the Original Code is - * Canonical Ltd. - * Portions created by the Initial Developer are Copyright (C) 2010 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * Chris Coulson - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -#include -#include -#include -#include -#include -#include -#include -#include -#if 1 -# include -#endif -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -#include "uGlobalMenuBar.h" -#include "uGlobalMenu.h" -#include "uGlobalMenuUtils.h" -#include "uIGlobalMenuService.h" -#include "uWidgetAtoms.h" - -#include "uDebug.h" -#include "compat.h" - -#define MODIFIER_SHIFT 1 -#define MODIFIER_CONTROL 2 -#define MODIFIER_ALT 4 -#define MODIFIER_META 8 - -NS_IMPL_ISUPPORTS1(uGlobalMenuBarListener, nsIDOMEventListener) - -NS_IMETHODIMP -uGlobalMenuBarListener::HandleEvent(nsIDOMEvent *aEvent) -{ - nsAutoString type; - nsresult rv = aEvent->GetType(type); - NS_ENSURE_SUCCESS(rv, rv); - - if (type.EqualsLiteral("focus")) { - mMenuBar->Focus(); - } else if (type.EqualsLiteral("blur")) { - mMenuBar->Blur(); - } else if (type.EqualsLiteral("keypress")) { - rv = mMenuBar->KeyPress(aEvent); - } else if (type.EqualsLiteral("keydown")) { - rv = mMenuBar->KeyDown(aEvent); - } else if (type.EqualsLiteral("keyup")) { - rv = mMenuBar->KeyUp(aEvent); - } - - return rv; -} - -GtkWidget* -uGlobalMenuBar::WidgetToGTKWindow(nsIWidget *aWidget) -{ - // Get the main GDK drawing window from our nsIWidget - GdkWindow *window = static_cast(aWidget->GetNativeData(NS_NATIVE_WINDOW)); - if (!window) - return nsnull; - - // Get the widget for the main drawing window, which should be a MozContainer - gpointer user_data = nsnull; - gdk_window_get_user_data(window, &user_data); - if (!user_data || !GTK_IS_CONTAINER(user_data)) - return nsnull; - - return gtk_widget_get_toplevel(GTK_WIDGET(user_data)); -} - -PRBool -uGlobalMenuBar::AppendMenuObject(uGlobalMenuObject *menu) -{ - gboolean res = dbusmenu_menuitem_child_append(mDbusMenuItem, - menu->GetDbusMenuItem()); - return res && mMenuObjects.AppendElement(menu); -} - -PRBool -uGlobalMenuBar::InsertMenuObjectAt(uGlobalMenuObject *menu, - PRUint32 index) -{ - gboolean res = dbusmenu_menuitem_child_add_position(mDbusMenuItem, - menu->GetDbusMenuItem(), - index); - return res && mMenuObjects.InsertElementAt(index, menu); -} - -PRBool -uGlobalMenuBar::RemoveMenuObjectAt(PRUint32 index) -{ - NS_ASSERTION(index < mMenuObjects.Length(), "Invalid index"); - if (index >= mMenuObjects.Length()) { - return PR_FALSE; - } - - gboolean res = dbusmenu_menuitem_child_delete(mDbusMenuItem, - mMenuObjects[index]->GetDbusMenuItem()); - mMenuObjects.RemoveElementAt(index); - - return !!res; -} - -nsresult -uGlobalMenuBar::Build() -{ - PRUint32 count = mContent->GetChildCount(); - - for (PRUint32 i = 0; i < count; i++) { - nsIContent *menuContent = mContent->GetChildAt(i); - uGlobalMenuObject *newItem = - NewGlobalMenuItem(static_cast(this), - mListener, menuContent, this); - PRBool res = PR_FALSE; - if (newItem) { - res = AppendMenuObject(newItem); - } - NS_ASSERTION(res, "Failed to append menuitem. Our menu representation is out-of-sync with reality"); - if (!res) { - // XXX: Is there anything else we should do here? - return NS_ERROR_FAILURE; - } - } - - return NS_OK; -} - -nsresult -uGlobalMenuBar::Init(nsIWidget *aWindow, - nsIContent *aMenuBar) -{ - NS_ENSURE_ARG(aWindow); - NS_ENSURE_ARG(aMenuBar); - - // We create this early so that IsRegistered() works - mCancellable = uGlobalMenuRequestAutoCanceller::Create(); - - mContent = aMenuBar; - - mTopLevel = WidgetToGTKWindow(aWindow); - if (!GTK_IS_WINDOW(mTopLevel)) - return NS_ERROR_FAILURE; - - g_object_ref(mTopLevel); - - mPath = NS_LITERAL_CSTRING("/com/canonical/menu/"); - char xid[10]; - sprintf(xid, "%X", (PRUint32) GDK_WINDOW_XID(gtk_widget_get_window(mTopLevel))); - mPath.Append(xid); - - mServer = dbusmenu_server_new(mPath.get()); - if (!mServer) - return NS_ERROR_OUT_OF_MEMORY; - - mDbusMenuItem = dbusmenu_menuitem_new(); - if (!mDbusMenuItem) - return NS_ERROR_OUT_OF_MEMORY; - - dbusmenu_server_set_root(mServer, mDbusMenuItem); - - mListener = new uGlobalMenuDocListener(); - if (!mListener) - return NS_ERROR_OUT_OF_MEMORY; - - nsresult rv = mListener->Init(mContent); - NS_ENSURE_SUCCESS(rv, rv); - - rv = mListener->RegisterForContentChanges(mContent, this); - NS_ENSURE_SUCCESS(rv, rv); - - rv = Build(); - NS_ENSURE_SUCCESS(rv, rv); - - mEventListener = new uGlobalMenuBarListener(this); - NS_ENSURE_TRUE(mEventListener, NS_ERROR_OUT_OF_MEMORY); - - mDocTarget = do_QueryInterface(mContent->GetCurrentDoc()); - - mDocTarget->AddEventListener(NS_LITERAL_STRING("focus"), - mEventListener, - MOZ_API_TRUE); - mDocTarget->AddEventListener(NS_LITERAL_STRING("blur"), - mEventListener, - MOZ_API_TRUE); - mDocTarget->AddEventListener(NS_LITERAL_STRING("keypress"), - mEventListener, - MOZ_API_FALSE); - mDocTarget->AddEventListener(NS_LITERAL_STRING("keydown"), - mEventListener, - MOZ_API_FALSE); - mDocTarget->AddEventListener(NS_LITERAL_STRING("keyup"), - mEventListener, - MOZ_API_FALSE); - - nsCOMPtr prefs = do_GetService(NS_PREFSERVICE_CONTRACTID); - NS_ENSURE_TRUE(prefs, NS_ERROR_FAILURE); - - prefs->GetIntPref("ui.key.menuAccessKey", &mAccessKey); - if (mAccessKey == nsIDOMKeyEvent::DOM_VK_SHIFT) { - mAccessKeyMask = MODIFIER_SHIFT; - } else if (mAccessKey == nsIDOMKeyEvent::DOM_VK_CONTROL) { - mAccessKeyMask = MODIFIER_CONTROL; - } else if (mAccessKey == nsIDOMKeyEvent::DOM_VK_ALT) { - mAccessKeyMask = MODIFIER_ALT; - } else if (mAccessKey == nsIDOMKeyEvent::DOM_VK_META) { - mAccessKeyMask = MODIFIER_META; - } else { - mAccessKeyMask = MODIFIER_ALT; - } - - rv = mListener->RegisterForAllChanges(this); - NS_ENSURE_SUCCESS(rv, rv); - - nsCOMPtr service = - do_GetService("@canonical.com/globalmenu-service;1"); - NS_ENSURE_TRUE(service, NS_ERROR_FAILURE); - - service->RegisterGlobalMenuBar(this, mCancellable); - - return NS_OK; -} - -PRBool -uGlobalMenuBar::ShouldParentStayVisible(nsIContent *aContent) -{ - static nsIAtom *blacklist[] = - { uWidgetAtoms::toolbarspring, nsnull }; - - nsIContent *parent = aContent->GetParent(); - if (!parent) { - return PR_TRUE; - } - - PRUint32 count = parent->GetChildCount(); - - if (count <= 1) { - // It's just us - return PR_FALSE; - } - - for (PRUint32 i = 0 ; i < count ; i++) { - nsIContent *child = parent->GetChildAt(i); - if (child == aContent) { - continue; - } - - PRBool found = PR_FALSE; - for (PRUint32 j = 0 ; blacklist[j] != nsnull ; j++) { - if (child->Tag() == blacklist[j]) { - found = PR_TRUE; - break; - } - } - - if (!found) { - return PR_TRUE; - } - } - - return PR_FALSE; -} - -PRUint32 -uGlobalMenuBar::GetModifiersFromEvent(nsIDOMKeyEvent *aKeyEvent) -{ - PRUint32 modifiers = 0; - MOZ_API_BOOL modifier; - - aKeyEvent->GetAltKey(&modifier); - if (modifier) { - modifiers |= MODIFIER_ALT; - } - - aKeyEvent->GetShiftKey(&modifier); - if (modifier) { - modifiers |= MODIFIER_SHIFT; - } - - aKeyEvent->GetCtrlKey(&modifier); - if (modifier) { - modifiers |= MODIFIER_CONTROL; - } - - aKeyEvent->GetMetaKey(&modifier); - if (modifier) { - modifiers |= MODIFIER_META; - } - - return modifiers; -} - -PRBool -uGlobalMenuBar::IsParentOfMenuBar(nsIContent *aContent) -{ - nsIContent *tmp = mContent->GetParent(); - - while (tmp) { - if (tmp == aContent) { - return PR_TRUE; - } - - tmp = tmp->GetParent(); - } - - return PR_FALSE; -} - -void -uGlobalMenuBar::SetXULMenuBarHidden(PRBool hidden) -{ - mXULMenuHidden = hidden; - - if (hidden) { - if (mHiddenElement) { - mHiddenElement->SetAttr(kNameSpaceID_None, uWidgetAtoms::hidden, - mRestoreHidden ? NS_LITERAL_STRING("true") : - NS_LITERAL_STRING("false"), MOZ_API_TRUE); - } - nsIContent *tmp = mContent; - - // Walk up the DOM tree until we find a node with siblings - while (tmp) { - if (ShouldParentStayVisible(tmp)) { - break; - } - - tmp = tmp->GetParent(); - } - - mHiddenElement = tmp; - mRestoreHidden = mHiddenElement->AttrValueIs(kNameSpaceID_None, - uWidgetAtoms::hidden, - uWidgetAtoms::_true, - eCaseMatters); - - mHiddenElement->SetAttr(kNameSpaceID_None, uWidgetAtoms::hidden, - NS_LITERAL_STRING("true"), MOZ_API_TRUE); - } else if (mHiddenElement) { - mHiddenElement->SetAttr(kNameSpaceID_None, uWidgetAtoms::hidden, - mRestoreHidden ? NS_LITERAL_STRING("true") : - NS_LITERAL_STRING("false"), MOZ_API_TRUE); - mHiddenElement = nsnull; - } -} - -uGlobalMenuBar::uGlobalMenuBar(): - uGlobalMenuObject(MenuBar), mServer(nsnull), mTopLevel(nsnull), - mOpenedByKeyboard(PR_FALSE) -{ - MOZ_COUNT_CTOR(uGlobalMenuBar); -} - -uGlobalMenuBar::~uGlobalMenuBar() -{ - SetXULMenuBarHidden(PR_FALSE); - - if (mDocTarget) { - mDocTarget->RemoveEventListener(NS_LITERAL_STRING("focus"), - mEventListener, - MOZ_API_TRUE); - mDocTarget->RemoveEventListener(NS_LITERAL_STRING("blur"), - mEventListener, - MOZ_API_TRUE); - mDocTarget->RemoveEventListener(NS_LITERAL_STRING("keypress"), - mEventListener, - MOZ_API_FALSE); - mDocTarget->RemoveEventListener(NS_LITERAL_STRING("keydown"), - mEventListener, - MOZ_API_FALSE); - mDocTarget->RemoveEventListener(NS_LITERAL_STRING("keyup"), - mEventListener, - MOZ_API_FALSE); - } - - if (mListener) { - mListener->UnregisterForAllChanges(this); - mListener->UnregisterForContentChanges(mContent, this); - mListener->Destroy(); - } - - if (mTopLevel) - g_object_unref(mTopLevel); - - if (mDbusMenuItem) - g_object_unref(mDbusMenuItem); - - if (mServer) - g_object_unref(mServer); - - MOZ_COUNT_DTOR(uGlobalMenuBar); -} - -/*static*/ uGlobalMenuBar* -uGlobalMenuBar::Create(nsIWidget *aWindow, - nsIContent *aMenuBar) -{ - uGlobalMenuBar *menubar = new uGlobalMenuBar(); - if (!menubar) { - return nsnull; - } - - if (NS_FAILED(menubar->Init(aWindow, aMenuBar))) { - delete menubar; - return nsnull; - } - - return menubar; -} - -void -uGlobalMenuBar::Blur() -{ - dbusmenu_server_set_status(mServer, DBUSMENU_STATUS_NORMAL); -} - -void -uGlobalMenuBar::Focus() -{ - mOpenedByKeyboard = PR_FALSE; -} - -PRBool -uGlobalMenuBar::ShouldHandleKeyEvent(nsIDOMEvent *aKeyEvent) -{ -#if 0 -# define nsEvent aKeyEvent -#else - nsCOMPtr nsEvent = do_QueryInterface(aKeyEvent); - if (!nsEvent) { - return PR_FALSE; - } -#endif - - MOZ_API_BOOL handled, trusted; - nsEvent->GetPreventDefault(&handled); - nsEvent->GetIsTrusted(&trusted); - -#if 0 -# undef nsEvent -#endif - - if (handled || !trusted) { - return PR_FALSE; - } - - return PR_TRUE; -} - -nsresult -uGlobalMenuBar::KeyDown(nsIDOMEvent *aKeyEvent) -{ - if (!ShouldHandleKeyEvent(aKeyEvent)) { - return NS_OK; - } - - nsCOMPtr keyEvent = do_QueryInterface(aKeyEvent); - if (keyEvent) { - PRUint32 keyCode; - keyEvent->GetKeyCode(&keyCode); - PRUint32 modifiers = GetModifiersFromEvent(keyEvent); - if ((keyCode == static_cast(mAccessKey)) && - ((modifiers & ~mAccessKeyMask) == 0)) { - dbusmenu_server_set_status(mServer, DBUSMENU_STATUS_NOTICE); - } - } - - return NS_OK; -} - -nsresult -uGlobalMenuBar::KeyUp(nsIDOMEvent *aKeyEvent) -{ - if (!ShouldHandleKeyEvent(aKeyEvent)) { - return NS_OK; - } - - nsCOMPtr keyEvent = do_QueryInterface(aKeyEvent); - if (keyEvent) { - PRUint32 keyCode; - keyEvent->GetKeyCode(&keyCode); - if (keyCode == static_cast(mAccessKey)) { - dbusmenu_server_set_status(mServer, DBUSMENU_STATUS_NORMAL); - } - } - - return NS_OK; -} - -nsresult -uGlobalMenuBar::KeyPress(nsIDOMEvent *aKeyEvent) -{ - if (!ShouldHandleKeyEvent(aKeyEvent)) { - return NS_OK; - } - - nsCOMPtr keyEvent = do_QueryInterface(aKeyEvent); - uGlobalMenuObject *found = nsnull; - PRUint32 keyCode = nsnull; - - if (keyEvent) { - keyEvent->GetKeyCode(&keyCode); - PRUint32 count = mMenuObjects.Length(); - PRUint32 modifiers = GetModifiersFromEvent(keyEvent); - if ((modifiers & mAccessKeyMask) && ((modifiers & ~mAccessKeyMask) == 0)) { - // The menu access modifier is pressed - PRUint32 charCode; - keyEvent->GetCharCode(&charCode); - if (charCode != 0) { - PRUnichar ch = PRUnichar(charCode); - PRUnichar chl; - PRUnichar chu; - // XXX: I think we need to link against libxul.so to get ToLowerCase - // and ToUpperCase from nsUnicharUtils.h - nsCOMPtr converter = - do_GetService(NS_UNICHARUTIL_CONTRACTID); - if (converter) { - converter->ToUpper(ch, &chu); - converter->ToLower(ch, &chl); - } else { - if (ch < 256) { - chu = toupper(char(ch)); - chl = tolower(char(ch)); - } else { - chu = ch; - chl = ch; - } - } - - for (PRUint32 i = 0; i < count; i++) { - nsCOMPtr content; - mMenuObjects[i]->GetContent(getter_AddRefs(content)); - if (content) { - nsAutoString accessKey; - content->GetAttr(kNameSpaceID_None, uWidgetAtoms::accesskey, - accessKey); - const PRUnichar *key = accessKey.BeginReading(); - if (*key == chl || *key == chu) { - found = mMenuObjects[i]; - break; - } - } - } - } - } else if (keyCode == nsIDOMKeyEvent::DOM_VK_F10) { - // Go through each mMenuObject, and find the first one - // that is both visible and sensitive, and mark it found - // for opening. - for (PRUint32 i = 0; i < count; i++) { - uGlobalMenu *menu = static_cast((uGlobalMenuObject *)mMenuObjects[i]); - if (menu->CanOpen()) { - found = mMenuObjects[i]; - break; - } - } - } - } - - if (found) { - mOpenedByKeyboard = PR_TRUE; - uGlobalMenu *menu = static_cast(found); - menu->OpenMenu(); - aKeyEvent->StopPropagation(); - aKeyEvent->PreventDefault(); - } - - return NS_OK; -} - -void -uGlobalMenuBar::SetMenuBarRegistered(PRBool aRegistered) -{ - if (mCancellable) { - mCancellable->Destroy(); - mCancellable = nsnull; - } - - SetXULMenuBarHidden(aRegistered); -} - -PRUint32 -uGlobalMenuBar::GetWindowID() -{ - return (PRUint32) GDK_WINDOW_XID(gtk_widget_get_window(mTopLevel)); -} - -const char* -uGlobalMenuBar::GetMenuPath() -{ - return mPath.get(); -} - -PRBool -uGlobalMenuBar::WidgetHasSameToplevelWindow(nsIWidget *aWidget) -{ - GtkWidget *topLevel = WidgetToGTKWindow(aWidget); - return GDK_WINDOW_XID(gtk_widget_get_window(mTopLevel)) == GDK_WINDOW_XID(gtk_widget_get_window(topLevel)); -} - -void -uGlobalMenuBar::ObserveAttributeChanged(nsIDocument *aDocument, - nsIContent *aContent, - nsIAtom *aAttribute) -{ - -} - -void -uGlobalMenuBar::ObserveContentRemoved(nsIDocument *aDocument, - nsIContent *aContainer, - nsIContent *aChild, - PRInt32 aIndexInContainer) -{ - if (IsParentOfMenuBar(aContainer)) { - SetXULMenuBarHidden(mXULMenuHidden); - return; - } - - if (aContainer != mContent) { - return; - } - - PRBool res = RemoveMenuObjectAt(aIndexInContainer); - NS_ASSERTION(res, "Failed to remove menuitem. Our menu representation is out-of-sync with reality"); - // XXX: Is there anything else we can do if removal fails? -} - -void -uGlobalMenuBar::ObserveContentInserted(nsIDocument *aDocument, - nsIContent *aContainer, - nsIContent *aChild, - PRInt32 aIndexInContainer) -{ - if (IsParentOfMenuBar(aContainer)) { - SetXULMenuBarHidden(mXULMenuHidden); - return; - } - - if (aContainer != mContent) { - return; - } - - uGlobalMenuObject *newItem = - NewGlobalMenuItem(static_cast(this), - mListener, aChild, this); - PRBool res = PR_FALSE; - if (newItem) { - res = InsertMenuObjectAt(newItem, aIndexInContainer); - } - NS_ASSERTION(res, "Failed to insert menuitem. Our menu representation is out-of-sync with reality"); - // XXX: Is there anything else we can do if insertion fails? -} reverted: --- firefox-11.0+build1/debian/globalmenu/components/src/uGlobalMenuObject.cpp +++ firefox-11.0+build1.orig/debian/globalmenu/components/src/uGlobalMenuObject.cpp @@ -1,711 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is globalmenu-extension. - * - * The Initial Developer of the Original Code is - * Canonical Ltd. - * Portions created by the Initial Developer are Copyright (C) 2010 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * Chris Coulson - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#if MOZILLA_BRANCH_MAJOR_VERSION < 11 -# include -#endif -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -#include "uGlobalMenuObject.h" -#include "uGlobalMenuBar.h" -#include "uWidgetAtoms.h" - -#include "uDebug.h" -#include "compat.h" - -#define MAX_LABEL_NCHARS 40 - -typedef nsresult (nsIDOMRect::*GetRectSideMethod)(nsIDOMCSSPrimitiveValue**); - -NS_IMPL_ISUPPORTS3(uGlobalMenuIconLoader, imgIDecoderObserver, imgIContainerObserver, nsIRunnable) - -// Yes, we're abusing PRPackedBool a bit here. We initialize it to a value -// that is neither true or false, so that we don't need another static member -// to indicate the intialization status of it. -PRPackedBool uGlobalMenuIconLoader::sImagesInMenus = -1; -nsCOMPtr uGlobalMenuIconLoader::sLoader = 0; - -PRBool -uGlobalMenuIconLoader::ShouldShowIcon() -{ - // Ideally, we want to get the visibility of the XUL image in our menu item, - // but that is anonymous content which is only created when the frame is drawn - // (which obviously never happens here). - // As an alternative, we get the user setting for menus-have-icons from - // nsILookAndFeel. If menu icons are to be hidden, we hide everything except - // for menuitems with the menuitem-with-favicon class. This is basically - // how the visibility gets set anyway (see chrome://toolkit/content/xul.css), - // which should work in most cases. But, I guess a theme could override this, - // and then we ignore the users theme settings. Oh well...... - - if (sImagesInMenus == static_cast(-1)) { - // We could get the correct GtkSettings by getting the GdkScreen that our - // top-level window is on. However, I don't think this matters, as - // nsILookAndFeel never had per-screen settings - GtkSettings *settings = gtk_settings_get_default(); - gboolean menus_have_icons; - g_object_get(settings, "gtk-menu-images", &menus_have_icons, NULL); - - sImagesInMenus = !!menus_have_icons; - } - - if (sImagesInMenus) { - return PR_TRUE; - } - - return mMenuItem->WithFavicon(); -} - -void -uGlobalMenuIconLoader::LoadIcon() -{ - NS_DispatchToCurrentThread(this); -} - -static PRInt32 -GetDOMRectSide(nsIDOMRect* aRect, GetRectSideMethod aMethod) -{ - nsCOMPtr dimensionValue; - (aRect->*aMethod)(getter_AddRefs(dimensionValue)); - if (!dimensionValue) - return -1; - - PRUint16 primitiveType; - nsresult rv = dimensionValue->GetPrimitiveType(&primitiveType); - if (NS_FAILED(rv) || primitiveType != nsIDOMCSSPrimitiveValue::CSS_PX) - return -1; - - float dimension = 0; - rv = dimensionValue->GetFloatValue(nsIDOMCSSPrimitiveValue::CSS_PX, - &dimension); - if (NS_FAILED(rv)) - return -1; - - return NSToIntRound(dimension); -} - -NS_IMETHODIMP -uGlobalMenuIconLoader::Run() -{ - TRACE_WITH_MENUOBJECT(mMenuItem); - // Some of this is borrowed from widget/src/cocoa/nsMenuItemIconX.mm - if (mIconRequest) { - mIconRequest->Cancel(NS_BINDING_ABORTED); - mIconRequest = nsnull; - } - - if (!mMenuItem) { - // Our menu item got destroyed already - return NS_OK; - } - - mMenuItem->GetContent(getter_AddRefs(mContent)); - - nsIDocument *doc = mContent->GetCurrentDoc(); - if (!doc) { - // We might have been removed from the menu, in which case we will - // no longer be in a document - return NS_OK; - } - - if (!ShouldShowIcon()) { - ClearIcon(); - return NS_OK; - } - - mIconLoaded = PR_FALSE; - - nsAutoString uriString; - PRBool hasImage = mContent->GetAttr(kNameSpaceID_None, uWidgetAtoms::image, - uriString); - - nsresult rv; - nsCOMPtr domRect; - - if (!hasImage) { - DEBUG_WITH_MENUOBJECT(mMenuItem, "Menuitem does not have an image"); - nsCOMPtr cssStyleDecl; - nsCOMPtr domWin; - nsCOMPtr domDoc = do_QueryInterface(doc); - if (domDoc) { - domDoc->GetDefaultView(getter_AddRefs(domWin)); - if (domWin) { - nsCOMPtr domElement = do_QueryInterface(mContent); - if (domElement) { - domWin->GetComputedStyle(domElement, EmptyString(), - getter_AddRefs(cssStyleDecl)); - } - } - } - - if (!cssStyleDecl) { - return NS_ERROR_FAILURE; - } - - nsCOMPtr cssValue; - nsCOMPtr primitiveValue; - PRUint16 primitiveType; - cssStyleDecl->GetPropertyCSSValue(NS_LITERAL_STRING("list-style-image"), - getter_AddRefs(cssValue)); - if (cssValue) { - primitiveValue = do_QueryInterface(cssValue); - if (primitiveValue) { - primitiveValue->GetPrimitiveType(&primitiveType); - if (primitiveType == nsIDOMCSSPrimitiveValue::CSS_URI) { - rv = primitiveValue->GetStringValue(uriString); - if (NS_SUCCEEDED(rv)) { - hasImage = PR_TRUE; - } - } else { - NS_WARNING("list-style-image has wrong primitive type"); - } - } - } - - if (!hasImage) { - return NS_OK; - } - - cssStyleDecl->GetPropertyCSSValue(NS_LITERAL_STRING("-moz-image-region"), - getter_AddRefs(cssValue)); - if (cssValue) { - primitiveValue = do_QueryInterface(cssValue); - if (primitiveValue) { - primitiveValue->GetPrimitiveType(&primitiveType); - if (primitiveType == nsIDOMCSSPrimitiveValue::CSS_RECT) { - primitiveValue->GetRectValue(getter_AddRefs(domRect)); - } - } - } - } - - DEBUG_WITH_MENUOBJECT(mMenuItem, "Icon URI: %s", DEBUG_CSTR_FROM_UTF16(uriString)); - nsCOMPtr uri; - rv = NS_NewURI(getter_AddRefs(uri), uriString); - if (NS_FAILED(rv)) { - NS_WARNING("Failed to create new URI"); - ClearIcon(); - return NS_OK; - } - - if (!sLoader) { - sLoader = do_GetService("@mozilla.org/image/loader;1"); - } - - NS_ASSERTION(sLoader, "No icon loader"); - if (!sLoader) { - return NS_OK; - } - - nsCOMPtr loadGroup = doc->GetDocumentLoadGroup(); - -#if MOZILLA_BRANCH_MAJOR_VERSION >= 8 - rv = sLoader->LoadImage(uri, nsnull, nsnull, nsnull, loadGroup, this, -#else - rv = sLoader->LoadImage(uri, nsnull, nsnull, loadGroup, this, -#endif - nsnull, nsIRequest::LOAD_NORMAL, nsnull, - nsnull, nsnull, getter_AddRefs(mIconRequest)); - NS_ENSURE_SUCCESS(rv, rv); - - mIconRequest->RequestDecode(); - - mImageRect.SetEmpty(); - - if (domRect) { - PRInt32 bottom = GetDOMRectSide(domRect, &nsIDOMRect::GetBottom); - PRInt32 right = GetDOMRectSide(domRect, &nsIDOMRect::GetRight); - PRInt32 top = GetDOMRectSide(domRect, &nsIDOMRect::GetTop); - PRInt32 left = GetDOMRectSide(domRect, &nsIDOMRect::GetLeft); - - if (top < 0 || left < 0 || bottom <= top || right <= left) { - return NS_ERROR_FAILURE; - } - - mImageRect.SetRect(left, top, right - left, bottom - top); - } - - return NS_OK; -} - -void -uGlobalMenuIconLoader::ClearIcon() -{ - dbusmenu_menuitem_property_remove(mMenuItem->GetDbusMenuItem(), - DBUSMENU_MENUITEM_PROP_ICON_DATA); -} - -NS_IMETHODIMP -uGlobalMenuIconLoader::OnStartRequest(imgIRequest *aRequest) -{ - return NS_ERROR_NOT_IMPLEMENTED; -} - -NS_IMETHODIMP -uGlobalMenuIconLoader::OnStartDecode(imgIRequest *aRequest) -{ - return NS_ERROR_NOT_IMPLEMENTED; -} - -NS_IMETHODIMP -uGlobalMenuIconLoader::OnStartContainer(imgIRequest *aRequest, imgIContainer *aContainer) -{ - TRACE_WITH_MENUOBJECT(mMenuItem); - return NS_ERROR_NOT_IMPLEMENTED; -} - -NS_IMETHODIMP -uGlobalMenuIconLoader::OnStartFrame(imgIRequest *aRequest, PRUint32 aFrame) -{ - return NS_ERROR_NOT_IMPLEMENTED; -} - -NS_IMETHODIMP -uGlobalMenuIconLoader::OnDataAvailable(imgIRequest *aRequest, - MOZ_API_BOOL aCurrentFrame, - const nsIntRect *aRect) -{ - return NS_ERROR_NOT_IMPLEMENTED; -} - -NS_IMETHODIMP -uGlobalMenuIconLoader::OnStopFrame(imgIRequest *aRequest, PRUint32 aFrame) -{ - TRACE_WITH_MENUOBJECT(mMenuItem); - if (aRequest != mIconRequest) { - return NS_ERROR_FAILURE; - } - - if (mIconLoaded) { - DEBUG_WITH_MENUOBJECT(mMenuItem, "Icon is already loaded"); - return NS_OK; - } - - mIconLoaded = PR_TRUE; - - nsCOMPtr img; - aRequest->GetImage(getter_AddRefs(img)); - if (!img) { - NS_WARNING("Failed to get image"); - return NS_ERROR_FAILURE; - } - - PRInt32 origWidth; - PRInt32 origHeight; - img->GetWidth(&origWidth); - img->GetHeight(&origHeight); - - PRBool needsClip = PR_FALSE; - - if (!mImageRect.IsEmpty()) { - if (mImageRect.XMost() > origWidth || mImageRect.YMost() > origHeight) { - NS_WARNING("-moz-image-region is larger than image"); - return NS_ERROR_FAILURE; - } - - if (!(mImageRect.x == 0 && mImageRect.y == 0 && - mImageRect.width == origWidth && mImageRect.height == origHeight)) { - needsClip = PR_TRUE; - } - } - - if ((!needsClip && (origWidth > 100 || origHeight > 100)) || - (needsClip && (mImageRect.width > 100 || mImageRect.height > 100))) { - /* The icon data needs to go across DBus. Make sure the icon - * data isn't too large, else our connection gets terminated and - * GDbus helpfully aborts the application. Thank you :) - */ - NS_WARNING("Icon data too large"); - ClearIcon(); - return NS_OK; - } - - nsCOMPtr clippedImg; - if (needsClip) { - nsresult rv = img->ExtractFrame(0, mImageRect, 0, - getter_AddRefs(clippedImg)); - if (NS_FAILED(rv)) { - NS_WARNING("Failed to clip icon"); - return NS_ERROR_FAILURE; - } - } - - nsCOMPtr converter = - do_GetService("@mozilla.org/widget/image-to-gdk-pixbuf;1"); - NS_ASSERTION(converter, "No image converter"); - if (!converter) { - return NS_ERROR_FAILURE; - } - - GdkPixbuf *pixbuf = - converter->ConvertImageToPixbuf(clippedImg ? clippedImg : img); - if (pixbuf) { - dbusmenu_menuitem_property_set_image(mMenuItem->GetDbusMenuItem(), - DBUSMENU_MENUITEM_PROP_ICON_DATA, - pixbuf); - g_object_unref(pixbuf); - } else { - ClearIcon(); - } - - return NS_OK; -} - -NS_IMETHODIMP -uGlobalMenuIconLoader::OnStopContainer(imgIRequest *aRequest, - imgIContainer *aContainer) -{ - return NS_ERROR_NOT_IMPLEMENTED; -} - -NS_IMETHODIMP -uGlobalMenuIconLoader::OnStopDecode(imgIRequest *aRequest, nsresult status, - const PRUnichar *statusArg) -{ - TRACE_WITH_MENUOBJECT(mMenuItem); - return NS_ERROR_NOT_IMPLEMENTED; -} - -NS_IMETHODIMP -uGlobalMenuIconLoader::OnStopRequest(imgIRequest *aRequest, MOZ_API_BOOL aIsLastPart) -{ - TRACE_WITH_MENUOBJECT(mMenuItem); - - if (mIconRequest) { - mIconRequest->Cancel(NS_BINDING_ABORTED); - mIconRequest = nsnull; - } - - return NS_OK; -} - -NS_IMETHODIMP -uGlobalMenuIconLoader::OnDiscard(imgIRequest *aRequest) -{ - return NS_ERROR_NOT_IMPLEMENTED; -} - -NS_IMETHODIMP -#if MOZILLA_BRANCH_MAJOR_VERSION >= 12 -uGlobalMenuIconLoader::FrameChanged(imgIRequest *aRequest, - imgIContainer *aContainer, -#else -uGlobalMenuIconLoader::FrameChanged(imgIContainer *aContainer, -#endif - const nsIntRect *aDirtyRect) -{ - return NS_ERROR_NOT_IMPLEMENTED; -} - -#if MOZILLA_BRANCH_MAJOR_VERSION >= 11 -NS_IMETHODIMP -uGlobalMenuIconLoader::OnImageIsAnimated(imgIRequest* aRequest) -{ - return NS_OK; -} -#endif - -void -uGlobalMenuIconLoader::Destroy() -{ - TRACE_WITH_MENUOBJECT(mMenuItem); - if (mIconRequest) { - mIconRequest->Cancel(NS_BINDING_ABORTED); - mIconRequest = nsnull; - } - - mMenuItem = nsnull; -} - -void -uGlobalMenuObject::GetContent(nsIContent **_retval) -{ - if (!_retval) { - return; - } - *_retval = mContent; - NS_IF_ADDREF(*_retval); -} - -void -uGlobalMenuObject::SyncLabelFromContent(nsIContent *aContent) -{ - TRACE_WITH_THIS_MENUOBJECT(); - // Gecko stores the label and access key in separate attributes - // so we need to convert label="Foo"/accesskey="F" in to - // label="_Foo" for dbusmenu - - nsAutoString label; - if (aContent && aContent->GetAttr(kNameSpaceID_None, - uWidgetAtoms::label, label)) { - UGM_BLOCK_EVENTS_FOR_CURRENT_SCOPE(); - DEBUG_WITH_CONTENT(aContent, "Content has label \"%s\"", DEBUG_CSTR_FROM_UTF16(label)); - mContent->SetAttr(kNameSpaceID_None, uWidgetAtoms::label, label, MOZ_API_TRUE); - } else { - mContent->GetAttr(kNameSpaceID_None, uWidgetAtoms::label, label); - } - - nsAutoString accesskey; - mContent->GetAttr(kNameSpaceID_None, uWidgetAtoms::accesskey, accesskey); - - const PRUnichar *tmp = accesskey.BeginReading(); - PRUnichar keyUpper; - PRUnichar keyLower; - // XXX: I think we need to link against libxul.so to get ToLowerCase - // and ToUpperCase from nsUnicharUtils.h - nsCOMPtr converter = - do_GetService(NS_UNICHARUTIL_CONTRACTID); - if (converter) { - converter->ToUpper(*tmp, &keyUpper); - converter->ToLower(*tmp, &keyLower); - } else { - if (*tmp < 256) { - keyUpper = toupper(char(*tmp)); - keyLower = tolower(char(*tmp)); - } else { - NS_WARNING("accesskey matching is case-sensitive when it shouldn't be"); - keyUpper = *tmp; - keyLower = *tmp; - } - } - - PRUnichar *cur = label.BeginWriting(); - PRUnichar *end = label.EndWriting(); - int length = label.Length(); - int pos = 0; - PRBool foundAccessKey = PR_FALSE; - - while (cur < end) { - if (*cur != PRUnichar('_')) { - if ((*cur != keyLower && *cur != keyUpper) || foundAccessKey) { - cur++; - pos++; - continue; - } - foundAccessKey = PR_TRUE; - } - - length += 1; - label.SetLength(length); - int newLength = label.Length(); - if (length != newLength) - break; - - cur = label.BeginWriting() + pos; - end = label.EndWriting(); - memmove(cur + 1, cur, (length - 1 - pos) * sizeof(PRUnichar)); -// \^/ - *cur = PRUnichar('_'); // Yeah! -// v - - cur += 2; - pos += 2; - } - - // Ellipsize long labels. I've picked an arbitrary length here - if (length > MAX_LABEL_NCHARS) { - cur = label.BeginWriting(); - for (PRUint32 i = 1; i < 4; i++) { - *(cur + (MAX_LABEL_NCHARS - i)) = PRUnichar('.'); - } - *(cur + MAX_LABEL_NCHARS) = nsnull; - label.SetLength(MAX_LABEL_NCHARS); - } - - nsCAutoString clabel; - CopyUTF16toUTF8(label, clabel); - DEBUG_WITH_THIS_MENUOBJECT("Setting label to \"%s\"", clabel.get()); - dbusmenu_menuitem_property_set(mDbusMenuItem, - DBUSMENU_MENUITEM_PROP_LABEL, - clabel.get()); -} - -void -uGlobalMenuObject::SyncLabelFromContent() -{ - SyncLabelFromContent(nsnull); -} - -// Synchronize the 'hidden' attribute on the DOM node with the -// 'visible' property on the dbusmenu node -void -uGlobalMenuObject::SyncVisibilityFromContent() -{ - TRACE_WITH_THIS_MENUOBJECT(); - mContentVisible = !IsHidden(); - PRBool realVis = (!mMenuBar || !ShouldShowOnlyForKb() || - mMenuBar->OpenedByKeyboard()) ? - mContentVisible : PR_FALSE; - DEBUG_WITH_THIS_MENUOBJECT("Setting %s", realVis ? "visible" : "hidden"); - - dbusmenu_menuitem_property_set_bool(mDbusMenuItem, - DBUSMENU_MENUITEM_PROP_VISIBLE, - realVis); -} - -void -uGlobalMenuObject::SyncSensitivityFromContent(nsIContent *aContent) -{ - TRACE_WITH_THIS_MENUOBJECT(); - - nsIContent *content; - if (aContent) { - content = aContent; - } else { - content = mContent; - } - PRBool disabled = content->AttrValueIs(kNameSpaceID_None, - uWidgetAtoms::disabled, - uWidgetAtoms::_true, - eCaseMatters); - DEBUG_WITH_THIS_MENUOBJECT("Setting %s", disabled ? "disabled" : "enabled"); - - if (aContent) { - UGM_BLOCK_EVENTS_FOR_CURRENT_SCOPE(); - if (disabled) { - mContent->SetAttr(kNameSpaceID_None, uWidgetAtoms::disabled, - NS_LITERAL_STRING("true"), MOZ_API_TRUE); - } else { - mContent->UnsetAttr(kNameSpaceID_None, uWidgetAtoms::disabled, MOZ_API_TRUE); - } - } - - dbusmenu_menuitem_property_set_bool(mDbusMenuItem, - DBUSMENU_MENUITEM_PROP_ENABLED, - !disabled); -} - -void -uGlobalMenuObject::SyncSensitivityFromContent() -{ - SyncSensitivityFromContent(nsnull); -} - -void -uGlobalMenuObject::UpdateInfoFromContentClass() -{ - TRACE_WITH_THIS_MENUOBJECT(); - nsCOMPtr element(do_QueryInterface(mContent)); - if (!element) { - return; - } - - nsCOMPtr classes; - element->GetClassList(getter_AddRefs(classes)); - if (!classes) { - return; - } - - MOZ_API_BOOL tmp; - classes->Contains(NS_LITERAL_STRING("show-only-for-keyboard"), - &tmp); - mShowOnlyForKb = !!tmp; - - classes->Contains(NS_LITERAL_STRING("menuitem-with-favicon"), - &tmp); - mWithFavicon = !!tmp; - - DEBUG_WITH_THIS_MENUOBJECT("show-only-for-keyboard class? %s", mShowOnlyForKb ? "Yes" : "No"); - DEBUG_WITH_THIS_MENUOBJECT("menuitem-with-favicon class? %s", mWithFavicon ? "Yes" : "No"); -} - -PRBool -uGlobalMenuObject::IsHidden() -{ - return mContent->AttrValueIs(kNameSpaceID_None, uWidgetAtoms::hidden, - uWidgetAtoms::_true, eCaseMatters) || - mContent->AttrValueIs(kNameSpaceID_None, uWidgetAtoms::collapsed, - uWidgetAtoms::_true, eCaseMatters); -} - -void -uGlobalMenuObject::UpdateVisibility() -{ - TRACE_WITH_THIS_MENUOBJECT(); - if (!mMenuBar) { - return; - } - - PRBool newVis = (!ShouldShowOnlyForKb() || mMenuBar->OpenedByKeyboard()) ? - mContentVisible : PR_FALSE; - - DEBUG_WITH_THIS_MENUOBJECT("Setting %s", newVis ? "visible" : "hidden"); - dbusmenu_menuitem_property_set_bool(mDbusMenuItem, - DBUSMENU_MENUITEM_PROP_VISIBLE, - newVis); -} - -void -uGlobalMenuObject::SyncIconFromContent() -{ - TRACE_WITH_THIS_MENUOBJECT(); - if (!mIconLoader) { - mIconLoader = new uGlobalMenuIconLoader(this); - } - - mIconLoader->LoadIcon(); -} - -void -uGlobalMenuObject::DestroyIconLoader() -{ - if (mIconLoader) { - mIconLoader->Destroy(); - } -} reverted: --- firefox-11.0+build1/debian/globalmenu/components/src/uDebug.h +++ firefox-11.0+build1.orig/debian/globalmenu/components/src/uDebug.h @@ -1,187 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is globalmenu-extension. - * - * The Initial Developer of the Original Code is - * Canonical Ltd. - * Portions created by the Initial Developer are Copyright (C) 2010 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * Chris Coulson - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -#ifndef _U_DEBUG_H -#define _U_DEBUG_H - -#include -#include - -#if defined DEBUG_chrisccoulson && !defined DEBUG -#undef NS_ASSERTION -#undef NS_WARN_IF_FALSE -#undef NS_WARNING - -#define NS_ASSERTION(expr, str) \ - do { \ - if (!(expr)) { \ - NS_DebugBreak(NS_DEBUG_ASSERTION, str, #expr, __FILE__, __LINE__); \ - } \ - } while(0) - -#define NS_WARN_IF_FALSE(_expr,_msg) \ - do { \ - if (!(_expr)) { \ - NS_DebugBreak(NS_DEBUG_WARNING, _msg, #_expr, __FILE__, __LINE__); \ - } \ - } while(0) - -#define NS_WARNING(str) \ - NS_DebugBreak(NS_DEBUG_WARNING, str, nsnull, __FILE__, __LINE__) -#endif - -#ifdef DEBUG -#define DEBUG_chrisccoulson -#endif - -#ifdef DEBUG_chrisccoulson -class FunctionTracer -{ -public: - FunctionTracer(const char *funcName, const char *extra): mFuncName(funcName), mExtra(extra) - { - if (getenv("GLOBAL_MENU_VERBOSE")) { - printf("%*s=== globalmenu-extension: Entering %s [%s] ===\n", sDepth, "", mFuncName.get(), mExtra.get()); - } - sDepth++; - } - - FunctionTracer(const char *funcName): mFuncName(funcName) - { - if (getenv("GLOBAL_MENU_VERBOSE")) { - printf("%*s=== globalmenu-extension: Entering %s ===\n", sDepth, "", mFuncName.get()); - } - sDepth++; - } - - ~FunctionTracer() - { - sDepth--; - if (getenv("GLOBAL_MENU_VERBOSE")) { - if (mExtra.Length() > 0) { - printf("%*s=== globalmenu-extension: Leaving %s [%s] ===\n", sDepth, "", mFuncName.get(), mExtra.get()); - } else { - printf("%*s=== globalmenu-extension: Leaving %s ===\n", sDepth, "", mFuncName.get()); - } - } - } - - static PRUint32 sDepth; -private: - nsCString mFuncName; - nsCString mExtra; -}; - -#define DEBUG_WITH_THIS_MENUOBJECT(format...) \ - DEBUG_WITH_MENUOBJECT(this, format) - -#define DEBUG_WITH_MENUOBJECT(object, format...) \ - if (getenv("GLOBAL_MENU_VERBOSE")) { \ - nsCOMPtr content; \ - if (object) object->GetContent(getter_AddRefs(content)); \ - nsAutoString id; \ - nsCAutoString cid; \ - if (content) content->GetAttr(kNameSpaceID_None, uWidgetAtoms::id, id); \ - CopyUTF16toUTF8(id, cid); \ - char *str; \ - asprintf(&str, format); \ - printf("%*s* globalmenu-extension %s: %s [menuobject: %p (id: %s)] [this: %p]\n", FunctionTracer::sDepth, "", __PRETTY_FUNCTION__, str, object, cid.get(), this); \ - free(str); \ - } - -#define DEBUG_WITH_CONTENT(content, format...) \ - if (getenv("GLOBAL_MENU_VERBOSE")) { \ - nsAutoString id; \ - nsCAutoString cid; \ - if (content) content->GetAttr(kNameSpaceID_None, uWidgetAtoms::id, id); \ - CopyUTF16toUTF8(id, cid); \ - char *str; \ - asprintf(&str, format); \ - printf("%*s* globalmenu-extension %s: %s [content: %p (id: %s)] [this: %p]\n", FunctionTracer::sDepth, "", __PRETTY_FUNCTION__, str, content, cid.get(), this); \ - free(str); \ - } - -#define DEBUG_CSTR_FROM_UTF16(str) __extension__({ \ - nsCAutoString cstr; \ - CopyUTF16toUTF8(str, cstr); \ - cstr.get(); \ -}) - -#define TRACE_WITH_THIS_MENUOBJECT() \ - TRACE_WITH_MENUOBJECT(this) - -#define TRACE_WITH_MENUOBJECT(object) \ - char *_id_s; \ - { \ - nsCOMPtr content; \ - if (object) object->GetContent(getter_AddRefs(content)); \ - nsAutoString _id; \ - if (content) content->GetAttr(kNameSpaceID_None, uWidgetAtoms::id, _id); \ - nsCAutoString _cid; \ - CopyUTF16toUTF8(_id, _cid); \ - asprintf(&_id_s, "menuobject: %p (id: %s)", object, _cid.get()); \ - } \ - FunctionTracer _marker(__PRETTY_FUNCTION__, _id_s); \ - free(_id_s); - -#define TRACE_WITH_CONTENT(content) \ - char *_id_s; \ - { \ - nsAutoString _id; \ - content->GetAttr(kNameSpaceID_None, uWidgetAtoms::id, _id); \ - nsCAutoString _cid; \ - CopyUTF16toUTF8(_id, _cid); \ - asprintf(&_id_s, "id: %s", _cid.get()); \ - } \ - FunctionTracer _marker(__PRETTY_FUNCTION__, _id_s); \ - free(_id_s); - -#define TRACE() \ - FunctionTracer _marker(__PRETTY_FUNCTION__); -#else -#define DEBUG_WITH_THIS_MENUOBJECT(format...) -#define DEBUG_WITH_MENUOBJECT(object, format...) -#define DEBUG_WITH_CONTENT(content, format...) -#define DEBUG_CSTR_FROM_UTF16(str) -#define TRACE_WITH_THIS_MENUOBJECT() -#define TRACE_WITH_MENUOBJECT(object) -#define TRACE_WITH_CONTENT(content) -#define TRACE() -#endif - -#endif reverted: --- firefox-11.0+build1/debian/globalmenu/components/src/uWidgetAtomList.h +++ firefox-11.0+build1.orig/debian/globalmenu/components/src/uWidgetAtomList.h @@ -1,65 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is mozilla.org code. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 1999 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * Original Author: Mike Pinkerton (pinkerton@netscape.com) - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -WIDGET_ATOM(accesskey, "accesskey") -WIDGET_ATOM(autocheck, "autocheck") -WIDGET_ATOM(checkbox, "checkbox") -WIDGET_ATOM(checked, "checked") -WIDGET_ATOM(_class, "class") -WIDGET_ATOM(collapsed, "collapsed") -WIDGET_ATOM(command, "command") -WIDGET_ATOM(disabled, "disabled") -WIDGET_ATOM(_false, "false") -WIDGET_ATOM(hidden, "hidden") -WIDGET_ATOM(id, "id") -WIDGET_ATOM(image, "image") -WIDGET_ATOM(key, "key") -WIDGET_ATOM(keycode, "keycode") -WIDGET_ATOM(label, "label") -WIDGET_ATOM(menu, "menu") -WIDGET_ATOM(menuactive, "_moz-menuactive") -WIDGET_ATOM(menuitem, "menuitem") -WIDGET_ATOM(menupopup, "menupopup") -WIDGET_ATOM(menuseparator, "menuseparator") -WIDGET_ATOM(modifiers, "modifiers") -WIDGET_ATOM(name, "name") -WIDGET_ATOM(open, "open") -WIDGET_ATOM(radio, "radio") -WIDGET_ATOM(toolbarspring, "toolbarspring") -WIDGET_ATOM(_true, "true") -WIDGET_ATOM(type, "type") reverted: --- firefox-11.0+build1/debian/globalmenu/components/src/uGlobalMenu.cpp +++ firefox-11.0+build1.orig/debian/globalmenu/components/src/uGlobalMenu.cpp @@ -1,762 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is globalmenu-extension. - * - * The Initial Developer of the Original Code is - * Canonical Ltd. - * Portions created by the Initial Developer are Copyright (C) 2010 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * Chris Coulson - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -#include "uGlobalMenu.h" -#include "uGlobalMenuBar.h" -#include "uGlobalMenuUtils.h" -#include "uWidgetAtoms.h" - -#include "uDebug.h" -#include "compat.h" - -/*static*/ PRBool -uGlobalMenu::MenuEventCallback(DbusmenuMenuitem *menu, - const gchar *name, - GVariant *value, - guint timestamp, - void *data) -{ - uGlobalMenu *self = static_cast(data); - if (!g_strcmp0("closed", name)) { - self->OnClose(); - return PR_TRUE; - } - - if (!g_strcmp0("opened", name)) { - self->OnOpen(); - return PR_TRUE; - } - - return PR_FALSE; -} - -/*static*/ PRBool -uGlobalMenu::MenuAboutToOpenCallback(DbusmenuMenuitem *menu, - void *data) -{ - uGlobalMenu *self = static_cast(data); - self->AboutToOpen(); - - // We return false here for "needsUpdate", as we have no way of - // knowing in advance if the menu structure is going to be updated. - // The menu layout will still update on the client, but we won't block - // opening the menu until it's happened - return PR_FALSE; -} - -void -uGlobalMenu::Activate() -{ - mContent->SetAttr(kNameSpaceID_None, uWidgetAtoms::menuactive, - NS_LITERAL_STRING("true"), MOZ_API_TRUE); - - nsCOMPtr target = do_QueryInterface(mContent); - if (target) { -#if MOZILLA_BRANCH_MAJOR_VERSION >= 10 - nsCOMPtr domDoc = do_QueryInterface(mContent->OwnerDoc()); -#else - nsCOMPtr domDoc = do_QueryInterface(mContent->GetOwnerDoc()); -#endif - if (domDoc) { - nsCOMPtr event; - domDoc->CreateEvent(NS_LITERAL_STRING("Events"), - getter_AddRefs(event)); - if (event) { - event->InitEvent(NS_LITERAL_STRING("DOMMenuItemActive"), - MOZ_API_TRUE, MOZ_API_TRUE); - nsCOMPtr priv = do_QueryInterface(event); - if (priv) { - priv->SetTrusted(MOZ_API_TRUE); - } - MOZ_API_BOOL dummy; - target->DispatchEvent(event, &dummy); - } - } - } -} - -void -uGlobalMenu::Deactivate() -{ - mContent->UnsetAttr(kNameSpaceID_None, uWidgetAtoms::menuactive, MOZ_API_TRUE); - -#if MOZILLA_BRANCH_MAJOR_VERSION >= 10 - nsCOMPtr domDoc = do_QueryInterface(mContent->OwnerDoc()); -#else - nsCOMPtr domDoc = do_QueryInterface(mContent->GetOwnerDoc()); -#endif - if (domDoc) { - nsCOMPtr event; - domDoc->CreateEvent(NS_LITERAL_STRING("Events"), - getter_AddRefs(event)); - if (event) { - event->InitEvent(NS_LITERAL_STRING("DOMMenuItemInactive"), - MOZ_API_TRUE, MOZ_API_TRUE); - nsCOMPtr target = do_QueryInterface(mContent); - if (target) { - nsCOMPtr priv = do_QueryInterface(event); - if (priv) { - priv->SetTrusted(MOZ_API_TRUE); - } - MOZ_API_BOOL dummy; - target->DispatchEvent(event, &dummy); - } - } - } -} - -PRBool -uGlobalMenu::CanOpen() -{ - PRBool isHidden = IsHidden(); - PRBool isDisabled = mContent->AttrValueIs(kNameSpaceID_None, - uWidgetAtoms::disabled, - uWidgetAtoms::_true, - eCaseMatters); - - return (!isHidden && !isDisabled); -} - -void -uGlobalMenu::AboutToOpen() -{ - TRACE_WITH_THIS_MENUOBJECT(); - // XXX: HACK, HACK, HACK ALERT!! - // We ignore the first AboutToOpen on top-level menus, because Unity - // stupidly sends this signal on all top-levels when the window opens. - // This isn't useful at all for us, and leaves the menu in a partially - // open state (it doesn't finish the job by sending open/close events), - // where we sit unnecessarily keeping our menu in-sync with the DOM - // (we do think it is in the middle of opening, after all) until after - // the menu is first opened, when sanity returns again - // YUCK! - if (!mPrimed) { - DEBUG_WITH_THIS_MENUOBJECT("Ignoring first AboutToOpen"); - mPrimed = PR_TRUE; - return; - } - - mOpening = PR_TRUE; - - if (DoesNeedRebuild()) { - Build(); - } - - // If there is no popup content, then there is nothing to do, and it's - // unsafe to proceed anyway - if (!mPopupContent) { - DEBUG_WITH_THIS_MENUOBJECT("Menu has no popup content"); - mOpening = PR_FALSE; - return; - } - - PRUint32 count = mMenuObjects.Length(); - for (PRUint32 i = 0; i < count; i++) { - mMenuObjects[i]->AboutToShowNotify(); - } - - // XXX: This should happen when the pointer hovers over the menu entry, - // but we don't have that information right now. We synthesize it for - // menus, but this doesn't work for menuitems at all - Activate(); - -#if MOZILLA_BRANCH_MAJOR_VERSION >= 10 - nsCOMPtr domDoc = do_QueryInterface(mPopupContent->OwnerDoc()); -#else - nsCOMPtr domDoc = do_QueryInterface(mPopupContent->GetOwnerDoc()); -#endif - if (domDoc) { - nsCOMPtr event; - domDoc->CreateEvent(NS_LITERAL_STRING("mouseevent"), - getter_AddRefs(event)); - if (event) { - nsCOMPtr mouseEvent = do_QueryInterface(event); - if (mouseEvent) { - nsCOMPtr window; - domDoc->GetDefaultView(getter_AddRefs(window)); - if (window) { - mouseEvent->InitMouseEvent(NS_LITERAL_STRING("popupshowing"), - MOZ_API_TRUE, MOZ_API_TRUE, window, nsnull, - 0, 0, 0, 0, MOZ_API_FALSE, MOZ_API_FALSE, - MOZ_API_FALSE, MOZ_API_FALSE, 0, nsnull); - nsCOMPtr target = do_QueryInterface(mPopupContent); - if (target) { - nsCOMPtr priv = do_QueryInterface(event); - if (priv) { - priv->SetTrusted(MOZ_API_TRUE); - } - MOZ_API_BOOL dummy; - // XXX: dummy == PR_FALSE means that we should prevent the - // the menu from opening, but there's no way to do this - target->DispatchEvent(event, &dummy); - } - } - } - } - } - - nsCOMPtr os = - do_GetService("@mozilla.org/observer-service;1"); - if (os) { - nsAutoString popupID; - mPopupContent->GetAttr(kNameSpaceID_None, uWidgetAtoms::id, popupID); - os->NotifyObservers(nsnull, "native-menu-service:popup-open", popupID.get()); - } -} - -void -uGlobalMenu::OnOpen() -{ - if (!mOpening) { - AboutToOpen(); - } - - // If there is no popup content, then there is nothing to do, and it's - // unsafe to proceed anyway - if (!mPopupContent) { - mOpening = PR_FALSE; - return; - } - - mContent->SetAttr(kNameSpaceID_None, uWidgetAtoms::open, NS_LITERAL_STRING("true"), MOZ_API_TRUE); - -#if MOZILLA_BRANCH_MAJOR_VERSION >= 10 - nsCOMPtr domDoc = do_QueryInterface(mPopupContent->OwnerDoc()); -#else - nsCOMPtr domDoc = do_QueryInterface(mPopupContent->GetOwnerDoc()); -#endif - if (domDoc) { - nsCOMPtr event; - domDoc->CreateEvent(NS_LITERAL_STRING("mouseevent"), - getter_AddRefs(event)); - if (event) { - nsCOMPtr mouseEvent = do_QueryInterface(event); - if (mouseEvent) { - nsCOMPtr window; - domDoc->GetDefaultView(getter_AddRefs(window)); - if (window) { - mouseEvent->InitMouseEvent(NS_LITERAL_STRING("popupshown"), - MOZ_API_TRUE, MOZ_API_TRUE, window, nsnull, - 0, 0, 0, 0, MOZ_API_FALSE, MOZ_API_FALSE, - MOZ_API_FALSE, MOZ_API_FALSE, 0, nsnull); - nsCOMPtr target = do_QueryInterface(mPopupContent); - if (target) { - nsCOMPtr priv = do_QueryInterface(event); - if (priv) { - priv->SetTrusted(MOZ_API_TRUE); - } - MOZ_API_BOOL dummy; - target->DispatchEvent(event, &dummy); - } - } - } - } - } - - mOpening = PR_FALSE; -} - -void -uGlobalMenu::OnClose() -{ - mOpening = PR_FALSE; - // If there is no popup content, then there is nothing to do, and it's - // unsafe to proceed anyway - if (!mPopupContent) { - return; - } - - mContent->UnsetAttr(kNameSpaceID_None, uWidgetAtoms::open, MOZ_API_TRUE); - -#if MOZILLA_BRANCH_MAJOR_VERSION >= 10 - nsCOMPtr domDoc = do_QueryInterface(mPopupContent->OwnerDoc()); -#else - nsCOMPtr domDoc = do_QueryInterface(mPopupContent->GetOwnerDoc()); -#endif - if (domDoc) { - nsCOMPtr event; - domDoc->CreateEvent(NS_LITERAL_STRING("mouseevent"), - getter_AddRefs(event)); - if (event) { - nsCOMPtr mouseEvent = do_QueryInterface(event); - if (mouseEvent) { - nsCOMPtr window; - domDoc->GetDefaultView(getter_AddRefs(window)); - if (window) { - mouseEvent->InitMouseEvent(NS_LITERAL_STRING("popuphiding"), - MOZ_API_TRUE, MOZ_API_TRUE, window, nsnull, - 0, 0, 0, 0, MOZ_API_FALSE, MOZ_API_FALSE, - MOZ_API_FALSE, MOZ_API_FALSE, 0, nsnull); - nsCOMPtr target = do_QueryInterface(mPopupContent); - if (target) { - nsCOMPtr priv = do_QueryInterface(event); - if (priv) { - priv->SetTrusted(MOZ_API_TRUE); - } - MOZ_API_BOOL dummy; - target->DispatchEvent(event, &dummy); - mouseEvent->InitMouseEvent(NS_LITERAL_STRING("popuphidden"), - MOZ_API_TRUE, MOZ_API_TRUE, window, nsnull, - 0, 0, 0, 0, MOZ_API_FALSE, MOZ_API_FALSE, - MOZ_API_FALSE, MOZ_API_FALSE, 0, nsnull); - target->DispatchEvent(event, &dummy); - } - } - } - } - } - - Deactivate(); -} - -void -uGlobalMenu::SyncProperties() -{ - TRACE_WITH_THIS_MENUOBJECT(); - - UpdateInfoFromContentClass(); - SyncLabelFromContent(); - SyncSensitivityFromContent(); - SyncVisibilityFromContent(); - SyncIconFromContent(); - - ClearInvalid(); -} - -nsresult -uGlobalMenu::ConstructDbusMenuItem() -{ - mDbusMenuItem = dbusmenu_menuitem_new(); - if (!mDbusMenuItem) - return NS_ERROR_OUT_OF_MEMORY; - - // This happens automatically when we add children, but we have to - // do this manually for menus which don't initially have children, - // so we can receive about-to-show which triggers a build of the menu - dbusmenu_menuitem_property_set(mDbusMenuItem, - DBUSMENU_MENUITEM_PROP_CHILD_DISPLAY, - DBUSMENU_MENUITEM_CHILD_DISPLAY_SUBMENU); - - mOpenHandlerID = g_signal_connect(G_OBJECT(mDbusMenuItem), - "about-to-show", - G_CALLBACK(MenuAboutToOpenCallback), - this); - mEventHandlerID = g_signal_connect(G_OBJECT(mDbusMenuItem), - "event", - G_CALLBACK(MenuEventCallback), - this); - - SyncProperties(); - - return NS_OK; -} - -void -uGlobalMenu::GetMenuPopupFromMenu(nsIContent **aResult) -{ - if (!aResult) - return; - - *aResult = nsnull; - - // Taken from widget/src/cocoa/nsMenuX.mm. Not sure if we need this - nsresult rv; - nsCOMPtr xblService = do_GetService("@mozilla.org/xbl;1", &rv); - if (!xblService) - return; - - PRInt32 dummy; - nsCOMPtr tag; - xblService->ResolveTag(mContent, &dummy, getter_AddRefs(tag)); - if (tag == uWidgetAtoms::menupopup) { - *aResult = mContent; - NS_ADDREF(*aResult); - return; - } - - PRUint32 count = mContent->GetChildCount(); - - for (PRUint32 i = 0; i < count; i++) { - PRInt32 dummy; - nsIContent *child = mContent->GetChildAt(i); - nsCOMPtr tag; - xblService->ResolveTag(child, &dummy, getter_AddRefs(tag)); - if (tag == uWidgetAtoms::menupopup) { - *aResult = child; - NS_ADDREF(*aResult); - return; - } - } -} - -PRBool -uGlobalMenu::InsertMenuObjectAt(uGlobalMenuObject *menuObj, - PRUint32 index) -{ - gboolean res = dbusmenu_menuitem_child_add_position(mDbusMenuItem, - menuObj->GetDbusMenuItem(), - index); - return res && mMenuObjects.InsertElementAt(index, menuObj); -} - -PRBool -uGlobalMenu::AppendMenuObject(uGlobalMenuObject *menuObj) -{ - gboolean res = dbusmenu_menuitem_child_append(mDbusMenuItem, - menuObj->GetDbusMenuItem()); - return res && mMenuObjects.AppendElement(menuObj); -} - -PRBool -uGlobalMenu::RemoveMenuObjectAt(PRUint32 index) -{ - NS_ASSERTION(index < mMenuObjects.Length(), "Invalid index"); - if (index >= mMenuObjects.Length()) { - return PR_FALSE; - } - - gboolean res = dbusmenu_menuitem_child_delete(mDbusMenuItem, - mMenuObjects[index]->GetDbusMenuItem()); - mMenuObjects.RemoveElementAt(index); - - return !!res; -} - -nsresult -uGlobalMenu::Build() -{ - TRACE_WITH_THIS_MENUOBJECT(); - - PRUint32 count = mMenuObjects.Length(); - for (PRUint32 i = 0; i < count; i++) { - RemoveMenuObjectAt(0); - } - - if (mPopupContent && mPopupContent != mContent) { - mListener->UnregisterForContentChanges(mPopupContent, this); - } - - GetMenuPopupFromMenu(getter_AddRefs(mPopupContent)); - - if (!mPopupContent) { - // The menu has no popup, so there are no menuitems here - return NS_OK; - } - - // Manually wrap the menupopup node to make sure it's bounded - // Borrowed from widget/src/cocoa/nsMenuX.mm, we need this to make - // some menus in Thunderbird work - nsIDocument *doc = mPopupContent->GetCurrentDoc(); - if (doc) { - nsresult rv; - nsCOMPtr xpconnect = - do_GetService(nsIXPConnect::GetCID(), &rv); - if (NS_SUCCEEDED(rv)) { - nsIScriptGlobalObject *sgo = doc->GetScriptGlobalObject(); - nsCOMPtr scriptContext = sgo->GetContext(); - JSObject *global = sgo->GetGlobalJSObject(); - if (scriptContext && global) { - JSContext *cx = (JSContext *)scriptContext->GetNativeContext(); - if (cx) { - nsCOMPtr wrapper; - xpconnect->WrapNative(cx, global, - mPopupContent, NS_GET_IID(nsISupports), - getter_AddRefs(wrapper)); - } - } - } - } - - if (mContent != mPopupContent) { - nsresult rv = mListener->RegisterForContentChanges(mPopupContent, this); - NS_ENSURE_SUCCESS(rv, rv); - } - - ClearNeedsRebuild(); - - count = mPopupContent->GetChildCount(); - - for (PRUint32 i = 0; i < count; i++) { - nsIContent *child = mPopupContent->GetChildAt(i); - uGlobalMenuObject *menuObject = - NewGlobalMenuItem(static_cast(this), - mListener, child, mMenuBar); - PRBool res = PR_FALSE; - if (menuObject) { - res = AppendMenuObject(menuObject); - } - NS_WARN_IF_FALSE(res, "Failed to append menuitem. Marking menu invalid"); - if (!res) { - SetNeedsRebuild(); - return NS_ERROR_FAILURE; - } - } - - return NS_OK; -} - -nsresult -uGlobalMenu::Init(uGlobalMenuObject *aParent, - uGlobalMenuDocListener *aListener, - nsIContent *aContent, - uGlobalMenuBar *aMenuBar) -{ - NS_ENSURE_ARG(aParent); - NS_ENSURE_ARG(aListener); - NS_ENSURE_ARG(aContent); - NS_ENSURE_ARG(aMenuBar); - - mParent = aParent; - mListener = aListener; - mContent = aContent; - mMenuBar = aMenuBar; - - // See the hack comment above for why this workaround is here - if (mParent->GetType() != MenuBar || mMenuBar->IsRegistered()) { - mPrimed = PR_TRUE; - } - - nsresult rv = mListener->RegisterForContentChanges(mContent, this); - NS_ENSURE_SUCCESS(rv, rv); - - return ConstructDbusMenuItem(); -} - -uGlobalMenu::uGlobalMenu(): - uGlobalMenuObject(Menu), mOpening(PR_FALSE), mNeedsRebuild(PR_TRUE), - mPrimed(PR_FALSE) -{ - MOZ_COUNT_CTOR(uGlobalMenu); -} - -uGlobalMenu::~uGlobalMenu() -{ - if (mListener) { - mListener->UnregisterForContentChanges(mContent, this); - if (mPopupContent && mContent != mPopupContent) { - mListener->UnregisterForContentChanges(mPopupContent, this); - } - } - - DestroyIconLoader(); - - if (mDbusMenuItem) { - g_signal_handler_disconnect(mDbusMenuItem, mOpenHandlerID); - g_signal_handler_disconnect(mDbusMenuItem, mEventHandlerID); - g_object_unref(mDbusMenuItem); - } - - MOZ_COUNT_DTOR(uGlobalMenu); -} - -/*static*/ uGlobalMenuObject* -uGlobalMenu::Create(uGlobalMenuObject *aParent, - uGlobalMenuDocListener *aListener, - nsIContent *aContent, - uGlobalMenuBar *aMenuBar) -{ - TRACE_WITH_CONTENT(aContent); - - uGlobalMenu *menu = new uGlobalMenu(); - if (!menu) { - return nsnull; - } - - if (NS_FAILED(menu->Init(aParent, aListener, aContent, aMenuBar))) { - delete menu; - return nsnull; - } - - return static_cast(menu); -} - -void -uGlobalMenu::AboutToShowNotify() -{ - TRACE_WITH_THIS_MENUOBJECT(); - - if (IsDirty()) { - SyncProperties(); - } else { - UpdateVisibility(); - } -} - -void -uGlobalMenu::OpenMenu() -{ - if (!CanOpen()) { - return; - } - - dbusmenu_menuitem_show_to_user(mDbusMenuItem, 0); -} - -void -uGlobalMenu::ObserveAttributeChanged(nsIDocument *aDocument, - nsIContent *aContent, - nsIAtom *aAttribute) -{ - TRACE_WITH_THIS_MENUOBJECT(); - NS_ASSERTION(aContent == mContent || aContent == mPopupContent, - "Received an event that wasn't meant for us!"); - - if (IsDirty()) { - DEBUG_WITH_THIS_MENUOBJECT("Previously marked as invalid"); - return; - } - - if (mParent->GetType() == Menu && - !(static_cast(mParent))->IsOpening()) { - DEBUG_WITH_THIS_MENUOBJECT("Parent isn't opening. Marking invalid"); - Invalidate(); - return; - } - - if (aAttribute == uWidgetAtoms::open) { - return; - } - - if (aAttribute == uWidgetAtoms::disabled) { - SyncSensitivityFromContent(); - } else if (aAttribute == uWidgetAtoms::hidden || - aAttribute == uWidgetAtoms::collapsed) { - SyncVisibilityFromContent(); - } else if (aAttribute == uWidgetAtoms::label || - aAttribute == uWidgetAtoms::accesskey) { - SyncLabelFromContent(); - } else if (aAttribute == uWidgetAtoms::image) { - SyncIconFromContent(); - } else if (aAttribute == uWidgetAtoms::_class) { - UpdateInfoFromContentClass(); - SyncVisibilityFromContent(); - SyncIconFromContent(); - } -} - -void -uGlobalMenu::ObserveContentRemoved(nsIDocument *aDocument, - nsIContent *aContainer, - nsIContent *aChild, - PRInt32 aIndexInContainer) -{ - TRACE_WITH_THIS_MENUOBJECT(); - NS_ASSERTION(aContainer == mContent || aContainer == mPopupContent, - "Received an event that wasn't meant for us!"); - - if (DoesNeedRebuild()) { - DEBUG_WITH_THIS_MENUOBJECT("Previously marked as needing a rebuild"); - return; - } - - if (!IsOpening()) { - DEBUG_WITH_THIS_MENUOBJECT("Parent not opening - Marking as needing a rebuild"); - SetNeedsRebuild(); - return; - } - - if (aContainer == mPopupContent) { - PRBool res = RemoveMenuObjectAt(aIndexInContainer); - NS_WARN_IF_FALSE(res, "Failed to remove menuitem. Marking menu invalid"); - if (!res) { - SetNeedsRebuild(); - } - } else { - Build(); - } -} - -void -uGlobalMenu::ObserveContentInserted(nsIDocument *aDocument, - nsIContent *aContainer, - nsIContent *aChild, - PRInt32 aIndexInContainer) -{ - TRACE_WITH_THIS_MENUOBJECT(); - NS_ASSERTION(aContainer == mContent || aContainer == mPopupContent, - "Received an event that wasn't meant for us!"); - - if (DoesNeedRebuild()) { - DEBUG_WITH_THIS_MENUOBJECT("Previously marked as needing a rebuild"); - return; - } - - if (!IsOpening()) { - DEBUG_WITH_THIS_MENUOBJECT("Parent not opening - Marking as needing a rebuild"); - SetNeedsRebuild(); - return; - } - - if (aContainer == mPopupContent) { - uGlobalMenuObject *newItem = - NewGlobalMenuItem(static_cast(this), - mListener, aChild, mMenuBar); - PRBool res = PR_FALSE; - if (newItem) { - res = InsertMenuObjectAt(newItem, aIndexInContainer); - } - NS_WARN_IF_FALSE(res, "Failed to insert menuitem. Marking menu invalid"); - if (!res) { - SetNeedsRebuild(); - } - } else { - Build(); - } -} reverted: --- firefox-11.0+build1/debian/globalmenu/components/src/uGlobalMenuItem.cpp +++ firefox-11.0+build1.orig/debian/globalmenu/components/src/uGlobalMenuItem.cpp @@ -1,843 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is globalmenu-extension. - * - * The Initial Developer of the Original Code is - * Canonical Ltd. - * Portions created by the Initial Developer are Copyright (C) 2010 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * Chris Coulson - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include - -#include "uGlobalMenuItem.h" -#include "uGlobalMenuBar.h" -#include "uGlobalMenu.h" -#include "uWidgetAtoms.h" - -#include "uDebug.h" -#include "compat.h" - -// XXX: Borrowed from content/xbl/src/nsXBLPrototypeHandler.cpp. This doesn't -// seem to be publicly available, and we need a way to map key names -// to key codes (so we can then map them to GDK key codes) - -struct keyCodeData { - const char* str; - size_t strlength; - PRUint32 keycode; -}; - -// All of these must be uppercase, since the function below does -// case-insensitive comparison by converting to uppercase. -// XXX: be sure to check this periodically for new symbol additions! -static struct keyCodeData gKeyCodes[] = { - -#define KEYCODE_ENTRY(str) {#str, sizeof(#str) - 1, nsIDOMKeyEvent::DOM_##str} - - KEYCODE_ENTRY(VK_CANCEL), - KEYCODE_ENTRY(VK_BACK_SPACE), - KEYCODE_ENTRY(VK_TAB), - KEYCODE_ENTRY(VK_CLEAR), - KEYCODE_ENTRY(VK_RETURN), - KEYCODE_ENTRY(VK_ENTER), - KEYCODE_ENTRY(VK_SHIFT), - KEYCODE_ENTRY(VK_CONTROL), - KEYCODE_ENTRY(VK_ALT), - KEYCODE_ENTRY(VK_PAUSE), - KEYCODE_ENTRY(VK_CAPS_LOCK), - KEYCODE_ENTRY(VK_ESCAPE), - KEYCODE_ENTRY(VK_SPACE), - KEYCODE_ENTRY(VK_PAGE_UP), - KEYCODE_ENTRY(VK_PAGE_DOWN), - KEYCODE_ENTRY(VK_END), - KEYCODE_ENTRY(VK_HOME), - KEYCODE_ENTRY(VK_LEFT), - KEYCODE_ENTRY(VK_UP), - KEYCODE_ENTRY(VK_RIGHT), - KEYCODE_ENTRY(VK_DOWN), - KEYCODE_ENTRY(VK_PRINTSCREEN), - KEYCODE_ENTRY(VK_INSERT), - KEYCODE_ENTRY(VK_HELP), - KEYCODE_ENTRY(VK_DELETE), - KEYCODE_ENTRY(VK_0), - KEYCODE_ENTRY(VK_1), - KEYCODE_ENTRY(VK_2), - KEYCODE_ENTRY(VK_3), - KEYCODE_ENTRY(VK_4), - KEYCODE_ENTRY(VK_5), - KEYCODE_ENTRY(VK_6), - KEYCODE_ENTRY(VK_7), - KEYCODE_ENTRY(VK_8), - KEYCODE_ENTRY(VK_9), - KEYCODE_ENTRY(VK_SEMICOLON), - KEYCODE_ENTRY(VK_EQUALS), - KEYCODE_ENTRY(VK_A), - KEYCODE_ENTRY(VK_B), - KEYCODE_ENTRY(VK_C), - KEYCODE_ENTRY(VK_D), - KEYCODE_ENTRY(VK_E), - KEYCODE_ENTRY(VK_F), - KEYCODE_ENTRY(VK_G), - KEYCODE_ENTRY(VK_H), - KEYCODE_ENTRY(VK_I), - KEYCODE_ENTRY(VK_J), - KEYCODE_ENTRY(VK_K), - KEYCODE_ENTRY(VK_L), - KEYCODE_ENTRY(VK_M), - KEYCODE_ENTRY(VK_N), - KEYCODE_ENTRY(VK_O), - KEYCODE_ENTRY(VK_P), - KEYCODE_ENTRY(VK_Q), - KEYCODE_ENTRY(VK_R), - KEYCODE_ENTRY(VK_S), - KEYCODE_ENTRY(VK_T), - KEYCODE_ENTRY(VK_U), - KEYCODE_ENTRY(VK_V), - KEYCODE_ENTRY(VK_W), - KEYCODE_ENTRY(VK_X), - KEYCODE_ENTRY(VK_Y), - KEYCODE_ENTRY(VK_Z), - KEYCODE_ENTRY(VK_NUMPAD0), - KEYCODE_ENTRY(VK_NUMPAD1), - KEYCODE_ENTRY(VK_NUMPAD2), - KEYCODE_ENTRY(VK_NUMPAD3), - KEYCODE_ENTRY(VK_NUMPAD4), - KEYCODE_ENTRY(VK_NUMPAD5), - KEYCODE_ENTRY(VK_NUMPAD6), - KEYCODE_ENTRY(VK_NUMPAD7), - KEYCODE_ENTRY(VK_NUMPAD8), - KEYCODE_ENTRY(VK_NUMPAD9), - KEYCODE_ENTRY(VK_MULTIPLY), - KEYCODE_ENTRY(VK_ADD), - KEYCODE_ENTRY(VK_SEPARATOR), - KEYCODE_ENTRY(VK_SUBTRACT), - KEYCODE_ENTRY(VK_DECIMAL), - KEYCODE_ENTRY(VK_DIVIDE), - KEYCODE_ENTRY(VK_F1), - KEYCODE_ENTRY(VK_F2), - KEYCODE_ENTRY(VK_F3), - KEYCODE_ENTRY(VK_F4), - KEYCODE_ENTRY(VK_F5), - KEYCODE_ENTRY(VK_F6), - KEYCODE_ENTRY(VK_F7), - KEYCODE_ENTRY(VK_F8), - KEYCODE_ENTRY(VK_F9), - KEYCODE_ENTRY(VK_F10), - KEYCODE_ENTRY(VK_F11), - KEYCODE_ENTRY(VK_F12), - KEYCODE_ENTRY(VK_F13), - KEYCODE_ENTRY(VK_F14), - KEYCODE_ENTRY(VK_F15), - KEYCODE_ENTRY(VK_F16), - KEYCODE_ENTRY(VK_F17), - KEYCODE_ENTRY(VK_F18), - KEYCODE_ENTRY(VK_F19), - KEYCODE_ENTRY(VK_F20), - KEYCODE_ENTRY(VK_F21), - KEYCODE_ENTRY(VK_F22), - KEYCODE_ENTRY(VK_F23), - KEYCODE_ENTRY(VK_F24), - KEYCODE_ENTRY(VK_NUM_LOCK), - KEYCODE_ENTRY(VK_SCROLL_LOCK), - KEYCODE_ENTRY(VK_COMMA), - KEYCODE_ENTRY(VK_PERIOD), - KEYCODE_ENTRY(VK_SLASH), - KEYCODE_ENTRY(VK_BACK_QUOTE), - KEYCODE_ENTRY(VK_OPEN_BRACKET), - KEYCODE_ENTRY(VK_BACK_SLASH), - KEYCODE_ENTRY(VK_CLOSE_BRACKET), - KEYCODE_ENTRY(VK_QUOTE) - -#undef KEYCODE_ENTRY -}; - -PRUint32 -uGlobalMenuItem::GetKeyCode(nsAString &aKeyName) -{ - nsCAutoString keyName; - CopyUTF16toUTF8(aKeyName, keyName); - ToUpperCase(keyName); // We want case-insensitive comparison with data - // stored as uppercase. - - PRUint32 keyNameLength = keyName.Length(); - const char* keyNameStr = keyName.get(); - for (PRUint16 i = 0; i < (sizeof(gKeyCodes) / sizeof(gKeyCodes[0])); ++i) - if (keyNameLength == gKeyCodes[i].strlength && - !strcmp(gKeyCodes[i].str, keyNameStr)) - return gKeyCodes[i].keycode; - - return 0; -} - -// XXX: Borrowed from widget/src/gtk2/nsGtkKeyUtils.cpp -struct nsKeyConverter { - int vkCode; // Platform independent key code - int keysym; // GDK keysym key code -}; - -// -// Netscape keycodes are defined in widget/public/nsGUIEvent.h -// GTK keycodes are defined in -// -static struct nsKeyConverter nsKeycodes[] = { - { nsIDOMKeyEvent::DOM_VK_CANCEL, GDK_Cancel }, - { nsIDOMKeyEvent::DOM_VK_BACK_SPACE, GDK_BackSpace }, - { nsIDOMKeyEvent::DOM_VK_TAB, GDK_Tab }, - { nsIDOMKeyEvent::DOM_VK_TAB, GDK_ISO_Left_Tab }, - { nsIDOMKeyEvent::DOM_VK_CLEAR, GDK_Clear }, - { nsIDOMKeyEvent::DOM_VK_RETURN, GDK_Return }, - { nsIDOMKeyEvent::DOM_VK_SHIFT, GDK_Shift_L }, - { nsIDOMKeyEvent::DOM_VK_SHIFT, GDK_Shift_R }, - { nsIDOMKeyEvent::DOM_VK_CONTROL, GDK_Control_L }, - { nsIDOMKeyEvent::DOM_VK_CONTROL, GDK_Control_R }, - { nsIDOMKeyEvent::DOM_VK_ALT, GDK_Alt_L }, - { nsIDOMKeyEvent::DOM_VK_ALT, GDK_Alt_R }, - { nsIDOMKeyEvent::DOM_VK_META, GDK_Meta_L }, - { nsIDOMKeyEvent::DOM_VK_META, GDK_Meta_R }, - { nsIDOMKeyEvent::DOM_VK_PAUSE, GDK_Pause }, - { nsIDOMKeyEvent::DOM_VK_CAPS_LOCK, GDK_Caps_Lock }, - { nsIDOMKeyEvent::DOM_VK_KANA, GDK_Kana_Lock }, - { nsIDOMKeyEvent::DOM_VK_KANA, GDK_Kana_Shift }, - { nsIDOMKeyEvent::DOM_VK_HANGUL, GDK_Hangul }, - // { nsIDOMKeyEvent::DOM_VK_JUNJA, GDK_XXX }, - // { nsIDOMKeyEvent::DOM_VK_FINAL, GDK_XXX }, - { nsIDOMKeyEvent::DOM_VK_HANJA, GDK_Hangul_Hanja }, - { nsIDOMKeyEvent::DOM_VK_KANJI, GDK_Kanji }, - { nsIDOMKeyEvent::DOM_VK_ESCAPE, GDK_Escape }, - { nsIDOMKeyEvent::DOM_VK_CONVERT, GDK_Henkan }, - { nsIDOMKeyEvent::DOM_VK_NONCONVERT, GDK_Muhenkan }, - // { nsIDOMKeyEvent::DOM_VK_ACCEPT, GDK_XXX }, - { nsIDOMKeyEvent::DOM_VK_MODECHANGE, GDK_Mode_switch }, - { nsIDOMKeyEvent::DOM_VK_SPACE, GDK_space }, - { nsIDOMKeyEvent::DOM_VK_PAGE_UP, GDK_Page_Up }, - { nsIDOMKeyEvent::DOM_VK_PAGE_DOWN, GDK_Page_Down }, - { nsIDOMKeyEvent::DOM_VK_END, GDK_End }, - { nsIDOMKeyEvent::DOM_VK_HOME, GDK_Home }, - { nsIDOMKeyEvent::DOM_VK_LEFT, GDK_Left }, - { nsIDOMKeyEvent::DOM_VK_UP, GDK_Up }, - { nsIDOMKeyEvent::DOM_VK_RIGHT, GDK_Right }, - { nsIDOMKeyEvent::DOM_VK_DOWN, GDK_Down }, - { nsIDOMKeyEvent::DOM_VK_SELECT, GDK_Select }, - { nsIDOMKeyEvent::DOM_VK_PRINT, GDK_Print }, - { nsIDOMKeyEvent::DOM_VK_EXECUTE, GDK_Execute }, - { nsIDOMKeyEvent::DOM_VK_PRINTSCREEN, GDK_Print }, - { nsIDOMKeyEvent::DOM_VK_INSERT, GDK_Insert }, - { nsIDOMKeyEvent::DOM_VK_DELETE, GDK_Delete }, - { nsIDOMKeyEvent::DOM_VK_HELP, GDK_Help }, - - // keypad keys - { nsIDOMKeyEvent::DOM_VK_LEFT, GDK_KP_Left }, - { nsIDOMKeyEvent::DOM_VK_RIGHT, GDK_KP_Right }, - { nsIDOMKeyEvent::DOM_VK_UP, GDK_KP_Up }, - { nsIDOMKeyEvent::DOM_VK_DOWN, GDK_KP_Down }, - { nsIDOMKeyEvent::DOM_VK_PAGE_UP, GDK_KP_Page_Up }, - // Not sure what these are - //{ nsIDOMKeyEvent::DOM_VK_, GDK_KP_Prior }, - //{ nsIDOMKeyEvent::DOM_VK_, GDK_KP_Next }, - // GDK_KP_Begin is the 5 on the non-numlock keypad - //{ nsIDOMKeyEvent::DOM_VK_, GDK_KP_Begin }, - { nsIDOMKeyEvent::DOM_VK_PAGE_DOWN, GDK_KP_Page_Down }, - { nsIDOMKeyEvent::DOM_VK_HOME, GDK_KP_Home }, - { nsIDOMKeyEvent::DOM_VK_END, GDK_KP_End }, - { nsIDOMKeyEvent::DOM_VK_INSERT, GDK_KP_Insert }, - { nsIDOMKeyEvent::DOM_VK_DELETE, GDK_KP_Delete }, - - { nsIDOMKeyEvent::DOM_VK_MULTIPLY, GDK_KP_Multiply }, - { nsIDOMKeyEvent::DOM_VK_ADD, GDK_KP_Add }, - { nsIDOMKeyEvent::DOM_VK_SEPARATOR, GDK_KP_Separator }, - { nsIDOMKeyEvent::DOM_VK_SUBTRACT, GDK_KP_Subtract }, - { nsIDOMKeyEvent::DOM_VK_DECIMAL, GDK_KP_Decimal }, - { nsIDOMKeyEvent::DOM_VK_DIVIDE, GDK_KP_Divide }, - { nsIDOMKeyEvent::DOM_VK_RETURN, GDK_KP_Enter }, - { nsIDOMKeyEvent::DOM_VK_NUM_LOCK, GDK_Num_Lock }, - { nsIDOMKeyEvent::DOM_VK_SCROLL_LOCK,GDK_Scroll_Lock }, - - { nsIDOMKeyEvent::DOM_VK_COMMA, GDK_comma }, - { nsIDOMKeyEvent::DOM_VK_PERIOD, GDK_period }, - { nsIDOMKeyEvent::DOM_VK_SLASH, GDK_slash }, - { nsIDOMKeyEvent::DOM_VK_BACK_SLASH, GDK_backslash }, - { nsIDOMKeyEvent::DOM_VK_BACK_QUOTE, GDK_grave }, - { nsIDOMKeyEvent::DOM_VK_OPEN_BRACKET, GDK_bracketleft }, - { nsIDOMKeyEvent::DOM_VK_CLOSE_BRACKET, GDK_bracketright }, - { nsIDOMKeyEvent::DOM_VK_SEMICOLON, GDK_colon }, - { nsIDOMKeyEvent::DOM_VK_QUOTE, GDK_apostrophe }, - - // context menu key, keysym 0xff67, typically keycode 117 on 105-key (Microsoft) - // x86 keyboards, located between right 'Windows' key and right Ctrl key - { nsIDOMKeyEvent::DOM_VK_CONTEXT_MENU, GDK_Menu }, - { nsIDOMKeyEvent::DOM_VK_SLEEP, GDK_Sleep }, - - // NS doesn't have dash or equals distinct from the numeric keypad ones, - // so we'll use those for now. See bug 17008: - { nsIDOMKeyEvent::DOM_VK_SUBTRACT, GDK_minus }, - { nsIDOMKeyEvent::DOM_VK_EQUALS, GDK_equal }, - - // Some shifted keys, see bug 15463 as well as 17008. - // These should be subject to different keyboard mappings. - { nsIDOMKeyEvent::DOM_VK_QUOTE, GDK_quotedbl }, - { nsIDOMKeyEvent::DOM_VK_OPEN_BRACKET, GDK_braceleft }, - { nsIDOMKeyEvent::DOM_VK_CLOSE_BRACKET, GDK_braceright }, - { nsIDOMKeyEvent::DOM_VK_BACK_SLASH, GDK_bar }, - { nsIDOMKeyEvent::DOM_VK_SEMICOLON, GDK_semicolon }, - { nsIDOMKeyEvent::DOM_VK_BACK_QUOTE, GDK_asciitilde }, - { nsIDOMKeyEvent::DOM_VK_COMMA, GDK_less }, - { nsIDOMKeyEvent::DOM_VK_PERIOD, GDK_greater }, - { nsIDOMKeyEvent::DOM_VK_SLASH, GDK_question }, - { nsIDOMKeyEvent::DOM_VK_1, GDK_exclam }, - { nsIDOMKeyEvent::DOM_VK_2, GDK_at }, - { nsIDOMKeyEvent::DOM_VK_3, GDK_numbersign }, - { nsIDOMKeyEvent::DOM_VK_4, GDK_dollar }, - { nsIDOMKeyEvent::DOM_VK_5, GDK_percent }, - { nsIDOMKeyEvent::DOM_VK_6, GDK_asciicircum }, - { nsIDOMKeyEvent::DOM_VK_7, GDK_ampersand }, - { nsIDOMKeyEvent::DOM_VK_8, GDK_asterisk }, - { nsIDOMKeyEvent::DOM_VK_9, GDK_parenleft }, - { nsIDOMKeyEvent::DOM_VK_0, GDK_parenright }, - { nsIDOMKeyEvent::DOM_VK_SUBTRACT, GDK_underscore }, - { nsIDOMKeyEvent::DOM_VK_EQUALS, GDK_plus } -}; - -PRUint32 -uGlobalMenuItem::MozKeyCodeToGdkKeyCode(PRUint32 aMozKeyCode) -{ - if (aMozKeyCode >= nsIDOMKeyEvent::DOM_VK_A && - aMozKeyCode <= nsIDOMKeyEvent::DOM_VK_Z) - return aMozKeyCode; - - if (aMozKeyCode >= nsIDOMKeyEvent::DOM_VK_0 && - aMozKeyCode <= nsIDOMKeyEvent::DOM_VK_9) - return aMozKeyCode; - - if (aMozKeyCode >= nsIDOMKeyEvent::DOM_VK_NUMPAD0 && - aMozKeyCode <= nsIDOMKeyEvent::DOM_VK_NUMPAD9) - return aMozKeyCode - nsIDOMKeyEvent::DOM_VK_NUMPAD0 + GDK_0; - - if (aMozKeyCode >= nsIDOMKeyEvent::DOM_VK_F1 && - aMozKeyCode <= nsIDOMKeyEvent::DOM_VK_F24) - return aMozKeyCode - nsIDOMKeyEvent::DOM_VK_F1 + GDK_KEY_F1; - - for (PRUint32 i = 0; i < NS_ARRAY_LENGTH(nsKeycodes); i++) { - if (nsKeycodes[i].vkCode == aMozKeyCode) - return nsKeycodes[i].keysym; - } - - return GDK_VoidSymbol; -} - -void -uGlobalMenuItem::SyncAccelFromContent() -{ - if (!mKeyContent) { - dbusmenu_menuitem_property_remove(mDbusMenuItem, - DBUSMENU_MENUITEM_PROP_SHORTCUT); - return; - } - - nsAutoString modStr; - mKeyContent->GetAttr(kNameSpaceID_None, uWidgetAtoms::modifiers, modStr); - - PRUint32 modifier = 0; - - if (!modStr.IsEmpty()) { - char* str = ToNewUTF8String(modStr); - char *token = strtok(str, ", \t"); - while(token) { - if (strcmp(token, "shift") == 0) { - modifier |= GDK_SHIFT_MASK; - } else if (strcmp(token, "alt") == 0) { - modifier |= GDK_MOD1_MASK; - } else if (strcmp(token, "meta") == 0) { - modifier |= GDK_META_MASK; - } else if (strcmp(token, "control") == 0) { - modifier |= GDK_CONTROL_MASK; - } else if (strcmp(token, "accel") == 0) { - nsCOMPtr prefs = do_GetService(NS_PREFSERVICE_CONTRACTID); - if (prefs) { - PRInt32 accel; - prefs->GetIntPref("ui.key.accelKey", &accel); - if (accel == nsIDOMKeyEvent::DOM_VK_META) { - modifier |= GDK_META_MASK; - } else if (accel == nsIDOMKeyEvent::DOM_VK_ALT) { - modifier |= GDK_MOD1_MASK; - } else { - modifier |= GDK_CONTROL_MASK; - } - } else { - // This is the default, see layout/xul/base/src/nsMenuFrame.cpp - modifier |= GDK_CONTROL_MASK; - } - } - - token = strtok(nsnull, ", \t"); - } - - nsMemory::Free(str); - } - - nsAutoString keyStr; - guint key = 0; - mKeyContent->GetAttr(kNameSpaceID_None, uWidgetAtoms::key, keyStr); - - nsCAutoString cKeyStr; - CopyUTF16toUTF8(keyStr, cKeyStr); - - if (!cKeyStr.IsEmpty()) { - key = gdk_keyval_from_name(cKeyStr.get()); - } - - if (key == 0 && !keyStr.IsEmpty()) { - key = gdk_unicode_to_keyval(*keyStr.BeginReading()); - } - - if (key == 0) { - mKeyContent->GetAttr(kNameSpaceID_None, uWidgetAtoms::keycode, keyStr); - if (!keyStr.IsEmpty()) - key = MozKeyCodeToGdkKeyCode(GetKeyCode(keyStr)); - } - - if (key == 0) { - key = GDK_VoidSymbol; - } - - if (key != GDK_VoidSymbol) { - dbusmenu_menuitem_property_set_shortcut(mDbusMenuItem, key, - static_cast(modifier)); - } else { - dbusmenu_menuitem_property_remove(mDbusMenuItem, - DBUSMENU_MENUITEM_PROP_SHORTCUT); - } -} - -void -uGlobalMenuItem::SyncTypeAndStateFromContent() -{ - static nsIContent::AttrValuesArray attrs[] = - { &uWidgetAtoms::checkbox, &uWidgetAtoms::radio, nsnull }; - PRInt32 type = mContent->FindAttrValueIn(kNameSpaceID_None, - uWidgetAtoms::type, - attrs, eCaseMatters); - - if (type >= 0 && type < 2) { - if (type == 0) { - dbusmenu_menuitem_property_set(mDbusMenuItem, - DBUSMENU_MENUITEM_PROP_TOGGLE_TYPE, - DBUSMENU_MENUITEM_TOGGLE_CHECK); - mType = CheckBox; - } else if (type == 1) { - dbusmenu_menuitem_property_set(mDbusMenuItem, - DBUSMENU_MENUITEM_PROP_TOGGLE_TYPE, - DBUSMENU_MENUITEM_TOGGLE_RADIO); - mType = Radio; - } - - nsIContent *content = mCommandContent ? mCommandContent : mContent; - mToggleState = content->AttrValueIs(kNameSpaceID_None, - uWidgetAtoms::checked, - uWidgetAtoms::_true, - eCaseMatters); - dbusmenu_menuitem_property_set_int(mDbusMenuItem, - DBUSMENU_MENUITEM_PROP_TOGGLE_STATE, - mToggleState ? - DBUSMENU_MENUITEM_TOGGLE_STATE_CHECKED : - DBUSMENU_MENUITEM_TOGGLE_STATE_UNCHECKED); - - if (mCommandContent) { - UGM_BLOCK_EVENTS_FOR_CURRENT_SCOPE(); - if (mToggleState) { - mContent->SetAttr(kNameSpaceID_None, uWidgetAtoms::checked, - NS_LITERAL_STRING("true"), MOZ_API_TRUE); - } else { - mContent->UnsetAttr(kNameSpaceID_None, uWidgetAtoms::checked, - MOZ_API_TRUE); - } - } - - mIsToggle = PR_TRUE; - } else { - dbusmenu_menuitem_property_remove(mDbusMenuItem, - DBUSMENU_MENUITEM_PROP_TOGGLE_TYPE); - dbusmenu_menuitem_property_remove(mDbusMenuItem, - DBUSMENU_MENUITEM_PROP_TOGGLE_STATE); - mIsToggle = PR_FALSE; - mType = Normal; - } -} - -void -uGlobalMenuItem::SyncProperties() -{ - TRACE_WITH_THIS_MENUOBJECT(); - - if (mCommandContent) { - mListener->UnregisterForContentChanges(mCommandContent, this); - mCommandContent = nsnull; - } - if (mKeyContent) { - mListener->UnregisterForContentChanges(mKeyContent, this); - mKeyContent = nsnull; - } - - nsIDocument *doc = mContent->GetCurrentDoc(); - nsAutoString value; - mContent->GetAttr(kNameSpaceID_None, uWidgetAtoms::command, value); - if (!value.IsEmpty()) { - mCommandContent = doc->GetElementById(value); - if (mCommandContent) { - mListener->RegisterForContentChanges(mCommandContent, this); - } - } - mContent->GetAttr(kNameSpaceID_None, uWidgetAtoms::key, value); - if (!value.IsEmpty()) { - mKeyContent = doc->GetElementById(value); - if (mKeyContent) { - mListener->RegisterForContentChanges(mKeyContent, this); - } - } - - // We need to do this first, as some of the next functions may - // trigger mutation events, which we want to handle if we our parent - // is opening - ClearInvalid(); - - UpdateInfoFromContentClass(); - SyncLabelFromContent(mCommandContent); - SyncSensitivityFromContent(mCommandContent); - SyncVisibilityFromContent(); - SyncTypeAndStateFromContent(); - SyncAccelFromContent(); - SyncIconFromContent(); -} - -/*static*/ void -uGlobalMenuItem::ItemActivatedCallback(DbusmenuMenuitem *menuItem, - PRUint32 timeStamp, - void *data) -{ - uGlobalMenuItem *self = static_cast(data); - self->Activate(); -} - -void -uGlobalMenuItem::Activate() -{ - // This first bit seems backwards, but it's not really. If autocheck is - // not set or autocheck==true, then the checkbox state is usually updated - // by the input event that clicked on the menu item. In this case, we need - // to manually update the checkbox state. If autocheck==false, then the input - // event doesn't toggle the checkbox state, and it is up to the handler on - // this node to do it instead. In this case, we leave it alone - - // XXX: it is important to update the checkbox state before dispatching - // the event, as the handler might check the new state - if (!mContent->AttrValueIs(kNameSpaceID_None, uWidgetAtoms::autocheck, - uWidgetAtoms::_false, eCaseMatters) && - mType != Normal) { - nsIContent *content = mCommandContent ? mCommandContent : mContent; - if (!mToggleState) { - // We're currently not checked, so check now - content->SetAttr(kNameSpaceID_None, uWidgetAtoms::checked, - NS_LITERAL_STRING("true"), MOZ_API_TRUE); - } else if (mToggleState && mType == CheckBox) { - // We're currently checked, so uncheck now. Don't do this for radio buttons - content->UnsetAttr(kNameSpaceID_None, uWidgetAtoms::checked, MOZ_API_TRUE); - } - } - -#if MOZILLA_BRANCH_MAJOR_VERSION >= 10 - nsCOMPtr domDoc = do_QueryInterface(mContent->OwnerDoc()); -#else - nsCOMPtr domDoc = do_QueryInterface(mContent->GetOwnerDoc()); -#endif - if (domDoc) { - nsCOMPtr event; - domDoc->CreateEvent(NS_LITERAL_STRING("xulcommandevent"), - getter_AddRefs(event)); - if (event) { - nsCOMPtr cmdEvent = do_QueryInterface(event); - if (cmdEvent) { - nsCOMPtr window; - domDoc->GetDefaultView(getter_AddRefs(window)); - if (window) { - cmdEvent->InitCommandEvent(NS_LITERAL_STRING("command"), - MOZ_API_TRUE, MOZ_API_TRUE, window, 0, - MOZ_API_FALSE, MOZ_API_FALSE, MOZ_API_FALSE, - MOZ_API_FALSE, nsnull); - nsCOMPtr target = do_QueryInterface(mContent); - if (target) { - nsCOMPtr priv = do_QueryInterface(event); - if (priv) { - priv->SetTrusted(MOZ_API_TRUE); - } - MOZ_API_BOOL dummy; - target->DispatchEvent(event, &dummy); - } - } - } - } - } -} - -nsresult -uGlobalMenuItem::ConstructDbusMenuItem() -{ - mDbusMenuItem = dbusmenu_menuitem_new(); - if (!mDbusMenuItem) - return NS_ERROR_OUT_OF_MEMORY; - - mHandlerID = g_signal_connect(G_OBJECT(mDbusMenuItem), - DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, - G_CALLBACK(ItemActivatedCallback), - this); - - SyncProperties(); - - return NS_OK; -} - -nsresult -uGlobalMenuItem::Init(uGlobalMenuObject *aParent, - uGlobalMenuDocListener *aListener, - nsIContent *aContent, - uGlobalMenuBar *aMenuBar) -{ - NS_ENSURE_ARG(aParent); - NS_ENSURE_ARG(aListener); - NS_ENSURE_ARG(aContent); - NS_ENSURE_ARG(aMenuBar); - - mParent = aParent; - mListener = aListener; - mContent = aContent; - mMenuBar = aMenuBar; - - nsresult rv; - rv = mListener->RegisterForContentChanges(mContent, this); - NS_ENSURE_SUCCESS(rv, rv); - - return ConstructDbusMenuItem(); -} - -void -uGlobalMenuItem::UncheckSiblings() -{ - if (mType != Radio) { - // If we're not a radio button, we don't care - return; - } - - nsAutoString name; - mContent->GetAttr(kNameSpaceID_None, uWidgetAtoms::name, name); - if (name.IsEmpty()) { - // If we don't have a name, then we can't find our siblings - return; - } - - nsIContent *parent = mContent->GetParent(); - if (!parent) { - return; - } - - PRUint32 count = parent->GetChildCount(); - for (PRUint32 i = 0; i < count; i++) { - nsIContent *sibling = parent->GetChildAt(i); - if (sibling->AttrValueIs(kNameSpaceID_None, uWidgetAtoms::name, - name, eCaseMatters) && sibling != mContent && - sibling->AttrValueIs(kNameSpaceID_None, uWidgetAtoms::type, - uWidgetAtoms::radio, eCaseMatters)) { - sibling->UnsetAttr(kNameSpaceID_None, uWidgetAtoms::checked, MOZ_API_TRUE); - } - } -} - -uGlobalMenuItem::uGlobalMenuItem(): - uGlobalMenuObject(MenuItem) -{ - MOZ_COUNT_CTOR(uGlobalMenuItem); -} - -uGlobalMenuItem::~uGlobalMenuItem() -{ - if (mListener) { - mListener->UnregisterForContentChanges(mContent, this); - if (mCommandContent) { - mListener->UnregisterForContentChanges(mCommandContent, this); - } - if (mKeyContent) { - mListener->UnregisterForContentChanges(mKeyContent, this); - } - } - - DestroyIconLoader(); - - if (mDbusMenuItem) { - g_signal_handler_disconnect(mDbusMenuItem, mHandlerID); - g_object_unref(mDbusMenuItem); - } - - MOZ_COUNT_DTOR(uGlobalMenuItem); -} - -/*static*/ uGlobalMenuObject* -uGlobalMenuItem::Create(uGlobalMenuObject *aParent, - uGlobalMenuDocListener *aListener, - nsIContent *aContent, - uGlobalMenuBar *aMenuBar) -{ - TRACE_WITH_CONTENT(aContent); - - uGlobalMenuItem *menuitem = new uGlobalMenuItem(); - if (!menuitem) { - return nsnull; - } - - if (NS_FAILED(menuitem->Init(aParent, aListener, aContent, aMenuBar))) { - delete menuitem; - return nsnull; - } - - return static_cast(menuitem); -} - -void -uGlobalMenuItem::AboutToShowNotify() -{ - TRACE_WITH_THIS_MENUOBJECT(); - - if (IsDirty()) { - SyncProperties(); - } else { - UpdateVisibility(); - } -} - -void -uGlobalMenuItem::ObserveAttributeChanged(nsIDocument *aDocument, - nsIContent *aContent, - nsIAtom *aAttribute) -{ - TRACE_WITH_THIS_MENUOBJECT(); - UGM_ENSURE_EVENTS_UNBLOCKED(); - NS_ASSERTION(aContent == mContent || aContent == mCommandContent || - aContent == mKeyContent, - "Received an event that wasn't meant for us!"); - - if ((aContent == mContent || aContent == mCommandContent) && - aAttribute == uWidgetAtoms::checked && - aContent->AttrValueIs(kNameSpaceID_None, uWidgetAtoms::checked, - uWidgetAtoms::_true, eCaseMatters)) { - UncheckSiblings(); - } - - if (IsDirty()) { - DEBUG_WITH_THIS_MENUOBJECT("Previously marked as invalid"); - return; - } - - if (mParent->GetType() == Menu && - !(static_cast(mParent))->IsOpening()) { - DEBUG_WITH_THIS_MENUOBJECT("Parent isn't opening. Marking invalid"); - Invalidate(); - return; - } - - if (aContent == mContent) { - if (aAttribute == uWidgetAtoms::command || - aAttribute == uWidgetAtoms::key) { - SyncProperties(); - } else if (aAttribute == uWidgetAtoms::label || - aAttribute == uWidgetAtoms::accesskey) { - SyncLabelFromContent(mCommandContent); - } else if (aAttribute == uWidgetAtoms::hidden || - aAttribute == uWidgetAtoms::collapsed) { - SyncVisibilityFromContent(); - } else if (aAttribute == uWidgetAtoms::disabled) { - SyncSensitivityFromContent(mCommandContent); - } else if (aAttribute == uWidgetAtoms::checked || - aAttribute == uWidgetAtoms::type) { - SyncTypeAndStateFromContent(); - } else if (aAttribute == uWidgetAtoms::image) { - SyncIconFromContent(); - } else if (aAttribute == uWidgetAtoms::_class) { - UpdateInfoFromContentClass(); - SyncVisibilityFromContent(); - SyncIconFromContent(); - } - } else if (aContent == mCommandContent) { - if (aAttribute == uWidgetAtoms::label) { - SyncLabelFromContent(mCommandContent); - } else if (aAttribute == uWidgetAtoms::disabled) { - SyncSensitivityFromContent(mCommandContent); - } else if (aAttribute == uWidgetAtoms::checked) { - SyncTypeAndStateFromContent(); - } - } else if (aContent == mKeyContent) { - SyncAccelFromContent(); - } -} - -void -uGlobalMenuItem::ObserveContentRemoved(nsIDocument *aDocument, - nsIContent *aContainer, - nsIContent *aChild, - PRInt32 aIndexInContainer) -{ - NS_ASSERTION(0, "We can't remove content from a menuitem!"); -} - -void -uGlobalMenuItem::ObserveContentInserted(nsIDocument *aDocument, - nsIContent *aContainer, - nsIContent *aChild, - PRInt32 aIndexInContainer) -{ - NS_ASSERTION(0, "We can't insert content in to a menuitem!"); -} reverted: --- firefox-11.0+build1/debian/globalmenu/components/public/uIGlobalMenuService.idl +++ firefox-11.0+build1.orig/debian/globalmenu/components/public/uIGlobalMenuService.idl @@ -1,71 +0,0 @@ -/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is globalmenu-extension. - * - * The Initial Developer of the Original Code is - * Canonical Ltd. - * Portions created by the Initial Developer are Copyright (C) 2010 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * Chris Coulson - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -#include "nsISupports.idl" -#include "nsIObserver.idl" - -[ptr] native uGlobalMenuBarPtr(uGlobalMenuBar); -[ptr] native nsIWidgetPtr(nsIWidget); -[ptr] native nsIContentPtr(nsIContent); -[ptr] native uGlobalMenuRequestAutoCancellerPtr(uGlobalMenuRequestAutoCanceller); - -%{C++ -class uGlobalMenuBar; -class uGlobalMenuRequestAutoCanceller; -class nsIWidget; -class nsIContent; -%} - -[scriptable, uuid(92e2d4d4-84d6-400b-99ce-bb3b63639b5b)] -interface uIGlobalMenuService : nsISupports -{ - /* Create a menu bar from the specified DOM node and associate with the top-level - * window containing the specified DOM window */ - [noscript] void createGlobalMenuBar (in nsIWidgetPtr parent, in nsIContentPtr menuBarNode); - - /* Register a menu bar with the menu bar service */ - [noscript, notxpcom] void registerGlobalMenuBar (in uGlobalMenuBarPtr menuBar, in uGlobalMenuRequestAutoCancellerPtr canceller); - - /* Convenience functions to register to receive notification of the menu - * service online status changing */ - void registerNotification (in nsIObserver observer); - void unregisterNotification (in nsIObserver observer); - - /* Menu service online status */ - readonly attribute boolean online; -}; reverted: --- firefox-11.0+build1/debian/globalmenu/components/public/Makefile.in +++ firefox-11.0+build1.orig/debian/globalmenu/components/public/Makefile.in @@ -1,52 +0,0 @@ -# ***** BEGIN LICENSE BLOCK ***** -# Version: MPL 1.1/GPL 2.0/LGPL 2.1 -# -# The contents of this file are subject to the Mozilla Public License Version -# 1.1 (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# http://www.mozilla.org/MPL/ -# -# Software distributed under the License is distributed on an "AS IS" basis, -# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License -# for the specific language governing rights and limitations under the -# License. -# -# The Original Code is mozilla.org code. -# -# The Initial Developer of the Original Code is -# Netscape Communications Corporation. -# Portions created by the Initial Developer are Copyright (C) 2001 -# the Initial Developer. All Rights Reserved. -# -# Contributor(s): -# Chris Coulson -# -# Alternatively, the contents of this file may be used under the terms of -# either the GNU General Public License Version 2 or later (the "GPL"), or -# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), -# in which case the provisions of the GPL or the LGPL are applicable instead -# of those above. If you wish to allow use of your version of this file only -# under the terms of either the GPL or the LGPL, and not to allow others to -# use your version of this file under the terms of the MPL, indicate your -# decision by deleting the provisions above and replace them with the notice -# and other provisions required by the GPL or the LGPL. If you do not delete -# the provisions above, a recipient may use your version of this file under -# the terms of any one of the MPL, the GPL or the LGPL. -# -# ***** END LICENSE BLOCK ***** - -DEPTH = ../../../.. -topsrcdir = @top_srcdir@ -srcdir = @srcdir@ -VPATH = @srcdir@ - -include $(DEPTH)/config/autoconf.mk - -MODULE = globalmenu -XPI_NAME = globalmenu - -XPIDLSRCS = \ - uIGlobalMenuService.idl \ - $(NULL) - -include $(topsrcdir)/config/rules.mk diff -u firefox-11.0+build1/debian/globalmenu/chrome/content/firefoxOverlay.xul firefox-11.0+build1/debian/globalmenu/chrome/content/firefoxOverlay.xul --- firefox-11.0+build1/debian/globalmenu/chrome/content/firefoxOverlay.xul +++ firefox-11.0+build1/debian/globalmenu/chrome/content/firefoxOverlay.xul @@ -40,2 +40,5 @@