Merging mozilla-central into holly
authorMike Conley <mconley@mozilla.com>
Thu, 21 Nov 2013 15:42:19 -0500
changeset 170864 a5f367ff70fe3a8dc06260be0264aaec7c9bf486
parent 170765 29e642bbcc0685133ed58d166ee1c6d706f6a889 (current diff)
parent 170863 d316d1dd062efe054d6aa456f380ccb11bcf0aa8 (diff)
child 170927 4e828a33185eb276b86139eac2af2e4c9ff76e8c
push id3224
push userlsblakk@mozilla.com
push dateTue, 04 Feb 2014 01:06:49 +0000
treeherdermozilla-beta@60c04d0987f1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
milestone28.0a1
Merging mozilla-central into holly
browser/components/moz.build
embedding/browser/build/Makefile.in
embedding/components/build/Makefile.in
embedding/components/printingui/src/mac/Makefile.in
embedding/components/printingui/src/os2/Makefile.in
embedding/components/printingui/src/unixshared/Makefile.in
embedding/components/printingui/src/win/Makefile.in
ipc/keystore/Makefile.in
layout/style/nsCSSProps.cpp
memory/replace/dummy/Makefile.in
parser/htmlparser/src/Makefile.in
toolkit/components/telemetry/Histograms.json
toolkit/library/winvccorlib/Makefile.in
--- a/accessible/moz.build
+++ b/accessible/moz.build
@@ -2,10 +2,8 @@
 # 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 += ['public', 'src']
 TEST_DIRS += ['tests']
 
-MODULE = 'accessibility'
-
--- a/accessible/public/ia2/Makefile.in
+++ b/accessible/public/ia2/Makefile.in
@@ -5,18 +5,16 @@
 DEFFILE       = $(win_srcdir)/IA2Marshal.def
 
 IA2DIR        = $(topsrcdir)/other-licenses/ia2
 
 DEFINES       += -DREGISTER_PROXY_DLL
 
 GARBAGE       += $(MIDL_GENERATED_FILES)
 
-FORCE_SHARED_LIB = 1
-
 # Please keep this list in sync with the moz.build file until the rest of this
 # Makefile is ported over.
 MIDL_INTERFACES = \
   Accessible2.idl \
   Accessible2_2.idl \
   AccessibleAction.idl \
   AccessibleApplication.idl \
   AccessibleComponent.idl \
--- a/accessible/public/ia2/moz.build
+++ b/accessible/public/ia2/moz.build
@@ -1,9 +1,9 @@
 # -*- 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/.
 
-MODULE = 'accessibility'
 LIBRARY_NAME = 'IA2Marshal'
 
+FORCE_SHARED_LIB = True
--- a/accessible/public/moz.build
+++ b/accessible/public/moz.build
@@ -30,14 +30,14 @@ XPIDL_SOURCES += [
     'nsIAccessibleText.idl',
     'nsIAccessibleTextChangeEvent.idl',
     'nsIAccessibleTypes.idl',
     'nsIAccessibleValue.idl',
     'nsIAccessibleVirtualCursorChangeEvent.idl',
     'nsIXBLAccessible.idl',
 ]
 
-MODULE = 'accessibility'
+XPIDL_MODULE = 'accessibility'
 
 EXPORTS += [
     'nsIAccessibilityService.h',
 ]
 
--- a/accessible/public/msaa/Makefile.in
+++ b/accessible/public/msaa/Makefile.in
@@ -3,18 +3,16 @@
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
 DEFFILE = $(win_srcdir)/AccessibleMarshal.def
 
 DEFINES += -DREGISTER_PROXY_DLL
 
 GARBAGE += $(MIDL_GENERATED_FILES) done_gen dlldata.c
 
-FORCE_SHARED_LIB = 1
-
 MIDL_GENERATED_FILES = \
 	ISimpleDOMNode.h \
 	ISimpleDOMNode_p.c \
 	ISimpleDOMNode_i.c \
 	ISimpleDOMDocument.h \
 	ISimpleDOMDocument_p.c \
 	ISimpleDOMDocument_i.c \
 	ISimpleDOMText.h \
--- a/accessible/public/msaa/moz.build
+++ b/accessible/public/msaa/moz.build
@@ -1,19 +1,19 @@
 # -*- 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/.
 
-MODULE = 'accessibility'
-
 LIBRARY_NAME = 'AccessibleMarshal'
 
 GENERATED_SOURCES += [
     'dlldata.c',
     'ISimpleDOMDocument_i.c',
     'ISimpleDOMDocument_p.c',
     'ISimpleDOMNode_i.c',
     'ISimpleDOMNode_p.c',
     'ISimpleDOMText_i.c',
     'ISimpleDOMText_p.c',
 ]
+
+FORCE_SHARED_LIB = True
--- a/accessible/src/atk/Makefile.in
+++ b/accessible/src/atk/Makefile.in
@@ -1,13 +1,12 @@
 # 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/.
 
-EXPORT_LIBRARY = ..
 include $(topsrcdir)/config/rules.mk
 
 ifdef MOZ_ENABLE_GTK
 CFLAGS      += $(TK_CFLAGS)
 CXXFLAGS    += $(TK_CFLAGS)
 endif
 
 ifdef MOZ_ENABLE_DBUS
--- a/accessible/src/atk/moz.build
+++ b/accessible/src/atk/moz.build
@@ -1,16 +1,14 @@
 # -*- 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/.
 
-MODULE = 'accessibility'
-
 EXPORTS.mozilla.a11y += [
     'AccessibleWrap.h',
     'HyperTextAccessibleWrap.h',
 ]
 
 SOURCES += [
     'AccessibleWrap.cpp',
     'ApplicationAccessibleWrap.cpp',
@@ -28,21 +26,18 @@ SOURCES += [
     'nsMaiInterfaceTable.cpp',
     'nsMaiInterfaceText.cpp',
     'nsMaiInterfaceValue.cpp',
     'Platform.cpp',
     'RootAccessibleWrap.cpp',
     'UtilInterface.cpp',
 ]
 
-LIBRARY_NAME = 'accessibility_toolkit_s'
-
-LIBXUL_LIBRARY = True
-
 LOCAL_INCLUDES += [
     '../base',
     '../generic',
     '../html',
     '../xpcom',
     '../xul',
     '/other-licenses/atk-1.0',
 ]
 
+FINAL_LIBRARY = 'xul'
--- a/accessible/src/base/moz.build
+++ b/accessible/src/base/moz.build
@@ -1,18 +1,16 @@
 # -*- 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/.
 
 include('../shared.mozbuild')
 
-MODULE = 'accessibility'
-
 EXPORTS += [
     'AccEvent.h',
     'nsAccessibilityService.h'
 ]
 
 EXPORTS.mozilla.a11y += [
     'AccTypes.h',
     'DocManager.h',
@@ -55,20 +53,16 @@ UNIFIED_SOURCES += [
     'TreeWalker.cpp',
 ]
 
 if a11y_log:
     UNIFIED_SOURCES += [
         'Logging.cpp',
     ]
 
-LIBRARY_NAME = 'accessibility_base_s'
-
-LIBXUL_LIBRARY = True
-
 LOCAL_INCLUDES += [
     '../../../content/xbl/src',
     '../../../ipc/chromium/src',
     '../../../layout/generic',
     '../../../layout/style',
     '../../../layout/svg',
     '../../../layout/xul/base/src',
     '../../../layout/xul/tree/',
@@ -90,8 +84,10 @@ elif CONFIG['MOZ_WIDGET_TOOLKIT'] == 'wi
 elif CONFIG['MOZ_WIDGET_TOOLKIT'] == 'cocoa':
     LOCAL_INCLUDES += [
         '../mac',
     ]
 else:
     LOCAL_INCLUDES += [
         '../other',
     ]
+
+FINAL_LIBRARY = 'xul'
--- a/accessible/src/generic/moz.build
+++ b/accessible/src/generic/moz.build
@@ -1,16 +1,14 @@
 # -*- 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/.
 
-MODULE = 'accessibility'
-
 EXPORTS.mozilla.a11y += [
     'Accessible.h',
     'DocAccessible.h',
     'HyperTextAccessible.h',
 ]
 
 UNIFIED_SOURCES += [
     'Accessible.cpp',
@@ -22,20 +20,16 @@ UNIFIED_SOURCES += [
     'HyperTextAccessible.cpp',
     'ImageAccessible.cpp',
     'OuterDocAccessible.cpp',
     'RootAccessible.cpp',
     'TableCellAccessible.cpp',
     'TextLeafAccessible.cpp',
 ]
 
-LIBRARY_NAME = 'accessibility_generic_s'
-
-LIBXUL_LIBRARY = True
-
 LOCAL_INCLUDES += [
     '../../../layout/generic',
     '../../../layout/xul/base/src',
     '../base',
     '../html',
     '../xpcom',
     '../xul',
 ]
@@ -51,8 +45,10 @@ elif CONFIG['MOZ_WIDGET_TOOLKIT'] == 'wi
 elif CONFIG['MOZ_WIDGET_TOOLKIT'] == 'cocoa':
     LOCAL_INCLUDES += [
         '../mac',
     ]
 else:
     LOCAL_INCLUDES += [
         '../other',
     ]
+
+FINAL_LIBRARY = 'xul'
--- a/accessible/src/html/moz.build
+++ b/accessible/src/html/moz.build
@@ -1,31 +1,25 @@
 # -*- 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/.
 
-MODULE = 'accessibility'
-
 UNIFIED_SOURCES += [
     'HTMLCanvasAccessible.cpp',
     'HTMLElementAccessibles.cpp',
     'HTMLFormControlAccessible.cpp',
     'HTMLImageMapAccessible.cpp',
     'HTMLLinkAccessible.cpp',
     'HTMLListAccessible.cpp',
     'HTMLSelectAccessible.cpp',
     'HTMLTableAccessible.cpp',
 ]
 
-LIBRARY_NAME = 'accessibility_html_s'
-
-LIBXUL_LIBRARY = True
-
 LOCAL_INCLUDES += [
     '../../../layout/generic',
     '../../../layout/tables',
     '../../../layout/xul/base/src',
     '../base',
     '../generic',
     '../xpcom',
 ]
@@ -42,8 +36,10 @@ elif CONFIG['MOZ_WIDGET_TOOLKIT'] == 'wi
 elif CONFIG['MOZ_WIDGET_TOOLKIT'] == 'cocoa':
     LOCAL_INCLUDES += [
         '../mac',
     ]
 else:
     LOCAL_INCLUDES += [
         '../other',
     ]
+
+FINAL_LIBRARY = 'xul'
--- a/accessible/src/mac/Makefile.in
+++ b/accessible/src/mac/Makefile.in
@@ -1,10 +1,9 @@
 # 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/.
 
-EXPORT_LIBRARY = ..
 include $(topsrcdir)/config/rules.mk
 
 ifneq ($(A11Y_LOG),0)
   DEFINES += -DA11Y_LOG
 endif
--- a/accessible/src/mac/moz.build
+++ b/accessible/src/mac/moz.build
@@ -1,45 +1,40 @@
 # -*- 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/.
 
-MODULE = 'accessibility'
-
 EXPORTS += [
     'mozAccessibleProtocol.h',
 ]
 
 EXPORTS.mozilla.a11y += [
     'AccessibleWrap.h',
     'HyperTextAccessibleWrap.h',
 ]
 
-LIBRARY_NAME = 'accessibility_toolkit_s'
-
 UNIFIED_SOURCES += [
     'AccessibleWrap.mm',
     'DocAccessibleWrap.mm',
     'MacUtils.mm',
     'mozAccessible.mm',
     'mozActionElements.mm',
     'mozDocAccessible.mm',
     'mozHTMLAccessible.mm',
     'mozTextAccessible.mm',
     'Platform.mm',
     'RootAccessibleWrap.mm',
 ]
 
-LIBXUL_LIBRARY = True
-
 LOCAL_INCLUDES += [
     '../base',
     '../generic',
     '../html',
     '../xul',
     '/layout/generic',
     '/layout/xul/base/src',
     '/widget/cocoa',
     '/widget/xpwidgets',
 ]
 
+FINAL_LIBRARY = 'xul'
--- a/accessible/src/other/Makefile.in
+++ b/accessible/src/other/Makefile.in
@@ -1,10 +1,9 @@
 # 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/.
 
-EXPORT_LIBRARY = ..
 include $(topsrcdir)/config/rules.mk
 
 ifneq ($(A11Y_LOG),0)
   DEFINES += -DA11Y_LOG
 endif
--- a/accessible/src/other/moz.build
+++ b/accessible/src/other/moz.build
@@ -1,29 +1,24 @@
 # -*- 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/.
 
-MODULE = 'accessibility'
-
 EXPORTS.mozilla.a11y += [
     'AccessibleWrap.h',
     'HyperTextAccessibleWrap.h',
 ]
 
 SOURCES += [
     'AccessibleWrap.cpp',
     'Platform.cpp',
 ]
 
-LIBRARY_NAME = 'accessibility_toolkit_s'
-
-LIBXUL_LIBRARY = True
-
 LOCAL_INCLUDES += [
     '../base',
     '../generic',
     '../html',
     '../xul',
 ]
 
+FINAL_LIBRARY = 'xul'
--- a/accessible/src/windows/ia2/moz.build
+++ b/accessible/src/windows/ia2/moz.build
@@ -1,16 +1,14 @@
 # -*- 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/.
 
-MODULE = 'accessibility'
-
 EXPORTS += [
     'ia2Accessible.h',
     'ia2AccessibleAction.h',
     'ia2AccessibleComponent.h',
     'ia2AccessibleEditableText.h',
     'ia2AccessibleHyperlink.h',
     'ia2AccessibleHypertext.h',
     'ia2AccessibleText.h',
@@ -27,23 +25,18 @@ SOURCES += [
     'ia2AccessibleImage.cpp',
     'ia2AccessibleRelation.cpp',
     'ia2AccessibleTable.cpp',
     'ia2AccessibleTableCell.cpp',
     'ia2AccessibleText.cpp',
     'ia2AccessibleValue.cpp',
 ]
 
-LIBXUL_LIBRARY = True
-
 LOCAL_INCLUDES += [
     '../../base',
     '../../generic',
     '../../html',
     '../../xpcom',
     '../../xul',
     '../msaa',
 ]
 
-LIBRARY_NAME = 'accessibility_toolkit_ia2_s'
-
-EXPORT_LIBRARY = True
-
+FINAL_LIBRARY = 'xul'
--- a/accessible/src/windows/msaa/moz.build
+++ b/accessible/src/windows/msaa/moz.build
@@ -1,16 +1,14 @@
 # -*- 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/.
 
-MODULE = 'accessibility'
-
 EXPORTS += [
     'IUnknownImpl.h',
 ]
 
 EXPORTS.mozilla.a11y += [
     'AccessibleWrap.h',
     'Compatibility.h',
     'HyperTextAccessibleWrap.h',
@@ -37,29 +35,24 @@ SOURCES += [
 
 if CONFIG['MOZ_XUL']:
     SOURCES += [
         'XULListboxAccessibleWrap.cpp',
         'XULMenuAccessibleWrap.cpp',
         'XULTreeGridAccessibleWrap.cpp',
     ]
 
-LIBXUL_LIBRARY = True
-
 LOCAL_INCLUDES += [
     '../../../../content/base/src',
     '../../../../content/events/src',
     '../../base',
     '../../generic',
     '../../html',
     '../../xpcom',
     '../../xul',
     '../ia2',
     '../sdn',
     '../uia',
 ]
 
-LIBRARY_NAME = 'accessibility_toolkit_msaa_s'
-
-EXPORT_LIBRARY = True
-
 include('/ipc/chromium/chromium-config.mozbuild')
 
+FINAL_LIBRARY = 'xul'
--- a/accessible/src/windows/sdn/moz.build
+++ b/accessible/src/windows/sdn/moz.build
@@ -1,33 +1,26 @@
 # -*- 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/.
 
-MODULE = 'accessibility'
-
 SOURCES += [
     'sdnAccessible.cpp',
     'sdnDocAccessible.cpp',
     'sdnTextAccessible.cpp',
 ]
 
-LIBXUL_LIBRARY = True
-
 LOCAL_INCLUDES += [
     '../../base',
     '../../generic',
     '../../html',
     '../../xpcom',
     '../../xul',
     '../msaa',
 ]
 
 # The midl generated code include Windows headers which defines min and max
 # macros which conflicts with std::min/max.  Suppress the macros:
 DEFINES['NOMINMAX'] = True
 
-LIBRARY_NAME = 'accessibility_toolkit_sdn_s'
-
-EXPORT_LIBRARY = True
-
+FINAL_LIBRARY = 'xul'
--- a/accessible/src/windows/uia/Makefile.in
+++ b/accessible/src/windows/uia/Makefile.in
@@ -1,14 +1,12 @@
 # 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/.
 
-EXPORT_LIBRARY = ..
-
 # The midl generated code include Windows headers which defines min and max
 # macros which conflicts with std::min/max.  Suppress the macros:
 OS_CXXFLAGS += -DNOMINMAX
 
 include $(topsrcdir)/config/rules.mk
 
 ifdef A11Y_LOG
   DEFINES += -DA11Y_LOG
--- a/accessible/src/windows/uia/moz.build
+++ b/accessible/src/windows/uia/moz.build
@@ -1,25 +1,20 @@
 # -*- 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/.
 
-MODULE = 'accessibility'
-
 SOURCES += [
     'uiaRawElmProvider.cpp',
 ]
 
-LIBXUL_LIBRARY = True
-
 LOCAL_INCLUDES += [
     '../../base',
     '../../generic',
     '../../html',
     '../../xpcom',
     '../../xul',
     '../msaa',
 ]
 
-LIBRARY_NAME = 'accessibility_toolkit_uia_s'
-
+FINAL_LIBRARY = 'xul'
--- a/accessible/src/xpcom/moz.build
+++ b/accessible/src/xpcom/moz.build
@@ -1,16 +1,14 @@
 # -*- 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/.
 
-MODULE = 'accessibility'
-
 EXPORTS += [
     'xpcAccessibleHyperText.h',
     'xpcAccessibleSelectable.h',
 ]
 
 UNIFIED_SOURCES += [
     'nsAccessibleRelation.cpp',
     'xpcAccessibleHyperText.cpp',
@@ -18,20 +16,16 @@ UNIFIED_SOURCES += [
     'xpcAccessibleTable.cpp',
     'xpcAccessibleTableCell.cpp',
 ]
 
 GENERATED_SOURCES += [
     'xpcAccEvents.cpp',
 ]
 
-LIBRARY_NAME = 'accessibility_xpcom_s'
-
-LIBXUL_LIBRARY = True
-
 LOCAL_INCLUDES += [
     '../base',
     '../generic',
 ]
 
 if CONFIG['MOZ_ENABLE_GTK']:
     LOCAL_INCLUDES += [
         '../atk',
@@ -43,8 +37,10 @@ elif CONFIG['MOZ_WIDGET_TOOLKIT'] == 'wi
 elif CONFIG['MOZ_WIDGET_TOOLKIT'] == 'cocoa':
     LOCAL_INCLUDES += [
         '../mac',
     ]
 else:
     LOCAL_INCLUDES += [
         '../other',
     ]
+
+FINAL_LIBRARY = 'xul'
--- a/accessible/src/xul/moz.build
+++ b/accessible/src/xul/moz.build
@@ -1,35 +1,29 @@
 # -*- 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/.
 
-MODULE = 'accessibility'
-
 UNIFIED_SOURCES += [
     'XULAlertAccessible.cpp',
     'XULColorPickerAccessible.cpp',
     'XULComboboxAccessible.cpp',
     'XULElementAccessibles.cpp',
     'XULFormControlAccessible.cpp',
     'XULListboxAccessible.cpp',
     'XULMenuAccessible.cpp',
     'XULSelectControlAccessible.cpp',
     'XULSliderAccessible.cpp',
     'XULTabAccessible.cpp',
     'XULTreeAccessible.cpp',
     'XULTreeGridAccessible.cpp',
 ]
 
-LIBRARY_NAME = 'accessibility_xul_s'
-
-LIBXUL_LIBRARY = True
-
 LOCAL_INCLUDES += [
     '../../../layout/generic',
     '../../../layout/xul/base/src',
     '../../../layout/xul/tree//',
     '../base',
     '../generic',
     '../html',
     '../xpcom',
@@ -47,8 +41,10 @@ elif CONFIG['MOZ_WIDGET_TOOLKIT'] == 'wi
 elif CONFIG['MOZ_WIDGET_TOOLKIT'] == 'cocoa':
     LOCAL_INCLUDES += [
         '../mac',
     ]
 else:
     LOCAL_INCLUDES += [
         '../other',
     ]
+
+FINAL_LIBRARY = 'xul'
--- a/accessible/tests/moz.build
+++ b/accessible/tests/moz.build
@@ -1,10 +1,8 @@
 # -*- 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 += ['mochitest']
 
-MODULE = 'test_accessibility'
-
--- a/b2g/components/moz.build
+++ b/b2g/components/moz.build
@@ -1,18 +1,16 @@
 # -*- 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/.
 
 TEST_DIRS += ['test']
 
-MODULE = 'B2GComponents'
-
 EXTRA_COMPONENTS += [
     'ActivitiesGlue.js',
     'AlertsService.js',
     'B2GAboutRedirector.js',
     'ContentHandler.js',
     'ContentPermissionPrompt.js',
     'FilePicker.js',
     'HelperAppDialog.js',
--- a/b2g/components/test/moz.build
+++ b/b2g/components/test/moz.build
@@ -1,12 +1,7 @@
 # -*- 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/.
 
-MODULE = 'B2GComponents'
-
 XPCSHELL_TESTS_MANIFESTS += ['unit/xpcshell.ini']
-
-FAIL_ON_WARNINGS = True
-
--- a/browser/components/about/moz.build
+++ b/browser/components/about/moz.build
@@ -1,19 +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/.
 
-MODULE = 'browserabout'
-
 EXPORTS.mozilla.browser += [
     'AboutRedirector.h',
 ]
 
 SOURCES += [
     'AboutRedirector.cpp',
 ]
 
-LIBRARY_NAME = 'browserabout_s'
-
-FORCE_STATIC_LIB = True
+FINAL_LIBRARY = 'browsercomps'
--- a/browser/components/build/Makefile.in
+++ b/browser/components/build/Makefile.in
@@ -1,53 +1,39 @@
 # 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/.
 
-SHORT_LIBNAME = brwsrcmp
 MODULE_NAME = nsBrowserCompsModule
-FORCE_SHARED_LIB = 1
 
 ifeq ($(OS_ARCH),WINNT)
 OS_LIBS	+= $(call EXPAND_LIBNAME,ole32 shell32 shlwapi)
 endif
 
 LOCAL_INCLUDES = \
 	-I$(srcdir)/../shell/src \
 	-I$(srcdir)/../feeds/src \
 	-I$(srcdir)/../about \
 	-I$(srcdir)/../dirprovider \
 	$(NULL)
 
 ifeq ($(OS_ARCH),WINNT)
 OS_LIBS += $(call EXPAND_LIBNAME,version)
 endif
 
-SHARED_LIBRARY_LIBS = \
-	../feeds/src/$(LIB_PREFIX)browser_feeds_s.$(LIB_SUFFIX) \
-	../about/$(LIB_PREFIX)browserabout_s.$(LIB_SUFFIX) \
-	../dirprovider/$(LIB_PREFIX)browserdir_s.$(LIB_SUFFIX) \
-	$(NULL)
-
-ifneq (,$(filter windows cocoa gtk2 gtk3, $(MOZ_WIDGET_TOOLKIT)))
-SHARED_LIBRARY_LIBS += ../shell/src/$(LIB_PREFIX)shellservice_s.$(LIB_SUFFIX)
-endif
-
 EXTRA_DSO_LDOPTS += \
-	$(call EXPAND_LIBNAME_PATH,unicharutil_external_s,$(LIBXUL_DIST)/lib) \
-	$(XPCOM_STATICRUNTIME_GLUE_LDOPTS) \
+	$(XPCOM_GLUE_LDOPTS) \
 	$(MOZ_COMPONENT_LIBS) \
 	$(NULL)
 
 ifdef JS_SHARED_LIBRARY
 EXTRA_DSO_LDOPTS += $(MOZ_JS_LIBS)
 endif
 
 LOCAL_INCLUDES += -I$(srcdir)/../migration/src
-SHARED_LIBRARY_LIBS += ../migration/src/$(LIB_PREFIX)migration_s.$(LIB_SUFFIX)
 
 # Mac: Need to link with CoreFoundation for Mac Migrators (PList reading code)
 # GTK2: Need to link with glib for GNOME shell service
 ifneq (,$(filter cocoa gtk2 gtk3,$(MOZ_WIDGET_TOOLKIT)))
 EXTRA_DSO_LDOPTS += \
   $(TK_LIBS) \
   $(NULL)
 endif
--- a/browser/components/build/moz.build
+++ b/browser/components/build/moz.build
@@ -1,20 +1,19 @@
 # -*- 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/.
 
-MODULE = 'browsercomps'
-
 EXPORTS += [
     'nsBrowserCompsCID.h',
 ]
 
 SOURCES += [
     'nsModule.cpp',
 ]
 
 LIBRARY_NAME = 'browsercomps'
 
 IS_COMPONENT = True
 
+FORCE_SHARED_LIB = True
--- a/browser/components/dirprovider/moz.build
+++ b/browser/components/dirprovider/moz.build
@@ -1,23 +1,19 @@
 # -*- 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/.
 
-MODULE = 'browserdir'
-
 EXPORTS.mozilla.browser += [
     'DirectoryProvider.h',
 ]
 
 SOURCES += [
     'DirectoryProvider.cpp',
 ]
 
-LIBRARY_NAME = 'browserdir_s'
-
 XPCSHELL_TESTS_MANIFESTS += [
     'tests/unit/xpcshell.ini',
 ]
 
-FORCE_STATIC_LIB = True
+FINAL_LIBRARY = 'browsercomps'
--- a/browser/components/feeds/public/moz.build
+++ b/browser/components/feeds/public/moz.build
@@ -5,10 +5,10 @@
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
 XPIDL_SOURCES += [
     'nsIFeedResultService.idl',
     'nsIFeedWriter.idl',
     'nsIWebContentConverterRegistrar.idl',
 ]
 
-MODULE = 'browser-feeds'
+XPIDL_MODULE = 'browser-feeds'
 
--- a/browser/components/feeds/src/moz.build
+++ b/browser/components/feeds/src/moz.build
@@ -1,25 +1,21 @@
 # -*- 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/.
 
-MODULE = 'browser_feeds'
-
 SOURCES += [
     'nsFeedSniffer.cpp',
 ]
 
 EXTRA_COMPONENTS += [
     'BrowserFeeds.manifest',
     'FeedConverter.js',
     'WebContentConverter.js',
 ]
 
 EXTRA_PP_COMPONENTS += [
     'FeedWriter.js',
 ]
 
-LIBRARY_NAME = 'browser_feeds_s'
-
-FORCE_STATIC_LIB = True
+FINAL_LIBRARY = 'browsercomps'
--- a/browser/components/migration/public/moz.build
+++ b/browser/components/migration/public/moz.build
@@ -3,10 +3,10 @@
 # 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/.
 
 XPIDL_SOURCES += [
     'nsIBrowserProfileMigrator.idl',
 ]
 
-MODULE = 'migration'
+XPIDL_MODULE = 'migration'
 
--- a/browser/components/migration/src/moz.build
+++ b/browser/components/migration/src/moz.build
@@ -1,16 +1,14 @@
 # -*- 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/.
 
-MODULE = 'migration'
-
 if CONFIG['OS_ARCH'] == 'WINNT':
     SOURCES += [
         'nsIEHistoryEnumerator.cpp',
     ]
 
 EXTRA_COMPONENTS += [
     'FirefoxProfileMigrator.js',
     'ProfileMigrator.js',
@@ -31,15 +29,13 @@ if CONFIG['OS_ARCH'] == 'WINNT':
         'SafariProfileMigrator.js',
     ]
 
 if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'cocoa':
     EXTRA_PP_COMPONENTS += [
         'SafariProfileMigrator.js',
     ]
 
-LIBRARY_NAME = 'migration_s'
-
 EXTRA_PP_JS_MODULES += [
     'MigrationUtils.jsm',
 ]
 
-FORCE_STATIC_LIB = True
+FINAL_LIBRARY = 'browsercomps'
--- a/browser/components/moz.build
+++ b/browser/components/moz.build
@@ -25,18 +25,16 @@ DIRS += ['build']
 
 XPIDL_SOURCES += [
     'nsIBrowserGlue.idl',
     'nsIBrowserHandler.idl',
 ]
 
 XPIDL_MODULE = 'browsercompsbase'
 
-MODULE = 'browsercomps'
-
 EXTRA_COMPONENTS += [
     'BrowserComponents.manifest',
 ]
 EXTRA_PP_COMPONENTS += [
     'nsBrowserContentHandler.js',
     'nsBrowserGlue.js',
 ]
 
--- a/browser/components/sessionstore/moz.build
+++ b/browser/components/sessionstore/moz.build
@@ -6,17 +6,17 @@
 
 DIRS += ['src']
 
 XPIDL_SOURCES += [
     'nsISessionStartup.idl',
     'nsISessionStore.idl',
 ]
 
-MODULE = 'sessionstore'
+XPIDL_MODULE = 'sessionstore'
 
 XPCSHELL_TESTS_MANIFESTS += [
     'test/unit/xpcshell.ini',
 ]
 
 BROWSER_CHROME_MANIFESTS += [
     'test/browser.ini',
 ]
--- a/browser/components/shell/public/moz.build
+++ b/browser/components/shell/public/moz.build
@@ -12,10 +12,10 @@ if CONFIG['OS_ARCH'] == 'WINNT':
     XPIDL_SOURCES += [
         'nsIWindowsShellService.idl',
     ]
 elif CONFIG['MOZ_WIDGET_TOOLKIT'] == 'cocoa':
     XPIDL_SOURCES += [
         'nsIMacShellService.idl',
     ]
 
-MODULE = 'shellservice'
+XPIDL_MODULE = 'shellservice'
 
--- a/browser/components/shell/src/moz.build
+++ b/browser/components/shell/src/moz.build
@@ -1,30 +1,26 @@
 # -*- 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/.
 
-MODULE = 'shellservice'
-
 if CONFIG['OS_ARCH'] == 'WINNT':
     SOURCES += [
         'nsWindowsShellService.cpp',
     ]
 elif CONFIG['MOZ_WIDGET_TOOLKIT'] == 'cocoa':
     SOURCES += [
         'nsMacShellService.cpp',
     ]
 elif CONFIG['MOZ_WIDGET_GTK']:
     SOURCES += [
         'nsGNOMEShellService.cpp',
     ]
 
 if SOURCES:
-    LIBRARY_NAME = 'shellservice_s'
+    FINAL_LIBRARY = 'browsercomps'
 
 EXTRA_COMPONENTS += [
     'nsSetDefaultBrowser.js',
     'nsSetDefaultBrowser.manifest',
 ]
-
-FORCE_STATIC_LIB = True
--- a/browser/components/shell/src/nsWindowsShellService.cpp
+++ b/browser/components/shell/src/nsWindowsShellService.cpp
@@ -455,23 +455,23 @@ nsWindowsShellService::IsDefaultBrowser(
 
     ::ZeroMemory(currValue, sizeof(currValue));
     DWORD len = sizeof currValue;
     res = ::RegQueryValueExW(theKey, L"", nullptr, nullptr,
                              (LPBYTE)currValue, &len);
     // Close the key that was opened.
     ::RegCloseKey(theKey);
     if (REG_FAILED(res) ||
-        !valueData.Equals(currValue, CaseInsensitiveCompare)) {
+        _wcsicmp(valueData.get(), currValue)) {
       // Key wasn't set or was set to something other than our registry entry.
       NS_ConvertUTF8toUTF16 oldValueData(settings->oldValueData);
       offset = oldValueData.Find("%APPPATH%");
       oldValueData.Replace(offset, 9, appLongPath);
       // The current registry value doesn't match the current or the old format.
-      if (!oldValueData.Equals(currValue, CaseInsensitiveCompare)) {
+      if (_wcsicmp(oldValueData.get(), currValue)) {
         *aIsDefaultBrowser = false;
         return NS_OK;
       }
 
       res = ::RegOpenKeyExW(HKEY_CLASSES_ROOT, PromiseFlatString(keyName).get(),
                             0, KEY_SET_VALUE, &theKey);
       if (REG_FAILED(res)) {
         // If updating the open command fails try to update it using the helper
@@ -574,17 +574,17 @@ nsWindowsShellService::IsDefaultBrowser(
     ::ZeroMemory(currValue, sizeof(currValue));
     DWORD len = sizeof currValue;
     res = ::RegQueryValueExW(theKey, L"", nullptr, nullptr, (LPBYTE)currValue,
                              &len);
 
     // Don't update the FTP protocol handler's shell open command when the
     // current registry value doesn't exist or matches the old format.
     if (REG_FAILED(res) ||
-        !oldValueOpen.Equals(currValue, CaseInsensitiveCompare)) {
+        _wcsicmp(oldValueOpen.get(), currValue)) {
       ::RegCloseKey(theKey);
       return NS_OK;
     }
 
     NS_ConvertUTF8toUTF16 valueData(VAL_OPEN);
     valueData.Replace(offset, 9, appLongPath);
     const nsString &flatValue = PromiseFlatString(valueData);
     res = ::RegSetValueExW(theKey, L"", 0, REG_SZ,
--- a/browser/fuel/public/moz.build
+++ b/browser/fuel/public/moz.build
@@ -3,10 +3,10 @@
 # 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/.
 
 XPIDL_SOURCES += [
     'fuelIApplication.idl',
 ]
 
-MODULE = 'fuel'
+XPIDL_MODULE = 'fuel'
 
--- a/browser/fuel/src/moz.build
+++ b/browser/fuel/src/moz.build
@@ -1,15 +1,13 @@
 # -*- 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/.
 
-MODULE = 'fuel'
-
 EXTRA_COMPONENTS += [
     'fuelApplication.manifest',
 ]
 
 EXTRA_PP_COMPONENTS += [
     'fuelApplication.js',
 ]
--- a/browser/metro/base/content/contenthandlers/Content.js
+++ b/browser/metro/base/content/contenthandlers/Content.js
@@ -109,16 +109,17 @@ function getOverflowContentBoundingRect(
 
 /*
  * Content
  *
  * Browser event receiver for content.
  */
 let Content = {
   _debugEvents: false,
+  _isZoomedIn: false,
 
   get formAssistant() {
     delete this.formAssistant;
     return this.formAssistant = new FormAssistant();
   },
 
   init: function init() {
     this._isZoomedToElement = false;
@@ -128,16 +129,17 @@ let Content = {
     addMessageListener("Browser:SaveAs", this);
     addMessageListener("Browser:MozApplicationCache:Fetch", this);
     addMessageListener("Browser:SetCharset", this);
     addMessageListener("Browser:CanUnload", this);
     addMessageListener("Browser:PanBegin", this);
 
     addEventListener("touchstart", this, false);
     addEventListener("click", this, true);
+    addEventListener("dblclick", this, true);
     addEventListener("keydown", this);
     addEventListener("keyup", this);
 
     // Synchronous events caught during the bubbling phase
     addEventListener("MozApplicationManifest", this, false);
     addEventListener("DOMContentLoaded", this, false);
     addEventListener("DOMAutoComplete", this, false);
     addEventListener("DOMFormHasPassword", this, false);
@@ -175,16 +177,25 @@ let Content = {
         // Allow down arrow to trigger autofill popup on empty input.
         if ((!aEvent.target.value && aEvent.keyCode != aEvent.DOM_VK_DOWN)
           || aEvent.keyCode == aEvent.DOM_VK_ESCAPE)
           this.formAssistant.close();
         else
           this.formAssistant.open(aEvent.target, aEvent);
         break;
 
+      case "dblclick":
+        // XXX Once gesture listners are used(Bug 933236), apzc will notify us
+        if (aEvent.mozInputSource == Ci.nsIDOMMouseEvent.MOZ_SOURCE_TOUCH) {
+          let selection = content.getSelection();
+          selection.removeAllRanges();
+          this._onZoomToTappedContent(aEvent.target);
+        }
+        break;
+
       case "click":
         // Workaround for bug 925457: we sometimes don't recognize the
         // correct tap target or are unable to identify if it's editable.
         // Instead always save tap co-ordinates for the keyboard to look for
         // when it is up.
         SelectionHandler.onClickCoords(aEvent.clientX, aEvent.clientY);
 
         if (aEvent.eventPhase == aEvent.BUBBLING_PHASE)
@@ -358,16 +369,85 @@ let Content = {
         let webNav = docShell.QueryInterface(Ci.nsIWebNavigation);
         webNav.loadURI(content.location,
                        Ci.nsIWebNavigation.LOAD_FLAGS_BYPASS_CLASSIFIER,
                        null, null, null);
       }
     }
   },
 
+  _onZoomToTappedContent: function (aElement) {
+    if (!aElement || this._isZoomedIn) {
+      this._zoomOut();
+      return;
+    }
+
+    while (aElement && !this._shouldZoomToElement(aElement)) {
+      aElement = aElement.parentNode;
+    }
+
+    if (!aElement) {
+      this._zoomOut();
+    } else {
+      this._zoomToElement(aElement);
+    }
+  },
+
+  /******************************************************
+   * Zoom utilities
+   */
+  _zoomOut: function() {
+    let rect = getBoundingContentRect(content.document.documentElement);
+
+    let utils = Util.getWindowUtils(content);
+    let viewId = utils.getViewId(content.document.documentElement);
+    let presShellId = {};
+    utils.getPresShellId(presShellId);
+    let zoomData = [rect.x,
+                    rect.y,
+                    rect.width,
+                    rect.height,
+                    presShellId.value,
+                    viewId].join(",");
+    Services.obs.notifyObservers(null, "Metro:ZoomToRect", zoomData);
+    this._isZoomedIn = false;
+  },
+
+  _zoomToElement: function(aElement) {
+    let rect = getBoundingContentRect(aElement);
+    let utils = Util.getWindowUtils(content);
+    let viewId = utils.getViewId(content.document.documentElement);
+    let presShellId = {};
+    utils.getPresShellId(presShellId);
+    let zoomData = [rect.x,
+                    rect.y,
+                    rect.width,
+                    rect.height,
+                    presShellId.value,
+                    viewId].join(",");
+    Services.obs.notifyObservers(null, "Metro:ZoomToRect", zoomData);
+    this._isZoomedIn = true;
+  },
+
+  _shouldZoomToElement: function(aElement) {
+    let win = aElement.ownerDocument.defaultView;
+    if (win.getComputedStyle(aElement, null).display == "inline") {
+      return false;
+    }
+    else if (aElement instanceof Ci.nsIDOMHTMLLIElement) {
+      return false;
+    }
+    else if (aElement instanceof Ci.nsIDOMHTMLQuoteElement) {
+      return false;
+    }
+    else {
+      return true;
+    }
+  },
+
 
   /******************************************************
    * General utilities
    */
 
   _getContentClientRects: function getContentClientRects(aElement) {
     let offset = ContentScroll.getScrollOffset(content);
     offset = new Point(offset.x, offset.y);
--- a/browser/metro/base/content/input.js
+++ b/browser/metro/base/content/input.js
@@ -88,17 +88,16 @@ var TouchModule = {
     this._targetScrollbox = null;
     this._targetScrollInterface = null;
 
     this._kinetic = new KineticController(this._dragBy.bind(this),
                                           this._kineticStop.bind(this));
 
     // capture phase events
     window.addEventListener("CancelTouchSequence", this, true);
-    window.addEventListener("dblclick", this, true);
     window.addEventListener("keydown", this, true);
     window.addEventListener("MozMouseHittest", this, true);
 
     // bubble phase
     window.addEventListener("contextmenu", this, false);
     window.addEventListener("touchstart", this, false);
     window.addEventListener("touchmove", this, false);
     window.addEventListener("touchend", this, false);
@@ -139,30 +138,16 @@ var TouchModule = {
             this._onTouchStart(aEvent);
             break;
           case "touchmove":
             this._onTouchMove(aEvent);
             break;
           case "touchend":
             this._onTouchEnd(aEvent);
             break;
-          case "dblclick":
-            // XXX This will get picked up somewhere below us for "double tap to zoom"
-            // once we get omtc and the apzc. Currently though dblclick is delivered to
-            // content and triggers selection of text, so fire up the SelectionHelperUI
-            // once selection is present.
-            if (!InputSourceHelper.isPrecise &&
-                !SelectionHelperUI.isActive &&
-                !FindHelperUI.isActive) {
-              setTimeout(function () {
-                SelectionHelperUI.attachEditSession(Browser.selectedTab.browser,
-                                                    aEvent.clientX, aEvent.clientY);
-              }, 50);
-            }
-            break;
           case "keydown":
             this._handleKeyDown(aEvent);
             break;
           case "MozMouseHittest":
             // Used by widget to hit test chrome vs content. Make sure the XUl scrollbars
             // are counted as "chrome". Since the XUL scrollbars have sub-elements we walk
             // the parent chain to ensure we catch all of those as well.
             let onScrollbar = false;
--- a/browser/metro/base/tests/mochitest/browser_selection_basic.js
+++ b/browser/metro/base/tests/mochitest/browser_selection_basic.js
@@ -58,31 +58,16 @@ gTests.push({
         return SelectionHelperUI.isSelectionUIVisible;
       }, kCommonWaitMs, kCommonPollMs);
 
     is(getTrimmedSelection(gWindow).toString(), "There", "selection test");
   },
 });
 
 gTests.push({
-  desc: "double-tap to select",
-  setUp: setUpAndTearDown,
-  tearDown: setUpAndTearDown,
-  run: function test() {
-    sendDoubleTap(gWindow, 30, 20);
-
-    yield waitForCondition(function () {
-        return SelectionHelperUI.isSelectionUIVisible;
-      }, kCommonWaitMs, kCommonPollMs);
-
-    is(getTrimmedSelection(gWindow).toString(), "There", "selection test");
-  },
-});
-
-gTests.push({
   desc: "appbar interactions",
   setUp: setUpAndTearDown,
   tearDown: setUpAndTearDown,
   run: function test() {
     sendContextMenuClick(100, 20);
 
     yield waitForCondition(function () {
         return SelectionHelperUI.isSelectionUIVisible;
--- a/browser/metro/components/moz.build
+++ b/browser/metro/components/moz.build
@@ -3,17 +3,17 @@
 # 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/.
 
 XPIDL_SOURCES += [
     'SessionStore.idl',
 ]
 
-MODULE = 'components'
+XPIDL_MODULE = 'components'
 
 # metro/components.manifest
 EXTRA_COMPONENTS += [
     'AlertsService.js',
     'BrowserStartup.js',
     'ContentDispatchChooser.js',
     'ContentPermissionPrompt.js',
     'DirectoryProvider.js',
--- a/browser/metro/shell/moz.build
+++ b/browser/metro/shell/moz.build
@@ -6,10 +6,8 @@
 
 DIRS += [
     'commandexecutehandler',
     'linktool',
 ]
 
 TEST_DIRS += ['testing']
 
-MODULE = 'metro'
-
--- a/build/automation.py.in
+++ b/build/automation.py.in
@@ -516,29 +516,22 @@ class Automation(object):
       llvmsym = os.path.join(xrePath, "llvm-symbolizer")
       if os.path.isfile(llvmsym):
         env["ASAN_SYMBOLIZER_PATH"] = llvmsym
         self.log.info("INFO | automation.py | ASan using symbolizer at %s", llvmsym)
 
       try:
         totalMemory = int(os.popen("free").readlines()[1].split()[1])
 
-        # Only 2 GB RAM or less available? Use custom ASan options to reduce
+        # Only 4 GB RAM or less available? Use custom ASan options to reduce
         # the amount of resources required to do the tests. Standard options 
         # will otherwise lead to OOM conditions on the current test slaves.
-        # 
-        # If we have more than 2 GB or RAM but still less than 4 GB, we need
-        # another set of options to prevent OOM in some memory-intensive
-        # tests.
-        if totalMemory <= 1024 * 1024 * 2:
+        if totalMemory <= 1024 * 1024 * 4:
           self.log.info("INFO | automation.py | ASan running in low-memory configuration")
-          env["ASAN_OPTIONS"] = "quarantine_size=50331648:redzone=64"
-        elif totalMemory <= 1024 * 1024 * 4:
-          self.log.info("INFO | automation.py | ASan running in mid-memory configuration")
-          env["ASAN_OPTIONS"] = "quarantine_size=100663296:redzone=64"
+          env["ASAN_OPTIONS"] = "quarantine_size=50331648"
         else:
           self.log.info("INFO | automation.py | ASan running in default memory configuration")
       except OSError,err:
         self.log.info("Failed determine available memory, disabling ASan low-memory configuration: %s", err.strerror)
       except:
         self.log.info("Failed determine available memory, disabling ASan low-memory configuration")
 
     return env
--- a/build/automationutils.py
+++ b/build/automationutils.py
@@ -452,30 +452,23 @@ def environment(xrePath, env=None, crash
       # Symbolizer support
       llvmsym = os.path.join(xrePath, "llvm-symbolizer")
       if os.path.isfile(llvmsym):
         env["ASAN_SYMBOLIZER_PATH"] = llvmsym
         log.info("ASan using symbolizer at %s", llvmsym)
 
       totalMemory = systemMemory()
 
-      # Only 2 GB RAM or less available? Use custom ASan options to reduce
+      # Only 4 GB RAM or less available? Use custom ASan options to reduce
       # the amount of resources required to do the tests. Standard options
       # will otherwise lead to OOM conditions on the current test slaves.
-      #
-      # If we have more than 2 GB or RAM but still less than 4 GB, we need
-      # another set of options to prevent OOM in some memory-intensive
-      # tests.
       message = "INFO | runtests.py | ASan running in %s configuration"
-      if totalMemory <= 1024 * 1024 * 2:
+      if totalMemory <= 1024 * 1024 * 4:
         message = message % 'low-memory'
-        env["ASAN_OPTIONS"] = "quarantine_size=50331648:redzone=64"
-      elif totalMemory <= 1024 * 1024 * 4:
-        message = message % 'mid-memory'
-        env["ASAN_OPTIONS"] = "quarantine_size=80530636:redzone=64"
+        env["ASAN_OPTIONS"] = "quarantine_size=50331648"
       else:
         message = message % 'default memory'
     except OSError,err:
       log.info("Failed determine available memory, disabling ASan low-memory configuration: %s", err.strerror)
     except:
       log.info("Failed determine available memory, disabling ASan low-memory configuration")
     else:
       log.info(message)
--- a/build/mobile/robocop/moz.build
+++ b/build/mobile/robocop/moz.build
@@ -1,11 +1,9 @@
 # -*- 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/.
 
-MODULE = 'robocop'
-
 ANDROID_RESFILES = [
     'res/values/strings.xml',
 ]
--- a/build/mobile/sutagent/android/fencp/moz.build
+++ b/build/mobile/sutagent/android/fencp/moz.build
@@ -1,15 +1,13 @@
 # -*- 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/.
 
-MODULE = 'FenCP'
-
 ANDROID_RESFILES = [
     'res/drawable-hdpi/icon.png',
     'res/drawable-ldpi/icon.png',
     'res/drawable-mdpi/icon.png',
     'res/layout/main.xml',
     'res/values/strings.xml',
 ]
--- a/build/mobile/sutagent/android/ffxcp/moz.build
+++ b/build/mobile/sutagent/android/ffxcp/moz.build
@@ -1,15 +1,13 @@
 # -*- 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/.
 
-MODULE = 'FfxCP'
-
 ANDROID_RESFILES = [
     'res/drawable-hdpi/icon.png',
     'res/drawable-ldpi/icon.png',
     'res/drawable-mdpi/icon.png',
     'res/layout/main.xml',
     'res/values/strings.xml',
 ]
--- a/build/mobile/sutagent/android/moz.build
+++ b/build/mobile/sutagent/android/moz.build
@@ -1,16 +1,14 @@
 # -*- 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/.
 
-MODULE = 'sutAgentAndroid'
-
 ANDROID_RESFILES = [
     'res/drawable/ateamlogo.png',
     'res/drawable/ic_stat_first.png',
     'res/drawable/ic_stat_neterror.png',
     'res/drawable/ic_stat_warning.png',
     'res/drawable/icon.png',
     'res/layout/main.xml',
     'res/values/strings.xml',
--- a/build/mobile/sutagent/android/watcher/moz.build
+++ b/build/mobile/sutagent/android/watcher/moz.build
@@ -1,16 +1,14 @@
 # -*- 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/.
 
-MODULE = 'Watcher'
-
 ANDROID_RESFILES = [
     'res/drawable-hdpi/ateamlogo.png',
     'res/drawable-hdpi/icon.png',
     'res/drawable-ldpi/ateamlogo.png',
     'res/drawable-ldpi/icon.png',
     'res/drawable-mdpi/ateamlogo.png',
     'res/drawable-mdpi/icon.png',
     'res/layout/main.xml',
--- a/build/moz.build
+++ b/build/moz.build
@@ -17,10 +17,8 @@ if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'andr
     TEST_DIRS += [
         'mobile/sutagent/android',
         'mobile/sutagent/android/watcher',
         'mobile/sutagent/android/ffxcp',
         'mobile/sutagent/android/fencp',
         'mobile/robocop',
     ]
 
-MODULE = 'build'
-
--- a/build/unix/moz.build
+++ b/build/unix/moz.build
@@ -7,10 +7,8 @@
 if CONFIG['MOZ_LIBSTDCXX_TARGET_VERSION'] or CONFIG['MOZ_LIBSTDCXX_HOST_VERSION']:
     DIRS += ['stdc++compat']
 
 if CONFIG['USE_ELF_HACK']:
     DIRS += ['elfhack']
 
 TEST_DIRS += ['test']
 
-MODULE = 'build'
-
--- a/build/unix/stdc++compat/moz.build
+++ b/build/unix/stdc++compat/moz.build
@@ -1,16 +1,14 @@
 # -*- 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/.
 
-MODULE = 'build'
-
 if CONFIG['MOZ_LIBSTDCXX_TARGET_VERSION']:
     LIBRARY_NAME = 'stdc++compat'
     SOURCES += ['stdc++compat.cpp']
 
 if CONFIG['MOZ_LIBSTDCXX_HOST_VERSION']:
     HOST_LIBRARY_NAME = 'host_stdc++compat'
     HOST_SOURCES += [
         'stdc++compat.cpp',
--- a/build/win32/crashinjectdll/Makefile.in
+++ b/build/win32/crashinjectdll/Makefile.in
@@ -1,9 +1,8 @@
 # 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/.
 
 DEFFILE = $(srcdir)/crashinjectdll.def
-FORCE_SHARED_LIB = 1
 USE_STATIC_LIBS = 1
 
 MOZ_GLUE_LDFLAGS =
--- a/build/win32/crashinjectdll/moz.build
+++ b/build/win32/crashinjectdll/moz.build
@@ -5,8 +5,9 @@
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
 SOURCES += [
     'crashinjectdll.cpp',
 ]
 
 LIBRARY_NAME = 'crashinjectdll'
 
+FORCE_SHARED_LIB = True
--- a/build/win32/vmwarerecordinghelper/Makefile.in
+++ b/build/win32/vmwarerecordinghelper/Makefile.in
@@ -1,10 +1,9 @@
 # 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/.
 
 DEFFILE = $(srcdir)/$(LIBRARY_NAME).def
 
-FORCE_SHARED_LIB = 1
 USE_STATIC_LIBS = 1
 
 MOZ_GLUE_LDFLAGS =
--- a/build/win32/vmwarerecordinghelper/moz.build
+++ b/build/win32/vmwarerecordinghelper/moz.build
@@ -5,8 +5,9 @@
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
 SOURCES += [
     'vmwarerecordinghelper.cpp',
 ]
 
 LIBRARY_NAME = 'vmwarerecordinghelper'
 
+FORCE_SHARED_LIB = True
--- a/caps/idl/moz.build
+++ b/caps/idl/moz.build
@@ -6,10 +6,10 @@
 
 XPIDL_SOURCES += [
     'nsIDomainPolicy.idl',
     'nsIPrincipal.idl',
     'nsIScriptSecurityManager.idl',
     'nsISecurityCheckedComponent.idl',
 ]
 
-MODULE = 'caps'
+XPIDL_MODULE = 'caps'
 
--- a/caps/include/moz.build
+++ b/caps/include/moz.build
@@ -1,12 +1,10 @@
 # -*- 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/.
 
-MODULE = 'caps'
-
 EXPORTS += [
     'nsJSPrincipals.h',
 ]
 
--- a/caps/moz.build
+++ b/caps/moz.build
@@ -2,10 +2,8 @@
 # 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 += ['idl', 'include', 'src']
 TEST_DIRS += ['tests/mochitest']
 
-MODULE = 'caps'
-
--- a/caps/src/moz.build
+++ b/caps/src/moz.build
@@ -1,30 +1,26 @@
 # -*- 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/.
 
-MODULE = 'caps'
-
 SOURCES += [
     'DomainPolicy.cpp',
     'nsJSPrincipals.cpp',
     'nsNullPrincipal.cpp',
     'nsNullPrincipalURI.cpp',
     'nsPrincipal.cpp',
     'nsScriptSecurityManager.cpp',
     'nsSecurityManagerFactory.cpp',
     'nsSystemPrincipal.cpp',
 ]
 
-LIBRARY_NAME = 'caps_s'
-
-LIBXUL_LIBRARY = True
-
 MSVC_ENABLE_PGO = True
 
 LOCAL_INCLUDES += [
     '../include',
     '/dom/base',
     '/js/xpconnect/src',
 ]
+
+FINAL_LIBRARY = 'gklayout'
--- a/chrome/public/moz.build
+++ b/chrome/public/moz.build
@@ -4,10 +4,10 @@
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
 XPIDL_SOURCES += [
     'nsIChromeRegistry.idl',
     'nsIToolkitChromeRegistry.idl',
 ]
 
-MODULE = 'chrome'
+XPIDL_MODULE = 'chrome'
 
--- a/chrome/src/moz.build
+++ b/chrome/src/moz.build
@@ -1,27 +1,22 @@
 # -*- 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/.
 
-MODULE = 'chrome'
-
 EXPORTS.mozilla.chrome += [
     'RegistryMessageUtils.h',
 ]
 
 SOURCES += [
     'nsChromeProtocolHandler.cpp',
     'nsChromeRegistry.cpp',
     'nsChromeRegistryChrome.cpp',
     'nsChromeRegistryContent.cpp',
 ]
 
-LIBXUL_LIBRARY = True
-
 MSVC_ENABLE_PGO = True
 
-LIBRARY_NAME = 'chrome_s'
-
 include('/ipc/chromium/chromium-config.mozbuild')
 
+FINAL_LIBRARY = 'xpcom_core'
--- a/chrome/test/moz.build
+++ b/chrome/test/moz.build
@@ -1,13 +1,11 @@
 # -*- 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/.
 
-MODULE = 'test_chrome'
-
 XPCSHELL_TESTS_MANIFESTS += ['unit/xpcshell.ini']
 
 # FIXME/bug 575918: out-of-process xpcshell is broken on OS X
 if CONFIG['OS_ARCH'] != 'Darwin':
     XPCSHELL_TESTS_MANIFESTS += ['unit_ipc/xpcshell.ini']
--- a/config/config.mk
+++ b/config/config.mk
@@ -37,17 +37,19 @@ endif
   ANDROID_GENERATED_RESFILES \
   ANDROID_RESFILES \
   CMSRCS \
   CMMSRCS \
   CPP_UNIT_TESTS \
   DIRS \
   EXTRA_PP_COMPONENTS \
   EXTRA_PP_JS_MODULES \
+  FORCE_SHARED_LIB \
   FORCE_STATIC_LIB \
+  FINAL_LIBRARY \
   GTEST_CMMSRCS \
   GTEST_CPPSRCS \
   GTEST_CSRCS \
   HOST_CSRCS \
   HOST_CMMSRCS \
   HOST_LIBRARY_NAME \
   HOST_PROGRAM \
   HOST_SIMPLE_PROGRAMS \
@@ -68,16 +70,17 @@ endif
   TOOL_DIRS \
   XPCSHELL_TESTS \
   XPIDL_MODULE \
   $(NULL)
 
 _DEPRECATED_VARIABLES := \
   MOCHITEST_FILES_PARTS \
   MOCHITEST_BROWSER_FILES_PARTS \
+  SHORT_LIBNAME \
   $(NULL)
 
 ifndef EXTERNALLY_MANAGED_MAKE_FILE
 # Using $(firstword) may not be perfect. But it should be good enough for most
 # scenarios.
 _current_makefile = $(CURDIR)/$(firstword $(MAKEFILE_LIST))
 
 $(foreach var,$(_MOZBUILD_EXTERNAL_VARIABLES),$(if $(filter file override,$(subst $(NULL) ,_,$(origin $(var)))),\
@@ -128,17 +131,16 @@ endif
 COMMA = ,
 
 # Sanity check some variables
 CHECK_VARS := \
  XPI_NAME \
  LIBRARY_NAME \
  MODULE \
  DEPTH \
- SHORT_LIBNAME \
  XPI_PKGNAME \
  INSTALL_EXTENSION_ID \
  SHARED_LIBRARY_NAME \
  STATIC_LIBRARY_NAME \
  $(NULL)
 
 # checks for internal spaces or trailing spaces in the variable
 # named by $x
@@ -327,30 +329,31 @@ endif
 #
 # Build using PIC by default
 #
 _ENABLE_PIC=1
 
 # Determine if module being compiled is destined
 # to be merged into libxul
 
+ifeq ($(FINAL_LIBRARY),xul)
+  ifdef LIBXUL_LIBRARY
+    $(error FINAL_LIBRARY is "xul", LIBXUL_LIBRARY is implied)
+  endif
+  LIBXUL_LIBRARY := 1
+endif
+
 ifdef LIBXUL_LIBRARY
 ifdef IS_COMPONENT
 $(error IS_COMPONENT is set, but is not compatible with LIBXUL_LIBRARY)
 endif
 ifdef MODULE_NAME
 $(error MODULE_NAME is $(MODULE_NAME) but MODULE_NAME and LIBXUL_LIBRARY are not compatible)
 endif
-ifdef FORCE_STATIC_LIB
-$(error Makefile sets FORCE_STATIC_LIB which was already implied by LIBXUL_LIBRARY)
-endif
 FORCE_STATIC_LIB=1
-ifneq ($(SHORT_LIBNAME),)
-$(error SHORT_LIBNAME is $(SHORT_LIBNAME) but SHORT_LIBNAME is not compatable with LIBXUL_LIBRARY)
-endif
 endif
 
 # If we are building this component into an extension/xulapp, it cannot be
 # statically linked. In the future we may want to add a xulapp meta-component
 # build option.
 
 ifdef XPI_NAME
 ifdef IS_COMPONENT
--- a/config/expandlibs_exec.py
+++ b/config/expandlibs_exec.py
@@ -79,18 +79,24 @@ class ExpandArgsMore(ExpandArgs):
                 if os.path.exists(arg + conf.LIBS_DESC_SUFFIX):
                     newlist += self._extract(self._expand_desc(arg))
                     continue
                 elif os.path.exists(arg) and (len(ar_extract) or conf.AR == 'lib'):
                     tmp = tempfile.mkdtemp(dir=os.curdir)
                     self.tmp.append(tmp)
                     if conf.AR == 'lib':
                         out = subprocess.check_output([conf.AR, '-NOLOGO', '-LIST', arg])
-                        for l in out.splitlines():
-                            subprocess.call([conf.AR, '-NOLOGO', '-EXTRACT:%s' % l, os.path.abspath(arg)], cwd=tmp)
+                        files = out.splitlines()
+                        # If lib -list returns a list full of dlls, it's an
+                        # import lib.
+                        if all(isDynamicLib(f) for f in files):
+                            newlist += [arg]
+                            continue
+                        for f in files:
+                            subprocess.call([conf.AR, '-NOLOGO', '-EXTRACT:%s' % f, os.path.abspath(arg)], cwd=tmp)
                     else:
                         subprocess.call(ar_extract + [os.path.abspath(arg)], cwd=tmp)
                     objs = []
                     for root, dirs, files in os.walk(tmp):
                         objs += [relativize(os.path.join(root, f)) for f in files if isObject(f)]
                     newlist += sorted(objs)
                     continue
             newlist += [arg]
--- a/config/rules.mk
+++ b/config/rules.mk
@@ -207,22 +207,16 @@ ifdef MKSHLIB
 ifdef LIB_IS_C_ONLY
 MKSHLIB			= $(MKCSHLIB)
 endif
 
 ifneq (,$(filter OS2 WINNT,$(OS_ARCH)))
 IMPORT_LIBRARY		:= $(LIB_PREFIX)$(SHARED_LIBRARY_NAME).$(IMPORT_LIB_SUFFIX)
 endif
 
-ifeq (OS2,$(OS_ARCH))
-ifdef SHORT_LIBNAME
-SHARED_LIBRARY_NAME	:= $(SHORT_LIBNAME)
-endif
-endif
-
 ifdef MAKE_FRAMEWORK
 SHARED_LIBRARY		:= $(SHARED_LIBRARY_NAME)
 else
 SHARED_LIBRARY		:= $(DLL_PREFIX)$(SHARED_LIBRARY_NAME)$(DLL_SUFFIX)
 endif
 
 ifeq ($(OS_ARCH),OS2)
 DEF_FILE		:= $(SHARED_LIBRARY:.dll=.def)
@@ -505,17 +499,17 @@ endif
 ifeq ($(OS_ARCH),FreeBSD)
 ifdef IS_COMPONENT
 EXTRA_DSO_LDOPTS += -Wl,-Bsymbolic
 endif
 endif
 
 ifeq ($(OS_ARCH),NetBSD)
 ifneq (,$(filter arc cobalt hpcmips mipsco newsmips pmax sgimips,$(OS_TEST)))
-ifeq ($(MODULE),layout)
+ifneq (,$(filter layout/%,$(relativesrcdir)))
 OS_CFLAGS += -Wa,-xgot
 OS_CXXFLAGS += -Wa,-xgot
 endif
 endif
 endif
 
 #
 # HP-UXBeOS specific section: for COMPONENTS only, add -Bsymbolic flag
@@ -1684,17 +1678,16 @@ endif
 
 FREEZE_VARIABLES = \
   CSRCS \
   CPPSRCS \
   EXPORTS \
   DIRS \
   LIBRARY \
   MODULE \
-  SHORT_LIBNAME \
   TIERS \
   EXTRA_COMPONENTS \
   EXTRA_PP_COMPONENTS \
   MOCHITEST_FILES \
   MOCHITEST_CHROME_FILES \
   MOCHITEST_BROWSER_FILES \
   MOCHITEST_A11Y_FILES \
   MOCHITEST_METRO_FILES \
--- a/config/version.mk
+++ b/config/version.mk
@@ -17,19 +17,16 @@ RCFILE=./module.rc
 RESFILE=./module.res
 _RC_STRING = -QUIET 1 -DEPTH $(DEPTH) -TOPSRCDIR $(topsrcdir) -OBJDIR . -SRCDIR $(srcdir) -DISPNAME $(MOZ_APP_DISPLAYNAME) -APPVERSION $(MOZ_APP_VERSION)
 ifdef MOZILLA_OFFICIAL
 _RC_STRING += -OFFICIAL 1
 endif
 ifdef MOZ_DEBUG
 _RC_STRING += -DEBUG 1
 endif
-ifdef MODULE
-_RC_STRING += -MODNAME $(MODULE)
-endif
 ifdef PROGRAM
 _RC_STRING += -BINARY $(PROGRAM)
 else
 ifdef _PROGRAM
 _RC_STRING += -BINARY $(_PROGRAM)
 else
 ifdef SHARED_LIBRARY
 _RC_STRING += -BINARY $(SHARED_LIBRARY)
--- a/configure.in
+++ b/configure.in
@@ -3100,16 +3100,19 @@ AC_CACHE_CHECK(
     [if test "$OS_TARGET" = NetBSD -o "$OS_TARGET" = OpenBSD; then
         dnl no need for res_ninit() on NetBSD and OpenBSD
         ac_cv_func_res_ninit=no
      else
         AC_TRY_LINK([
             #ifdef linux
             #define _BSD_SOURCE 1
             #endif
+            #include <sys/types.h>
+            #include <netinet/in.h>
+            #include <arpa/nameser.h>
             #include <resolv.h>
             ],
             [int foo = res_ninit(&_res);],
             [ac_cv_func_res_ninit=yes],
             [ac_cv_func_res_ninit=no])
      fi
     ])
 
@@ -6124,17 +6127,16 @@ if test -n "$MOZ_TREE_FREETYPE"; then
    AC_DEFINE(MOZ_TREE_FREETYPE)
    AC_SUBST(MOZ_TREE_FREETYPE)
    MOZ_ENABLE_CAIRO_FT=1
    FT_FONT_FEATURE="#define CAIRO_HAS_FT_FONT 1"
    FT2_CFLAGS='-I$(topsrcdir)/modules/freetype2/include'
    CAIRO_FT_CFLAGS='-I$(topsrcdir)/modules/freetype2/include'
    FT2_LIBS='$(call EXPAND_LIBNAME_PATH,freetype,$(DEPTH)/modules/freetype2/.libs)'
    CAIRO_FT_OSLIBS=''
-   CAIRO_FT_LIBS='$(call EXPAND_LIBNAME_PATH,freetype,$(DEPTH)/modules/freetype2/.libs)'
    AC_DEFINE(HAVE_FT_BITMAP_SIZE_Y_PPEM)
    AC_DEFINE(HAVE_FT_GLYPHSLOT_EMBOLDEN)
    AC_DEFINE(HAVE_FT_LOAD_SFNT_TABLE)
    AC_SUBST(CAIRO_FT_CFLAGS)
 fi
 
 dnl ========================================================
 dnl Installer
@@ -7949,17 +7951,16 @@ if test "$MOZ_TREE_CAIRO"; then
         fi
         ;;
       os2)
         OS2_SURFACE_FEATURE="#define CAIRO_HAS_OS2_SURFACE 1"
         FT_FONT_FEATURE="#define CAIRO_HAS_FT_FONT 1"
         MOZ_ENABLE_CAIRO_FT=1
         CAIRO_FT_CFLAGS="-I${MZFTCFGFT2}/include"
         CAIRO_FT_OSLIBS="-L${MZFTCFGFT2}/lib -lmozft -lmzfntcfg"
-        CAIRO_FT_LIBS=""
         ;;
     esac
     if test "$USE_FC_FREETYPE"; then
         FC_FONT_FEATURE="#define CAIRO_HAS_FC_FONT 1"
     fi
     AC_SUBST(MOZ_ENABLE_CAIRO_FT)
     AC_SUBST(MOZ_ENABLE_DWRITE_FONT)
     AC_SUBST(MOZ_ENABLE_D2D_SURFACE)
@@ -7982,17 +7983,16 @@ if test "$MOZ_TREE_CAIRO"; then
     AC_SUBST(WIN32_FONT_FEATURE)
     AC_SUBST(WIN32_DWRITE_FONT_FEATURE)
     AC_SUBST(WIN32_D2D_SURFACE_FEATURE)
     AC_SUBST(QUARTZ_FONT_FEATURE)
     AC_SUBST(PNG_FUNCTIONS_FEATURE)
     AC_SUBST(QT_SURFACE_FEATURE)
     AC_SUBST(TEE_SURFACE_FEATURE)
 
-    MOZ_CAIRO_LIBS='$(call EXPAND_LIBNAME_PATH,mozcairo,$(DEPTH)/gfx/cairo/cairo/src)'" $CAIRO_FT_LIBS"
     MOZ_CAIRO_OSLIBS='${CAIRO_FT_OSLIBS}'
 
     if test "$MOZ_X11"; then
         MOZ_CAIRO_OSLIBS="$MOZ_CAIRO_OSLIBS $XLDFLAGS -lXrender"
     fi
 
     CAIRO_FEATURES_H=gfx/cairo/cairo/src/cairo-features.h
 else
@@ -8010,64 +8010,35 @@ fi
 
 AC_SUBST(MOZ_TREE_CAIRO)
 AC_SUBST(MOZ_CAIRO_CFLAGS)
 AC_SUBST(MOZ_CAIRO_LIBS)
 AC_SUBST(MOZ_CAIRO_OSLIBS)
 AC_SUBST(MOZ_TREE_PIXMAN)
 
 dnl ========================================================
-dnl qcms
-dnl ========================================================
-
-QCMS_LIBS='$(DEPTH)/gfx/qcms/$(LIB_PREFIX)mozqcms.$(LIB_SUFFIX)'
-AC_SUBST(QCMS_LIBS)
-
-dnl ========================================================
-dnl HarfBuzz
-dnl ========================================================
-MOZ_HARFBUZZ_LIBS='$(DEPTH)/gfx/harfbuzz/src/$(LIB_PREFIX)mozharfbuzz.$(LIB_SUFFIX)'
-AC_SUBST(MOZ_HARFBUZZ_LIBS)
-
-dnl ========================================================
-dnl SIL Graphite
-dnl ========================================================
-MOZ_GRAPHITE_LIBS='$(DEPTH)/gfx/graphite2/src/$(LIB_PREFIX)mozgraphite2.$(LIB_SUFFIX)'
-AC_SUBST(MOZ_GRAPHITE_LIBS)
-
-dnl ========================================================
-dnl OTS
-dnl ========================================================
-MOZ_OTS_LIBS='$(DEPTH)/gfx/ots/src/$(LIB_PREFIX)mozots.$(LIB_SUFFIX)'
-AC_SUBST(MOZ_OTS_LIBS)
-
-dnl ========================================================
 dnl Skia 
 dnl ========================================================
 if test "$MOZ_ENABLE_SKIA"; then
-  MOZ_SKIA_LIBS='$(DEPTH)/gfx/skia/$(LIB_PREFIX)skia.$(LIB_SUFFIX)'
   AC_DEFINE(MOZ_ENABLE_SKIA)
   AC_DEFINE(USE_SKIA)
   if test "${MOZ_WIDGET_TOOLKIT}" = "android" -o x"$MOZ_WIDGET_TOOLKIT" = x"gonk"; then
     AC_DEFINE(SK_BUILD_FOR_ANDROID_NDK)
   elif test "$OS_ARCH" = "WINNT"; then
     AC_DEFINE(SKIA_DLL)
     AC_DEFINE(GR_DLL)
   fi
 
   if test "${CPU_ARCH}" != "ppc" -a "${CPU_ARCH}" != "ppc64"; then
     MOZ_ENABLE_SKIA_GPU=1
     AC_DEFINE(USE_SKIA_GPU)
     AC_SUBST(MOZ_ENABLE_SKIA_GPU)
   fi
-else
-  MOZ_SKIA_LIBS=
 fi
 AC_SUBST(MOZ_ENABLE_SKIA)
-AC_SUBST(MOZ_SKIA_LIBS)
 
 dnl ========================================================
 dnl disable xul
 dnl ========================================================
 MOZ_ARG_DISABLE_BOOL(xul,
 [  --disable-xul           Disable XUL],
     MOZ_XUL= )
 if test "$MOZ_XUL"; then
--- a/content/base/public/moz.build
+++ b/content/base/public/moz.build
@@ -26,18 +26,16 @@ XPIDL_SOURCES += [
     'nsISelectionDisplay.idl',
     'nsISelectionListener.idl',
     'nsISelectionPrivate.idl',
     'nsIXMLHttpRequest.idl',
 ]
 
 XPIDL_MODULE = 'content_base'
 
-MODULE = 'content'
-
 EXPORTS += [
     'HTMLSplitOnSpacesTokenizer.h',
     'mozFlushType.h',
     'nsCaseTreatment.h',
     'nsContentCID.h',
     'nsContentCreatorFunctions.h',
     'nsContentPolicyUtils.h',
     'nsContentTypeParser.h',
--- a/content/base/public/nsINode.h
+++ b/content/base/public/nsINode.h
@@ -1073,16 +1073,22 @@ public:
   mozilla::dom::Element* QuerySelector(const nsAString& aSelector,
                                        mozilla::ErrorResult& aResult);
   already_AddRefed<nsINodeList> QuerySelectorAll(const nsAString& aSelector,
                                                  mozilla::ErrorResult& aResult);
 
   nsresult QuerySelector(const nsAString& aSelector, nsIDOMElement **aReturn);
   nsresult QuerySelectorAll(const nsAString& aSelector, nsIDOMNodeList **aReturn);
 
+protected:
+  // nsIDocument overrides this with its own (faster) version.  This
+  // should really only be called for elements and document fragments.
+  mozilla::dom::Element* GetElementById(const nsAString& aId);
+
+public:
   /**
    * Associate an object aData to aKey on this node. If aData is null any
    * previously registered object and UserDataHandler associated to aKey on
    * this node will be removed.
    * Should only be used to implement the DOM Level 3 UserData API.
    *
    * @param aKey the key to associate the object to
    * @param aData the object to associate to aKey on this node (may be null)
--- a/content/base/src/DocumentFragment.h
+++ b/content/base/src/DocumentFragment.h
@@ -35,16 +35,18 @@ private:
                                         kNameSpaceID_None),
                       "Bad NodeType in aNodeInfo");
   }
 
 public:
   using FragmentOrElement::GetFirstChild;
   using nsINode::QuerySelector;
   using nsINode::QuerySelectorAll;
+  // Make sure bindings can see our superclass' protected GetElementById method.
+  using nsINode::GetElementById;
 
   // nsISupports
   NS_DECL_ISUPPORTS_INHERITED
 
   // interface nsIDOMNode
   NS_FORWARD_NSIDOMNODE_TO_NSINODE
 
   // interface nsIDOMDocumentFragment
--- a/content/base/src/moz.build
+++ b/content/base/src/moz.build
@@ -1,16 +1,14 @@
 # -*- 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/.
 
-MODULE = 'content'
-
 EXPORTS += [
     'mozAutoDocUpdate.h',
     'nsAtomListUtils.h',
     'nsAttrAndChildArray.h',
     'nsAttrName.h',
     'nsAttrValue.h',
     'nsAttrValueInlines.h',
     'nsContentList.h',
@@ -174,24 +172,21 @@ EXTRA_PP_COMPONENTS += [
 ]
 
 EXTRA_JS_MODULES += [
     'CSPUtils.jsm',
 ]
 
 FAIL_ON_WARNINGS = True
 
-LIBXUL_LIBRARY = True
-
 MSVC_ENABLE_PGO = True
 
-LIBRARY_NAME = 'gkconbase_s'
-
 include('/ipc/chromium/chromium-config.mozbuild')
 
+FINAL_LIBRARY = 'gklayout'
 LOCAL_INCLUDES += [
     '/caps/include',
     '/content/events/src',
     '/content/html/content/src',
     '/content/html/document/src',
     '/content/xbl/src',
     '/content/xml/content/src',
     '/content/xml/document/src',
--- a/content/base/src/nsContentList.cpp
+++ b/content/base/src/nsContentList.cpp
@@ -200,17 +200,17 @@ NS_GetContentList(nsINode* aRootNode,
   nsContentListKey hashKey(aRootNode, aMatchNameSpaceId, aTagname);
   uint32_t recentlyUsedCacheIndex = RecentlyUsedCacheIndex(hashKey);
   nsContentList* cachedList = sRecentlyUsedContentLists[recentlyUsedCacheIndex];
   if (cachedList && cachedList->MatchesKey(hashKey)) {
     list = cachedList;
     return list.forget();
   }
 
-  static PLDHashTableOps hash_table_ops =
+  static const PLDHashTableOps hash_table_ops =
   {
     PL_DHashAllocTable,
     PL_DHashFreeTable,
     ContentListHashtableHashKey,
     ContentListHashtableMatchEntry,
     PL_DHashMoveEntryStub,
     PL_DHashClearEntryStub,
     PL_DHashFinalizeStub
@@ -321,17 +321,17 @@ GetFuncStringContentList(nsINode* aRootN
                          nsContentListDestroyFunc aDestroyFunc,
                          nsFuncStringContentListDataAllocator aDataAllocator,
                          const nsAString& aString)
 {
   NS_ASSERTION(aRootNode, "content list has to have a root");
 
   nsRefPtr<nsCacheableFuncStringContentList> list;
 
-  static PLDHashTableOps hash_table_ops =
+  static const PLDHashTableOps hash_table_ops =
   {
     PL_DHashAllocTable,
     PL_DHashFreeTable,
     FuncStringContentListHashtableHashKey,
     FuncStringContentListHashtableMatchEntry,
     PL_DHashMoveEntryStub,
     PL_DHashClearEntryStub,
     PL_DHashFinalizeStub
--- a/content/base/src/nsContentUtils.cpp
+++ b/content/base/src/nsContentUtils.cpp
@@ -390,17 +390,17 @@ nsContentUtils::Init()
   
   rv = CallGetService(NS_WBRK_CONTRACTID, &sWordBreaker);
   NS_ENSURE_SUCCESS(rv, rv);
 
   if (!InitializeEventTable())
     return NS_ERROR_FAILURE;
 
   if (!sEventListenerManagersHash.ops) {
-    static PLDHashTableOps hash_table_ops =
+    static const PLDHashTableOps hash_table_ops =
     {
       PL_DHashAllocTable,
       PL_DHashFreeTable,
       PL_DHashVoidPtrKeyStub,
       PL_DHashMatchEntryStub,
       PL_DHashMoveEntryStub,
       EventListenerManagerHashClearEntry,
       PL_DHashFinalizeStub,
--- a/content/base/src/nsDocument.cpp
+++ b/content/base/src/nsDocument.cpp
@@ -3587,17 +3587,17 @@ nsDocument::SetSubDocumentFor(Element* a
       if (PL_DHASH_ENTRY_IS_BUSY(entry)) {
         PL_DHashTableRawRemove(mSubDocuments, entry);
       }
     }
   } else {
     if (!mSubDocuments) {
       // Create a new hashtable
 
-      static PLDHashTableOps hash_table_ops =
+      static const PLDHashTableOps hash_table_ops =
       {
         PL_DHashAllocTable,
         PL_DHashFreeTable,
         PL_DHashVoidPtrKeyStub,
         PL_DHashMatchEntryStub,
         PL_DHashMoveEntryStub,
         SubDocClearEntry,
         PL_DHashFinalizeStub,
--- a/content/base/src/nsINode.cpp
+++ b/content/base/src/nsINode.cpp
@@ -2314,24 +2314,76 @@ AddScopeElements(TreeMatchContext& aMatc
                  nsINode* aMatchContextNode)
 {
   if (aMatchContextNode->IsElement()) {
     aMatchContext.SetHasSpecifiedScope();
     aMatchContext.AddScopeElement(aMatchContextNode->AsElement());
   }
 }
 
+namespace {
+struct SelectorMatchInfo {
+  nsCSSSelectorList* const mSelectorList;
+  TreeMatchContext& mMatchContext;
+};
+}
+
+// Given an id, find elements with that id under aRoot that match aMatchInfo if
+// any is provided.  If no SelectorMatchInfo is provided, just find the ones
+// with the given id.  aRoot must be in the document.
+template<bool onlyFirstMatch, class T>
+inline static void
+FindMatchingElementsWithId(const nsAString& aId, nsINode* aRoot,
+                           SelectorMatchInfo* aMatchInfo,
+                           T& aList)
+{
+  MOZ_ASSERT(aRoot->IsInDoc(),
+             "Don't call me if the root is not in the document");
+  MOZ_ASSERT(aRoot->IsElement() || aRoot->IsNodeOfType(nsINode::eDOCUMENT),
+             "The optimization below to check ContentIsDescendantOf only for "
+             "elements depends on aRoot being either an element or a "
+             "document if it's in the document.  Note that document fragments "
+             "can't be IsInDoc(), so should never show up here.");
+
+  const nsSmallVoidArray* elements = aRoot->OwnerDoc()->GetAllElementsForId(aId);
+
+  if (!elements) {
+    // Nothing to do; we're done
+    return;
+  }
+
+  // XXXbz: Should we fall back to the tree walk if aRoot is not the
+  // document and |elements| is long, for some value of "long"?
+  for (int32_t i = 0; i < elements->Count(); ++i) {
+    Element *element = static_cast<Element*>(elements->ElementAt(i));
+    if (!aRoot->IsElement() ||
+        (element != aRoot &&
+           nsContentUtils::ContentIsDescendantOf(element, aRoot))) {
+      // We have an element with the right id and it's a strict descendant
+      // of aRoot.  Make sure it really matches the selector.
+      if (!aMatchInfo ||
+          nsCSSRuleProcessor::SelectorListMatches(element,
+                                                  aMatchInfo->mMatchContext,
+                                                  aMatchInfo->mSelectorList)) {
+        aList.AppendElement(element);
+        if (onlyFirstMatch) {
+          return;
+        }
+      }
+    }
+  }
+}
+
 // Actually find elements matching aSelectorList (which must not be
 // null) and which are descendants of aRoot and put them in aList.  If
 // onlyFirstMatch, then stop once the first one is found.
 template<bool onlyFirstMatch, class Collector, class T>
 MOZ_ALWAYS_INLINE static nsresult
 FindMatchingElements(nsINode* aRoot, const nsAString& aSelector, T &aList)
 {
-
   nsIDocument* doc = aRoot->OwnerDoc();
   nsIDocument::SelectorCache& cache = doc->GetSelectorCache();
   nsCSSSelectorList* selectorList = nullptr;
   bool haveCachedList = cache.GetList(aSelector, &selectorList);
 
   if (!haveCachedList) {
     nsresult rv = ParseSelectorList(aRoot, aSelector, &selectorList);
     if (NS_FAILED(rv)) {
@@ -2375,42 +2427,19 @@ FindMatchingElements(nsINode* aRoot, con
                "The optimization below to check ContentIsDescendantOf only for "
                "elements depends on aRoot being either an element or a "
                "document if it's in the document.");
   if (aRoot->IsInDoc() &&
       doc->GetCompatibilityMode() != eCompatibility_NavQuirks &&
       !selectorList->mNext &&
       selectorList->mSelectors->mIDList) {
     nsIAtom* id = selectorList->mSelectors->mIDList->mAtom;
-    const nsSmallVoidArray* elements =
-      doc->GetAllElementsForId(nsDependentAtomString(id));
-
-    // XXXbz: Should we fall back to the tree walk if aRoot is not the
-    // document and |elements| is long, for some value of "long"?
-    if (elements) {
-      for (int32_t i = 0; i < elements->Count(); ++i) {
-        Element *element = static_cast<Element*>(elements->ElementAt(i));
-        if (!aRoot->IsElement() ||
-            (element != aRoot &&
-             nsContentUtils::ContentIsDescendantOf(element, aRoot))) {
-          // We have an element with the right id and it's a strict descendant
-          // of aRoot.  Make sure it really matches the selector.
-          if (nsCSSRuleProcessor::SelectorListMatches(element, matchingContext,
-                                                      selectorList)) {
-            aList.AppendElement(element);
-            if (onlyFirstMatch) {
-              return NS_OK;
-            }
-          }
-        }
-      }
-    }
-
-    // No elements with this id, or none of them are our descendants,
-    // or none of them match.  We're done here.
+    SelectorMatchInfo info = { selectorList, matchingContext };
+    FindMatchingElementsWithId<onlyFirstMatch, T>(nsDependentAtomString(id),
+                                                  aRoot, &info, aList);
     return NS_OK;
   }
 
   Collector results;
   for (nsIContent* cur = aRoot->GetFirstChild();
        cur;
        cur = cur->GetNextNode(aRoot)) {
     if (cur->IsElement() &&
@@ -2487,16 +2516,39 @@ nsINode::QuerySelector(const nsAString& 
 nsresult
 nsINode::QuerySelectorAll(const nsAString& aSelector, nsIDOMNodeList **aReturn)
 {
   ErrorResult rv;
   *aReturn = nsINode::QuerySelectorAll(aSelector, rv).get();
   return rv.ErrorCode();
 }
 
+Element*
+nsINode::GetElementById(const nsAString& aId)
+{
+  MOZ_ASSERT(IsElement() || IsNodeOfType(eDOCUMENT_FRAGMENT),
+             "Bogus this object for GetElementById call");
+  if (IsInDoc()) {
+    ElementHolder holder;
+    FindMatchingElementsWithId<true>(aId, this, nullptr, holder);
+    return holder.mElement;
+  }
+
+  for (nsIContent* kid = GetFirstChild(); kid; kid = kid->GetNextNode(this)) {
+    if (!kid->IsElement()) {
+      continue;
+    }
+    nsIAtom* id = kid->AsElement()->GetID();
+    if (id && id->Equals(aId)) {
+      return kid->AsElement();
+    }
+  }
+  return nullptr;
+}
+
 JSObject*
 nsINode::WrapObject(JSContext *aCx, JS::Handle<JSObject*> aScope)
 {
   MOZ_ASSERT(IsDOMBinding());
 
   // Make sure one of these is true
   // (1) our owner document has a script handling object,
   // (2) Our owner document has had a script handling object, or has been marked
--- a/content/base/test/mochitest.ini
+++ b/content/base/test/mochitest.ini
@@ -527,16 +527,17 @@ support-files =
 [test_copypaste.xhtml]
 [test_createHTMLDocument.html]
 [test_declare_stylesheet_obsolete.html]
 [test_domparser_null_char.html]
 [test_domparsing.html]
 [test_elementTraversal.html]
 [test_fileapi.html]
 [test_fileapi_slice.html]
+[test_getElementById.html]
 [test_html_colors_quirks.html]
 [test_html_colors_standards.html]
 [test_html_in_xhr.html]
 [test_htmlcopyencoder.html]
 [test_htmlcopyencoder.xhtml]
 [test_ipc_messagemanager_blob.html]
 [test_meta_viewport0.html]
 [test_meta_viewport1.html]
--- a/content/base/test/moz.build
+++ b/content/base/test/moz.build
@@ -5,18 +5,16 @@
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
 TEST_TOOL_DIRS += [
     'chrome',
     'csp',
     'websocket_hybi',
 ]
 
-MODULE = 'content'
-
 XPCSHELL_TESTS_MANIFESTS += ['unit/xpcshell.ini']
 
 # FIXME/bug 575918: out-of-process xpcshell is broken on OS X
 if CONFIG['OS_ARCH'] != 'Darwin':
     XPCSHELL_TESTS_MANIFESTS += ['unit_ipc/xpcshell.ini']
 
 CPP_UNIT_TESTS += [
     'TestGetURL.cpp',
new file mode 100644
--- /dev/null
+++ b/content/base/test/test_getElementById.html
@@ -0,0 +1,58 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=933193
+-->
+<head>
+  <meta charset="utf-8">
+  <title>Test for Bug 933193</title>
+  <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
+</head>
+<body>
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=933193">Mozilla Bug 933193</a>
+<p id="display"></p>
+<div id="content" style="display: none">
+
+</div>
+<pre id="test">
+</pre>
+  <script type="application/javascript">
+
+  /** Test for Bug 933193 **/
+    var kid = document.createElement("span");
+    kid.id = "test";
+    var svg = document.createElementNS("http://www.w3.org/2000/svg", "svg");
+    svg.appendChild(kid);
+    is(svg.getElementById("test"), kid,
+       "Should find the right node when not in the DOM");
+
+    var newKid = document.createElement("span");
+    newKid.id = "test";
+    var newKidParent = document.createElement("span");
+    newKidParent.appendChild(newKid);
+    svg.insertBefore(newKidParent, kid);
+    is(svg.getElementById("test"), newKid,
+       "Should find the first right node when not in the DOM");
+    newKid.remove();
+    is(svg.getElementById("test"), kid,
+       "Should find the right node again when not in the DOM");
+
+    document.body.appendChild(svg);
+    is(svg.getElementById("test"), kid,
+       "Should find the right node when in the DOM");
+
+    is(document.getElementById("test").localName, "pre",
+       "document.getElementById should find the first element in the " +
+       "document with that id");
+
+    var frag = document.createDocumentFragment();
+    is(frag.getElementById("test"), null, "Shouldn't find what does not exist");
+    frag.appendChild(kid);
+    is(frag.getElementById("test"), kid,
+       "Should find the right node in the document fragment");
+    is(svg.getElementById("test"), null,
+       "Shouldn't find the kid since it's gone now");
+  </script>
+</body>
+</html>
--- a/content/canvas/public/moz.build
+++ b/content/canvas/public/moz.build
@@ -5,18 +5,16 @@
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
 XPIDL_SOURCES += [
     'nsICanvasGLPrivate.idl',
 ]
 
 XPIDL_MODULE = 'content_canvas'
 
-MODULE = 'content'
-
 EXPORTS += [
     'nsICanvasElementExternal.h',
     'nsICanvasRenderingContextInternal.h',
 ]
 
 EXPORTS.mozilla.ipc += [
     'DocumentRendererChild.h',
     'DocumentRendererNativeIDChild.h',
--- a/content/canvas/src/moz.build
+++ b/content/canvas/src/moz.build
@@ -1,16 +1,14 @@
 # -*- 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/.
 
-MODULE = 'content'
-
 EXPORTS.mozilla.dom += [
     'CanvasGradient.h',
     'CanvasPattern.h',
     'CanvasRenderingContext2D.h',
     'CanvasUtils.h',
     'ImageData.h',
     'TextMetrics.h',
 ]
@@ -78,24 +76,21 @@ if CONFIG['MOZ_WEBGL']:
     ]
 else:
     UNIFIED_SOURCES += [
         'WebGLContextNotSupported.cpp',
     ]
 
 FAIL_ON_WARNINGS = True
 
-LIBXUL_LIBRARY = True
-
 MSVC_ENABLE_PGO = True
 
-LIBRARY_NAME = 'gkconcvs_s'
-
 include('/ipc/chromium/chromium-config.mozbuild')
 
+FINAL_LIBRARY = 'gklayout'
 LOCAL_INCLUDES += [
     '/content/base/src',
     '/content/html/content/src',
     '/content/xul/content/src',
     '/dom/base',
     '/image/src',
     '/js/xpconnect/src',
     '/layout/generic',
--- a/content/events/public/moz.build
+++ b/content/events/public/moz.build
@@ -5,18 +5,16 @@
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
 XPIDL_SOURCES += [
     'nsIEventListenerService.idl',
 ]
 
 XPIDL_MODULE = 'content_events'
 
-MODULE = 'content'
-
 EXPORTS += [
     'nsAsyncDOMEvent.h',
     'nsDOMKeyNameList.h',
     'nsEventDispatcher.h',
     'nsEventNameList.h',
     'nsEventStates.h',
     'nsIPrivateTextEvent.h',
     'nsIPrivateTextRange.h',
--- a/content/events/src/moz.build
+++ b/content/events/src/moz.build
@@ -1,33 +1,31 @@
 # -*- 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/.
 
-MODULE = 'content'
-
 EXPORTS += [
     'nsDOMEvent.h',
     'nsDOMEventTargetHelper.h',
     'nsDOMTouchEvent.h',
     'nsDOMUIEvent.h',
     'nsEventListenerManager.h',
     'nsEventStateManager.h',
 ]
 
 EXPORTS.mozilla.dom += [
     'Touch.h',
 ]
 
 if CONFIG['MOZ_WEBSPEECH']:
     EXPORTS.mozilla.dom += ['SpeechRecognitionError.h']
 
-SOURCES += [
+UNIFIED_SOURCES += [
     'DOMWheelEvent.cpp',
     'EventTarget.cpp',
     'nsAsyncDOMEvent.cpp',
     'nsContentEventHandler.cpp',
     'nsDOMAnimationEvent.cpp',
     'nsDOMBeforeUnloadEvent.cpp',
     'nsDOMClipboardEvent.cpp',
     'nsDOMCommandEvent.cpp',
@@ -51,37 +49,38 @@ SOURCES += [
     'nsDOMTextEvent.cpp',
     'nsDOMTouchEvent.cpp',
     'nsDOMTransitionEvent.cpp',
     'nsDOMUIEvent.cpp',
     'nsDOMXULCommandEvent.cpp',
     'nsEventDispatcher.cpp',
     'nsEventListenerManager.cpp',
     'nsEventListenerService.cpp',
-    'nsEventStateManager.cpp',
     'nsIMEStateManager.cpp',
     'nsPaintRequest.cpp',
     'nsPrivateTextRange.cpp',
     'TextComposition.cpp',
     'Touch.cpp',
 ]
 
+# nsEventStateManager.cpp should be built separately because of Mac OS X headers.
+SOURCES += [
+    'nsEventStateManager.cpp',
+]
+
 if CONFIG['MOZ_WEBSPEECH']:
-    SOURCES += ['SpeechRecognitionError.cpp']
+    UNIFIED_SOURCES += ['SpeechRecognitionError.cpp']
 
 FAIL_ON_WARNINGS = True
 
-LIBXUL_LIBRARY = True
-
 MSVC_ENABLE_PGO = True
 
-LIBRARY_NAME = 'gkconevents_s'
-
 include('/ipc/chromium/chromium-config.mozbuild')
 
+FINAL_LIBRARY = 'gklayout'
 LOCAL_INCLUDES += [
     '/content/base/src',
     '/content/html/content/src',
     '/content/xml/content/src',
     '/content/xul/content/src',
     '/dom/base',
     '/dom/settings',
     '/dom/src/storage',
--- a/content/html/content/public/moz.build
+++ b/content/html/content/public/moz.build
@@ -8,18 +8,16 @@ XPIDL_SOURCES += [
     'nsIFormSubmitObserver.idl',
     'nsIHTMLMenu.idl',
     'nsIMenuBuilder.idl',
     'nsIPhonetic.idl',
 ]
 
 XPIDL_MODULE = 'content_html'
 
-MODULE = 'content'
-
 EXPORTS += [
     'nsFormSubmission.h',
     'nsIConstraintValidation.h',
     'nsIForm.h',
     'nsIFormControl.h',
     'nsIFormProcessor.h',
     'nsIHTMLCollection.h',
     'nsIRadioGroupContainer.h',
--- a/content/html/content/src/moz.build
+++ b/content/html/content/src/moz.build
@@ -1,16 +1,14 @@
 # -*- 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/.
 
-MODULE = 'content'
-
 EXPORTS += [
     'HTMLPropertiesCollection.h',
     'nsGenericHTMLElement.h',
     'nsHTMLDNSPrefetch.h',
 ]
 
 EXPORTS.mozilla.dom += [
     'HTMLAnchorElement.h',
@@ -153,24 +151,21 @@ SOURCES += [
     'TextTrackManager.cpp',
     'TimeRanges.cpp',
     'UndoManager.cpp',
     'ValidityState.cpp',
 ]
 
 FAIL_ON_WARNINGS = True
 
-LIBXUL_LIBRARY = True
-
 MSVC_ENABLE_PGO = True
 
-LIBRARY_NAME = 'gkconhtmlcon_s'
-
 include('/ipc/chromium/chromium-config.mozbuild')
 
+FINAL_LIBRARY = 'gklayout'
 LOCAL_INCLUDES += [
     '/content/base/src',
     '/content/canvas/src',
     '/content/events/src',
     '/content/html/document/src',
     '/content/media/',
     '/content/xbl/src',
     '/content/xul/content/src',
--- a/content/html/document/public/moz.build
+++ b/content/html/document/public/moz.build
@@ -5,10 +5,8 @@
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
 XPIDL_SOURCES += [
     'nsIImageDocument.idl',
 ]
 
 XPIDL_MODULE = 'content_htmldoc'
 
-MODULE = 'content'
-
--- a/content/html/document/src/moz.build
+++ b/content/html/document/src/moz.build
@@ -1,16 +1,14 @@
 # -*- 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/.
 
-MODULE = 'content'
-
 EXPORTS += [
     'nsIHTMLDocument.h',
 ]
 
 EXPORTS.mozilla.dom += [
     'HTMLAllCollection.h',
     'ImageDocument.h',
 ]
@@ -20,25 +18,23 @@ SOURCES += [
     'ImageDocument.cpp',
     'MediaDocument.cpp',
     'nsHTMLContentSink.cpp',
     'nsHTMLDocument.cpp',
     'PluginDocument.cpp',
     'VideoDocument.cpp',
 ]
 
-LIBRARY_NAME = 'gkconhtmldoc_s'
-
 FAIL_ON_WARNINGS = True
 
-LIBXUL_LIBRARY = True
-
 MSVC_ENABLE_PGO = True
 
 LOCAL_INCLUDES += [
     '../../content/src',
     '/caps/include',
     '/content/base/src',
     '/content/events/src',
     '/dom/base',
     '/layout/style',
     '/xpcom/ds',
 ]
+
+FINAL_LIBRARY = 'gklayout'
--- a/content/mathml/content/src/moz.build
+++ b/content/mathml/content/src/moz.build
@@ -1,25 +1,20 @@
 # -*- 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/.
 
-MODULE = 'content'
-
 SOURCES += [
     'nsMathMLElement.cpp',
     'nsMathMLElementFactory.cpp',
 ]
 
 FAIL_ON_WARNINGS = True
 
-LIBXUL_LIBRARY = True
-
-LIBRARY_NAME = 'gkcontentmathml_s'
-
 include('/ipc/chromium/chromium-config.mozbuild')
 
+FINAL_LIBRARY = 'gklayout'
 LOCAL_INCLUDES += [
     '/content/base/src',
 ]
 
--- a/content/media/AudioSegment.cpp
+++ b/content/media/AudioSegment.cpp
@@ -121,46 +121,55 @@ AudioSegment::WriteTo(uint64_t aID, Audi
     TrackTicks offset = 0;
     while (offset < c.mDuration) {
       TrackTicks durationTicks =
         std::min<TrackTicks>(c.mDuration - offset, AUDIO_PROCESSING_FRAMES);
       if (uint64_t(outputChannels)*durationTicks > INT32_MAX || offset > INT32_MAX) {
         NS_ERROR("Buffer overflow");
         return;
       }
+
       uint32_t duration = uint32_t(durationTicks);
-      buf.SetLength(outputChannels*duration);
-      if (c.mBuffer) {
-        channelData.SetLength(c.mChannelData.Length());
-        for (uint32_t i = 0; i < channelData.Length(); ++i) {
-          channelData[i] =
-            AddAudioSampleOffset(c.mChannelData[i], c.mBufferFormat, int32_t(offset));
-        }
 
-        if (channelData.Length() < outputChannels) {
-          // Up-mix. Note that this might actually make channelData have more
-          // than outputChannels temporarily.
-          AudioChannelsUpMix(&channelData, outputChannels, gZeroChannel);
-        }
+      // If we have written data in the past, or we have real (non-silent) data
+      // to write, we can proceed. Otherwise, it means we just started the
+      // AudioStream, and we don't have real data to write to it (just silence).
+      // To avoid overbuffering in the AudioStream, we simply drop the silence,
+      // here. The stream will underrun and output silence anyways.
+      if (c.mBuffer || aOutput->GetWritten()) {
+        buf.SetLength(outputChannels*duration);
+        if (c.mBuffer) {
+          channelData.SetLength(c.mChannelData.Length());
+          for (uint32_t i = 0; i < channelData.Length(); ++i) {
+            channelData[i] =
+              AddAudioSampleOffset(c.mChannelData[i], c.mBufferFormat, int32_t(offset));
+          }
 
-        if (channelData.Length() > outputChannels) {
-          // Down-mix.
-          DownmixAndInterleave(channelData, c.mBufferFormat, duration,
-                               c.mVolume, outputChannels, buf.Elements());
+          if (channelData.Length() < outputChannels) {
+            // Up-mix. Note that this might actually make channelData have more
+            // than outputChannels temporarily.
+            AudioChannelsUpMix(&channelData, outputChannels, gZeroChannel);
+          }
+
+          if (channelData.Length() > outputChannels) {
+            // Down-mix.
+            DownmixAndInterleave(channelData, c.mBufferFormat, duration,
+                                 c.mVolume, outputChannels, buf.Elements());
+          } else {
+            InterleaveAndConvertBuffer(channelData.Elements(), c.mBufferFormat,
+                                       duration, c.mVolume,
+                                       outputChannels,
+                                       buf.Elements());
+          }
         } else {
-          InterleaveAndConvertBuffer(channelData.Elements(), c.mBufferFormat,
-                                     duration, c.mVolume,
-                                     outputChannels,
-                                     buf.Elements());
+          // Assumes that a bit pattern of zeroes == 0.0f
+          memset(buf.Elements(), 0, buf.Length()*sizeof(AudioDataValue));
         }
-      } else {
-        // Assumes that a bit pattern of zeroes == 0.0f
-        memset(buf.Elements(), 0, buf.Length()*sizeof(AudioDataValue));
+        aOutput->Write(buf.Elements(), int32_t(duration), &(c.mTimeStamp));
       }
-      aOutput->Write(buf.Elements(), int32_t(duration), &(c.mTimeStamp));
       if(!c.mTimeStamp.IsNull()) {
         TimeStamp now = TimeStamp::Now();
         // would be more efficient to c.mTimeStamp to ms on create time then pass here
         LogTime(AsyncLatencyLogger::AudioMediaStreamTrack, aID,
                 (now - c.mTimeStamp).ToMilliseconds(), c.mTimeStamp);
       }
       offset += duration;
     }
--- a/content/media/AudioStream.cpp
+++ b/content/media/AudioStream.cpp
@@ -139,16 +139,17 @@ static cubeb_stream_type ConvertChannelT
 #endif
 
 AudioStream::AudioStream()
 : mInRate(0),
   mOutRate(0),
   mChannels(0),
   mWritten(0),
   mAudioClock(MOZ_THIS_IN_INITIALIZER_LIST()),
+  mLatencyRequest(HighLatency),
   mReadPoint(0)
 {}
 
 void AudioStream::InitLibrary()
 {
 #ifdef PR_LOGGING
   gAudioStreamLog = PR_NewLogModule("AudioStream");
 #endif
@@ -359,16 +360,17 @@ private:
   }
 
   long DataCallback(void* aBuffer, long aFrames);
   void StateCallback(cubeb_state aState);
 
   // aTime is the time in ms the samples were inserted into MediaStreamGraph
   long GetUnprocessed(void* aBuffer, long aFrames, int64_t &aTime);
   long GetTimeStretched(void* aBuffer, long aFrames, int64_t &aTime);
+  long GetUnprocessedWithSilencePadding(void* aBuffer, long aFrames, int64_t &aTime);
 
   // Shared implementation of underflow adjusted position calculation.
   // Caller must own the monitor.
   int64_t GetPositionInFramesUnlocked();
 
   void StartUnlocked();
 
   // The monitor is held to protect all access to member variables.  Write()
@@ -572,16 +574,17 @@ BufferedAudioStream::Init(int32_t aNumCh
   if (!cubebContext || aNumChannels < 0 || aRate < 0) {
     return NS_ERROR_FAILURE;
   }
 
   PR_LOG(gAudioStreamLog, PR_LOG_DEBUG,
     ("%s  channels: %d, rate: %d", __FUNCTION__, aNumChannels, aRate));
   mInRate = mOutRate = aRate;
   mChannels = aNumChannels;
+  mLatencyRequest = aLatencyRequest;
 
   mDumpFile = OpenDumpFile(this);
 
   cubeb_stream_params params;
   params.rate = aRate;
   params.channels = aNumChannels;
 #if defined(__ANDROID__)
 #if defined(MOZ_B2G)
@@ -629,16 +632,23 @@ BufferedAudioStream::Init(int32_t aNumCh
 
   // Size mBuffer for one second of audio.  This value is arbitrary, and was
   // selected based on the observed behaviour of the existing AudioStream
   // implementations.
   uint32_t bufferLimit = FramesToBytes(aRate);
   NS_ABORT_IF_FALSE(bufferLimit % mBytesPerFrame == 0, "Must buffer complete frames");
   mBuffer.SetCapacity(bufferLimit);
 
+  // Start the stream right away when low latency has been requested. This means
+  // that the DataCallback will feed silence to cubeb, until the first frames
+  // are writtent to this BufferedAudioStream.
+  if (mLatencyRequest == AudioStream::LowLatency) {
+    Start();
+  }
+
   return NS_OK;
 }
 
 void
 BufferedAudioStream::Shutdown()
 {
   if (mState == STARTED) {
     Pause();
@@ -907,16 +917,42 @@ BufferedAudioStream::GetUnprocessed(void
 
   // First time block now has our first returned sample
   mReadPoint += BytesToFrames(available);
   GetBufferInsertTime(aTimeMs);
 
   return BytesToFrames(available) + flushedFrames;
 }
 
+// Get unprocessed samples, and pad the beginning of the buffer with silence if
+// there is not enough data.
+long
+BufferedAudioStream::GetUnprocessedWithSilencePadding(void* aBuffer, long aFrames, int64_t& aTimeMs)
+{
+  uint32_t toPopBytes = FramesToBytes(aFrames);
+  uint32_t available = std::min(toPopBytes, mBuffer.Length());
+  uint32_t silenceOffset = toPopBytes - available;
+
+  uint8_t* wpos = reinterpret_cast<uint8_t*>(aBuffer);
+
+  memset(wpos, 0, silenceOffset);
+  wpos += silenceOffset;
+
+  void* input[2];
+  uint32_t input_size[2];
+  mBuffer.PopElements(available, &input[0], &input_size[0], &input[1], &input_size[1]);
+  memcpy(wpos, input[0], input_size[0]);
+  wpos += input_size[0];
+  memcpy(wpos, input[1], input_size[1]);
+
+  GetBufferInsertTime(aTimeMs);
+
+  return aFrames;
+}
+
 long
 BufferedAudioStream::GetTimeStretched(void* aBuffer, long aFrames, int64_t &aTimeMs)
 {
   long processedFrames = 0;
 
   // We need to call the non-locking version, because we already have the lock.
   if (AudioStream::EnsureTimeStretcherInitialized() != NS_OK) {
     return 0;
@@ -960,18 +996,26 @@ BufferedAudioStream::DataCallback(void* 
   uint32_t available = std::min(static_cast<uint32_t>(FramesToBytes(aFrames)), mBuffer.Length());
   NS_ABORT_IF_FALSE(available % mBytesPerFrame == 0, "Must copy complete frames");
   AudioDataValue* output = reinterpret_cast<AudioDataValue*>(aBuffer);
   uint32_t underrunFrames = 0;
   uint32_t servicedFrames = 0;
   int64_t insertTime;
 
   if (available) {
+    // When we are playing a low latency stream, and it is the first time we are
+    // getting data from the buffer, we prefer to add the silence for an
+    // underrun at the beginning of the buffer, so the first buffer is not cut
+    // in half by the silence inserted to compensate for the underrun.
     if (mInRate == mOutRate) {
-      servicedFrames = GetUnprocessed(output, aFrames, insertTime);
+      if (mLatencyRequest == AudioStream::LowLatency && !mWritten) {
+        servicedFrames = GetUnprocessedWithSilencePadding(output, aFrames, insertTime);
+      } else {
+        servicedFrames = GetUnprocessed(output, aFrames, insertTime);
+      }
     } else {
       servicedFrames = GetTimeStretched(output, aFrames, insertTime);
     }
     float scaled_volume = float(GetVolumeScale() * mVolume);
 
     ScaleAudioSamples(output, aFrames * mChannels, scaled_volume);
 
     NS_ABORT_IF_FALSE(mBuffer.Length() % mBytesPerFrame == 0, "Must copy complete frames");
--- a/content/media/AudioStream.h
+++ b/content/media/AudioStream.h
@@ -202,16 +202,18 @@ protected:
   // Number of frames written to the buffers.
   int64_t mWritten;
   AudioClock mAudioClock;
   nsAutoPtr<soundtouch::SoundTouch> mTimeStretcher;
   nsRefPtr<AsyncLatencyLogger> mLatencyLog;
 
   // copy of Latency logger's starting time for offset calculations
   TimeStamp mStartTime;
+  // Whether we are playing a low latency stream, or a normal stream.
+  LatencyRequest mLatencyRequest;
   // Where in the current mInserts[0] block cubeb has read to
   int64_t mReadPoint;
   // Keep track of each inserted block of samples and the time it was inserted
   // so we can estimate the clock time for a specific sample's insertion (for when
   // we send data to cubeb).  Blocks are aged out as needed.
   struct Inserts {
     int64_t mTimeMs;
     int64_t mFrames;
--- a/content/media/apple/moz.build
+++ b/content/media/apple/moz.build
@@ -1,24 +1,19 @@
 # -*- 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/.
 
-MODULE = 'content'
-
 EXPORTS += [
     'AppleDecoder.h',
     'AppleMP3Reader.h',
 ]
 
 UNIFIED_SOURCES += [
     'AppleDecoder.cpp',
     'AppleMP3Reader.cpp',
 ]
 
-LIBRARY_NAME = 'gkconapplemedia_s'
-
 FAIL_ON_WARNINGS = True
 
-LIBXUL_LIBRARY = True
-
+FINAL_LIBRARY = 'gklayout'
--- a/content/media/directshow/moz.build
+++ b/content/media/directshow/moz.build
@@ -1,16 +1,14 @@
 # -*- 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/.
 
-MODULE = 'content'
-
 EXPORTS += [
     'AudioSinkFilter.h',
     'AudioSinkInputPin.h',
     'DirectShowDecoder.h',
     'DirectShowReader.h',
     'DirectShowUtils.h',
 ]
 
@@ -31,16 +29,13 @@ if not CONFIG['MOZ_WEBRTC']:
         'media/webrtc/trunk/webrtc/modules/video_capture/windows/BaseFilter.cpp',
         'media/webrtc/trunk/webrtc/modules/video_capture/windows/BaseInputPin.cpp',
         'media/webrtc/trunk/webrtc/modules/video_capture/windows/BasePin.cpp',
         'media/webrtc/trunk/webrtc/modules/video_capture/windows/MediaType.cpp',
     ]]
 
 FAIL_ON_WARNINGS = True
 
-LIBXUL_LIBRARY = True
-
-LIBRARY_NAME = 'gkcondirectshow_s'
-
+FINAL_LIBRARY = 'gklayout'
 LOCAL_INCLUDES += [
     '/media/webrtc/trunk/webrtc/modules/video_capture/windows',
 ]
 
--- a/content/media/encoder/moz.build
+++ b/content/media/encoder/moz.build
@@ -1,16 +1,14 @@
 # -*- 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/.
 
-MODULE = 'content'
-
 EXPORTS += [
     'ContainerWriter.h',
     'EncodedFrameContainer.h',
     'MediaEncoder.h',
     'TrackEncoder.h',
     'TrackMetadataBase.h',
 ]
 
@@ -18,14 +16,11 @@ UNIFIED_SOURCES += [
     'MediaEncoder.cpp',
     'TrackEncoder.cpp',
 ]
 
 if CONFIG['MOZ_OPUS']:
     EXPORTS += ['OpusTrackEncoder.h']
     UNIFIED_SOURCES += ['OpusTrackEncoder.cpp']
 
-LIBRARY_NAME = 'gkconencoder_s'
-
 FAIL_ON_WARNINGS = True
 
-LIBXUL_LIBRARY = True
-
+FINAL_LIBRARY = 'gklayout'
--- a/content/media/gstreamer/moz.build
+++ b/content/media/gstreamer/moz.build
@@ -1,34 +1,29 @@
 # -*- 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/.
 
-MODULE = 'content'
-
 EXPORTS += [
     'GStreamerDecoder.h',
     'GStreamerFormatHelper.h',
     'GStreamerLoader.h',
     'GStreamerReader.h',
 ]
 
 SOURCES += [
     'GStreamerDecoder.cpp',
     'GStreamerFormatHelper.cpp',
     'GStreamerLoader.cpp',
     'GStreamerMozVideoBuffer.cpp',
     'GStreamerReader.cpp',
 ]
 
-LIBRARY_NAME = 'gkcongstreamer_s'
-
 FAIL_ON_WARNINGS = True
 
-LIBXUL_LIBRARY = True
-
+FINAL_LIBRARY = 'gklayout'
 LOCAL_INCLUDES += [
     '/content/base/src',
     '/content/html/content/src',
 ]
 
--- a/content/media/mediasource/moz.build
+++ b/content/media/mediasource/moz.build
@@ -2,18 +2,16 @@
 # 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/.
 
 PARALLEL_DIRS += [
     'test'
 ]
 
-MODULE = 'content'
-
 EXPORTS += [
     'AsyncEventRunner.h',
     'MediaSourceDecoder.h',
 ]
 
 EXPORTS.mozilla.dom += [
     'MediaSource.h',
     'SourceBuffer.h',
@@ -25,12 +23,9 @@ UNIFIED_SOURCES += [
     'MediaSourceDecoder.cpp',
     'SourceBuffer.cpp',
     'SourceBufferList.cpp',
     'SourceBufferResource.cpp',
 ]
 
 FAIL_ON_WARNINGS = True
 
-LIBXUL_LIBRARY = True
-
-LIBRARY_NAME = 'gkconmediasource_s'
-
+FINAL_LIBRARY = 'gklayout'
--- a/content/media/moz.build
+++ b/content/media/moz.build
@@ -43,18 +43,16 @@ PARALLEL_DIRS += ['webrtc']
 if CONFIG['MOZ_OMX_DECODER']:
     PARALLEL_DIRS += ['omx']
     PARALLEL_DIRS += ['omx/mediaresourcemanager']
 
 PARALLEL_DIRS += ['webspeech']
 
 TEST_DIRS += ['test']
 
-MODULE = 'content'
-
 EXPORTS += [
     'AbstractMediaDecoder.h',
     'AudioAvailableEventManager.h',
     'AudioChannelFormat.h',
     'AudioEventTimeline.h',
     'AudioNodeEngine.h',
     'AudioNodeExternalInputStream.h',
     'AudioNodeStream.h',
@@ -145,24 +143,21 @@ SOURCES += [
 
 FAIL_ON_WARNINGS = True
 
 if CONFIG['CPU_ARCH'] == 'arm' and CONFIG['BUILD_ARM_NEON']:
     SOURCES += [
         'AudioNodeEngineNEON.cpp',
     ]
 
-LIBXUL_LIBRARY = True
-
 MSVC_ENABLE_PGO = True
 
-LIBRARY_NAME = 'gkconmedia_s'
-
 include('/ipc/chromium/chromium-config.mozbuild')
 
+FINAL_LIBRARY = 'gklayout'
 LOCAL_INCLUDES += [
     '/content/base/src',
     '/layout/generic',
     '/layout/xul/base/src',
 ]
 
 if CONFIG['MOZ_DIRECTSHOW']:
     LOCAL_INCLUDES += [
--- a/content/media/ogg/moz.build
+++ b/content/media/ogg/moz.build
@@ -1,28 +1,23 @@
 # -*- 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/.
 
-MODULE = 'content'
-
 EXPORTS += [
     'OggCodecState.h',
     'OggDecoder.h',
     'OggReader.h',
     'OggWriter.h',
 ]
 
 UNIFIED_SOURCES += [
     'OggCodecState.cpp',
     'OggDecoder.cpp',
     'OggReader.cpp',
     'OggWriter.cpp',
 ]
 
-LIBRARY_NAME = 'gkconogg_s'
-
 FAIL_ON_WARNINGS = True
 
-LIBXUL_LIBRARY = True
-
+FINAL_LIBRARY = 'gklayout'
--- a/content/media/omx/mediaresourcemanager/moz.build
+++ b/content/media/omx/mediaresourcemanager/moz.build
@@ -1,21 +1,17 @@
 # -*- 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/.
 
-MODULE = 'content'
-
 SOURCES += [
     'IMediaResourceManagerClient.cpp',
     'IMediaResourceManagerDeathNotifier.cpp',
     'IMediaResourceManagerService.cpp',
     'MediaResourceManagerClient.cpp',
     'MediaResourceManagerService.cpp',
 ]
 
-LIBRARY_NAME = 'mediaresourcemanager'
-
 include('/ipc/chromium/chromium-config.mozbuild')
 
-FORCE_STATIC_LIB = True
+FINAL_LIBRARY = 'gklayout'
--- a/content/media/omx/moz.build
+++ b/content/media/omx/moz.build
@@ -1,16 +1,14 @@
 # -*- 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/.
 
-MODULE = 'content'
-
 EXPORTS += [
     'MediaOmxDecoder.h',
     'MediaOmxReader.h',
 ]
 
 SOURCES += [
     'MediaOmxDecoder.cpp',
     'MediaOmxReader.cpp',
@@ -23,21 +21,18 @@ if 'rtsp' in CONFIG['NECKO_PROTOCOLS']:
         'RtspOmxDecoder.h',
         'RtspOmxReader.h',
     ]
     SOURCES += [
         'RtspOmxDecoder.cpp',
         'RtspOmxReader.cpp',
     ]
 
-LIBXUL_LIBRARY = True
-
-LIBRARY_NAME = 'gkconomx_s'
-
 include('/ipc/chromium/chromium-config.mozbuild')
 
+FINAL_LIBRARY = 'gklayout'
 LOCAL_INCLUDES += [
     '/content/base/src',
     '/content/html/content/src',
     '/ipc/chromium/src',
     'mediaresourcemanager',
 ]
 
--- a/content/media/plugins/moz.build
+++ b/content/media/plugins/moz.build
@@ -1,31 +1,27 @@
 # -*- 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/.
 
-MODULE = 'content'
-
 EXPORTS += [
     'MediaPluginDecoder.h',
     'MediaPluginHost.h',
     'MediaPluginReader.h',
     'MediaResourceServer.h',
     'MPAPI.h',
 ]
 
 SOURCES += [
     'MediaPluginDecoder.cpp',
     'MediaPluginHost.cpp',
     'MediaPluginReader.cpp',
     'MediaResourceServer.cpp',
 ]
 
-LIBRARY_NAME = 'gkconmediaplugins_s'
-
-LIBXUL_LIBRARY = True
-
 LOCAL_INCLUDES += [
     '/content/base/src',
     '/content/html/content/src',
     ]
+
+FINAL_LIBRARY = 'gklayout'
--- a/content/media/raw/moz.build
+++ b/content/media/raw/moz.build
@@ -1,29 +1,25 @@
 # -*- 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/.
 
-MODULE = 'content'
-
 EXPORTS += [
     'RawDecoder.h',
     'RawReader.h',
     'RawStructs.h',
 ]
 
 UNIFIED_SOURCES += [
     'RawDecoder.cpp',
     'RawReader.cpp',
 ]
 
-LIBRARY_NAME = 'gkconraw_s'
-
 FAIL_ON_WARNINGS = True
 
-LIBXUL_LIBRARY = True
-
 LOCAL_INCLUDES += [
     '/content/base/src',
     '/content/html/content/src',
 ]
+
+FINAL_LIBRARY = 'gklayout'
--- a/content/media/wave/moz.build
+++ b/content/media/wave/moz.build
@@ -1,24 +1,19 @@
 # -*- 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/.
 
-MODULE = 'content'
-
 EXPORTS += [
     'WaveDecoder.h',
     'WaveReader.h',
 ]
 
 UNIFIED_SOURCES += [
     'WaveDecoder.cpp',
     'WaveReader.cpp',
 ]
 
-LIBRARY_NAME = 'gkconwave_s'
-
 FAIL_ON_WARNINGS = True
 
-LIBXUL_LIBRARY = True
-
+FINAL_LIBRARY = 'gklayout'
--- a/content/media/webaudio/blink/moz.build
+++ b/content/media/webaudio/blink/moz.build
@@ -1,16 +1,14 @@
 # -*- 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/.
 
-MODULE = 'content'
-
 SOURCES += [
     'Biquad.cpp',
     'DirectConvolver.cpp',
     'DynamicsCompressor.cpp',
     'DynamicsCompressorKernel.cpp',
     'FFTConvolver.cpp',
     'HRTFDatabase.cpp',
     'HRTFDatabaseLoader.cpp',
@@ -21,18 +19,15 @@ SOURCES += [
     'Reverb.cpp',
     'ReverbAccumulationBuffer.cpp',
     'ReverbConvolver.cpp',
     'ReverbConvolverStage.cpp',
     'ReverbInputBuffer.cpp',
     'ZeroPole.cpp',
 ]
 
-LIBXUL_LIBRARY = True
-
-LIBRARY_NAME = 'gkconwebaudio_blink_s'
-
 include('/ipc/chromium/chromium-config.mozbuild')
 
+FINAL_LIBRARY = 'gklayout'
 LOCAL_INCLUDES += [
     '/content/media/webaudio',
 ]
 
--- a/content/media/webaudio/moz.build
+++ b/content/media/webaudio/moz.build
@@ -3,18 +3,16 @@
 # 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/.
 
 PARALLEL_DIRS += ['blink', 'test']
 
 TEST_TOOL_DIRS += ['compiledtest']
 
-MODULE = 'content'
-
 EXPORTS += [
     'AudioParamTimeline.h',
     'MediaBufferDecoder.h',
     'ThreeDPoint.h',
     'WebAudioUtils.h',
 ]
 
 EXPORTS.mozilla += [
@@ -81,14 +79,11 @@ SOURCES += [
     'ScriptProcessorNode.cpp',
     'ThreeDPoint.cpp',
     'WaveShaperNode.cpp',
     'WebAudioUtils.cpp',
 ]
 
 FAIL_ON_WARNINGS = True
 
-LIBXUL_LIBRARY = True
-
-LIBRARY_NAME = 'gkconwebaudio_s'
-
 include('/ipc/chromium/chromium-config.mozbuild')
 
+FINAL_LIBRARY = 'gklayout'
--- a/content/media/webm/moz.build
+++ b/content/media/webm/moz.build
@@ -1,25 +1,20 @@
 # -*- 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/.
 
-MODULE = 'content'
-
 EXPORTS += [
     'WebMDecoder.h',
     'WebMReader.h',
 ]
 
 UNIFIED_SOURCES += [
     'WebMBufferedParser.cpp',
     'WebMDecoder.cpp',
     'WebMReader.cpp',
 ]
 
-LIBRARY_NAME = 'gkconwebm_s'
-
 FAIL_ON_WARNINGS = True
 
-LIBXUL_LIBRARY = True
-
+FINAL_LIBRARY = 'gklayout'
--- a/content/media/webrtc/moz.build
+++ b/content/media/webrtc/moz.build
@@ -1,18 +1,16 @@
 # -*- 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/.
 
 XPIDL_MODULE = 'content_webrtc'
 
-MODULE = 'content'
-
 EXPORTS += [
     'MediaEngine.h',
     'MediaEngineDefault.h',
 ]
 
 if CONFIG['MOZ_WEBRTC']:
     EXPORTS += ['LoadMonitor.h', 'MediaEngineWebRTC.h']
     UNIFIED_SOURCES += [
@@ -36,16 +34,13 @@ if CONFIG['MOZ_WEBRTC']:
 XPIDL_SOURCES += [
     'nsITabSource.idl'
 ]
 
 UNIFIED_SOURCES += [
     'MediaEngineDefault.cpp',
 ]
 
-LIBXUL_LIBRARY = True
-
-LIBRARY_NAME = 'gkconwebrtc_s'
-
 include('/ipc/chromium/chromium-config.mozbuild')
 
+FINAL_LIBRARY = 'gklayout'
 if CONFIG['OS_ARCH'] == 'WINNT':
     DEFINES['NOMINMAX'] = True
--- a/content/media/webspeech/recognition/moz.build
+++ b/content/media/webspeech/recognition/moz.build
@@ -1,15 +1,13 @@
 # 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/.
 
-MODULE = 'content'
-
 XPIDL_MODULE = 'dom_webspeechrecognition'
 
 XPIDL_SOURCES = [
   'nsIDOMSpeechRecognitionEvent.idl',
   'nsISpeechRecognitionService.idl'
 ]
 
 TEST_DIRS += ['test']
@@ -35,17 +33,15 @@ UNIFIED_SOURCES += [
     'SpeechRecognition.cpp',
     'SpeechRecognitionAlternative.cpp',
     'SpeechRecognitionResult.cpp',
     'SpeechRecognitionResultList.cpp',
     'SpeechStreamListener.cpp',
     'test/FakeSpeechRecognitionService.cpp',
 ]
 
-LIBXUL_LIBRARY = True
-
-LIBRARY_NAME = 'gkconwebspeechrecognition_s'
-
 LOCAL_INCLUDES += [
     '/dom/base',
 ]
 
 include('/ipc/chromium/chromium-config.mozbuild')
+
+FINAL_LIBRARY = 'gklayout'
--- a/content/media/webspeech/synth/moz.build
+++ b/content/media/webspeech/synth/moz.build
@@ -1,15 +1,14 @@
 # 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/.
 
 if CONFIG['MOZ_WEBSPEECH']:
-    MODULE = 'content'
 
     TEST_DIRS += ['test', 'ipc/test']
 
     XPIDL_MODULE = 'dom_webspeechsynth'
 
     XPIDL_SOURCES += [
         'nsIDOMSpeechSynthesisEvent.idl',
         'nsISpeechService.idl',
@@ -43,19 +42,14 @@ if CONFIG['MOZ_WEBSPEECH']:
 
 IPDL_SOURCES += [
     'ipc/PSpeechSynthesis.ipdl',
     'ipc/PSpeechSynthesisRequest.ipdl',
 ]
 
 FAIL_ON_WARNINGS = True
 
-LIBXUL_LIBRARY = True
-
-LIBRARY_NAME = 'gkconwebspeechsynth_s'
-
-EXPORT_LIBRARY = True
-
 include('/ipc/chromium/chromium-config.mozbuild')
 
+FINAL_LIBRARY = 'gklayout'
 LOCAL_INCLUDES += [
     'ipc',
 ]
--- a/content/media/webspeech/synth/pico/moz.build
+++ b/content/media/webspeech/synth/pico/moz.build
@@ -1,19 +1,14 @@
 # -*- 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/.
 
-MODULE = 'synthpico'
-
 SOURCES += [
     'nsPicoService.cpp',
     'PicoModule.cpp'
 ]
-
-LIBRARY_NAME = 'synthpico'
-LIBXUL_LIBRARY = True
-EXPORT_LIBRARY = True
 FAIL_ON_WARNINGS = True
 include('/ipc/chromium/chromium-config.mozbuild')
 
+FINAL_LIBRARY = 'gklayout'
--- a/content/media/webvtt/moz.build
+++ b/content/media/webvtt/moz.build
@@ -4,18 +4,16 @@
 # 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/.
 
 XPIDL_SOURCES += [
   'nsIWebVTTListener.idl',
   'nsIWebVTTParserWrapper.idl',
 ]
 
-MODULE = 'webvtt'
-
 XPIDL_MODULE = 'webvtt'
 
 EXTRA_COMPONENTS += [
   'WebVTT.manifest',
   'WebVTTParserWrapper.js',
 ]
 
 EXTRA_JS_MODULES += [
--- a/content/media/wmf/moz.build
+++ b/content/media/wmf/moz.build
@@ -1,30 +1,25 @@
 # -*- 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/.
 
-MODULE = 'content'
-
 EXPORTS += [
     'WMF.h',
     'WMFDecoder.h',
     'WMFReader.h',
     'WMFUtils.h',
 ]
 
 SOURCES += [
     'DXVA2Manager.cpp',
     'WMFByteStream.cpp',
     'WMFDecoder.cpp',
     'WMFReader.cpp',
     'WMFSourceReaderCallback.cpp',
     'WMFUtils.cpp',
 ]
 
-LIBRARY_NAME = 'gkconwmf_s'
-
 FAIL_ON_WARNINGS = True
 
-LIBXUL_LIBRARY = True
-
+FINAL_LIBRARY = 'gklayout'
--- a/content/moz.build
+++ b/content/moz.build
@@ -16,10 +16,8 @@ PARALLEL_DIRS += [
     'xml',
     'xul',
     'xbl',
     'xslt',
 ]
 
 TEST_TOOL_DIRS += ['test']
 
-MODULE = 'content'
-
--- a/content/smil/moz.build
+++ b/content/smil/moz.build
@@ -1,18 +1,16 @@
 # -*- 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/.
 
 TEST_TOOL_DIRS += ['test']
 
-MODULE = 'content'
-
 EXPORTS += [
     'nsDOMTimeEvent.h',
     'nsISMILAttr.h',
     'nsISMILType.h',
     'nsSMILAnimationController.h',
     'nsSMILAnimationFunction.h',
     'nsSMILCompositorTable.h',
     'nsSMILCSSProperty.h',
@@ -58,17 +56,15 @@ SOURCES += [
     'SMILBoolType.cpp',
     'SMILEnumType.cpp',
     'SMILIntegerType.cpp',
     'SMILStringType.cpp',
 ]
 
 FAIL_ON_WARNINGS = True
 
-LIBXUL_LIBRARY = True
-
-LIBRARY_NAME = 'gkconsmil_s'
-
 LOCAL_INCLUDES += [
     '../base/src',
     '../events/src',
     '/layout/style',
 ]
+
+FINAL_LIBRARY = 'gklayout'
--- a/content/svg/content/src/SVGSVGElement.cpp
+++ b/content/svg/content/src/SVGSVGElement.cpp
@@ -430,28 +430,16 @@ SVGSVGElement::CreateSVGTransform()
 
 already_AddRefed<SVGTransform>
 SVGSVGElement::CreateSVGTransformFromMatrix(SVGMatrix& matrix)
 {
   nsRefPtr<SVGTransform> transform = new SVGTransform(matrix.Matrix());
   return transform.forget();
 }
 
-Element*
-SVGSVGElement::GetElementById(const nsAString& elementId, ErrorResult& rv)
-{
-  nsAutoString selector(NS_LITERAL_STRING("#"));
-  nsStyleUtil::AppendEscapedCSSIdent(PromiseFlatString(elementId), selector);
-  nsIContent* element = QuerySelector(selector, rv);
-  if (!rv.Failed() && element) {
-    return element->AsElement();
-  }
-  return nullptr;
-}
-
 //----------------------------------------------------------------------
 
 already_AddRefed<SVGAnimatedRect>
 SVGSVGElement::ViewBox()
 {
   return mViewBox.ToSVGAnimatedRect(this);
 }
 
--- a/content/svg/content/src/SVGSVGElement.h
+++ b/content/svg/content/src/SVGSVGElement.h
@@ -241,17 +241,17 @@ public:
   already_AddRefed<nsIDOMSVGNumber> CreateSVGNumber();
   already_AddRefed<nsIDOMSVGLength> CreateSVGLength();
   already_AddRefed<SVGAngle> CreateSVGAngle();
   already_AddRefed<nsISVGPoint> CreateSVGPoint();
   already_AddRefed<SVGMatrix> CreateSVGMatrix();
   already_AddRefed<SVGIRect> CreateSVGRect();
   already_AddRefed<SVGTransform> CreateSVGTransform();
   already_AddRefed<SVGTransform> CreateSVGTransformFromMatrix(SVGMatrix& matrix);
-  Element* GetElementById(const nsAString& elementId, ErrorResult& rv);
+  using nsINode::GetElementById; // This does what we want
   already_AddRefed<SVGAnimatedRect> ViewBox();
   already_AddRefed<DOMSVGAnimatedPreserveAspectRatio> PreserveAspectRatio();
   uint16_t ZoomAndPan();
   void SetZoomAndPan(uint16_t aZoomAndPan, ErrorResult& rv);
 
 private:
   // nsSVGElement overrides
 
--- a/content/svg/content/src/moz.build
+++ b/content/svg/content/src/moz.build
@@ -1,16 +1,14 @@
 # -*- 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/.
 
-MODULE = 'content'
-
 EXPORTS += [
     'nsSVGClass.h',
     'nsSVGElement.h',
     'nsSVGFeatures.h',
     'SVGAttrValueWrapper.h',
     'SVGPreserveAspectRatio.h',
     'SVGStringList.h',
 ]
@@ -242,22 +240,19 @@ UNIFIED_SOURCES += [
     'SVGUseElement.cpp',
     'SVGViewBoxSMILType.cpp',
     'SVGViewElement.cpp',
     'SVGZoomEvent.cpp',
 ]
 
 FAIL_ON_WARNINGS = True
 
-LIBXUL_LIBRARY = True
-
-LIBRARY_NAME = 'gkcontentsvg_s'
-
 include('/ipc/chromium/chromium-config.mozbuild')
 
+FINAL_LIBRARY = 'gklayout'
 LOCAL_INCLUDES += [
     '/content/base/src',
     '/content/events/src',
     '/content/html/content/src',
     '/content/smil',
     '/content/xbl/src',
     '/content/xml/content/src',
     '/dom',
--- a/content/svg/document/src/moz.build
+++ b/content/svg/document/src/moz.build
@@ -1,31 +1,27 @@
 # -*- 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/.
 
-MODULE = 'content'
-
 EXPORTS.mozilla.dom += [
     'SVGDocument.h',
 ]
 
 SOURCES += [
     'SVGDocument.cpp',
 ]
 
-LIBRARY_NAME = 'gkconsvgdoc_s'
-
 FAIL_ON_WARNINGS = True
 
-LIBXUL_LIBRARY = True
-
 LOCAL_INCLUDES += [
     '/content/base/src',
     '/content/events/src',
     '/content/html/document/src',
     '/content/svg/content/src',
     '/content/xml/document/src',
     '/layout/style',
     '/xpcom/ds',
 ]
+
+FINAL_LIBRARY = 'gklayout'
--- a/content/test/moz.build
+++ b/content/test/moz.build
@@ -1,9 +1,7 @@
 # -*- 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/.
 
-MODULE = 'test_content'
-
 XPCSHELL_TESTS_MANIFESTS += ['unit/xpcshell.ini']
--- a/content/xbl/src/moz.build
+++ b/content/xbl/src/moz.build
@@ -1,16 +1,14 @@
 # -*- 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/.
 
-MODULE = 'content'
-
 EXPORTS += [
     'nsBindingManager.h',
     'nsXBLBinding.h',
     'nsXBLService.h',
 ]
 
 EXPORTS.mozilla.dom += [
     'XBLChildrenElement.h',
@@ -33,25 +31,23 @@ SOURCES += [
     'nsXBLSerialize.cpp',
     'nsXBLService.cpp',
     'nsXBLWindowKeyHandler.cpp',
     'XBLChildrenElement.cpp',
 ]
 
 FAIL_ON_WARNINGS = True
 
-LIBXUL_LIBRARY = True
-
 MSVC_ENABLE_PGO = True
 
-LIBRARY_NAME = 'gkconxbl_s'
-
 LOCAL_INCLUDES += [
     '/content/base/src',
     '/content/events/src',
     '/content/html/document/src',
     '/content/xml/document/src',
     '/content/xul/content/src',
     '/content/xul/document/src',
     '/dom/base',
     '/layout/style',
     '/xpcom/ds',
 ]
+
+FINAL_LIBRARY = 'gklayout'
--- a/content/xbl/src/nsBindingManager.cpp
+++ b/content/xbl/src/nsBindingManager.cpp
@@ -87,17 +87,17 @@ static bool
 InitObjectEntry(PLDHashTable* table, PLDHashEntryHdr* entry, const void* key)
 {
   new (entry) ObjectEntry;
   return true;
 }
   
 
 
-static PLDHashTableOps ObjectTableOps = {
+static const PLDHashTableOps ObjectTableOps = {
   PL_DHashAllocTable,
   PL_DHashFreeTable,
   PL_DHashVoidPtrKeyStub,
   PL_DHashMatchEntryStub,
   PL_DHashMoveEntryStub,
   ClearObjectEntry,
   PL_DHashFinalizeStub,
   InitObjectEntry
--- a/content/xml/content/src/moz.build
+++ b/content/xml/content/src/moz.build
@@ -1,34 +1,29 @@
 # -*- 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/.
 
-MODULE = 'content'
-
 EXPORTS.mozilla.dom += [
     'CDATASection.h',
     'nsXMLElement.h',
     'ProcessingInstruction.h',
     'XMLStylesheetProcessingInstruction.h',
 ]
 
 SOURCES += [
     'CDATASection.cpp',
     'nsXMLElement.cpp',
     'ProcessingInstruction.cpp',
     'XMLStylesheetProcessingInstruction.cpp',
 ]
 
-LIBRARY_NAME = 'gkconxmlcon_s'
-
 FAIL_ON_WARNINGS = True
 
-LIBXUL_LIBRARY = True
-
 MSVC_ENABLE_PGO = True
 
+FINAL_LIBRARY = 'gklayout'
 LOCAL_INCLUDES += [
     '/content/base/src',
 ]
 
--- a/content/xml/document/public/moz.build
+++ b/content/xml/document/public/moz.build
@@ -1,12 +1,10 @@
 # -*- 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/.
 
-MODULE = 'content'
-
 EXPORTS += [
     'nsIXMLContentSink.h',
 ]
 
--- a/content/xml/document/src/moz.build
+++ b/content/xml/document/src/moz.build
@@ -1,37 +1,33 @@
 # -*- 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/.
 
-MODULE = 'content'
-
 EXPORTS.mozilla.dom += [
     'XMLDocument.h',
 ]
 
 SOURCES += [
     'nsXMLContentSink.cpp',
     'nsXMLFragmentContentSink.cpp',
     'nsXMLPrettyPrinter.cpp',
     'XMLDocument.cpp',
 ]
 
-LIBRARY_NAME = 'gkconxmldoc_s'
-
 FAIL_ON_WARNINGS = True
 
-LIBXUL_LIBRARY = True
-
 MSVC_ENABLE_PGO = True
 
 LOCAL_INCLUDES += [
     '/caps/include',
     '/content/base/src',
     '/content/events/src',
     '/content/html/document/src',
     '/content/xul/content/src',
     '/dom/base',
     '/layout/style',
     '/xpcom/ds',
     ]
+
+FINAL_LIBRARY = 'gklayout'
--- a/content/xslt/public/moz.build
+++ b/content/xslt/public/moz.build
@@ -11,14 +11,12 @@ XPIDL_SOURCES += [
     'txIEXSLTRegExFunctions.idl',
     'txIFunctionEvaluationContext.idl',
     'txINodeSet.idl',
     'txIXPathObject.idl',
 ]
 
 XPIDL_MODULE = 'content_xslt'
 
-MODULE = 'content'
-
 EXPORTS += [
     'nsIDocumentTransformer.h',
 ]
 
--- a/content/xslt/src/base/moz.build
+++ b/content/xslt/src/base/moz.build
@@ -1,28 +1,24 @@
 # -*- 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/.
 
-MODULE = 'transformiix'
-
 SOURCES += [
     'txDouble.cpp',
     'txExpandedNameMap.cpp',
     'txList.cpp',
     'txNamespaceMap.cpp',
     'txURIUtils.cpp',
 ]
 
-LIBRARY_NAME = 'txbase_s'
-
 FAIL_ON_WARNINGS = True
 
-LIBXUL_LIBRARY = True
-
 LOCAL_INCLUDES += [
     '../../public',
     '../xml',
     '../xpath',
     '../xslt',
 ]
+
+FINAL_LIBRARY = 'gklayout'
--- a/content/xslt/src/xml/moz.build
+++ b/content/xslt/src/xml/moz.build
@@ -1,25 +1,21 @@
 # -*- 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/.
 
-MODULE = 'transformiix'
-
 SOURCES += [
     'txXMLParser.cpp',
     'txXMLUtils.cpp',
 ]
 
-LIBRARY_NAME = 'txxml_s'
-
 FAIL_ON_WARNINGS = True
 
-LIBXUL_LIBRARY = True
-
 LOCAL_INCLUDES += [
     '../base',
     '../xpath',
     '../xslt',
     '/content/base/src',
 ]
+
+FINAL_LIBRARY = 'gklayout'
--- a/content/xslt/src/xpath/moz.build
+++ b/content/xslt/src/xpath/moz.build
@@ -1,16 +1,14 @@
 # -*- 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/.
 
-MODULE = 'transformiix'
-
 EXPORTS.mozilla.dom += [
     'XPathEvaluator.h',
 ]
 
 SOURCES += [
     'nsXPathExpression.cpp',
     'nsXPathNSResolver.cpp',
     'nsXPathResult.cpp',
@@ -46,19 +44,17 @@ SOURCES += [
     'txUnionExpr.cpp',
     'txUnionNodeTest.cpp',
     'txVariableRefExpr.cpp',
     'txXPathOptimizer.cpp',
     'txXPCOMExtensionFunction.cpp',
     'XPathEvaluator.cpp',
 ]
 
-LIBRARY_NAME = 'txxpath_s'
-
 FAIL_ON_WARNINGS = True
 
-LIBXUL_LIBRARY = True
-
 LOCAL_INCLUDES += [
     '../base',
     '../xml',
     '../xslt',
 ]
+
+FINAL_LIBRARY = 'gklayout'
--- a/content/xslt/src/xslt/moz.build
+++ b/content/xslt/src/xslt/moz.build
@@ -1,16 +1,14 @@
 # -*- 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/.
 
-MODULE = 'transformiix'
-
 SOURCES += [
     'txBufferingHandler.cpp',
     'txCurrentFunctionCall.cpp',
     'txDocumentFunctionCall.cpp',
     'txExecutionState.cpp',
     'txEXSLTFunctions.cpp',
     'txFormatNumberFunctionCall.cpp',
     'txGenerateIdFunctionCall.cpp',
@@ -39,23 +37,21 @@ SOURCES += [
     'txXSLTProcessor.cpp',
 ]
 
 EXTRA_COMPONENTS += [
     'txEXSLTRegExFunctions.js',
     'txEXSLTRegExFunctions.manifest',
 ]
 
-LIBRARY_NAME = 'txxslt_s'
-
 FAIL_ON_WARNINGS = True
 
-LIBXUL_LIBRARY = True
-
 # For nsDependentJSString
 LOCAL_INCLUDES += ["/dom/base"]
 
 LOCAL_INCLUDES += [
     '../base',
     '../xml',
     '../xpath',
     '/content/base/src',
 ]
+
+FINAL_LIBRARY = 'gklayout'
--- a/content/xul/content/moz.build
+++ b/content/xul/content/moz.build
@@ -2,10 +2,8 @@
 # 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/.
 
 PARALLEL_DIRS += ['public', 'src']
 TEST_DIRS += ['test']
 
-MODULE = 'xul'
-
--- a/content/xul/content/public/moz.build
+++ b/content/xul/content/public/moz.build
@@ -4,10 +4,10 @@
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
 if CONFIG['MOZ_XUL']:
     XPIDL_SOURCES += [
         'nsIXULContextMenuBuilder.idl',
     ]
 
-MODULE = 'xul'
+XPIDL_MODULE = 'xul'
 
--- a/content/xul/content/src/moz.build
+++ b/content/xul/content/src/moz.build
@@ -1,26 +1,22 @@
 # -*- 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/.
 
-MODULE = 'xul'
-
 if CONFIG['MOZ_XUL']:
-    LIBXUL_LIBRARY = True
     MSVC_ENABLE_PGO = True
 
     SOURCES += [
         'nsXULContextMenuBuilder.cpp',
         'nsXULElement.cpp',
         'nsXULPopupListener.cpp',
     ]
-    LIBRARY_NAME = 'gkconxulcon_s'
 
 FAIL_ON_WARNINGS = True
 
 LOCAL_INCLUDES += [
     '../../document/src',
     '../../templates/src',
     '/content/base/src',
     '/content/events/src',
@@ -28,8 +24,10 @@ LOCAL_INCLUDES += [
     '/content/xbl/src',
     '/content/xml/content/src',
     '/content/xml/document/src',
     '/layout/generic',
     '/layout/style',
     '/layout/xul/base/src',
     '/xpcom/ds',
 ]
+
+FINAL_LIBRARY = 'gklayout'
--- a/content/xul/document/moz.build
+++ b/content/xul/document/moz.build
@@ -2,10 +2,8 @@
 # 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/.
 
 PARALLEL_DIRS += ['public', 'src']
 DIRS += ['test']
 
-MODULE = 'xuldoc'
-
--- a/content/xul/document/public/moz.build
+++ b/content/xul/document/public/moz.build
@@ -12,10 +12,10 @@ XPIDL_SOURCES += [
 if CONFIG['MOZ_XUL']:
     XPIDL_SOURCES += [
         'nsIXULOverlayProvider.idl',
     ]
     EXPORTS += [
         'nsIXULDocument.h',
     ]
 
-MODULE = 'xuldoc'
+XPIDL_MODULE = 'xuldoc'
 
--- a/content/xul/document/src/XULDocument.cpp
+++ b/content/xul/document/src/XULDocument.cpp
@@ -775,17 +775,17 @@ XULDocument::AddBroadcastListenerFor(Ele
 
     rv = nsContentUtils::CheckSameOrigin(this, &aListener);
 
     if (NS_FAILED(rv)) {
         aRv.Throw(rv);
         return;
     }
 
-    static PLDHashTableOps gOps = {
+    static const PLDHashTableOps gOps = {
         PL_DHashAllocTable,
         PL_DHashFreeTable,
         PL_DHashVoidPtrKeyStub,
         PL_DHashMatchEntryStub,
         PL_DHashMoveEntryStub,
         ClearBroadcasterMapEntry,
         PL_DHashFinalizeStub,
         nullptr
--- a/content/xul/document/src/moz.build
+++ b/content/xul/document/src/moz.build
@@ -1,43 +1,39 @@
 # -*- 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/.
 
-MODULE = 'xuldoc'
-
 SOURCES += [
     'nsXULControllers.cpp',
 ]
 
 if CONFIG['MOZ_XUL']:
     SOURCES += [
         'nsXULCommandDispatcher.cpp',
         'nsXULContentSink.cpp',
         'nsXULPrototypeCache.cpp',
         'nsXULPrototypeDocument.cpp',
         'XULDocument.cpp',
     ]
 
-LIBRARY_NAME = 'gkconxuldoc_s'
-
 FAIL_ON_WARNINGS = True
 
-LIBXUL_LIBRARY = True
-
 MSVC_ENABLE_PGO = True
 
 LOCAL_INCLUDES += [
     '/content/base/src',
     '/content/events/src',
     '/content/xbl/src',
     '/content/xml/document/src',
     '/content/xul/content/src',
     '/content/xul/templates/src',
     '/dom/base',
     '/layout/base',
     '/layout/generic',
     '/layout/style',
     '/layout/xul/base/src',
     '/xpcom/ds',
 ]
+
+FINAL_LIBRARY = 'gklayout'
--- a/content/xul/templates/moz.build
+++ b/content/xul/templates/moz.build
@@ -2,10 +2,8 @@
 # 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/.
 
 PARALLEL_DIRS += ['public', 'src']
 TEST_TOOL_DIRS += ['tests/chrome']
 
-MODULE = 'xultmpl'
-
--- a/content/xul/templates/public/moz.build
+++ b/content/xul/templates/public/moz.build
@@ -8,10 +8,10 @@ XPIDL_SOURCES += [
     'nsIXULBuilderListener.idl',
     'nsIXULSortService.idl',
     'nsIXULTemplateBuilder.idl',
     'nsIXULTemplateQueryProcessor.idl',
     'nsIXULTemplateResult.idl',
     'nsIXULTemplateRuleFilter.idl',
 ]
 
-MODULE = 'xultmpl'
+XPIDL_MODULE = 'xultmpl'
 
--- a/content/xul/templates/src/moz.build
+++ b/content/xul/templates/src/moz.build
@@ -1,16 +1,14 @@
 # -*- 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/.
 
-MODULE = 'xultmpl'
-
 SOURCES += [
     'nsContentSupportMap.cpp',
     'nsContentTestNode.cpp',
     'nsInstantiationNode.cpp',
     'nsRDFBinding.cpp',
     'nsRDFConInstanceTestNode.cpp',
     'nsRDFConMemberTestNode.cpp',
     'nsRDFPropertyTestNode.cpp',
@@ -30,20 +28,18 @@ SOURCES += [
     'nsXULTemplateQueryProcessorXML.cpp',
     'nsXULTemplateResultRDF.cpp',
     'nsXULTemplateResultSetRDF.cpp',
     'nsXULTemplateResultStorage.cpp',
     'nsXULTemplateResultXML.cpp',
     'nsXULTreeBuilder.cpp',
 ]
 
-LIBRARY_NAME = 'gkconxultmpl_s'
-
-LIBXUL_LIBRARY = True
-
 MSVC_ENABLE_PGO = True
 
 LOCAL_INCLUDES += [
     '../../content/src',
     '/content/base/src',
     '/dom/base',
     '/layout/xul/tree/',
 ]
+
+FINAL_LIBRARY = 'gklayout'
--- a/db/sqlite3/src/Makefile.in
+++ b/db/sqlite3/src/Makefile.in
@@ -1,17 +1,13 @@
 #
 # 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/.
 
-SHORT_LIBNAME    = mozsqlt3
-ifndef MOZ_FOLD_LIBS
-FORCE_SHARED_LIB = 1
-endif
 LIB_IS_C_ONLY    = 1
 
 ifeq ($(OS_ARCH),WINNT)
 DEFFILE = $(CURDIR)/sqlite-processed.def
 RCFILE  = sqlite.rc
 RESFILE = sqlite.res
 
 GARBAGE += \
--- a/db/sqlite3/src/moz.build
+++ b/db/sqlite3/src/moz.build
@@ -1,21 +1,21 @@
 # -*- 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/.
-
-MODULE = 'sqlite3'
 NO_VISIBILITY_FLAGS = True
 
 EXPORTS += [
     'sqlite3.h',
 ]
 
 LIBRARY_NAME = 'mozsqlite3'
 
 SOURCES += [
     'sqlite3.c',
 ]
 
 if CONFIG['MOZ_FOLD_LIBS']:
     FORCE_STATIC_LIB = True
+else:
+    FORCE_SHARED_LIB = True
--- a/docshell/base/moz.build
+++ b/docshell/base/moz.build
@@ -28,17 +28,17 @@ XPIDL_SOURCES += [
     'nsIScrollable.idl',
     'nsITextScroll.idl',
     'nsIURIFixup.idl',
     'nsIWebNavigation.idl',
     'nsIWebNavigationInfo.idl',
     'nsIWebPageDescriptor.idl',
 ]
 
-MODULE = 'docshell'
+XPIDL_MODULE = 'docshell'
 
 EXPORTS += [
     'nsDocShellLoadTypes.h',
     'nsILinkHandler.h',
     'nsIWebShellServices.h',
     'SerializedLoadContext.h',
 ]
 
@@ -59,24 +59,21 @@ SOURCES += [
     'nsDownloadHistory.cpp',
     'nsDSURIContentListener.cpp',
     'nsWebNavigationInfo.cpp',
     'SerializedLoadContext.cpp',
 ]
 
 FAIL_ON_WARNINGS = True
 
-LIBXUL_LIBRARY = True
-
 MSVC_ENABLE_PGO = True
 
-LIBRARY_NAME = 'basedocshell_s'
-
 include('/ipc/chromium/chromium-config.mozbuild')
 
+FINAL_LIBRARY = 'xul'
 LOCAL_INCLUDES += [
     '../shistory/src',
     '/content/base/src',
     '/dom/base',
     '/layout/base',
     '/layout/generic',
     '/layout/xul/base/src',
     '/netwerk/protocol/viewsource',
--- a/docshell/build/moz.build
+++ b/docshell/build/moz.build
@@ -1,30 +1,26 @@
 # -*- 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/.
 
-MODULE = 'docshell'
-
 EXPORTS += [
     'nsDocShellCID.h',
 ]
 
 SOURCES += [
     'nsDocShellModule.cpp',
 ]
 
-LIBRARY_NAME = 'docshell'
-
-LIBXUL_LIBRARY = True
-
 LOCAL_INCLUDES += [
     '../base',
     '../shistory/src/',
     '/uriloader/base',
     '/uriloader/exthandler',
     '/uriloader/prefetch',
     ]
 
 if CONFIG["MOZ_WIDGET_TOOLKIT"] == "cocoa":
     LOCAL_INCLUDES += ['/uriloader/exthandler/mac']
+
+FINAL_LIBRARY = 'xul'
--- a/docshell/moz.build
+++ b/docshell/moz.build
@@ -8,10 +8,8 @@ DIRS += [
     'base',
     'shistory',
     'build',
     'resources/content',
 ]
 
 TEST_DIRS += ['test']
 
-MODULE = 'docshell'
-
--- a/docshell/shistory/moz.build
+++ b/docshell/shistory/moz.build
@@ -1,10 +1,8 @@
 # -*- 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 += ['public', 'src']
 
-MODULE = 'shistory'
-
--- a/docshell/shistory/public/moz.build
+++ b/docshell/shistory/public/moz.build
@@ -9,10 +9,10 @@ XPIDL_SOURCES += [
     'nsISHContainer.idl',
     'nsISHEntry.idl',
     'nsISHistory.idl',
     'nsISHistoryInternal.idl',
     'nsISHistoryListener.idl',
     'nsISHTransaction.idl',
 ]
 
-MODULE = 'shistory'
+XPIDL_MODULE = 'shistory'
 
--- a/docshell/shistory/src/moz.build
+++ b/docshell/shistory/src/moz.build
@@ -1,30 +1,26 @@
 # -*- 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/.
 
-MODULE = 'shistory'
-
 EXPORTS += [
     'nsSHEntryShared.h',
 ]
 
 SOURCES += [
     'nsSHEntry.cpp',
     'nsSHEntryShared.cpp',
     'nsSHistory.cpp',
     'nsSHTransaction.cpp',
 ]
 
-LIBRARY_NAME = 'shistory_s'
-
 FAIL_ON_WARNINGS = True
 
-LIBXUL_LIBRARY = True
-
 MSVC_ENABLE_PGO = True
 
 LOCAL_INCLUDES += [
     '/docshell/base',
 ]
+
+FINAL_LIBRARY = 'xul'
--- a/docshell/test/moz.build
+++ b/docshell/test/moz.build
@@ -1,18 +1,16 @@
 # -*- 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 += ['chrome', 'navigation', 'browser']
 
-MODULE = 'test_docshell'
-
 XPCSHELL_TESTS_MANIFESTS += ['unit/xpcshell.ini']
 
 # FIXME/bug 575918: out-of-process xpcshell is broken on OS X
 if CONFIG['OS_ARCH'] != 'Darwin':
     XPCSHELL_TESTS_MANIFESTS += ['unit_ipc/xpcshell.ini']
 
 MOCHITEST_MANIFESTS += ['mochitest.ini']
 
--- a/docshell/test/navigation/moz.build
+++ b/docshell/test/navigation/moz.build
@@ -1,12 +1,10 @@
 # -*- 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/.
 
-MODULE = 'test_docshell'
-
 MOCHITEST_MANIFESTS += ['mochitest.ini']
 
 BROWSER_CHROME_MANIFESTS += ['browser.ini']
 
--- a/dom/activities/src/moz.build
+++ b/dom/activities/src/moz.build
@@ -1,16 +1,14 @@
 # -*- 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/.
 
-MODULE = 'dom'
-
 EXPORTS.mozilla.dom += [
     'Activity.h',
 ]
 
 SOURCES += [
     'Activity.cpp',
 ]
 
@@ -25,15 +23,13 @@ EXTRA_COMPONENTS += [
 
 EXTRA_JS_MODULES += [
     'ActivitiesService.jsm',
     'ActivitiesServiceFilter.jsm',
 ]
 
 FAIL_ON_WARNINGS = True
 
-LIBXUL_LIBRARY = True
-
-LIBRARY_NAME = 'dom_activities_s'
-
 LOCAL_INCLUDES += [
     '/dom/base',
 ]
+
+FINAL_LIBRARY = 'gklayout'
--- a/dom/activities/tests/moz.build
+++ b/dom/activities/tests/moz.build
@@ -1,10 +1,7 @@
 # -*- 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/.
 
 XPCSHELL_TESTS_MANIFESTS += ['unit/xpcshell.ini']
-
-FAIL_ON_WARNINGS = True
-
--- a/dom/alarm/moz.build
+++ b/dom/alarm/moz.build
@@ -8,18 +8,16 @@ TEST_DIRS += ['test']
 
 XPIDL_SOURCES += [
     'nsIAlarmHalService.idl',
     'nsIDOMAlarmsManager.idl',
 ]
 
 XPIDL_MODULE = 'dom_alarm'
 
-MODULE = 'dom'
-
 EXPORTS.mozilla.dom.alarm += [
     'AlarmHalService.h',
 ]
 
 SOURCES += [
     'AlarmHalService.cpp',
 ]
 
@@ -30,14 +28,11 @@ EXTRA_COMPONENTS += [
 
 EXTRA_JS_MODULES += [
     'AlarmDB.jsm',
     'AlarmService.jsm',
 ]
 
 FAIL_ON_WARNINGS = True
 
-LIBXUL_LIBRARY = True
-
-LIBRARY_NAME = 'domalarm_s'
-
 include('/ipc/chromium/chromium-config.mozbuild')
 
+FINAL_LIBRARY = 'gklayout'
--- a/dom/apps/src/moz.build
+++ b/dom/apps/src/moz.build
@@ -35,16 +35,14 @@ EXTRA_JS_MODULES += [
 EXTRA_PP_JS_MODULES += [
     'AppsUtils.jsm',
     'OperatorApps.jsm',
     'Webapps.jsm',
 ]
 
 FAIL_ON_WARNINGS = True
 
-LIBXUL_LIBRARY = True
-
-LIBRARY_NAME = 'dom_apps_s'
+FINAL_LIBRARY = 'gklayout'
 
 LOCAL_INCLUDES += [
     '/js/xpconnect/wrappers',
 ]
 
--- a/dom/audiochannel/moz.build
+++ b/dom/audiochannel/moz.build
@@ -7,33 +7,26 @@
 TEST_TOOL_DIRS += ['tests']
 
 XPIDL_SOURCES += [
     'nsIAudioChannelAgent.idl',
 ]
 
 XPIDL_MODULE = 'dom_audiochannel'
 
-MODULE = 'dom'
-
 EXPORTS += [
     'AudioChannelAgent.h',
     'AudioChannelCommon.h',
     'AudioChannelService.h',
     'AudioChannelServiceChild.h',
 ]
 
 SOURCES += [
     'AudioChannelAgent.cpp',
     'AudioChannelService.cpp',
     'AudioChannelServiceChild.cpp',
 ]
 
 FAIL_ON_WARNINGS = True
 
-LIBXUL_LIBRARY = True
-
-LIBRARY_NAME = 'domaudiochannel_s'
-
-EXPORT_LIBRARY = True
-
 include('/ipc/chromium/chromium-config.mozbuild')
 
+FINAL_LIBRARY = 'gklayout'
--- a/dom/audiochannel/tests/moz.build
+++ b/dom/audiochannel/tests/moz.build
@@ -1,14 +1,12 @@
 # -*- 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/.
 
-MODULE = 'dom'
-
 CPP_UNIT_TESTS += [
     'TestAudioChannelService.cpp',
 ]
 
 FAIL_ON_WARNINGS = True
 
--- a/dom/base/moz.build
+++ b/dom/base/moz.build
@@ -9,17 +9,17 @@ TEST_DIRS += ['test']
 XPIDL_SOURCES += [
     'nsIDOMDOMCursor.idl',
     'nsIDOMDOMRequest.idl',
     'nsIEntropyCollector.idl',
     'nsIScriptChannel.idl',
     'nsISiteSpecificUserAgent.idl',
 ]
 
-MODULE = 'dom'
+XPIDL_MODULE = 'dom'
 
 EXPORTS += [
     'Crypto.h',
     'nsContentPermissionHelper.h',
     'nsDOMCID.h',
     'nsDOMClassInfoClasses.h',
     'nsDOMClassInfoID.h',
     'nsDOMJSUtils.h',
@@ -113,22 +113,18 @@ EXTRA_JS_MODULES += [
     'ConsoleAPIStorage.jsm',
     'DOMRequestHelper.jsm',
     'IndexedDBHelper.jsm',
     'ObjectWrapper.jsm',
 ]
 
 FAIL_ON_WARNINGS = True
 
-LIBXUL_LIBRARY = True
-
 MSVC_ENABLE_PGO = True
 
-LIBRARY_NAME = 'jsdombase_s'
-
 LOCAL_INCLUDES += [
     '../battery',
     '../bluetooth',
     '../media',
     '../network/src',
     '../src/geolocation',
     '../src/storage',
     '../time',
@@ -145,14 +141,16 @@ LOCAL_INCLUDES += [
 if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'gonk':
     LOCAL_INCLUDES += [
         '../fmradio',
         '../system/gonk',
     ]
 
 include('/ipc/chromium/chromium-config.mozbuild')
 
+FINAL_LIBRARY = 'gklayout'
+
 LOCAL_INCLUDES += [
     '/js/xpconnect/src',
     '/js/xpconnect/wrappers',
     '/xpcom/ds',
 ]
 
--- a/dom/base/nsScriptNameSpaceManager.cpp
+++ b/dom/base/nsScriptNameSpaceManager.cpp
@@ -332,17 +332,17 @@ nsScriptNameSpaceManager::RegisterInterf
   return NS_OK;
 }
 
 #define GLOBALNAME_HASHTABLE_INITIAL_SIZE	1024
 
 nsresult
 nsScriptNameSpaceManager::Init()
 {
-  static PLDHashTableOps hash_table_ops =
+  static const PLDHashTableOps hash_table_ops =
   {
     PL_DHashAllocTable,
     PL_DHashFreeTable,
     GlobalNameHashHashKey,
     GlobalNameHashMatchEntry,
     PL_DHashMoveEntryStub,
     GlobalNameHashClearEntry,
     PL_DHashFinalizeStub,
--- a/dom/battery/moz.build
+++ b/dom/battery/moz.build
@@ -12,18 +12,15 @@ EXPORTS.mozilla.dom.battery += [
 ]
 
 SOURCES += [
     'BatteryManager.cpp',
 ]
 
 FAIL_ON_WARNINGS = True
 
-LIBXUL_LIBRARY = True
-
-LIBRARY_NAME = 'dom_battery_s'
-
 include('/ipc/chromium/chromium-config.mozbuild')
 
+FINAL_LIBRARY = 'gklayout'
 LOCAL_INCLUDES += [
     '/content/events/src',
 ]
 
--- a/dom/bindings/BindingUtils.cpp
+++ b/dom/bindings/BindingUtils.cpp
@@ -2162,16 +2162,23 @@ ThreadsafeCheckIsChrome(JSContext* aCx, 
 
 void
 TraceGlobal(JSTracer* aTrc, JSObject* aObj)
 {
   MOZ_ASSERT(js::GetObjectClass(aObj)->flags & JSCLASS_DOM_GLOBAL);
   mozilla::dom::TraceProtoAndIfaceCache(aTrc, aObj);
 }
 
+void
+FinalizeGlobal(JSFreeOp* aFreeOp, JSObject* aObj)
+{
+  MOZ_ASSERT(js::GetObjectClass(aObj)->flags & JSCLASS_DOM_GLOBAL);
+  mozilla::dom::DestroyProtoAndIfaceCache(aObj);
+}
+
 bool
 ResolveGlobal(JSContext* aCx, JS::Handle<JSObject*> aObj,
               JS::MutableHandle<jsid> aId, unsigned aFlags,
               JS::MutableHandle<JSObject*> aObjp)
 {
   bool resolved;
   if (!JS_ResolveStandardClass(aCx, aObj, aId, &resolved)) {
     return false;
--- a/dom/bindings/BindingUtils.h
+++ b/dom/bindings/BindingUtils.h
@@ -15,16 +15,17 @@
 #include "mozilla/dom/DOMJSClass.h"
 #include "mozilla/dom/DOMJSProxyHandler.h"
 #include "mozilla/dom/Exceptions.h"
 #include "mozilla/dom/NonRefcountedDOMObject.h"
 #include "mozilla/dom/Nullable.h"
 #include "mozilla/dom/RootedDictionary.h"
 #include "mozilla/dom/workers/Workers.h"
 #include "mozilla/ErrorResult.h"
+#include "mozilla/HoldDropJSObjects.h"
 #include "mozilla/Likely.h"
 #include "mozilla/Util.h"
 #include "nsCycleCollector.h"
 #include "nsIXPConnect.h"
 #include "MainThreadUtils.h"
 #include "nsTraceRefcnt.h"
 #include "qsObjectHelper.h"
 #include "xpcpublic.h"
@@ -284,16 +285,21 @@ AllocateProtoAndIfaceCache(JSObject* obj
 {
   MOZ_ASSERT(js::GetObjectClass(obj)->flags & JSCLASS_DOM_GLOBAL);
   MOZ_ASSERT(js::GetReservedSlot(obj, DOM_PROTOTYPE_SLOT).isUndefined());
 
   JS::Heap<JSObject*>* protoAndIfaceArray = new JS::Heap<JSObject*>[kProtoAndIfaceCacheCount];
 
   js::SetReservedSlot(obj, DOM_PROTOTYPE_SLOT,
                       JS::PrivateValue(protoAndIfaceArray));
+
+#ifdef NS_BUILD_REFCNT_LOGGING
+  NS_LogCtor((void*)protoAndIfaceArray, "ProtoAndIfaceArray",
+             sizeof(JS::Heap<JSObject*>) * kProtoAndIfaceCacheCount);
+#endif
 }
 
 inline void
 TraceProtoAndIfaceCache(JSTracer* trc, JSObject* obj)
 {
   MOZ_ASSERT(js::GetObjectClass(obj)->flags & JSCLASS_DOM_GLOBAL);
 
   if (!HasProtoAndIfaceArray(obj))
@@ -308,16 +314,21 @@ TraceProtoAndIfaceCache(JSTracer* trc, J
 
 inline void
 DestroyProtoAndIfaceCache(JSObject* obj)
 {
   MOZ_ASSERT(js::GetObjectClass(obj)->flags & JSCLASS_DOM_GLOBAL);
 
   JS::Heap<JSObject*>* protoAndIfaceArray = GetProtoAndIfaceArray(obj);
 
+#ifdef NS_BUILD_REFCNT_LOGGING
+  NS_LogDtor((void*)protoAndIfaceArray, "ProtoAndIfaceArray",
+             sizeof(JS::Heap<JSObject*>) * kProtoAndIfaceCacheCount);
+#endif
+
   delete [] protoAndIfaceArray;
 }
 
 /**
  * Add constants to an object.
  */
 bool
 DefineConstants(JSContext* cx, JS::Handle<JSObject*> obj,
@@ -2268,16 +2279,19 @@ public:
 };
 
 bool
 ThreadsafeCheckIsChrome(JSContext* aCx, JSObject* aObj);
 
 void
 TraceGlobal(JSTracer* aTrc, JSObject* aObj);
 
+void
+FinalizeGlobal(JSFreeOp* aFop, JSObject* aObj);
+
 bool
 ResolveGlobal(JSContext* aCx, JS::Handle<JSObject*> aObj,
               JS::MutableHandle<jsid> aId, unsigned aFlags,
               JS::MutableHandle<JSObject*> aObjp);
 
 bool
 EnumerateGlobal(JSContext* aCx, JS::Handle<JSObject*> aObj);
 
@@ -2318,15 +2332,17 @@ CreateGlobal(JSContext* aCx, T* aObject,
   JS::Handle<JSObject*> proto = ProtoGetter(aCx, global);
   NS_ENSURE_TRUE(proto, nullptr);
 
   if (!JS_SetPrototype(aCx, global, proto)) {
     NS_WARNING("Failed to set proto");
     return nullptr;
   }
 
+  mozilla::HoldJSObjects(aObject);
+
   return global;
 }
 
 } // namespace dom
 } // namespace mozilla
 
 #endif /* mozilla_dom_BindingUtils_h__ */
--- a/dom/bindings/Codegen.py
+++ b/dom/bindings/Codegen.py
@@ -1079,16 +1079,18 @@ def finalizeHook(descriptor, hookName, c
     if descriptor.customFinalize:
         finalize = "self->%s(%s);" % (hookName, context)
     else:
         finalize = "JSBindingFinalized<%s>::Finalized(self);\n" % descriptor.nativeType
         if descriptor.wrapperCache:
             finalize += "ClearWrapper(self, self);\n"
         if descriptor.interface.getExtendedAttribute('OverrideBuiltins'):
             finalize += "self->mExpandoAndGeneration.expando = JS::UndefinedValue();\n"
+        if descriptor.interface.getExtendedAttribute("Global"):
+            finalize += "mozilla::dom::FinalizeGlobal(fop, obj);\n"
         if descriptor.nativeOwnership == 'worker':
             finalize += "self->Release();"
         else:
             finalize += ("AddForDeferredFinalization<%s, %s >(self);" %
                 (descriptor.nativeType, DeferredFinalizeSmartPtr(descriptor)))
     return CGIfWrapper(CGGeneric(finalize), "self")
 
 class CGClassFinalizeHook(CGAbstractClassHook):
--- a/dom/bindings/moz.build
+++ b/dom/bindings/moz.build
@@ -1,16 +1,14 @@
 # -*- 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/.
 
-MODULE = 'dom'
-
 EXPORTS.mozilla += [
     'ErrorResult.h',
 ]
 
 EXPORTS.mozilla.dom += [
     'AtomList.h',
     'BindingDeclarations.h',
     'BindingUtils.h',
@@ -30,24 +28,18 @@ EXPORTS.mozilla.dom += [
     'PrimitiveConversions.h',
     'RootedDictionary.h',
     'TypedArray.h',
     'UnionMember.h',
 ]
 
 FAIL_ON_WARNINGS = True
 
-LIBXUL_LIBRARY = True
-
 MSVC_ENABLE_PGO = True
 
-LIBRARY_NAME = 'dombindings_s'
-
-EXPORT_LIBRARY = True
-
 LOCAL_INCLUDES += [
     '/content/base/src',
     '/content/canvas/src',
     '/content/events/src',
     '/content/html/content/src',
     '/content/html/document/src',
     '/content/media/webaudio',
     '/content/media/webspeech/recognition',
@@ -77,8 +69,10 @@ LOCAL_INCLUDES += [
 ]
 
 include('/ipc/chromium/chromium-config.mozbuild')
 
 if CONFIG['MOZ_AUDIO_CHANNEL_MANAGER']:
     LOCAL_INCLUDES += [
         '/dom/system/gonk',
     ]
+
+FINAL_LIBRARY = 'xul'
--- a/dom/bindings/test/moz.build
+++ b/dom/bindings/test/moz.build
@@ -1,16 +1,14 @@
 # -*- 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/.
 
-MODULE = 'dom'
-
 LIBXUL_LIBRARY = True
 # Do NOT export this library.  We don't actually want our test code
 # being added to libxul or anything.
 
 LIBRARY_NAME = 'dombindings_test_s'
 
 MOCHITEST_MANIFESTS += ['mochitest.ini']
 
--- a/dom/bluetooth/moz.build
+++ b/dom/bluetooth/moz.build
@@ -2,19 +2,16 @@
 # 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/.
 
 if CONFIG['MOZ_B2G_BT']:
     PARALLEL_DIRS += ['interfaces']
 
-    LIBXUL_LIBRARY = True
-    MODULE = 'dom'
-    LIBRARY_NAME = 'dombluetooth_s'
 
     SOURCES += [
         'BluetoothA2dpManager.cpp',
         'BluetoothAdapter.cpp',
         'BluetoothDevice.cpp',
         'BluetoothHidManager.cpp',
         'BluetoothManager.cpp',
         'BluetoothOppManager.cpp',
@@ -63,16 +60,18 @@ if CONFIG['MOZ_B2G_BT']:
             'bluez/BluetoothHfpManager.cpp',
             'bluez/linux/BluetoothDBusService.cpp',
         ]
         LOCAL_INCLUDES += [
             'bluez',
             'bluez/linux',
         ]
 
+    FINAL_LIBRARY = 'gklayout'
+
 EXPORTS.mozilla.dom.bluetooth.ipc += [
     'ipc/BluetoothMessageUtils.h',
 ]
 
 EXPORTS.mozilla.dom.bluetooth += [
     'BluetoothCommon.h',
 ]
 
--- a/dom/browser-element/moz.build
+++ b/dom/browser-element/moz.build
@@ -3,18 +3,16 @@
 # 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/.
 
 TEST_DIRS += ['mochitest']
 
 XPIDL_MODULE = 'dom_browserelement'
 
-MODULE = 'dom'
-
 EXPORTS.mozilla += [
     'BrowserElementParent.h',
 ]
 
 SOURCES += [
     'BrowserElementParent.cpp',
 ]
 
@@ -25,26 +23,24 @@ EXTRA_COMPONENTS += [
 
 EXTRA_JS_MODULES += [
     'BrowserElementParent.jsm',
     'BrowserElementPromptService.jsm',
 ]
 
 FAIL_ON_WARNINGS = True
 
-LIBXUL_LIBRARY = True
-
-LIBRARY_NAME = 'dom_browserelement_s'
-
 LOCAL_INCLUDES += [
     '../bluetooth',
     '/content/html/content/src',
 ]
 
 include('/ipc/chromium/chromium-config.mozbuild')
 
+FINAL_LIBRARY = 'gklayout'
+
 LOCAL_INCLUDES += [
     '/content/base/src',
     '/dom/',
     '/dom/base',
     '/dom/ipc',
 ]
 
--- a/dom/camera/moz.build
+++ b/dom/camera/moz.build
@@ -8,18 +8,16 @@ XPIDL_SOURCES += [
     'nsIDOMCameraManager.idl',
 ]
 
 if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'gonk':
     TEST_DIRS += ['test']
 
 XPIDL_MODULE = 'dom_camera'
 
-MODULE = 'dom'
-
 EXPORTS += [
     'CameraCommon.h',
     'CameraPreviewMediaStream.h',
     'DOMCameraManager.h',
     'GonkCameraControl.h',
 ]
 
 SOURCES += [
@@ -44,17 +42,15 @@ if CONFIG['MOZ_B2G_CAMERA']:
 else:
     SOURCES += [
         'FallbackCameraControl.cpp',
         'FallbackCameraManager.cpp',
     ]
 
 FAIL_ON_WARNINGS = True
 
-LIBXUL_LIBRARY = True
-
-LIBRARY_NAME = 'domcamera_s'
-
 LOCAL_INCLUDES += [
     '../base',
 ]
 
 include('/ipc/chromium/chromium-config.mozbuild')
+
+FINAL_LIBRARY = 'gklayout'
--- a/dom/cellbroadcast/src/moz.build
+++ b/dom/cellbroadcast/src/moz.build
@@ -11,12 +11,9 @@ EXPORTS.mozilla.dom += [
 ]
 
 SOURCES += [
     'CellBroadcast.cpp',
 ]
 
 FAIL_ON_WARNINGS = True
 
-LIBXUL_LIBRARY = True
-
-LIBRARY_NAME = 'dom_cellbroadcast_s'
-
+FINAL_LIBRARY = 'gklayout'
--- a/dom/datastore/moz.build
+++ b/dom/datastore/moz.build
@@ -5,18 +5,16 @@
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
 XPIDL_SOURCES += [
     'nsIDataStoreService.idl',
 ]
 
 XPIDL_MODULE = 'dom_datastore'
 
-MODULE = 'dom'
-
 EXTRA_COMPONENTS += [
     'DataStore.manifest',
     'DataStoreService.js',
 ]
 
 EXTRA_JS_MODULES += [
     'DataStore.jsm',
     'DataStoreChangeNotifier.jsm',
--- a/dom/devicestorage/moz.build
+++ b/dom/devicestorage/moz.build
@@ -3,18 +3,16 @@
 # 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/.
 
 TEST_DIRS += ['test', 'ipc']
 
 XPIDL_MODULE = 'dom_devicestorage'
 
-MODULE = 'dom'
-
 EXPORTS += [
     'DeviceStorage.h',
     'nsDeviceStorage.h',
 ]
 
 EXPORTS.mozilla.dom.devicestorage += [
     'DeviceStorageRequestChild.h',
     'DeviceStorageRequestParent.h',
@@ -27,21 +25,18 @@ SOURCES += [
 ]
 
 IPDL_SOURCES += [
     'PDeviceStorageRequest.ipdl',
 ]
 
 FAIL_ON_WARNINGS = True
 
-LIBXUL_LIBRARY = True
-
-LIBRARY_NAME = 'domdevicestorage_s'
-
 include('/ipc/chromium/chromium-config.mozbuild')
 
+FINAL_LIBRARY = 'gklayout'
 LOCAL_INCLUDES += [
     '/content/base/src',
     '/content/events/src',
     '/dom/base',
     '/dom/ipc',
 ]
 
--- a/dom/encoding/moz.build
+++ b/dom/encoding/moz.build
@@ -1,34 +1,29 @@
 # -*- 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/.
 
 TEST_DIRS += ['test']
 
-MODULE = 'dom'
-
 EXPORTS.mozilla.dom += [
     'EncodingUtils.h',
     'FallbackEncoding.h',
     'TextDecoder.h',
     'TextEncoder.h',
 ]
 
 SOURCES += [
     'EncodingUtils.cpp',
     'FallbackEncoding.cpp',
     'TextDecoder.cpp',
     'TextEncoder.cpp',
 ]
 
 FAIL_ON_WARNINGS = True
 
-LIBXUL_LIBRARY = True
-
-LIBRARY_NAME = 'domencoding_s'
-
+FINAL_LIBRARY = 'gklayout'
 LOCAL_INCLUDES += [
     '/intl/locale/src',
 ]
 
--- a/dom/file/moz.build
+++ b/dom/file/moz.build
@@ -8,18 +8,16 @@ TEST_DIRS += ['test']
 
 XPIDL_SOURCES += [
     'nsIDOMFileHandle.idl',
     'nsIDOMLockedFile.idl',
 ]
 
 XPIDL_MODULE = 'dom_file'
 
-MODULE = 'dom'
-
 EXPORTS += [
     'nsIFileStorage.h',
 ]
 
 EXPORTS.mozilla.dom.file += [
     'ArchiveEvent.h',
     'ArchiveReader.h',
     'ArchiveRequest.h',
@@ -52,15 +50,13 @@ SOURCES += [
     'FileStreamWrappers.cpp',
     'LockedFile.cpp',
     'MemoryStreams.cpp',
     'MetadataHelper.cpp',
 ]
 
 FAIL_ON_WARNINGS = True
 
-LIBXUL_LIBRARY = True
-
-LIBRARY_NAME = 'domfile_s'
-
 LOCAL_INCLUDES += [
     '../base',
 ]
+
+FINAL_LIBRARY = 'gklayout'
--- a/dom/fmradio/ipc/moz.build
+++ b/dom/fmradio/ipc/moz.build
@@ -15,21 +15,22 @@ SOURCES += [
     'FMRadioChild.cpp',
     'FMRadioParent.cpp',
     'FMRadioRequestChild.cpp',
     'FMRadioRequestParent.cpp',
 ]
 
 FAIL_ON_WARNINGS = True
 
-LIBXUL_LIBRARY = True
 LIBRARY_NAME   = 'domfmradio_s'
 
 LOCAL_INCLUDES += [
     '/dom/base',
 ]
 
 include('/ipc/chromium/chromium-config.mozbuild')
 
+FINAL_LIBRARY = 'gklayout'
+
 LOCAL_INCLUDES += [
     '/dom/fmradio',
 ]
 
--- a/dom/fmradio/moz.build
+++ b/dom/fmradio/moz.build
@@ -4,32 +4,28 @@
 # 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/.
 
 if CONFIG['MOZ_B2G_FM']:
     DIRS += [
         'ipc',
     ]
 
-    MODULE = 'dom'
-
     EXPORTS.mozilla.dom += [
         'FMRadio.h',
         'FMRadioCommon.h',
         'FMRadioService.h',
     ]
 
     SOURCES += [
         'FMRadio.cpp',
         'FMRadioService.cpp',
     ]
 
-    LIBXUL_LIBRARY = True
-
-    LIBRARY_NAME = 'domfmradio_s'
+    FINAL_LIBRARY = 'gklayout'
 
 IPDL_SOURCES += [
     'ipc/PFMRadio.ipdl',
     'ipc/PFMRadioRequest.ipdl',
 ]
 
 FAIL_ON_WARNINGS = True
 
--- a/dom/gamepad/moz.build
+++ b/dom/gamepad/moz.build
@@ -13,18 +13,15 @@ EXPORTS.mozilla.dom += [
 SOURCES = [
     'Gamepad.cpp',
     'GamepadButton.cpp',
     'GamepadService.cpp',
     ]
 
 FAIL_ON_WARNINGS = True
 
-LIBXUL_LIBRARY = True
-
-LIBRARY_NAME = 'domgamepad_s'
-
 include('/ipc/chromium/chromium-config.mozbuild')
 
+FINAL_LIBRARY = 'gklayout'
 LOCAL_INCLUDES += [
     '/dom/base',
 ]
 
--- a/dom/icc/src/moz.build
+++ b/dom/icc/src/moz.build
@@ -9,18 +9,15 @@ EXPORTS.mozilla.dom += [
 ]
 
 SOURCES += [
     'IccManager.cpp',
 ]
 
 FAIL_ON_WARNINGS = True
 
-LIBXUL_LIBRARY = True
-
-LIBRARY_NAME = 'dom_icc_s'
-
 include('/ipc/chromium/chromium-config.mozbuild')
 
+FINAL_LIBRARY = 'gklayout'
 LOCAL_INCLUDES += [
     '/content/events/src',
 ]
 
--- a/dom/icc/tests/moz.build
+++ b/dom/icc/tests/moz.build
@@ -1,8 +1,6 @@
 # -*- 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/.
 
-MODULE = 'test_dom_icc'
-
--- a/dom/indexedDB/ipc/moz.build
+++ b/dom/indexedDB/ipc/moz.build
@@ -1,16 +1,14 @@
 # -*- 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/.
 
-MODULE = 'dom'
-
 EXPORTS.mozilla.dom.indexedDB += [
     'SerializationHelpers.h',
 ]
 
 # Need to enable these tests sometime soon.
 #XPCSHELL_TESTS_MANIFESTS += ['unit/xpcshell.ini']
 
 SOURCES += [
@@ -27,21 +25,18 @@ IPDL_SOURCES += [
     'PIndexedDBIndex.ipdl',
     'PIndexedDBObjectStore.ipdl',
     'PIndexedDBRequest.ipdl',
     'PIndexedDBTransaction.ipdl',
 ]
 
 FAIL_ON_WARNINGS = True
 
-LIBXUL_LIBRARY = True
-
-LIBRARY_NAME = 'dom_indexeddb_ipc_s'
-
 MOCHITEST_MANIFESTS += ['mochitest.ini']
 
 include('/ipc/chromium/chromium-config.mozbuild')
 
+FINAL_LIBRARY = 'gklayout'
 LOCAL_INCLUDES += [
     '/content/events/src',
     '/dom/indexedDB',
 ]
 
--- a/dom/indexedDB/moz.build
+++ b/dom/indexedDB/moz.build
@@ -8,18 +8,16 @@ DIRS += ['ipc']
 TEST_DIRS += ['test']
 
 XPIDL_SOURCES += [
     'nsIIndexedDatabaseManager.idl',
 ]
 
 XPIDL_MODULE = 'dom_indexeddb'
 
-MODULE = 'dom'
-
 EXPORTS.mozilla.dom.indexedDB += [
     'Client.h',
     'DatabaseInfo.h',
     'FileInfo.h',
     'FileManager.h',
     'IDBCursor.h',
     'IDBDatabase.h',
     'IDBEvents.h',
@@ -59,22 +57,19 @@ SOURCES += [
     'Key.cpp',
     'KeyPath.cpp',
     'OpenDatabaseHelper.cpp',
     'TransactionThreadPool.cpp',
 ]
 
 FAIL_ON_WARNINGS = True
 
-LIBXUL_LIBRARY = True
-
-LIBRARY_NAME = 'dom_indexeddb_s'
-
 include('/ipc/chromium/chromium-config.mozbuild')
 
+FINAL_LIBRARY = 'gklayout'
 LOCAL_INCLUDES += [
     '/caps/include',
     '/content/base/src',
     '/content/events/src',
     '/db/sqlite3/src',
     '/dom/base',
     '/dom/quota',
     '/dom/src/storage',
--- a/dom/inputmethod/moz.build
+++ b/dom/inputmethod/moz.build
@@ -5,22 +5,16 @@
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
 XPIDL_SOURCES += [
     'nsIB2GKeyboard.idl',
 ]
 
 XPIDL_MODULE = 'dom_inputmethod'
 
-MODULE = 'dom'
-
 EXTRA_COMPONENTS += [
     'InputMethod.manifest',
     'MozKeyboard.js',
 ]
 
 EXTRA_JS_MODULES += [
     'Keyboard.jsm',
 ]
-
-FAIL_ON_WARNINGS = True
-
-LIBXUL_LIBRARY = True
--- a/dom/interfaces/apps/moz.build
+++ b/dom/interfaces/apps/moz.build
@@ -11,10 +11,8 @@ XPIDL_SOURCES += [
     'nsIDOMApplicationRegistry.idl',
     'nsIDOMApplicationRegistry2.idl',
     'nsIDOMMozApplicationEvent.idl',
     'nsIInterAppCommService.idl',
 ]
 
 XPIDL_MODULE = 'dom_apps'
 
-MODULE = 'dom'
-
--- a/dom/interfaces/base/moz.build
+++ b/dom/interfaces/base/moz.build
@@ -55,10 +55,8 @@ if CONFIG['MOZ_B2G']:
 
 if CONFIG['MOZ_WEBSPEECH']:
     XPIDL_SOURCES += [
         'nsISpeechSynthesisGetter.idl'
     ]
 
 XPIDL_MODULE = 'dom_base'
 
-MODULE = 'dom'
-
--- a/dom/interfaces/canvas/moz.build
+++ b/dom/interfaces/canvas/moz.build
@@ -6,10 +6,8 @@
 
 XPIDL_SOURCES += [
     'nsIDOMCanvasRenderingContext2D.idl',
     'nsIDOMWebGLRenderingContext.idl',
 ]
 
 XPIDL_MODULE = 'dom_canvas'
 
-MODULE = 'dom'
-
--- a/dom/interfaces/core/moz.build
+++ b/dom/interfaces/core/moz.build
@@ -24,10 +24,8 @@ XPIDL_SOURCES += [
     'nsIDOMText.idl',
     'nsIDOMUserDataHandler.idl',
     'nsIDOMXMLDocument.idl',
     'nsIInlineEventHandlers.idl',
 ]
 
 XPIDL_MODULE = 'dom_core'
 
-MODULE = 'dom'
-
--- a/dom/interfaces/css/moz.build
+++ b/dom/interfaces/css/moz.build
@@ -28,10 +28,8 @@ XPIDL_SOURCES += [
     'nsIDOMElementCSSInlineStyle.idl',
     'nsIDOMMozCSSKeyframeRule.idl',
     'nsIDOMMozCSSKeyframesRule.idl',
     'nsIDOMRect.idl',
 ]
 
 XPIDL_MODULE = 'dom_css'
 
-MODULE = 'dom'
-
--- a/dom/interfaces/devicestorage/moz.build
+++ b/dom/interfaces/devicestorage/moz.build
@@ -5,15 +5,8 @@
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
 XPIDL_SOURCES += [
     'nsIDOMDeviceStorage.idl',
     'nsIDOMDeviceStorageChangeEvent.idl',
 ]
 
 XPIDL_MODULE = 'dom_devicestorage'
-
-MODULE = 'dom'
-
-LIBXUL_LIBRARY = True
-
-LIBRARY_NAME = 'domdevicestorage_s'
-
--- a/dom/interfaces/events/moz.build
+++ b/dom/interfaces/events/moz.build
@@ -47,10 +47,8 @@ XPIDL_SOURCES += [
     'nsIDOMTouchEvent.idl',
     'nsIDOMTransitionEvent.idl',
     'nsIDOMUIEvent.idl',
     'nsIDOMWheelEvent.idl',
 ]
 
 XPIDL_MODULE = 'dom_events'
 
-MODULE = 'dom'
-
--- a/dom/interfaces/geolocation/moz.build
+++ b/dom/interfaces/geolocation/moz.build
@@ -10,10 +10,8 @@ XPIDL_SOURCES += [
     'nsIDOMGeoPositionCallback.idl',
     'nsIDOMGeoPositionCoords.idl',
     'nsIDOMGeoPositionError.idl',
     'nsIDOMGeoPositionErrorCallback.idl',
 ]
 
 XPIDL_MODULE = 'dom_geolocation'
 
-MODULE = 'dom'
-
--- a/dom/interfaces/html/moz.build
+++ b/dom/interfaces/html/moz.build
@@ -63,10 +63,8 @@ XPIDL_SOURCES += [
     'nsIDOMMozBrowserFrame.idl',
     'nsIDOMTimeRanges.idl',
     'nsIDOMValidityState.idl',
     'nsIMozBrowserFrame.idl',
 ]
 
 XPIDL_MODULE = 'dom_html'
 
-MODULE = 'dom'
-
--- a/dom/interfaces/json/moz.build
+++ b/dom/interfaces/json/moz.build
@@ -5,10 +5,8 @@
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
 XPIDL_SOURCES += [
     'nsIJSON.idl',
 ]
 
 XPIDL_MODULE = 'dom_json'
 
-MODULE = 'dom'
-
--- a/dom/interfaces/notification/moz.build
+++ b/dom/interfaces/notification/moz.build
@@ -6,10 +6,8 @@
 
 XPIDL_SOURCES += [
     'nsIDOMDesktopNotification.idl',
     'nsINotificationStorage.idl',
 ]
 
 XPIDL_MODULE = 'dom_notification'
 
-MODULE = 'dom'
-
--- a/dom/interfaces/offline/moz.build
+++ b/dom/interfaces/offline/moz.build
@@ -6,10 +6,8 @@
 
 XPIDL_SOURCES += [
     'nsIDOMLoadStatus.idl',
     'nsIDOMOfflineResourceList.idl',
 ]
 
 XPIDL_MODULE = 'dom_offline'
 
-MODULE = 'dom'
-
--- a/dom/interfaces/permission/moz.build
+++ b/dom/interfaces/permission/moz.build
@@ -6,10 +6,8 @@
 
 XPIDL_SOURCES += [
     'nsIDOMPermissionSettings.idl',
     'nsIPermissionPromptService.idl',
 ]
 
 XPIDL_MODULE = 'dom_permissionsettings'
 
-MODULE = 'dom'
-
--- a/dom/interfaces/range/moz.build
+++ b/dom/interfaces/range/moz.build
@@ -5,10 +5,8 @@
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
 XPIDL_SOURCES += [
     'nsIDOMRange.idl',
 ]
 
 XPIDL_MODULE = 'dom_range'
 
-MODULE = 'dom'
-
--- a/dom/interfaces/settings/moz.build
+++ b/dom/interfaces/settings/moz.build
@@ -6,10 +6,8 @@
 
 XPIDL_SOURCES += [
     'nsIDOMMozSettingsEvent.idl',
     'nsISettingsService.idl',
 ]
 
 XPIDL_MODULE = 'dom_settings'
 
-MODULE = 'dom'
-
--- a/dom/interfaces/sidebar/moz.build
+++ b/dom/interfaces/sidebar/moz.build
@@ -6,10 +6,8 @@
 
 XPIDL_SOURCES += [
     'nsISidebar.idl',
     'nsIWebContentHandlerRegistrar.idl',
 ]
 
 XPIDL_MODULE = 'dom_sidebar'
 
-MODULE = 'dom'
-
--- a/dom/interfaces/smil/moz.build
+++ b/dom/interfaces/smil/moz.build
@@ -5,10 +5,8 @@
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
 XPIDL_SOURCES += [
     'nsIDOMTimeEvent.idl',
 ]
 
 XPIDL_MODULE = 'dom_smil'
 
-MODULE = 'dom'
-
--- a/dom/interfaces/storage/moz.build
+++ b/dom/interfaces/storage/moz.build
@@ -8,14 +8,12 @@ XPIDL_SOURCES += [
     'nsIDOMStorage.idl',
     'nsIDOMStorageEvent.idl',
     'nsIDOMStorageManager.idl',
     'nsIDOMToString.idl',
 ]
 
 XPIDL_MODULE = 'dom_storage'
 
-MODULE = 'dom'
-
 EXPORTS += [
     'nsPIDOMStorage.h',
 ]
 
--- a/dom/interfaces/stylesheets/moz.build
+++ b/dom/interfaces/stylesheets/moz.build
@@ -7,10 +7,8 @@
 XPIDL_SOURCES += [
     'nsIDOMMediaList.idl',
     'nsIDOMStyleSheet.idl',
     'nsIDOMStyleSheetList.idl',
 ]
 
 XPIDL_MODULE = 'dom_stylesheets'
 
-MODULE = 'dom'
-
--- a/dom/interfaces/svg/moz.build
+++ b/dom/interfaces/svg/moz.build
@@ -7,10 +7,8 @@
 XPIDL_SOURCES += [
     'nsIDOMSVGElement.idl',
     'nsIDOMSVGLength.idl',
     'nsIDOMSVGNumber.idl',
 ]
 
 XPIDL_MODULE = 'dom_svg'
 
-MODULE = 'dom'
-
--- a/dom/interfaces/traversal/moz.build
+++ b/dom/interfaces/traversal/moz.build
@@ -7,10 +7,8 @@
 XPIDL_SOURCES += [
     'nsIDOMNodeFilter.idl',
     'nsIDOMNodeIterator.idl',
     'nsIDOMTreeWalker.idl',
 ]
 
 XPIDL_MODULE = 'dom_traversal'
 
-MODULE = 'dom'
-
--- a/dom/interfaces/xbl/moz.build
+++ b/dom/interfaces/xbl/moz.build
@@ -5,10 +5,8 @@
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
 XPIDL_SOURCES += [
     'nsIDOMDocumentXBL.idl',
 ]
 
 XPIDL_MODULE = 'dom_xbl'
 
-MODULE = 'dom'
-
--- a/dom/interfaces/xpath/moz.build
+++ b/dom/interfaces/xpath/moz.build
@@ -10,10 +10,8 @@ XPIDL_SOURCES += [
     'nsIDOMXPathExpression.idl',
     'nsIDOMXPathNamespace.idl',
     'nsIDOMXPathNSResolver.idl',
     'nsIDOMXPathResult.idl',
 ]
 
 XPIDL_MODULE = 'dom_xpath'
 
-MODULE = 'dom'
-
--- a/dom/interfaces/xul/moz.build
+++ b/dom/interfaces/xul/moz.build
@@ -24,10 +24,8 @@ XPIDL_SOURCES += [
     'nsIDOMXULSelectCntrlEl.idl',
     'nsIDOMXULSelectCntrlItemEl.idl',
     'nsIDOMXULTextboxElement.idl',
     'nsIDOMXULTreeElement.idl',
 ]
 
 XPIDL_MODULE = 'dom_xul'
 
-MODULE = 'dom'
-
--- a/dom/ipc/moz.build
+++ b/dom/ipc/moz.build
@@ -2,18 +2,16 @@
 # 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/.
 
 if CONFIG['MOZ_WIDGET_TOOLKIT'] != 'cocoa':
     TEST_DIRS += ['tests']
 
-MODULE = 'dom'
-
 EXPORTS += [
     'nsICachedFileDescriptorListener.h',
     'PCOMContentPermissionRequestChild.h',
 ]
 
 EXPORTS.mozilla.dom.ipc += [
     'Blob.h',
     'nsIRemoteBlob.h',
@@ -68,24 +66,19 @@ IPDL_SOURCES += [
     'PCrashReporter.ipdl',
     'PDocumentRenderer.ipdl',
     'PMemoryReportRequest.ipdl',
     'PTabContext.ipdlh',
 ]
 
 FAIL_ON_WARNINGS = True
 
-LIBXUL_LIBRARY = True
-
-LIBRARY_NAME = 'domipc_s'
-
-EXPORT_LIBRARY = True
-
 include('/ipc/chromium/chromium-config.mozbuild')
 
+FINAL_LIBRARY = 'xul'
 LOCAL_INCLUDES += [
     '../src/base',
     '../src/geolocation',
     '../src/storage',
     '/chrome/src',
     '/content/base/src',
     '/content/events/src',
     '/content/media/webspeech/synth/ipc',
--- a/dom/media/bridge/moz.build
+++ b/dom/media/bridge/moz.build
@@ -3,31 +3,26 @@
 # 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/.
 
 XPIDL_SOURCES += [
     'IPeerConnection.idl',
 ]
 
-MODULE = 'peerconnection'
+XPIDL_MODULE = 'peerconnection'
 
 SOURCES += [
     'MediaModule.cpp',
 ]
 
 LOCAL_INCLUDES += [
     '/ipc/chromium/src',
     '/media/mtransport',
     '/media/webrtc/signaling/include',
     '/media/webrtc/signaling/src/common/time_profiling',
     '/media/webrtc/signaling/src/media-conduit',
     '/media/webrtc/signaling/src/mediapipeline',
     '/media/webrtc/signaling/src/peerconnection',
     '/media/webrtc/signaling/src/sipcc/include',
 ]
 
-LIBRARY_NAME = 'peerconnection'
-
-LIBXUL_LIBRARY = True
-
-EXPORT_LIBRARY = True
-
+FINAL_LIBRARY = 'xul'
--- a/dom/media/moz.build
+++ b/dom/media/moz.build
@@ -17,18 +17,16 @@ TEST_DIRS += ['tests/mochitest', 'tests/
 XPIDL_SOURCES += [
     'nsIDOMMediaStream.idl',
     'nsIDOMNavigatorUserMedia.idl',
     'nsIMediaManager.idl',
 ]
 
 XPIDL_MODULE = 'dom_media'
 
-MODULE = 'dom'
-
 EXPORTS.mozilla.dom += [
     'GetUserMediaRequest.h',
 ]
 
 EXPORTS.mozilla += [
     'MediaManager.h',
 ]
 
@@ -47,18 +45,16 @@ if CONFIG['MOZ_B2G']:
         'MediaPermissionGonk.h',
     ]
     SOURCES += [
         'MediaPermissionGonk.cpp',
     ]
 
 FAIL_ON_WARNINGS = True
 
-LIBXUL_LIBRARY = True
-
-LIBRARY_NAME = 'dom_media_s'
-
 LOCAL_INCLUDES += [
     '../base',
     '../camera',
 ]
 
 include('/ipc/chromium/chromium-config.mozbuild')
+
+FINAL_LIBRARY = 'gklayout'
--- a/dom/mobilemessage/src/moz.build
+++ b/dom/mobilemessage/src/moz.build
@@ -64,19 +64,17 @@ IPDL_SOURCES += [
     'ipc/PMobileMessageCursor.ipdl',
     'ipc/PSms.ipdl',
     'ipc/PSmsRequest.ipdl',
     'ipc/SmsTypes.ipdlh',
 ]
 
 FAIL_ON_WARNINGS = True
 
-LIBXUL_LIBRARY = True
-
 MSVC_ENABLE_PGO = True
 
-LIBRARY_NAME = 'dom_mobilemessage_s'
-
 LOCAL_INCLUDES += [
     '/dom/base',
 ]
 
 include('/ipc/chromium/chromium-config.mozbuild')
+
+FINAL_LIBRARY = 'gklayout'
--- a/dom/moz.build
+++ b/dom/moz.build
@@ -106,10 +106,8 @@ TEST_DIRS += [
     'tests',
     'imptests',
     'bindings/test',
 ]
 
 if CONFIG['MOZ_WIDGET_TOOLKIT'] in ('gtk2', 'cocoa', 'windows', 'android', 'qt', 'os2'):
     TEST_DIRS += ['plugins/test']
 
-MODULE = 'dom'
-
--- a/dom/network/src/moz.build
+++ b/dom/network/src/moz.build
@@ -62,18 +62,15 @@ if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'gonk
 IPDL_SOURCES += [
     'PTCPServerSocket.ipdl',
     'PTCPSocket.ipdl',
     'PUDPSocket.ipdl',
 ]
 
 FAIL_ON_WARNINGS = True
 
-LIBXUL_LIBRARY = True
-
-LIBRARY_NAME = 'dom_network_s'
-
 include('/ipc/chromium/chromium-config.mozbuild')
 
+FINAL_LIBRARY = 'gklayout'
 LOCAL_INCLUDES += [
     '/content/events/src',
 ]
 
--- a/dom/network/tests/moz.build
+++ b/dom/network/tests/moz.build
@@ -1,12 +1,10 @@
 # -*- 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/.
 
-MODULE = 'test_dom_socket'
-
 XPCSHELL_TESTS_MANIFESTS += ['unit/xpcshell.ini', 'unit_ipc/xpcshell.ini']
 
 if CONFIG['MOZ_B2G_RIL']:
     XPCSHELL_TESTS_MANIFESTS += ['unit_stats/xpcshell.ini']
--- a/dom/nfc/moz.build
+++ b/dom/nfc/moz.build
@@ -1,25 +1,22 @@
 # 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/.
 #
 # Copyright © 2013 Deutsche Telekom, Inc.
 
 if CONFIG['MOZ_NFC']:
-    MODULE = 'dom'
     EXPORTS.mozilla.dom += [
         'MozNdefRecord.h',
     ]
     SOURCES += [
         'MozNdefRecord.cpp',
     ]
     EXTRA_COMPONENTS += [
       'nsNfc.js',
       'nsNfc.manifest',
     ]
 
 FAIL_ON_WARNINGS = True
 
-LIBRARY_NAME = 'dom_nfc_s'
-
-LIBXUL_LIBRARY = True
+FINAL_LIBRARY = 'gklayout'
--- a/dom/payment/tests/moz.build
+++ b/dom/payment/tests/moz.build
@@ -1,9 +1,7 @@
 # -*- 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/.
 
-MODULE = 'test_dom_payment'
-
 XPCSHELL_TESTS_MANIFESTS += ['unit/xpcshell.ini']
--- a/dom/permission/tests/moz.build
+++ b/dom/permission/tests/moz.build
@@ -1,12 +1,10 @@
 # -*- 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/.
 
-MODULE = 'test_permission'
-
 XPCSHELL_TESTS_MANIFESTS += ['unit/xpcshell.ini']
 
 MOCHITEST_MANIFESTS += ['mochitest.ini']
 
--- a/dom/plugins/base/android/ANPNativeWindow.cpp
+++ b/dom/plugins/base/android/ANPNativeWindow.cpp
@@ -21,15 +21,16 @@ using namespace mozilla;
 static ANPNativeWindow anp_native_window_acquireNativeWindow(NPP instance) {
   nsNPAPIPluginInstance* pinst = static_cast<nsNPAPIPluginInstance*>(instance->ndata);
   return pinst->AcquireContentWindow();
 }
 
 static void anp_native_window_invertPluginContent(NPP instance, bool isContentInverted) {
   nsNPAPIPluginInstance* pinst = static_cast<nsNPAPIPluginInstance*>(instance->ndata);
   pinst->SetInverted(isContentInverted);
+  pinst->RedrawPlugin();
 }
 
 
 void InitNativeWindowInterface(ANPNativeWindowInterfaceV0* i) {
     ASSIGN(i, acquireNativeWindow);
     ASSIGN(i, invertPluginContent);
 }
--- a/dom/plugins/base/android/moz.build
+++ b/dom/plugins/base/android/moz.build
@@ -1,16 +1,14 @@
 # -*- 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/.
 
-MODULE = 'plugin'
-
 EXPORTS += [
     'android_npapi.h',
     'ANPKeyCodes.h',
 ]
 
 SOURCES += [
     'ANPAudio.cpp',
     'ANPBitmap.cpp',
@@ -22,24 +20,19 @@ SOURCES += [
     'ANPSurface.cpp',
     'ANPSystem.cpp',
     'ANPVideo.cpp',
     'ANPWindow.cpp',
 ]
 
 FAIL_ON_WARNINGS = True
 
-LIBXUL_LIBRARY = True
-
-LIBRARY_NAME = 'gkpluginandroid_s'
-
-EXPORT_LIBRARY = True
-
 include('/ipc/chromium/chromium-config.mozbuild')
 
+FINAL_LIBRARY = 'gklayout'
 LOCAL_INCLUDES += [
     '/dom/plugins/base',
     '/dom/plugins/base/android/include',
     '/gfx/gl',
     '/widget/android',
     '/widget/xpwidgets',
 ]
 
--- a/dom/plugins/base/moz.build
+++ b/dom/plugins/base/moz.build
@@ -13,17 +13,17 @@ XPIDL_SOURCES += [
     'nsIPluginHost.idl',
     'nsIPluginInputStream.idl',
     'nsIPluginInstanceOwner.idl',
     'nsIPluginTag.idl',
     'nsIPluginTagInfo.idl',
     'nspluginroot.idl',
 ]
 
-MODULE = 'plugin'
+XPIDL_MODULE = 'plugin'
 
 EXPORTS += [
     'npapi.h',
     'npfunctions.h',
     'npruntime.h',
     'nptypes.h',
     'nsJSNPRuntime.h',
     'nsNPAPIPluginInstance.h',
@@ -90,24 +90,18 @@ else:
         ]
 
 if CONFIG['MOZ_WIDGET_TOOLKIT'] != 'android':
     # android_npapi.h extends the NPNVariable and NPPVariable enums
     # using #defines, which results in Wswitch warnings in gcc-4.6.
     # Therefore, enable FAIL_ON_WARNINGS only on non-Android platforms.
     FAIL_ON_WARNINGS = True
 
-LIBXUL_LIBRARY = True
-
 MSVC_ENABLE_PGO = True
 
-LIBRARY_NAME = 'gkplugin'
-
-EXPORT_LIBRARY = True
-
 LOCAL_INCLUDES += [
     '/content/base/src',
     '/dom/base',
     '/gfx/skia/include/config',
     '/gfx/skia/include/core',
     '/layout/generic',
     '/layout/xul/base/src',
     '/widget/android',
@@ -124,8 +118,9 @@ if CONFIG['OS_ARCH'] == 'WINNT':
     LOCAL_INCLUDES += [
         '/xpcom/base',
     ]
 
 include('/ipc/chromium/chromium-config.mozbuild')
 
 DEFINES['SK_BUILD_FOR_ANDROID_NDK'] = True
 
+FINAL_LIBRARY = 'xul'
--- a/dom/plugins/base/nsJSNPRuntime.cpp
+++ b/dom/plugins/base/nsJSNPRuntime.cpp
@@ -988,17 +988,17 @@ nsJSObjWrapper::GetNewOrUsed(NPP npp, JS
 
     if (LookupNPP(npobj) == npp)
       return _retainobject(npobj);
   }
 
   if (!sJSObjWrappers.ops) {
     // No hash yet (or any more), initialize it.
 
-    static PLDHashTableOps ops =
+    static const PLDHashTableOps ops =
       {
         PL_DHashAllocTable,
         PL_DHashFreeTable,
         JSObjWrapperHash,
         JSObjWrapperHashMatchEntry,
         PL_DHashMoveEntryStub,
         PL_DHashClearEntryStub,
         PL_DHashFinalizeStub
--- a/dom/plugins/ipc/interpose/Makefile.in
+++ b/dom/plugins/ipc/interpose/Makefile.in
@@ -1,11 +1,10 @@
 # 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/.
 
-FORCE_SHARED_LIB = 1
 DIST_INSTALL     = 1
 
 
 EXTRA_DSO_LDOPTS += \
   -framework Carbon \
   $(NULL)
--- a/dom/plugins/ipc/interpose/moz.build
+++ b/dom/plugins/ipc/interpose/moz.build
@@ -6,8 +6,10 @@
 
 LIBRARY_NAME = 'plugin_child_interpose'
 
 SOURCES += [ "%s.mm" % (LIBRARY_NAME) ]
 
 SOURCES += [
     'plugin_child_quirks.mm',
 ]
+
+FORCE_SHARED_LIB = True
--- a/dom/plugins/ipc/moz.build
+++ b/dom/plugins/ipc/moz.build
@@ -2,18 +2,16 @@
 # 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/.
 
 if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'cocoa':
     DIRS += ['interpose']
 
-MODULE = 'dom'
-
 EXPORTS.mozilla += [
     'PluginLibrary.h',
 ]
 
 EXPORTS.mozilla.plugins += [
     'AStream.h',
     'BrowserStreamChild.h',
     'BrowserStreamParent.h',
@@ -109,23 +107,18 @@ IPDL_SOURCES += [
     'PPluginScriptableObject.ipdl',
     'PPluginStream.ipdl',
     'PPluginSurface.ipdl',
     'PStreamNotify.ipdl',
 ]
 
 FAIL_ON_WARNINGS = True
 
-LIBXUL_LIBRARY = True
-
-LIBRARY_NAME = 'domplugins_s'
-
-EXPORT_LIBRARY = True
-
 include('/ipc/chromium/chromium-config.mozbuild')
 
+FINAL_LIBRARY = 'xul'
 LOCAL_INCLUDES += [
     '../base',
     '/xpcom/base/',
 ]
 
 DEFINES['FORCE_PR_LOG'] = True
 
--- a/dom/plugins/test/moz.build
+++ b/dom/plugins/test/moz.build
@@ -4,11 +4,9 @@
 # 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 += ['testplugin']
 
 if CONFIG['MOZ_WIDGET_TOOLKIT'] in ('gtk2', 'gtk3', 'cocoa', 'windows'):
     TEST_DIRS += ['mochitest']
 
-MODULE = 'test_plugin'
-
 XPCSHELL_TESTS_MANIFESTS += ['unit/xpcshell.ini']
--- a/dom/plugins/test/testplugin/moz.build
+++ b/dom/plugins/test/testplugin/moz.build
@@ -1,16 +1,14 @@
 # -*- 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 += ['secondplugin']
 
-MODULE = 'nptest'
-
 LIBRARY_NAME = 'nptest'
 
 FAIL_ON_WARNINGS = not CONFIG['_MSC_VER']
 
 relative_path = '.'
 include('testplugin.mozbuild')
--- a/dom/plugins/test/testplugin/secondplugin/moz.build
+++ b/dom/plugins/test/testplugin/secondplugin/moz.build
@@ -1,12 +1,10 @@
 # -*- 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/.
 
-MODULE = 'npsecondtest'
-
 LIBRARY_NAME = 'npsecondtest'
 
 relative_path = '..'
 include('../testplugin.mozbuild')
--- a/dom/plugins/test/testplugin/testplugin.mk
+++ b/dom/plugins/test/testplugin/testplugin.mk
@@ -1,15 +1,13 @@
 #
 # 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/.
 
-FORCE_SHARED_LIB = 1
-
 # Don't use STL wrappers; nptest isn't Gecko code
 STL_FLAGS =
 
 # must link statically with the CRT; nptest isn't Gecko code
 USE_STATIC_LIBS = 1
 
 VPATH += $(topsrcdir)/build
 
--- a/dom/plugins/test/testplugin/testplugin.mozbuild
+++ b/dom/plugins/test/testplugin/testplugin.mozbuild
@@ -35,8 +35,10 @@ elif toolkit == 'os2':
 elif toolkit == 'qt':
     SOURCES += [
         relative_path + '/nptest_qt.cpp',
     ]
 elif toolkit == 'windows':
     SOURCES += [
         relative_path + '/nptest_windows.cpp',
     ]
+
+FORCE_SHARED_LIB = True
--- a/dom/power/moz.build
+++ b/dom/power/moz.build
@@ -27,14 +27,11 @@ EXPORTS.mozilla.dom.power += [
 SOURCES += [
     'PowerManager.cpp',
     'PowerManagerService.cpp',
     'WakeLock.cpp',
 ]
 
 FAIL_ON_WARNINGS = True
 
-LIBXUL_LIBRARY = True
-
-LIBRARY_NAME = 'dom_power_s'
-
 include('/ipc/chromium/chromium-config.mozbuild')
 
+FINAL_LIBRARY = 'gklayout'
--- a/dom/promise/moz.build
+++ b/dom/promise/moz.build
@@ -3,29 +3,25 @@
 # 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/.
 
 TEST_DIRS += ['tests']
 
 XPIDL_MODULE = 'dom_promise'
 
-MODULE = 'dom'
-
 EXPORTS.mozilla.dom += [
     'Promise.h',
 ]
 
 SOURCES += [
     'Promise.cpp',
     'PromiseCallback.cpp',
 ]
 
 FAIL_ON_WARNINGS = True
 
-LIBXUL_LIBRARY = True
-
-LIBRARY_NAME = 'dompromise_s'
-
 LOCAL_INCLUDES += [
     '../base',
     '../workers',
 ]
+
+FINAL_LIBRARY = 'gklayout'
--- a/dom/quota/moz.build
+++ b/dom/quota/moz.build
@@ -7,18 +7,16 @@
 XPIDL_SOURCES += [
     'nsIQuotaManager.idl',
     'nsIQuotaRequest.idl',
     'nsIUsageCallback.idl',
 ]
 
 XPIDL_MODULE = 'dom_quota'
 
-MODULE = 'dom'
-
 EXPORTS += [
     'nsIOfflineStorage.h',
 ]
 
 EXPORTS.mozilla.dom.quota += [
     'AcquireListener.h',
     'ArrayCluster.h',
     'Client.h',
@@ -37,20 +35,17 @@ SOURCES += [
     'CheckQuotaHelper.cpp',
     'FileStreams.cpp',
     'QuotaManager.cpp',
     'QuotaObject.cpp',
 ]
 
 FAIL_ON_WARNINGS = True
 
-LIBXUL_LIBRARY = True
-
 MSVC_ENABLE_PGO = True
 
-LIBRARY_NAME = 'domquota_s'
-
 include('/ipc/chromium/chromium-config.mozbuild')
 
+FINAL_LIBRARY = 'gklayout'
 LOCAL_INCLUDES += [
     '/caps/include',
 ]
 
--- a/dom/src/events/moz.build
+++ b/dom/src/events/moz.build
@@ -1,24 +1,20 @@
 # -*- 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/.
 
-MODULE = 'dom'
-
 SOURCES += [
     'nsJSEventListener.cpp',
 ]
 
-LIBRARY_NAME = 'jsdomevents_s'
-
 FAIL_ON_WARNINGS = True
 
-LIBXUL_LIBRARY = True
-
 MSVC_ENABLE_PGO = True
 
 LOCAL_INCLUDES += [
     "/content/base/src",
     "/dom/base",
 ]
+
+FINAL_LIBRARY = 'gklayout'
--- a/dom/src/geolocation/moz.build
+++ b/dom/src/geolocation/moz.build
@@ -1,34 +1,29 @@
 # -*- 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/.
 
-MODULE = 'dom'
-
 EXPORTS += [
     'nsGeoPosition.h',
     'nsGeoPositionIPCSerialiser.h',
 ]
 
 SOURCES += [
     'nsGeolocation.cpp',
     'nsGeoPosition.cpp',
 ]
 
 FAIL_ON_WARNINGS = True
 
-LIBXUL_LIBRARY = True
-
-LIBRARY_NAME = 'jsdomgeolocation_s'
-
 include('/ipc/chromium/chromium-config.mozbuild')
 
+FINAL_LIBRARY = 'gklayout'
 LOCAL_INCLUDES += [
     '/content/base/src',
     '/content/events/src',
     '/dom/base',
     '/dom/ipc',
 ]
 
 if CONFIG['MOZ_ENABLE_QTMOBILITY']:
--- a/dom/src/json/moz.build
+++ b/dom/src/json/moz.build
@@ -1,27 +1,23 @@
 # -*- 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/.
 
 TEST_DIRS += ['test']
 
-MODULE = 'dom'
-
 EXPORTS += [
     'nsJSON.h',
 ]
 
 SOURCES += [
     'nsJSON.cpp',
 ]
 
-LIBRARY_NAME = 'json_s'
-
 FAIL_ON_WARNINGS = True
 
-LIBXUL_LIBRARY = True
-
 LOCAL_INCLUDES += [
     '/content/base/src',
 ]
+
+FINAL_LIBRARY = 'gklayout'
--- a/dom/src/json/test/moz.build
+++ b/dom/src/json/test/moz.build
@@ -1,12 +1,10 @@
 # -*- 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/.
 
-MODULE = 'json_test'
-
 XPCSHELL_TESTS_MANIFESTS += ['unit/xpcshell.ini']
 
 MOCHITEST_MANIFESTS += ['mochitest.ini']
 
--- a/dom/src/jsurl/moz.build
+++ b/dom/src/jsurl/moz.build
@@ -1,28 +1,24 @@
 # -*- 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/.
 
 TEST_DIRS += ['test']
 
-MODULE = 'jsurl'
-
 EXPORTS += [
     'nsJSProtocolHandler.h',
 ]
 
 SOURCES += [
     'nsJSProtocolHandler.cpp',
 ]
 
-LIBRARY_NAME = 'jsurl_s'
-
 FAIL_ON_WARNINGS = True
 
-LIBXUL_LIBRARY = True
-
 LOCAL_INCLUDES += [
     "/dom/base",
     "/netwerk/base/src",
 ]
+
+FINAL_LIBRARY = 'gklayout'
--- a/dom/src/notification/moz.build
+++ b/dom/src/notification/moz.build
@@ -1,16 +1,14 @@
 # -*- 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/.
 
-MODULE = 'dom'
-
 EXTRA_COMPONENTS += [
     'NotificationStorage.js',
     'NotificationStorage.manifest',
 ]
 
 EXTRA_JS_MODULES += [
     'NotificationDB.jsm'
 ]
@@ -22,21 +20,18 @@ EXPORTS.mozilla.dom += [
 
 SOURCES += [
     'DesktopNotification.cpp',
     'Notification.cpp',
 ]
 
 FAIL_ON_WARNINGS = True
 
-LIBXUL_LIBRARY = True
-
-LIBRARY_NAME = 'jsdomnotification_s'
-
 include('/ipc/chromium/chromium-config.mozbuild')
 
+FINAL_LIBRARY = 'gklayout'
 LOCAL_INCLUDES += [
     '/content/base/src',
     '/content/events/src',
     '/dom/base',
     '/dom/ipc',
 ]
 
--- a/dom/src/offline/moz.build
+++ b/dom/src/offline/moz.build
@@ -1,26 +1,22 @@
 # -*- 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/.
 
-MODULE = 'dom'
-
 EXPORTS += [
     'nsDOMOfflineResourceList.h',
 ]
 SOURCES += [
     'nsDOMOfflineResourceList.cpp',
 ]
 
-LIBRARY_NAME = 'jsdomoffline_s'
-
 FAIL_ON_WARNINGS = True
 
-LIBXUL_LIBRARY = True
-
 LOCAL_INCLUDES += [
     "/content/base/src",
     "/content/events/src",
     "/dom/base",
 ]
+
+FINAL_LIBRARY = 'gklayout'
--- a/dom/src/storage/moz.build
+++ b/dom/src/storage/moz.build
@@ -1,16 +1,14 @@
 # -*- 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/.
 
-MODULE = 'dom'
-
 EXPORTS.mozilla.dom += [
     'DOMStorageIPC.h',
 ]
 
 SOURCES += [
     'DOMStorage.cpp',
     'DOMStorageCache.cpp',
     'DOMStorageDBThread.cpp',
@@ -20,23 +18,20 @@ SOURCES += [
 ]
 
 IPDL_SOURCES += [
     'PStorage.ipdl',
 ]
 
 FAIL_ON_WARNINGS = True
 
-LIBXUL_LIBRARY = True
-
 MSVC_ENABLE_PGO = True
 
-LIBRARY_NAME = 'jsdomstorage_s'
-
 include('/ipc/chromium/chromium-config.mozbuild')
 
+FINAL_LIBRARY = 'gklayout'
 LOCAL_INCLUDES += [
     '/content/events/src',
     '/dom/base',
 ]
 
 if CONFIG['ENABLE_TESTS']:
     DEFINES['DOM_STORAGE_TESTS'] = True
--- a/dom/system/android/moz.build
+++ b/dom/system/android/moz.build
@@ -1,28 +1,21 @@
 # -*- 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/.
 
-MODULE = 'dom'
-
 SOURCES += [
     'AndroidLocationProvider.cpp',
     'nsHapticFeedback.cpp',
 ]
 
 FAIL_ON_WARNINGS = True
 
-LIBXUL_LIBRARY = True
-
-LIBRARY_NAME = 'domsystemandroid_s'
-
-EXPORT_LIBRARY = True
-
 include('/ipc/chromium/chromium-config.mozbuild')
 
+FINAL_LIBRARY = 'gklayout'
 LOCAL_INCLUDES += [
     '/content/events/src',
     '/dom/src/geolocation',
 ]
 
--- a/dom/system/gonk/moz.build
+++ b/dom/system/gonk/moz.build
@@ -24,18 +24,16 @@ XPIDL_SOURCES += [
     'nsIVolumeMountLock.idl',
     'nsIVolumeService.idl',
     'nsIVolumeStat.idl',
     'nsIWorkerHolder.idl',
 ]
 
 XPIDL_MODULE = 'dom_system_gonk'
 
-MODULE = 'dom'
-
 EXPORTS += [
     'GonkGPSGeolocationProvider.h',
     'nsVolume.h',
     'nsVolumeService.h',
 ]
 SOURCES += [
     'AudioChannelManager.cpp',
     'AudioManager.cpp',
@@ -109,23 +107,20 @@ if CONFIG['MOZ_B2G_BT_BLUEZ']:
     ]
 elif CONFIG['MOZ_B2G_BT_BLUEDROID']:
     LOCAL_INCLUDES += [
         '/dom/bluetooth/bluedroid',
     ]
 
 FAIL_ON_WARNINGS = True
 
-LIBXUL_LIBRARY = True
-
-LIBRARY_NAME = 'domsystemgonk_s'
-
 include('/ipc/chromium/chromium-config.mozbuild')
 
 LOCAL_INCLUDES += [
     '/content/events/src',
     '/dom/base',
     '/dom/bluetooth',
     '/dom/nfc',
     '/dom/src/geolocation',
     '/dom/wifi',
 ]
 
+FINAL_LIBRARY = 'gklayout'
--- a/dom/system/mac/moz.build
+++ b/dom/system/mac/moz.build
@@ -1,24 +1,17 @@
 # -*- 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/.
 
-MODULE = 'dom'
-
 SOURCES += ['CoreLocationLocationProvider.mm']
 
 FAIL_ON_WARNINGS = True
 
-LIBXUL_LIBRARY = True
-
-LIBRARY_NAME = 'domsystemmac_s'
-
-EXPORT_LIBRARY = True
-
 include('/ipc/chromium/chromium-config.mozbuild')
 
+FINAL_LIBRARY = 'gklayout'
 LOCAL_INCLUDES += [
     '/dom/src/geolocation',
 ]
 
--- a/dom/system/moz.build
+++ b/dom/system/moz.build
@@ -20,18 +20,16 @@ elif toolkit == 'gonk':
 TEST_DIRS += ['tests']
 
 XPIDL_SOURCES += [
     'nsIOSFileConstantsService.idl',
 ]
 
 XPIDL_MODULE = 'dom_system'
 
-MODULE = 'dom'
-
 EXPORTS += [
     'nsDeviceSensors.h',
 ]
 
 EXPORTS.mozilla += [
     'OSFileConstants.h',
 ]
 
@@ -45,24 +43,19 @@ SOURCES += [
 if CONFIG['OS_TARGET'] != 'Android' or CONFIG['MOZ_WIDGET_TOOLKIT'] == 'gonk':
     EXTRA_COMPONENTS += [
         'NetworkGeolocationProvider.js',
         'NetworkGeolocationProvider.manifest',
     ]
 
 FAIL_ON_WARNINGS = True
 
-LIBXUL_LIBRARY = True
-
-LIBRARY_NAME = 'domsystem_s'
-
-EXPORT_LIBRARY = True
-
 include('/ipc/chromium/chromium-config.mozbuild')
 
+FINAL_LIBRARY = 'gklayout'
 # We fire the nsDOMDeviceAcceleration
 LOCAL_INCLUDES += [
     '/content/events/src',
     '/dom/base',
     '/dom/bindings',
     '/js/xpconnect/loader',
 ]
 
--- a/dom/system/tests/moz.build
+++ b/dom/system/tests/moz.build
@@ -1,10 +1,8 @@
 # -*- 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/.
 
-MODULE = 'test_domsystem'
-
 MOCHITEST_CHROME_MANIFESTS += ['chrome.ini']
 
--- a/dom/system/unix/moz.build
+++ b/dom/system/unix/moz.build
@@ -1,30 +1,23 @@
 # -*- 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/.
 
-MODULE = 'dom'
-
 if CONFIG['MOZ_ENABLE_QTMOBILITY']:
     GENERATED_SOURCES += [
         'moc_QTMLocationProvider.cpp',
     ]
     SOURCES += [
         'QTMLocationProvider.cpp',
     ]
 
     LOCAL_INCLUDES += [
         '/dom/src/geolocation',
     ]
 
 FAIL_ON_WARNINGS = True
 
-LIBXUL_LIBRARY = True
-
-LIBRARY_NAME = 'domsystemunix_s'
-
-EXPORT_LIBRARY = True
-
 include('/ipc/chromium/chromium-config.mozbuild')
 
+FINAL_LIBRARY = 'gklayout'
--- a/dom/system/windows/moz.build
+++ b/dom/system/windows/moz.build
@@ -1,25 +1,18 @@
 # -*- 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/.
 
-MODULE = 'dom'
-
 SOURCES += [
     'nsHapticFeedback.cpp',
 ]
 
 # We fire the nsDOMDeviceAcceleration
 LOCAL_INCLUDES += [
     '/content/events/src',
 ]
 
 FAIL_ON_WARNINGS = True
 
-LIBXUL_LIBRARY = True
-
-LIBRARY_NAME = 'domsystemwindows_s'
-
-EXPORT_LIBRARY = True
-
+FINAL_LIBRARY = 'gklayout'
--- a/dom/telephony/moz.build
+++ b/dom/telephony/moz.build
@@ -5,18 +5,16 @@
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
 XPIDL_SOURCES += [
     'nsITelephonyProvider.idl',
 ]
 
 XPIDL_MODULE = 'dom_telephony'
 
-MODULE = 'dom'
-
 EXPORTS.mozilla.dom += [
     'CallEvent.h',
     'CallsList.h',
     'Telephony.h',
     'TelephonyCall.h',
     'TelephonyCallGroup.h',
 ]
 
@@ -50,14 +48,11 @@ if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'gonk
         'nsIGonkTelephonyProvider.idl',
     ]
     EXTRA_COMPONENTS += [
         'gonk/TelephonyProvider.js',
         'gonk/TelephonyProvider.manifest',
     ]
 
 FAIL_ON_WARNINGS = True
-
-LIBXUL_LIBRARY = True
-
-LIBRARY_NAME = 'domtelephony_s'
 include('/ipc/chromium/chromium-config.mozbuild')
 
+FINAL_LIBRARY = 'gklayout'
--- a/dom/tests/moz.build
+++ b/dom/tests/moz.build
@@ -1,11 +1,9 @@
 # -*- 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 += ['mochitest', 'browser']
 
-MODULE = 'test_dom'
-
 XPCSHELL_TESTS_MANIFESTS += ['unit/xpcshell.ini']
--- a/dom/time/moz.build
+++ b/dom/time/moz.build
@@ -5,32 +5,27 @@
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
 XPIDL_SOURCES += [
     'nsITimeService.idl',
 ]
 
 XPIDL_MODULE = 'dom_time'
 
-MODULE = 'dom'
-
 EXPORTS.mozilla.dom.time += [
     'DateCacheCleaner.h',
     'TimeChangeObserver.h',
     'TimeManager.h',
     'TimeService.h',
 ]
 
 SOURCES += [
     'DateCacheCleaner.cpp',
     'TimeChangeObserver.cpp',
     'TimeManager.cpp',
     'TimeService.cpp',
 ]
 
 FAIL_ON_WARNINGS = True
 
-LIBXUL_LIBRARY = True
-
-LIBRARY_NAME = 'dom_time_s'
-
 include('/ipc/chromium/chromium-config.mozbuild')
 
+FINAL_LIBRARY = 'gklayout'
--- a/dom/voicemail/moz.build
+++ b/dom/voicemail/moz.build
@@ -7,27 +7,23 @@
 XPIDL_SOURCES += [
     'nsIDOMMozVoicemailEvent.idl',
     'nsIDOMMozVoicemailStatus.idl',
     'nsIVoicemailProvider.idl',
 ]
 
 XPIDL_MODULE = 'dom_voicemail'
 
-MODULE = 'dom'
-
 EXPORTS.mozilla.dom += [
     'Voicemail.h',
 ]
 
 SOURCES += [
     'Voicemail.cpp',
 ]
 
 FAIL_ON_WARNINGS = True
 
-LIBXUL_LIBRARY = True
-
-LIBRARY_NAME = 'domvoicemail_s'
-
 LOCAL_INCLUDES += [
     '../base',
 ]
+
+FINAL_LIBRARY = 'gklayout'
--- a/dom/webidl/DocumentFragment.webidl
+++ b/dom/webidl/DocumentFragment.webidl
@@ -8,23 +8,17 @@
  * http://www.w3.org/TR/2012/WD-selectors-api-20120628/#interface-definitions
  *
  * Copyright © 2012 W3C® (MIT, ERCIM, Keio), All Rights Reserved. W3C
  * liability, trademark and document use rules apply.
  */
 
 [Constructor]
 interface DocumentFragment : Node {
-  // NEW
-  /*
-    FIXME: not implemented yet
-
-  void prepend((Node or DOMString)... nodes);
-  void append((Node or DOMString)... nodes);
-  */
+  Element? getElementById(DOMString elementId);
 };
 
 // http://www.w3.org/TR/2012/WD-selectors-api-20120628/#interface-definitions
 partial interface DocumentFragment {
   [Throws]
   Element?  querySelector(DOMString selectors);
   [Throws]
   NodeList  querySelectorAll(DOMString selectors);
--- a/dom/webidl/SVGSVGElement.webidl
+++ b/dom/webidl/SVGSVGElement.webidl
@@ -54,17 +54,16 @@ interface SVGSVGElement : SVGGraphicsEle
   [NewObject]
   SVGMatrix createSVGMatrix();
   [NewObject]
   SVGRect createSVGRect();
   [NewObject]
   SVGTransform createSVGTransform();
   [NewObject]
   SVGTransform createSVGTransformFromMatrix(SVGMatrix matrix);
-  [Throws]
   Element? getElementById(DOMString elementId);
 };
 
 /*SVGSVGElement implements ViewCSS;
 SVGSVGElement implements DocumentCSS;*/
 SVGSVGElement implements SVGFitToViewBox;
 SVGSVGElement implements SVGZoomAndPan;
 
--- a/dom/webidl/moz.build
+++ b/dom/webidl/moz.build
@@ -1,16 +1,14 @@
 # -*- 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/.
 
-MODULE = 'dom'
-
 GENERATED_WEBIDL_FILES = [
     'CSS2Properties.webidl',
 ]
 
 PREPROCESSED_WEBIDL_FILES = [
     'Crypto.webidl',
     'Navigator.webidl',
     'Window.webidl',
--- a/dom/wifi/moz.build
+++ b/dom/wifi/moz.build
@@ -8,18 +8,16 @@ XPIDL_SOURCES += [
     'nsIDOMMozWifiConnectionInfoEvent.idl',
     'nsIDOMMozWifiStatusChangeEvent.idl',
     'nsIWifi.idl',
     'nsIWifiService.idl',
 ]
 
 XPIDL_MODULE = 'dom_wifi'
 
-MODULE = 'dom'
-
 EXTRA_COMPONENTS += [
     'DOMWifiManager.js',
     'DOMWifiManager.manifest',
     'WifiWorker.js',
     'WifiWorker.manifest',
 ]
 
 EXTRA_JS_MODULES += [
@@ -29,14 +27,9 @@ EXTRA_JS_MODULES += [
 
 if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'gonk':
     SOURCES = [
         'NetUtils.cpp',
         'WifiProxyService.cpp',
         'WifiUtils.cpp',
     ]
 
-LIBXUL_LIBRARY = True
-
-LIBRARY_NAME = 'domwifi_s'
-
-EXPORT_LIBRARY = True
-
+FINAL_LIBRARY = 'xul'
--- a/dom/workers/WorkerPrivate.cpp
+++ b/dom/workers/WorkerPrivate.cpp
@@ -4235,16 +4235,21 @@ WorkerPrivate::ResumeInternal(JSContext*
 void
 WorkerPrivate::TraceTimeouts(const TraceCallbacks& aCallbacks,
                              void* aClosure) const
 {
   AssertIsOnWorkerThread();
 
   for (uint32_t index = 0; index < mTimeouts.Length(); index++) {
     TimeoutInfo* info = mTimeouts[index];
+
+    if (info->mTimeoutCallable.isUndefined()) {
+      continue;
+    }
+
     aCallbacks.Trace(&info->mTimeoutCallable, "mTimeoutCallable", aClosure);
     for (uint32_t index2 = 0; index2 < info->mExtraArgVals.Length(); index2++) {
       aCallbacks.Trace(&info->mExtraArgVals[index2], "mExtraArgVals[i]", aClosure);
     }
   }
 }
 
 bool
--- a/dom/workers/WorkerScope.cpp
+++ b/dom/workers/WorkerScope.cpp
@@ -36,16 +36,18 @@ WorkerGlobalScope::WorkerGlobalScope(Wor
 {
   mWorkerPrivate->AssertIsOnWorkerThread();
 
   SetIsDOMBinding();
 }
 
 WorkerGlobalScope::~WorkerGlobalScope()
 {
+  // Matches the HoldJSObjects in CreateGlobal.
+  mozilla::DropJSObjects(this);
 }
 
 NS_IMPL_CYCLE_COLLECTION_CLASS(WorkerGlobalScope)
 
 NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(WorkerGlobalScope,
                                                   nsDOMEventTargetHelper)
   tmp->mWorkerPrivate->AssertIsOnWorkerThread();
 NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
--- a/dom/workers/moz.build
+++ b/dom/workers/moz.build
@@ -1,18 +1,16 @@
 # -*- 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/.
 
 TEST_DIRS += ['test']
 
-MODULE = 'dom'
-
 # Public stuff.
 EXPORTS.mozilla.dom += [
     'WorkerPrivate.h',
     'WorkerScope.h',
 ]
 
 EXPORTS.mozilla.dom.workers += [
     'Workers.h',
@@ -45,23 +43,21 @@ SOURCES += [
     'SharedWorker.cpp',
     'URL.cpp',
     'WorkerPrivate.cpp',
     'WorkerScope.cpp',
     'XMLHttpRequest.cpp',
     'XMLHttpRequestUpload.cpp',
 ]
 
-LIBRARY_NAME = 'domworkers_s'
-
 FAIL_ON_WARNINGS = True
 
-LIBXUL_LIBRARY = True
-
 MSVC_ENABLE_PGO = True
 
 LOCAL_INCLUDES += [
     '../base',
     '../system',
     '/content/base/src',
     '/content/events/src',
     '/xpcom/build',
 ]
+
+FINAL_LIBRARY = 'gklayout'
--- a/dom/workers/test/mochitest.ini
+++ b/dom/workers/test/mochitest.ini
@@ -40,16 +40,17 @@ support-files =
   terminate_worker.js
   testXHR.txt
   threadErrors_worker1.js
   threadErrors_worker2.js
   threadErrors_worker3.js
   threadErrors_worker4.js
   threadTimeouts_worker.js
   throwingOnerror_worker.js
+  timeoutTracing_worker.js
   transferable_worker.js
   urlApi_worker.js
   url_worker.js
   workersDisabled_worker.js
   xhr2_worker.js
   xhrAbort_worker.js
   xhr_implicit_cancel_worker.js
   xhr_worker.js
@@ -91,16 +92,17 @@ support-files =
 [test_rvals.html]
 [test_sharedWorker.html]
 [test_simpleThread.html]
 [test_suspend.html]
 [test_terminate.html]
 [test_threadErrors.html]
 [test_threadTimeouts.html]
 [test_throwingOnerror.html]
+[test_timeoutTracing.html]
 [test_transferable.html]
 [test_url.html]
 [test_urlApi.html]
 [test_workersDisabled.html]
 [test_xhr.html]
 [test_xhr2.html]
 [test_xhrAbort.html]
 [test_xhr_implicit_cancel.html]
new file mode 100644
--- /dev/null
+++ b/dom/workers/test/test_timeoutTracing.html
@@ -0,0 +1,47 @@
+<!--
+  Any copyright is dedicated to the Public Domain.
+  http://creativecommons.org/publicdomain/zero/1.0/
+-->
+<!DOCTYPE HTML>
+<html>
+<!--
+Tests of DOM Worker Threads
+-->
+<head>
+  <title>Test for DOM Worker Threads</title>
+  <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
+</head>
+<body>
+<pre id="test">
+<script class="testbody" type="text/javascript">
+
+  var worker = new Worker("timeoutTracing_worker.js");
+
+  worker.onmessage = function(event) {
+    // begin
+    worker.onmessage = null;
+
+    // 1 second should be enough to crash.
+    window.setTimeout(function(event) {
+      ok(true, "Didn't crash!");
+      SimpleTest.finish();
+    }, 1000);
+
+    var os = SpecialPowers.Cc["@mozilla.org/observer-service;1"]
+                          .getService(SpecialPowers.Ci.nsIObserverService);
+    os.notifyObservers(null, "memory-pressure", "heap-minimize");
+  }
+
+  worker.onerror = function(event) {
+    ok(false, "I was expecting a crash, not an error");
+    SimpleTest.finish();
+  };
+
+  SimpleTest.waitForExplicitFinish();
+
+</script>
+</pre>
+</body>
+</html>
+
new file mode 100644
--- /dev/null
+++ b/dom/workers/test/timeoutTracing_worker.js
@@ -0,0 +1,13 @@
+/**
+ * Any copyright is dedicated to the Public Domain.
+ * http://creativecommons.org/publicdomain/zero/1.0/
+ */
+
+onmessage = function(event) {
+  throw "No messages should reach me!";
+}
+
+setInterval(function() { postMessage("Still alive!"); }, 20);
+setInterval(";", 20);
+
+postMessage("Begin!");
--- a/editor/composer/public/moz.build
+++ b/editor/composer/public/moz.build
@@ -3,10 +3,10 @@
 # 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/.
 
 XPIDL_SOURCES += [
     'nsIEditingSession.idl',
 ]
 
-MODULE = 'composer'
+XPIDL_MODULE = 'composer'
 
--- a/editor/composer/src/moz.build
+++ b/editor/composer/src/moz.build
@@ -1,27 +1,20 @@
 # -*- 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/.
 
-MODULE = 'editor'
-
 UNIFIED_SOURCES += [
     'nsComposerCommands.cpp',
     'nsComposerCommandsUpdater.cpp',
     'nsComposerController.cpp',
     'nsComposerDocumentCommands.cpp',
     'nsComposerRegistration.cpp',
     'nsComposeTxtSrvFilter.cpp',
     'nsEditingSession.cpp',
     'nsEditorSpellCheck.cpp',
 ]
 
-LIBRARY_NAME = 'composer'
-
 FAIL_ON_WARNINGS = True
 
-LIBXUL_LIBRARY = True
-
-EXPORT_LIBRARY = True
-
+FINAL_LIBRARY = 'xul'
--- a/editor/idl/moz.build
+++ b/editor/idl/moz.build
@@ -20,10 +20,10 @@ XPIDL_SOURCES += [
     'nsIHTMLObjectResizeListener.idl',
     'nsIHTMLObjectResizer.idl',
     'nsIPlaintextEditor.idl',
     'nsITableEditor.idl',
     'nsIURIRefObject.idl',
     'nsPIEditorTransaction.idl',
 ]
 
-MODULE = 'editor'
+XPIDL_MODULE = 'editor'
 
--- a/editor/libeditor/base/moz.build
+++ b/editor/libeditor/base/moz.build
@@ -1,18 +1,16 @@
 # -*- 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/.
 
 TEST_DIRS += ['tests']
 
-MODULE = 'editor'
-
 UNIFIED_SOURCES += [
     'ChangeAttributeTxn.cpp',
     'ChangeCSSInlineStyleTxn.cpp',
     'CreateElementTxn.cpp',
     'DeleteNodeTxn.cpp',
     'DeleteRangeTxn.cpp',
     'DeleteTextTxn.cpp',
     'EditAggregateTxn.cpp',
@@ -28,22 +26,20 @@ UNIFIED_SOURCES += [
     'nsEditorUtils.cpp',
     'nsSelectionState.cpp',
     'nsStyleSheetTxns.cpp',
     'PlaceholderTxn.cpp',
     'SetDocTitleTxn.cpp',
     'SplitElementTxn.cpp',
 ]
 
-LIBRARY_NAME = 'editorbase_s'
-
 FAIL_ON_WARNINGS = True
 
-LIBXUL_LIBRARY = True
-
 LOCAL_INCLUDES += [
     '../text',
     '/content/base/src',
     '/content/events/src',
     '/editor/txmgr/src',
     '/extensions/spellcheck/src',
     '/layout/style',
 ]
+
+FINAL_LIBRARY = 'gklayout'
--- a/editor/libeditor/html/moz.build
+++ b/editor/libeditor/html/moz.build
@@ -1,18 +1,16 @@
 # -*- 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/.
 
 TEST_DIRS += ['tests']
 
-MODULE = 'editor'
-
 UNIFIED_SOURCES += [
     'nsEditProperty.cpp',
     'nsHTMLAbsPosition.cpp',
     'nsHTMLAnonymousUtils.cpp',
     'nsHTMLCSSUtils.cpp',
     'nsHTMLDataTransfer.cpp',
     'nsHTMLEditor.cpp',
     'nsHTMLEditorEventListener.cpp',
@@ -23,24 +21,22 @@ UNIFIED_SOURCES += [
     'nsHTMLObjectResizer.cpp',
     'nsHTMLURIRefObject.cpp',
     'nsTableEditor.cpp',
     'nsWSRunObject.cpp',
     'TextEditorTest.cpp',
     'TypeInState.cpp',
 ]
 
-LIBRARY_NAME = 'htmleditor_s'
-
 FAIL_ON_WARNINGS = True
 
-LIBXUL_LIBRARY = True
-
 LOCAL_INCLUDES += [
     '../base',
     '../text',
     '/content/base/src',
     '/editor/txmgr/src',
     '/layout/generic',
     '/layout/style',
     '/layout/tables',
     '/layout/xul/base/src',
 ]
+
+FINAL_LIBRARY = 'gklayout'
--- a/editor/libeditor/text/moz.build
+++ b/editor/libeditor/text/moz.build
@@ -1,30 +1,26 @@
 # -*- 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/.
 
 TEST_DIRS += ['tests']
 
-MODULE = 'editor'
-
 UNIFIED_SOURCES += [
     'nsInternetCiter.cpp',
     'nsPlaintextDataTransfer.cpp',
     'nsPlaintextEditor.cpp',
     'nsTextEditRules.cpp',
     'nsTextEditRulesBidi.cpp',
     'nsTextEditUtils.cpp',
 ]
 
-LIBRARY_NAME = 'texteditor_s'
-
 FAIL_ON_WARNINGS = True
 
-LIBXUL_LIBRARY = True
-
 LOCAL_INCLUDES += [
     '../base',
     '/content/base/src',
     '/editor/txmgr/src',
 ]
+
+FINAL_LIBRARY = 'gklayout'
--- a/editor/moz.build
+++ b/editor/moz.build
@@ -8,16 +8,11 @@ PARALLEL_DIRS += [
     'public',
     'idl',
     'txtsvc',
     'libeditor',
     'txmgr',
     'composer',
 ]
 
-MODULE = 'editor'
-
 EXTRA_JS_MODULES += [
     'AsyncSpellCheckTestHelper.jsm',
 ]
-
-FAIL_ON_WARNINGS = True
-
--- a/editor/public/moz.build
+++ b/editor/public/moz.build
@@ -1,12 +1,10 @@
 # -*- 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/.
 
-MODULE = 'editor'
-
 EXPORTS += [
     'nsEditorCID.h',
 ]
 
--- a/editor/txmgr/idl/moz.build
+++ b/editor/txmgr/idl/moz.build
@@ -6,10 +6,10 @@
 
 XPIDL_SOURCES += [
     'nsITransaction.idl',
     'nsITransactionList.idl',
     'nsITransactionListener.idl',
     'nsITransactionManager.idl',
 ]
 
-MODULE = 'txmgr'
+XPIDL_MODULE = 'txmgr'
 
--- a/editor/txmgr/moz.build
+++ b/editor/txmgr/moz.build
@@ -2,10 +2,8 @@
 # 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/.
 
 PARALLEL_DIRS += ['public', 'src', 'idl']
 TEST_TOOL_DIRS += ['tests']
 
-MODULE = 'txmgr'
-
--- a/editor/txmgr/public/moz.build
+++ b/editor/txmgr/public/moz.build
@@ -1,12 +1,10 @@
 # -*- 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/.
 
-MODULE = 'txmgr'
-
 EXPORTS += [
     'nsTransactionManagerCID.h',
 ]
 
--- a/editor/txmgr/src/moz.build
+++ b/editor/txmgr/src/moz.build
@@ -1,24 +1,17 @@
 # -*- 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/.
 
-MODULE = 'txmgr'
-
 UNIFIED_SOURCES += [
     'nsTransactionItem.cpp',
     'nsTransactionList.cpp',
     'nsTransactionManager.cpp',
     'nsTransactionManagerFactory.cpp',
     'nsTransactionStack.cpp',
 ]
 
-LIBRARY_NAME = 'txmgr'
-
 FAIL_ON_WARNINGS = True
 
-LIBXUL_LIBRARY = True
-
-EXPORT_LIBRARY = True
-
+FINAL_LIBRARY = 'xul'
--- a/editor/txtsvc/moz.build
+++ b/editor/txtsvc/moz.build
@@ -1,10 +1,8 @@
 # -*- 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/.
 
 PARALLEL_DIRS += ['public', 'src']
 
-MODULE = 'txtsvc'
-
--- a/editor/txtsvc/public/moz.build
+++ b/editor/txtsvc/public/moz.build
@@ -4,17 +4,17 @@
 # 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/.
 
 XPIDL_SOURCES += [
     'nsIInlineSpellChecker.idl',
     'nsITextServicesFilter.idl',
 ]
 
-MODULE = 'txtsvc'
+XPIDL_MODULE = 'txtsvc'
 
 EXPORTS += [
     'nsISpellChecker.h',
     'nsITextService.h',
     'nsITextServicesDocument.h',
     'nsTextServicesCID.h',
 ]
 
--- a/editor/txtsvc/src/moz.build
+++ b/editor/txtsvc/src/moz.build
@@ -1,19 +1,14 @@
 # -*- 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/.
 
-MODULE = 'txtsvc'
-
 UNIFIED_SOURCES += [
     'nsFilteredContentIterator.cpp',
     'nsTextServicesDocument.cpp',
 ]
 
-LIBRARY_NAME = 'txtsvc_s'
-
 FAIL_ON_WARNINGS = True
 
-LIBXUL_LIBRARY = True
-
+FINAL_LIBRARY = 'gklayout'
--- a/embedding/base/moz.build
+++ b/embedding/base/moz.build
@@ -6,13 +6,13 @@
 
 XPIDL_SOURCES += [
     'nsIDialogCreator.idl',
     'nsIWindowCreator.idl',
     'nsIWindowCreator2.idl',
     'nsIWindowProvider.idl',
 ]
 
-MODULE = 'embed_base'
+XPIDL_MODULE = 'embed_base'
 
 EXPORTS += [
     'nsEmbedCID.h',
 ]
deleted file mode 100644
--- a/embedding/browser/build/Makefile.in
+++ /dev/null
@@ -1,8 +0,0 @@
-# 
-# This Source Code Form is subject to the terms of the Mozilla Public
-# License, v. 2.0. If a copy of the MPL was not distributed with this
-# file, You can obtain one at http://mozilla.org/MPL/2.0/.
-
-SHARED_LIBRARY_LIBS= \
-		../webBrowser/$(LIB_PREFIX)nsWebBrowser_s.$(LIB_SUFFIX) \
-		$(NULL)
--- a/embedding/browser/build/moz.build
+++ b/embedding/browser/build/moz.build
@@ -1,25 +1,20 @@
 # -*- 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/.
 
-MODULE = 'webbrwsr'
-
 SOURCES += [
     'nsWebBrowserModule.cpp',
 ]
 
 LIBRARY_NAME = 'webbrwsr'
 
 FAIL_ON_WARNINGS = True
 
-LIBXUL_LIBRARY = True
-
-EXPORT_LIBRARY = True
-
+FINAL_LIBRARY = 'xul'
 LOCAL_INCLUDES += [
     '../setup',
     '../webBrowser',
 ]
 
--- a/embedding/browser/webBrowser/moz.build
+++ b/embedding/browser/webBrowser/moz.build
@@ -26,34 +26,29 @@ if CONFIG['NS_PRINTING']:
     XPIDL_SOURCES += [
         'nsIPrintingPrompt.idl',
         'nsIPrintingPromptService.idl',
         'nsIWebBrowserPrint.idl',
     ]
 
 XPIDL_MODULE = 'webBrowser_core'
 
-MODULE = 'webbrwsr'
-
 EXPORTS += [
     'nsCTooltipTextProvider.h',
 ]
 
 SOURCES += [
     'nsCommandHandler.cpp',
     'nsContextMenuInfo.cpp',
     'nsDocShellTreeOwner.cpp',
     'nsEmbedStream.cpp',
     'nsWebBrowser.cpp',
     'nsWebBrowserContentPolicy.cpp',
 ]
 
-LIBRARY_NAME = 'nsWebBrowser_s'
-
 FAIL_ON_WARNINGS = True
 
-LIBXUL_LIBRARY = True
-
+FINAL_LIBRARY = 'webbrwsr'
 LOCAL_INCLUDES += [
     '../../../content/base/src',
     '../../../content/svg/content/src',
 ]
 
--- a/embedding/components/appstartup/src/moz.build
+++ b/embedding/components/appstartup/src/moz.build
@@ -1,22 +1,17 @@
 # -*- 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/.
 
-MODULE = 'embedcomponents'
-
 EXPORTS += [
     'nsIAppStartupNotifier.h',
 ]
 
 SOURCES += [
     'nsAppStartupNotifier.cpp',
 ]
 
-LIBRARY_NAME = 'appstartupnotifier_s'
-
 FAIL_ON_WARNINGS = True
 
-LIBXUL_LIBRARY = True
-
+FINAL_LIBRARY = 'embedcomponents'
deleted file mode 100644
--- a/embedding/components/build/Makefile.in
+++ /dev/null
@@ -1,20 +0,0 @@
-# This Source Code Form is subject to the terms of the Mozilla Public
-# License, v. 2.0. If a copy of the MPL was not distributed with this
-# file, You can obtain one at http://mozilla.org/MPL/2.0/.
-
-SHARED_LIBRARY_LIBS = \
-	../windowwatcher/src/$(LIB_PREFIX)windowwatcher_s.$(LIB_SUFFIX) \
-	../appstartup/src/$(LIB_PREFIX)appstartupnotifier_s.$(LIB_SUFFIX) \
-	../find/src/$(LIB_PREFIX)find_s.$(LIB_SUFFIX) \
-	../webbrowserpersist/src/$(LIB_PREFIX)webbrowserpersist_s.$(LIB_SUFFIX) \
-	../commandhandler/src/$(LIB_PREFIX)commandhandler_s.$(LIB_SUFFIX) \
-	$(NULL)
-
-ifdef MOZ_XUL
-ifdef NS_PRINTING
-SHARED_LIBRARY_LIBS += \
-	../printingui/src/$(LIB_PREFIX)printingui_s.$(LIB_SUFFIX) \
-	$(NULL)
-endif
-endif
-
--- a/embedding/components/build/moz.build
+++ b/embedding/components/build/moz.build
@@ -1,28 +1,23 @@
 # -*- 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/.
 
-MODULE = 'embedcomponents'
-
 SOURCES += [
     'nsEmbeddingModule.cpp',
 ]
 
 LIBRARY_NAME = 'embedcomponents'
 
 FAIL_ON_WARNINGS = True
 
-LIBXUL_LIBRARY = True
-
-EXPORT_LIBRARY = True
-
+FINAL_LIBRARY = 'xul'
 LOCAL_INCLUDES += [
     '../appstartup/src',
     '../commandhandler/src',
     '../find/src',
     '../webbrowserpersist/src',
     '../windowwatcher/src',
 ]
 
--- a/embedding/components/commandhandler/moz.build
+++ b/embedding/components/commandhandler/moz.build
@@ -1,10 +1,8 @@
 # -*- 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 += ['public', 'src']
 
-MODULE = 'commandhandler'
-
--- a/embedding/components/commandhandler/public/moz.build
+++ b/embedding/components/commandhandler/public/moz.build
@@ -8,10 +8,10 @@ XPIDL_SOURCES += [
     'nsICommandManager.idl',
     'nsICommandParams.idl',
     'nsIControllerCommand.idl',
     'nsIControllerCommandTable.idl',
     'nsIControllerContext.idl',
     'nsPICommandUpdater.idl',
 ]
 
-MODULE = 'commandhandler'
+XPIDL_MODULE = 'commandhandler'
 
--- a/embedding/components/commandhandler/src/moz.build
+++ b/embedding/components/commandhandler/src/moz.build
@@ -1,22 +1,17 @@
 # -*- 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/.
 
-MODULE = 'commandhandler'
-
 SOURCES += [
     'nsBaseCommandController.cpp',
     'nsCommandGroup.cpp',
     'nsCommandManager.cpp',
     'nsCommandParams.cpp',
     'nsControllerCommandTable.cpp',
 ]
 
-LIBRARY_NAME = 'commandhandler_s'
-
 FAIL_ON_WARNINGS = True
 
-LIBXUL_LIBRARY = True
-
+FINAL_LIBRARY = 'embedcomponents'
--- a/embedding/components/commandhandler/src/nsCommandParams.cpp
+++ b/embedding/components/commandhandler/src/nsCommandParams.cpp
@@ -8,17 +8,17 @@
 #include "nscore.h"
 #include "nsCRT.h"
 
 #include "nsCommandParams.h"
 #include "mozilla/HashFunctions.h"
 
 using namespace mozilla;
 
-PLDHashTableOps nsCommandParams::sHashOps =
+const PLDHashTableOps nsCommandParams::sHashOps =
 {
     PL_DHashAllocTable,
     PL_DHashFreeTable,
     HashKey,
     HashMatchEntry,
     HashMoveEntry,
     HashClearEntry,
     PL_DHashFinalizeStub
--- a/embedding/components/commandhandler/src/nsCommandParams.h
+++ b/embedding/components/commandhandler/src/nsCommandParams.h
@@ -142,13 +142,13 @@ protected:
   // internally.
   
   PLDHashTable    mValuesHash;
   
   // enumerator data
   int32_t         mCurEntry;
   int32_t         mNumEntries;      // number of entries at start of enumeration (-1 indicates not known)
     
-  static PLDHashTableOps    sHashOps;
+  static const PLDHashTableOps    sHashOps;
 };
 
 
 #endif // nsCommandParams_h__
--- a/embedding/components/find/moz.build
+++ b/embedding/components/find/moz.build
@@ -1,10 +1,8 @@
 # -*- 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 += ['public', 'src']
 
-MODULE = 'find'
-
--- a/embedding/components/find/public/moz.build
+++ b/embedding/components/find/public/moz.build
@@ -4,10 +4,10 @@
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
 XPIDL_SOURCES += [
     'nsIFind.idl',
     'nsIWebBrowserFind.idl',
 ]
 
-MODULE = 'find'
+XPIDL_MODULE = 'find'
 
--- a/embedding/components/find/src/moz.build
+++ b/embedding/components/find/src/moz.build
@@ -1,19 +1,14 @@
 # -*- 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/.
 
-MODULE = 'find'
-
 SOURCES += [
     'nsFind.cpp',
     'nsWebBrowserFind.cpp',
 ]
 
-LIBRARY_NAME = 'find_s'
-
 FAIL_ON_WARNINGS = True
 
-LIBXUL_LIBRARY = True
-
+FINAL_LIBRARY = 'embedcomponents'
deleted file mode 100644
--- a/embedding/components/printingui/src/mac/Makefile.in
+++ /dev/null
@@ -1,6 +0,0 @@
-# 
-# This Source Code Form is subject to the terms of the Mozilla Public
-# License, v. 2.0. If a copy of the MPL was not distributed with this
-# file, You can obtain one at http://mozilla.org/MPL/2.0/.
-
-EXPORT_LIBRARY	= ..
--- a/embedding/components/printingui/src/mac/moz.build
+++ b/embedding/components/printingui/src/mac/moz.build
@@ -1,23 +1,18 @@
 # -*- 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/.
 
-MODULE = 'embedcomponents'
-
 SOURCES += [
     'nsPrintProgress.cpp',
     'nsPrintProgressParams.cpp',
 ]
 
-LIBRARY_NAME = 'printingui_s'
-
 SOURCES += [
     'nsPrintingPromptServiceX.mm',
 ]
 
 FAIL_ON_WARNINGS = True
 
-LIBXUL_LIBRARY = True
-
+FINAL_LIBRARY = 'embedcomponents'
deleted file mode 100644
--- a/embedding/components/printingui/src/os2/Makefile.in
+++ /dev/null
@@ -1,6 +0,0 @@
-# 
-# This Source Code Form is subject to the terms of the Mozilla Public
-# License, v. 2.0. If a copy of the MPL was not distributed with this
-# file, You can obtain one at http://mozilla.org/MPL/2.0/.
-
-EXPORT_LIBRARY	= ..
--- a/embedding/components/printingui/src/os2/moz.build
+++ b/embedding/components/printingui/src/os2/moz.build
@@ -1,18 +1,13 @@
 # -*- 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/.
 
-MODULE = 'embedcomponents'
-
 SOURCES += [
     'nsPrintingPromptService.cpp',
     'nsPrintProgress.cpp',
     'nsPrintProgressParams.cpp',
 ]
 
-LIBRARY_NAME = 'printingui_s'
-
-LIBXUL_LIBRARY = True
-
+FINAL_LIBRARY = 'embedcomponents'
deleted file mode 100644
--- a/embedding/components/printingui/src/unixshared/Makefile.in
+++ /dev/null
@@ -1,6 +0,0 @@
-# 
-# This Source Code Form is subject to the terms of the Mozilla Public
-# License, v. 2.0. If a copy of the MPL was not distributed with this
-# file, You can obtain one at http://mozilla.org/MPL/2.0/.
-
-EXPORT_LIBRARY	= ..
--- a/embedding/components/printingui/src/unixshared/moz.build
+++ b/embedding/components/printingui/src/unixshared/moz.build
@@ -1,20 +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/.
 
-MODULE = 'embedcomponents'
-
 SOURCES += [
     'nsPrintingPromptService.cpp',
     'nsPrintProgress.cpp',
     'nsPrintProgressParams.cpp',
 ]
 
-LIBRARY_NAME = 'printingui_s'
-
 FAIL_ON_WARNINGS = True
 
-LIBXUL_LIBRARY = True
-
+FINAL_LIBRARY = 'embedcomponents'
deleted file mode 100644
--- a/embedding/components/printingui/src/win/Makefile.in
+++ /dev/null
@@ -1,6 +0,0 @@
-# 
-# This Source Code Form is subject to the terms of the Mozilla Public
-# License, v. 2.0. If a copy of the MPL was not distributed with this
-# file, You can obtain one at http://mozilla.org/MPL/2.0/.
-
-EXPORT_LIBRARY	= ..
--- a/embedding/components/printingui/src/win/moz.build
+++ b/embedding/components/printingui/src/win/moz.build
@@ -1,21 +1,16 @@
 # -*- 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/.
 
-MODULE = 'embedcomponents'
-
 SOURCES += [
     'nsPrintDialogUtil.cpp',
     'nsPrintingPromptService.cpp',
     'nsPrintProgress.cpp',
     'nsPrintProgressParams.cpp',
 ]
 
-LIBRARY_NAME = 'printingui_s'
-
 FAIL_ON_WARNINGS = True
 
-LIBXUL_LIBRARY = True
-
+FINAL_LIBRARY = 'embedcomponents'
--- a/embedding/components/webbrowserpersist/moz.build
+++ b/embedding/components/webbrowserpersist/moz.build
@@ -1,10 +1,8 @@
 # -*- 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 += ['public', 'src']
 
-MODULE = 'webbrowserpersist'
-
--- a/embedding/components/webbrowserpersist/public/moz.build
+++ b/embedding/components/webbrowserpersist/public/moz.build
@@ -4,10 +4,10 @@
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
 XPIDL_SOURCES += [
     'nsCWebBrowserPersist.idl',
     'nsIWebBrowserPersist.idl',
 ]
 
-MODULE = 'webbrowserpersist'
+XPIDL_MODULE = 'webbrowserpersist'
 
--- a/embedding/components/webbrowserpersist/src/moz.build
+++ b/embedding/components/webbrowserpersist/src/moz.build
@@ -1,23 +1,18 @@
 # -*- 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/.
 
-MODULE = 'webbrowserpersist'
-
 SOURCES += [
     'nsWebBrowserPersist.cpp',
 ]
 
-LIBRARY_NAME = 'webbrowserpersist_s'
-
 FAIL_ON_WARNINGS = True
 
-LIBXUL_LIBRARY = True
-
+FINAL_LIBRARY = 'embedcomponents'
 LOCAL_INCLUDES += [
     '/content/base/src',
     '/content/html/content/src',
 ]
 
--- a/embedding/components/windowwatcher/public/moz.build
+++ b/embedding/components/windowwatcher/public/moz.build
@@ -9,14 +9,14 @@ XPIDL_SOURCES += [
     'nsIPromptFactory.idl',
     'nsIPromptService.idl',
     'nsIPromptService2.idl',
     'nsIWindowWatcher.idl',
     'nsPIPromptService.idl',
     'nsPIWindowWatcher.idl',
 ]
 
-MODULE = 'windowwatcher'
+XPIDL_MODULE = 'windowwatcher'
 
 EXPORTS += [
     'nsPromptUtils.h',
 ]
 
--- a/embedding/components/windowwatcher/src/moz.build
+++ b/embedding/components/windowwatcher/src/moz.build
@@ -1,29 +1,24 @@
 # -*- 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/.
 
-MODULE = 'embedcomponents'
-
 SOURCES += [
     'nsAutoWindowStateHelper.cpp',
     'nsWindowWatcher.cpp',
 ]
 
 if CONFIG['MOZ_XUL']:
     SOURCES += [
         'nsDialogParamBlock.cpp',
     ]
 
-LIBRARY_NAME = 'windowwatcher_s'
-
 FAIL_ON_WARNINGS = True
 
-LIBXUL_LIBRARY = True
-
+FINAL_LIBRARY = 'embedcomponents'
 # For nsJSUtils
 LOCAL_INCLUDES += [
     '/dom/base',
 ]
 
--- a/embedding/moz.build
+++ b/embedding/moz.build
@@ -2,12 +2,10 @@
 # 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 += ['base', 'components', 'browser']
 TEST_DIRS += ['test']
 
-MODULE = 'embed'
-
 if CONFIG['ENABLE_TESTS']:
     XPCSHELL_TESTS_MANIFESTS += ['tests/unit/xpcshell.ini']
--- a/embedding/tests/winEmbed/moz.build
+++ b/embedding/tests/winEmbed/moz.build
@@ -1,16 +1,14 @@
 # -*- 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/.
 
-MODULE = 'winEmbed'
-
 PROGRAM = 'winEmbed'
 
 SOURCES += [
     'WebBrowserChrome.cpp',
     'WindowCreator.cpp',
     'winEmbed.cpp',
 ]
 
--- a/extensions/auth/moz.build
+++ b/extensions/auth/moz.build
@@ -1,16 +1,14 @@
 # -*- 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/.
 
-MODULE = 'auth'
-
 SOURCES += [
     'nsAuthFactory.cpp',
     'nsAuthGSSAPI.cpp',
     'nsAuthSASL.cpp',
     'nsHttpNegotiateAuth.cpp',
 ]
 
 if CONFIG['OS_ARCH'] == 'WINNT':
@@ -18,14 +16,9 @@ if CONFIG['OS_ARCH'] == 'WINNT':
         'nsAuthSSPI.cpp',
     ]
     DEFINES['USE_SSPI'] = True
 else:
     SOURCES += [
         'nsAuthSambaNTLM.cpp',
     ]
 
-LIBRARY_NAME = 'auth'
-
-LIBXUL_LIBRARY = True
-
-EXPORT_LIBRARY = True
-
+FINAL_LIBRARY = 'xul'
--- a/extensions/auth/nsAuthGSSAPI.cpp
+++ b/extensions/auth/nsAuthGSSAPI.cpp
@@ -35,16 +35,19 @@ typedef KLStatus (*KLCacheHasValidTicket
     KLPrincipal,
     KLKerberosVersion,
     KLBoolean *,
     KLPrincipal *,
     char **);
 #endif
 
 #if defined(HAVE_RES_NINIT)
+#include <sys/types.h>
+#include <netinet/in.h>
+#include <arpa/nameser.h>
 #include <resolv.h>
 #endif
 
 using namespace mozilla;
 
 //-----------------------------------------------------------------------------
 
 // We define GSS_C_NT_HOSTBASED_SERVICE explicitly since it may be referenced
--- a/extensions/cookie/moz.build
+++ b/extensions/cookie/moz.build
@@ -6,29 +6,24 @@
 
 TEST_TOOL_DIRS += ['test']
 
 XPIDL_SOURCES += [
     'nsICookieAcceptDialog.idl',
     'nsICookiePromptService.idl',
 ]
 
-MODULE = 'cookie'
+XPIDL_MODULE = 'cookie'
 
 SOURCES += [
     'nsCookieModule.cpp',
     'nsCookiePermission.cpp',
     'nsCookiePromptService.cpp',
     'nsPermission.cpp',
     'nsPermissionManager.cpp',
     'nsPopupWindowManager.cpp',
 ]
 
-LIBXUL_LIBRARY = True
-
 MSVC_ENABLE_PGO = True
 
-LIBRARY_NAME = 'cookie'
-
-EXPORT_LIBRARY = True
-
 include('/ipc/chromium/chromium-config.mozbuild')
 
+FINAL_LIBRARY = 'xul'
--- a/extensions/cookie/nsPermissionManager.cpp
+++ b/extensions/cookie/nsPermissionManager.cpp
@@ -127,16 +127,30 @@ GetHostForPrincipal(nsIPrincipal* aPrinc
   uri = NS_GetInnermostURI(uri);
   NS_ENSURE_TRUE(uri, NS_ERROR_FAILURE);
 
   rv = uri->GetAsciiHost(aHost);
   if (NS_SUCCEEDED(rv) && !aHost.IsEmpty()) {
     return NS_OK;
   }
 
+  // For the mailto scheme, we use the path of the URI. We have to chop off the
+  // query part if one exists, so we eliminate everything after a ?.
+  bool isMailTo = false;
+  if (NS_SUCCEEDED(uri->SchemeIs("mailto", &isMailTo)) && isMailTo) {
+    rv = uri->GetPath(aHost);
+    NS_ENSURE_SUCCESS(rv, rv);
+
+    int32_t spart = aHost.FindChar('?', 0);
+    if (spart >= 0) {
+      aHost.Cut(spart, aHost.Length() - spart);
+    }
+    return NS_OK;
+  }
+
   // Some entries like "file://" uses the origin.
   rv = aPrincipal->GetOrigin(getter_Copies(aHost));
   if (NS_SUCCEEDED(rv) && !aHost.IsEmpty()) {
     return NS_OK;
   }
 
   return NS_ERROR_UNEXPECTED;
 }
--- a/extensions/cookie/test/moz.build
+++ b/extensions/cookie/test/moz.build
@@ -1,16 +1,14 @@
 # -*- 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/.
 
-MODULE = 'test_cookies'
-
 XPCSHELL_TESTS_MANIFESTS += ['unit/xpcshell.ini']
 
 # FIXME/bug 575918: out-of-process xpcshell is broken on OS X
 if CONFIG['OS_ARCH'] != 'Darwin':
     XPCSHELL_TESTS_MANIFESTS += ['unit_ipc/xpcshell.ini']
 
 MOCHITEST_MANIFESTS += ['mochitest.ini']
 
new file mode 100644
--- /dev/null
+++ b/extensions/cookie/test/unit/test_permmanager_mailto.js
@@ -0,0 +1,38 @@
+/* Any copyright is dedicated to the Public Domain.
+   http://creativecommons.org/publicdomain/zero/1.0/ */
+
+function run_test() {
+  // initialize the permission manager service
+  const kTestAddr = "test@example.org";
+  const kType = "test-mailto";
+  const kCapability = 1;
+
+  // make a mailto: URI with parameters
+  let uri = Services.io.newURI("mailto:" + kTestAddr + "?subject=test", null,
+                               null);
+
+  // add a permission entry for that URI
+  Services.permissions.add(uri, kType, kCapability);
+  do_check_true(permission_exists(kTestAddr, kType, kCapability));
+
+  Services.permissions.removeAll();
+
+  uri = Services.io.newURI("mailto:" + kTestAddr, null, null);
+  Services.permissions.add(uri, kType, kCapability);
+  do_check_true(permission_exists(kTestAddr, kType, kCapability));
+
+  Services.permissions.removeAll();
+}
+
+function permission_exists(aHost, aType, aCapability) {
+  let e = Services.permissions.enumerator;
+  while (e.hasMoreElements()) {
+    let perm = e.getNext().QueryInterface(Ci.nsIPermission);
+    if (perm.host == aHost &&
+        perm.type == aType &&
+        perm.capability == aCapability) {
+      return true;
+    }
+  }
+  return false;
+}
--- a/extensions/cookie/test/unit/xpcshell.ini
+++ b/extensions/cookie/test/unit/xpcshell.ini
@@ -22,11 +22,12 @@ support-files =
 [test_permmanager_getPermissionObject.js]
 [test_permmanager_notifications.js]
 [test_permmanager_removeall.js]
 [test_permmanager_load_invalid_entries.js]
 skip-if = debug == true
 [test_permmanager_idn.js]
 [test_permmanager_subdomains.js]
 [test_permmanager_local_files.js]
+[test_permmanager_mailto.js]
 [test_permmanager_cleardata.js]
 [test_schema_2_migration.js]
 [test_schema_3_migration.js]
--- a/extensions/gio/moz.build
+++ b/extensions/gio/moz.build
@@ -1,20 +1,13 @@
 # -*- 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/.
 
-MODULE = 'nkgio'
-
 SOURCES += [
     'nsGIOProtocolHandler.cpp',
 ]
 
-LIBRARY_NAME = 'nkgio'
-
 FAIL_ON_WARNINGS = True
 
-LIBXUL_LIBRARY = True
-
-EXPORT_LIBRARY = True
-
+FINAL_LIBRARY = 'xul'
--- a/extensions/gnomevfs/Makefile.in
+++ b/extensions/gnomevfs/Makefile.in
@@ -1,19 +1,12 @@
 # vim:set ts=8 sw=8 sts=8 noet:
 # 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/.
 
-SHORT_LIBNAME	= nkgnomevfs
-
 LOCAL_INCLUDES	= $(MOZ_GNOMEVFS_CFLAGS)
 
 EXTRA_DSO_LDOPTS = \
 		   $(XPCOM_GLUE_LDOPTS) \
 		   $(NSPR_LIBS) \
 		   $(MOZ_GNOMEVFS_LIBS) \
 		   $(NULL)
-
-# make sure this component is never statically linked into the main
-# application.  this is necessary since we don't want to force users
-# to install gnome-vfs2 in order to use the rest of mozilla ;-)
-FORCE_SHARED_LIB= 1
--- a/extensions/gnomevfs/moz.build
+++ b/extensions/gnomevfs/moz.build
@@ -1,16 +1,18 @@
 # -*- 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/.
 
-MODULE = 'nkgnomevfs'
-
 SOURCES += [
     'nsGnomeVFSProtocolHandler.cpp',
 ]
 
 LIBRARY_NAME = 'nkgnomevfs'
 
 IS_COMPONENT = True
 
+# make sure this component is never statically linked into the main
+# application.  this is necessary since we don't want to force users
+# to install gnome-vfs2 in order to use the rest of mozilla ;-)
+FORCE_SHARED_LIB = True
--- a/extensions/permissions/moz.build
+++ b/extensions/permissions/moz.build
@@ -1,19 +1,12 @@
 # -*- 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/.
 
-MODULE = 'permissions'
-
 SOURCES += [
     'nsContentBlocker.cpp',
     'nsModuleFactory.cpp',
 ]
 
-LIBRARY_NAME = 'permissions'
-
-LIBXUL_LIBRARY = True
-
-EXPORT_LIBRARY = True
-
+FINAL_LIBRARY = 'xul'
--- a/extensions/pref/autoconfig/moz.build
+++ b/extensions/pref/autoconfig/moz.build
@@ -1,10 +1,8 @@
 # -*- 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 += ['public', 'src']
 
-MODULE = 'autoconfig'
-
--- a/extensions/pref/autoconfig/public/moz.build
+++ b/extensions/pref/autoconfig/public/moz.build
@@ -4,10 +4,10 @@
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
 XPIDL_SOURCES += [
     'nsIAutoConfig.idl',
     'nsIReadConfig.idl',
 ]
 
-MODULE = 'autoconfig'
+XPIDL_MODULE = 'autoconfig'
 
--- a/extensions/pref/autoconfig/src/moz.build
+++ b/extensions/pref/autoconfig/src/moz.build
@@ -1,21 +1,14 @@
 # -*- 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/.
 
-MODULE = 'autoconfig'
-
 SOURCES += [
     'nsAutoConfig.cpp',
     'nsConfigFactory.cpp',
     'nsJSConfigTriggers.cpp',
     'nsReadConfig.cpp',
 ]
 
-LIBXUL_LIBRARY = True
-
-LIBRARY_NAME = 'autoconfig'
-
-EXPORT_LIBRARY = True
-
+FINAL_LIBRARY = 'xul'
--- a/extensions/spellcheck/hunspell/moz.build
+++ b/extensions/spellcheck/hunspell/moz.build
@@ -1,12 +1,10 @@
 # -*- 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 += ['src']
 
-MODULE = 'hunspell'
-
 if CONFIG['ENABLE_TESTS']:
     XPCSHELL_TESTS_MANIFESTS += ['tests/unit/xpcshell.ini']
--- a/extensions/spellcheck/hunspell/src/moz.build
+++ b/extensions/spellcheck/hunspell/src/moz.build
@@ -1,17 +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/.
 
-MODULE = 'hunspell'
-
-SOURCES += [
+UNIFIED_SOURCES += [
     'mozHunspell.cpp',
     'mozHunspellDirProvider.cpp',
 ]
 
 if not CONFIG['MOZ_NATIVE_HUNSPELL']:
     SOURCES += [
         'affentry.cpp',
         'affixmgr.cpp',
@@ -21,12 +19,9 @@ if not CONFIG['MOZ_NATIVE_HUNSPELL']:
         'hashmgr.cpp',
         'hunspell.cpp',
         'hunzip.cpp',
         'phonet.cpp',
         'replist.cpp',
         'suggestmgr.cpp',
     ]
 
-LIBRARY_NAME = 'hunspell_s'
-
-LIBXUL_LIBRARY = True
-
+FINAL_LIBRARY = 'spellchecker'
--- a/extensions/spellcheck/hunspell/src/mozHunspell.cpp
+++ b/extensions/spellcheck/hunspell/src/mozHunspell.cpp
@@ -73,17 +73,16 @@
 #include "nsCRT.h"
 #include "mozInlineSpellChecker.h"
 #include "mozilla/Services.h"
 #include <stdlib.h>
 #include "nsIMemoryReporter.h"
 #include "nsIPrefService.h"
 #include "nsIPrefBranch.h"
 
-static NS_DEFINE_CID(kCharsetConverterManagerCID, NS_ICHARSETCONVERTERMANAGER_CID);
 static NS_DEFINE_CID(kUnicharUtilCID, NS_UNICHARUTIL_CID);
 
 NS_IMPL_CYCLE_COLLECTING_ADDREF(mozHunspell)
 NS_IMPL_CYCLE_COLLECTING_RELEASE(mozHunspell)
 
 NS_INTERFACE_MAP_BEGIN(mozHunspell)
   NS_INTERFACE_MAP_ENTRY(mozISpellCheckingEngine)
   NS_INTERFACE_MAP_ENTRY(nsIObserver)
--- a/extensions/spellcheck/idl/moz.build
+++ b/extensions/spellcheck/idl/moz.build
@@ -6,10 +6,10 @@
 
 XPIDL_SOURCES += [
     'mozIPersonalDictionary.idl',
     'mozISpellCheckingEngine.idl',
     'mozISpellI18NManager.idl',
     'mozISpellI18NUtil.idl',
 ]
 
-MODULE = 'spellchecker'
+XPIDL_MODULE = 'spellchecker'
 
--- a/extensions/spellcheck/moz.build
+++ b/extensions/spellcheck/moz.build
@@ -2,10 +2,8 @@
 # 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 += ['idl', 'locales', 'hunspell', 'src']
 TEST_DIRS += ['tests/chrome']
 
-MODULE = 'spellchecker'
-
--- a/extensions/spellcheck/src/Makefile.in
+++ b/extensions/spellcheck/src/Makefile.in
@@ -1,13 +1,11 @@
 # 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/.
 
-SHARED_LIBRARY_LIBS += ../hunspell/src/$(LIB_PREFIX)hunspell_s.$(LIB_SUFFIX)
-
 include $(topsrcdir)/config/rules.mk
 
 LOCAL_INCLUDES += \
 	-I$(srcdir)/../hunspell/src \
 	-I$(topsrcdir)/content/base/src \
 	-I$(topsrcdir)/editor/libeditor/base \
 	$(NULL)
--- a/extensions/spellcheck/src/moz.build
+++ b/extensions/spellcheck/src/moz.build
@@ -1,25 +1,20 @@
 # -*- 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/.
 
-MODULE = 'spellchecker'
-
-SOURCES += [
+UNIFIED_SOURCES += [
     'mozEnglishWordUtils.cpp',
     'mozGenericWordUtils.cpp',
     'mozInlineSpellChecker.cpp',
     'mozInlineSpellWordUtil.cpp',
     'mozPersonalDictionary.cpp',
     'mozSpellChecker.cpp',
     'mozSpellCheckerFactory.cpp',
     'mozSpellI18NManager.cpp',
 ]
 
 LIBRARY_NAME = 'spellchecker'
 
-LIBXUL_LIBRARY = True
-
-EXPORT_LIBRARY = True
-
+FINAL_LIBRARY = 'xul'
--- a/extensions/spellcheck/src/mozInlineSpellWordUtil.h
+++ b/extensions/spellcheck/src/mozInlineSpellWordUtil.h
@@ -1,13 +1,16 @@
 /* -*- Mode: C++; tab-width: 8; 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 mozInlineSpellWordUtil_h
+#define mozInlineSpellWordUtil_h
+
 #include "nsCOMPtr.h"
 #include "nsIDOMDocument.h"
 #include "nsIDocument.h"
 #include "nsString.h"
 #include "nsTArray.h"
 
 //#define DEBUG_SPELLCHECK
 
@@ -154,8 +157,10 @@ private:
   void BuildRealWords();
 
   void SplitDOMWord(int32_t aStart, int32_t aEnd);
 
   // Convenience functions, object must be initialized
   nsresult MakeRange(NodeOffset aBegin, NodeOffset aEnd, nsRange** aRange);
   nsresult MakeRangeForWord(const RealWord& aWord, nsRange** aRange);
 };
+
+#endif
--- a/extensions/spellcheck/src/mozPersonalDictionary.cpp
+++ b/extensions/spellcheck/src/mozPersonalDictionary.cpp
@@ -148,17 +148,17 @@ NS_IMETHODIMP mozPersonalDictionary::Sav
   //FIXME Deinst  -- get dictionary name from prefs;
   res = NS_GetSpecialDirectory(NS_APP_USER_PROFILE_50_DIR, getter_AddRefs(theFile));
   if(NS_FAILED(res)) return res;
   if(!theFile)return NS_ERROR_FAILURE;
   res = theFile->Append(NS_LITERAL_STRING(MOZ_PERSONAL_DICT_NAME));
   if(NS_FAILED(res)) return res;
 
   nsCOMPtr<nsIOutputStream> outStream;
-  NS_NewLocalFileOutputStream(getter_AddRefs(outStream), theFile, PR_CREATE_FILE | PR_WRONLY | PR_TRUNCATE ,0664);
+  NS_NewSafeLocalFileOutputStream(getter_AddRefs(outStream), theFile, PR_CREATE_FILE | PR_WRONLY | PR_TRUNCATE ,0664);
 
   // get a buffered output stream 4096 bytes big, to optimize writes
   nsCOMPtr<nsIOutputStream> bufferedOutputStream;
   res = NS_NewBufferedOutputStream(getter_AddRefs(bufferedOutputStream), outStream, 4096);
   if (NS_FAILED(res)) return res;
 
   nsTArray<nsString> array(mDictionaryTable.Count());
   mDictionaryTable.EnumerateEntries(AddHostToStringArray, &array);
@@ -166,16 +166,24 @@ NS_IMETHODIMP mozPersonalDictionary::Sav
   uint32_t bytesWritten;
   nsAutoCString utf8Key;
   for (uint32_t i = 0; i < array.Length(); ++i ) {
     CopyUTF16toUTF8(array[i], utf8Key);
 
     bufferedOutputStream->Write(utf8Key.get(), utf8Key.Length(), &bytesWritten);
     bufferedOutputStream->Write("\n", 1, &bytesWritten);
   }
+  nsCOMPtr<nsISafeOutputStream> safeStream = do_QueryInterface(bufferedOutputStream);
+  NS_ASSERTION(safeStream, "expected a safe output stream!");
+  if (safeStream) {
+    res = safeStream->Finish();
+    if (NS_FAILED(res)) {
+      NS_WARNING("failed to save personal dictionary file! possible data loss");
+    }
+  }
   return res;
 }
 
 /* readonly attribute nsIStringEnumerator GetWordList() */
 NS_IMETHODIMP mozPersonalDictionary::GetWordList(nsIStringEnumerator **aWords)
 {
   NS_ENSURE_ARG_POINTER(aWords);
   *aWords = nullptr;
--- a/extensions/universalchardet/moz.build
+++ b/extensions/universalchardet/moz.build
@@ -2,10 +2,8 @@
 # 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 += ['src']
 TEST_DIRS += ['tests']
 
-MODULE = 'universalchardet'
-
--- a/extensions/universalchardet/src/base/moz.build
+++ b/extensions/universalchardet/src/base/moz.build
@@ -1,16 +1,14 @@
 # -*- 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/.
 
-MODULE = 'universalchardet_s'
-
 SOURCES += [
     'CharDistribution.cpp',
     'JpCntx.cpp',
     'LangBulgarianModel.cpp',
     'LangCyrillicModel.cpp',
     'LangGreekModel.cpp',
     'LangHebrewModel.cpp',
     'LangHungarianModel.cpp',
@@ -29,12 +27,9 @@ SOURCES += [
     'nsMBCSSM.cpp',
     'nsSBCharSetProber.cpp',
     'nsSBCSGroupProber.cpp',
     'nsSJISProber.cpp',
     'nsUniversalDetector.cpp',
     'nsUTF8Prober.cpp',
 ]
 
-LIBRARY_NAME = 'universalchardet_s'
-
-LIBXUL_LIBRARY = True
-
+FINAL_LIBRARY = 'universalchardet'
--- a/extensions/universalchardet/src/moz.build
+++ b/extensions/universalchardet/src/moz.build
@@ -1,10 +1,8 @@
 # -*- 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 += ['base', 'xpcom']
 
-MODULE = 'universalchardet'
-
--- a/extensions/universalchardet/src/xpcom/Makefile.in
+++ b/extensions/universalchardet/src/xpcom/Makefile.in
@@ -1,10 +1,6 @@
 #
 # 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/.
 
 LOCAL_INCLUDES = -I$(srcdir)/../base
-
-SHARED_LIBRARY_LIBS = \
-		../base/$(LIB_PREFIX)universalchardet_s.$(LIB_SUFFIX) \
-		$(NULL)
--- a/extensions/universalchardet/src/xpcom/moz.build
+++ b/extensions/universalchardet/src/xpcom/moz.build
@@ -1,19 +1,14 @@
 # -*- 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/.
 
-MODULE = 'universalchardet'
-
 SOURCES += [
     'nsUdetXPCOMWrapper.cpp',
     'nsUniversalCharDetModule.cpp',
 ]
 
 LIBRARY_NAME = 'universalchardet'
 
-LIBXUL_LIBRARY = True
-
-EXPORT_LIBRARY = True
-
+FINAL_LIBRARY = 'xul'
--- a/extensions/widgetutils/moz.build
+++ b/extensions/widgetutils/moz.build
@@ -1,11 +1,9 @@
 # -*- 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 += ['src']
 
-MODULE = 'widgetutils'
-
 XPI_NAME = 'widgetutils'
--- a/extensions/widgetutils/src/Makefile.in
+++ b/extensions/widgetutils/src/Makefile.in
@@ -1,13 +1,10 @@
 # vim:set ts=8 sw=8 sts=8 noet:
 # 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/.
 
-SHORT_LIBNAME = widgetutils
-FORCE_SHARED_LIB = 1
-
 EXTRA_DSO_LDOPTS = \
   $(XPCOM_GLUE_LDOPTS) \
   $(NSPR_LIBS) \
   $(MOZ_COMPONENT_LIBS) \
   $(NULL)
--- a/extensions/widgetutils/src/moz.build
+++ b/extensions/widgetutils/src/moz.build
@@ -1,20 +1,20 @@
 # -*- 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/.
 
-MODULE = 'widgetutils'
-
 SOURCES += [
     'nsWidgetUtils.cpp',
 ]
 
 LIBRARY_NAME = 'widgetutils'
 
 IS_COMPONENT = True
 
 XPI_NAME = 'widgetutils'
 
 if CONFIG['TARGET_XPCOM_ABI']:
     FINAL_TARGET += '/platform/%(OS_TARGET)s_%(TARGET_XPCOM_ABI)s' % CONFIG
+
+FORCE_SHARED_LIB = True
--- a/gfx/2d/DrawTargetCG.h
+++ b/gfx/2d/DrawTargetCG.h
@@ -1,13 +1,16 @@
 /* -*- Mode: C++; tab-width: 20; 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_gfx_DrawTargetCG_h
+#define mozilla_gfx_DrawTargetCG_h
+
 #include <ApplicationServices/ApplicationServices.h>
 
 #include "2D.h"
 #include "Rect.h"
 #include "PathCG.h"
 #include "SourceSurfaceCG.h"
 #include "GLDefs.h"
 #include "Tools.h"
@@ -171,8 +174,11 @@ private:
    */
   AlignedArray<uint8_t> mData;
 
   RefPtr<SourceSurfaceCGContext> mSnapshot;
 };
 
 }
 }
+
+#endif
+
--- a/gfx/2d/PathCG.h
+++ b/gfx/2d/PathCG.h
@@ -90,17 +90,16 @@ public:
   virtual FillRule GetFillRule() const { return mFillRule; }
 
   CGMutablePathRef GetPath() const { return mPath; }
 
 private:
   friend class DrawTargetCG;
 
   CGMutablePathRef mPath;
-  bool mEndedActive;
   Point mEndPoint;
   FillRule mFillRule;
 };
 
 }
 }
 
 #endif
--- a/gfx/2d/RecordedEvent.cpp
+++ b/gfx/2d/RecordedEvent.cpp
@@ -272,17 +272,17 @@ RecordedDrawingEvent::RecordedDrawingEve
 
 void
 RecordedDrawingEvent::RecordToStream(ostream &aStream) const
 {
   WriteElement(aStream, mDT);
 }
 
 ReferencePtr
-RecordedDrawingEvent::GetObject() const
+RecordedDrawingEvent::GetObjectRef() const
 {
   return mDT;
 }
 
 void
 RecordedDrawTargetCreation::PlayEvent(Translator *aTranslator) const
 {
   RefPtr<DrawTarget> newDT =
--- a/gfx/2d/RecordedEvent.h
+++ b/gfx/2d/RecordedEvent.h
@@ -173,17 +173,17 @@ public:
   void RecordPatternData(std::ostream &aStream, const PatternStorage &aPatternStorage) const;
   void ReadPatternData(std::istream &aStream, PatternStorage &aPatternStorage) const;
   void StorePattern(PatternStorage &aDestination, const Pattern &aSource) const;
   void RecordStrokeOptions(std::ostream &aStream, const StrokeOptions &aStrokeOptions) const;
   void ReadStrokeOptions(std::istream &aStream, StrokeOptions &aStrokeOptions);
 
   virtual std::string GetName() const = 0;
 
-  virtual ReferencePtr GetObject() const = 0;
+  virtual ReferencePtr GetObjectRef() const = 0;
 
   virtual ReferencePtr GetDestinedDT() { return nullptr; }
 
   void OutputSimplePatternInfo(const PatternStorage &aStorage, std::stringstream &aOutput) const;
 
   static RecordedEvent *LoadEventFromStream(std::istream &aStream, EventType aType);
 
   EventType GetType() { return (EventType)mType; }
@@ -206,34 +206,34 @@ protected:
   RecordedDrawingEvent(EventType aType, DrawTarget *aTarget)
     : RecordedEvent(aType), mDT(aTarget)
   {
   }
 
   RecordedDrawingEvent(EventType aType, std::istream &aStream);
   virtual void RecordToStream(std::ostream &aStream) const;
 
-  virtual ReferencePtr GetObject() const;
+  virtual ReferencePtr GetObjectRef() const;
 
   ReferencePtr mDT;
 };
 
 class RecordedDrawTargetCreation : public RecordedEvent {
 public:
   RecordedDrawTargetCreation(ReferencePtr aRefPtr, BackendType aType, const IntSize &aSize, SurfaceFormat aFormat)
     : RecordedEvent(DRAWTARGETCREATION), mRefPtr(aRefPtr), mBackendType(aType), mSize(aSize), mFormat(aFormat)
   {}
 
   virtual void PlayEvent(Translator *aTranslator) const;
 
   virtual void RecordToStream(std::ostream &aStream) const;
   virtual void OutputSimpleEventInfo(std::stringstream &aStringStream) const;
 
   virtual std::string GetName() const { return "DrawTarget Creation"; }
-  virtual ReferencePtr GetObject() const { return mRefPtr; }
+  virtual ReferencePtr GetObjectRef() const { return mRefPtr; }
 
   ReferencePtr mRefPtr;
   BackendType mBackendType;
   IntSize mSize;
   SurfaceFormat mFormat;
   
 private:
   friend class RecordedEvent;
@@ -248,17 +248,17 @@ public:
   {}
 
   virtual void PlayEvent(Translator *aTranslator) const;
 
   virtual void RecordToStream(std::ostream &aStream) const;
   virtual void OutputSimpleEventInfo(std::stringstream &aStringStream) const;
 
   virtual std::string GetName() const { return "DrawTarget Destruction"; }
-  virtual ReferencePtr GetObject() const { return mRefPtr; }
+  virtual ReferencePtr GetObjectRef() const { return mRefPtr; }
 
   ReferencePtr mRefPtr;
 
   BackendType mBackendType;
 private:
   friend class RecordedEvent;
 
   RecordedDrawTargetDestruction(std::istream &aStream);
@@ -641,17 +641,17 @@ public:
   ~RecordedPathCreation();
   
   virtual void PlayEvent(Translator *aTranslator) const;
 
   virtual void RecordToStream(std::ostream &aStream) const;
   virtual void OutputSimpleEventInfo(std::stringstream &aStringStream) const;
   
   virtual std::string GetName() const { return "Path Creation"; }
-  virtual ReferencePtr GetObject() const { return mRefPtr; }
+  virtual ReferencePtr GetObjectRef() const { return mRefPtr; }
 private:
   friend class RecordedEvent;
 
   ReferencePtr mRefPtr;
   FillRule mFillRule;
   std::vector<PathOp> mPathOps;
 
   RecordedPathCreation(std::istream &aStream);
@@ -665,17 +665,17 @@ public:
   }
   
   virtual void PlayEvent(Translator *aTranslator) const;
 
   virtual void RecordToStream(std::ostream &aStream) const;
   virtual void OutputSimpleEventInfo(std::stringstream &aStringStream) const;
   
   virtual std::string GetName() const { return "Path Destruction"; }
-  virtual ReferencePtr GetObject() const { return mRefPtr; }
+  virtual ReferencePtr GetObjectRef() const { return mRefPtr; }
 private:
   friend class RecordedEvent;
 
   ReferencePtr mRefPtr;
 
   RecordedPathDestruction(std::istream &aStream);
 };
 
@@ -691,17 +691,17 @@ public:
   ~RecordedSourceSurfaceCreation();
 
   virtual void PlayEvent(Translator *aTranslator) const;
 
   virtual void RecordToStream(std::ostream &aStream) const;
   virtual void OutputSimpleEventInfo(std::stringstream &aStringStream) const;
   
   virtual std::string GetName() const { return "SourceSurface Creation"; }
-  virtual ReferencePtr GetObject() const { return mRefPtr; }
+  virtual ReferencePtr GetObjectRef() const { return mRefPtr; }
 private:
   friend class RecordedEvent;
 
   ReferencePtr mRefPtr;
   uint8_t *mData;
   int32_t mStride;
   IntSize mSize;
   SurfaceFormat mFormat;
@@ -718,17 +718,17 @@ public:
   }
 
   virtual void PlayEvent(Translator *aTranslator) const;
 
   virtual void RecordToStream(std::ostream &aStream) const;
   virtual void OutputSimpleEventInfo(std::stringstream &aStringStream) const;
   
   virtual std::string GetName() const { return "SourceSurface Destruction"; }
-  virtual ReferencePtr GetObject() const { return mRefPtr; }
+  virtual ReferencePtr GetObjectRef() const { return mRefPtr; }
 private:
   friend class RecordedEvent;
 
   ReferencePtr mRefPtr;
 
   RecordedSourceSurfaceDestruction(std::istream &aStream);
 };
 
@@ -744,17 +744,17 @@ public:
   ~RecordedGradientStopsCreation();
 
   virtual void PlayEvent(Translator *aTranslator) const;
 
   virtual void RecordToStream(std::ostream &aStream) const;
   virtual void OutputSimpleEventInfo(std::stringstream &aStringStream) const;
   
   virtual std::string GetName() const { return "GradientStops Creation"; }
-  virtual ReferencePtr GetObject() const { return mRefPtr; }
+  virtual ReferencePtr GetObjectRef() const { return mRefPtr; }
 private:
   friend class RecordedEvent;
 
   ReferencePtr mRefPtr;
   GradientStop *mStops;
   uint32_t mNumStops;
   ExtendMode mExtendMode;
   bool mDataOwned;
@@ -770,17 +770,17 @@ public:
   }
 
   virtual void PlayEvent(Translator *aTranslator) const;
 
   virtual void RecordToStream(std::ostream &aStream) const;
   virtual void OutputSimpleEventInfo(std::stringstream &aStringStream) const;
   
   virtual std::string GetName() const { return "GradientStops Destruction"; }
-  virtual ReferencePtr GetObject() const { return mRefPtr; }
+  virtual ReferencePtr GetObjectRef() const { return mRefPtr; }
 private:
   friend class RecordedEvent;
 
   ReferencePtr mRefPtr;
 
   RecordedGradientStopsDestruction(std::istream &aStream);
 };
 
@@ -792,17 +792,17 @@ public:
   }
 
   virtual void PlayEvent(Translator *aTranslator) const;
 
   virtual void RecordToStream(std::ostream &aStream) const;
   virtual void OutputSimpleEventInfo(std::stringstream &aStringStream) const;
   
   virtual std::string GetName() const { return "Snapshot"; }
-  virtual ReferencePtr GetObject() const { return mRefPtr; }
+  virtual ReferencePtr GetObjectRef() const { return mRefPtr; }
 private:
   friend class RecordedEvent;
 
   ReferencePtr mRefPtr;
   ReferencePtr mDT;
 
   RecordedSnapshot(std::istream &aStream);
 };
@@ -823,17 +823,17 @@ public:
   ~RecordedScaledFontCreation();
 
   virtual void PlayEvent(Translator *aTranslator) const;
 
   virtual void RecordToStream(std::ostream &aStream) const;
   virtual void OutputSimpleEventInfo(std::stringstream &aStringStream) const;
   
   virtual std::string GetName() const { return "ScaledFont Creation"; }
-  virtual ReferencePtr GetObject() const { return mRefPtr; }
+  virtual ReferencePtr GetObjectRef() const { return mRefPtr; }
 
   void SetFontData(const uint8_t *aData, uint32_t aSize, uint32_t aIndex, Float aGlyphSize);
 
 private:
   friend class RecordedEvent;
 
   ReferencePtr mRefPtr;
   uint8_t *mData;
@@ -852,17 +852,17 @@ public:
   }
 
   virtual void PlayEvent(Translator *aTranslator) const;
 
   virtual void RecordToStream(std::ostream &aStream) const;
   virtual void OutputSimpleEventInfo(std::stringstream &aStringStream) const;
   
   virtual std::string GetName() const { return "ScaledFont Destruction"; }
-  virtual ReferencePtr GetObject() const { return mRefPtr; }
+  virtual ReferencePtr GetObjectRef() const { return mRefPtr; }
 private:
   friend class RecordedEvent;
 
   ReferencePtr mRefPtr;
 
   RecordedScaledFontDestruction(std::istream &aStream);
 };
 
--- a/gfx/2d/moz.build
+++ b/gfx/2d/moz.build
@@ -1,16 +1,14 @@
 # -*- 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/.
 
-MODULE = 'gfx2d'
-
 EXPORTS.mozilla += [
     'GenericRefCounted.h',
 ]
 
 EXPORTS.mozilla.gfx += [
     '2D.h',
     'BaseMargin.h',
     'BasePoint.h',
@@ -33,17 +31,17 @@ EXPORTS.mozilla.gfx += [
     'UserData.h',
 ]
 
 if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'cocoa':
     EXPORTS.mozilla.gfx += [
         'MacIOSurface.h',
         'QuartzSupport.h',
     ]
-    SOURCES += [
+    UNIFIED_SOURCES += [
         'DrawTargetCG.cpp',
         'PathCG.cpp',
         'ScaledFontMac.cpp',
         'SourceSurfaceCG.cpp',
     ]
 elif CONFIG['MOZ_WIDGET_TOOLKIT'] == 'windows':
     SOURCES += [
         'DrawTargetD2D.cpp',
@@ -59,34 +57,36 @@ elif CONFIG['MOZ_WIDGET_TOOLKIT'] == 'wi
             'SourceSurfaceD2D1.cpp'
         ]
     if CONFIG['MOZ_ENABLE_SKIA']:
         SOURCES += [
             'ScaledFontWin.cpp',
         ]
 
 if CONFIG['MOZ_ENABLE_SKIA']:
-    SOURCES += [
+    UNIFIED_SOURCES += [
         'convolver.cpp',
         'DrawTargetSkia.cpp',
-        'image_operations.cpp',
         'PathSkia.cpp',
         'SourceSurfaceSkia.cpp',
     ]
+    SOURCES += [
+        'image_operations.cpp', # Uses _USE_MATH_DEFINES
+    ]
 
 # Are we targeting x86 or x64?  If so, build SSE2 files.
 if CONFIG['INTEL_ARCHITECTURE']:
     # VC2005 doesn't support _mm_castsi128_ps, so SSE2 is turned off
     if CONFIG['_MSC_VER'] != '1400':
         SOURCES += [
             'BlurSSE2.cpp',
             'ImageScalingSSE2.cpp',
         ]
 
-SOURCES += [
+UNIFIED_SOURCES += [
     'Blur.cpp',
     'DrawEventRecorder.cpp',
     'DrawTargetCairo.cpp',
     'DrawTargetDual.cpp',
     'DrawTargetRecording.cpp',
     'Factory.cpp',
     'ImageScaling.cpp',
     'Matrix.cpp',
@@ -105,18 +105,13 @@ SOURCES += [
 if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'cocoa':
     SOURCES += [
         'MacIOSurface.cpp',
         'QuartzSupport.mm',
     ]
 
 FAIL_ON_WARNINGS = True
 
-LIBXUL_LIBRARY = True
-
 MSVC_ENABLE_PGO = True
 
-LIBRARY_NAME = 'gfx2d'
-
-EXPORT_LIBRARY = True
-
 include('/ipc/chromium/chromium-config.mozbuild')
 
+FINAL_LIBRARY = 'gkmedias'
--- a/gfx/angle/moz.build
+++ b/gfx/angle/moz.build
@@ -3,18 +3,16 @@
 # 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/.
 
 # libEGL depends on (links against!) libGLESv2!
 if CONFIG['MOZ_ANGLE_RENDERER']:
     DIRS += ['src/libGLESv2', 'src/libEGL']
 
-MODULE = 'angle'
-
 EXPORTS.angle += [
     'include/GLSLANG/ShaderLang.h',
     'include/KHR/khrplatform.h',
 ]
 
 # WARNING: CPP_SOURCES seems very dependent on ordering. Grouping all of these
 # CPP_SOURCES lines into one list may break webgl tests.
 
@@ -114,15 +112,14 @@ UNIFIED_SOURCES += ['src/compiler/' + sr
     'OutputESSL.cpp',
     'OutputGLSL.cpp',
     'OutputGLSLBase.cpp',
     'ShaderLang.cpp',
     'TranslatorESSL.cpp',
     'TranslatorGLSL.cpp',
     'VersionGLSL.cpp',
 ]]
-
-LIBRARY_NAME = 'angle'
-LIBXUL_LIBRARY = True
 MSVC_ENABLE_PGO = True
 
 if CONFIG['OS_TARGET'] == 'WINNT':
     NO_VISIBILITY_FLAGS = True
+
+FINAL_LIBRARY = 'gkmedias'
--- a/gfx/angle/src/libEGL/Makefile.in
+++ b/gfx/angle/src/libEGL/Makefile.in
@@ -1,15 +1,12 @@
 # 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/.
 
-# On Windows, we don't automatically get "lib" prepended, but we need it.
-FORCE_SHARED_LIB = 1
-
 # ANGLE uses the STL, so we can't use our derpy STL wrappers.
 STL_FLAGS =
 
 ifndef GNU_CC
 # Enable unwind semantics for exception handlers in response to warning C4530.
 OS_CPPFLAGS += -EHsc
 endif
 
--- a/gfx/angle/src/libEGL/moz.build
+++ b/gfx/angle/src/libEGL/moz.build
@@ -1,16 +1,14 @@
 # -*- 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/.
 
-MODULE = 'libegl'
-
 # Target: 'libEGL'
 #   Requires: 'libGLESv2'
 # src/common:
 SOURCES += ['../common/' + src for src in [
     'debug.cpp',
     'RefCountObject.cpp',
 ]]
 
@@ -18,9 +16,12 @@ SOURCES += ['../common/' + src for src i
 SOURCES += [
     'Config.cpp',
     'Display.cpp',
     'libEGL.cpp',
     'main.cpp',
     'Surface.cpp',
 ]
 
+# On Windows, we don't automatically get "lib" prepended, but we need it.
 LIBRARY_NAME = 'libEGL'
+
+FORCE_SHARED_LIB = True
--- a/gfx/angle/src/libGLESv2/Makefile.in
+++ b/gfx/angle/src/libGLESv2/Makefile.in
@@ -1,15 +1,12 @@
 # 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/.
 
-# On Windows, we don't automatically get "lib" prepended, but we need it.
-FORCE_SHARED_LIB = 1
-
 # ANGLE uses the STL, so we can't use our derpy STL wrappers.
 STL_FLAGS =
 
 ifndef GNU_CC
 # Enable unwind semantics for exception handlers in response to warning C4530.
 OS_CPPFLAGS += -EHsc
 endif
 
--- a/gfx/angle/src/libGLESv2/moz.build
+++ b/gfx/angle/src/libGLESv2/moz.build
@@ -1,16 +1,14 @@
 # -*- 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/.
 
-MODULE = 'libglesv2'
-
 # Target: 'preprocessor'
 # src/compiler/preprocessor:
 SOURCES += ['../compiler/preprocessor/' + src for src in [
     'DiagnosticsBase.cpp',
     'DirectiveHandlerBase.cpp',
     'DirectiveParser.cpp',
     'ExpressionParser.cpp',
     'Input.cpp',
@@ -172,9 +170,12 @@ SOURCES += ['renderer/' + src for src in
     'TextureStorage9.cpp',
     'VertexBuffer.cpp',
     'VertexBuffer11.cpp',
     'VertexBuffer9.cpp',
     'VertexDataManager.cpp',
     'VertexDeclarationCache.cpp',
 ]]
 
+# On Windows, we don't automatically get "lib" prepended, but we need it.
 LIBRARY_NAME = 'libGLESv2'
+
+FORCE_SHARED_LIB = True
--- a/gfx/cairo/cairo/src/cairo-rename.h
+++ b/gfx/cairo/cairo/src/cairo-rename.h
@@ -357,135 +357,9 @@
 #define cairo_xlib_surface_get_drawable _moz_cairo_xlib_surface_get_drawable
 #define cairo_xlib_surface_get_height _moz_cairo_xlib_surface_get_height
 #define cairo_xlib_surface_get_screen _moz_cairo_xlib_surface_get_screen
 #define cairo_xlib_surface_get_visual _moz_cairo_xlib_surface_get_visual
 #define cairo_xlib_surface_get_width _moz_cairo_xlib_surface_get_width
 #define cairo_xlib_surface_get_xrender_format _moz_cairo_xlib_surface_get_xrender_format
 #define cairo_xlib_surface_set_drawable _moz_cairo_xlib_surface_set_drawable
 #define cairo_xlib_surface_set_size _moz_cairo_xlib_surface_set_size
-#ifdef MOZ_TREE_PIXMAN
-#define pixman_region_set_static_pointers _moz_pixman_region_set_static_pointers
-#define pixman_region_init _moz_pixman_region_init
-#define pixman_region_init_rect _moz_pixman_region_init_rect
-#define pixman_region_init_rects _moz_pixman_region_init_rects
-#define pixman_region_init_with_extents _moz_pixman_region_init_with_extents
-#define pixman_region_fini _moz_pixman_region_fini
-#define pixman_region_translate _moz_pixman_region_translate
-#define pixman_region_copy _moz_pixman_region_copy
-#define pixman_region_intersect _moz_pixman_region_intersect
-#define pixman_region_union _moz_pixman_region_union
-#define pixman_region_union_rect _moz_pixman_region_union_rect
-#define pixman_region_subtract _moz_pixman_region_subtract
-#define pixman_region_inverse _moz_pixman_region_inverse
-#define pixman_region_contains_point _moz_pixman_region_contains_point
-#define pixman_region_contains_rectangle _moz_pixman_region_contains_rectangle
-#define pixman_region_not_empty _moz_pixman_region_not_empty
-#define pixman_region_extents _moz_pixman_region_extents
-#define pixman_region_n_rects _moz_pixman_region_n_rects
-#define pixman_region_rectangles _moz_pixman_region_rectangles
-#define pixman_region_equal _moz_pixman_region_equal
-#define pixman_region_selfcheck _moz_pixman_region_selfcheck
-#define pixman_region_reset _moz_pixman_region_reset
-#define pixman_region32_init _moz_pixman_region32_init
-#define pixman_region32_init_rect _moz_pixman_region32_init_rect
-#define pixman_region32_init_rects _moz_pixman_region32_init_rects
-#define pixman_region32_init_with_extents _moz_pixman_region32_init_with_extents
-#define pixman_region32_fini _moz_pixman_region32_fini
-#define pixman_region32_translate _moz_pixman_region32_translate
-#define pixman_region32_copy _moz_pixman_region32_copy
-#define pixman_region32_intersect _moz_pixman_region32_intersect
-#define pixman_region32_union _moz_pixman_region32_union
-#define pixman_region32_union_rect _moz_pixman_region32_union_rect
-#define pixman_region32_subtract _moz_pixman_region32_subtract
-#define pixman_region32_inverse _moz_pixman_region32_inverse
-#define pixman_region32_contains_point _moz_pixman_region32_contains_point
-#define pixman_region32_contains_rectangle _moz_pixman_region32_contains_rectangle
-#define pixman_region32_not_empty _moz_pixman_region32_not_empty
-#define pixman_region32_extents _moz_pixman_region32_extents
-#define pixman_region32_n_rects _moz_pixman_region32_n_rects
-#define pixman_region32_rectangles _moz_pixman_region32_rectangles
-#define pixman_region32_equal _moz_pixman_region32_equal
-#define pixman_region32_selfcheck _moz_pixman_region32_selfcheck
-#define pixman_region32_reset _moz_pixman_region32_reset
-#define pixman_blt _moz_pixman_blt
-#define pixman_fill _moz_pixman_fill
-#define pixman_transform_point_3d _moz_pixman_transform_point_3d
-#define pixman_version _moz_pixman_version
-#define pixman_version_string _moz_pixman_version_string
-#define pixman_format_supported_destination _moz_pixman_format_supported_destination
-#define pixman_format_supported_source _moz_pixman_format_supported_source
-#define pixman_image_create_solid_fill _moz_pixman_image_create_solid_fill
-#define pixman_image_create_linear_gradient _moz_pixman_image_create_linear_gradient
-#define pixman_image_create_radial_gradient _moz_pixman_image_create_radial_gradient
-#define pixman_image_create_conical_gradient _moz_pixman_image_create_conical_gradient
-#define pixman_image_create_bits _moz_pixman_image_create_bits
-#define pixman_image_ref _moz_pixman_image_ref
-#define pixman_image_unref _moz_pixman_image_unref
-#define pixman_image_set_clip_region _moz_pixman_image_set_clip_region
-#define pixman_image_set_clip_region32 _moz_pixman_image_set_clip_region32
-#define pixman_image_set_has_client_clip _moz_pixman_image_set_has_client_clip
-#define pixman_image_set_transform _moz_pixman_image_set_transform
-#define pixman_image_set_repeat _moz_pixman_image_set_repeat
-#define pixman_image_set_filter _moz_pixman_image_set_filter
-#define pixman_image_set_source_clipping _moz_pixman_image_set_source_clipping
-#define pixman_image_set_alpha_map _moz_pixman_image_set_alpha_map
-#define pixman_image_set_component_alpha _moz_pixman_image_set_component_alpha
-#define pixman_image_set_accessors	 _moz_pixman_image_set_accessors	
-#define pixman_image_set_indexed	 _moz_pixman_image_set_indexed	
-#define pixman_image_get_data _moz_pixman_image_get_data
-#define pixman_image_get_width _moz_pixman_image_get_width
-#define pixman_image_get_height _moz_pixman_image_get_height
-#define pixman_image_get_stride _moz_pixman_image_get_stride
-#define pixman_image_get_depth _moz_pixman_image_get_depth
-#define pixman_image_fill_rectangles	 _moz_pixman_image_fill_rectangles	
-#define pixman_compute_composite_region _moz_pixman_compute_composite_region
-#define pixman_image_composite _moz_pixman_image_composite
-#define pixman_sample_ceil_y _moz_pixman_sample_ceil_y
-#define pixman_sample_floor_y _moz_pixman_sample_floor_y
-#define pixman_edge_step _moz_pixman_edge_step
-#define pixman_edge_init _moz_pixman_edge_init
-#define pixman_line_fixed_edge_init _moz_pixman_line_fixed_edge_init
-#define pixman_rasterize_edges _moz_pixman_rasterize_edges
-#define pixman_add_traps _moz_pixman_add_traps
-#define pixman_add_trapezoids _moz_pixman_add_trapezoids
-#define pixman_rasterize_trapezoid _moz_pixman_rasterize_trapezoid
-#define pixman_disable_out_of_bounds_workaround _moz_pixman_disable_out_of_bounds_workaround
-#define pixman_f_transform_bounds _moz_pixman_f_transform_bounds
-#define pixman_f_transform_from_pixman_transform _moz_pixman_f_transform_from_pixman_transform
-#define pixman_f_transform_init_identity _moz_pixman_f_transform_init_identity
-#define pixman_f_transform_init_rotate _moz_pixman_f_transform_init_rotate
-#define pixman_f_transform_init_scale _moz_pixman_f_transform_init_scale
-#define pixman_f_transform_init_translate _moz_pixman_f_transform_init_translate
-#define pixman_f_transform_invert _moz_pixman_f_transform_invert
-#define pixman_f_transform_multiply _moz_pixman_f_transform_multiply
-#define pixman_f_transform_point _moz_pixman_f_transform_point
-#define pixman_f_transform_point_3d _moz_pixman_f_transform_point_3d
-#define pixman_f_transform_rotate _moz_pixman_f_transform_rotate
-#define pixman_f_transform_scale _moz_pixman_f_transform_scale
-#define pixman_f_transform_translate _moz_pixman_f_transform_translate
-#define pixman_image_composite32 _moz_pixman_image_composite32
-#define pixman_image_fill_boxes _moz_pixman_image_fill_boxes
-#define pixman_image_get_component_alpha _moz_pixman_image_get_component_alpha
-#define pixman_image_get_destroy_data _moz_pixman_image_get_destroy_data
-#define pixman_image_get_format _moz_pixman_image_get_format
-#define pixman_image_set_destroy_function _moz_pixman_image_set_destroy_function
-#define pixman_region_init_from_image _moz_pixman_region_init_from_image
-#define pixman_region_intersect_rect _moz_pixman_region_intersect_rect
-#define pixman_region32_init_from_image _moz_pixman_region32_init_from_image
-#define pixman_region32_intersect_rect _moz_pixman_region32_intersect_rect
-#define pixman_transform_bounds _moz_pixman_transform_bounds
-#define pixman_transform_from_pixman_f_transform _moz_pixman_transform_from_pixman_f_transform
-#define pixman_transform_init_identity _moz_pixman_transform_init_identity
-#define pixman_transform_init_rotate _moz_pixman_transform_init_rotate
-#define pixman_transform_init_scale _moz_pixman_transform_init_scale
-#define pixman_transform_init_translate _moz_pixman_transform_init_translate
-#define pixman_transform_invert _moz_pixman_transform_invert
-#define pixman_transform_is_identity _moz_pixman_transform_is_identity
-#define pixman_transform_is_int_translate _moz_pixman_transform_is_int_translate
-#define pixman_transform_is_inverse _moz_pixman_transform_is_inverse
-#define pixman_transform_is_scale _moz_pixman_transform_is_scale
-#define pixman_transform_multiply _moz_pixman_transform_multiply
-#define pixman_transform_point _moz_pixman_transform_point
-#define pixman_transform_rotate _moz_pixman_transform_rotate
-#define pixman_transform_scale _moz_pixman_transform_scale
-#define pixman_transform_translate _moz_pixman_transform_translate
-#endif
+#include "pixman-rename.h"
--- a/gfx/cairo/cairo/src/moz.build
+++ b/gfx/cairo/cairo/src/moz.build
@@ -1,25 +1,24 @@
 # -*- 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/.
 
 CONFIGURE_SUBST_FILES += ['cairo-features.h']
 
-MODULE = 'cairo'
-
 EXPORTS.cairo += [
     'cairo-deprecated.h',
     'cairo-platform.h',
     'cairo-rename.h',
     'cairo-tee.h',
     'cairo-version.h',
     'cairo.h',
+    'pixman-rename.h',
 ]
 
 if CONFIG['MOZ_WIDGET_TOOLKIT'] not in ('cocoa', 'uikit'):
     EXPORTS.cairo += [
         'cairo-pdf.h',
     ]
     SOURCES += [
         'cairo-base85-stream.c',
@@ -109,20 +108,16 @@ if CONFIG['MOZ_ENABLE_CAIRO_FT']:
     EXPORTS.cairo += [
         'cairo-ft.h',
     ]
     SOURCES += [
         'cairo-ft-font.c',
         'cairo-type1-subset.c',
     ]
 
-LIBRARY_NAME = 'mozcairo'
-
-LIBXUL_LIBRARY = True
-
 SOURCES += [
     'cairo-analysis-surface.c',
     'cairo-arc.c',
     'cairo-array.c',
     'cairo-atomic.c',
     'cairo-base64-stream.c',
     'cairo-bentley-ottmann-rectangular.c',
     'cairo-bentley-ottmann-rectilinear.c',
@@ -188,8 +183,9 @@ SOURCES += [
     'cairo-user-font.c',
     'cairo-version.c',
     'cairo-wideint.c',
     'cairo.c',
 ]
 
 MSVC_ENABLE_PGO = True
 
+FINAL_LIBRARY = 'gkmedias'
new file mode 100644
--- /dev/null
+++ b/gfx/cairo/cairo/src/pixman-rename.h
@@ -0,0 +1,128 @@
+#ifdef MOZ_TREE_PIXMAN
+#define pixman_region_set_static_pointers _moz_pixman_region_set_static_pointers
+#define pixman_region_init _moz_pixman_region_init
+#define pixman_region_init_rect _moz_pixman_region_init_rect
+#define pixman_region_init_rects _moz_pixman_region_init_rects
+#define pixman_region_init_with_extents _moz_pixman_region_init_with_extents
+#define pixman_region_fini _moz_pixman_region_fini
+#define pixman_region_translate _moz_pixman_region_translate
+#define pixman_region_copy _moz_pixman_region_copy
+#define pixman_region_intersect _moz_pixman_region_intersect
+#define pixman_region_union _moz_pixman_region_union
+#define pixman_region_union_rect _moz_pixman_region_union_rect
+#define pixman_region_subtract _moz_pixman_region_subtract
+#define pixman_region_inverse _moz_pixman_region_inverse
+#define pixman_region_contains_point _moz_pixman_region_contains_point
+#define pixman_region_contains_rectangle _moz_pixman_region_contains_rectangle
+#define pixman_region_not_empty _moz_pixman_region_not_empty
+#define pixman_region_extents _moz_pixman_region_extents
+#define pixman_region_n_rects _moz_pixman_region_n_rects
+#define pixman_region_rectangles _moz_pixman_region_rectangles
+#define pixman_region_equal _moz_pixman_region_equal
+#define pixman_region_selfcheck _moz_pixman_region_selfcheck
+#define pixman_region_reset _moz_pixman_region_reset
+#define pixman_region32_init _moz_pixman_region32_init
+#define pixman_region32_init_rect _moz_pixman_region32_init_rect
+#define pixman_region32_init_rects _moz_pixman_region32_init_rects
+#define pixman_region32_init_with_extents _moz_pixman_region32_init_with_extents
+#define pixman_region32_init_from_image _moz_pixman_region32_init_from_image
+#define pixman_region32_fini _moz_pixman_region32_fini
+#define pixman_region32_translate _moz_pixman_region32_translate
+#define pixman_region32_copy _moz_pixman_region32_copy
+#define pixman_region32_intersect _moz_pixman_region32_intersect
+#define pixman_region32_intersect_rect _moz_pixman_region32_intersect_rect
+#define pixman_region32_union _moz_pixman_region32_union
+#define pixman_region32_union_rect _moz_pixman_region32_union_rect
+#define pixman_region32_subtract _moz_pixman_region32_subtract
+#define pixman_region32_inverse _moz_pixman_region32_inverse
+#define pixman_region32_contains_point _moz_pixman_region32_contains_point
+#define pixman_region32_contains_rectangle _moz_pixman_region32_contains_rectangle
+#define pixman_region32_not_empty _moz_pixman_region32_not_empty
+#define pixman_region32_extents _moz_pixman_region32_extents
+#define pixman_region32_n_rects _moz_pixman_region32_n_rects
+#define pixman_region32_rectangles _moz_pixman_region32_rectangles
+#define pixman_region32_equal _moz_pixman_region32_equal
+#define pixman_region32_selfcheck _moz_pixman_region32_selfcheck
+#define pixman_region32_reset _moz_pixman_region32_reset
+#define pixman_region32_clear _moz_pixman_region32_clear
+#define pixman_blt _moz_pixman_blt
+#define pixman_fill _moz_pixman_fill
+#define pixman_transform_point_3d _moz_pixman_transform_point_3d
+#define pixman_version _moz_pixman_version
+#define pixman_version_string _moz_pixman_version_string
+#define pixman_format_supported_destination _moz_pixman_format_supported_destination
+#define pixman_format_supported_source _moz_pixman_format_supported_source
+#define pixman_image_create_solid_fill _moz_pixman_image_create_solid_fill
+#define pixman_image_create_linear_gradient _moz_pixman_image_create_linear_gradient
+#define pixman_image_create_radial_gradient _moz_pixman_image_create_radial_gradient
+#define pixman_image_create_conical_gradient _moz_pixman_image_create_conical_gradient
+#define pixman_image_create_bits _moz_pixman_image_create_bits
+#define pixman_image_ref _moz_pixman_image_ref
+#define pixman_image_unref _moz_pixman_image_unref
+#define pixman_image_set_clip_region _moz_pixman_image_set_clip_region
+#define pixman_image_set_clip_region32 _moz_pixman_image_set_clip_region32
+#define pixman_image_set_has_client_clip _moz_pixman_image_set_has_client_clip
+#define pixman_image_set_transform _moz_pixman_image_set_transform
+#define pixman_image_set_repeat _moz_pixman_image_set_repeat
+#define pixman_image_set_filter _moz_pixman_image_set_filter
+#define pixman_image_set_source_clipping _moz_pixman_image_set_source_clipping
+#define pixman_image_set_alpha_map _moz_pixman_image_set_alpha_map
+#define pixman_image_set_component_alpha _moz_pixman_image_set_component_alpha
+#define pixman_image_set_accessors	 _moz_pixman_image_set_accessors	
+#define pixman_image_set_indexed	 _moz_pixman_image_set_indexed	
+#define pixman_image_get_data _moz_pixman_image_get_data
+#define pixman_image_get_width _moz_pixman_image_get_width
+#define pixman_image_get_height _moz_pixman_image_get_height
+#define pixman_image_get_stride _moz_pixman_image_get_stride
+#define pixman_image_get_depth _moz_pixman_image_get_depth
+#define pixman_image_fill_rectangles	 _moz_pixman_image_fill_rectangles	
+#define pixman_compute_composite_region _moz_pixman_compute_composite_region
+#define pixman_image_composite _moz_pixman_image_composite
+#define pixman_sample_ceil_y _moz_pixman_sample_ceil_y
+#define pixman_sample_floor_y _moz_pixman_sample_floor_y
+#define pixman_edge_step _moz_pixman_edge_step
+#define pixman_edge_init _moz_pixman_edge_init
+#define pixman_line_fixed_edge_init _moz_pixman_line_fixed_edge_init
+#define pixman_rasterize_edges _moz_pixman_rasterize_edges
+#define pixman_add_traps _moz_pixman_add_traps
+#define pixman_add_trapezoids _moz_pixman_add_trapezoids
+#define pixman_rasterize_trapezoid _moz_pixman_rasterize_trapezoid
+#define pixman_disable_out_of_bounds_workaround _moz_pixman_disable_out_of_bounds_workaround
+#define pixman_f_transform_bounds _moz_pixman_f_transform_bounds
+#define pixman_f_transform_from_pixman_transform _moz_pixman_f_transform_from_pixman_transform
+#define pixman_f_transform_init_identity _moz_pixman_f_transform_init_identity
+#define pixman_f_transform_init_rotate _moz_pixman_f_transform_init_rotate
+#define pixman_f_transform_init_scale _moz_pixman_f_transform_init_scale
+#define pixman_f_transform_init_translate _moz_pixman_f_transform_init_translate
+#define pixman_f_transform_invert _moz_pixman_f_transform_invert
+#define pixman_f_transform_multiply _moz_pixman_f_transform_multiply
+#define pixman_f_transform_point _moz_pixman_f_transform_point
+#define pixman_f_transform_point_3d _moz_pixman_f_transform_point_3d
+#define pixman_f_transform_rotate _moz_pixman_f_transform_rotate
+#define pixman_f_transform_scale _moz_pixman_f_transform_scale
+#define pixman_f_transform_translate _moz_pixman_f_transform_translate
+#define pixman_image_composite32 _moz_pixman_image_composite32
+#define pixman_image_fill_boxes _moz_pixman_image_fill_boxes
+#define pixman_image_get_component_alpha _moz_pixman_image_get_component_alpha
+#define pixman_image_get_destroy_data _moz_pixman_image_get_destroy_data
+#define pixman_image_get_format _moz_pixman_image_get_format
+#define pixman_image_set_destroy_function _moz_pixman_image_set_destroy_function
+#define pixman_region_init_from_image _moz_pixman_region_init_from_image
+#define pixman_region_intersect_rect _moz_pixman_region_intersect_rect
+#define pixman_transform_bounds _moz_pixman_transform_bounds
+#define pixman_transform_from_pixman_f_transform _moz_pixman_transform_from_pixman_f_transform
+#define pixman_transform_init_identity _moz_pixman_transform_init_identity
+#define pixman_transform_init_rotate _moz_pixman_transform_init_rotate
+#define pixman_transform_init_scale _moz_pixman_transform_init_scale
+#define pixman_transform_init_translate _moz_pixman_transform_init_translate
+#define pixman_transform_invert _moz_pixman_transform_invert
+#define pixman_transform_is_identity _moz_pixman_transform_is_identity
+#define pixman_transform_is_int_translate _moz_pixman_transform_is_int_translate
+#define pixman_transform_is_inverse _moz_pixman_transform_is_inverse
+#define pixman_transform_is_scale _moz_pixman_transform_is_scale
+#define pixman_transform_multiply _moz_pixman_transform_multiply
+#define pixman_transform_point _moz_pixman_transform_point
+#define pixman_transform_rotate _moz_pixman_transform_rotate
+#define pixman_transform_scale _moz_pixman_transform_scale
+#define pixman_transform_translate _moz_pixman_transform_translate
+#endif
--- a/gfx/cairo/libpixman/src/moz.build
+++ b/gfx/cairo/libpixman/src/moz.build
@@ -1,16 +1,14 @@
 # -*- 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/.
 
-MODULE = 'libpixman'
-
 EXPORTS += [
     'pixman-version.h',
     'pixman.h',
 ]
 
 # Apple's arm assembler doesn't support the same syntax as
 # the standard GNU assembler, so use the C fallback paths for now.
 # This may be fixable if clang's ARM/iOS assembler improves into a
@@ -22,18 +20,16 @@ if CONFIG['OS_ARCH'] != 'Darwin' and CON
             'pixman-arm-neon-asm.S',
         ]
     if CONFIG['HAVE_ARM_SIMD']:
         SOURCES += [
             'pixman-arm-simd-asm-scaled.S',
             'pixman-arm-simd-asm.S',
         ]
 
-LIBXUL_LIBRARY = True
-
 SOURCES += [
     'pixman-access-accessors.c',
     'pixman-access.c',
     'pixman-arm.c',
     'pixman-bits-image.c',
     'pixman-combine-float.c',
     'pixman-combine16.c',
     'pixman-combine32.c',
@@ -59,10 +55,9 @@ SOURCES += [
     'pixman-trap.c',
     'pixman-utils.c',
     'pixman-x86.c',
     'pixman.c',
 ]
 
 MSVC_ENABLE_PGO = True
 
-LIBRARY_NAME = 'mozlibpixman'
-
+FINAL_LIBRARY = 'gkmedias'
--- a/gfx/cairo/libpixman/src/pixman-compiler.h
+++ b/gfx/cairo/libpixman/src/pixman-compiler.h
@@ -80,17 +80,29 @@
 #   endif
 #   ifndef noinline
 #      define noinline
 #   endif
 #endif
 
 /* In libxul builds we don't ever want to export pixman symbols */
 #if 1
-#   define PIXMAN_EXPORT cairo_public
+#include "prcpucfg.h"
+
+#ifdef HAVE_VISIBILITY_HIDDEN_ATTRIBUTE
+#define CVISIBILITY_HIDDEN __attribute__((visibility("hidden")))
+#elif defined(__SUNPRO_C) && (__SUNPRO_C >= 0x550)
+#define CVISIBILITY_HIDDEN __hidden
+#else
+#define CVISIBILITY_HIDDEN
+#endif
+
+/* In libxul builds we don't ever want to export cairo symbols */
+#define PIXMAN_EXPORT extern CVISIBILITY_HIDDEN
+
 #else
 
 /* GCC visibility */
 #if defined(__GNUC__) && __GNUC__ >= 4 && !defined(_WIN32)
 #   define PIXMAN_EXPORT __attribute__ ((visibility("default")))
 /* Sun Studio 8 visibility */
 #elif defined(__SUNPRO_C) && (__SUNPRO_C >= 0x550)
 #   define PIXMAN_EXPORT __global
--- a/gfx/cairo/libpixman/src/pixman.h
+++ b/gfx/cairo/libpixman/src/pixman.h
@@ -64,17 +64,20 @@ SOFTWARE.
  * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  * PERFORMANCE OF THIS SOFTWARE.
  */
 
 #ifndef PIXMAN_H__
 #define PIXMAN_H__
 
-#include "cairo-platform.h"
+#ifdef MOZILLA_VERSION
+#include "cairo/pixman-rename.h"
+#endif
+
 
 #include <pixman-version.h>
 
 #ifdef  __cplusplus
 #define PIXMAN_BEGIN_DECLS extern "C" {
 #define PIXMAN_END_DECLS }
 #else
 #define PIXMAN_BEGIN_DECLS
--- a/gfx/gl/moz.build
+++ b/gfx/gl/moz.build
@@ -1,16 +1,14 @@
 # -*- 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/.
 
-MODULE = 'gl'
-
 gl_provider = 'Null'
 
 if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'windows':
     gl_provider = 'WGL'
 elif CONFIG['MOZ_WIDGET_TOOLKIT'] == 'cocoa':
     gl_provider = 'CGL'
 elif CONFIG['MOZ_WIDGET_GTK']:
     if CONFIG['MOZ_EGL_XRENDER_COMPOSITE']:
@@ -107,18 +105,13 @@ SOURCES += [
     'SurfaceStream.cpp',
     'TextureGarbageBin.cpp',
     'TextureImageEGL.cpp',
     'VBOArena.cpp',
 ]
 
 FAIL_ON_WARNINGS = True
 
-LIBXUL_LIBRARY = True
-
 MSVC_ENABLE_PGO = True
 
-LIBRARY_NAME = 'gl'
-
-EXPORT_LIBRARY = True
-
 include('/ipc/chromium/chromium-config.mozbuild')
 
+FINAL_LIBRARY = 'xul'
--- a/gfx/graphite2/src/moz.build
+++ b/gfx/graphite2/src/moz.build
@@ -1,21 +1,14 @@
 # -*- 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/.
 
-MODULE = 'graphite2'
-
-if CONFIG['OS_TARGET'] == 'WINNT':
-    FORCE_STATIC_LIB = True
-else:
-    LIBXUL_LIBRARY = True
-
 # This should contain all of the _PUBLIC_HEADERS from files.mk
 EXPORTS.graphite2 += [
     '../include/graphite2/Font.h',
     '../include/graphite2/Log.h',
     '../include/graphite2/Segment.h',
     '../include/graphite2/Types.h',
 ]
 
@@ -57,14 +50,14 @@ SOURCES += [
     'Segment.cpp',
     'Silf.cpp',
     'Slot.cpp',
     'Sparse.cpp',
     'TtfUtil.cpp',
     'UtfCodec.cpp',
 ]
 
-LIBRARY_NAME = 'mozgraphite2'
-
 MSVC_ENABLE_PGO = True
 
 if CONFIG['OS_TARGET'] == 'WINNT':
     NO_VISIBILITY_FLAGS = True
+
+FINAL_LIBRARY = 'gkmedias'
--- a/gfx/harfbuzz/src/moz.build
+++ b/gfx/harfbuzz/src/moz.build
@@ -1,21 +1,14 @@
 # -*- 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/.
 
-MODULE = 'harfbuzz'
-
-if CONFIG['OS_ARCH'] == 'WINNT':
-    FORCE_STATIC_LIB = True
-else:
-    LIBXUL_LIBRARY = True
-
 EXPORTS.harfbuzz += [
     'hb-blob.h',
     'hb-buffer.h',
     'hb-common.h',
     'hb-deprecated.h',
     'hb-face.h',
     'hb-font.h',
     'hb-ot-layout.h',
@@ -52,12 +45,11 @@ SOURCES += [
     'hb-set.cc',
     'hb-shape-plan.cc',
     'hb-shape.cc',
     'hb-shaper.cc',
     'hb-unicode.cc',
     'hb-warning.cc',
 ]
 
-LIBRARY_NAME = 'mozharfbuzz'
-
 MSVC_ENABLE_PGO = True
 
+FINAL_LIBRARY = 'gkmedias'
--- a/gfx/ipc/moz.build
+++ b/gfx/ipc/moz.build
@@ -1,16 +1,14 @@
 # -*- 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/.
 
-MODULE = 'gfxipc'
-
 EXPORTS.mozilla += [
     'GfxMessageUtils.h'
 ]
 
 EXPORTS.mozilla.gfx += [
     'SharedDIB.h',
 ]
 
@@ -23,16 +21,11 @@ if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'wind
         'SharedDIBSurface.cpp',
         'SharedDIBWin.cpp',
     ]
 
 SOURCES += [
     'SharedDIB.cpp',
 ]
 
-LIBXUL_LIBRARY = True
-
-LIBRARY_NAME = 'gfxipc_s'
-
-EXPORT_LIBRARY = True
-
 include('/ipc/chromium/chromium-config.mozbuild')
 
+FINAL_LIBRARY = 'xul'
--- a/gfx/layers/client/CanvasClient.cpp
+++ b/gfx/layers/client/CanvasClient.cpp
@@ -101,16 +101,24 @@ CanvasClient2D::Update(gfx::IntSize aSiz
 TemporaryRef<BufferTextureClient>
 CanvasClient2D::CreateBufferTextureClient(gfx::SurfaceFormat aFormat, TextureFlags aFlags)
 {
   return CompositableClient::CreateBufferTextureClient(aFormat,
                                                        mTextureInfo.mTextureFlags | aFlags);
 }
 
 void
+CanvasClient2D::OnActorDestroy()
+{
+  if (mBuffer) {
+    mBuffer->OnActorDestroy();
+  }
+}
+
+void
 DeprecatedCanvasClient2D::Updated()
 {
   mForwarder->UpdateTexture(this, 1, mDeprecatedTextureClient->LockSurfaceDescriptor());
 }
 
 
 DeprecatedCanvasClient2D::DeprecatedCanvasClient2D(CompositableForwarder* aFwd,
                                                    TextureFlags aFlags)
@@ -152,16 +160,24 @@ DeprecatedCanvasClient2D::Update(gfx::In
   }
 
   gfxASurface* surface = mDeprecatedTextureClient->LockSurface();
   aLayer->UpdateSurface(surface);
   mDeprecatedTextureClient->Unlock();
 }
 
 void
+DeprecatedCanvasClient2D::OnActorDestroy()
+{
+  if (mDeprecatedTextureClient) {
+    mDeprecatedTextureClient->OnActorDestroy();
+  }
+}
+
+void
 DeprecatedCanvasClientSurfaceStream::Updated()
 {
   mForwarder->UpdateTextureNoSwap(this, 1, mDeprecatedTextureClient->LockSurfaceDescriptor());
 }
 
 
 DeprecatedCanvasClientSurfaceStream::DeprecatedCanvasClientSurfaceStream(CompositableForwarder* aFwd,
                                                                          TextureFlags aFlags)
@@ -219,10 +235,18 @@ DeprecatedCanvasClientSurfaceStream::Upd
     // Ref this so the SurfaceStream doesn't disappear unexpectedly. The
     // Compositor will need to unref it when finished.
     aLayer->mGLContext->AddRef();
   }
 
   aLayer->Painted();
 }
 
+void
+DeprecatedCanvasClientSurfaceStream::OnActorDestroy()
+{
+  if (mDeprecatedTextureClient) {
+    mDeprecatedTextureClient->OnActorDestroy();
+  }
+}
+
 }
 }
--- a/gfx/layers/client/CanvasClient.h
+++ b/gfx/layers/client/CanvasClient.h
@@ -86,19 +86,22 @@ public:
   CreateBufferTextureClient(gfx::SurfaceFormat aFormat,
                             TextureFlags aFlags = TEXTURE_FLAGS_DEFAULT) MOZ_OVERRIDE;
 
   virtual void OnDetach() MOZ_OVERRIDE
   {
     mBuffer = nullptr;
   }
 
+  virtual void OnActorDestroy() MOZ_OVERRIDE;
+
 private:
   RefPtr<TextureClient> mBuffer;
 };
+
 class DeprecatedCanvasClient2D : public CanvasClient
 {
 public:
   DeprecatedCanvasClient2D(CompositableForwarder* aLayerForwarder,
                            TextureFlags aFlags);
 
   TextureInfo GetTextureInfo() const MOZ_OVERRIDE
   {
@@ -109,16 +112,18 @@ public:
   virtual void Updated() MOZ_OVERRIDE;
 
   virtual void SetDescriptorFromReply(TextureIdentifier aTextureId,
                                       const SurfaceDescriptor& aDescriptor) MOZ_OVERRIDE
   {
     mDeprecatedTextureClient->SetDescriptorFromReply(aDescriptor);
   }
 
+  virtual void OnActorDestroy() MOZ_OVERRIDE;
+
 private:
   RefPtr<DeprecatedTextureClient> mDeprecatedTextureClient;
 };
 
 // Used for GL canvases where we don't need to do any readback, i.e., with a
 // GL backend.
 class DeprecatedCanvasClientSurfaceStream : public CanvasClient
 {
@@ -135,16 +140,18 @@ public:
   virtual void Updated() MOZ_OVERRIDE;
 
   virtual void SetDescriptorFromReply(TextureIdentifier aTextureId,
                                       const SurfaceDescriptor& aDescriptor) MOZ_OVERRIDE
   {
     mDeprecatedTextureClient->SetDescriptorFromReply(aDescriptor);
   }
 
+  virtual void OnActorDestroy() MOZ_OVERRIDE;
+
 private:
   RefPtr<DeprecatedTextureClient> mDeprecatedTextureClient;
 };
 
 }
 }
 
 #endif
--- a/gfx/layers/client/CompositableClient.cpp
+++ b/gfx/layers/client/CompositableClient.cpp
@@ -30,17 +30,16 @@ CompositableClient::CompositableClient(C
 
 
 CompositableClient::~CompositableClient()
 {
   MOZ_COUNT_DTOR(CompositableClient);
   Destroy();
 
   FlushTexturesToRemoveCallbacks();
-
   MOZ_ASSERT(mTexturesToRemove.Length() == 0, "would leak textures pending for deletion");
 }
 
 void
 CompositableClient::FlushTexturesToRemoveCallbacks()
 {
   std::map<uint64_t,TextureClientData*>::iterator it
     = mTexturesToRemoveCallbacks.begin();
@@ -82,16 +81,17 @@ CompositableClient::Connect()
 }
 
 void
 CompositableClient::Destroy()
 {
   if (!mCompositableChild) {
     return;
   }
+  mCompositableChild->SetClient(nullptr);
   mCompositableChild->Destroy();
   mCompositableChild = nullptr;
 }
 
 uint64_t
 CompositableClient::GetAsyncID() const
 {
   if (mCompositableChild) {
@@ -252,10 +252,18 @@ CompositableClient::OnTransaction()
 {
   for (unsigned i = 0; i < mTexturesToRemove.Length(); ++i) {
     const TextureIDAndFlags& texture = mTexturesToRemove[i];
     mForwarder->RemoveTexture(this, texture.mID, texture.mFlags);
   }
   mTexturesToRemove.Clear();
 }
 
+
+void
+CompositableChild::ActorDestroy(ActorDestroyReason why)
+{
+  if (mCompositableClient && why == AbnormalShutdown) {
+    mCompositableClient->OnActorDestroy();
+  }
+}
 } // namespace layers
 } // namespace mozilla
--- a/gfx/layers/client/CompositableClient.h
+++ b/gfx/layers/client/CompositableClient.h
@@ -156,16 +156,22 @@ public:
    */
   void OnReplyTextureRemoved(uint64_t aTextureID);
 
   /**
    * Run all he registered callbacks (see the comment for OnReplyTextureRemoved).
    * Only call this if you know what you are doing.
    */
   void FlushTexturesToRemoveCallbacks();
+
+  /**
+   * Our IPDL actor is being destroyed, get rid of any shmem resources now.
+   */
+  virtual void OnActorDestroy() = 0;
+
 protected:
   struct TextureIDAndFlags {
     TextureIDAndFlags(uint64_t aID, TextureFlags aFlags)
     : mID(aID), mFlags(aFlags) {}
     uint64_t mID;
     TextureFlags mFlags;
   };
   // The textures to destroy in the next transaction;
@@ -202,16 +208,18 @@ public:
     mCompositableClient = aClient;
   }
 
   CompositableClient* GetCompositableClient() const
   {
     return mCompositableClient;
   }
 
+  virtual void ActorDestroy(ActorDestroyReason why) MOZ_OVERRIDE;
+
   void SetAsyncID(uint64_t aID) { mID = aID; }
   uint64_t GetAsyncID() const
   {
     return mID;
   }
 private:
   CompositableClient* mCompositableClient;
   uint64_t mID;
--- a/gfx/layers/client/ContentClient.cpp
+++ b/gfx/layers/client/ContentClient.cpp
@@ -322,16 +322,31 @@ ContentClientRemoteBuffer::SwapBuffers(c
 
   mFrontAndBackBufferDiffer = true;
   mDeprecatedTextureClient->SetAccessMode(DeprecatedTextureClient::ACCESS_READ_WRITE);
   if (mDeprecatedTextureClientOnWhite) {
     mDeprecatedTextureClientOnWhite->SetAccessMode(DeprecatedTextureClient::ACCESS_READ_WRITE);
   }
 }
 
+
+void
+ContentClientRemoteBuffer::OnActorDestroy()
+{
+  if (mDeprecatedTextureClient) {
+    mDeprecatedTextureClient->OnActorDestroy();
+  }
+  if (mDeprecatedTextureClientOnWhite) {
+    mDeprecatedTextureClientOnWhite->OnActorDestroy();
+  }
+  for (size_t i = 0; i < mOldTextures.Length(); ++i) {
+    mOldTextures[i]->OnActorDestroy();
+  }
+}
+
 ContentClientDoubleBuffered::~ContentClientDoubleBuffered()
 {
   if (mDeprecatedTextureClient) {
     MOZ_ASSERT(mFrontClient);
     mDeprecatedTextureClient->SetDescriptor(SurfaceDescriptor());
     mFrontClient->SetDescriptor(SurfaceDescriptor());
   }
   if (mDeprecatedTextureClientOnWhite) {
@@ -422,16 +437,36 @@ ContentClientDoubleBuffered::SwapBuffers
   mFrontClient->SetAccessMode(DeprecatedTextureClient::ACCESS_READ_ONLY);
   if (mFrontClientOnWhite) {
     mFrontClientOnWhite->SetAccessMode(DeprecatedTextureClient::ACCESS_READ_ONLY);
   }
 
   ContentClientRemoteBuffer::SwapBuffers(aFrontUpdatedRegion);
 }
 
+void
+ContentClientDoubleBuffered::OnActorDestroy()
+{
+  if (mDeprecatedTextureClient) {
+    mDeprecatedTextureClient->OnActorDestroy();
+  }
+  if (mDeprecatedTextureClientOnWhite) {
+    mDeprecatedTextureClientOnWhite->OnActorDestroy();
+  }
+  for (size_t i = 0; i < mOldTextures.Length(); ++i) {
+    mOldTextures[i]->OnActorDestroy();
+  }
+  if (mFrontClient) {
+    mFrontClient->OnActorDestroy();
+  }
+  if (mFrontClientOnWhite) {
+    mFrontClientOnWhite->OnActorDestroy();
+  }
+}
+
 struct AutoDeprecatedTextureClient {
   AutoDeprecatedTextureClient()
     : mTexture(nullptr)
   {}
   ~AutoDeprecatedTextureClient()
   {
     if (mTexture) {
       mTexture->Unlock();
--- a/gfx/layers/client/ContentClient.h
+++ b/gfx/layers/client/ContentClient.h
@@ -158,16 +158,18 @@ public:
                             RefPtr<gfx::DrawTarget>* aBlackDT, RefPtr<gfx::DrawTarget>* aWhiteDT) MOZ_OVERRIDE;
   virtual bool SupportsAzureContent() const;
 
   virtual TextureInfo GetTextureInfo() const MOZ_OVERRIDE
   {
     MOZ_CRASH("Should not be called on non-remote ContentClient");
   }
 
+  virtual void OnActorDestroy() MOZ_OVERRIDE {}
+
 private:
   BasicLayerManager* mManager;
 };
 
 /**
  * A ContentClientRemote backed by a ThebesLayerBuffer.
  *
  * When using a ContentClientRemote, SurfaceDescriptors are created on
@@ -242,16 +244,18 @@ public:
 
   void DestroyBuffers();
 
   virtual TextureInfo GetTextureInfo() const MOZ_OVERRIDE
   {
     return mTextureInfo;
   }
 
+  virtual void OnActorDestroy() MOZ_OVERRIDE;
+
 protected:
   virtual nsIntRegion GetUpdatedRegion(const nsIntRegion& aRegionToDraw,
                                        const nsIntRegion& aVisibleRegion,
                                        bool aDidSelfCopy);
 
   // create and configure mDeprecatedTextureClient
   void BuildDeprecatedTextureClients(ContentType aType,
                                      const nsIntRect& aRect,
@@ -305,16 +309,18 @@ public:
 
   virtual void SyncFrontBufferToBackBuffer() MOZ_OVERRIDE;
 
 protected:
   virtual void CreateFrontBufferAndNotify(const nsIntRect& aBufferRect) MOZ_OVERRIDE;
   virtual void DestroyFrontBuffer() MOZ_OVERRIDE;
   virtual void LockFrontBuffer() MOZ_OVERRIDE;
 
+  virtual void OnActorDestroy() MOZ_OVERRIDE;
+
 private:
   void UpdateDestinationFrom(const RotatedBuffer& aSource,
                              const nsIntRegion& aUpdateRegion);
 
   RefPtr<DeprecatedTextureClient> mFrontClient;
   RefPtr<DeprecatedTextureClient> mFrontClientOnWhite;
   nsIntRegion mFrontUpdatedRegion;
   nsIntRect mFrontBufferRect;
@@ -390,16 +396,18 @@ public:
     if (IsSurfaceDescriptorValid(mUpdateDescriptor)) {
       mForwarder->DestroySharedSurface(&mUpdateDescriptor);
     }
     if (IsSurfaceDescriptorValid(mUpdateDescriptorOnWhite)) {
       mForwarder->DestroySharedSurface(&mUpdateDescriptorOnWhite);
     }
   }
 
+  virtual void OnActorDestroy() MOZ_OVERRIDE {}
+
 private:
 
   enum BufferType{
     BUFFER_BLACK,
     BUFFER_WHITE
   };
 
   void NotifyBufferCreated(ContentType aType, uint32_t aFlags)
--- a/gfx/layers/client/ImageClient.cpp
+++ b/gfx/layers/client/ImageClient.cpp
@@ -275,16 +275,35 @@ ImageClientBuffered::UpdateImage(ImageCo
                                  uint32_t aContentFlags)
 {
   RefPtr<TextureClient> temp = mFrontBuffer;
   mFrontBuffer = mBackBuffer;
   mBackBuffer = temp;
   return ImageClientSingle::UpdateImage(aContainer, aContentFlags);
 }
 
+void
+ImageClientSingle::OnActorDestroy()
+{
+  if (mFrontBuffer) {
+    mFrontBuffer->OnActorDestroy();
+  }
+}
+
+void
+ImageClientBuffered::OnActorDestroy()
+{
+  if (mFrontBuffer) {
+    mFrontBuffer->OnActorDestroy();
+  }
+  if (mBackBuffer) {
+    mBackBuffer->OnActorDestroy();
+  }
+}
+
 bool
 ImageClientSingle::AddTextureClient(TextureClient* aTexture)
 {
   MOZ_ASSERT((mTextureFlags & aTexture->GetFlags()) == mTextureFlags);
   return CompositableClient::AddTextureClient(aTexture);
 }
 
 TemporaryRef<BufferTextureClient>
@@ -460,16 +479,24 @@ DeprecatedImageClientSingle::Updated()
 ImageClientBridge::ImageClientBridge(CompositableForwarder* aFwd,
                                      TextureFlags aFlags)
 : ImageClient(aFwd, BUFFER_BRIDGE)
 , mAsyncContainerID(0)
 , mLayer(nullptr)
 {
 }
 
+void
+DeprecatedImageClientSingle::OnActorDestroy()
+{
+  if (mDeprecatedTextureClient) {
+    mDeprecatedTextureClient->OnActorDestroy();
+  }
+}
+
 bool
 ImageClientBridge::UpdateImage(ImageContainer* aContainer, uint32_t aContentFlags)
 {
   if (!GetForwarder() || !mLayer) {
     return false;
   }
   if (mAsyncContainerID == aContainer->GetAsyncContainerID()) {
     return true;
--- a/gfx/layers/client/ImageClient.h
+++ b/gfx/layers/client/ImageClient.h
@@ -97,16 +97,18 @@ public:
 
   virtual TextureInfo GetTextureInfo() const MOZ_OVERRIDE;
 
   virtual already_AddRefed<Image> CreateImage(const uint32_t *aFormats,
                                               uint32_t aNumFormats) MOZ_OVERRIDE;
 
   virtual void FlushAllImages(bool aExceptFront) MOZ_OVERRIDE;
 
+  virtual void OnActorDestroy() MOZ_OVERRIDE;
+
 protected:
   RefPtr<TextureClient> mFrontBuffer;
   // Some layers may want to enforce some flags to all their textures
   // (like disallowing tiling)
   TextureFlags mTextureFlags;
 };
 
 /**
@@ -120,16 +122,18 @@ public:
                       CompositableType aType);
 
   virtual bool UpdateImage(ImageContainer* aContainer, uint32_t aContentFlags);
 
   virtual void OnDetach() MOZ_OVERRIDE;
 
   virtual void FlushAllImages(bool aExceptFront) MOZ_OVERRIDE;
 
+  virtual void OnActorDestroy() MOZ_OVERRIDE;
+
 protected:
   RefPtr<TextureClient> mBackBuffer;
 };
 
 /**
  * An image client which uses a single texture client, may be single or double
  * buffered. (As opposed to using two texture clients for buffering, as in
  * ContentClientDoubleBuffered, or using multiple clients for YCbCr or tiled
@@ -164,16 +168,18 @@ public:
   virtual TextureInfo GetTextureInfo() const MOZ_OVERRIDE
   {
     return mTextureInfo;
   }
 
   virtual already_AddRefed<Image> CreateImage(const uint32_t *aFormats,
                                               uint32_t aNumFormats) MOZ_OVERRIDE;
 
+  virtual void OnActorDestroy() MOZ_OVERRIDE;
+
 private:
   RefPtr<DeprecatedTextureClient> mDeprecatedTextureClient;
   TextureInfo mTextureInfo;
 };
 
 /**
  * Image class to be used for async image uploads using the image bridge
  * protocol.
@@ -205,16 +211,18 @@ public:
 
   virtual already_AddRefed<Image> CreateImage(const uint32_t *aFormats,
                                               uint32_t aNumFormats) MOZ_OVERRIDE
   {
     NS_WARNING("Should not create an image through an ImageClientBridge");
     return nullptr;
   }
 
+  virtual void OnActorDestroy() MOZ_OVERRIDE {}
+
 protected:
   uint64_t mAsyncContainerID;
   ShadowableLayer* mLayer;
 };
 
 }
 }
 
--- a/gfx/layers/client/TextureClient.cpp
+++ b/gfx/layers/client/TextureClient.cpp
@@ -385,16 +385,25 @@ DeprecatedTextureClient::DeprecatedTextu
 }
 
 DeprecatedTextureClient::~DeprecatedTextureClient()
 {
   MOZ_COUNT_DTOR(DeprecatedTextureClient);
   MOZ_ASSERT(mDescriptor.type() == SurfaceDescriptor::T__None, "Need to release surface!");
 }
 
+void
+DeprecatedTextureClient::OnActorDestroy()
+{
+  if (ISurfaceAllocator::IsShmem(&mDescriptor)) {
+    mDescriptor = SurfaceDescriptor();
+  }
+}
+
+
 DeprecatedTextureClientShmem::DeprecatedTextureClientShmem(CompositableForwarder* aForwarder,
                                        const TextureInfo& aTextureInfo)
   : DeprecatedTextureClient(aForwarder, aTextureInfo)
 {
 }
 
 DeprecatedTextureClientShmem::~DeprecatedTextureClientShmem()
 {
--- a/gfx/layers/client/TextureClient.h
+++ b/gfx/layers/client/TextureClient.h
@@ -211,16 +211,20 @@ public:
   bool IsValid() const { return mValid; }
 
   /**
    * An invalid TextureClient cannot provide access to its shared data
    * anymore. This usually means it will soon be destroyed.
    */
   void MarkInvalid() { mValid = false; }
 
+  // If a texture client holds a reference to shmem, it should override this
+  // method to forget about the shmem _without_ releasing it.
+  virtual void OnActorDestroy() {}
+
 protected:
   void AddFlags(TextureFlags  aFlags)
   {
     MOZ_ASSERT(!IsSharedWithCompositor());
     mFlags |= aFlags;
   }
 
   uint64_t mID;
@@ -311,16 +315,21 @@ public:
   virtual bool IsAllocated() const MOZ_OVERRIDE { return mAllocated; }
 
   virtual TextureClientData* DropTextureData() MOZ_OVERRIDE;
 
   ISurfaceAllocator* GetAllocator() const;
 
   ipc::Shmem& GetShmem() { return mShmem; }
 
+  virtual void OnActorDestroy() MOZ_OVERRIDE
+  {
+    mShmem = ipc::Shmem();
+  }
+
 protected:
   ipc::Shmem mShmem;
   ISurfaceAllocator* mAllocator;
   bool mAllocated;
 };
 
 /**
  * TextureClient that wraps raw memory.
@@ -487,16 +496,18 @@ public:
 
   AccessMode GetAccessMode() const
   {
     return mAccessMode;
   }
 
   virtual gfxContentType GetContentType() = 0;
 
+  void OnActorDestroy();
+
 protected:
   DeprecatedTextureClient(CompositableForwarder* aForwarder,
                 const TextureInfo& aTextureInfo);
 
   CompositableForwarder* mForwarder;
   // So far all DeprecatedTextureClients use a SurfaceDescriptor, so it makes sense to
   // keep the reference here.
   SurfaceDescriptor mDescriptor;
--- a/gfx/layers/client/TiledContentClient.h
+++ b/gfx/layers/client/TiledContentClient.h
@@ -196,16 +196,24 @@ public:
                          LayerManager::DrawThebesLayerCallback aCallback,
                          void* aCallbackData);
 
   SurfaceDescriptorTiles GetSurfaceDescriptorTiles();
 
   static BasicTiledLayerBuffer OpenDescriptor(ISurfaceAllocator* aAllocator,
                                               const SurfaceDescriptorTiles& aDescriptor);
 
+  void OnActorDestroy()
+  {
+    for (size_t i = 0; i < mRetainedTiles.Length(); i++) {
+      if (mRetainedTiles[i].IsPlaceholderTile()) continue;
+      mRetainedTiles[i].mDeprecatedTextureClient->OnActorDestroy();
+    }
+  }
+
 protected:
   BasicTiledLayerTile ValidateTile(BasicTiledLayerTile aTile,
                                    const nsIntPoint& aTileRect,
                                    const nsIntRegion& dirtyRect);
 
   // If this returns true, we perform the paint operation into a single large
   // buffer and copy it out to the tiles instead of calling PaintThebes() on
   // each tile individually. Somewhat surprisingly, this turns out to be faster
@@ -285,16 +293,22 @@ public:
   }
 
   enum TiledBufferType {
     TILED_BUFFER,
     LOW_PRECISION_TILED_BUFFER
   };
   void LockCopyAndWrite(TiledBufferType aType);
 
+  virtual void OnActorDestroy() MOZ_OVERRIDE
+  {
+    mTiledBuffer.OnActorDestroy();
+    mLowPrecisionTiledBuffer.OnActorDestroy();
+  }
+
 private:
   BasicTiledLayerBuffer mTiledBuffer;
   BasicTiledLayerBuffer mLowPrecisionTiledBuffer;
 };
 
 }
 }
 
--- a/gfx/layers/composite/CompositableHost.cpp
+++ b/gfx/layers/composite/CompositableHost.cpp
@@ -232,17 +232,24 @@ CompositableHost::DumpTextureHost(FILE* 
   surf->DumpAsDataURL(aFile ? aFile : stderr);
 }
 #endif
 
 void
 CompositableParent::ActorDestroy(ActorDestroyReason why)
 {
   if (mHost) {
-    mHost->Detach();
+    // XXX: sadness warning. We should be able to do this whenever we get ActorDestroy,
+    // not just for abnormal shutdowns (which is the only case we _need_ to - so that
+    // we don't double release our shmems). But, for some reason, that causes a
+    // crash, we don't know why. (Bug 925773).
+    if (why == AbnormalShutdown) {
+      mHost->OnActorDestroy();
+    }
+    mHost->Detach(nullptr, CompositableHost::FORCE_DETACH);
   }
 }
 
 CompositableParent::CompositableParent(CompositableParentManager* aMgr,
                                        const TextureInfo& aTextureInfo,
                                        uint64_t aID)
 : mManager(aMgr)
 , mType(aTextureInfo.mCompositableType)
--- a/gfx/layers/composite/CompositableHost.h
+++ b/gfx/layers/composite/CompositableHost.h
@@ -102,16 +102,22 @@ public:
     return mBackendData;
   }
 
   virtual void SetCompositableBackendSpecificData(CompositableBackendSpecificData* aBackendData)
   {
     mBackendData = aBackendData;
   }
 
+  /**
+   * Our IPDL actor is being destroyed, get rid of any shmem resources now and
+   * don't worry about compositing anymore.
+   */
+  virtual void OnActorDestroy() = 0;
+
   // If base class overrides, it should still call the parent implementation
   virtual void SetCompositor(Compositor* aCompositor);
 
   // composite the contents of this buffer host to the compositor's surface
   virtual void Composite(EffectChain& aEffectChain,
                          float aOpacity,
                          const gfx::Matrix4x4& aTransform,
                          const gfx::Filter& aFilter,
@@ -232,16 +238,17 @@ public:
   void SetLayer(Layer* aLayer) { mLayer = aLayer; }
 
   virtual TiledLayerComposer* AsTiledLayerComposer() { return nullptr; }
 
   typedef uint32_t AttachFlags;
   static const AttachFlags NO_FLAGS = 0;
   static const AttachFlags ALLOW_REATTACH = 1;
   static const AttachFlags KEEP_ATTACHED = 2;
+  static const AttachFlags FORCE_DETACH = 2;
 
   virtual void Attach(Layer* aLayer,
                       Compositor* aCompositor,
                       AttachFlags aFlags = NO_FLAGS)
   {
     MOZ_ASSERT(aCompositor, "Compositor is required");
     NS_ASSERTION(aFlags & ALLOW_REATTACH || !mAttached,
                  "Re-attaching compositables must be explicitly authorised");
@@ -252,20 +259,22 @@ public:
   }
   // Detach this compositable host from its layer.
   // If we are used for async video, then it is not safe to blindly detach since
   // we might be re-attached to a different layer. aLayer is the layer which the
   // caller expects us to be attached to, we will only detach if we are in fact
   // attached to that layer. If we are part of a normal layer, then we will be
   // detached in any case. if aLayer is null, then we will only detach if we are
   // not async.
-  void Detach(Layer* aLayer = nullptr)
+  // Only force detach if the IPDL tree is being shutdown.
+  void Detach(Layer* aLayer = nullptr, AttachFlags aFlags = NO_FLAGS)
   {
     if (!mKeepAttached ||
-        aLayer == mLayer) {
+        aLayer == mLayer ||
+        aFlags & FORCE_DETACH) {
       SetLayer(nullptr);
       SetCompositor(nullptr);
       mAttached = false;
       mKeepAttached = false;
       if (mBackendData) {
         mBackendData->ClearData();
       }
     }
--- a/gfx/layers/composite/ContentHost.cpp
+++ b/gfx/layers/composite/ContentHost.cpp
@@ -48,16 +48,33 @@ ContentHostBase::DestroyFrontHost()
              "We won't be able to destroy our SurfaceDescriptor");
   MOZ_ASSERT(!mDeprecatedTextureHostOnWhite || mDeprecatedTextureHostOnWhite->GetDeAllocator(),
              "We won't be able to destroy our SurfaceDescriptor");
   mDeprecatedTextureHost = nullptr;
   mDeprecatedTextureHostOnWhite = nullptr;
 }
 
 void
+ContentHostBase::OnActorDestroy()
+{
+  if (mDeprecatedTextureHost) {
+    mDeprecatedTextureHost->OnActorDestroy();
+  }
+  if (mDeprecatedTextureHostOnWhite) {
+    mDeprecatedTextureHostOnWhite->OnActorDestroy();
+  }
+  if (mNewFrontHost) {
+    mNewFrontHost->OnActorDestroy();
+  }
+  if (mNewFrontHostOnWhite) {
+    mNewFrontHostOnWhite->OnActorDestroy();
+  }
+}
+
+void
 ContentHostBase::Composite(EffectChain& aEffectChain,
                            float aOpacity,
                            const gfx::Matrix4x4& aTransform,
                            const Filter& aFilter,
                            const Rect& aClipRect,
                            const nsIntRegion* aVisibleRegion,
                            TiledLayerProperties* aLayerProperties)
 {
@@ -404,39 +421,59 @@ ContentHostDoubleBuffered::EnsureDepreca
 void
 ContentHostDoubleBuffered::DestroyTextures()
 {
   if (mNewFrontHost) {
     MOZ_ASSERT(mNewFrontHost->GetDeAllocator(),
                "We won't be able to destroy our SurfaceDescriptor");
     mNewFrontHost = nullptr;
   }
-
   if (mNewFrontHostOnWhite) {
     MOZ_ASSERT(mNewFrontHostOnWhite->GetDeAllocator(),
                "We won't be able to destroy our SurfaceDescriptor");
     mNewFrontHostOnWhite = nullptr;
   }
-
   if (mBackHost) {
     MOZ_ASSERT(mBackHost->GetDeAllocator(),
                "We won't be able to destroy our SurfaceDescriptor");
     mBackHost = nullptr;
   }
-
   if (mBackHostOnWhite) {
     MOZ_ASSERT(mBackHostOnWhite->GetDeAllocator(),
                "We won't be able to destroy our SurfaceDescriptor");
     mBackHostOnWhite = nullptr;
   }
 
   // don't touch mDeprecatedTextureHost, we might need it for compositing
 }
 
 void
+ContentHostDoubleBuffered::OnActorDestroy()
+{
+  if (mDeprecatedTextureHost) {
+    mDeprecatedTextureHost->OnActorDestroy();
+  }
+  if (mDeprecatedTextureHostOnWhite) {
+    mDeprecatedTextureHostOnWhite->OnActorDestroy();
+  }
+  if (mNewFrontHost) {
+    mNewFrontHost->OnActorDestroy();
+  }
+  if (mNewFrontHostOnWhite) {
+    mNewFrontHostOnWhite->OnActorDestroy();
+  }
+  if (mBackHost) {
+    mBackHost->OnActorDestroy();
+  }
+  if (mBackHostOnWhite) {
+    mBackHostOnWhite->OnActorDestroy();
+  }
+}
+
+void
 ContentHostDoubleBuffered::UpdateThebes(const ThebesBufferData& aData,
                                         const nsIntRegion& aUpdated,
                                         const nsIntRegion& aOldValidRegionBack,
                                         nsIntRegion* aUpdatedRegionBack)
 {
   if (!mDeprecatedTextureHost && !mNewFrontHost) {
     mInitialised = false;
 
--- a/gfx/layers/composite/ContentHost.h
+++ b/gfx/layers/composite/ContentHost.h
@@ -122,16 +122,18 @@ public:
   virtual DeprecatedTextureHost* GetDeprecatedTextureHost() MOZ_OVERRIDE;
 
   virtual void SetPaintWillResample(bool aResample) { mPaintWillResample = aResample; }
   // The client has destroyed its texture clients and we should destroy our
   // texture hosts and SurfaceDescriptors. Note that we don't immediately
   // destroy our front buffer so that we can continue to composite.
   virtual void DestroyTextures() = 0;
 
+  virtual void OnActorDestroy() MOZ_OVERRIDE;
+
 protected:
   virtual nsIntPoint GetOriginOffset()
   {
     return mBufferRect.TopLeft() - mBufferRotation;
   }
 
   bool PaintWillResample() { return mPaintWillResample; }
 
@@ -172,16 +174,18 @@ public:
                             nsIntRegion* aUpdatedRegionBack);
 
   virtual void EnsureDeprecatedTextureHost(TextureIdentifier aTextureId,
                                  const SurfaceDescriptor& aSurface,
                                  ISurfaceAllocator* aAllocator,
                                  const TextureInfo& aTextureInfo) MOZ_OVERRIDE;
   virtual void DestroyTextures() MOZ_OVERRIDE;
 
+  virtual void OnActorDestroy() MOZ_OVERRIDE;
+
 #ifdef MOZ_DUMP_PAINTING
   virtual void Dump(FILE* aFile=nullptr,
                     const char* aPrefix="",
                     bool aDumpHtml=false) MOZ_OVERRIDE;
 #endif
 
   virtual void PrintInfo(nsACString& aTo, const char* aPrefix);
 protected:
--- a/gfx/layers/composite/ImageHost.h
+++ b/gfx/layers/composite/ImageHost.h
@@ -63,16 +63,23 @@ public:
   virtual void SetPictureRect(const nsIntRect& aPictureRect) MOZ_OVERRIDE
   {
     mPictureRect = aPictureRect;
     mHasPictureRect = true;
   }
 
   virtual LayerRenderState GetRenderState() MOZ_OVERRIDE;
 
+  virtual void OnActorDestroy() MOZ_OVERRIDE
+  {
+    if (mFrontBuffer) {
+      mFrontBuffer->OnActorDestroy();
+    }
+  }
+
   virtual void PrintInfo(nsACString& aTo, const char* aPrefix);
 
 #ifdef MOZ_DUMP_PAINTING
   virtual void Dump(FILE* aFile=NULL,
                     const char* aPrefix="",
                     bool aDumpHtml=false) MOZ_OVERRIDE;
 
   virtual already_AddRefed<gfxImageSurface> GetAsSurface() MOZ_OVERRIDE;
@@ -123,16 +130,23 @@ public:
     mPictureRect = aPictureRect;
     mHasPictureRect = true;
   }
 
   virtual LayerRenderState GetRenderState() MOZ_OVERRIDE;
 
   virtual void SetCompositor(Compositor* aCompositor) MOZ_OVERRIDE;
 
+  virtual void OnActorDestroy() MOZ_OVERRIDE
+  {
+    if (mDeprecatedTextureHost) {
+      mDeprecatedTextureHost->OnActorDestroy();
+    }
+  }
+
   virtual void PrintInfo(nsACString& aTo, const char* aPrefix);
 
 #ifdef MOZ_DUMP_PAINTING
   virtual void Dump(FILE* aFile=nullptr,
                     const char* aPrefix="",
                     bool aDumpHtml=false) MOZ_OVERRIDE;
 
   virtual already_AddRefed<gfxImageSurface> GetAsSurface() MOZ_OVERRIDE;
--- a/gfx/layers/composite/TextureHost.cpp
+++ b/gfx/layers/composite/TextureHost.cpp
@@ -238,16 +238,25 @@ DeprecatedTextureHost::SwapTextures(cons
   // register the TextureHost with the GrallocBufferActor.
   // The reason why this SetBuffer calls is needed here is that just above we
   // overwrote *mBuffer in place, so we need to tell the new mBuffer about this
   // TextureHost.
   SetBuffer(mBuffer, mDeAllocator);
 }
 
 void
+DeprecatedTextureHost::OnActorDestroy()
+{
+  if (ISurfaceAllocator::IsShmem(mBuffer)) {
+    *mBuffer = SurfaceDescriptor();
+    mBuffer = nullptr;
+  }
+}
+
+void
 DeprecatedTextureHost::PrintInfo(nsACString& aTo, const char* aPrefix)
 {
   aTo += aPrefix;
   aTo += nsPrintfCString("%s (0x%p)", Name(), this);
   AppendToString(aTo, GetSize(), " [size=", "]");
   AppendToString(aTo, GetFormat(), " [format=", "]");
   AppendToString(aTo, mFlags, " [flags=", "]");
 }
@@ -501,16 +510,23 @@ ShmemTextureHost::DeallocateSharedData()
 {
   if (mShmem) {
     MOZ_ASSERT(mDeallocator,
                "Shared memory would leak without a ISurfaceAllocator");
     mDeallocator->DeallocShmem(*mShmem);
   }
 }
 
+void
+ShmemTextureHost::OnActorDestroy()
+{
+  delete mShmem;
+  mShmem = nullptr;
+}
+
 uint8_t* ShmemTextureHost::GetBuffer()
 {
   return mShmem ? mShmem->get<uint8_t>() : nullptr;
 }
 
 MemoryTextureHost::MemoryTextureHost(uint64_t aID,
                                      uint8_t* aBuffer,
                                      gfx::SurfaceFormat aFormat,
--- a/gfx/layers/composite/TextureHost.h
+++ b/gfx/layers/composite/TextureHost.h
@@ -379,16 +379,20 @@ public:
   {
     // By default we return an empty render state, this should be overridden
     // by the TextureHost implementations that are used on B2G with Composer2D
     return LayerRenderState();
   }
 
   virtual void SetCompositableBackendSpecificData(CompositableBackendSpecificData* aBackendData);
 
+  // If a texture host holds a reference to shmem, it should override this method
+  // to forget about the shmem _without_ releasing it.
+  virtual void OnActorDestroy() {}
+
   virtual const char *Name() { return "TextureHost"; }
   virtual void PrintInfo(nsACString& aTo, const char* aPrefix);
 
 protected:
   uint64_t mID;
   RefPtr<TextureHost> mNextTexture;
   TextureFlags mFlags;
   RefPtr<CompositableBackendSpecificData> mCompositableBackendData;
@@ -475,16 +479,18 @@ public:
   ~ShmemTextureHost();
 
   virtual void DeallocateSharedData() MOZ_OVERRIDE;
 
   virtual uint8_t* GetBuffer() MOZ_OVERRIDE;
 
   virtual const char *Name() MOZ_OVERRIDE { return "ShmemTextureHost"; }
 
+  virtual void OnActorDestroy() MOZ_OVERRIDE;
+
 protected:
   mozilla::ipc::Shmem* mShmem;
   ISurfaceAllocator* mDeallocator;
 };
 
 /**
  * TextureHost that wraps raw memory.
  * The corresponding texture on the client side is MemoryTextureClient.
@@ -705,16 +711,18 @@ public:
     mBuffer = aBuffer;
     mDeAllocator = aAllocator;
   }
 
   // used only for hacky fix in gecko 23 for bug 862324
   // see bug 865908 about fixing this.
   virtual void ForgetBuffer() {}
 
+  void OnActorDestroy();
+
 protected:
   /**
    * Should be implemented by the backend-specific DeprecatedTextureHost classes
    *
    * It should not take a reference to aImage, unless it knows the data
    * to be thread-safe.
    */
   virtual void UpdateImpl(const SurfaceDescriptor& aImage,
--- a/gfx/layers/composite/TiledContentHost.h
+++ b/gfx/layers/composite/TiledContentHost.h
@@ -114,16 +114,26 @@ public:
   // by the sum of the resolutions of all parent layers' FrameMetrics.
   const gfxSize& GetFrameResolution() { return mFrameResolution; }
 
   void SetCompositor(Compositor* aCompositor)
   {
     mCompositor = aCompositor;
   }
 
+  void OnActorDestroy()
+  {
+    Iterator end = TilesEnd();
+    for (Iterator it = TilesBegin(); it != end; ++it) {
+      if (it->mDeprecatedTextureHost) {
+        it->mDeprecatedTextureHost->OnActorDestroy();
+      }
+    }
+  }
+
 protected:
   TiledTexture ValidateTile(TiledTexture aTile,
                             const nsIntPoint& aTileRect,
                             const nsIntRegion& dirtyRect);
 
   // do nothing, the desctructor in the texture host takes care of releasing resources
   void ReleaseTile(TiledTexture aTile) {}
 
@@ -234,16 +244,22 @@ public:
     mVideoMemoryTiledBuffer.SetCompositor(aCompositor);
     mLowPrecisionVideoMemoryTiledBuffer.SetCompositor(aCompositor);
   }
 
   virtual void Attach(Layer* aLayer,
                       Compositor* aCompositor,
                       AttachFlags aFlags = NO_FLAGS) MOZ_OVERRIDE;
 
+  virtual void OnActorDestroy() MOZ_OVERRIDE
+  {
+    mVideoMemoryTiledBuffer.OnActorDestroy();
+    mLowPrecisionVideoMemoryTiledBuffer.OnActorDestroy();
+  }
+
 #ifdef MOZ_DUMP_PAINTING
   virtual void Dump(FILE* aFile=nullptr,
                     const char* aPrefix="",
                     bool aDumpHtml=false) MOZ_OVERRIDE;
 #endif
 
   virtual void PrintInfo(nsACString& aTo, const char* aPrefix);
 
--- a/gfx/layers/ipc/ISurfaceAllocator.cpp
+++ b/gfx/layers/ipc/ISurfaceAllocator.cpp
@@ -107,16 +107,23 @@ ISurfaceAllocator::AllocSurfaceDescripto
                                getter_AddRefs(buffer))) {
     return false;
   }
 
   *aBuffer = buffer->GetShmem();
   return true;
 }
 
+/* static */ bool
+ISurfaceAllocator::IsShmem(SurfaceDescriptor* aSurface)
+{
+  return aSurface && (aSurface->type() == SurfaceDescriptor::TShmem ||
+                      aSurface->type() == SurfaceDescriptor::TYCbCrImage ||
+                      aSurface->type() == SurfaceDescriptor::TRGBImage);
+}
 
 void
 ISurfaceAllocator::DestroySharedSurface(SurfaceDescriptor* aSurface)
 {
   MOZ_ASSERT(aSurface);
   if (!aSurface) {
     return;
   }
--- a/gfx/layers/ipc/ISurfaceAllocator.h
+++ b/gfx/layers/ipc/ISurfaceAllocator.h
@@ -118,16 +118,20 @@ ISurfaceAllocator() {}
   // method that does the actual allocation work
   virtual PGrallocBufferChild* AllocGrallocBuffer(const gfxIntSize& aSize,
                                                   uint32_t aFormat,
                                                   uint32_t aUsage,
                                                   MaybeMagicGrallocBufferHandle* aHandle)
   {
     return nullptr;
   }
+
+  // Returns true if aSurface wraps a Shmem.
+  static bool IsShmem(SurfaceDescriptor* aSurface);
+
 protected:
   // this method is needed for a temporary fix, will be removed after
   // DeprecatedTextureClient/Host rework.
   virtual bool IsOnCompositorSide() const = 0;
   static bool PlatformDestroySharedSurface(SurfaceDescriptor* aSurface);
   virtual bool PlatformAllocSurfaceDescriptor(const gfxIntSize& aSize,
                                               gfxContentType aContent,
                                               uint32_t aCaps,
--- a/gfx/layers/ipc/ShadowLayerUtilsGralloc.cpp
+++ b/gfx/layers/ipc/ShadowLayerUtilsGralloc.cpp
@@ -381,19 +381,16 @@ ISurfaceAllocator::PlatformAllocSurfaceD
 
   if (!checkedDevice) {
     char propValue[PROPERTY_VALUE_MAX];
     property_get("ro.product.device", propValue, "None");
 
     if (strcmp("crespo",propValue) == 0) {
       NS_WARNING("Nexus S has issues with gralloc, falling back to shmem");
       disableGralloc = true;
-    } else if (strcmp("peak", propValue) == 0) {
-      NS_WARNING("Geeksphone Peak has issues with gralloc, falling back to shmem");
-      disableGralloc = true;
     }
 
     checkedDevice = true;
   }
 
   if (disableGralloc) {
     return false;
   }
--- a/gfx/layers/moz.build
+++ b/gfx/layers/moz.build
@@ -1,16 +1,14 @@
 # -*- 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/.
 
-MODULE = 'thebes'
-
 EXPORTS += [
     'basic/BasicCanvasLayer.h',
     'basic/BasicImplData.h',
     'basic/BasicLayers.h',
     'basic/BasicLayersImpl.h',
     'basic/BasicThebesLayer.h',
     'client/ClientCanvasLayer.h',
     'client/ClientContainerLayer.h',
@@ -292,16 +290,13 @@ IPDL_SOURCES = [
     'ipc/PCompositable.ipdl',
     'ipc/PCompositor.ipdl',
     'ipc/PGrallocBuffer.ipdl',
     'ipc/PImageBridge.ipdl',
     'ipc/PLayer.ipdl',
     'ipc/PLayerTransaction.ipdl',
 ]
 
-LIBXUL_LIBRARY = True
-
 MSVC_ENABLE_PGO = True
 
-LIBRARY_NAME = 'layers'
-
 include('/ipc/chromium/chromium-config.mozbuild')
 
+FINAL_LIBRARY = 'thebes'
--- a/gfx/layers/opengl/TextureHostOGL.cpp
+++ b/gfx/layers/opengl/TextureHostOGL.cpp
@@ -295,20 +295,18 @@ TextureImageTextureSourceOGL::BindTextur
 }
 
 SharedTextureSourceOGL::SharedTextureSourceOGL(CompositorOGL* aCompositor,
                                                gl::SharedTextureHandle aHandle,
                                                gfx::SurfaceFormat aFormat,
                                                GLenum aTarget,
                                                GLenum aWrapMode,
                                                SharedTextureShareType aShareType,
-                                               gfx::IntSize aSize,
-                                               const gfx3DMatrix& aTexTransform)
-  : mTextureTransform(aTexTransform)
-  , mSize(aSize)
+                                               gfx::IntSize aSize)
+  : mSize(aSize)
   , mCompositor(aCompositor)
   , mSharedHandle(aHandle)
   , mFormat(aFormat)
   , mShareType(aShareType)
   , mTextureTarget(aTarget)
   , mWrapMode(aWrapMode)
 {}
 
@@ -352,16 +350,28 @@ SharedTextureSourceOGL::IsValid() const
 }
 
 gl::GLContext*
 SharedTextureSourceOGL::gl() const
 {
   return mCompositor ? mCompositor->gl() : nullptr;
 }
 
+gfx3DMatrix
+SharedTextureSourceOGL::GetTextureTransform()
+{
+  GLContext::SharedHandleDetails handleDetails;
+  if (!gl()->GetSharedHandleDetails(mShareType, mSharedHandle, handleDetails)) {
+    NS_WARNING("Could not get shared handle details");
+    return gfx3DMatrix();
+  }
+
+  return handleDetails.mTextureTransform;
+}
+
 SharedTextureHostOGL::SharedTextureHostOGL(uint64_t aID,
                                            TextureFlags aFlags,
                                            gl::SharedTextureShareType aShareType,
                                            gl::SharedTextureHandle aSharedHandle,
                                            gfx::IntSize aSize,
                                            bool inverted)
   : TextureHost(aID, aFlags)
   , mSize(aSize)
@@ -401,18 +411,17 @@ SharedTextureHostOGL::Lock()
 
     GLenum wrapMode = LOCAL_GL_CLAMP_TO_EDGE;
     mTextureSource = new SharedTextureSourceOGL(mCompositor,
                                                 mSharedHandle,
                                                 handleDetails.mTextureFormat,
                                                 handleDetails.mTarget,
                                                 wrapMode,
                                                 mShareType,
-                                                mSize,
-                                                handleDetails.mTextureTransform);
+                                                mSize);
   }
   return true;
 }
 
 void
 SharedTextureHostOGL::Unlock()
 {
   if (!mTextureSource) {
--- a/gfx/layers/opengl/TextureHostOGL.h
+++ b/gfx/layers/opengl/TextureHostOGL.h
@@ -246,30 +246,29 @@ public:
   typedef gl::SharedTextureShareType SharedTextureShareType;
 
   SharedTextureSourceOGL(CompositorOGL* aCompositor,
                          gl::SharedTextureHandle aHandle,
                          gfx::SurfaceFormat aFormat,
                          GLenum aTarget,
                          GLenum aWrapMode,
                          SharedTextureShareType aShareType,
-                         gfx::IntSize aSize,
-                         const gfx3DMatrix& aTexTransform);
+                         gfx::IntSize aSize);
 
   virtual TextureSourceOGL* AsSourceOGL() { return this; }
 
   virtual void BindTexture(GLenum activetex) MOZ_OVERRIDE;
 
   virtual bool IsValid() const MOZ_OVERRIDE;
 
   virtual gfx::IntSize GetSize() const MOZ_OVERRIDE { return mSize; }
 
   virtual gfx::SurfaceFormat GetFormat() const MOZ_OVERRIDE { return mFormat; }
 
-  virtual gfx3DMatrix GetTextureTransform() MOZ_OVERRIDE { return mTextureTransform; }
+  virtual gfx3DMatrix GetTextureTransform() MOZ_OVERRIDE;
 
   virtual GLenum GetTextureTarget() const { return mTextureTarget; }
 
   virtual GLenum GetWrapMode() const MOZ_OVERRIDE { return mWrapMode; }
 
   virtual void UnbindTexture() MOZ_OVERRIDE {}
 
   // SharedTextureSource doesn't own any gl texture
@@ -277,17 +276,16 @@ public:
 
   void DetachSharedHandle();
 
   void SetCompositor(CompositorOGL* aCompositor);
 
   gl::GLContext* gl() const;
 
 protected:
-  gfx3DMatrix mTextureTransform;
   gfx::IntSize mSize;
   CompositorOGL* mCompositor;
   gl::SharedTextureHandle mSharedHandle;
   gfx::SurfaceFormat mFormat;
   SharedTextureShareType mShareType;
   GLenum mTextureTarget;
   GLenum mWrapMode;
 };
--- a/gfx/moz.build
+++ b/gfx/moz.build
@@ -25,10 +25,8 @@ DIRS += [
 if CONFIG['MOZ_ENABLE_SKIA']:
     DIRS += ['skia']
 
 if CONFIG['ENABLE_TESTS']:
     DIRS += ['tests/gtest']
 
 TEST_TOOL_DIRS += ['tests']
 
-MODULE = 'gfx'
-