Bug 1085696. Part 1 Move widget/xpwidget to /widget. r=roc
authorMason Chang <mchang@mozilla.com>
Thu, 23 Oct 2014 10:16:45 -0700
changeset 224257 41c37790896e424e2743811d3d19be00068ce941
parent 224256 12f287650d0c2f29e12d042ba358b056033c5989
child 224258 ccd53912eb4ce6cf469d6042b02f8090aecebee8
push id4311
push userraliiev@mozilla.com
push dateMon, 12 Jan 2015 19:37:41 +0000
treeherdermozilla-esr52@150c9fed433b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersroc
bugs1085696
milestone36.0a1
Bug 1085696. Part 1 Move widget/xpwidget to /widget. r=roc
accessible/mac/moz.build
dom/base/moz.build
dom/ipc/moz.build
dom/plugins/base/android/moz.build
dom/plugins/base/moz.build
dom/plugins/ipc/moz.build
hal/moz.build
widget/ContentHelper.cpp
widget/ContentHelper.h
widget/GfxDriverInfo.cpp
widget/GfxDriverInfo.h
widget/GfxInfoBase.cpp
widget/GfxInfoBase.h
widget/GfxInfoCollector.cpp
widget/GfxInfoCollector.h
widget/GfxInfoWebGL.cpp
widget/GfxInfoWebGL.h
widget/GfxInfoX11.cpp
widget/GfxInfoX11.h
widget/InputData.cpp
widget/PuppetWidget.cpp
widget/PuppetWidget.h
widget/ScreenProxy.cpp
widget/ScreenProxy.h
widget/SharedWidgetUtils.cpp
widget/WidgetUtils.cpp
widget/WidgetUtils.h
widget/android/moz.build
widget/cocoa/moz.build
widget/gonk/moz.build
widget/gtk/moz.build
widget/moz.build
widget/nsAppShellSingleton.h
widget/nsBaseAppShell.cpp
widget/nsBaseAppShell.h
widget/nsBaseClipboard.cpp
widget/nsBaseClipboard.h
widget/nsBaseDragService.cpp
widget/nsBaseDragService.h
widget/nsBaseFilePicker.cpp
widget/nsBaseFilePicker.h
widget/nsBaseScreen.cpp
widget/nsBaseScreen.h
widget/nsBaseWidget.cpp
widget/nsBaseWidget.h
widget/nsClipboardHelper.cpp
widget/nsClipboardHelper.h
widget/nsClipboardProxy.cpp
widget/nsClipboardProxy.h
widget/nsColorPickerProxy.cpp
widget/nsColorPickerProxy.h
widget/nsContentProcessWidgetFactory.cpp
widget/nsFilePickerProxy.cpp
widget/nsFilePickerProxy.h
widget/nsHTMLFormatConverter.cpp
widget/nsHTMLFormatConverter.h
widget/nsIWidgetListener.cpp
widget/nsIdleService.cpp
widget/nsIdleService.h
widget/nsNativeTheme.cpp
widget/nsNativeTheme.h
widget/nsPrimitiveHelpers.cpp
widget/nsPrimitiveHelpers.h
widget/nsPrintOptionsImpl.cpp
widget/nsPrintOptionsImpl.h
widget/nsPrintSession.cpp
widget/nsPrintSession.h
widget/nsPrintSettingsImpl.cpp
widget/nsPrintSettingsImpl.h
widget/nsScreenManagerProxy.cpp
widget/nsScreenManagerProxy.h
widget/nsTransferable.cpp
widget/nsTransferable.h
widget/nsXPLookAndFeel.cpp
widget/nsXPLookAndFeel.h
widget/qt/moz.build
widget/shared/SharedWidgetUtils.cpp
widget/shared/WidgetUtils.h
widget/shared/moz.build
widget/windows/moz.build
widget/windows/winrt/moz.build
widget/xpwidgets/ContentHelper.cpp
widget/xpwidgets/ContentHelper.h
widget/xpwidgets/GfxDriverInfo.cpp
widget/xpwidgets/GfxDriverInfo.h
widget/xpwidgets/GfxInfoBase.cpp
widget/xpwidgets/GfxInfoBase.h
widget/xpwidgets/GfxInfoCollector.cpp
widget/xpwidgets/GfxInfoCollector.h
widget/xpwidgets/GfxInfoWebGL.cpp
widget/xpwidgets/GfxInfoWebGL.h
widget/xpwidgets/GfxInfoX11.cpp
widget/xpwidgets/GfxInfoX11.h
widget/xpwidgets/InputData.cpp
widget/xpwidgets/PuppetWidget.cpp
widget/xpwidgets/PuppetWidget.h
widget/xpwidgets/ScreenProxy.cpp
widget/xpwidgets/ScreenProxy.h
widget/xpwidgets/WidgetUtils.cpp
widget/xpwidgets/moz.build
widget/xpwidgets/nsAppShellSingleton.h
widget/xpwidgets/nsBaseAppShell.cpp
widget/xpwidgets/nsBaseAppShell.h
widget/xpwidgets/nsBaseClipboard.cpp
widget/xpwidgets/nsBaseClipboard.h
widget/xpwidgets/nsBaseDragService.cpp
widget/xpwidgets/nsBaseDragService.h
widget/xpwidgets/nsBaseFilePicker.cpp
widget/xpwidgets/nsBaseFilePicker.h
widget/xpwidgets/nsBaseScreen.cpp
widget/xpwidgets/nsBaseScreen.h
widget/xpwidgets/nsBaseWidget.cpp
widget/xpwidgets/nsBaseWidget.h
widget/xpwidgets/nsClipboardHelper.cpp
widget/xpwidgets/nsClipboardHelper.h
widget/xpwidgets/nsClipboardProxy.cpp
widget/xpwidgets/nsClipboardProxy.h
widget/xpwidgets/nsColorPickerProxy.cpp
widget/xpwidgets/nsColorPickerProxy.h
widget/xpwidgets/nsContentProcessWidgetFactory.cpp
widget/xpwidgets/nsFilePickerProxy.cpp
widget/xpwidgets/nsFilePickerProxy.h
widget/xpwidgets/nsHTMLFormatConverter.cpp
widget/xpwidgets/nsHTMLFormatConverter.h
widget/xpwidgets/nsIWidgetListener.cpp
widget/xpwidgets/nsIdleService.cpp
widget/xpwidgets/nsIdleService.h
widget/xpwidgets/nsNativeTheme.cpp
widget/xpwidgets/nsNativeTheme.h
widget/xpwidgets/nsPrimitiveHelpers.cpp
widget/xpwidgets/nsPrimitiveHelpers.h
widget/xpwidgets/nsPrintOptionsImpl.cpp
widget/xpwidgets/nsPrintOptionsImpl.h
widget/xpwidgets/nsPrintSession.cpp
widget/xpwidgets/nsPrintSession.h
widget/xpwidgets/nsPrintSettingsImpl.cpp
widget/xpwidgets/nsPrintSettingsImpl.h
widget/xpwidgets/nsScreenManagerProxy.cpp
widget/xpwidgets/nsScreenManagerProxy.h
widget/xpwidgets/nsTransferable.cpp
widget/xpwidgets/nsTransferable.h
widget/xpwidgets/nsXPLookAndFeel.cpp
widget/xpwidgets/nsXPLookAndFeel.h
--- a/accessible/mac/moz.build
+++ b/accessible/mac/moz.build
@@ -28,13 +28,13 @@ UNIFIED_SOURCES += [
 
 LOCAL_INCLUDES += [
     '/accessible/base',
     '/accessible/generic',
     '/accessible/html',
     '/accessible/xul',
     '/layout/generic',
     '/layout/xul',
+    '/widget',
     '/widget/cocoa',
-    '/widget/xpwidgets',
 ]
 
 FINAL_LIBRARY = 'xul'
--- a/dom/base/moz.build
+++ b/dom/base/moz.build
@@ -158,16 +158,17 @@ LOCAL_INCLUDES += [
     '/content/html/document/src',
     '/content/xul/document/src',
     '/dom/geolocation',
     '/dom/storage',
     '/layout/base',
     '/layout/generic',
     '/layout/style',
     '/layout/xul',
+    '/widget',
     '/widget/shared',
 ]
 
 if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'gonk':
     LOCAL_INCLUDES += [
         '../fmradio',
         '../system/gonk',
     ]
--- a/dom/ipc/moz.build
+++ b/dom/ipc/moz.build
@@ -114,17 +114,17 @@ LOCAL_INCLUDES += [
     '/extensions/cookie',
     '/extensions/spellcheck/src',
     '/hal/sandbox',
     '/js/ipc',
     '/layout/base',
     '/netwerk/base/src',
     '/toolkit/xre',
     '/uriloader/exthandler',
-    '/widget/xpwidgets',
+    '/widget',
     '/xpcom/base',
     '/xpcom/threads',
 ]
 
 DEFINES['BIN_SUFFIX'] = '"%s"' % CONFIG['BIN_SUFFIX']
 
 if CONFIG['MOZ_WIDGET_TOOLKIT'] in ('android', 'gtk2', 'gonk', 'qt'):
     DEFINES['MOZ_ENABLE_FREETYPE'] = True
--- a/dom/plugins/base/android/moz.build
+++ b/dom/plugins/base/android/moz.build
@@ -26,15 +26,15 @@ SOURCES += [
 FAIL_ON_WARNINGS = True
 
 include('/ipc/chromium/chromium-config.mozbuild')
 
 FINAL_LIBRARY = 'xul'
 LOCAL_INCLUDES += [
     '/dom/plugins/base',
     '/gfx/gl',
+    '/widget',
     '/widget/android',
-    '/widget/xpwidgets',
 ]
 
 DEFINES['MOZ_APP_NAME'] = '"%s"' % CONFIG['MOZ_APP_NAME']
 
 CXXFLAGS += CONFIG['MOZ_CAIRO_CFLAGS']
--- a/dom/plugins/base/moz.build
+++ b/dom/plugins/base/moz.build
@@ -95,18 +95,18 @@ if CONFIG['MOZ_WIDGET_TOOLKIT'] != 'andr
 
 MSVC_ENABLE_PGO = True
 
 LOCAL_INCLUDES += [
     '/content/base/src',
     '/dom/base',
     '/layout/generic',
     '/layout/xul',
+    '/widget',
     '/widget/android',
-    '/widget/xpwidgets',
     '/xpcom/base',
 ]
 
 if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'android':
     LOCAL_INCLUDES += [
         '/dom/plugins/base/android',
     ]
 
--- a/dom/plugins/ipc/moz.build
+++ b/dom/plugins/ipc/moz.build
@@ -49,17 +49,17 @@ if CONFIG['OS_ARCH'] == 'WINNT':
         'PluginHangUIParent.cpp',
         'PluginSurfaceParent.cpp',
     ]
     SOURCES += [
         'MiniShmParent.cpp', # Issues with CreateEvent
     ]
     DEFINES['MOZ_HANGUI_PROCESS_NAME'] = '"plugin-hang-ui%s"' % CONFIG['BIN_SUFFIX']
     LOCAL_INCLUDES += [
-        '/widget/shared',
+        '/widget',
         'hangui',
     ]
 
 if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'cocoa':
     EXPORTS.mozilla.plugins += [
         'PluginInterposeOSX.h',
     ]
 
--- a/hal/moz.build
+++ b/hal/moz.build
@@ -184,18 +184,18 @@ FINAL_LIBRARY = 'xul'
 if CONFIG['MOZ_GAMEPAD']:
     LOCAL_INCLUDES += [
         '/dom/base',
     ]
 
 if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'gonk':
     # So that we can call nsScreenManagerGonk::GetConfiguration().
     LOCAL_INCLUDES += [
+        '/widget',
         '/widget/gonk',
-        '/widget/xpwidgets'
     ]
 
 if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'gonk':
     CXXFLAGS += ['-I%s/hardware/libhardware_legacy/include' % CONFIG['ANDROID_SOURCE']]
 
 CFLAGS += CONFIG['GLIB_CFLAGS']
 CFLAGS += CONFIG['MOZ_DBUS_GLIB_CFLAGS']
 CXXFLAGS += CONFIG['GLIB_CFLAGS']
rename from widget/xpwidgets/ContentHelper.cpp
rename to widget/ContentHelper.cpp
rename from widget/xpwidgets/ContentHelper.h
rename to widget/ContentHelper.h
rename from widget/xpwidgets/GfxDriverInfo.cpp
rename to widget/GfxDriverInfo.cpp
rename from widget/xpwidgets/GfxDriverInfo.h
rename to widget/GfxDriverInfo.h
rename from widget/xpwidgets/GfxInfoBase.cpp
rename to widget/GfxInfoBase.cpp
rename from widget/xpwidgets/GfxInfoBase.h
rename to widget/GfxInfoBase.h
rename from widget/xpwidgets/GfxInfoCollector.cpp
rename to widget/GfxInfoCollector.cpp
rename from widget/xpwidgets/GfxInfoCollector.h
rename to widget/GfxInfoCollector.h
rename from widget/xpwidgets/GfxInfoWebGL.cpp
rename to widget/GfxInfoWebGL.cpp
rename from widget/xpwidgets/GfxInfoWebGL.h
rename to widget/GfxInfoWebGL.h
rename from widget/xpwidgets/GfxInfoX11.cpp
rename to widget/GfxInfoX11.cpp
rename from widget/xpwidgets/GfxInfoX11.h
rename to widget/GfxInfoX11.h
rename from widget/xpwidgets/InputData.cpp
rename to widget/InputData.cpp
rename from widget/xpwidgets/PuppetWidget.cpp
rename to widget/PuppetWidget.cpp
rename from widget/xpwidgets/PuppetWidget.h
rename to widget/PuppetWidget.h
rename from widget/xpwidgets/ScreenProxy.cpp
rename to widget/ScreenProxy.cpp
rename from widget/xpwidgets/ScreenProxy.h
rename to widget/ScreenProxy.h
rename from widget/shared/SharedWidgetUtils.cpp
rename to widget/SharedWidgetUtils.cpp
rename from widget/xpwidgets/WidgetUtils.cpp
rename to widget/WidgetUtils.cpp
--- a/widget/WidgetUtils.h
+++ b/widget/WidgetUtils.h
@@ -3,18 +3,23 @@
  */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this file,
  * You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef mozilla_WidgetUtils_h
 #define mozilla_WidgetUtils_h
 
+#include "mozilla/EventForwards.h"
+#include "mozilla/gfx/Matrix.h"
+#include "nsCOMPtr.h"
+#include "nsIDOMWindow.h"
+#include "nsIWidget.h"
+#include "nsPIDOMWindow.h"
 #include "nsRect.h"
-#include "mozilla/gfx/Matrix.h"
 
 namespace mozilla {
 
 // NB: these must match up with pseudo-enum in nsIScreen.idl.
 enum ScreenRotation {
   ROTATION_0 = 0,
   ROTATION_90,
   ROTATION_180,
@@ -28,11 +33,59 @@ gfx::Matrix ComputeTransformForRotation(
 
 gfx::Matrix ComputeTransformForUnRotation(const nsIntRect& aBounds,
                                           ScreenRotation aRotation);
 
 nsIntRect RotateRect(nsIntRect aRect,
                      const nsIntRect& aBounds,
                      ScreenRotation aRotation);
 
+namespace widget {
+
+class WidgetUtils
+{
+public:
+
+  /**
+   * Starting at the docshell item for the passed in DOM window this looks up
+   * the docshell tree until it finds a docshell item that has a widget.
+   */
+  static already_AddRefed<nsIWidget> DOMWindowToWidget(nsIDOMWindow *aDOMWindow);
+
+  /**
+   * Compute our keyCode value (NS_VK_*) from an ASCII character.
+   */
+  static uint32_t ComputeKeyCodeFromChar(uint32_t aCharCode);
+
+  /**
+   * Get unshifted charCode and shifted charCode for aKeyCode if the keyboad
+   * layout is a Latin keyboard layout.
+   *
+   * @param aKeyCode            Our keyCode (NS_VK_*).
+   * @param aIsCapsLock         TRUE if CapsLock is Locked.  Otherwise, FALSE.
+   *                            This is used only when aKeyCode is NS_VK_[0-9].
+   * @param aUnshiftedCharCode  CharCode for aKeyCode without Shift key.
+   *                            This may be zero if aKeyCode key doesn't input
+   *                            a Latin character.
+   *                            Note that must not be nullptr.
+   * @param aShiftedCharCode    CharCode for aKeyCOde with Shift key.
+   *                            This is always 0 when aKeyCode isn't
+   *                            NS_VK_[A-Z].
+   *                            Note that must not be nullptr.
+   */
+  static void GetLatinCharCodeForKeyCode(uint32_t aKeyCode,
+                                         bool aIsCapsLock,
+                                         uint32_t* aUnshiftedCharCode,
+                                         uint32_t* aShiftedCharCode);
+
+  /**
+   * GetDeadKeyNameIndex() returns a key name index for dead key or
+   * "Unidentified".  This method can return the index from non-combining
+   * unicode character, e.g., '`' returns KEY_NAME_INDEX_DeadGrave.
+   * So, you cannot use this method for checking if the char is a dead char.
+   */
+  static KeyNameIndex GetDeadKeyNameIndex(char16_t aChar);
+};
+
+} // namespace widget
 } // namespace mozilla
 
 #endif // mozilla_WidgetUtils_h
--- a/widget/android/moz.build
+++ b/widget/android/moz.build
@@ -50,14 +50,14 @@ include('/ipc/chromium/chromium-config.m
 FINAL_LIBRARY = 'xul'
 
 LOCAL_INCLUDES += [
     '/docshell/base',
     '/dom/base',
     '/dom/system/android',
     '/netwerk/base/src',
     '/netwerk/cache',
+    '/widget',
     '/widget/android/android',
     '/widget/shared',
-    '/widget/xpwidgets',
 ]
 
 #DEFINES['DEBUG_WIDGETS'] = True
--- a/widget/cocoa/moz.build
+++ b/widget/cocoa/moz.build
@@ -70,20 +70,20 @@ if CONFIG['TARGET_CPU'] == 'x86_64':
         'ComplexTextInputPanel.mm',
     ]
 
 include('/ipc/chromium/chromium-config.mozbuild')
 
 FINAL_LIBRARY = 'xul'
 LOCAL_INCLUDES += [
     '../shared',
-    '../xpwidgets',
     '/layout/forms',
     '/layout/generic',
     '/layout/xul',
+    '/widget',
 ]
 
 RESOURCE_FILES.cursors += [
     'cursors/arrowN.png',
     'cursors/arrowN@2x.png',
     'cursors/arrowS.png',
     'cursors/arrowS@2x.png',
     'cursors/cell.png',
--- a/widget/gonk/moz.build
+++ b/widget/gonk/moz.build
@@ -66,18 +66,18 @@ include('/ipc/chromium/chromium-config.m
 
 FINAL_LIBRARY = 'xul'
 
 LOCAL_INCLUDES += [
     '/content/media/omx/mediaresourcemanager',
     '/dom/system/android',
     '/gfx/skia/trunk/include/config',
     '/gfx/skia/trunk/include/core',
+    '/widget',
     '/widget/shared',
-    '/widget/xpwidgets',
 ]
 
 DEFINES['HAVE_OFF64_T'] = True
 DEFINES['SK_BUILD_FOR_ANDROID_NDK'] = True
 
 if CONFIG['ANDROID_VERSION'] != '15':
     DEFINES['HAVE_POSIX_CLOCKS'] = True
 
--- a/widget/gtk/moz.build
+++ b/widget/gtk/moz.build
@@ -77,20 +77,20 @@ else:
     ]
 
 include('/ipc/chromium/chromium-config.mozbuild')
 
 FINAL_LIBRARY = 'xul'
 
 LOCAL_INCLUDES += [
     '../shared',
-    '../xpwidgets',
     '/layout/generic',
     '/layout/xul',
     '/other-licenses/atk-1.0',
+    '/widget',
 ]
 
 if CONFIG['MOZ_X11']:
     LOCAL_INCLUDES += [
         '../shared/x11',
     ]
 
 DEFINES['CAIRO_GFX'] = True
--- a/widget/moz.build
+++ b/widget/moz.build
@@ -1,15 +1,15 @@
 # -*- Mode: python; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40 -*-
 # vim: set filetype=python:
 # This Source Code Form is subject to the terms of the Mozilla Public
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
-DIRS += ['shared', 'xpwidgets']
+DIRS += ['shared']
 
 toolkit = CONFIG['MOZ_WIDGET_TOOLKIT']
 
 if toolkit in ('cocoa', 'qt', 'android', 'gonk'):
     DIRS += [toolkit]
 if toolkit in ('qt', 'android', 'gonk', 'gtk2', 'gtk3'):
     EXPORTS += ['nsIPrintDialogService.h']
 
@@ -89,16 +89,20 @@ if CONFIG['MOZ_METRO']:
     XPIDL_SOURCES += [
         'MetroUIUtils.idl',
         'nsIWinMetroUtils.idl',
     ]
 
 XPIDL_MODULE = 'widget'
 
 EXPORTS += [
+    'ContentHelper.h',
+    'GfxDriverInfo.h',
+    'GfxInfoBase.h',
+    'GfxInfoCollector.h',
     'InputData.h',
     'nsIDeviceContextSpec.h',
     'nsIPluginWidget.h',
     'nsIRollupListener.h',
     'nsIWidget.h',
     'nsIWidgetListener.h',
     'nsWidgetInitData.h',
     'nsWidgetsCID.h',
@@ -114,15 +118,104 @@ EXPORTS.mozilla += [
     'MiscEvents.h',
     'MouseEvents.h',
     'TextEvents.h',
     'TextRange.h',
     'TouchEvents.h',
     'WidgetUtils.h',
 ]
 
+UNIFIED_SOURCES += [
+    'ContentHelper.cpp',
+    'GfxDriverInfo.cpp',
+    'GfxInfoBase.cpp',
+    'GfxInfoCollector.cpp',
+    'GfxInfoWebGL.cpp',
+    'InputData.cpp',
+    'nsBaseAppShell.cpp',
+    'nsBaseDragService.cpp',
+    'nsBaseScreen.cpp',
+    'nsClipboardHelper.cpp',
+    'nsClipboardProxy.cpp',
+    'nsColorPickerProxy.cpp',
+    'nsContentProcessWidgetFactory.cpp',
+    'nsFilePickerProxy.cpp',
+    'nsHTMLFormatConverter.cpp',
+    'nsIdleService.cpp',
+    'nsIWidgetListener.cpp',
+    'nsPrimitiveHelpers.cpp',
+    'nsPrintOptionsImpl.cpp',
+    'nsPrintSession.cpp',
+    'nsPrintSettingsImpl.cpp',
+    'nsScreenManagerProxy.cpp',
+    'nsTransferable.cpp',
+    'nsXPLookAndFeel.cpp',
+    'PuppetWidget.cpp',
+    'ScreenProxy.cpp',
+    'SharedWidgetUtils.cpp',
+    'WidgetUtils.cpp',
+]
+
+# nsBaseWidget.cpp needs to be built separately because of name clashes in the OS X headers
+SOURCES += [
+    'nsBaseWidget.cpp',
+]
+
 if CONFIG['MOZ_INSTRUMENT_EVENT_LOOP']:
     EXPORTS.mozilla += [
         'WidgetTraceEvent.h',
     ]
 
 EXPORTS.ipc = ['nsGUIEventIPC.h']
 
+if CONFIG['MOZ_X11']:
+    UNIFIED_SOURCES += [
+        'GfxInfoX11.cpp'
+    ]
+
+if toolkit in ('cocoa', 'windows'):
+    UNIFIED_SOURCES += [
+        'nsBaseClipboard.cpp',
+    ]
+
+if toolkit in ('qt', 'gtk2', 'gtk3', 'cocoa', 'windows',
+                                    'android', 'gonk'):
+    UNIFIED_SOURCES += [
+        'nsBaseFilePicker.cpp',
+    ]
+
+if toolkit in ('qt', 'gtk2', 'gtk3', 'windows', 'cocoa'):
+    UNIFIED_SOURCES += [
+        'nsNativeTheme.cpp',
+    ]
+
+if not CONFIG['MOZ_B2G']:
+    DEFINES['MOZ_CROSS_PROCESS_IME'] = True
+
+FAIL_ON_WARNINGS = True
+
+MSVC_ENABLE_PGO = True
+
+include('/ipc/chromium/chromium-config.mozbuild')
+
+LOCAL_INCLUDES += [
+    '/layout/base',
+    '/layout/forms',
+    '/layout/generic',
+    '/layout/xul',
+    '/view',
+    '/widget/shared',
+]
+
+widget_dir = toolkit
+if widget_dir in ('gtk3', 'gtk2'):
+    # gtk3 shares includes with gtk2
+    widget_dir = 'gtk'
+
+LOCAL_INCLUDES += [
+    '/widget/%s' % widget_dir,
+]
+FINAL_LIBRARY = 'xul'
+
+if CONFIG['MOZ_ENABLE_D3D10_LAYER']:
+    DEFINES['MOZ_ENABLE_D3D10_LAYER'] = True
+
+CXXFLAGS += CONFIG['TK_CFLAGS']
rename from widget/xpwidgets/nsAppShellSingleton.h
rename to widget/nsAppShellSingleton.h
rename from widget/xpwidgets/nsBaseAppShell.cpp
rename to widget/nsBaseAppShell.cpp
rename from widget/xpwidgets/nsBaseAppShell.h
rename to widget/nsBaseAppShell.h
rename from widget/xpwidgets/nsBaseClipboard.cpp
rename to widget/nsBaseClipboard.cpp
rename from widget/xpwidgets/nsBaseClipboard.h
rename to widget/nsBaseClipboard.h
rename from widget/xpwidgets/nsBaseDragService.cpp
rename to widget/nsBaseDragService.cpp
rename from widget/xpwidgets/nsBaseDragService.h
rename to widget/nsBaseDragService.h
rename from widget/xpwidgets/nsBaseFilePicker.cpp
rename to widget/nsBaseFilePicker.cpp
rename from widget/xpwidgets/nsBaseFilePicker.h
rename to widget/nsBaseFilePicker.h
rename from widget/xpwidgets/nsBaseScreen.cpp
rename to widget/nsBaseScreen.cpp
rename from widget/xpwidgets/nsBaseScreen.h
rename to widget/nsBaseScreen.h
rename from widget/xpwidgets/nsBaseWidget.cpp
rename to widget/nsBaseWidget.cpp
rename from widget/xpwidgets/nsBaseWidget.h
rename to widget/nsBaseWidget.h
rename from widget/xpwidgets/nsClipboardHelper.cpp
rename to widget/nsClipboardHelper.cpp
rename from widget/xpwidgets/nsClipboardHelper.h
rename to widget/nsClipboardHelper.h
rename from widget/xpwidgets/nsClipboardProxy.cpp
rename to widget/nsClipboardProxy.cpp
rename from widget/xpwidgets/nsClipboardProxy.h
rename to widget/nsClipboardProxy.h
rename from widget/xpwidgets/nsColorPickerProxy.cpp
rename to widget/nsColorPickerProxy.cpp
rename from widget/xpwidgets/nsColorPickerProxy.h
rename to widget/nsColorPickerProxy.h
rename from widget/xpwidgets/nsContentProcessWidgetFactory.cpp
rename to widget/nsContentProcessWidgetFactory.cpp
rename from widget/xpwidgets/nsFilePickerProxy.cpp
rename to widget/nsFilePickerProxy.cpp
rename from widget/xpwidgets/nsFilePickerProxy.h
rename to widget/nsFilePickerProxy.h
rename from widget/xpwidgets/nsHTMLFormatConverter.cpp
rename to widget/nsHTMLFormatConverter.cpp
rename from widget/xpwidgets/nsHTMLFormatConverter.h
rename to widget/nsHTMLFormatConverter.h
rename from widget/xpwidgets/nsIWidgetListener.cpp
rename to widget/nsIWidgetListener.cpp
rename from widget/xpwidgets/nsIdleService.cpp
rename to widget/nsIdleService.cpp
rename from widget/xpwidgets/nsIdleService.h
rename to widget/nsIdleService.h
rename from widget/xpwidgets/nsNativeTheme.cpp
rename to widget/nsNativeTheme.cpp
rename from widget/xpwidgets/nsNativeTheme.h
rename to widget/nsNativeTheme.h
rename from widget/xpwidgets/nsPrimitiveHelpers.cpp
rename to widget/nsPrimitiveHelpers.cpp
rename from widget/xpwidgets/nsPrimitiveHelpers.h
rename to widget/nsPrimitiveHelpers.h
rename from widget/xpwidgets/nsPrintOptionsImpl.cpp
rename to widget/nsPrintOptionsImpl.cpp
rename from widget/xpwidgets/nsPrintOptionsImpl.h
rename to widget/nsPrintOptionsImpl.h
rename from widget/xpwidgets/nsPrintSession.cpp
rename to widget/nsPrintSession.cpp
rename from widget/xpwidgets/nsPrintSession.h
rename to widget/nsPrintSession.h
rename from widget/xpwidgets/nsPrintSettingsImpl.cpp
rename to widget/nsPrintSettingsImpl.cpp
rename from widget/xpwidgets/nsPrintSettingsImpl.h
rename to widget/nsPrintSettingsImpl.h
rename from widget/xpwidgets/nsScreenManagerProxy.cpp
rename to widget/nsScreenManagerProxy.cpp
rename from widget/xpwidgets/nsScreenManagerProxy.h
rename to widget/nsScreenManagerProxy.h
rename from widget/xpwidgets/nsTransferable.cpp
rename to widget/nsTransferable.cpp
rename from widget/xpwidgets/nsTransferable.h
rename to widget/nsTransferable.h
rename from widget/xpwidgets/nsXPLookAndFeel.cpp
rename to widget/nsXPLookAndFeel.cpp
rename from widget/xpwidgets/nsXPLookAndFeel.h
rename to widget/nsXPLookAndFeel.h
--- a/widget/qt/moz.build
+++ b/widget/qt/moz.build
@@ -33,17 +33,17 @@ if CONFIG['NS_PRINTING']:
     ]
 
 include('/ipc/chromium/chromium-config.mozbuild')
 
 FINAL_LIBRARY = 'xul'
 
 LOCAL_INCLUDES += [
     '../shared',
-    '/widget/xpwidgets',
+    '/widget',
 ]
 
 if CONFIG['MOZ_X11']:
     LOCAL_INCLUDES += [
         '../shared/x11',
     ]
 
 #DEFINES['DEBUG_WIDGETS'] = True
deleted file mode 100644
--- a/widget/shared/WidgetUtils.h
+++ /dev/null
@@ -1,67 +0,0 @@
-/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-#ifndef __mozilla_widget_WidgetUtils_h__
-#define __mozilla_widget_WidgetUtils_h__
-
-#include "nsCOMPtr.h"
-#include "nsIWidget.h"
-#include "nsPIDOMWindow.h"
-#include "nsIDOMWindow.h"
-#include "mozilla/EventForwards.h"
-
-namespace mozilla {
-namespace widget {
-
-class WidgetUtils
-{
-public:
-
-  /**
-   * Starting at the docshell item for the passed in DOM window this looks up
-   * the docshell tree until it finds a docshell item that has a widget.
-   */
-  static already_AddRefed<nsIWidget> DOMWindowToWidget(nsIDOMWindow *aDOMWindow);
-
-  /**
-   * Compute our keyCode value (NS_VK_*) from an ASCII character.
-   */
-  static uint32_t ComputeKeyCodeFromChar(uint32_t aCharCode);
-
-  /**
-   * Get unshifted charCode and shifted charCode for aKeyCode if the keyboad
-   * layout is a Latin keyboard layout.
-   *
-   * @param aKeyCode            Our keyCode (NS_VK_*).
-   * @param aIsCapsLock         TRUE if CapsLock is Locked.  Otherwise, FALSE.
-   *                            This is used only when aKeyCode is NS_VK_[0-9].
-   * @param aUnshiftedCharCode  CharCode for aKeyCode without Shift key.
-   *                            This may be zero if aKeyCode key doesn't input
-   *                            a Latin character.
-   *                            Note that must not be nullptr.
-   * @param aShiftedCharCode    CharCode for aKeyCOde with Shift key.
-   *                            This is always 0 when aKeyCode isn't
-   *                            NS_VK_[A-Z].
-   *                            Note that must not be nullptr.
-   */
-  static void GetLatinCharCodeForKeyCode(uint32_t aKeyCode,
-                                         bool aIsCapsLock,
-                                         uint32_t* aUnshiftedCharCode,
-                                         uint32_t* aShiftedCharCode);
-
-  /**
-   * GetDeadKeyNameIndex() returns a key name index for dead key or
-   * "Unidentified".  This method can return the index from non-combining
-   * unicode character, e.g., '`' returns KEY_NAME_INDEX_DeadGrave.
-   * So, you cannot use this method for checking if the char is a dead char.
-   */
-  static KeyNameIndex GetDeadKeyNameIndex(char16_t aChar);
-};
-
-} // namespace widget
-} // namespace mozilla
-
-#endif
--- a/widget/shared/moz.build
+++ b/widget/shared/moz.build
@@ -8,17 +8,16 @@ if CONFIG['MOZ_X11']:
     DIRS += ['x11']
 
 EXPORTS.mozilla += [
     'VsyncDispatcher.h',
 ]
 
 UNIFIED_SOURCES += [
     'nsShmImage.cpp',
-    'SharedWidgetUtils.cpp',
     'VsyncDispatcher.cpp',
     'WidgetEventImpl.cpp',
 ]
 
 include('/ipc/chromium/chromium-config.mozbuild')
 
 FAIL_ON_WARNINGS = True
 
--- a/widget/windows/moz.build
+++ b/widget/windows/moz.build
@@ -88,20 +88,20 @@ if CONFIG['NS_ENABLE_TSF']:
 MSVC_ENABLE_PGO = True
 
 include('/ipc/chromium/chromium-config.mozbuild')
 
 FINAL_LIBRARY = 'xul'
 
 LOCAL_INCLUDES += [
     '../shared',
-    '../xpwidgets',
     '/layout/generic',
     '/layout/xul',
     '/toolkit/xre',
+    '/widget',
     '/xpcom/base',
 ]
 
 DEFINES['MOZ_UNICODE'] = True
 
 for var in ('MOZ_ENABLE_D3D9_LAYER', 'MOZ_ENABLE_D3D10_LAYER'):
     if CONFIG[var]:
         DEFINES[var] = True
--- a/widget/windows/winrt/moz.build
+++ b/widget/windows/winrt/moz.build
@@ -32,20 +32,20 @@ EXPORTS.mozilla.widget += [
 
 include('/ipc/chromium/chromium-config.mozbuild')
 
 FINAL_LIBRARY = 'xul'
 
 LOCAL_INCLUDES += [
     '../',
     '../../shared',
-    '../../xpwidgets',
     '/layout/generic',
     '/layout/xul',
     '/toolkit/xre',
+    '/widget',
     '/xpcom/base',
 ]
 
 DEFINES['MOZ_UNICODE'] = True
 
 for var in ('MOZ_ENABLE_D3D9_LAYER', 'MOZ_ENABLE_D3D10_LAYER'):
     if CONFIG[var]:
         DEFINES[var] = True
deleted file mode 100644
--- a/widget/xpwidgets/moz.build
+++ /dev/null
@@ -1,101 +0,0 @@
-# -*- Mode: python; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40 -*-
-# vim: set filetype=python:
-# This Source Code Form is subject to the terms of the Mozilla Public
-# License, v. 2.0. If a copy of the MPL was not distributed with this
-# file, You can obtain one at http://mozilla.org/MPL/2.0/.
-
-EXPORTS += [
-    'ContentHelper.h',
-    'GfxDriverInfo.h',
-    'GfxInfoBase.h',
-    'GfxInfoCollector.h',
-]
-
-UNIFIED_SOURCES += [
-    'ContentHelper.cpp',
-    'GfxDriverInfo.cpp',
-    'GfxInfoBase.cpp',
-    'GfxInfoCollector.cpp',
-    'GfxInfoWebGL.cpp',
-    'InputData.cpp',
-    'nsBaseAppShell.cpp',
-    'nsBaseDragService.cpp',
-    'nsBaseScreen.cpp',
-    'nsClipboardHelper.cpp',
-    'nsClipboardProxy.cpp',
-    'nsColorPickerProxy.cpp',
-    'nsContentProcessWidgetFactory.cpp',
-    'nsFilePickerProxy.cpp',
-    'nsHTMLFormatConverter.cpp',
-    'nsIdleService.cpp',
-    'nsIWidgetListener.cpp',
-    'nsPrimitiveHelpers.cpp',
-    'nsPrintOptionsImpl.cpp',
-    'nsPrintSession.cpp',
-    'nsPrintSettingsImpl.cpp',
-    'nsScreenManagerProxy.cpp',
-    'nsTransferable.cpp',
-    'nsXPLookAndFeel.cpp',
-    'PuppetWidget.cpp',
-    'ScreenProxy.cpp',
-    'WidgetUtils.cpp',
-]
-
-# nsBaseWidget.cpp needs to be built separately because of name clashes in the OS X headers
-SOURCES += [
-    'nsBaseWidget.cpp',
-]
-
-if CONFIG['MOZ_X11']:
-    UNIFIED_SOURCES += [
-        'GfxInfoX11.cpp'
-    ]
-
-if CONFIG['MOZ_WIDGET_TOOLKIT'] in ('cocoa', 'windows'):
-    UNIFIED_SOURCES += [
-        'nsBaseClipboard.cpp',
-    ]
-
-if CONFIG['MOZ_WIDGET_TOOLKIT'] in ('qt', 'gtk2', 'gtk3', 'cocoa', 'windows',
-                                    'android', 'gonk'):
-    UNIFIED_SOURCES += [
-        'nsBaseFilePicker.cpp',
-    ]
-
-if CONFIG['MOZ_WIDGET_TOOLKIT'] in ('qt', 'gtk2', 'gtk3', 'windows', 'cocoa'):
-    UNIFIED_SOURCES += [
-        'nsNativeTheme.cpp',
-    ]
-
-if not CONFIG['MOZ_B2G']:
-    DEFINES['MOZ_CROSS_PROCESS_IME'] = True
-
-FAIL_ON_WARNINGS = True
-
-MSVC_ENABLE_PGO = True
-
-include('/ipc/chromium/chromium-config.mozbuild')
-
-LOCAL_INCLUDES += [
-    '../shared',
-    '/layout/base',
-    '/layout/forms',
-    '/layout/generic',
-    '/layout/xul',
-    '/view',
-]
-
-widget_dir = CONFIG['MOZ_WIDGET_TOOLKIT']
-if widget_dir in ('gtk3', 'gtk2'):
-    # gtk3 shares includes with gtk2
-    widget_dir = 'gtk'
-
-LOCAL_INCLUDES += [
-    '../%s' % widget_dir,
-]
-FINAL_LIBRARY = 'xul'
-
-if CONFIG['MOZ_ENABLE_D3D10_LAYER']:
-    DEFINES['MOZ_ENABLE_D3D10_LAYER'] = True
-
-CXXFLAGS += CONFIG['TK_CFLAGS']