merge mozilla-inbound to mozilla-central a=merge
authorCarsten "Tomcat" Book <cbook@mozilla.com>
Wed, 08 Mar 2017 16:59:42 +0100
changeset 495323 800ba54a4bd52628833c4db005ddd182586666c4
parent 495312 000054adb7fb59778459785833445ebc7e105688 (current diff)
parent 495322 791a43e25a1e56bfad5a062bd7f94a6d2f0957d5 (diff)
child 495324 875d605cac00841a88201c7dfd07765a39dd09da
child 495326 c291ce76e4d437c0d36a103023415ed0b29e204f
child 495343 6964fbecaacc7ea2af787b2c2157e22eb53c678d
child 495364 075480742a749f689f019288638ffe002a50749b
child 495370 46f86d6a6acabc501f8591bbd0da0e2a4d7d67cd
child 495395 ee2f6dce9f6179cb012e3a8f03af9591db2d476d
child 495399 8e22b431625f038c483da22479a28c00b18e16d9
child 495400 f7dd2411d9383e28bc50f488d12299fbabf8cb4e
child 495403 edd9c36577ef970e16e4efa3ac9d6935ef063ac7
child 495406 d699d14bca611f42da81297d56342fabd917d820
child 495408 5cb0a545c32db556eb89eb3ba490fb642024bb84
child 495413 cfdc21515b29190d9585e4baf990412c1b9ccc84
child 495420 4466e47a4ad73ac9fbbb08558641ed0cc60b200b
child 495425 3c115925e31804d60d718dec218b572ba716dfb6
child 495442 b3f7794c6712af3252bac58c88e0a9d73f14e1f9
child 495454 791151895f73ad006b826f3867c05dd4b51e9ee2
child 495485 f76993ad97b7de99c8572879abee94d989709026
child 495529 f4eb0ddc4e16712dfac3085b3e5948b5c9ab0657
child 495537 5a4f04e4e19d251db2129dabc92eee060c30338d
child 495544 2067dcfd8c12fe83a7bc0ec45dd9becd5384ea26
child 495567 bd5fe830e8d404191addd383457b97f5a611c3cc
child 495573 3348b42783f210bd0002db3d34c4a4bebd90ebf5
child 495579 6633d37aa7b6fdfb5d322e44df5cda5ad4aa008b
child 495581 e1cd6acdb3e303745fa1b72b3bf0013b30db659b
child 495607 b5cb7a7f8ec4725cee144f6b028805de250dd0d8
child 495634 76f6f17e15429daaa28af43d7daf070ec059f996
child 495853 9a00834599e546d17259ce72c6ce91af8d7bfd3d
child 495898 dd4a814f344473ac1e2d43cdb3dd4aacc634eddf
child 496706 f389a6b125fc3e689f0c17ede63c0e97932323a3
child 496728 edd6df8166d9a118fb877fe2910d141c9b98c8c8
child 496729 bfa78c1579cf8e38718f942f9f28eb20c54e0ce4
child 496799 728b4f4df6e176778c455dfbc861f338f6556bd9
child 496801 0c1559d0d2ccac3000a9060b55616926351b8738
child 496848 a6f4fd2b3fc0ef2c829a5c7d5e5a3d89820d40b8
child 496871 e4dfccd0170f42ffbf837972f2d44c512f60bee3
child 496882 53ff9a889bb77eda1b12b611de36a715eaa95de6
child 496896 e6106c2dbdd84c4ea5c775acf5cfce346663c0ff
child 496920 ec81354ece1e07ab1d586a81943577602acedbd5
child 497243 cd78078e728773bb1d5a4af6a29c9b329de95850
child 497688 ddf0b4009b102912b97a81216ad8579059f6796d
child 497818 3c7edc4ce445814a4b04fad63202a857976dae37
child 497863 6457443d26ae33fc39e33966da751752561c197c
child 497867 b9e7085839fd3eae2a8e0cc58027245740979a66
child 498476 0de15238047c7fa6411711632d0784678c1f3a92
child 501605 528a28602c5b7513cb99df237165625d17666e66
child 558457 3b54320922cf8239b0fa24b7f4b9bf0d0e638f6b
push id48284
push userjichen@mozilla.com
push dateWed, 08 Mar 2017 16:05:19 +0000
reviewersmerge
milestone55.0a1
merge mozilla-inbound to mozilla-central a=merge
dom/canvas/WebGLElementArrayCache.cpp
dom/canvas/WebGLElementArrayCache.h
dom/canvas/gtest/TestWebGLElementArrayCache.cpp
gfx/layers/d3d9/CompositorD3D9.cpp
gfx/layers/d3d9/CompositorD3D9.h
gfx/layers/d3d9/DeviceManagerD3D9.cpp
gfx/layers/d3d9/DeviceManagerD3D9.h
gfx/layers/d3d9/LayerManagerD3D9Shaders.h
gfx/layers/d3d9/LayerManagerD3D9Shaders.hlsl
gfx/layers/d3d9/Nv3DVUtils.cpp
gfx/layers/d3d9/Nv3DVUtils.h
gfx/layers/d3d9/ReadbackLayerD3D9.h
gfx/layers/d3d9/TextureD3D9.cpp
gfx/layers/d3d9/TextureD3D9.h
gfx/layers/d3d9/genshaders.sh
testing/mozharness/configs/single_locale/release_mozilla-beta_android_api_15.py
testing/mozharness/configs/single_locale/release_mozilla-release_android_api_15.py
testing/web-platform/meta/html/browsers/origin/cross-origin-objects/cross-origin-objects.html.ini
widget/gtk/nsWindow.cpp
--- a/accessible/aom/AccessibleNode.cpp
+++ b/accessible/aom/AccessibleNode.cpp
@@ -149,25 +149,27 @@ AccessibleNode::Has(const Sequence<nsStr
 
 void
 AccessibleNode::Get(JSContext* aCX, const nsAString& aAttribute,
                     JS::MutableHandle<JS::Value> aValue,
                     ErrorResult& aRv)
 {
   if (!mIntl) {
     aRv.Throw(NS_ERROR_DOM_INVALID_STATE_ERR);
+    return;
   }
 
   nsCOMPtr<nsIPersistentProperties> attrs = mIntl->Attributes();
   nsAutoString value;
   attrs->GetStringProperty(NS_ConvertUTF16toUTF8(aAttribute), value);
 
   JS::Rooted<JS::Value> jsval(aCX);
   if (!ToJSValue(aCX, value, &jsval)) {
     aRv.Throw(NS_ERROR_UNEXPECTED);
+    return;
   }
 
   aValue.set(jsval);
 }
 
 nsINode*
 AccessibleNode::GetDOMNode()
 {
--- a/accessible/tests/browser/e10s/browser_caching_name.js
+++ b/accessible/tests/browser/e10s/browser_caching_name.js
@@ -387,17 +387,17 @@ function* testElmRule(browser, target, r
  * @param {[type]} expected     expected name value
  */
 function* testSubtreeRule(browser, target, rule, expected) {
   testName(target.acc, expected);
   let onEvent = waitForEvent(EVENT_REORDER, target.id);
   yield ContentTask.spawn(browser, target.id, id => {
     let elm = content.document.getElementById(id);
     while (elm.firstChild) {
-      elm.removeChild(elm.firstChild);
+      elm.firstChild.remove();
     }
   });
   yield updateAccessibleIfNeeded(onEvent, target);
 }
 
 /**
  * Iterate over a list of rules and test accessible names for each one of the
  * rules.
--- a/accessible/tests/browser/e10s/browser_treeupdate_doc.js
+++ b/accessible/tests/browser/e10s/browser_treeupdate_doc.js
@@ -152,17 +152,17 @@ addAccessibleTask(`
   };
   testAccessibleTree(iframe, tree);
 
   /* ================= Remove HTML from iframe document ===================== */
   reorderEventPromise = waitForEvent(EVENT_REORDER, iframe);
   yield ContentTask.spawn(browser, {}, () => {
     // Remove HTML element.
     let docNode = content.document.getElementById('iframe').contentDocument;
-    docNode.removeChild(docNode.firstChild);
+    docNode.firstChild.remove();
   });
   let event = yield reorderEventPromise;
 
   ok(event.accessible instanceof nsIAccessibleDocument,
     'Reorder should happen on the document');
   tree = {
     role: ROLE_DOCUMENT,
     children: [ ]
@@ -230,17 +230,17 @@ addAccessibleTask(`
   };
   testAccessibleTree(iframe, tree);
 
   reorderEventPromise = waitForEvent(EVENT_REORDER, iframe);
   yield ContentTask.spawn(browser, {}, () => {
     let docEl =
       content.document.getElementById('iframe').contentDocument.documentElement;
     // Remove aftermath of this test before next test starts.
-    docEl.removeChild(docEl.firstChild);
+    docEl.firstChild.remove();
   });
   // Make sure reorder event was fired and that the input was removed.
   yield reorderEventPromise;
   tree = {
     role: ROLE_DOCUMENT,
     children: [ ]
   };
   testAccessibleTree(iframe, tree);
--- a/accessible/tests/browser/e10s/browser_treeupdate_optgroup.js
+++ b/accessible/tests/browser/e10s/browser_treeupdate_optgroup.js
@@ -51,17 +51,17 @@ addAccessibleTask('<select id="select"><
   };
   testAccessibleTree(select, tree);
   ok(!isDefunct(option1Node), 'option shouldn\'t be defunct');
 
   onEvent = waitForEvent(EVENT_REORDER, 'select');
   // Remove grouping from combobox
   yield ContentTask.spawn(browser, {}, () => {
     let contentSelect = content.document.getElementById('select');
-    contentSelect.removeChild(contentSelect.firstChild);
+    contentSelect.firstChild.remove();
   });
   yield onEvent;
 
   tree = {
     COMBOBOX: [ {
       COMBOBOX_LIST: [
         { COMBOBOX_OPTION: [] },
         { COMBOBOX_OPTION: [] }
--- a/accessible/tests/mochitest/events/test_mutation.html
+++ b/accessible/tests/mochitest/events/test_mutation.html
@@ -409,18 +409,18 @@
       ];
 
       this.invoke = function hideHideNDestroyDoc_invoke()
       {
         var doc = getAccessible('c6').firstChild;
         var l1 = doc.firstChild;
         this.target = l1.firstChild;
         var l2 = doc.lastChild;
-        l1.DOMNode.removeChild(l1.DOMNode.firstChild);
-        l2.DOMNode.removeChild(l2.DOMNode.firstChild);
+        l1.DOMNode.firstChild.remove();
+        l2.DOMNode.firstChild.remove();
       }
 
       this.check = function hideHideNDestroyDoc_check()
       {
         getNode('c6').remove();
       }
 
       this.getID = function hideHideNDestroyDoc_getID()
--- a/accessible/tests/mochitest/events/test_text.html
+++ b/accessible/tests/mochitest/events/test_text.html
@@ -46,17 +46,17 @@
      */
     function removeChildSpan(aID)
     {
       this.__proto__ = new textRemoveInvoker(aID, 0, 5, "33322");
 
       this.invoke = function removeChildSpan_invoke()
       {
         // remove HTML span, a first child of the node
-        this.DOMNode.removeChild(this.DOMNode.firstChild);
+        this.DOMNode.firstChild.remove();
       }
 
       this.getID = function removeChildSpan_getID()
       {
         return "Remove inaccessible span containing accessible nodes" + prettyName(aID);
       }
     }
 
@@ -157,17 +157,17 @@
 
       this.invoke = function removeChildren_invoke()
       {
         if (aLastToFirst) {
           while (this.DOMNode.firstChild)
             this.DOMNode.removeChild(this.DOMNode.lastChild);
         } else {
           while (this.DOMNode.firstChild)
-            this.DOMNode.removeChild(this.DOMNode.firstChild);
+            this.DOMNode.firstChild.remove();
         }
       }
 
       this.getID = function removeChildren_getID()
       {
         return "remove children of " + prettyName(aID) +
           (aLastToFirst ? " from last to first" : " from first to last");
       }
--- a/accessible/tests/mochitest/name/markup.js
+++ b/accessible/tests/mochitest/name/markup.js
@@ -311,17 +311,17 @@ function testNameForSubtreeRule(aElm, aR
 
   if (gDumpToConsole) {
     dump("\nProcessed from subtree rule. Wait for reorder event on " +
          prettyName(aElm) + "\n");
   }
   waitForEvent(EVENT_REORDER, aElm, gTestIterator.iterateNext, gTestIterator);
 
   while (aElm.firstChild)
-    aElm.removeChild(aElm.firstChild);
+    aElm.firstChild.remove();
 }
 
 /**
  * Return array of 'rule' elements. Used in conjunction with
  * getRuleElmsFromRulesetElm() function.
  */
 function getRuleElmsByRulesetId(aRulesetId)
 {
--- a/accessible/tests/mochitest/treeupdate/test_doc.html
+++ b/accessible/tests/mochitest/treeupdate/test_doc.html
@@ -261,17 +261,17 @@
       this.__proto__ = new rootContentRemoved(aID);
 
       this.invoke = function removeHTMLFromIFrameDoc_invoke()
       {
         this.preinvoke();
 
         // Remove HTML element.
         var docNode = getDocNode(aID);
-        docNode.removeChild(docNode.firstChild);
+        docNode.firstChild.remove();
       }
 
       this.getID = function removeHTMLFromIFrameDoc_getID()
       {
         return "remove HTML element";
       }
     }
 
--- a/accessible/tests/mochitest/treeupdate/test_general.html
+++ b/accessible/tests/mochitest/treeupdate/test_general.html
@@ -59,17 +59,17 @@
     function removeRemove(aContainer)
     {
       this.eventSeq = [
         new invokerChecker(EVENT_REORDER, aContainer)
       ];
 
       this.invoke = function removeRemove_invoke()
       {
-        getNode(aContainer).removeChild(getNode(aContainer).firstChild);
+        getNode(aContainer).firstChild.remove();
       }
 
       this.finalCheck = function removeRemove_finalCheck()
       {
         var accTree =
           { SECTION: [ // container
             { PUSHBUTTON: [ ] }
           ] };
--- a/accessible/tests/mochitest/treeupdate/test_optgroup.html
+++ b/accessible/tests/mochitest/treeupdate/test_optgroup.html
@@ -72,17 +72,17 @@
     {
       this.selectNode = getNode(aID);
       this.select = getAccessible(this.selectNode);
       this.selectList = this.select.firstChild;
 
       this.invoke = function removeOptGroup_invoke()
       {
         this.option1Node = this.selectNode.firstChild.firstChild;
-        this.selectNode.removeChild(this.selectNode.firstChild);
+        this.selectNode.firstChild.remove();
       }
 
       this.eventSeq = [
         new invokerChecker(EVENT_REORDER, this.selectList)
       ];
 
       this.finalCheck = function removeOptGroup_finalCheck()
       {
--- a/browser/base/content/browser-ctrlTab.js
+++ b/browser/base/content/browser-ctrlTab.js
@@ -236,17 +236,17 @@ var ctrlTab = {
 
   updatePreview: function ctrlTab_updatePreview(aPreview, aTab) {
     if (aPreview == this.showAllButton)
       return;
 
     aPreview._tab = aTab;
 
     if (aPreview.firstChild)
-      aPreview.removeChild(aPreview.firstChild);
+      aPreview.firstChild.remove();
     if (aTab) {
       let canvasWidth = this.canvasWidth;
       let canvasHeight = this.canvasHeight;
       aPreview.appendChild(tabPreviews.get(aTab));
       aPreview.setAttribute("label", aTab.label);
       aPreview.setAttribute("tooltiptext", aTab.label);
       aPreview.setAttribute("canvaswidth", canvasWidth);
       aPreview.setAttribute("canvasstyle",
--- a/browser/base/content/browser-fxaccounts.js
+++ b/browser/base/content/browser-fxaccounts.js
@@ -325,17 +325,17 @@ var gFxAccounts = {
 
   sendTabToDevice(url, clientId, title) {
     Weave.Service.clientsEngine.sendURIToClientForDisplay(url, clientId, title);
   },
 
   populateSendTabToDevicesMenu(devicesPopup, url, title) {
     // remove existing menu items
     while (devicesPopup.hasChildNodes()) {
-      devicesPopup.removeChild(devicesPopup.firstChild);
+      devicesPopup.firstChild.remove();
     }
 
     const fragment = document.createDocumentFragment();
 
     const onTargetDeviceCommand = (event) => {
       let clients = event.target.getAttribute("clientId") ?
         [event.target.getAttribute("clientId")] :
         this.remoteClients.map(client => client.id);
--- a/browser/base/content/browser-places.js
+++ b/browser/base/content/browser-places.js
@@ -741,17 +741,17 @@ HistoryMenu.prototype = {
    * Populate when the history menu is opened
    */
   populateUndoSubmenu: function PHM_populateUndoSubmenu() {
     var undoMenu = this._rootElt.getElementsByClassName("recentlyClosedTabsMenu")[0];
     var undoPopup = undoMenu.firstChild;
 
     // remove existing menu items
     while (undoPopup.hasChildNodes())
-      undoPopup.removeChild(undoPopup.firstChild);
+      undoPopup.firstChild.remove();
 
     // no restorable tabs, so make sure menu is disabled, and return
     if (this._getClosedTabCount() == 0) {
       undoMenu.setAttribute("disabled", true);
       return;
     }
 
     // enable menu
@@ -777,17 +777,17 @@ HistoryMenu.prototype = {
    * Populate when the history menu is opened
    */
   populateUndoWindowSubmenu: function PHM_populateUndoWindowSubmenu() {
     let undoMenu = this._rootElt.getElementsByClassName("recentlyClosedWindowsMenu")[0];
     let undoPopup = undoMenu.firstChild;
 
     // remove existing menu items
     while (undoPopup.hasChildNodes())
-      undoPopup.removeChild(undoPopup.firstChild);
+      undoPopup.firstChild.remove();
 
     // no restorable windows, so make sure menu is disabled, and return
     if (SessionStore.getClosedWindowCount() == 0) {
       undoMenu.setAttribute("disabled", true);
       return;
     }
 
     // enable menu
--- a/browser/base/content/pageinfo/pageInfo.js
+++ b/browser/base/content/pageinfo/pageInfo.js
@@ -413,17 +413,17 @@ function resetPageInfo(args) {
     mediaTab.hidden = true;
   }
   gImageView.clear();
   gImageHash = {};
 
   /* Reset Feeds Tab */
   var feedListbox = document.getElementById("feedListbox");
   while (feedListbox.firstChild)
-    feedListbox.removeChild(feedListbox.firstChild);
+    feedListbox.firstChild.remove();
 
   /* Call registered overlay reset functions */
   onResetRegistry.forEach(function(func) { func(); });
 
   /* Rebuild the data */
   loadTab(args);
 }
 
--- a/browser/base/content/pageinfo/security.js
+++ b/browser/base/content/pageinfo/security.js
@@ -301,17 +301,17 @@ function securityOnLoad(uri, windowInfo)
 function setText(id, value) {
   var element = document.getElementById(id);
   if (!element)
     return;
   if (element.localName == "textbox" || element.localName == "label")
     element.value = value;
   else {
     if (element.hasChildNodes())
-      element.removeChild(element.firstChild);
+      element.firstChild.remove();
     var textNode = document.createTextNode(value);
     element.appendChild(textNode);
   }
 }
 
 function viewCertHelper(parent, cert) {
   if (!cert)
     return;
--- a/browser/base/content/utilityOverlay.js
+++ b/browser/base/content/utilityOverlay.js
@@ -485,17 +485,17 @@ function checkForMiddleClick(node, event
 // Populate a menu with user-context menu items. This method should be called
 // by onpopupshowing passing the event as first argument.
 function createUserContextMenu(event, {
                                         isContextMenu = false,
                                         excludeUserContextId = 0,
                                         useAccessKeys = true
                                       } = {}) {
   while (event.target.hasChildNodes()) {
-    event.target.removeChild(event.target.firstChild);
+    event.target.firstChild.remove();
   }
 
   let bundle = document.getElementById("bundle_browser");
   let docfrag = document.createDocumentFragment();
 
   // If we are excluding a userContextId, we want to add a 'no-container' item.
   if (excludeUserContextId) {
     let menuitem = document.createElement("menuitem");
--- a/browser/components/customizableui/CustomizableWidgets.jsm
+++ b/browser/components/customizableui/CustomizableWidgets.jsm
@@ -239,22 +239,22 @@ const CustomizableWidgets = [
         },
         handleCompletion(aReason) {
           log.debug("History view is being shown!");
         },
       });
 
       let recentlyClosedTabs = doc.getElementById("PanelUI-recentlyClosedTabs");
       while (recentlyClosedTabs.firstChild) {
-        recentlyClosedTabs.removeChild(recentlyClosedTabs.firstChild);
+        recentlyClosedTabs.firstChild.remove();
       }
 
       let recentlyClosedWindows = doc.getElementById("PanelUI-recentlyClosedWindows");
       while (recentlyClosedWindows.firstChild) {
-        recentlyClosedWindows.removeChild(recentlyClosedWindows.firstChild);
+        recentlyClosedWindows.firstChild.remove();
       }
 
       let utils = RecentlyClosedTabsAndWindowsMenuUtils;
       let tabsFragment = utils.getTabsFragment(doc.defaultView, "toolbarbutton", true,
                                                "menuRestoreAllTabsSubview.label");
       let separator = doc.getElementById("PanelUI-recentlyClosedTabs-separator");
       let elementCount = tabsFragment.childElementCount;
       separator.hidden = !elementCount;
--- a/browser/components/customizableui/content/panelUI.js
+++ b/browser/components/customizableui/content/panelUI.js
@@ -487,17 +487,17 @@ const PanelUI = {
 
     let helpMenu = document.getElementById("menu_HelpPopup");
     let items = this.getElementsByTagName("vbox")[0];
     let attrs = ["oncommand", "onclick", "label", "key", "disabled"];
     let NSXUL = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";
 
     // Remove all buttons from the view
     while (items.firstChild) {
-      items.removeChild(items.firstChild);
+      items.firstChild.remove();
     }
 
     // Add the current set of menuitems of the Help menu to this view
     let menuItems = Array.prototype.slice.call(helpMenu.getElementsByTagName("menuitem"));
     let fragment = document.createDocumentFragment();
     for (let node of menuItems) {
       if (node.hidden)
         continue;
--- a/browser/components/feeds/FeedWriter.js
+++ b/browser/components/feeds/FeedWriter.js
@@ -168,17 +168,17 @@ FeedWriter.prototype = {
     }
     return "";
   },
 
   _setContentText(id, text) {
     let element = this._document.getElementById(id);
     let textNode = text.createDocumentFragment(element);
     while (element.hasChildNodes())
-      element.removeChild(element.firstChild);
+      element.firstChild.remove();
     element.appendChild(textNode);
     if (text.base) {
       element.setAttributeNS(XML_NS, "base", text.base.spec);
     }
   },
 
   /**
    * Safely sets the href attribute on an anchor tag, providing the URI
--- a/browser/components/migration/content/migration.js
+++ b/browser/components/migration/content/migration.js
@@ -180,17 +180,17 @@ var MigrationWizard = { /* exported Migr
   onSelectProfilePageShow() {
     // Disabling this for now, since we ask about import sources in automigration
     // too and don't want to disable the back button
     // if (this._autoMigrate)
     //   document.documentElement.getButton("back").disabled = true;
 
     var profiles = document.getElementById("profiles");
     while (profiles.hasChildNodes())
-      profiles.removeChild(profiles.firstChild);
+      profiles.firstChild.remove();
 
     // Note that this block is still reached even if the user chose 'From File'
     // and we canceled the dialog.  When that happens, _migrator will be null.
     if (this._migrator) {
       var sourceProfiles = this._migrator.sourceProfiles;
 
       for (let profile of sourceProfiles) {
         var item = document.createElement("radio");
@@ -220,17 +220,17 @@ var MigrationWizard = { /* exported Migr
     if (this._autoMigrate)
       this._wiz.currentPage.next = "homePageImport";
   },
 
   // 3 - ImportItems
   onImportItemsPageShow() {
     var dataSources = document.getElementById("dataSources");
     while (dataSources.hasChildNodes())
-      dataSources.removeChild(dataSources.firstChild);
+      dataSources.firstChild.remove();
 
     var items = this._migrator.getMigrateData(this._selectedProfile, this._autoMigrate);
     for (var i = 0; i < 16; ++i) {
       var itemID = (items >> i) & 0x1 ? Math.pow(2, i) : 0;
       if (itemID > 0) {
         var checkbox = document.createElement("checkbox");
         checkbox.id = itemID;
         checkbox.setAttribute("label",
@@ -362,17 +362,17 @@ var MigrationWizard = { /* exported Migr
         exp++;
       }
     }
   },
 
   _listItems(aID) {
     var items = document.getElementById(aID);
     while (items.hasChildNodes())
-      items.removeChild(items.firstChild);
+      items.firstChild.remove();
 
     var itemID;
     for (var i = 0; i < 16; ++i) {
       itemID = (this._itemsFlags >> i) & 0x1 ? Math.pow(2, i) : 0;
       if (itemID > 0) {
         var label = document.createElement("label");
         label.id = itemID + "_migrated";
         try {
--- a/browser/components/places/content/browserPlacesViews.js
+++ b/browser/components/places/content/browserPlacesViews.js
@@ -1006,17 +1006,17 @@ PlacesToolbar.prototype = {
   _rebuild: function PT__rebuild() {
     // Clear out references to existing nodes, since they will be removed
     // and re-added.
     if (this._overFolder.elt)
       this._clearOverFolder();
 
     this._openedMenuButton = null;
     while (this._rootElt.hasChildNodes()) {
-      this._rootElt.removeChild(this._rootElt.firstChild);
+      this._rootElt.firstChild.remove();
     }
 
     let cc = this._resultNode.childCount;
     for (let i = 0; i < cc; ++i) {
       this._insertNewItem(this._resultNode.getChild(i), null);
     }
 
     if (this._chevronPopup.hasAttribute("type")) {
@@ -1947,16 +1947,16 @@ PlacesPanelMenuView.prototype = {
 
   invalidateContainer: function PAMV_invalidateContainer(aPlacesNode) {
     let elt = this._getDOMNodeForPlacesNode(aPlacesNode);
     if (elt != this._rootElt)
       return;
 
     // Container is the toolbar itself.
     while (this._rootElt.hasChildNodes()) {
-      this._rootElt.removeChild(this._rootElt.firstChild);
+      this._rootElt.firstChild.remove();
     }
 
     for (let i = 0; i < this._resultNode.childCount; ++i) {
       this._insertNewItem(this._resultNode.getChild(i), null);
     }
   }
 };
--- a/browser/components/places/content/places.js
+++ b/browser/components/places/content/places.js
@@ -414,17 +414,17 @@ var PlacesOrganizer = {
     const locale = Cc["@mozilla.org/chrome/chrome-registry;1"]
                    .getService(Ci.nsIXULChromeRegistry)
                    .getSelectedLocale("global", true);
     const dtOptions = { year: "numeric", month: "long", day: "numeric" };
     let dateFormatter = new Intl.DateTimeFormat(locale, dtOptions);
 
     // Remove existing menu items.  Last item is the restoreFromFile item.
     while (restorePopup.childNodes.length > 1)
-      restorePopup.removeChild(restorePopup.firstChild);
+      restorePopup.firstChild.remove();
 
     Task.spawn(function* () {
       let backupFiles = yield PlacesBackups.getBackupFiles();
       if (backupFiles.length == 0)
         return;
 
       // Populate menu with backups.
       for (let i = 0; i < backupFiles.length; i++) {
@@ -1002,17 +1002,17 @@ var ViewMenu = {
         NS_ASSERT(endElement,
                   "endID does not correspond to an existing element");
       }
       while (startElement.nextSibling != endElement)
         popup.removeChild(startElement.nextSibling);
       return endElement;
     }
     while (popup.hasChildNodes()) {
-      popup.removeChild(popup.firstChild);
+      popup.firstChild.remove();
     }
     return null;
   },
 
   /**
    * Fills a menupopup with a list of columns
    * @param   event
    *          The popupshowing event that invoked this function.
--- a/browser/components/preferences/blocklists.js
+++ b/browser/components/preferences/blocklists.js
@@ -76,17 +76,17 @@ var gBlocklistManager = {
       this.uninit();
     }
 
     this._type = "tracking";
     this._brandShortName = params.brandShortName;
 
     let blocklistsText = document.getElementById("blocklistsText");
     while (blocklistsText.hasChildNodes()) {
-      blocklistsText.removeChild(blocklistsText.firstChild);
+      blocklistsText.firstChild.remove();
     }
     blocklistsText.appendChild(document.createTextNode(params.introText));
 
     document.title = params.windowTitle;
 
     this._loadBlockLists();
   },
 
--- a/browser/components/preferences/in-content/advanced.js
+++ b/browser/components/preferences/in-content/advanced.js
@@ -552,17 +552,17 @@ var gAdvancedPane = {
    * Updates the list of offline applications
    */
   updateOfflineApps() {
     var pm = Components.classes["@mozilla.org/permissionmanager;1"]
                        .getService(Components.interfaces.nsIPermissionManager);
 
     var list = document.getElementById("offlineAppsList");
     while (list.firstChild) {
-      list.removeChild(list.firstChild);
+      list.firstChild.remove();
     }
 
     var groups;
     try {
       var cacheService = Components.classes["@mozilla.org/network/application-cache-service;1"].
                          getService(Components.interfaces.nsIApplicationCacheService);
       groups = cacheService.getGroups();
     } catch (e) {
--- a/browser/components/preferences/languages.js
+++ b/browser/components/preferences/languages.js
@@ -92,17 +92,17 @@ var gLanguagesDialog = {
       }
     }
     this._buildAvailableLanguageList();
   },
 
   _buildAvailableLanguageList() {
     var availableLanguagesPopup = document.getElementById("availableLanguagesPopup");
     while (availableLanguagesPopup.hasChildNodes())
-      availableLanguagesPopup.removeChild(availableLanguagesPopup.firstChild);
+      availableLanguagesPopup.firstChild.remove();
 
     // Sort the list of languages by name
     this._availableLanguagesList.sort(function(a, b) {
                                         return a.name.localeCompare(b.name);
                                       });
 
     // Load the UI with the data
     for (var i = 0; i < this._availableLanguagesList.length; ++i) {
@@ -114,17 +114,17 @@ var gLanguagesDialog = {
         availableLanguagesPopup.appendChild(menuitem);
         menuitem.setAttribute("label", this._availableLanguagesList[i].name);
       }
     }
   },
 
   readAcceptLanguages() {
     while (this._activeLanguages.hasChildNodes())
-      this._activeLanguages.removeChild(this._activeLanguages.firstChild);
+      this._activeLanguages.firstChild.remove();
 
     var selectedIndex = 0;
     var preference = document.getElementById("intl.accept_languages");
     if (preference.value == "")
       return undefined;
     var languages = preference.value.toLowerCase().split(/\s*,\s*/);
     for (var i = 0; i < languages.length; ++i) {
       var name = this._getLanguageName(languages[i]);
--- a/browser/components/preferences/permissions.js
+++ b/browser/components/preferences/permissions.js
@@ -213,17 +213,17 @@ var gPermissionManager = {
       this.uninit();
     }
 
     this._type = aParams.permissionType;
     this._manageCapability = aParams.manageCapability;
 
     var permissionsText = document.getElementById("permissionsText");
     while (permissionsText.hasChildNodes())
-      permissionsText.removeChild(permissionsText.firstChild);
+      permissionsText.firstChild.remove();
     permissionsText.appendChild(document.createTextNode(aParams.introText));
 
     document.title = aParams.windowTitle;
 
     document.getElementById("btnBlock").hidden    = !aParams.blockVisible;
     document.getElementById("btnSession").hidden  = !aParams.sessionVisible;
     document.getElementById("btnAllow").hidden    = !aParams.allowVisible;
 
--- a/browser/components/syncedtabs/SyncedTabsDeckView.js
+++ b/browser/components/syncedtabs/SyncedTabsDeckView.js
@@ -95,17 +95,17 @@ SyncedTabsDeckView.prototype = {
         Array.prototype.map.call(this._doc.getElementsByClassName(panel.id),
                                  item => item.classList.remove("selected"));
       }
     }
   },
 
   _clearChilden() {
     while (this.container.firstChild) {
-      this.container.removeChild(this.container.firstChild);
+      this.container.firstChild.remove();
     }
   },
 
   _attachListeners() {
     this.container.querySelector(".android-link").addEventListener("click", this.props.onAndroidClick);
     this.container.querySelector(".ios-link").addEventListener("click", this.props.oniOSClick);
     let syncPrefLinks = this.container.querySelectorAll(".sync-prefs");
     for (let link of syncPrefLinks) {
--- a/browser/components/syncedtabs/TabListView.js
+++ b/browser/components/syncedtabs/TabListView.js
@@ -164,17 +164,17 @@ TabListView.prototype = {
 
   _createTab(item) {
     return this._doc.importNode(this._tabTemplate.content, true).firstElementChild;
   },
 
   _clearChilden(node) {
     let parent = node || this.container;
     while (parent.firstChild) {
-      parent.removeChild(parent.firstChild);
+      parent.firstChild.remove();
     }
   },
 
   // These listeners are attached only once, when we initialize the view
   _attachFixedListeners() {
     this.tabsFilter.addEventListener("input", this.onFilter.bind(this));
     this.tabsFilter.addEventListener("focus", this.onFilterFocus.bind(this));
     this.tabsFilter.addEventListener("blur", this.onFilterBlur.bind(this));
--- a/browser/components/uitour/UITour.jsm
+++ b/browser/components/uitour/UITour.jsm
@@ -1231,17 +1231,17 @@ this.UITour = {
       // Make the heartbeat icon pulse twice.
       notice.label = aOptions.thankyouMessage;
       messageImage.classList.remove("pulse-onshow");
       messageImage.classList.add("pulse-twice");
 
       // Remove all the children of the notice (rating container
       // and the flex).
       while (notice.firstChild) {
-        notice.removeChild(notice.firstChild);
+        notice.firstChild.remove();
       }
 
       // Make sure that we have a valid URL. If we haven't, do not open the engagement page.
       let engagementURL = null;
       try {
         engagementURL = new URL(aOptions.engagementURL);
       } catch (error) {
         log.error("showHeartbeat: Invalid URL specified.");
--- a/browser/extensions/mortar/ppapi/generators/idl_gen_rpc.py
+++ b/browser/extensions/mortar/ppapi/generators/idl_gen_rpc.py
@@ -38,16 +38,17 @@ customAPIs = {
   ('PPB_OpenGLES2', 'GenBuffers', 'buffers'): { 'array': True, 'arrayType': 'GLuint', 'arraySize': 'n', 'create': False },
   ('PPB_OpenGLES2', 'GenTextures', 'textures'): { 'array': True, 'arrayType': 'GLuint', 'arraySize': 'n', 'create': False },
   ('PPB_OpenGLES2', 'ShaderSource', 'str'): { 'array': True, 'arrayType': 'str_t', 'arraySize': 'count', 'mode': 'in' },
   ('PPB_OpenGLES2', 'UniformMatrix3fv', 'value'): { 'array': True, 'arrayType': 'GLfloat', 'arraySize': 'count * 9', 'mode': 'in' },
   ('PPB_PDF', 'SearchString', 'results'): { 'arraySize': None },
   ('PPB_PDF', 'SetAccessibilityPageInfo', 'text_runs'): { 'arraySize': 'page_info->text_run_count' },
   ('PPB_PDF', 'SetAccessibilityPageInfo', 'chars'): { 'arraySize': 'page_info->char_count' },
   ('PPB_TCPSocket_Private', 'Write', 'buffer'): { 'array': True, 'arrayType': 'uint8_t', 'arraySize': 'bytes_to_write' },
+  ('PPP_Printing_Dev', 'PrintPages', 'page_ranges'): { 'array': True, 'arraySize': None },
 }
 def getCustom(interface, member, param):
   def matches(pattern, value):
     return pattern == value or pattern == '*'
   custom = list(v for (i, m, p), v in customAPIs.iteritems() if matches(interface, i) and matches(m, member) and matches(p, param))
   assert len(custom) <= 1
   return custom[0] if len(custom) == 1 else dict()
 
@@ -330,17 +331,20 @@ class RPCGen(object):
     out = ''
     out += 'char* Call_%s_%s(const %s* _interface, JSONIterator& iterator) {\n' % (iface.GetName(), node.GetName(), version)
     callnode = node.GetOneOf('Callspec')
     params = []
     hasOutParams = False
     for param in callnode.GetListOf('Param'):
       mode = self.cgen.GetParamMode(param)
       ptype, pname, parray, pspec = self.cgen.GetComponents(param, release, "store")
-      out += '  ' + self.cgen.Compose(ptype, pname, parray, pspec, '', func_as_ptr=True,
+      prefix = ''
+      if getCustom(iface.GetName(), node.GetName(), param.GetName()).get("array"):
+        prefix = '*'
+      out += '  ' + self.cgen.Compose(ptype, pname, parray, pspec, prefix, func_as_ptr=True,
               include_name=True, unsized_as_ptr=True) + ';\n'
       if mode == 'out':
         if len(parray) > 0:
           out += '  iterator.skip();\n'
           out += '  PointerValueFromJSON(iterator, ' + pname + ');\n'
       else:
         out += '  iterator.skip();\n'
         out += self.FromJSON(release, '', pname, param, True, callnode)
@@ -354,17 +358,18 @@ class RPCGen(object):
     if rtype != 'void':
       out += rtype + ' rval;\n'
       out += '  rval = '
     params = []
     for param in callnode.GetListOf('Param'):
       mode = self.cgen.GetParamMode(param)
       ntype, mode = self.cgen.GetRootTypeMode(param, release, mode)
       ptype, pname, parray, pspec = self.cgen.GetComponents(param, release, mode)
-      if mode == 'out' or ntype == 'Struct' or (mode == 'constptr_in' and ntype == 'TypeValue'):
+      isArray = getCustom(iface.GetName(), node.GetName(), param.GetName()).get("array")
+      if (mode == 'out' or ntype == 'Struct' or (mode == 'constptr_in' and ntype == 'TypeValue')) and not isArray:
         pname = '&' + pname
       pname = '(' + self.cgen.Compose(ptype, pname, parray, pspec, '', func_as_ptr=True,
               include_name=False, unsized_as_ptr=True) + ')' + pname
       params.append(pname)
     out += '_interface->' + node.GetName() + '(' + ", ".join(params) + ');\n'
     if rtype != 'void' or hasOutParams:
       typeref = node.GetType(release)
       if hasOutParams:
--- a/browser/extensions/mortar/ppapi/out/rpc.cc
+++ b/browser/extensions/mortar/ppapi/out/rpc.cc
@@ -232,84 +232,16 @@ inline PP_Bool PP_FromBool(bool b) {
  * @return A C++ "bool" type.
  */
 inline bool PP_ToBool(PP_Bool b) {
   return (b != PP_FALSE);
 }
 
 #endif  /* __cplusplus */
 
-/* pp_point.idl */
-/**
- * @addtogroup Structs
- * @{
- */
-/**
- * The PP_Point structure defines the integer x and y coordinates of a point.
- */
-struct PP_Point {
-  /**
-   * This value represents the horizontal coordinate of a point, starting with 0
-   * as the left-most coordinate.
-   */
-  int32_t x;
-  /**
-   * This value represents the vertical coordinate of a point, starting with 0
-   * as the top-most coordinate.
-   */
-  int32_t y;
-};
-PP_COMPILE_ASSERT_STRUCT_SIZE_IN_BYTES(PP_Point, 8);
-
-/**
- * The PP_FloatPoint structure defines the floating-point x and y coordinates
- * of a point.
- */
-struct PP_FloatPoint {
-  float x;
-  float y;
-};
-PP_COMPILE_ASSERT_STRUCT_SIZE_IN_BYTES(PP_FloatPoint, 8);
-/**
- * @}
- */
-
-/**
- * @addtogroup Functions
- * @{
- */
-
-/**
- * PP_MakePoint() creates a <code>PP_Point</code> given the x and y coordinates
- * as int32_t values.
- *
- * @param[in] x An int32_t value representing a horizontal coordinate of a
- * point, starting with 0 as the left-most coordinate.
- * @param[in] y An int32_t value representing a vertical coordinate of a point,
- * starting with 0 as the top-most coordinate.
- *
- * @return A <code>PP_Point</code> structure.
- */
-PP_INLINE struct PP_Point PP_MakePoint(int32_t x, int32_t y) {
-  struct PP_Point ret;
-  ret.x = x;
-  ret.y = y;
-  return ret;
-}
-
-PP_INLINE struct PP_FloatPoint PP_MakeFloatPoint(float x, float y) {
-  struct PP_FloatPoint ret;
-  ret.x = x;
-  ret.y = y;
-  return ret;
-}
-/**
- * @}
- */
-
 /* pp_size.idl */
 /**
  * @addtogroup Structs
  * @{
  */
 /**
  * The <code>PP_Size</code> struct contains the size of a 2D rectangle.
  */
@@ -368,16 +300,84 @@ PP_INLINE struct PP_FloatSize PP_MakeFlo
   struct PP_FloatSize ret;
   ret.width = w;
   ret.height = h;
   return ret;
 }
 /**
  * @}
  */
+/* pp_point.idl */
+/**
+ * @addtogroup Structs
+ * @{
+ */
+/**
+ * The PP_Point structure defines the integer x and y coordinates of a point.
+ */
+struct PP_Point {
+  /**
+   * This value represents the horizontal coordinate of a point, starting with 0
+   * as the left-most coordinate.
+   */
+  int32_t x;
+  /**
+   * This value represents the vertical coordinate of a point, starting with 0
+   * as the top-most coordinate.
+   */
+  int32_t y;
+};
+PP_COMPILE_ASSERT_STRUCT_SIZE_IN_BYTES(PP_Point, 8);
+
+/**
+ * The PP_FloatPoint structure defines the floating-point x and y coordinates
+ * of a point.
+ */
+struct PP_FloatPoint {
+  float x;
+  float y;
+};
+PP_COMPILE_ASSERT_STRUCT_SIZE_IN_BYTES(PP_FloatPoint, 8);
+/**
+ * @}
+ */
+
+/**
+ * @addtogroup Functions
+ * @{
+ */
+
+/**
+ * PP_MakePoint() creates a <code>PP_Point</code> given the x and y coordinates
+ * as int32_t values.
+ *
+ * @param[in] x An int32_t value representing a horizontal coordinate of a
+ * point, starting with 0 as the left-most coordinate.
+ * @param[in] y An int32_t value representing a vertical coordinate of a point,
+ * starting with 0 as the top-most coordinate.
+ *
+ * @return A <code>PP_Point</code> structure.
+ */
+PP_INLINE struct PP_Point PP_MakePoint(int32_t x, int32_t y) {
+  struct PP_Point ret;
+  ret.x = x;
+  ret.y = y;
+  return ret;
+}
+
+PP_INLINE struct PP_FloatPoint PP_MakeFloatPoint(float x, float y) {
+  struct PP_FloatPoint ret;
+  ret.x = x;
+  ret.y = y;
+  return ret;
+}
+/**
+ * @}
+ */
+
 /* pp_rect.idl */
 /**
  * @addtogroup Structs
  * @{
  */
 /**
  * The <code>PP_Rect</code> struct contains the size and location of a 2D
  * rectangle.
@@ -49233,24 +49233,32 @@ char* Call_PPP_Printing_Dev_Begin(const 
   int32_t rval;
   rval = _interface->Begin((PP_Instance )instance, (const struct PP_PrintSettings_Dev* )&print_settings);
   return strdup(ToString_int32_t(rval).c_str());
 }
 char* Call_PPP_Printing_Dev_PrintPages(const PPP_Printing_Dev* _interface, JSONIterator& iterator) {
   PP_Instance instance;
   iterator.skip();
   FromJSON_PP_Instance(iterator, instance);
-  struct PP_PrintPageNumberRange_Dev page_ranges;
-  iterator.skip();
-  FromJSON_PP_PrintPageNumberRange_Dev(iterator, page_ranges);
+  struct PP_PrintPageNumberRange_Dev *page_ranges;
+  iterator.skip();
+
+  {
+    size_t children = iterator.expectArrayAndGotoFirstItem();
+    page_ranges = new struct PP_PrintPageNumberRange_Dev[children];
+    for (uint32_t _n = 0; _n < children; ++_n) {
+      FromJSON_PP_PrintPageNumberRange_Dev(iterator, (page_ranges)[_n]);
+    }
+    // FIXME Null out remaining items?
+  }
   uint32_t page_range_count;
   iterator.skip();
   FromJSON_uint32_t(iterator, page_range_count);
   int32_t rval;
-  rval = _interface->PrintPages((PP_Instance )instance, (const struct PP_PrintPageNumberRange_Dev* )&page_ranges, (uint32_t )page_range_count);
+  rval = _interface->PrintPages((PP_Instance )instance, (const struct PP_PrintPageNumberRange_Dev* )page_ranges, (uint32_t )page_range_count);
   return strdup(ToString_PP_Resource(rval).c_str());
 }
 char* Call_PPP_Printing_Dev_End(const PPP_Printing_Dev* _interface, JSONIterator& iterator) {
   PP_Instance instance;
   iterator.skip();
   FromJSON_PP_Instance(iterator, instance);
   _interface->End((PP_Instance )instance);
   return nullptr;
--- a/browser/extensions/pdfjs/content/web/viewer.js
+++ b/browser/extensions/pdfjs/content/web/viewer.js
@@ -3893,17 +3893,17 @@ var PDFAttachmentViewer = function PDFAt
   this._renderedCapability = pdfjsLib.createPromiseCapability();
   this.eventBus.on('fileattachmentannotation', this._appendAttachment.bind(this));
  }
  PDFAttachmentViewer.prototype = {
   reset: function PDFAttachmentViewer_reset(keepRenderedCapability) {
    this.attachments = null;
    var container = this.container;
    while (container.firstChild) {
-    container.removeChild(container.firstChild);
+    container.firstChild.remove();
    }
    if (!keepRenderedCapability) {
     this._renderedCapability = pdfjsLib.createPromiseCapability();
    }
   },
   _dispatchEvent: function PDFAttachmentViewer_dispatchEvent(attachmentsCount) {
    this.eventBus.dispatch('attachmentsloaded', {
     source: this,
@@ -4593,17 +4593,17 @@ var PDFOutlineViewer = function PDFOutli
   this.eventBus = options.eventBus;
  }
  PDFOutlineViewer.prototype = {
   reset: function PDFOutlineViewer_reset() {
    this.outline = null;
    this.lastToggleIsShow = true;
    var container = this.container;
    while (container.firstChild) {
-    container.removeChild(container.firstChild);
+    container.firstChild.remove();
    }
   },
   _dispatchEvent: function PDFOutlineViewer_dispatchEvent(outlineCount) {
    this.eventBus.dispatch('outlineloaded', {
     source: this,
     outlineCount: outlineCount
    });
   },
--- a/build/clang-plugin/Checks.inc
+++ b/build/clang-plugin/Checks.inc
@@ -5,16 +5,17 @@
 // The list of checker classes that are compatible with clang-tidy.
 
 CHECK(ArithmeticArgChecker, "arithmetic-argument")
 CHECK(AssertAssignmentChecker, "assignment-in-assert")
 CHECK(ExplicitImplicitChecker, "implicit-constructor")
 CHECK(ExplicitOperatorBoolChecker, "explicit-operator-bool")
 CHECK(KungFuDeathGripChecker, "kungfu-death-grip")
 CHECK(MustOverrideChecker, "must-override")
+CHECK(MustReturnFromCallerChecker, "must-return-from-caller")
 CHECK(MustUseChecker, "must-use")
 CHECK(NaNExprChecker, "nan-expr")
 CHECK(NeedsNoVTableTypeChecker, "needs-no-vtable-type")
 CHECK(NoAddRefReleaseOnReturnChecker, "no-addref-release-on-return")
 CHECK(NoAutoTypeChecker, "no-auto-type")
 CHECK(NoDuplicateRefCntMemberChecker, "no-duplicate-refcnt-member")
 CHECK(NoExplicitMoveConstructorChecker, "no-explicit-move-constructor")
 CHECK(NonMemMovableMemberChecker, "non-memmovable-member")
--- a/build/clang-plugin/ChecksIncludes.inc
+++ b/build/clang-plugin/ChecksIncludes.inc
@@ -6,16 +6,17 @@
 // are compatible with clang-tidy.
 
 #include "ArithmeticArgChecker.h"
 #include "AssertAssignmentChecker.h"
 #include "ExplicitImplicitChecker.h"
 #include "ExplicitOperatorBoolChecker.h"
 #include "KungFuDeathGripChecker.h"
 #include "MustOverrideChecker.h"
+#include "MustReturnFromCallerChecker.h"
 #include "MustUseChecker.h"
 #include "NaNExprChecker.h"
 #include "NeedsNoVTableTypeChecker.h"
 #include "NoAddRefReleaseOnReturnChecker.h"
 #include "NoAutoTypeChecker.h"
 #include "NoDuplicateRefCntMemberChecker.h"
 #include "NoExplicitMoveConstructorChecker.h"
 #include "NonMemMovableMemberChecker.h"
--- a/build/clang-plugin/CustomMatchers.h
+++ b/build/clang-plugin/CustomMatchers.h
@@ -226,12 +226,17 @@ AST_MATCHER(CXXMethodDecl, isRequiredBas
   return Decl
       && hasCustomAnnotation(Decl, "moz_required_base_method");
 }
 
 AST_MATCHER(CXXMethodDecl, isNonVirtual) {
   const CXXMethodDecl *Decl = Node.getCanonicalDecl();
   return Decl && !Decl->isVirtual();
 }
+
+AST_MATCHER(FunctionDecl, isMozMustReturnFromCaller) {
+  const FunctionDecl *Decl = Node.getCanonicalDecl();
+  return Decl && hasCustomAnnotation(Decl, "moz_must_return_from_caller");
+}
 }
 }
 
 #endif
new file mode 100644
--- /dev/null
+++ b/build/clang-plugin/MustReturnFromCallerChecker.cpp
@@ -0,0 +1,105 @@
+/* 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 "MustReturnFromCallerChecker.h"
+#include "CustomMatchers.h"
+
+void MustReturnFromCallerChecker::registerMatchers(MatchFinder* AstMatcher) {
+  // Look for a call to a MOZ_MUST_RETURN_FROM_CALLER function
+  AstMatcher->addMatcher(callExpr(callee(functionDecl(isMozMustReturnFromCaller())),
+                                  anyOf(hasAncestor(lambdaExpr().bind("containing-lambda")),
+                                        hasAncestor(functionDecl().bind("containing-func")))).bind("call"),
+                         this);
+}
+
+void MustReturnFromCallerChecker::check(
+    const MatchFinder::MatchResult& Result) {
+  const auto *ContainingLambda =
+    Result.Nodes.getNodeAs<LambdaExpr>("containing-lambda");
+  const auto *ContainingFunc =
+    Result.Nodes.getNodeAs<FunctionDecl>("containing-func");
+  const auto *Call = Result.Nodes.getNodeAs<CallExpr>("call");
+
+  Stmt *Body = nullptr;
+  if (ContainingLambda) {
+    Body = ContainingLambda->getBody();
+  } else if (ContainingFunc) {
+    Body = ContainingFunc->getBody();
+  } else {
+    return;
+  }
+  assert(Body && "Should have a body by this point");
+
+  // Generate the CFG for the enclosing function or decl.
+  CFG::BuildOptions Options;
+  std::unique_ptr<CFG> TheCFG =
+    CFG::buildCFG(nullptr, Body, Result.Context, Options);
+  if (!TheCFG) {
+    return;
+  }
+
+  // Determine which block in the CFG we want to look at the successors of.
+  StmtToBlockMap BlockMap(TheCFG.get(), Result.Context);
+  size_t CallIndex;
+  const auto *Block = BlockMap.blockContainingStmt(Call, &CallIndex);
+  assert(Block && "This statement should be within the CFG!");
+
+  if (!immediatelyReturns(Block, Result.Context, CallIndex + 1)) {
+    diag(Call->getLocStart(),
+         "You must immediately return after calling this function",
+         DiagnosticIDs::Error);
+  }
+}
+
+bool
+MustReturnFromCallerChecker::immediatelyReturns(RecurseGuard<const CFGBlock *> Block,
+                                                ASTContext *TheContext,
+                                                size_t FromIdx) {
+  if (Block.isRepeat()) {
+    return false;
+  }
+
+  for (size_t I = FromIdx; I < Block->size(); ++I) {
+    Optional<CFGStmt> S = (*Block)[I].getAs<CFGStmt>();
+    if (!S) {
+      continue;
+    }
+
+    auto AfterTrivials = IgnoreTrivials(S->getStmt());
+
+    // If we are looking at a ConstructExpr, a DeclRefExpr or a MemberExpr it's
+    // OK to use them after a call to a MOZ_MUST_RETURN_FROM_CALLER function.
+    // It is also, of course, OK to look at a ReturnStmt.
+    if (isa<ReturnStmt>(AfterTrivials) ||
+        isa<CXXConstructExpr>(AfterTrivials) ||
+        isa<DeclRefExpr>(AfterTrivials) ||
+        isa<MemberExpr>(AfterTrivials)) {
+      continue;
+    }
+
+    // It's also OK to call any function or method which is annotated with
+    // MOZ_MAY_CALL_AFTER_MUST_RETURN. We consider all CXXConversionDecls
+    // to be MOZ_MAY_CALL_AFTER_MUST_RETURN (like operator T*()).
+    if (auto CE = dyn_cast<CallExpr>(AfterTrivials)) {
+      auto Callee = CE->getDirectCallee();
+      if (Callee && hasCustomAnnotation(Callee, "moz_may_call_after_must_return")) {
+        continue;
+      }
+
+      if (Callee && isa<CXXConversionDecl>(Callee)) {
+        continue;
+      }
+    }
+
+    // Otherwise, this expression is problematic.
+    return false;
+  }
+
+  for (auto Succ = Block->succ_begin(); Succ != Block->succ_end(); ++Succ) {
+    if (!immediatelyReturns(Block.recurse(*Succ), TheContext, 0)) {
+      return false;
+    }
+  }
+  return true;
+}
new file mode 100644
--- /dev/null
+++ b/build/clang-plugin/MustReturnFromCallerChecker.h
@@ -0,0 +1,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/. */
+
+#ifndef MustReturnFromCallerChecker_h__
+#define MustReturnFromCallerChecker_h__
+
+#include "plugin.h"
+#include "Utils.h"
+#include "RecurseGuard.h"
+#include "StmtToBlockMap.h"
+
+class MustReturnFromCallerChecker : public BaseCheck {
+public:
+  MustReturnFromCallerChecker(StringRef CheckName,
+                              ContextType *Context = nullptr)
+    : BaseCheck(CheckName, Context) {}
+  void registerMatchers(MatchFinder* AstMatcher) override;
+  void check(const MatchFinder::MatchResult &Result) override;
+private:
+  bool immediatelyReturns(RecurseGuard<const CFGBlock *> Block,
+                          ASTContext *TheContext,
+                          size_t FromIdx);
+};
+
+#endif
new file mode 100644
--- /dev/null
+++ b/build/clang-plugin/RecurseGuard.h
@@ -0,0 +1,63 @@
+/* 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 RecurseGuard_h__
+#define RecurseGuard_h__
+
+#include "Utils.h"
+
+// This class acts as a tracker for avoiding infinite recursion when traversing
+// chains in CFGs etc.
+//
+// Constructing a RecurseGuard sets up a shared backing store which tracks the
+// currently observed objects. Whenever recursing, use RecurseGuard.recurse(T)
+// to construct another RecurseGuard with the same backing store.
+//
+// The RecurseGuard object will unregister its object when it is destroyed, and
+// has a method `isRepeat()` which will return `true` if the item was already
+// seen.
+template<typename T>
+class RecurseGuard {
+public:
+  RecurseGuard(T Thing) : Thing(Thing), Set(new DenseSet<T>()), Repeat(false) {
+    Set->insert(Thing);
+  }
+  RecurseGuard(T Thing, std::shared_ptr<DenseSet<T>>& Set)
+    : Thing(Thing), Set(Set), Repeat(false) {
+    Repeat = !Set->insert(Thing).second;
+  }
+  RecurseGuard(const RecurseGuard &) = delete;
+  RecurseGuard(RecurseGuard && Other)
+    : Thing(Other.Thing), Set(Other.Set), Repeat(Other.Repeat) {
+    Other.Repeat = true;
+  }
+  ~RecurseGuard() {
+    if (!Repeat) {
+      Set->erase(Thing);
+    }
+  }
+
+  bool isRepeat() { return Repeat; }
+
+  T get() { return Thing; }
+
+  operator T() {
+    return Thing;
+  }
+
+  T operator ->() {
+    return Thing;
+  }
+
+  RecurseGuard recurse(T NewThing) {
+    return RecurseGuard(NewThing, Set);
+  }
+
+private:
+  T Thing;
+  std::shared_ptr<DenseSet<T>> Set;
+  bool Repeat;
+};
+
+#endif // RecurseGuard_h__
new file mode 100644
--- /dev/null
+++ b/build/clang-plugin/StmtToBlockMap.h
@@ -0,0 +1,86 @@
+/* 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 StmtToBlockMap_h__
+#define StmtToBlockMap_h__
+
+#include "Utils.h"
+
+// This method is copied from clang-tidy's ExprSequence.cpp.
+//
+// Returns the Stmt nodes that are parents of 'S', skipping any potential
+// intermediate non-Stmt nodes.
+//
+// In almost all cases, this function returns a single parent or no parents at
+// all.
+inline SmallVector<const Stmt *, 1> getParentStmts(const Stmt *S,
+                                                   ASTContext *Context) {
+  SmallVector<const Stmt *, 1> Result;
+
+  ASTContext::DynTypedNodeList Parents = Context->getParents(*S);
+
+  SmallVector<ast_type_traits::DynTypedNode, 1> NodesToProcess(Parents.begin(),
+                                                               Parents.end());
+
+  while (!NodesToProcess.empty()) {
+    ast_type_traits::DynTypedNode Node = NodesToProcess.back();
+    NodesToProcess.pop_back();
+
+    if (const auto *S = Node.get<Stmt>()) {
+      Result.push_back(S);
+    } else {
+      Parents = Context->getParents(Node);
+      NodesToProcess.append(Parents.begin(), Parents.end());
+    }
+  }
+
+  return Result;
+}
+
+// This class is a modified version of the class from clang-tidy's ExprSequence.cpp
+//
+// Maps `Stmt`s to the `CFGBlock` that contains them. Some `Stmt`s may be
+// contained in more than one `CFGBlock`; in this case, they are mapped to the
+// innermost block (i.e. the one that is furthest from the root of the tree).
+// An optional outparameter provides the index into the block where the `Stmt`
+// was found.
+class StmtToBlockMap {
+public:
+  // Initializes the map for the given `CFG`.
+  StmtToBlockMap(const CFG *TheCFG, ASTContext *TheContext) : Context(TheContext) {
+    for (const auto *B : *TheCFG) {
+      for (size_t I = 0; I < B->size(); ++I) {
+        if (Optional<CFGStmt> S = (*B)[I].getAs<CFGStmt>()) {
+          Map[S->getStmt()] = std::make_pair(B, I);
+        }
+      }
+    }
+  }
+
+  // Returns the block that S is contained in. Some `Stmt`s may be contained
+  // in more than one `CFGBlock`; in this case, this function returns the
+  // innermost block (i.e. the one that is furthest from the root of the tree).
+  //
+  // The optional outparameter `Index` is set to the index into the block where
+  // the `Stmt` was found.
+  const CFGBlock *blockContainingStmt(const Stmt *S, size_t *Index = nullptr) const {
+    while (!Map.count(S)) {
+      SmallVector<const Stmt *, 1> Parents = getParentStmts(S, Context);
+      if (Parents.empty())
+        return nullptr;
+      S = Parents[0];
+    }
+
+    const auto &E = Map.lookup(S);
+    if (Index) *Index = E.second;
+    return E.first;
+  }
+
+private:
+  ASTContext *Context;
+
+  llvm::DenseMap<const Stmt *, std::pair<const CFGBlock *, size_t>> Map;
+};
+
+#endif // StmtToBlockMap_h__
--- a/build/clang-plugin/moz.build
+++ b/build/clang-plugin/moz.build
@@ -11,16 +11,17 @@ UNIFIED_SOURCES += [
     'AssertAssignmentChecker.cpp',
     'CustomTypeAnnotation.cpp',
     'DiagnosticsMatcher.cpp',
     'ExplicitImplicitChecker.cpp',
     'ExplicitOperatorBoolChecker.cpp',
     'KungFuDeathGripChecker.cpp',
     'MozCheckAction.cpp',
     'MustOverrideChecker.cpp',
+    'MustReturnFromCallerChecker.cpp',
     'MustUseChecker.cpp',
     'NaNExprChecker.cpp',
     'NeedsNoVTableTypeChecker.cpp',
     'NoAddRefReleaseOnReturnChecker.cpp',
     'NoAutoTypeChecker.cpp',
     'NoDuplicateRefCntMemberChecker.cpp',
     'NoExplicitMoveConstructorChecker.cpp',
     'NonMemMovableMemberChecker.cpp',
--- a/build/clang-plugin/plugin.h
+++ b/build/clang-plugin/plugin.h
@@ -1,15 +1,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/. */
 
 #ifndef plugin_h__
 #define plugin_h__
 
+#include "clang/Analysis/CFG.h"
 #include "clang/AST/ASTConsumer.h"
 #include "clang/AST/ASTContext.h"
 #include "clang/AST/RecursiveASTVisitor.h"
 #include "clang/ASTMatchers/ASTMatchFinder.h"
 #include "clang/ASTMatchers/ASTMatchers.h"
 #include "clang/Basic/Version.h"
 #include "clang/Frontend/CompilerInstance.h"
 #include "clang/Frontend/MultiplexConsumer.h"
new file mode 100644
--- /dev/null
+++ b/build/clang-plugin/tests/TestMustReturnFromCaller.cpp
@@ -0,0 +1,183 @@
+#include <cstddef>
+
+#define MOZ_MUST_RETURN_FROM_CALLER __attribute__((annotate("moz_must_return_from_caller")))
+#define MOZ_MAY_CALL_AFTER_MUST_RETURN __attribute__((annotate("moz_may_call_after_must_return")))
+
+void MOZ_MUST_RETURN_FROM_CALLER Throw() {}
+void DoAnythingElse();
+int MakeAnInt();
+int MOZ_MAY_CALL_AFTER_MUST_RETURN SafeMakeInt();
+bool Condition();
+
+class Foo {
+public:
+  __attribute__((annotate("moz_implicit"))) Foo(std::nullptr_t);
+  Foo();
+};
+
+void a1() {
+  Throw();
+}
+
+int a2() {
+  Throw(); // expected-error {{You must immediately return after calling this function}}
+  return MakeAnInt();
+}
+
+int a3() {
+  Throw();
+  return 5;
+}
+
+int a4() {
+  Throw(); // expected-error {{You must immediately return after calling this function}}
+  return Condition() ? MakeAnInt() : MakeAnInt();
+}
+
+void a5() {
+  Throw(); // expected-error {{You must immediately return after calling this function}}
+  DoAnythingElse();
+}
+
+int a6() {
+  Throw(); // expected-error {{You must immediately return after calling this function}}
+  DoAnythingElse();
+  return MakeAnInt();
+}
+
+int a7() {
+  Throw(); // expected-error {{You must immediately return after calling this function}}
+  DoAnythingElse();
+  return Condition() ? MakeAnInt() : MakeAnInt();
+}
+
+int a8() {
+  Throw();
+  return SafeMakeInt();
+}
+
+int a9() {
+  if (Condition()) {
+    Throw();
+  }
+  return SafeMakeInt();
+}
+
+void b1() {
+  if (Condition()) {
+    Throw();
+  }
+}
+
+int b2() {
+  if (Condition()) {
+    Throw(); // expected-error {{You must immediately return after calling this function}}
+  }
+  return MakeAnInt();
+}
+
+int b3() {
+  if (Condition()) {
+    Throw();
+  }
+  return 5;
+}
+
+int b4() {
+  if (Condition()) {
+    Throw(); // expected-error {{You must immediately return after calling this function}}
+  }
+  return Condition() ? MakeAnInt() : MakeAnInt();
+}
+
+void b5() {
+  if (Condition()) {
+    Throw(); // expected-error {{You must immediately return after calling this function}}
+  }
+  DoAnythingElse();
+}
+
+void b6() {
+  if (Condition()) {
+    Throw(); // expected-error {{You must immediately return after calling this function}}
+    DoAnythingElse();
+  }
+}
+
+void b7() {
+  if (Condition()) {
+    Throw();
+    return;
+  }
+  DoAnythingElse();
+}
+
+void b8() {
+  if (Condition()) {
+    Throw(); // expected-error {{You must immediately return after calling this function}}
+    DoAnythingElse();
+    return;
+  }
+  DoAnythingElse();
+}
+
+void b9() {
+  while (Condition()) {
+    Throw(); // expected-error {{You must immediately return after calling this function}}
+  }
+}
+
+void b10() {
+  while (Condition()) {
+    Throw();
+    return;
+  }
+}
+
+void b11() {
+  Throw(); // expected-error {{You must immediately return after calling this function}}
+  if (Condition()) {
+    return;
+  } else {
+    return;
+  }
+}
+
+void b12() {
+  switch (MakeAnInt()) {
+  case 1:
+    break;
+  default:
+    Throw();
+    return;
+  }
+}
+
+void b13() {
+  if (Condition()) {
+    Throw();
+  }
+  return;
+}
+
+Foo b14() {
+  if (Condition()) {
+    Throw();
+    return nullptr;
+  }
+  return nullptr;
+}
+
+Foo b15() {
+  if (Condition()) {
+    Throw();
+  }
+  return nullptr;
+}
+
+Foo b16() {
+  if (Condition()) {
+    Throw();
+  }
+  return Foo();
+}
--- a/build/clang-plugin/tests/moz.build
+++ b/build/clang-plugin/tests/moz.build
@@ -13,16 +13,17 @@ SOURCES += [
     'TestCustomHeap.cpp',
     'TestExplicitOperatorBool.cpp',
     'TestGlobalClass.cpp',
     'TestHeapClass.cpp',
     'TestInheritTypeAnnotationsFromTemplateArgs.cpp',
     'TestKungFuDeathGrip.cpp',
     'TestMultipleAnnotations.cpp',
     'TestMustOverride.cpp',
+    'TestMustReturnFromCaller.cpp',
     'TestMustUse.cpp',
     'TestNANTestingExpr.cpp',
     'TestNANTestingExprC.c',
     'TestNeedsNoVTableType.cpp',
     'TestNoAddRefReleaseOnReturn.cpp',
     'TestNoArithmeticExprInArgument.cpp',
     'TestNoAutoType.cpp',
     'TestNoDuplicateRefCntMember.cpp',
--- a/caps/BasePrincipal.cpp
+++ b/caps/BasePrincipal.cpp
@@ -46,29 +46,16 @@ OriginAttributes::InitPrefs()
     Preferences::AddBoolVarCache(&sFirstPartyIsolation,
                                  "privacy.firstparty.isolate");
     Preferences::AddBoolVarCache(&sRestrictedOpenerAccess,
                                  "privacy.firstparty.isolate.restrict_opener_access");
   }
 }
 
 void
-OriginAttributes::Inherit(const OriginAttributes& aAttrs)
-{
-  mAppId = aAttrs.mAppId;
-  mInIsolatedMozBrowser = aAttrs.mInIsolatedMozBrowser;
-
-
-  mUserContextId = aAttrs.mUserContextId;
-
-  mPrivateBrowsingId = aAttrs.mPrivateBrowsingId;
-  mFirstPartyDomain = aAttrs.mFirstPartyDomain;
-}
-
-void
 OriginAttributes::SetFirstPartyDomain(const bool aIsTopLevelDocument,
                                       nsIURI* aURI)
 {
   bool isFirstPartyEnabled = IsFirstPartyEnabled();
 
   // When the pref is on, we also compute the firstPartyDomain attribute
   // if this is for top-level document.
   if (isFirstPartyEnabled && aIsTopLevelDocument) {
--- a/caps/BasePrincipal.h
+++ b/caps/BasePrincipal.h
@@ -35,20 +35,16 @@ public:
     mAppId = aAppId;
     mInIsolatedMozBrowser = aInIsolatedMozBrowser;
   }
 
   explicit OriginAttributes(const OriginAttributesDictionary& aOther)
     : OriginAttributesDictionary(aOther)
   {}
 
-  // This method 'clones' the OriginAttributes ignoring the addonId value becaue
-  // this is computed from the principal URI and never propagated.
-  void Inherit(const OriginAttributes& aAttrs);
-
   void SetFirstPartyDomain(const bool aIsTopLevelDocument, nsIURI* aURI);
 
   enum {
     STRIP_FIRST_PARTY_DOMAIN = 0x01,
     STRIP_USER_CONTEXT_ID = 0x02,
   };
 
   inline void StripAttributes(uint32_t aFlags)
--- a/caps/nsNullPrincipal.cpp
+++ b/caps/nsNullPrincipal.cpp
@@ -43,21 +43,19 @@ nsNullPrincipal::CreateWithInheritedAttr
   nsresult rv = nullPrin->Init(Cast(aInheritFrom)->OriginAttributesRef());
   MOZ_RELEASE_ASSERT(NS_SUCCEEDED(rv));
   return nullPrin.forget();
 }
 
 /* static */ already_AddRefed<nsNullPrincipal>
 nsNullPrincipal::CreateWithInheritedAttributes(nsIDocShell* aDocShell)
 {
-  OriginAttributes attrs;
-  attrs.Inherit(nsDocShell::Cast(aDocShell)->GetOriginAttributes());
-
   RefPtr<nsNullPrincipal> nullPrin = new nsNullPrincipal();
-  nsresult rv = nullPrin->Init(attrs);
+  nsresult rv =
+    nullPrin->Init(nsDocShell::Cast(aDocShell)->GetOriginAttributes());
   MOZ_RELEASE_ASSERT(NS_SUCCEEDED(rv));
   return nullPrin.forget();
 }
 
 /* static */ already_AddRefed<nsNullPrincipal>
 nsNullPrincipal::Create(const OriginAttributes& aOriginAttributes, nsIURI* aURI)
 {
   RefPtr<nsNullPrincipal> nullPrin = new nsNullPrincipal();
--- a/caps/nsScriptSecurityManager.cpp
+++ b/caps/nsScriptSecurityManager.cpp
@@ -374,19 +374,21 @@ nsScriptSecurityManager::GetChannelURIPr
     // If this is a top-level document load, the origin attributes of the
     // loadInfo will be set from nsDocShell::DoURILoad.
     // For subresource loading, the origin attributes of the loadInfo is from
     // its loadingPrincipal.
     OriginAttributes attrs;
 
     // For addons loadInfo might be null.
     if (loadInfo) {
-      attrs.Inherit(loadInfo->GetOriginAttributes());
+      attrs = loadInfo->GetOriginAttributes();
     }
-    nsCOMPtr<nsIPrincipal> prin = BasePrincipal::CreateCodebasePrincipal(uri, attrs);
+
+    nsCOMPtr<nsIPrincipal> prin =
+      BasePrincipal::CreateCodebasePrincipal(uri, attrs);
     prin.forget(aPrincipal);
     return *aPrincipal ? NS_OK : NS_ERROR_FAILURE;
 }
 
 NS_IMETHODIMP
 nsScriptSecurityManager::IsSystemPrincipal(nsIPrincipal* aPrincipal,
                                            bool* aIsSystem)
 {
@@ -1138,36 +1140,32 @@ nsScriptSecurityManager::GetAppCodebaseP
 NS_IMETHODIMP
 nsScriptSecurityManager::
   GetLoadContextCodebasePrincipal(nsIURI* aURI,
                                   nsILoadContext* aLoadContext,
                                   nsIPrincipal** aPrincipal)
 {
   NS_ENSURE_STATE(aLoadContext);
   OriginAttributes docShellAttrs;
-  bool result = aLoadContext->GetOriginAttributes(docShellAttrs);;
+  bool result = aLoadContext->GetOriginAttributes(docShellAttrs);
   NS_ENSURE_TRUE(result, NS_ERROR_FAILURE);
 
-  OriginAttributes attrs;
-  attrs.Inherit(docShellAttrs);
-
-  nsCOMPtr<nsIPrincipal> prin = BasePrincipal::CreateCodebasePrincipal(aURI, attrs);
+  nsCOMPtr<nsIPrincipal> prin =
+    BasePrincipal::CreateCodebasePrincipal(aURI, docShellAttrs);
   prin.forget(aPrincipal);
   return *aPrincipal ? NS_OK : NS_ERROR_FAILURE;
 }
 
 NS_IMETHODIMP
 nsScriptSecurityManager::GetDocShellCodebasePrincipal(nsIURI* aURI,
                                                       nsIDocShell* aDocShell,
                                                       nsIPrincipal** aPrincipal)
 {
-  OriginAttributes attrs;
-  attrs.Inherit(nsDocShell::Cast(aDocShell)->GetOriginAttributes());
-
-  nsCOMPtr<nsIPrincipal> prin = BasePrincipal::CreateCodebasePrincipal(aURI, attrs);
+  nsCOMPtr<nsIPrincipal> prin =
+    BasePrincipal::CreateCodebasePrincipal(aURI, nsDocShell::Cast(aDocShell)->GetOriginAttributes());
   prin.forget(aPrincipal);
   return *aPrincipal ? NS_OK : NS_ERROR_FAILURE;
 }
 
 // static
 nsIPrincipal*
 nsScriptSecurityManager::doGetObjectPrincipal(JSObject *aObj)
 {
--- a/devtools/client/debugger/new/debugger.js
+++ b/devtools/client/debugger/new/debugger.js
@@ -36077,17 +36077,17 @@ return /******/ (function(modules) { // 
 	  if (match) {
 	    var after = current.slice(match.index + match[0].length)
 	    node.className = current.slice(0, match.index) + (after ? match[1] + after : "")
 	  }
 	}
 	
 	function removeChildren(e) {
 	  for (var count = e.childNodes.length; count > 0; --count)
-	    { e.removeChild(e.firstChild) }
+	    { e.firstChild.remove() }
 	  return e
 	}
 	
 	function removeChildrenAndAdd(parent, e) {
 	  return removeChildren(parent).appendChild(e)
 	}
 	
 	function elt(tag, content, className, style) {
--- a/devtools/client/framework/sidebar.js
+++ b/devtools/client/framework/sidebar.js
@@ -571,17 +571,17 @@ ToolSidebar.prototype = {
       let win = panel.firstChild.contentWindow;
       if (win && ("destroy" in win)) {
         yield win.destroy();
       }
       panel.remove();
     }
 
     while (this._tabbox.tabs && this._tabbox.tabs.hasChildNodes()) {
-      this._tabbox.tabs.removeChild(this._tabbox.tabs.firstChild);
+      this._tabbox.tabs.firstChild.remove();
     }
 
     if (this._currentTool && this._telemetry) {
       this._telemetry.toolClosed(this._currentTool);
     }
 
     this._toolPanel.emit("sidebar-destroyed", this);
 
--- a/devtools/client/inspector/markup/markup.js
+++ b/devtools/client/inspector/markup/markup.js
@@ -1599,29 +1599,29 @@ MarkupView.prototype = {
       }
     }
 
     if (container.node.inlineTextChild) {
       container.setExpanded(false);
       // this container will do double duty as the container for the single
       // text child.
       while (container.children.firstChild) {
-        container.children.removeChild(container.children.firstChild);
+        container.children.firstChild.remove();
       }
 
       container.setInlineTextChild(container.node.inlineTextChild);
 
       this._containers.set(container.node.inlineTextChild, container);
       container.childrenDirty = false;
       return promise.resolve(container);
     }
 
     if (!container.hasChildren) {
       while (container.children.firstChild) {
-        container.children.removeChild(container.children.firstChild);
+        container.children.firstChild.remove();
       }
       container.childrenDirty = false;
       container.setExpanded(false);
       return promise.resolve(container);
     }
 
     // If we're not expanded (or asked to update anyway), we're done for
     // now.  Note that this will leave the childrenDirty flag set, so when
@@ -1654,17 +1654,17 @@ MarkupView.prototype = {
         let fragment = this.doc.createDocumentFragment();
 
         for (let child of children.nodes) {
           let childContainer = this.importNode(child, flash);
           fragment.appendChild(childContainer.elt);
         }
 
         while (container.children.firstChild) {
-          container.children.removeChild(container.children.firstChild);
+          container.children.firstChild.remove();
         }
 
         if (!(children.hasFirst && children.hasLast)) {
           let nodesCount = container.node.numChildren;
           let showAllString = PluralForm.get(nodesCount,
             INSPECTOR_L10N.getStr("markupView.more.showAll2"));
           let data = {
             showing: INSPECTOR_L10N.getStr("markupView.more.showing"),
--- a/devtools/client/inspector/markup/test/browser.ini
+++ b/devtools/client/inspector/markup/test/browser.ini
@@ -156,16 +156,17 @@ skip-if = e10s # Bug 1036409 - The last 
 [browser_markup_tag_edit_06.js]
 [browser_markup_tag_edit_07.js]
 [browser_markup_tag_edit_08.js]
 [browser_markup_tag_edit_09.js]
 [browser_markup_tag_edit_10.js]
 [browser_markup_tag_edit_11.js]
 [browser_markup_tag_edit_12.js]
 [browser_markup_tag_edit_13-other.js]
+[browser_markup_tag_edit_avoid_refocus.js]
 [browser_markup_tag_edit_long-classname.js]
 [browser_markup_textcontent_display.js]
 [browser_markup_textcontent_edit_01.js]
 [browser_markup_textcontent_edit_02.js]
 [browser_markup_toggle_01.js]
 [browser_markup_toggle_02.js]
 [browser_markup_toggle_03.js]
 [browser_markup_update-on-navigtion.js]
new file mode 100644
--- /dev/null
+++ b/devtools/client/inspector/markup/test/browser_markup_tag_edit_avoid_refocus.js
@@ -0,0 +1,43 @@
+/* vim: set ts=2 et sw=2 tw=80: */
+/* Any copyright is dedicated to the Public Domain.
+ http://creativecommons.org/publicdomain/zero/1.0/ */
+
+"use strict";
+
+// Bug 1327683 - Tests that an editable attribute is not refocused
+// when the focus has been moved to an other element than the editor.
+
+const TEST_URL = 'data:text/html,<body class="abcd"></body>';
+
+add_task(function* () {
+  let {inspector} = yield openInspectorForURL(TEST_URL);
+
+  yield selectNode(".abcd", inspector);
+  yield clickContainer(".abcd", inspector);
+
+  let container = yield focusNode(".abcd", inspector);
+  ok(container && container.editor, "The markup-container was found");
+
+  info("Listening for the markupmutation event");
+  let nodeMutated = inspector.once("markupmutation");
+  let attr = container.editor.attrElements.get("class").querySelector(".editable");
+
+  attr.focus();
+  EventUtils.sendKey("return", inspector.panelWin);
+  let input = inplaceEditor(attr).input;
+  ok(input, "Found editable field for class attribute");
+
+  input.value = "class=\"wxyz\"";
+
+  let onFocus = once(inspector.searchBox, "focus");
+  EventUtils.synthesizeMouseAtCenter(inspector.searchBox, {}, inspector.panelWin);
+
+  info("Wait for the focus event on search box");
+  yield onFocus;
+
+  info("Wait for the markup-mutation event");
+  yield nodeMutated;
+
+  is(inspector.panelDoc.activeElement, inspector.searchBox,
+     "The currently focused element is the search box");
+});
--- a/devtools/client/inspector/markup/views/element-editor.js
+++ b/devtools/client/inspector/markup/views/element-editor.js
@@ -442,16 +442,23 @@ ElementEditor.prototype = {
   refocusOnEdit: function (attrName, attrNode, direction) {
     // Only allow one refocus on attribute change at a time, so when there's
     // more than 1 request in parallel, the last one wins.
     if (this._editedAttributeObserver) {
       this.markup.inspector.off("markupmutation", this._editedAttributeObserver);
       this._editedAttributeObserver = null;
     }
 
+    let activeElement = this.markup.doc.activeElement;
+    if (!activeElement || !activeElement.inplaceEditor) {
+      // The focus was already removed from the current inplace editor, we should not
+      // refocus the editable attribute.
+      return;
+    }
+
     let container = this.markup.getContainer(this.node);
 
     let activeAttrs = [...this.attrList.childNodes]
       .filter(el => el.style.display != "none");
     let attributeIndex = activeAttrs.indexOf(attrNode);
 
     let onMutations = this._editedAttributeObserver = (e, mutations) => {
       let isDeletedAttribute = false;
--- a/devtools/client/scratchpad/scratchpad.js
+++ b/devtools/client/scratchpad/scratchpad.js
@@ -1362,17 +1362,17 @@ var Scratchpad = {
     }
 
     let recentFilesPopup = recentFilesMenu.firstChild;
     let filePaths = this.getRecentFiles();
     let filename = this.getState().filename;
 
     recentFilesMenu.setAttribute("disabled", true);
     while (recentFilesPopup.hasChildNodes()) {
-      recentFilesPopup.removeChild(recentFilesPopup.firstChild);
+      recentFilesPopup.firstChild.remove();
     }
 
     if (filePaths.length > 0) {
       recentFilesMenu.removeAttribute("disabled");
 
       // Print out menuitems with the most recent file first.
       for (let i = filePaths.length - 1; i >= 0; --i) {
         let menuitem = document.createElement("menuitem");
--- a/devtools/client/shared/developer-toolbar.js
+++ b/devtools/client/shared/developer-toolbar.js
@@ -1014,28 +1014,28 @@ OutputPanel.prototype._outputChanged = f
 OutputPanel.prototype._update = function () {
   // destroy has been called, bail out
   if (this._div == null) {
     return;
   }
 
   // Empty this._div
   while (this._div.hasChildNodes()) {
-    this._div.removeChild(this._div.firstChild);
+    this._div.firstChild.remove();
   }
 
   if (this.displayedOutput.data != null) {
     let context = this._devtoolbar.requisition.conversionContext;
     this.displayedOutput.convert("dom", context).then(node => {
       if (node == null) {
         return;
       }
 
       while (this._div.hasChildNodes()) {
-        this._div.removeChild(this._div.firstChild);
+        this._div.firstChild.remove();
       }
 
       let links = node.querySelectorAll("*[href]");
       for (let i = 0; i < links.length; i++) {
         links[i].setAttribute("target", "_blank");
       }
 
       this._div.appendChild(node);
--- a/devtools/client/shared/widgets/TableWidget.js
+++ b/devtools/client/shared/widgets/TableWidget.js
@@ -1549,17 +1549,17 @@ Cell.prototype = {
       span.textContent = value;
       value = span;
     }
 
     if (value instanceof Node) {
       this.label.removeAttribute("value");
 
       while (this.label.firstChild) {
-        this.label.removeChild(this.label.firstChild);
+        this.label.firstChild.remove();
       }
 
       this.label.appendChild(value);
     } else {
       this.label.setAttribute("value", value + "");
     }
   },
 
--- a/devtools/client/shared/widgets/tooltip/Tooltip.js
+++ b/devtools/client/shared/widgets/tooltip/Tooltip.js
@@ -196,17 +196,17 @@ Tooltip.prototype = {
     this.panel.sizeTo(width, height);
   },
 
   /**
    * Empty the tooltip's content
    */
   empty: function () {
     while (this.panel.hasChildNodes()) {
-      this.panel.removeChild(this.panel.firstChild);
+      this.panel.firstChild.remove();
     }
   },
 
   /**
    * Gets this panel's visibility state.
    * @return boolean
    */
   isHidden: function () {
--- a/devtools/client/styleeditor/StyleEditorUI.jsm
+++ b/devtools/client/styleeditor/StyleEditorUI.jsm
@@ -860,17 +860,17 @@ StyleEditorUI.prototype = {
    *         Editor to update @media sidebar of
    */
   _updateMediaList: function (editor) {
     Task.spawn(function* () {
       let details = yield this.getEditorDetails(editor);
       let list = details.querySelector(".stylesheet-media-list");
 
       while (list.firstChild) {
-        list.removeChild(list.firstChild);
+        list.firstChild.remove();
       }
 
       let rules = editor.mediaRules;
       let showSidebar = Services.prefs.getBoolPref(PREF_MEDIA_SIDEBAR);
       let sidebar = details.querySelector(".stylesheet-sidebar");
 
       let inSource = false;
 
--- a/devtools/shared/gcli/commands/csscoverage.js
+++ b/devtools/shared/gcli/commands/csscoverage.js
@@ -151,17 +151,17 @@ exports.items = [
 
       let data = {
         preload: csscoveragePageReport.preload,
         unused: csscoveragePageReport.unused,
         summary: csscoveragePageReport.summary,
         onback: () => {
           // The back button clears and hides .csscoverage-report
           while (host.hasChildNodes()) {
-            host.removeChild(host.firstChild);
+            host.firstChild.remove();
           }
           host.hidden = true;
         }
       };
 
       let addOnClick = rule => {
         rule.onclick = () => {
           panel.selectStyleSheet(rule.url, rule.start.line);
--- a/devtools/shared/gcli/source/lib/gcli/util/util.js
+++ b/devtools/shared/gcli/source/lib/gcli/util/util.js
@@ -383,17 +383,17 @@ exports.createElement = function(doc, ta
 };
 
 /**
  * Remove all the child nodes from this node
  * @param elem The element that should have it's children removed
  */
 exports.clearElement = function(elem) {
   while (elem.hasChildNodes()) {
-    elem.removeChild(elem.firstChild);
+    elem.firstChild.remove();
   }
 };
 
 var isAllWhitespace = /^\s*$/;
 
 /**
  * Iterate over the children of a node looking for TextNodes that have only
  * whitespace content and remove them.
--- a/docshell/base/LoadContext.cpp
+++ b/docshell/base/LoadContext.cpp
@@ -46,17 +46,17 @@ LoadContext::LoadContext(nsIPrincipal* a
   , mNestedFrameId(0)
   , mIsContent(true)
   , mUseRemoteTabs(false)
   , mUseTrackingProtection(false)
 #ifdef DEBUG
   , mIsNotNull(true)
 #endif
 {
-  mOriginAttributes.Inherit(aPrincipal->OriginAttributesRef());
+  mOriginAttributes = aPrincipal->OriginAttributesRef();
   if (!aOptionalBase) {
     return;
   }
 
   MOZ_ALWAYS_SUCCEEDS(aOptionalBase->GetIsContent(&mIsContent));
   MOZ_ALWAYS_SUCCEEDS(aOptionalBase->GetUseRemoteTabs(&mUseRemoteTabs));
   MOZ_ALWAYS_SUCCEEDS(aOptionalBase->GetUseTrackingProtection(&mUseTrackingProtection));
 }
--- a/docshell/base/nsDocShell.cpp
+++ b/docshell/base/nsDocShell.cpp
@@ -4998,40 +4998,38 @@ nsDocShell::DisplayLoadError(nsresult aE
       if (errorClass == nsINSSErrorsService::ERROR_CLASS_BAD_CERT) {
         error.AssignLiteral("nssBadCert");
 
         // If this is an HTTP Strict Transport Security host or a pinned host
         // and the certificate is bad, don't allow overrides (RFC 6797 section
         // 12.1, HPKP draft spec section 2.6).
         uint32_t flags =
           UsePrivateBrowsing() ? nsISocketProvider::NO_PERMANENT_STORAGE : 0;
-        OriginAttributes originAttributes;
-        originAttributes.Inherit(mOriginAttributes);
         bool isStsHost = false;
         bool isPinnedHost = false;
         if (XRE_IsParentProcess()) {
           nsCOMPtr<nsISiteSecurityService> sss =
             do_GetService(NS_SSSERVICE_CONTRACTID, &rv);
           NS_ENSURE_SUCCESS(rv, rv);
           rv = sss->IsSecureURI(nsISiteSecurityService::HEADER_HSTS, aURI,
-                                flags, originAttributes, nullptr, &isStsHost);
+                                flags, mOriginAttributes, nullptr, &isStsHost);
           NS_ENSURE_SUCCESS(rv, rv);
           rv = sss->IsSecureURI(nsISiteSecurityService::HEADER_HPKP, aURI,
-                                flags, originAttributes, nullptr,
+                                flags, mOriginAttributes, nullptr,
                                 &isPinnedHost);
           NS_ENSURE_SUCCESS(rv, rv);
         } else {
           mozilla::dom::ContentChild* cc =
             mozilla::dom::ContentChild::GetSingleton();
           mozilla::ipc::URIParams uri;
           SerializeURI(aURI, uri);
           cc->SendIsSecureURI(nsISiteSecurityService::HEADER_HSTS, uri, flags,
-                              originAttributes, &isStsHost);
+                              mOriginAttributes, &isStsHost);
           cc->SendIsSecureURI(nsISiteSecurityService::HEADER_HPKP, uri, flags,
-                              originAttributes, &isPinnedHost);
+                              mOriginAttributes, &isPinnedHost);
         }
 
         if (Preferences::GetBool(
               "browser.xul.error_pages.expert_bad_cert", false)) {
           cssClass.AssignLiteral("expertBadCert");
         }
 
         // HSTS/pinning takes precedence over the expert bad cert pref. We
@@ -9731,20 +9729,18 @@ nsDocShell::JustStartedNetworkLoad()
 {
   return mDocumentRequest && mDocumentRequest != GetCurrentDocChannel();
 }
 
 nsresult
 nsDocShell::CreatePrincipalFromReferrer(nsIURI* aReferrer,
                                         nsIPrincipal** aResult)
 {
-  OriginAttributes attrs;
-  attrs.Inherit(mOriginAttributes);
   nsCOMPtr<nsIPrincipal> prin =
-    BasePrincipal::CreateCodebasePrincipal(aReferrer, attrs);
+    BasePrincipal::CreateCodebasePrincipal(aReferrer, mOriginAttributes);
   prin.forget(aResult);
 
   return *aResult ? NS_OK : NS_ERROR_FAILURE;
 }
 
 NS_IMETHODIMP
 nsDocShell::InternalLoad(nsIURI* aURI,
                          nsIURI* aOriginalURI,
@@ -10724,21 +10720,21 @@ nsDocShell::InternalLoad(nsIURI* aURI,
 
   nsAutoString srcdoc;
   if (aFlags & INTERNAL_LOAD_FLAGS_IS_SRCDOC) {
     srcdoc = aSrcdoc;
   } else {
     srcdoc = NullString();
   }
 
-  OriginAttributes attrs;
   bool isTopLevelDoc = mItemType == typeContent &&
                        (isTargetTopLevelDocShell ||
                         GetIsMozBrowser());
-  attrs.Inherit(GetOriginAttributes());
+
+  OriginAttributes attrs = GetOriginAttributes();
   attrs.SetFirstPartyDomain(isTopLevelDoc, aURI);
 
   net::PredictorLearn(aURI, nullptr,
                       nsINetworkPredictor::LEARN_LOAD_TOPLEVEL, attrs);
   net::PredictorPredict(aURI, nullptr,
                         nsINetworkPredictor::PREDICT_LOAD, attrs, nullptr);
 
   // Increase pressure on the throttling service so background channels will be
@@ -10980,19 +10976,19 @@ nsDocShell::DoURILoad(nsIURI* aURI,
 
   // We have to do this in case our OriginAttributes are different from the
   // OriginAttributes of the parent document. Or in case there isn't a
   // parent document.
   bool isTopLevelDoc = mItemType == typeContent &&
                        (aContentPolicyType == nsIContentPolicy::TYPE_DOCUMENT ||
                         GetIsMozBrowser());
 
-  OriginAttributes attrs;
-  attrs.Inherit(GetOriginAttributes());
+  OriginAttributes attrs = GetOriginAttributes();
   attrs.SetFirstPartyDomain(isTopLevelDoc, aURI);
+
   rv = loadInfo->SetOriginAttributes(attrs);
   if (NS_WARN_IF(NS_FAILED(rv))) {
     return rv;
   }
 
   if (!isSrcdoc) {
     rv = NS_NewChannelInternal(getter_AddRefs(channel),
                                aURI,
@@ -12597,19 +12593,16 @@ nsDocShell::LoadHistoryEntry(nsISHEntry*
   if (isSrcdoc) {
     aEntry->GetSrcdocData(srcdoc);
     aEntry->GetBaseURI(getter_AddRefs(baseURI));
     flags |= INTERNAL_LOAD_FLAGS_IS_SRCDOC;
   } else {
     srcdoc = NullString();
   }
 
-  // If there is no valid triggeringPrincipal, we deny the load
-  MOZ_ASSERT(triggeringPrincipal,
-             "need a valid triggeringPrincipal to load from history");
   if (!triggeringPrincipal) {
     triggeringPrincipal = nsContentUtils::GetSystemPrincipal();
   }
 
   // Passing nullptr as aSourceDocShell gives the same behaviour as before
   // aSourceDocShell was introduced. According to spec we should be passing
   // the source browsing context that was used when the history entry was
   // first created. bug 947716 has been created to address this issue.
@@ -14226,22 +14219,20 @@ nsDocShell::OnOverLink(nsIContent* aCont
   nsAutoCString spec;
   rv = aURI->GetSpec(spec);
   NS_ENSURE_SUCCESS(rv, rv);
 
   nsAutoString uStr;
   rv = textToSubURI->UnEscapeURIForUI(charset, spec, uStr);
   NS_ENSURE_SUCCESS(rv, rv);
 
-  OriginAttributes attrs;
-  attrs.Inherit(aContent->NodePrincipal()->OriginAttributesRef());
-
   mozilla::net::PredictorPredict(aURI, mCurrentURI,
                                  nsINetworkPredictor::PREDICT_LINK,
-                                 attrs, nullptr);
+                                 aContent->NodePrincipal()->OriginAttributesRef(),
+                                 nullptr);
 
   if (browserChrome2) {
     nsCOMPtr<nsIDOMElement> element = do_QueryInterface(aContent);
     rv = browserChrome2->SetStatusWithContext(nsIWebBrowserChrome::STATUS_LINK,
                                               uStr, element);
   } else {
     rv = browserChrome->SetStatus(nsIWebBrowserChrome::STATUS_LINK, uStr.get());
   }
@@ -14743,20 +14734,18 @@ nsDocShell::ShouldPrepareForIntercept(ns
 
       if (isThirdPartyURI) {
         return NS_OK;
       }
     }
   }
 
   if (aIsNonSubresourceRequest) {
-    OriginAttributes attrs;
-    attrs.Inherit(mOriginAttributes);
     nsCOMPtr<nsIPrincipal> principal =
-      BasePrincipal::CreateCodebasePrincipal(aURI, attrs);
+      BasePrincipal::CreateCodebasePrincipal(aURI, mOriginAttributes);
     *aShouldIntercept = swm->IsAvailable(principal, aURI);
     return NS_OK;
   }
 
   nsCOMPtr<nsIDocument> doc = GetDocument();
   if (!doc) {
     return NS_ERROR_NOT_AVAILABLE;
   }
@@ -14795,22 +14784,19 @@ nsDocShell::ChannelIntercepted(nsIInterc
     // For top-level navigations, save a document ID which will be passed to
     // the FetchEvent as the clientId later on.
     rv = nsIDocument::GenerateDocumentId(mInterceptedDocumentId);
     NS_ENSURE_SUCCESS(rv, rv);
   }
 
   bool isReload = mLoadType & LOAD_CMD_RELOAD;
 
-  OriginAttributes attrs;
-  attrs.Inherit(mOriginAttributes);
-
   ErrorResult error;
-  swm->DispatchFetchEvent(attrs, doc, mInterceptedDocumentId, aChannel,
-                          isReload, isSubresourceLoad, error);
+  swm->DispatchFetchEvent(mOriginAttributes, doc, mInterceptedDocumentId,
+                          aChannel, isReload, isSubresourceLoad, error);
   if (NS_WARN_IF(error.Failed())) {
     return error.StealNSResult();
   }
 
   return NS_OK;
 }
 
 bool
--- a/docshell/shistory/nsSHEntry.cpp
+++ b/docshell/shistory/nsSHEntry.cpp
@@ -508,20 +508,16 @@ nsSHEntry::GetTriggeringPrincipal(nsIPri
 {
   NS_IF_ADDREF(*aTriggeringPrincipal = mShared->mTriggeringPrincipal);
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsSHEntry::SetTriggeringPrincipal(nsIPrincipal* aTriggeringPrincipal)
 {
-  MOZ_ASSERT(aTriggeringPrincipal, "need a valid triggeringPrincipal");
-  if (!aTriggeringPrincipal) {
-    return NS_ERROR_FAILURE;
-  }
   mShared->mTriggeringPrincipal = aTriggeringPrincipal;
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsSHEntry::GetPrincipalToInherit(nsIPrincipal** aPrincipalToInherit)
 {
   NS_IF_ADDREF(*aPrincipalToInherit = mShared->mPrincipalToInherit);
--- a/docshell/test/chrome/bug303267.html
+++ b/docshell/test/chrome/bug303267.html
@@ -8,17 +8,17 @@
 <script>
 var pageshowcount = 0;
 function showpageshowcount()
 {
 	pageshowcount++;
 	var div1 = document.getElementById("div1");
 	while (div1.firstChild)
 	{
-		div1.removeChild(div1.firstChild);
+		div1.firstChild.remove();
 	}
 	div1.appendChild(document.createTextNode(
 	  "pageshowcount: " + pageshowcount));
 }
 </script>
 <div id="div1">
 	</div>
 </body>
--- a/docshell/test/navigation/file_bug534178.html
+++ b/docshell/test/navigation/file_bug534178.html
@@ -1,14 +1,14 @@
 <html>
   <head>
     <script>
     
       function testDone() {
-        document.body.removeChild(document.body.firstChild);
+        document.body.firstChild.remove();
         var isOK = false;
         try {
           isOK = history.previous != location;
         } catch(ex) {
           // history.previous should throw if this is the first page in shistory.
           isOK = true;
         }
         document.body.textContent = isOK ? "PASSED" : "FAILED";
--- a/docshell/test/test_bug570341.html
+++ b/docshell/test/test_bug570341.html
@@ -26,17 +26,17 @@ https://bugzilla.mozilla.org/show_bug.cg
       }
     }
     moments['evt_unload'] = unload;
     return moments;
   }
 
   function showSequence(node){
     while(node.firstChild) {
-      node.removeChild(node.firstChild);
+      node.firstChild.remove();
     }
     var sequence = [];
     for (var p in moments) {
       sequence.push(p);
     }
     sequence.sort(function(a, b){
       return moments[a] - moments[b];
     });
--- a/dom/animation/Animation.cpp
+++ b/dom/animation/Animation.cpp
@@ -411,32 +411,36 @@ Promise*
 Animation::GetReady(ErrorResult& aRv)
 {
   nsCOMPtr<nsIGlobalObject> global = GetOwnerGlobal();
   if (!mReady && global) {
     mReady = Promise::Create(global, aRv); // Lazily create on demand
   }
   if (!mReady) {
     aRv.Throw(NS_ERROR_FAILURE);
-  } else if (PlayState() != AnimationPlayState::Pending) {
+    return nullptr;
+  }
+  if (PlayState() != AnimationPlayState::Pending) {
     mReady->MaybeResolve(this);
   }
   return mReady;
 }
 
 Promise*
 Animation::GetFinished(ErrorResult& aRv)
 {
   nsCOMPtr<nsIGlobalObject> global = GetOwnerGlobal();
   if (!mFinished && global) {
     mFinished = Promise::Create(global, aRv); // Lazily create on demand
   }
   if (!mFinished) {
     aRv.Throw(NS_ERROR_FAILURE);
-  } else if (mFinishedIsResolved) {
+    return nullptr;
+  }
+  if (mFinishedIsResolved) {
     MaybeResolveFinishedPromise();
   }
   return mFinished;
 }
 
 void
 Animation::Cancel()
 {
--- a/dom/animation/KeyframeUtils.cpp
+++ b/dom/animation/KeyframeUtils.cpp
@@ -468,18 +468,18 @@ KeyframeUtils::GetKeyframesFromObject(JS
                "Should not set any keyframes when there is an error");
     return keyframes;
   }
 
   // FIXME: Bug 1311257: Support missing keyframes for Servo backend.
   if ((!AnimationUtils::IsCoreAPIEnabled() ||
        aDocument->IsStyledByServo()) &&
       RequiresAdditiveAnimation(keyframes, aDocument)) {
+    keyframes.Clear();
     aRv.Throw(NS_ERROR_DOM_ANIM_MISSING_PROPS_ERR);
-    keyframes.Clear();
   }
 
   return keyframes;
 }
 
 /* static */ void
 KeyframeUtils::ApplySpacing(nsTArray<Keyframe>& aKeyframes,
                             SpacingMode aSpacingMode,
@@ -765,18 +765,18 @@ GetKeyframeListFromKeyframeSequence(JSCo
                                     ErrorResult& aRv)
 {
   MOZ_ASSERT(!aRv.Failed());
   MOZ_ASSERT(aResult.IsEmpty());
 
   // Convert the object in aIterator to a sequence of keyframes producing
   // an array of Keyframe objects.
   if (!ConvertKeyframeSequence(aCx, aDocument, aIterator, aResult)) {
+    aResult.Clear();
     aRv.Throw(NS_ERROR_FAILURE);
-    aResult.Clear();
     return;
   }
 
   // If the sequence<> had zero elements, we won't generate any
   // keyframes.
   if (aResult.IsEmpty()) {
     return;
   }
--- a/dom/base/StructuredCloneHolder.cpp
+++ b/dom/base/StructuredCloneHolder.cpp
@@ -297,16 +297,17 @@ StructuredCloneHolder::Read(nsISupports*
   MOZ_ASSERT(aParent);
 
   mozilla::AutoRestore<nsISupports*> guard(mParent);
   mParent = aParent;
 
   if (!StructuredCloneHolderBase::Read(aCx, aValue)) {
     JS_ClearPendingException(aCx);
     aRv.Throw(NS_ERROR_DOM_DATA_CLONE_ERR);
+    return;
   }
 
   // If we are tranferring something, we cannot call 'Read()' more than once.
   if (mSupportsTransferring) {
     mBlobImplArray.Clear();
     mClonedSurfaces.Clear();
     Clear();
   }
--- a/dom/base/TextInputProcessor.cpp
+++ b/dom/base/TextInputProcessor.cpp
@@ -693,16 +693,23 @@ TextInputProcessor::NotifyIME(TextEventD
       CancelCompositionInternal();
       return NS_OK;
     }
     default:
       return NS_ERROR_NOT_IMPLEMENTED;
   }
 }
 
+NS_IMETHODIMP_(nsIMEUpdatePreference)
+TextInputProcessor::GetIMEUpdatePreference()
+{
+  // TextInputProcessor::NotifyIME does not require extra change notifications.
+  return nsIMEUpdatePreference();
+}
+
 NS_IMETHODIMP_(void)
 TextInputProcessor::OnRemovedFrom(TextEventDispatcher* aTextEventDispatcher)
 {
   // If This is called while this is being initialized, ignore the call.
   if (!mDispatcher) {
     return;
   }
   MOZ_ASSERT(aTextEventDispatcher == mDispatcher,
--- a/dom/base/TextInputProcessor.h
+++ b/dom/base/TextInputProcessor.h
@@ -27,16 +27,19 @@ public:
   TextInputProcessor();
 
   NS_DECL_ISUPPORTS
   NS_DECL_NSITEXTINPUTPROCESSOR
 
   // TextEventDispatcherListener
   NS_IMETHOD NotifyIME(TextEventDispatcher* aTextEventDispatcher,
                        const IMENotification& aNotification) override;
+
+  NS_IMETHOD_(nsIMEUpdatePreference) GetIMEUpdatePreference() override;
+
   NS_IMETHOD_(void)
     OnRemovedFrom(TextEventDispatcher* aTextEventDispatcher) override;
 
   NS_IMETHOD_(void) WillDispatchKeyboardEvent(
                       TextEventDispatcher* aTextEventDispatcher,
                       WidgetKeyboardEvent& aKeyboardEvent,
                       uint32_t aIndexOfKeypress,
                       void* aData) override;
--- a/dom/base/crashtests/771639.html
+++ b/dom/base/crashtests/771639.html
@@ -1,12 +1,12 @@
 <!DOCTYPE html>
 <script>
 var root = document.documentElement;
-while(root.firstChild) { root.removeChild(root.firstChild); }
+while(root.firstChild) { root.firstChild.remove(); }
 var div = document.createElement("div");
 root.appendChild(div);
 
 document.addEventListener("DOMNodeRemoved", function() {
   root.appendChild(document.createTextNode("some mutation"));
 });
 
 var range = document.createRange();
--- a/dom/base/nsDOMAttributeMap.cpp
+++ b/dom/base/nsDOMAttributeMap.cpp
@@ -314,18 +314,19 @@ nsDOMAttributeMap::SetNamedItemNS(Attr& 
   // its value in the element. @see bug 364413.
   nsAttrKey attrkey(ni->NamespaceID(), ni->NameAtom());
   mAttributeCache.Put(attrkey, &aAttr);
   aAttr.SetMap(this);
 
   rv = mContent->SetAttr(ni->NamespaceID(), ni->NameAtom(),
                          ni->GetPrefixAtom(), value, true);
   if (NS_FAILED(rv)) {
+    DropAttribute(ni->NamespaceID(), ni->NameAtom());
     aError.Throw(rv);
-    DropAttribute(ni->NamespaceID(), ni->NameAtom());
+    return nullptr;
   }
 
   return oldAttr.forget();
 }
 
 already_AddRefed<Attr>
 nsDOMAttributeMap::RemoveNamedItem(NodeInfo* aNodeInfo, ErrorResult& aError)
 {
--- a/dom/base/nsFrameLoader.cpp
+++ b/dom/base/nsFrameLoader.cpp
@@ -2447,17 +2447,17 @@ nsFrameLoader::MaybeCreateDocShell()
               "docshell and document should have the same appId attribute.");
     MOZ_ASSERT(attrs.mUserContextId == oa.mUserContextId,
               "docshell and document should have the same userContextId attribute.");
     MOZ_ASSERT(attrs.mInIsolatedMozBrowser == oa.mInIsolatedMozBrowser,
               "docshell and document should have the same inIsolatedMozBrowser attribute.");
     MOZ_ASSERT(attrs.mPrivateBrowsingId == oa.mPrivateBrowsingId,
               "docshell and document should have the same privateBrowsingId attribute.");
 
-    attrs.Inherit(oa);
+    attrs = oa;
   }
 
   if (OwnerIsMozBrowserFrame()) {
     attrs.mAppId = nsIScriptSecurityManager::NO_APP_ID;
     attrs.mInIsolatedMozBrowser = OwnerIsIsolatedMozBrowserFrame();
     mDocShell->SetFrameType(nsIDocShell::FRAME_TYPE_BROWSER);
   }
 
--- a/dom/base/nsGlobalWindow.cpp
+++ b/dom/base/nsGlobalWindow.cpp
@@ -3262,17 +3262,21 @@ nsGlobalWindow::DispatchDOMWindowCreated
 
   // Fire DOMWindowCreated at chrome event listeners
   nsContentUtils::DispatchChromeEvent(mDoc, mDoc, NS_LITERAL_STRING("DOMWindowCreated"),
                                       true /* bubbles */,
                                       false /* not cancellable */);
 
   nsCOMPtr<nsIObserverService> observerService =
     mozilla::services::GetObserverService();
-  if (observerService) {
+
+  // The event dispatching could possibly cause docshell destory, and
+  // consequently cause mDoc to be set to nullptr by DropOuterWindowDocs(),
+  // so check it again here.
+  if (observerService && mDoc) {
     nsAutoString origin;
     nsIPrincipal* principal = mDoc->NodePrincipal();
     nsContentUtils::GetUTFOrigin(principal, origin);
     observerService->
       NotifyObservers(static_cast<nsIDOMWindow*>(this),
                       nsContentUtils::IsSystemPrincipal(principal) ?
                         "chrome-document-global-created" :
                         "content-document-global-created",
--- a/dom/base/nsScriptLoader.cpp
+++ b/dom/base/nsScriptLoader.cpp
@@ -1308,21 +1308,19 @@ nsScriptLoader::StartLoad(nsScriptLoadRe
 
     nsCOMPtr<nsIHttpChannelInternal> internalChannel(do_QueryInterface(httpChannel));
     if (internalChannel) {
       rv = internalChannel->SetIntegrityMetadata(aRequest->mIntegrity.GetIntegrityString());
       MOZ_ASSERT(NS_SUCCEEDED(rv));
     }
   }
 
-  OriginAttributes attrs;
-  attrs.Inherit(mDocument->NodePrincipal()->OriginAttributesRef());
-
   mozilla::net::PredictorLearn(aRequest->mURI, mDocument->GetDocumentURI(),
-      nsINetworkPredictor::LEARN_LOAD_SUBRESOURCE, attrs);
+                               nsINetworkPredictor::LEARN_LOAD_SUBRESOURCE,
+                               mDocument->NodePrincipal()->OriginAttributesRef());
 
   // Set the initiator type
   nsCOMPtr<nsITimedChannel> timedChannel(do_QueryInterface(httpChannel));
   if (timedChannel) {
     timedChannel->SetInitiatorType(NS_LITERAL_STRING("script"));
   }
 
   nsAutoPtr<mozilla::dom::SRICheckDataVerifier> sriDataVerifier;
--- a/dom/base/test/chrome/chrome.ini
+++ b/dom/base/test/chrome/chrome.ini
@@ -67,8 +67,9 @@ support-files = ../file_bug357450.js
 [test_domparsing.xul]
 [test_fileconstructor.xul]
 [test_nsITextInputProcessor.xul]
 [test_range_getClientRectsAndTexts.html]
 [test_title.xul]
 [test_windowroot.xul]
 [test_swapFrameLoaders.xul]
 [test_groupedSHistory.xul]
+[test_bug1339722.html]
new file mode 100644
--- /dev/null
+++ b/dom/base/test/chrome/test_bug1339722.html
@@ -0,0 +1,67 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=1339722
+-->
+<head>
+  <meta charset="utf-8">
+  <title>Test for Bug 1339722</title>
+  <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
+  <link rel="stylesheet" type="text/css" href="chrome://global/skin"/>
+  <link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css"/>
+  <script type="application/javascript">
+
+  /**
+   * Test for Bug 1339722
+   * 1. Wait for "http-on-useragent-request" for the iframe load.
+   * 2. In the observer, access it's window proxy to trigger DOMWindowCreated.
+   * 3. In the event handler, delete the iframe so that the frameloader would be
+   *    destoryed in the middle of ReallyStartLoading.
+   * 4. Verify that it doesn't crash.
+  **/
+
+  const {interfaces: Ci, utils: Cu} = Components;
+  Cu.import("resource://gre/modules/Services.jsm");
+
+  const TOPIC = 'http-on-useragent-request';
+  Services.obs.addObserver({
+    observe(subject, topic, data) {
+      info('Got ' + topic);
+      Services.obs.removeObserver(this, TOPIC);
+
+      // Query window proxy so it triggers DOMWindowCreated.
+      let channel = subject.QueryInterface(Ci.nsIHttpChannel);
+      let win = channel.notificationCallbacks.getInterface(Ci.mozIDOMWindowProxy);
+    }
+  }, TOPIC, false);
+
+  let docShell = SpecialPowers.wrap(window)
+                              .QueryInterface(Ci.nsIInterfaceRequestor)
+                              .getInterface(Ci.nsIDocShell);
+  docShell.chromeEventHandler.addEventListener('DOMWindowCreated', function handler(e) {
+    docShell.chromeEventHandler.removeEventListener('DOMWindowCreated', handler);
+    let iframe = document.getElementById('testFrame');
+    is(e.target, iframe.contentDocument, 'verify event target');
+
+    // Remove the iframe to cause frameloader destroy.
+    iframe.remove();
+    setTimeout($ => {
+      ok(!document.getElementById('testFrame'), 'verify iframe removed');
+      SimpleTest.finish();
+    }, 0);
+  });
+
+  SimpleTest.waitForExplicitFinish();
+  </script>
+</head>
+<body>
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1339722">Mozilla Bug 1339722</a>
+<p id="display"></p>
+<div id="content" style="display: none"></div>
+<pre id="test">
+  <div id="frameContainer">
+    <iframe id="testFrame" src="http://www.example.com"></iframe>
+  </div>
+</pre>
+</body>
+</html>
--- a/dom/base/test/test_bug416383.html
+++ b/dom/base/test/test_bug416383.html
@@ -21,17 +21,17 @@ https://bugzilla.mozilla.org/show_bug.cg
 /** Test for Bug 416383 **/
 
 function runTest() {
   var testParent = document.getElementById("test_parent");
   var attrs = testParent.firstChild.attributes;
   ok(attrs != null, "Element should have attributes!");
   var attr = testParent.firstChild.getAttributeNode("someattr");
   ok(attr.value == "foo", "The value of the attribute should be 'foo'!");
-  testParent.removeChild(testParent.firstChild);
+  testParent.firstChild.remove();
   SpecialPowers.gc();
   ok(true, "Browser should not crash!")
 
 }
 
 SimpleTest.waitForExplicitFinish();
 addLoadEvent(runTest);
 addLoadEvent(SimpleTest.finish);
--- a/dom/base/test/test_mutationobservers.html
+++ b/dom/base/test/test_mutationobservers.html
@@ -241,17 +241,17 @@ function testChildList() {
       is(records[0].addedNodes.length, 0, "Shouldn't have got addedNodes");
       is(records[0].removedNodes.length, 1, "Should have got removedNodes");
       is(records[0].removedNodes[0], fc, "Should have removed a text node");
       observer.disconnect();
       then(testChildList2);
       m = null;
     });
   m.observe(div, { childList: true});
-  div.removeChild(div.firstChild);
+  div.firstChild.remove();
 }
 
 function testChildList2() {
   div.innerHTML = "<span>1</span><span>2</span>";
   m = new M(function(records, observer) {
       is(records[0].type, "childList", "Should have got childList");
       is(records[0].removedNodes.length, 2, "Should have got removedNodes");
       is(records[0].addedNodes.length, 1, "Should have got addedNodes");
--- a/dom/bindings/CallbackObject.cpp
+++ b/dom/bindings/CallbackObject.cpp
@@ -329,17 +329,17 @@ CallbackObject::CallSetup::~CallSetup()
       // runs.  Note that we've already run ~mAc, effectively, so we don't have
       // to worry about ordering here.
       if (mErrorResult.IsJSContextException()) {
         // XXXkhuey bug 1117269.  When this is fixed, please consider fixing
         // ThrowExceptionValueIfSafe over in Exceptions.cpp in the same way.
 
         // IsJSContextException shouldn't be true anymore because we will report
         // the exception on the JSContext ... so throw something else.
-        mErrorResult.Throw(NS_ERROR_UNEXPECTED);
+        mErrorResult.ThrowWithCustomCleanup(NS_ERROR_UNEXPECTED);
       }
     }
   }
 
   mAutoIncumbentScript.reset();
   mAutoEntryScript.reset();
 
   // It is important that this is the last thing we do, after leaving the
--- a/dom/bindings/Codegen.py
+++ b/dom/bindings/Codegen.py
@@ -5463,17 +5463,17 @@ def getJSToNativeConversionInfo(type, de
               JS::Rooted<JS::Value> valueToResolve(cx, $${val});
               if (!JS_WrapValue(cx, &valueToResolve)) {
                 $*{exceptionCode}
               }
               binding_detail::FastErrorResult promiseRv;
               nsCOMPtr<nsIGlobalObject> global =
                 do_QueryInterface(promiseGlobal.GetAsSupports());
               if (!global) {
-                promiseRv.Throw(NS_ERROR_UNEXPECTED);
+                promiseRv.ThrowWithCustomCleanup(NS_ERROR_UNEXPECTED);
                 promiseRv.MaybeSetPendingException(cx);
                 $*{exceptionCode}
               }
               $${declName} = Promise::Resolve(global, cx, valueToResolve,
                                               promiseRv);
               if (promiseRv.MaybeSetPendingException(cx)) {
                 $*{exceptionCode}
               }
--- a/dom/bindings/ErrorResult.h
+++ b/dom/bindings/ErrorResult.h
@@ -160,21 +160,58 @@ public:
     : TErrorResult()
   {
     AssignErrorCode(aRv);
   }
 
   operator ErrorResult&();
   operator OOMReporter&();
 
-  void Throw(nsresult rv) {
+  void MOZ_MUST_RETURN_FROM_CALLER Throw(nsresult rv) {
     MOZ_ASSERT(NS_FAILED(rv), "Please don't try throwing success");
     AssignErrorCode(rv);
   }
 
+  // This method acts identically to the `Throw` method, however, it does not
+  // have the MOZ_MUST_RETURN_FROM_CALLER static analysis annotation. It is
+  // intended to be used in situations when additional work needs to be
+  // performed in the calling function after the Throw method is called.
+  //
+  // In general you should prefer using `Throw`, and returning after an error,
+  // for example:
+  //
+  //   if (condition) {
+  //     aRv.Throw(NS_ERROR_FAILURE);
+  //     return;
+  //   }
+  //
+  // or
+  //
+  //   if (condition) {
+  //     aRv.Throw(NS_ERROR_FAILURE);
+  //   }
+  //   return;
+  //
+  // However, if you need to do some other work after throwing, such as:
+  //
+  //   if (condition) {
+  //     aRv.ThrowWithCustomCleanup(NS_ERROR_FAILURE);
+  //   }
+  //   // Do some important clean-up work which couldn't happen earlier.
+  //   // We want to do this clean-up work in both the success and failure cases.
+  //   CleanUpImportantState();
+  //   return;
+  //
+  // Then you'll need to use ThrowWithCustomCleanup to get around the static
+  // analysis, which would complain that you are doing work after the call to
+  // `Throw()`.
+  void ThrowWithCustomCleanup(nsresult rv) {
+    Throw(rv);
+  }
+
   // Duplicate our current state on the given TErrorResult object.  Any
   // existing errors or messages on the target will be suppressed before
   // cloning.  Our own error state remains unchanged.
   void CloneTo(TErrorResult& aRv) const;
 
   // Use SuppressException when you want to suppress any exception that might be
   // on the TErrorResult.  After this call, the TErrorResult will be back a "no
   // exception thrown" state.
@@ -302,17 +339,17 @@ public:
 
   // Check whether the TErrorResult says to just throw whatever is on
   // the JSContext already.
   bool IsJSContextException() {
     return ErrorCode() == NS_ERROR_INTERNAL_ERRORRESULT_EXCEPTION_ON_JSCONTEXT;
   }
 
   // Support for uncatchable exceptions.
-  void ThrowUncatchableException() {
+  void MOZ_MUST_RETURN_FROM_CALLER ThrowUncatchableException() {
     Throw(NS_ERROR_UNCATCHABLE_EXCEPTION);
   }
   bool IsUncatchableException() const {
     return ErrorCode() == NS_ERROR_UNCATCHABLE_EXCEPTION;
   }
 
   void MOZ_ALWAYS_INLINE MightThrowJSException()
   {
--- a/dom/canvas/ImageBitmap.cpp
+++ b/dom/canvas/ImageBitmap.cpp
@@ -1477,16 +1477,17 @@ ImageBitmap::Create(nsIGlobalObject* aGl
     imageBitmap = CreateInternal(aGlobal, aSrc.GetAsCanvasRenderingContext2D(), aCropRect, aRv);
   } else if (aSrc.IsImageBitmap()) {
     imageBitmap = CreateInternal(aGlobal, aSrc.GetAsImageBitmap(), aCropRect, aRv);
   } else if (aSrc.IsBlob()) {
     AsyncCreateImageBitmapFromBlob(promise, aGlobal, aSrc.GetAsBlob(), aCropRect);
     return promise.forget();
   } else {
     aRv.Throw(NS_ERROR_NOT_IMPLEMENTED);
+    return nullptr;
   }
 
   if (!aRv.Failed()) {
     AsyncFulfillImageBitmapPromise(promise, imageBitmap);
   }
 
   return promise.forget();
 }
@@ -1686,33 +1687,33 @@ protected:
     uint8_t* bufferData = nullptr;
     uint32_t bufferLength = 0;
     bool isSharedMemory = false;
     if (JS_IsArrayBufferObject(mBuffer)) {
       js::GetArrayBufferLengthAndData(mBuffer, &bufferLength, &isSharedMemory, &bufferData);
     } else if (JS_IsArrayBufferViewObject(mBuffer)) {
       js::GetArrayBufferViewLengthAndData(mBuffer, &bufferLength, &isSharedMemory, &bufferData);
     } else {
-      error.Throw(NS_ERROR_NOT_IMPLEMENTED);
+      error.ThrowWithCustomCleanup(NS_ERROR_NOT_IMPLEMENTED);
       mPromise->MaybeReject(error);
       return;
     }
 
     if (NS_WARN_IF(!bufferData) || NS_WARN_IF(!bufferLength)) {
-      error.Throw(NS_ERROR_NOT_AVAILABLE);
+      error.ThrowWithCustomCleanup(NS_ERROR_NOT_AVAILABLE);
       mPromise->MaybeReject(error);
       return;
     }
 
     // Check length.
     const int32_t neededBufferLength =
       mImageBitmap->MappedDataLength(mFormat, error);
 
     if (((int32_t)bufferLength - mOffset) < neededBufferLength) {
-      error.Throw(NS_ERROR_DOM_INDEX_SIZE_ERR);
+      error.ThrowWithCustomCleanup(NS_ERROR_DOM_INDEX_SIZE_ERR);
       mPromise->MaybeReject(error);
       return;
     }
 
     // Call ImageBitmapFormatUtils.
     UniquePtr<ImagePixelLayout> layout =
       mImageBitmap->mDataWrapper->MapDataInto(bufferData,
                                               mOffset,
--- a/dom/canvas/WebGLContextVertices.cpp
+++ b/dom/canvas/WebGLContextVertices.cpp
@@ -245,19 +245,21 @@ WebGLContext::GetVertexAttrib(JSContext*
                 obj =  GetVertexAttribInt32Array(cx, index);
                 break;
 
             case LOCAL_GL_UNSIGNED_INT:
                 obj = GetVertexAttribUint32Array(cx, index);
                 break;
             }
 
-            if (!obj)
+            if (!obj) {
                 rv.Throw(NS_ERROR_OUT_OF_MEMORY);
-            return JS::ObjectOrNullValue(obj);
+                return JS::NullValue();
+            }
+            return JS::ObjectValue(*obj);
         }
 
     case LOCAL_GL_VERTEX_ATTRIB_ARRAY_ENABLED:
         return JS::BooleanValue(mBoundVertexArray->mAttribs[index].mEnabled);
 
     case LOCAL_GL_VERTEX_ATTRIB_ARRAY_NORMALIZED:
         return JS::BooleanValue(mBoundVertexArray->mAttribs[index].Normalized());
 
--- a/dom/encoding/TextEncoder.cpp
+++ b/dom/encoding/TextEncoder.cpp
@@ -62,16 +62,17 @@ TextEncoder::Encode(JSContext* aCx,
     if (!outView) {
       aRv.Throw(NS_ERROR_OUT_OF_MEMORY);
       return;
     }
   }
 
   if (NS_FAILED(rv)) {
     aRv.Throw(rv);
+    return;
   }
   aRetval.set(outView);
 }
 
 void
 TextEncoder::GetEncoding(nsAString& aEncoding)
 {
   aEncoding.AssignLiteral("utf-8");
--- a/dom/events/DataTransfer.cpp
+++ b/dom/events/DataTransfer.cpp
@@ -327,18 +327,21 @@ DataTransfer::GetTypes(nsTArray<nsString
   for (uint32_t i = 0; i < items->Length(); i++) {
     DataTransferItem* item = items->ElementAt(i);
     MOZ_ASSERT(item);
 
     if (item->ChromeOnly() && aCallerType != CallerType::System) {
       continue;
     }
 
+    // NOTE: The reason why we get the internal type here is because we want
+    // kFileMime to appear in the types list for backwards compatibility
+    // reasons.
     nsAutoString type;
-    item->GetType(type);
+    item->GetInternalType(type);
     if (item->Kind() == DataTransferItem::KIND_STRING || type.EqualsASCII(kFileMime)) {
       // If the entry has kind KIND_STRING, we want to add it to the list.
       aTypes.AppendElement(type);
     }
   }
 
   for (uint32_t i = 0; i < mItems->Length(); ++i) {
     bool found = false;
@@ -516,18 +519,21 @@ DataTransfer::MozTypesAt(uint32_t aIndex
     const nsTArray<RefPtr<DataTransferItem>>& items = *mItems->MozItemsAt(aIndex);
 
     bool addFile = false;
     for (uint32_t i = 0; i < items.Length(); i++) {
       if (items[i]->ChromeOnly() && aCallerType != CallerType::System) {
         continue;
       }
 
+      // NOTE: The reason why we get the internal type here is because we want
+      // kFileMime to appear in the types list for backwards compatibility
+      // reasons.
       nsAutoString type;
-      items[i]->GetType(type);
+      items[i]->GetInternalType(type);
       if (NS_WARN_IF(!types->Add(type))) {
         aRv.Throw(NS_ERROR_FAILURE);
         return nullptr;
       }
 
       if (items[i]->Kind() == DataTransferItem::KIND_FILE) {
         addFile = true;
       }
@@ -976,17 +982,17 @@ DataTransfer::GetTransferable(uint32_t a
     for (uint32_t f = 0; f < count; f++) {
       RefPtr<DataTransferItem> formatitem = item[f];
       nsCOMPtr<nsIVariant> variant = formatitem->DataNoSecurityCheck();
       if (!variant) { // skip empty items
         continue;
       }
 
       nsAutoString type;
-      formatitem->GetType(type);
+      formatitem->GetInternalType(type);
 
       // If the data is of one of the well-known formats, use it directly.
       bool isCustomFormat = true;
       for (uint32_t f = 0; f < ArrayLength(knownFormats); f++) {
         if (type.EqualsASCII(knownFormats[f])) {
           isCustomFormat = false;
           break;
         }
--- a/dom/events/DataTransferItem.cpp
+++ b/dom/events/DataTransferItem.cpp
@@ -225,16 +225,47 @@ DataTransferItem::FillInExternalData()
   SetData(variant);
 
   if (oldKind != Kind()) {
     NS_WARNING("Clipboard data provided by the OS does not match predicted kind");
     mDataTransfer->TypesListMayHaveChanged();
   }
 }
 
+void
+DataTransferItem::GetType(nsAString& aType)
+{
+  // If we don't have a File, we can just put whatever our recorded internal
+  // type is.
+  if (Kind() != KIND_FILE) {
+    aType = mType;
+    return;
+  }
+
+  // If we do have a File, then we need to look at our File object to discover
+  // what its mime type is. We can use the System Principal here, as this
+  // information should be avaliable even if the data is currently inaccessible
+  // (for example during a dragover).
+  //
+  // XXX: This seems inefficient, as it seems like we should be able to get this
+  // data without getting the entire File object, which may require talking to
+  // the OS.
+  ErrorResult rv;
+  RefPtr<File> file = GetAsFile(*nsContentUtils::GetSystemPrincipal(), rv);
+  MOZ_ASSERT(!rv.Failed(), "Failed to get file data with system principal");
+
+  // If we don't actually have a file, fall back to returning the internal type.
+  if (NS_WARN_IF(!file)) {
+    aType = mType;
+    return;
+  }
+
+  file->GetType(aType);
+}
+
 already_AddRefed<File>
 DataTransferItem::GetAsFile(nsIPrincipal& aSubjectPrincipal,
                             ErrorResult& aRv)
 {
   // This is done even if we have an mCachedFile, as it performs the necessary
   // permissions checks to ensure that we are allowed to access this type.
   nsCOMPtr<nsIVariant> data = Data(&aSubjectPrincipal, aRv);
   if (NS_WARN_IF(!data || aRv.Failed())) {
--- a/dom/events/DataTransferItem.h
+++ b/dom/events/DataTransferItem.h
@@ -64,21 +64,23 @@ public:
       aKind = NS_LITERAL_STRING("string");
       return;
     default:
       aKind = NS_LITERAL_STRING("other");
       return;
     }
   }
 
-  void GetType(nsAString& aType) const
+  void GetInternalType(nsAString& aType) const
   {
     aType = mType;
   }
 
+  void GetType(nsAString& aType);
+
   eKind Kind() const
   {
     return mKind;
   }
 
   already_AddRefed<File>
   GetAsFile(nsIPrincipal& aSubjectPrincipal, ErrorResult& aRv);
 
--- a/dom/events/DataTransferItemList.cpp
+++ b/dom/events/DataTransferItemList.cpp
@@ -289,18 +289,19 @@ DataTransferItemList::MozRemoveByTypeAt(
 
     // items is no longer a valid reference, as removing the last element from
     // it via ClearDataHelper invalidated it. so we can't MOZ_ASSERT that the
     // length is now 0.
     return;
   }
 
   for (uint32_t i = 0; i < count; ++i) {
+    // NOTE: As this is a moz-prefixed API, it works based on internal types.
     nsAutoString type;
-    items[i]->GetType(type);
+    items[i]->GetInternalType(type);
     if (type == aType) {
       ClearDataHelper(items[i], -1, i, aSubjectPrincipal, aRv);
       return;
     }
   }
 }
 
 DataTransferItem*
@@ -308,18 +309,19 @@ DataTransferItemList::MozItemByTypeAt(co
 {
   if (NS_WARN_IF(aIndex >= mIndexedItems.Length())) {
     return nullptr;
   }
 
   uint32_t count = mIndexedItems[aIndex].Length();
   for (uint32_t i = 0; i < count; i++) {
     RefPtr<DataTransferItem> item = mIndexedItems[aIndex][i];
+    // NOTE: As this is a moz-prefixed API it works on internal types
     nsString type;
-    item->GetType(type);
+    item->GetInternalType(type);
     if (type.Equals(aType)) {
       return item;
     }
   }
 
   return nullptr;
 }
 
@@ -333,17 +335,17 @@ DataTransferItemList::SetDataWithPrincip
                                            ErrorResult& aRv)
 {
   if (aIndex < mIndexedItems.Length()) {
     nsTArray<RefPtr<DataTransferItem>>& items = mIndexedItems[aIndex];
     uint32_t count = items.Length();
     for (uint32_t i = 0; i < count; i++) {
       RefPtr<DataTransferItem> item = items[i];
       nsString type;
-      item->GetType(type);
+      item->GetInternalType(type);
       if (type.Equals(aType)) {
         if (NS_WARN_IF(aInsertOnly)) {
           aRv.Throw(NS_ERROR_DOM_NOT_SUPPORTED_ERR);
           return nullptr;
         }
 
         // don't allow replacing data that has a stronger principal
         bool subsumes;
--- a/dom/events/test/test_DataTransferItemList.html
+++ b/dom/events/test/test_DataTransferItemList.html
@@ -93,17 +93,17 @@
          "Adding a non-file entry to a non-zero index should not add an item to the items list");
 
       var file3 = new File(['<a id="e"><b id="f">heya!</b></a>'], "yetanotherfile.html",
                            {type: "text/html"});
       e.dataTransfer.mozSetDataAt("random/string", file3, 3);
       is(oldLength + 1, dtList.length,
          "Replacing the entry with a file should add it to the list!");
       is(dtList[oldLength].getAsFile(), file3, "It should be stored in the last index as a file");
-      is(dtList[oldLength].type, "random/string", "It should have the correct type");
+      is(dtList[oldLength].type, "text/html", "It should have the correct type");
       is(dtList[oldLength].kind, "file", "It should have the correct kind");
 
       todo(files.length == 3, "This test has chrome privileges, so the FileList objects aren't updated live");
       files = e.dataTransfer.files;
       is(files[files.length - 1], file3, "It should also be in the files list");
 
       oldLength = dtList.length;
       var nonstring = {};
--- a/dom/filesystem/GetFilesTask.cpp
+++ b/dom/filesystem/GetFilesTask.cpp
@@ -197,18 +197,18 @@ FileSystemResponseValue
 GetFilesTaskParent::GetSuccessRequestResult(ErrorResult& aRv) const
 {
   AssertIsOnBackgroundThread();
 
   InfallibleTArray<PBlobParent*> blobs;
 
   FallibleTArray<FileSystemFileResponse> inputs;
   if (!inputs.SetLength(mTargetBlobImplArray.Length(), mozilla::fallible_t())) {
+    FileSystemFilesResponse response;
     aRv.Throw(NS_ERROR_OUT_OF_MEMORY);
-    FileSystemFilesResponse response;
     return response;
   }
 
   for (unsigned i = 0; i < mTargetBlobImplArray.Length(); i++) {
     BlobParent* blobParent =
       BlobParent::GetOrCreate(mRequestParent->Manager(),
                               mTargetBlobImplArray[i]);
     inputs[i] = FileSystemFileResponse(blobParent, nullptr);
--- a/dom/flyweb/FlyWebService.cpp
+++ b/dom/flyweb/FlyWebService.cpp
@@ -1188,17 +1188,17 @@ FlyWebService::PairWithService(const nsA
   } else if (mMDNSFlywebService && mMDNSFlywebService->HasService(aServiceId)) {
     rv = mMDNSFlywebService->PairWithService(aServiceId, pairInfo);
   } else {
     notFound = true;
   }
 
   if (NS_FAILED(rv)) {
     ErrorResult result;
-    result.Throw(rv);
+    result.ThrowWithCustomCleanup(rv);
     const nsAString& reason = NS_LITERAL_STRING("Error pairing.");
     aCallback.PairingFailed(reason, result);
     ENSURE_SUCCESS_VOID(result);
     return;
   }
 
   if (!pairInfo) {
     ErrorResult res;
--- a/dom/flyweb/HttpServer.cpp
+++ b/dom/flyweb/HttpServer.cpp
@@ -187,19 +187,18 @@ HttpServer::AcceptWebSocket(InternalRequ
     if (aRv.Failed()) {
       conn->Close();
     }
     // This connection is now owned by the websocket, or we just closed it
     mConnections.RemoveElement(conn);
     return provider.forget();
   }
 
+  MOZ_ASSERT(false, "Unknown request");
   aRv.Throw(NS_ERROR_UNEXPECTED);
-  MOZ_ASSERT(false, "Unknown request");
-
   return nullptr;
 }
 
 void
 HttpServer::SendWebSocketResponse(InternalRequest* aConnectRequest,
                                   InternalResponse* aResponse)
 {
   for (Connection* conn : mConnections) {
--- a/dom/html/HTMLMediaElement.cpp
+++ b/dom/html/HTMLMediaElement.cpp
@@ -2696,16 +2696,17 @@ HTMLMediaElement::Seek(double aTime,
   mPlayingBeforeSeek = IsPotentiallyPlaying();
 
   // The media backend is responsible for dispatching the timeupdate
   // event if it changes the playback position as a result of the seek.
   LOG(LogLevel::Debug, ("%p SetCurrentTime(%f) starting seek", this, aTime));
   nsresult rv = mDecoder->Seek(aTime, aSeekType, promise);
   if (NS_FAILED(rv)) {
     aRv.Throw(rv);
+    return nullptr;
   }
 
   // We changed whether we're seeking so we need to AddRemoveSelfReference.
   AddRemoveSelfReference();
 
   return promise.forget();
 }
 
--- a/dom/html/crashtests/453406-1.html
+++ b/dom/html/crashtests/453406-1.html
@@ -1,16 +1,16 @@
 <html>
 <head>
 <script type="text/javascript">
 function boom()
 {
   var r = document.documentElement;
   while (r.firstChild)
-    r.removeChild(r.firstChild);
+    r.firstChild.remove();
 
   var b    = document.createElement("BODY");
   var s    = document.createElement("SCRIPT");
   var f1   = document.createElement("FORM");
   var i    = document.createElement("INPUT");
   var br   = document.createElement("BR");
   var f2   = document.createElement("FORM");
   var span = document.createElement("SPAN");
--- a/dom/html/crashtests/564461.xhtml
+++ b/dom/html/crashtests/564461.xhtml
@@ -6,17 +6,17 @@
   <binding id="editable"><content><div contenteditable="true" xmlns="http://www.w3.org/1999/xhtml"></div></content></binding>
 </bindings>
 
 <script type="text/javascript">
 <![CDATA[
 
 function boom()
 {
-  while (document.documentElement.firstChild) document.documentElement.removeChild(document.documentElement.firstChild);
+  while (document.documentElement.firstChild) document.documentElement.firstChild.remove();
   
   document.addEventListener("DOMSubtreeModified", function(){});
   document.addEventListener("DOMNodeInsertedIntoDocument", function(){});
   document.documentElement.appendChild(document.createElementNS("http://www.w3.org/1999/xhtml", "body"));
   document.body.style.MozBinding = 'url(#editable)';
 }
 
 ]]>
--- a/dom/html/test/forms/test_form_attribute-1.html
+++ b/dom/html/test/forms/test_form_attribute-1.html
@@ -419,17 +419,17 @@ for (var name of elementNames) {
   var elements = [
     document.createElement(name),
     document.createElement(name),
   ];
 
   for (var func of functions) {
     // Clean-up.
     while (content.firstChild) {
-      content.removeChild(content.firstChild);
+      content.firstChild.remove();
     }
     for (form of forms) {
       content.appendChild(form);
       form.removeAttribute('id');
     }
     for (e of elements) {
       content.appendChild(e);
       e.removeAttribute('form');
--- a/dom/html/test/test_bug300691-1.html
+++ b/dom/html/test/test_bug300691-1.html
@@ -90,17 +90,17 @@ valueIs("abcdeTesth",
         "Appending textnode shouldn't affect value in edited textarea");
 defValueIs("abcdefghijk", "Appended textnode 3");
 
 t.lastChild.data = "lmno";
 valueIs("abcdeTesth",
         "Modifying textnode text shouldn't affect value in edited textarea");
 defValueIs("abcdefghlmno", "Modified textnode text 3");
 
-t.removeChild(t.firstChild);
+t.firstChild.remove();
 valueIs("abcdeTesth",
         "Removing child textnode shouldn't affect value in edited textarea");
 defValueIs("defghlmno", "Removed textnode 3");
 
 t.insertBefore(document.createTextNode("abc"), t.firstChild);
 valueIs("abcdeTesth",
         "Inserting child textnode shouldn't affect value in edited textarea");
 defValueIs("abcdefghlmno", "Inserted a text node");
--- a/dom/html/test/test_bug311681.html
+++ b/dom/html/test/test_bug311681.html
@@ -73,17 +73,17 @@ https://bugzilla.mozilla.org/show_bug.cg
 
     // Check what getElementById returns now.
     is(getCont(), node, "Should be getting clone post-flush");
 
   }
 
   function clear(node) {
     while (node.hasChildNodes()) {
-      node.removeChild(node.firstChild);
+      node.firstChild.remove();
     }
   }
 
   addLoadEvent(testClone);
   addLoadEvent(SimpleTest.finish);
 </script>
 <p id="display"></p>
 <div id="content" style="display: none">
--- a/dom/html/test/test_bug311681.xhtml
+++ b/dom/html/test/test_bug311681.xhtml
@@ -73,17 +73,17 @@ https://bugzilla.mozilla.org/show_bug.cg
 
     // Check what getElementById returns now.
     is(getCont(), node, "Should be getting clone post-flush");
 
   }
 
   function clear(node) {
     while (node.hasChildNodes()) {
-      node.removeChild(node.firstChild);
+      node.firstChild.remove();
     }
   }
 
   addLoadEvent(testClone);
   addLoadEvent(SimpleTest.finish);
 ]]>
 </script>
 <p id="display"></p>
--- a/dom/html/test/test_bug691.html
+++ b/dom/html/test/test_bug691.html
@@ -18,17 +18,17 @@ function show(what) {
     stage.insertBefore(spaghetti,stage.firstChild);
   }
 }
 
 function remove() {
   var stage = document.getElementById("stage");
   var body = document.getElementsByTagName("BODY")[0];
   while (stage.firstChild) {
-    stage.removeChild(stage.firstChild);
+    stage.firstChild.remove();
   }
 }
 
 </script>
 </head>
 <body>
 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=691">Mozilla Bug 691</a>
 <p id="display"></p>
--- a/dom/ipc/URLClassifierParent.cpp
+++ b/dom/ipc/URLClassifierParent.cpp
@@ -20,17 +20,17 @@ URLClassifierParent::StartClassify(nsIPr
 {
   *aSuccess = false;
   nsresult rv = NS_OK;
   // Note that in safe mode, the URL classifier service isn't available, so we
   // should handle the service not being present gracefully.
   nsCOMPtr<nsIURIClassifier> uriClassifier =
     do_GetService(NS_URICLASSIFIERSERVICE_CONTRACTID, &rv);
   if (NS_SUCCEEDED(rv)) {
-    rv = uriClassifier->Classify(aPrincipal, aUseTrackingProtection,
+    rv = uriClassifier->Classify(aPrincipal, nullptr, aUseTrackingProtection,
                                  this, aSuccess);
   }
   if (NS_FAILED(rv) || !*aSuccess) {
     // We treat the case where we fail to classify and the case where the
     // classifier returns successfully but doesn't perform a lookup as the
     // classification not yielding any results, so we just kill the child actor
     // without ever calling out callback in both cases.
     // This means that code using this in the child process will only get a hit
--- a/dom/media/platforms/wmf/DXVA2Manager.cpp
+++ b/dom/media/platforms/wmf/DXVA2Manager.cpp
@@ -15,16 +15,17 @@
 #include "gfxPrefs.h"
 #include "gfxWindowsPlatform.h"
 #include "mfapi.h"
 #include "mozilla/Telemetry.h"
 #include "mozilla/gfx/DeviceManagerDx.h"
 #include "mozilla/layers/D3D11ShareHandleImage.h"
 #include "mozilla/layers/ImageBridgeChild.h"
 #include "mozilla/layers/TextureForwarder.h"
+#include "mozilla/layers/TextureD3D11.h"
 #include "nsPrintfCString.h"
 #include "nsThreadUtils.h"
 
 const CLSID CLSID_VideoProcessorMFT =
 {
   0x88753b26,
   0x5b24,
   0x49bd,
@@ -79,16 +80,18 @@ static const uint32_t kSyncSurfaceSize =
 namespace mozilla {
 
 using layers::Image;
 using layers::ImageContainer;
 using layers::D3D9SurfaceImage;
 using layers::D3D9RecycleAllocator;
 using layers::D3D11ShareHandleImage;
 using layers::D3D11RecycleAllocator;
+using namespace layers;
+using namespace gfx;
 
 class D3D9DXVA2Manager : public DXVA2Manager
 {
 public:
   D3D9DXVA2Manager();
   virtual ~D3D9DXVA2Manager();
 
   HRESULT Init(layers::KnowsCompositor* aKnowsCompositor,
@@ -588,26 +591,33 @@ D3D9DXVA2Manager::CreateDecoder(const DX
 }
 
 class D3D11DXVA2Manager : public DXVA2Manager
 {
 public:
   virtual ~D3D11DXVA2Manager();
 
   HRESULT Init(layers::KnowsCompositor* aKnowsCompositor,
-               nsACString& aFailureReason);
+               nsACString& aFailureReason,
+               ID3D11Device* aDevice);
+  HRESULT InitInternal(layers::KnowsCompositor* aKnowsCompositor,
+                       nsACString& aFailureReason,
+                       ID3D11Device* aDevice);
 
   IUnknown* GetDXVADeviceManager() override;
 
   // Copies a region (aRegion) of the video frame stored in aVideoSample
   // into an image which is returned by aOutImage.
   HRESULT CopyToImage(IMFSample* aVideoSample,
                       const nsIntRect& aRegion,
                       Image** aOutImage) override;
 
+  virtual HRESULT CopyToBGRATexture(ID3D11Texture2D *aInTexture,
+                                    ID3D11Texture2D** aOutTexture);
+
   HRESULT ConfigureForSize(uint32_t aWidth, uint32_t aHeight) override;
 
   bool IsD3D11() override { return true; }
 
   bool SupportsConfig(IMFMediaType* aType, float aFramerate) override;
 
   bool CreateDXVA2Decoder(const VideoInfo& aVideoInfo,
                           nsACString& aFailureReason) override;
@@ -620,20 +630,22 @@ private:
 
   bool CanCreateDecoder(const D3D11_VIDEO_DECODER_DESC& aDesc,
                         const float aFramerate) const;
 
   already_AddRefed<ID3D11VideoDecoder>
   CreateDecoder(const D3D11_VIDEO_DECODER_DESC& aDesc) const;
 
   RefPtr<ID3D11Device> mDevice;
+  RefPtr<ID3D11DeviceContext> mContext;
   RefPtr<IMFDXGIDeviceManager> mDXGIDeviceManager;
   RefPtr<MFTDecoder> mTransform;
   RefPtr<D3D11RecycleAllocator> mTextureClientAllocator;
   RefPtr<ID3D11VideoDecoder> mDecoder;
+  RefPtr<layers::SyncObject> mSyncObject;
   GUID mDecoderGUID;
   uint32_t mWidth = 0;
   uint32_t mHeight = 0;
   UINT mDeviceManagerToken = 0;
 };
 
 bool
 D3D11DXVA2Manager::SupportsConfig(IMFMediaType* aType, float aFramerate)
@@ -650,38 +662,98 @@ D3D11DXVA2Manager::SupportsConfig(IMFMed
 D3D11DXVA2Manager::~D3D11DXVA2Manager() { }
 
 IUnknown*
 D3D11DXVA2Manager::GetDXVADeviceManager()
 {
   MutexAutoLock lock(mLock);
   return mDXGIDeviceManager;
 }
-
 HRESULT
 D3D11DXVA2Manager::Init(layers::KnowsCompositor* aKnowsCompositor,
-                        nsACString& aFailureReason)
+                        nsACString& aFailureReason,
+                        ID3D11Device* aDevice)
 {
+  if (!NS_IsMainThread()) {
+    // DXVA Managers used for full video have to be initialized on the main
+    // thread. Managers initialized off the main thread have to pass a device
+    // and can only be used for color conversion.
+    MOZ_ASSERT(aDevice);
+    return InitInternal(aKnowsCompositor, aFailureReason, aDevice);
+  }
+
   HRESULT hr;
-
   ScopedGfxFeatureReporter reporter("DXVA2D3D11");
 
   gfx::D3D11VideoCrashGuard crashGuard;
   if (crashGuard.Crashed()) {
     NS_WARNING("DXVA2D3D11 crash detected");
     aFailureReason.AssignLiteral("DXVA2D3D11 crashes detected in the past");
     return E_FAIL;
   }
 
-  mDevice = gfx::DeviceManagerDx::Get()->CreateDecoderDevice();
+  hr = InitInternal(aKnowsCompositor, aFailureReason, aDevice);
+  NS_ENSURE_TRUE(SUCCEEDED(hr), hr);
+
+  if (layers::ImageBridgeChild::GetSingleton() || !aKnowsCompositor) {
+    // There's no proper KnowsCompositor for ImageBridge currently (and it
+    // implements the interface), so just use that if it's available.
+    mTextureClientAllocator = new D3D11RecycleAllocator(
+      layers::ImageBridgeChild::GetSingleton().get(), mDevice);
+
+    if (ImageBridgeChild::GetSingleton() && gfxPrefs::PDMWMFUseSyncTexture()) {
+      // We use a syncobject to avoid the cost of the mutex lock when compositing,
+      // and because it allows color conversion ocurring directly from this texture
+      // DXVA does not seem to accept IDXGIKeyedMutex textures as input.
+      mSyncObject =
+        layers::SyncObject::CreateSyncObject(layers::ImageBridgeChild::GetSingleton()->
+                                               GetTextureFactoryIdentifier().mSyncHandle,
+                                             mDevice);
+    }
+  } else {
+    mTextureClientAllocator =
+      new D3D11RecycleAllocator(aKnowsCompositor, mDevice);
+    if (gfxPrefs::PDMWMFUseSyncTexture()) {
+      // We use a syncobject to avoid the cost of the mutex lock when compositing,
+      // and because it allows color conversion ocurring directly from this texture
+      // DXVA does not seem to accept IDXGIKeyedMutex textures as input.
+      mSyncObject =
+        layers::SyncObject::CreateSyncObject(aKnowsCompositor->GetTextureFactoryIdentifier().mSyncHandle,
+                                             mDevice);
+    }
+  }
+  mTextureClientAllocator->SetMaxPoolSize(5);
+
+  Telemetry::Accumulate(Telemetry::MEDIA_DECODER_BACKEND_USED,
+                        uint32_t(media::MediaDecoderBackend::WMFDXVA2D3D11));
+
+  reporter.SetSuccessful();
+
+  return S_OK;
+}
+
+HRESULT
+D3D11DXVA2Manager::InitInternal(layers::KnowsCompositor* aKnowsCompositor,
+                                nsACString& aFailureReason,
+                                ID3D11Device* aDevice)
+{
+  HRESULT hr;
+
+  mDevice = aDevice;
+  
   if (!mDevice) {
-    aFailureReason.AssignLiteral("Failed to create D3D11 device for decoder");
-    return E_FAIL;
+    mDevice = gfx::DeviceManagerDx::Get()->CreateDecoderDevice();
+    if (!mDevice) {
+      aFailureReason.AssignLiteral("Failed to create D3D11 device for decoder");
+      return E_FAIL;
+    }
   }
 
+  mDevice->GetImmediateContext(getter_AddRefs(mContext));
+
   hr = wmf::MFCreateDXGIDeviceManager(&mDeviceManagerToken,
                                       getter_AddRefs(mDXGIDeviceManager));
   if (!SUCCEEDED(hr)) {
     aFailureReason =
       nsPrintfCString("MFCreateDXGIDeviceManager failed with code %X", hr);
     return hr;
   }
 
@@ -777,32 +849,16 @@ D3D11DXVA2Manager::Init(layers::KnowsCom
     for (const auto& model : sAMDPreUVD4) {
       if (adapterDesc.DeviceId == model) {
         mIsAMDPreUVD4 = true;
         break;
       }
     }
   }
 
-  if (layers::ImageBridgeChild::GetSingleton()) {
-    // There's no proper KnowsCompositor for ImageBridge currently (and it
-    // implements the interface), so just use that if it's available.
-    mTextureClientAllocator = new D3D11RecycleAllocator(
-      layers::ImageBridgeChild::GetSingleton().get(), mDevice);
-  } else {
-    mTextureClientAllocator =
-      new D3D11RecycleAllocator(aKnowsCompositor, mDevice);
-  }
-  mTextureClientAllocator->SetMaxPoolSize(5);
-
-  Telemetry::Accumulate(Telemetry::MEDIA_DECODER_BACKEND_USED,
-                        uint32_t(media::MediaDecoderBackend::WMFDXVA2D3D11));
-
-  reporter.SetSuccessful();
-
   return S_OK;
 }
 
 HRESULT
 D3D11DXVA2Manager::CreateOutputSample(RefPtr<IMFSample>& aSample,
                                       ID3D11Texture2D* aTexture)
 {
   RefPtr<IMFSample> sample;
@@ -822,48 +878,150 @@ D3D11DXVA2Manager::CreateOutputSample(Re
 
 HRESULT
 D3D11DXVA2Manager::CopyToImage(IMFSample* aVideoSample,
                                const nsIntRect& aRegion,
                                Image** aOutImage)
 {
   NS_ENSURE_TRUE(aVideoSample, E_POINTER);
   NS_ENSURE_TRUE(aOutImage, E_POINTER);
-
-  // Our video frame is stored in a non-sharable ID3D11Texture2D. We need
-  // to create a copy of that frame as a sharable resource, save its share
-  // handle, and put that handle into the rendering pipeline.
+  NS_ENSURE_TRUE(mSyncObject, E_FAIL);
+  MOZ_ASSERT(mTextureClientAllocator);
 
   RefPtr<D3D11ShareHandleImage> image =
     new D3D11ShareHandleImage(gfx::IntSize(mWidth, mHeight), aRegion);
   bool ok = image->AllocateTexture(mTextureClientAllocator, mDevice);
   NS_ENSURE_TRUE(ok, E_FAIL);
 
-  HRESULT hr = mTransform->Input(aVideoSample);
-  NS_ENSURE_TRUE(SUCCEEDED(hr), hr);
+  RefPtr<TextureClient> client = image->GetTextureClient(ImageBridgeChild::GetSingleton().get());
+  NS_ENSURE_TRUE(client, E_FAIL);
 
   RefPtr<IDXGIKeyedMutex> mutex;
-  RefPtr<IMFSample> sample;
+  HRESULT hr;
   RefPtr<ID3D11Texture2D> texture = image->GetTexture();
 
   texture->QueryInterface((IDXGIKeyedMutex**)getter_AddRefs(mutex));
 
-  hr = mutex->AcquireSync(0, 2000);
+  if (mutex) {
+    hr = mutex->AcquireSync(0, 2000);
+    NS_ENSURE_TRUE(SUCCEEDED(hr), hr);
+  }
+
+  if (client && client->GetFormat() == SurfaceFormat::NV12) {
+    // Our video frame is stored in a non-sharable ID3D11Texture2D. We need
+    // to create a copy of that frame as a sharable resource, save its share
+    // handle, and put that handle into the rendering pipeline.
+
+    RefPtr<IMFMediaBuffer> buffer;
+    hr = aVideoSample->GetBufferByIndex(0, getter_AddRefs(buffer));
+    NS_ENSURE_TRUE(SUCCEEDED(hr), hr);
+
+    RefPtr<IMFDXGIBuffer> dxgiBuf;
+    hr = buffer->QueryInterface((IMFDXGIBuffer**)getter_AddRefs(dxgiBuf));
+    NS_ENSURE_TRUE(SUCCEEDED(hr), hr);
+
+    RefPtr<ID3D11Texture2D> tex;
+    hr = dxgiBuf->GetResource(__uuidof(ID3D11Texture2D), getter_AddRefs(tex));
+    NS_ENSURE_TRUE(SUCCEEDED(hr), hr);
 
-  if (hr != S_OK) {
-    NS_WARNING("Acquire sync didn't manage to return within 2 seconds.");
+    UINT index;
+    dxgiBuf->GetSubresourceIndex(&index);
+    mContext->CopySubresourceRegion(texture, 0, 0, 0, 0, tex, index, nullptr);
+  } else {
+    // Our video sample is in NV12 format but our output texture is in BGRA.
+    // Use MFT to do color conversion.
+    hr = mTransform->Input(aVideoSample);
+    NS_ENSURE_TRUE(SUCCEEDED(hr), hr);
+
+    RefPtr<IMFSample> sample;
+    hr = CreateOutputSample(sample, texture);
+    NS_ENSURE_TRUE(SUCCEEDED(hr), hr);
+
+    hr = mTransform->Output(&sample);
+  }
+
+  if (!mutex) {
+    client->SyncWithObject(mSyncObject);
+    mSyncObject->FinalizeFrame();
+  } else {
+    mutex->ReleaseSync(0);
   }
 
-  hr = CreateOutputSample(sample, texture);
+  image.forget(aOutImage);
+
+  return S_OK;
+}
+
+HRESULT
+D3D11DXVA2Manager::CopyToBGRATexture(ID3D11Texture2D *aInTexture,
+                                     ID3D11Texture2D** aOutTexture)
+{
+  NS_ENSURE_TRUE(aInTexture, E_POINTER);
+  NS_ENSURE_TRUE(aOutTexture, E_POINTER);
+
+  HRESULT hr;
+  RefPtr<ID3D11Texture2D> texture, inTexture;
+
+  inTexture = aInTexture;
+
+  CD3D11_TEXTURE2D_DESC desc;
+  aInTexture->GetDesc(&desc);
+  ConfigureForSize(desc.Width, desc.Height);
+
+  RefPtr<IDXGIKeyedMutex> mutex;
+  inTexture->QueryInterface((IDXGIKeyedMutex**)getter_AddRefs(mutex));
+  // The rest of this function will not work if inTexture implements
+  // IDXGIKeyedMutex! In that case case we would have to copy to a
+  // non-mutex using texture.
+
+  if (mutex) {
+    RefPtr<ID3D11Texture2D> newTexture;
+
+    desc.MiscFlags = 0;
+    hr = mDevice->CreateTexture2D(&desc, nullptr, getter_AddRefs(newTexture));
+    NS_ENSURE_TRUE(SUCCEEDED(hr) && newTexture, E_FAIL);
+
+    hr = mutex->AcquireSync(0, 2000);
+    NS_ENSURE_TRUE(SUCCEEDED(hr), hr);
+
+    mContext->CopyResource(newTexture, inTexture);
+
+    mutex->ReleaseSync(0);
+    inTexture = newTexture;
+  }
+
+  desc.Format = DXGI_FORMAT_B8G8R8A8_UNORM;
+
+  hr = mDevice->CreateTexture2D(&desc, nullptr, getter_AddRefs(texture));
+  NS_ENSURE_TRUE(SUCCEEDED(hr) && texture, E_FAIL);
+
+  RefPtr<IMFSample> inputSample;
+  wmf::MFCreateSample(getter_AddRefs(inputSample));
+
+  // If these aren't set the decoder fails.
+  inputSample->SetSampleTime(10);
+  inputSample->SetSampleDuration(10000);
+
+  RefPtr<IMFMediaBuffer> inputBuffer;
+  hr = wmf::MFCreateDXGISurfaceBuffer(
+    __uuidof(ID3D11Texture2D), inTexture, 0, FALSE, getter_AddRefs(inputBuffer));
   NS_ENSURE_TRUE(SUCCEEDED(hr), hr);
 
-  hr = mTransform->Output(&sample);
-  mutex->ReleaseSync(0);
+  inputSample->AddBuffer(inputBuffer);
+
+  hr = mTransform->Input(inputSample);
+  NS_ENSURE_TRUE(SUCCEEDED(hr), hr);
 
-  image.forget(aOutImage);
+  RefPtr<IMFSample> outputSample;
+  hr = CreateOutputSample(outputSample, texture);
+  NS_ENSURE_TRUE(SUCCEEDED(hr), hr);
+
+  hr = mTransform->Output(&outputSample);
+
+  texture.forget(aOutTexture);
 
   return S_OK;
 }
 
 HRESULT ConfigureOutput(IMFMediaType* aOutput, void* aData)
 {
   HRESULT hr =
     aOutput->SetUINT32(MF_MT_INTERLACE_MODE, MFVideoInterlace_Progressive);
@@ -914,17 +1072,17 @@ D3D11DXVA2Manager::ConfigureForSize(uint
 
   RefPtr<IMFMediaType> outputType;
   hr = wmf::MFCreateMediaType(getter_AddRefs(outputType));
   NS_ENSURE_TRUE(SUCCEEDED(hr), hr);
 
   hr = outputType->SetGUID(MF_MT_MAJOR_TYPE, MFMediaType_Video);
   NS_ENSURE_TRUE(SUCCEEDED(hr), hr);
 
-  hr = outputType->SetGUID(MF_MT_SUBTYPE, MFVideoFormat_ARGB32);
+  hr = outputType->SetGUID(MF_MT_SUBTYPE, MFVideoFormat_NV12);
   NS_ENSURE_TRUE(SUCCEEDED(hr), hr);
 
   gfx::IntSize size(mWidth, mHeight);
   hr = mTransform->SetMediaTypes(inputType, outputType, ConfigureOutput, &size);
   NS_ENSURE_TRUE(SUCCEEDED(hr), hr);
 
   return S_OK;
 }
@@ -998,45 +1156,48 @@ D3D11DXVA2Manager::CreateDecoder(const D
     }
   }
   return nullptr;
 }
 
 /* static */
 DXVA2Manager*
 DXVA2Manager::CreateD3D11DXVA(layers::KnowsCompositor* aKnowsCompositor,
-                              nsACString& aFailureReason)
+                              nsACString& aFailureReason,
+                              ID3D11Device* aDevice)
 {
   // DXVA processing takes up a lot of GPU resources, so limit the number of
   // videos we use DXVA with at any one time.
   uint32_t dxvaLimit = gfxPrefs::PDMWMFMaxDXVAVideos();
 
   if (sDXVAVideosCount == dxvaLimit) {
     aFailureReason.AssignLiteral("Too many DXVA videos playing");
     return nullptr;
   }
 
   nsAutoPtr<D3D11DXVA2Manager> manager(new D3D11DXVA2Manager());
-  HRESULT hr = manager->Init(aKnowsCompositor, aFailureReason);
+  HRESULT hr = manager->Init(aKnowsCompositor, aFailureReason, aDevice);
   NS_ENSURE_TRUE(SUCCEEDED(hr), nullptr);
 
   return manager.forget();
 }
 
 DXVA2Manager::DXVA2Manager()
   : mLock("DXVA2Manager")
 {
-  MOZ_ASSERT(NS_IsMainThread());
-  ++sDXVAVideosCount;
+  if (NS_IsMainThread()) {
+    ++sDXVAVideosCount;
+  }
 }
 
 DXVA2Manager::~DXVA2Manager()
 {
-  MOZ_ASSERT(NS_IsMainThread());
-  --sDXVAVideosCount;
+  if (NS_IsMainThread()) {
+    --sDXVAVideosCount;
+  }
 }
 
 bool
 DXVA2Manager::IsUnsupportedResolution(const uint32_t& aWidth,
                                       const uint32_t& aHeight,
                                       const float& aFramerate) const
 {
   // AMD cards with UVD3 or earlier perform poorly trying to decode 1080p60 in
--- a/dom/media/platforms/wmf/DXVA2Manager.h
+++ b/dom/media/platforms/wmf/DXVA2Manager.h
@@ -26,29 +26,38 @@ public:
 
   // Creates and initializes a DXVA2Manager. We can use DXVA2 via either
   // D3D9Ex or D3D11.
   static DXVA2Manager* CreateD3D9DXVA(
     layers::KnowsCompositor* aKnowsCompositor,
     nsACString& aFailureReason);
   static DXVA2Manager* CreateD3D11DXVA(
     layers::KnowsCompositor* aKnowsCompositor,
-    nsACString& aFailureReason);
+    nsACString& aFailureReason,
+    ID3D11Device* aDevice = nullptr);
 
   // Returns a pointer to the D3D device manager responsible for managing the
   // device we're using for hardware accelerated video decoding. If we're using
   // D3D9Ex, this is an IDirect3DDeviceManager9. For D3D11 this is an
   // IMFDXGIDeviceManager. It is safe to call this on any thread.
   virtual IUnknown* GetDXVADeviceManager() = 0;
 
   // Creates an Image for the video frame stored in aVideoSample.
   virtual HRESULT CopyToImage(IMFSample* aVideoSample,
                               const nsIntRect& aRegion,
                               layers::Image** aOutImage) = 0;
 
+  virtual HRESULT CopyToBGRATexture(ID3D11Texture2D *aInTexture,
+                                    ID3D11Texture2D** aOutTexture)
+  {
+    // Not implemented!
+    MOZ_CRASH("CopyToBGRATexture not implemented on this manager.");
+    return E_FAIL;
+  }
+
   virtual HRESULT ConfigureForSize(uint32_t aWidth, uint32_t aHeight)
   {
     return S_OK;
   }
 
   virtual bool IsD3D11() { return false; }
 
   virtual ~DXVA2Manager();
--- a/dom/media/test/manifest.js
+++ b/dom/media/test/manifest.js
@@ -1540,17 +1540,17 @@ function removeNodeAndSource(n) {
   // Clearing srcObject and/or src will actually set them to some default
   // URI that will fail to load, so make sure we don't produce a spurious
   // bailing error.
   n.onerror = null;
   // reset |srcObject| first since it takes precedence over |src|.
   n.srcObject = null;
   n.src = "";
   while (n.firstChild) {
-    n.removeChild(n.firstChild);
+    n.firstChild.remove();
   }
 }
 
 function once(target, name, cb) {
   var p = new Promise(function(resolve, reject) {
     target.addEventListener(name, function() {
       resolve();
     }, {once: true});
--- a/dom/media/tests/mochitest/test_peerConnection_captureStream_canvas_2d_noSSRC.html
+++ b/dom/media/tests/mochitest/test_peerConnection_captureStream_canvas_2d_noSSRC.html
@@ -1,17 +1,17 @@
 <!DOCTYPE HTML>
 <html>
 <head>
   <script type="application/javascript" src="pc.js"></script>
   <script type="application/javascript" src="/tests/dom/canvas/test/captureStream_common.js"></script>
 </head>
 <body>
 <pre id="test">
-<script type="application/javascript;version=1.8">
+<script type="application/javascript">
 createHTML({
   title: "Canvas(2D)::CaptureStream as video-only input to peerconnection with no a=ssrc",
   visible: true
 });
 
 var test;
 runNetworkTest((options) => {
   options = options || { };
--- a/dom/media/webspeech/recognition/SpeechRecognition.cpp
+++ b/dom/media/webspeech/recognition/SpeechRecognition.cpp
@@ -182,16 +182,17 @@ SpeechRecognition::IsAuthorized(JSContex
 
 already_AddRefed<SpeechRecognition>
 SpeechRecognition::Constructor(const GlobalObject& aGlobal,
                                ErrorResult& aRv)
 {
   nsCOMPtr<nsPIDOMWindowInner> win = do_QueryInterface(aGlobal.GetAsSupports());
   if (!win) {
     aRv.Throw(NS_ERROR_FAILURE);
+    return nullptr;
   }
 
   MOZ_ASSERT(win->IsInnerWindow());
   RefPtr<SpeechRecognition> object = new SpeechRecognition(win);
   return object.forget();
 }
 
 nsISupports*
--- a/dom/media/webspeech/synth/SpeechSynthesisUtterance.cpp
+++ b/dom/media/webspeech/synth/SpeechSynthesisUtterance.cpp
@@ -64,16 +64,17 @@ already_AddRefed<SpeechSynthesisUtteranc
 SpeechSynthesisUtterance::Constructor(GlobalObject& aGlobal,
                                       const nsAString& aText,
                                       ErrorResult& aRv)
 {
   nsCOMPtr<nsPIDOMWindowInner> win = do_QueryInterface(aGlobal.GetAsSupports());
 
   if (!win) {
     aRv.Throw(NS_ERROR_FAILURE);
+    return nullptr;
   }
 
   MOZ_ASSERT(win->IsInnerWindow());
   RefPtr<SpeechSynthesisUtterance> object =
     new SpeechSynthesisUtterance(win, aText);
   return object.forget();
 }
 
--- a/dom/media/webvtt/vtt.jsm
+++ b/dom/media/webvtt/vtt.jsm
@@ -884,17 +884,17 @@ Cu.import('resource://gre/modules/Servic
   //                 affected and repositioned according to it.
   WebVTT.processCues = function(window, cues, overlay, controls) {
     if (!window || !cues || !overlay) {
       return null;
     }
 
     // Remove all previous children.
     while (overlay.firstChild) {
-      overlay.removeChild(overlay.firstChild);
+      overlay.firstChild.remove();
     }
 
     var controlBar;
     var controlBarShown;
 
     if (controls) {
       controlBar = controls.ownerDocument.getAnonymousElementByAttribute(
         controls, "anonid", "controlBar");
--- a/dom/quota/ActorsParent.cpp
+++ b/dom/quota/ActorsParent.cpp
@@ -6959,17 +6959,16 @@ StorageDirectoryHelper::GetDirectoryMeta
                                               int64_t& aTimestamp,
                                               nsACString& aSuffix,
                                               nsACString& aGroup,
                                               nsACString& aOrigin,
                                               bool& aIsApp)
 {
   AssertIsOnIOThread();
   MOZ_ASSERT(aDirectory);
-  MOZ_ASSERT(aTimestamp);
 
   nsCOMPtr<nsIBinaryInputStream> binaryStream;
   nsresult rv = GetBinaryInputStream(aDirectory,
                                      NS_LITERAL_STRING(METADATA_V2_FILE_NAME),
                                      getter_AddRefs(binaryStream));
   if (NS_WARN_IF(NS_FAILED(rv))) {
     return rv;
   }
--- a/dom/security/nsMixedContentBlocker.cpp
+++ b/dom/security/nsMixedContentBlocker.cpp
@@ -861,19 +861,19 @@ nsMixedContentBlocker::ShouldLoad(bool a
   if (!securityUI) {
     *aDecision = nsIContentPolicy::ACCEPT;
     return NS_OK;
   }
   nsresult stateRV = securityUI->GetState(&state);
 
   OriginAttributes originAttributes;
   if (principal) {
-    originAttributes.Inherit(principal->OriginAttributesRef());
+    originAttributes = principal->OriginAttributesRef();
   } else if (aRequestPrincipal) {
-    originAttributes.Inherit(aRequestPrincipal->OriginAttributesRef());
+    originAttributes = aRequestPrincipal->OriginAttributesRef();
   }
 
   bool doHSTSPriming = false;
   if (IsEligibleForHSTSPriming(aContentLocation)) {
     bool hsts = false;
     bool cached = false;
     nsCOMPtr<nsISiteSecurityService> sss =
       do_GetService(NS_SSSERVICE_CONTRACTID, &rv);
--- a/dom/smil/test/test_smilChangeAfterFrozen.xhtml
+++ b/dom/smil/test/test_smilChangeAfterFrozen.xhtml
@@ -183,17 +183,17 @@ function testCurrentColorChange()
      "Checking animated fill=currentColor after updating context but before " +
      "sampling");
   gSvg.setCurrentTime(0);
   is(SMILUtil.getComputedStyleSimple(gCircle, "fill"), "rgb(0, 255, 0)",
      "Checking animated fill=currentColor after updating context");
 
   // Clean up
   gCircle.removeAttribute("color");
-  gCircle.removeChild(gCircle.firstChild);
+  gCircle.firstChild.remove();
 }
 
 function testCurrentColorChangeUsingStyle()
 {
   setupTest();
   gCircle.setAttribute("style", "color: red"); // At first: currentColor=red
   var anim = createAnimSetTo("fill", "currentColor");
 
@@ -204,17 +204,17 @@ function testCurrentColorChangeUsingStyl
   gCircle.setAttribute("style", "color: lime"); // Change: currentColor=lime
   gSvg.setCurrentTime(0);
   is(SMILUtil.getComputedStyleSimple(gCircle, "fill"), "rgb(0, 255, 0)",
      "Checking animated fill=currentColor after updating context "
      + "(using style attr)");
 
   // Clean up
   gCircle.removeAttribute("style");
-  gCircle.removeChild(gCircle.firstChild);
+  gCircle.firstChild.remove();
 }
 
 function getFallbackColor(pServerStr)
 {
   return pServerStr.substr(pServerStr.indexOf(" ")+1);
 }
 
 function testCurrentColorChangeOnFallback()
@@ -231,17 +231,17 @@ function testCurrentColorChangeOnFallbac
 
   gCircle.setAttribute("color", "lime"); // Change: currentColor=lime
   gSvg.setCurrentTime(0);
   fallback = getFallbackColor(SMILUtil.getComputedStyleSimple(gCircle, "fill"));
   is(fallback, "rgb(0, 255, 0)",
      "Checking animated fallback fill=currentColor after updating context");
 
   gCircle.removeAttribute("style");
-  gCircle.removeChild(gCircle.firstChild);
+  gCircle.firstChild.remove();
 }
 
 function testInheritChange()
 {
   setupTest();
   gCircleParent.setAttribute("fill", "red"); // At first: inherit=red
   var anim = createAnimSetTo("fill", "inherit");
 
@@ -250,17 +250,17 @@ function testInheritChange()
      "Checking animated fill=inherit after animating");
 
   gCircleParent.setAttribute("fill", "lime"); // Change: inherit=lime
   gSvg.setCurrentTime(0);
   is(SMILUtil.getComputedStyleSimple(gCircle, "fill"), "rgb(0, 255, 0)",
      "Checking animated fill=inherit after updating context");
 
   gCircleParent.removeAttribute("fill");
-  gCircle.removeChild(gCircle.firstChild);
+  gCircle.firstChild.remove();
 }
 
 function testInheritChangeUsingStyle()
 {
   setupTest();
   gCircleParent.setAttribute("style", "fill: red"); // At first: inherit=red
   var anim = createAnimSetTo("fill", "inherit");
 
@@ -270,17 +270,17 @@ function testInheritChangeUsingStyle()
 
   gCircleParent.setAttribute("style", "fill: lime"); // Change: inherit=lime
   gSvg.setCurrentTime(0);
   is(SMILUtil.getComputedStyleSimple(gCircle, "fill"), "rgb(0, 255, 0)",
      "Checking animated fill=inherit after updating context "
      + "(using style attr)");
 
   gCircleParent.removeAttribute("style");
-  gCircle.removeChild(gCircle.firstChild);
+  gCircle.firstChild.remove();
 }
 
 function testEmUnitChangeOnProp()
 {
   setupTest();
   gCircleParent.setAttribute("font-size", "10px"); // At first: font-size: 10px
   var anim = createAnimSetTo("font-size", "2em");
 
@@ -289,17 +289,17 @@ function testEmUnitChangeOnProp()
      "Checking animated font-size=2em after animating ends");
 
   gCircleParent.setAttribute("font-size", "20px"); // Change: font-size: 20px
   gSvg.setCurrentTime(0);
   is(SMILUtil.getComputedStyleSimple(gCircle, "font-size"), "40px",
      "Checking animated font-size=2em after updating context");
 
   gCircleParent.removeAttribute("font-size");
-  gCircle.removeChild(gCircle.firstChild);
+  gCircle.firstChild.remove();
 }
 
 function testEmUnitChangeOnPropBase()
 {
   // Test the case where the base value for our animation sandwich is
   // context-sensitive.
   // Currently, this is taken care of by the compositor which keeps a cached
   // base value and compares it with the current base value. This test then just
@@ -314,17 +314,17 @@ function testEmUnitChangeOnPropBase()
      "Checking animated font-size=20px after anim ends");
 
   gSvg.setAttribute("font-size", "20px"); // Change: font-size: 20px
   gSvg.setCurrentTime(TIME_AFTER_ANIM_END);
   is(SMILUtil.getComputedStyleSimple(gCircle, "font-size"), "30px",
      "Checking animated font-size=30px after updating context");
 
   gCircleParent.removeAttribute("font-size");
-  gCircle.removeChild(gCircle.firstChild);
+  gCircle.firstChild.remove();
 }
 
 function testEmUnitChangeOnLength()
 {
   setupTest();
   gCircleParent.setAttribute("font-size", "10px"); // At first: font-size: 10px
   var anim = createAnimSetTo("cx", "2em");
 
@@ -339,17 +339,17 @@ function testEmUnitChangeOnLength()
      "Checking animated length=2em after updating context but before sampling");
 
   gSvg.setCurrentTime(0);
   is(gCircle.cx.animVal.value, 40,
      "Checking animated length=2em after updating context and after " +
      "resampling");
 
   gCircleParent.removeAttribute("font-size");
-  gCircle.removeChild(gCircle.firstChild);
+  gCircle.firstChild.remove();
 }
 
 function testPercentUnitChangeOnProp()
 {
   setupTest();
   gCircleParent.setAttribute("font-size", "10px"); // At first: font-size: 10px
   var anim = createAnimSetTo("font-size", "150%");
 
@@ -358,17 +358,17 @@ function testPercentUnitChangeOnProp()
      "Checking animated font-size=150% after animating");
 
   gCircleParent.setAttribute("font-size", "20px"); // Change: font-size: 20px
   gSvg.setCurrentTime(0);
   is(SMILUtil.getComputedStyleSimple(gCircle, "font-size"), "30px",
      "Checking animated font-size=150% after updating context");
 
   gCircleParent.removeAttribute("font-size");
-  gCircle.removeChild(gCircle.firstChild);
+  gCircle.firstChild.remove();
 }
 
 function testPercentUnitChangeOnLength()
 {
   setupTest();
   var oldHeight = gSvg.getAttribute("height");
   gSvg.setAttribute("height", "100px"); // At first: viewport height: 100px
   var anim = createAnimSetTo("cy", "100%");
@@ -394,17 +394,17 @@ function testPercentUnitChangeOnLength()
   gSvg.setAttribute("height", "50px"); // Change: height: 50px
   // force a layout flush (Bug 627594)
   gSvg.getCTM();
   gSvg.setCurrentTime(0); // Bug 508206
   is(gCircle.cy.animVal.value, 50,
      "Checking animated length=100% after updating context");
 
   gSvg.setAttribute("height", oldHeight);
-  gCircle.removeChild(gCircle.firstChild);
+  gCircle.firstChild.remove();
 }
 
 function testRelativeFontSize()
 {
   setupTest();
   gCircleParent.setAttribute("font-size", "10px"); // At first: font-size: 10px
   var anim = createAnimSetTo("font-size", "larger");
 
@@ -416,17 +416,17 @@ function testRelativeFontSize()
     "Checking animated font-size > 10px after animating");
 
   gCircleParent.setAttribute("font-size", "20px"); // Change: font-size: 20px
   gSvg.setCurrentTime(0);
   fsize = parseInt(SMILUtil.getComputedStyleSimple(gCircle, "font-size"));
   ok(fsize > 20, "Checking animated font-size > 20px after updating context");
 
   gCircleParent.removeAttribute("font-size");
-  gCircle.removeChild(gCircle.firstChild);
+  gCircle.firstChild.remove();
 }
 
 function testRelativeFontWeight()
 {
   setupTest();
   gCircleParent.setAttribute("font-weight", "100"); // At first: font-weight 100
   var anim = createAnimSetTo("font-weight", "bolder");
   // CSS 2: 'bolder': Specifies the next weight that is assigned to a font
@@ -442,17 +442,17 @@ function testRelativeFontWeight()
 
   gCircleParent.setAttribute("font-weight", "800"); // Change: font-weight 800
   gSvg.setCurrentTime(0);
   weight = parseInt(SMILUtil.getComputedStyleSimple(gCircle, "font-weight"));
   is(weight, 900,
      "Checking animated font-weight = 900 after updating context");
 
   gCircleParent.removeAttribute("font-weight");
-  gCircle.removeChild(gCircle.firstChild);
+  gCircle.firstChild.remove();
 }
 
 function testRelativeFont()
 {
   // Test a relative font-size as part of a 'font' spec since the code path
   // is different in this case
   // It turns out that, due to the way we store shorthand font properties, we
   // don't need to worry about marking such values as context-sensitive since we
@@ -474,17 +474,17 @@ function testRelativeFont()
 
   gCircleParent.setAttribute("font-size", "20px"); // Change: font-size: 20px
   gSvg.setCurrentTime(0);
   fsize  = parseInt(SMILUtil.getComputedStyleSimple(gCircle, "font-size"));
   ok(fsize > 20,
      "Checking size of shorthand 'font' > 20px after updating context");
 
   gCircleParent.removeAttribute("font-size");
-  gCircle.removeChild(gCircle.firstChild);
+  gCircle.firstChild.remove();
 }
 
 function testCalcFontSize()
 {
   setupTest();
   gCircleParent.setAttribute("font-size", "10px"); // At first: font-size: 10px
   var anim = createAnimSetTo("font-size", "calc(110% + 0.1em)");
 
@@ -495,17 +495,17 @@ function testCalcFontSize()
 
   gCircleParent.setAttribute("font-size", "20px"); // Change: font-size: 20px
   gSvg.setCurrentTime(0);
   fsize = parseInt(SMILUtil.getComputedStyleSimple(gCircle, "font-size"));
   is(fsize, 24, "Checking animated calc font-size == 24px after updating " +
                 "context");
 
   gCircleParent.removeAttribute("font-size");
-  gCircle.removeChild(gCircle.firstChild);
+  gCircle.firstChild.remove();
 }
 
 function testDashArray()
 {
   // stroke dasharrays don't currently convert units--but if someone ever fixes
   // that, hopefully this test will fail and remind us not to cache percentage
   // values in that case
   setupTest();
@@ -524,17 +524,17 @@ function testDashArray()
   gSvg.setAttribute("height", "50px"); // Change viewport: 50x50px
   gSvg.setAttribute("width",  "50px");
   gSvg.setCurrentTime(TIME_AFTER_ANIM_END);
   is(SMILUtil.getComputedStyleSimple(gCircle, "stroke-dasharray"), "0, 50%",
      "Checking animated stroke-dasharray after updating context");
 
   gSvg.setAttribute("height", oldHeight);
   gSvg.setAttribute("width",  oldWidth);
-  gCircle.removeChild(gCircle.firstChild);
+  gCircle.firstChild.remove();
 }
 
 function testClip()
 {
   setupTest();
   gCircleParent.setAttribute("font-size", "20px"); // At first: font-size: 20px
 
   // The clip property only applies to elements that establish a new
--- a/dom/svg/test/test_SVGTransformListAddition.xhtml
+++ b/dom/svg/test/test_SVGTransformListAddition.xhtml
@@ -148,17 +148,17 @@ function runAdditionTestCase(test, elem,
          "Unexpected transform type" + testDesc);
       is(transform.angle, expected[i].angle,
          "Unexpected transform angle" + testDesc);
     }
   }
   // We assume the only children of elem are the animation elements we've just
   // added.
   while (elem.firstChild) {
-    elem.removeChild(elem.firstChild);
+    elem.firstChild.remove();
   }
 }
 
 function createAnims(specs)
 {
   if (specs.constructor == Array) {
     var frag = document.createDocumentFragment();
     for (var i = 0; i < specs.length; ++i) {
--- a/dom/svg/test/test_text_dirty.html
+++ b/dom/svg/test/test_text_dirty.html
@@ -23,17 +23,17 @@ https://bugzilla.mozilla.org/show_bug.cg
 </div>
 <pre id="test">
 <script class="testbody" type="text/javascript">
 function runTest() {
   var svgText = document.getElementById("t");
 
   // Dirty the frames.
   document.getElementById("display").style.width = "700px";
-  svgText.removeChild(svgText.firstChild);
+  svgText.firstChild.remove();
 
   // Paint without flushing layout.  If the test fails, we'll trigger
   // an assertion.
   SpecialPowers.snapshotWindowWithOptions(window, undefined, undefined, { DRAWWINDOW_DO_NOT_FLUSH: true });
 
   ok(true);
   SimpleTest.finish();
 }
--- a/dom/svg/test/test_text_update.html
+++ b/dom/svg/test/test_text_update.html
@@ -20,12 +20,12 @@
 var text = document.querySelector("text");
 
 var length = text.getComputedTextLength();
 ok(length > 0, "text.getComputedTextLength() > 0");
 
 text.firstChild.nodeValue += "cd";
 ok(text.getComputedTextLength() > length, "text.getComputedTextLength() changes directly after DOM mutation");
 
-text.removeChild(text.firstChild);
+text.firstChild.remove();
 is(text.getComputedTextLength(), 0, "text.getComputedTextLength() == 0 after removing child");
 </script>
 </pre>
--- a/dom/tests/mochitest/general/test_clipboard_events.html
+++ b/dom/tests/mochitest/general/test_clipboard_events.html
@@ -5,16 +5,17 @@
   <script type="text/javascript" src="/MochiKit/MochiKit.js"></script>
   <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
   <script type="application/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
   <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
 </head>
 <body>
 <p id="display"></p>
 <div id="content" style="border: 3px solid black; padding: 3em;">CONTENT TEXT<input id="content-input" value="INPUT TEXT"></div>
+<img id="image" src="image_50.png">
 <button id="button">Button</button>
 
 <div id="syntheticSpot" oncut="compareSynthetic(event, 'cut')"
                         oncopy="compareSynthetic(event, 'copy')"
                         onpaste="compareSynthetic(event, 'paste')">Spot</div>
 
 <pre id="test">
 <script class="testbody" type="text/javascript">
@@ -51,16 +52,17 @@ var testFunctions = [
   test_input_cut_abort_dataTransfer,
   test_input_copy_dataTransfer,
   test_input_paste_dataTransfer,
   test_input_paste_abort_dataTransfer,
   test_input_copypaste_dataTransfer_multiple,
   test_input_copy_button_dataTransfer,
   test_eventspref_disabled,
   test_input_cut_disallowed_types_dataTransfer,
+  test_image_dataTransfer,
   ];
 
 function doTests()
 {
   // Init clipboard
   setClipboardText(clipboardInitialValue);
 
   // Reset value of contentInput.
@@ -703,14 +705,53 @@ function test_input_cut_disallowed_types
   try {
     synthesizeKey("x", {accelKey: 1});
     ok(oncutExecuted, "The oncut handler should have been executed");
   } finally {
     contentInput.oncut = null;
   }
 }
 
+// Try copying an image to the clipboard and make sure that it looks correct when pasting it.
+function test_image_dataTransfer() {
+  // cmd_copyImageContents errors on Android (bug 1299578).
+  if (navigator.userAgent.includes("Android")) {
+    return;
+  }
+
+  // Copy the image's data to the clipboard
+  SpecialPowers.setCommandNode(window, document.getElementById("image"));
+  SpecialPowers.doCommand(window, "cmd_copyImageContents");
+
+  let onpasteCalled = false;
+  document.onpaste = function(event) {
+    ok(event instanceof ClipboardEvent, "paste event is an ClipboardEvent");
+    ok(event.clipboardData instanceof DataTransfer, "paste event dataTransfer is a DataTransfer");
+    let items = event.clipboardData.items;
+    let foundData = false;
+    for (let i = 0; i < items.length; ++i)  {
+      if (items[i].kind == "file") {
+        foundData = true;
+        is(items[i].type, "image/png", "The type of the data must be image/png");
+        is(items[i].getAsFile().type, "image/png", "The attached file must be image/png");
+      }
+    }
+    ok(foundData, "Should have found a file entry in the DataTransferItemList");
+    let files = event.clipboardData.files;
+    is(files.length, 1, "There should only be one file on the DataTransfer");
+    is(files[0].type, "image/png", "The only file should be an image/png");
+    onpasteCalled = true;
+  }
+
+  try {
+    synthesizeKey("v", {accelKey: 1});
+    ok(onpasteCalled, "The paste event listener must have been called");
+  } finally {
+    document.onpaste = null;
+  }
+}
+
 SimpleTest.waitForFocus(doTests);
 
 </script>
 </pre>
 </body>
 </html>
--- a/dom/tests/mochitest/general/test_interfaces.js
+++ b/dom/tests/mochitest/general/test_interfaces.js
@@ -876,17 +876,17 @@ var interfaceNamesInGlobalScope =
     {name: "SpecialPowers", xbl: false},
 // IMPORTANT: Do not change this list without review from a DOM peer!
     "StereoPannerNode",
 // IMPORTANT: Do not change this list without review from a DOM peer!
     "Storage",
 // IMPORTANT: Do not change this list without review from a DOM peer!
     "StorageEvent",
 // IMPORTANT: Do not change this list without review from a DOM peer!
-    {name: "StorageManager", nightly: true, isSecureContext: true},
+    {name: "StorageManager", nightly: true, isSecureContext: true, android: false},
 // IMPORTANT: Do not change this list without review from a DOM peer!
     "StyleSheet",
 // IMPORTANT: Do not change this list without review from a DOM peer!
     "StyleSheetList",
 // IMPORTANT: Do not change this list without review from a DOM peer!
     "SubtleCrypto",
 // IMPORTANT: Do not change this list without review from a DOM peer!
     "SVGAElement",
--- a/dom/tests/mochitest/webcomponents/test_shadow_element.html
+++ b/dom/tests/mochitest/webcomponents/test_shadow_element.html
@@ -85,17 +85,17 @@ ok(secondDistNodes[0].id == "two" &&
 
 is(firstDistNodes.length, 4, "There should be four distributed nodes, two from the first shadow, two from the second shadow.");
 ok(firstDistNodes[0].id == "one" &&
    firstDistNodes[1].id == "two" &&
    firstDistNodes[2].id == "three" &&
    firstDistNodes[3].id == "four", "Reprojection through shadow should preserve node order.");
 
 // Remove a node from the host and make sure that it is removed from all insertion points.
-host.removeChild(host.firstChild);
+host.firstChild.remove();
 firstDistNodes = firstContent.getDistributedNodes();
 secondDistNodes = secondContent.getDistributedNodes();
 
 is(secondDistNodes.length, 1, "There should be one distriubted node remaining after removing node from host.");
 ok(secondDistNodes[0].id == "three", "Span with id=two should have been removed from content element.");
 is(firstDistNodes.length, 3, "There should be three distributed nodes remaining after removing node from host.");
 ok(firstDistNodes[0].id == "one" &&
    firstDistNodes[1].id == "three" &&
@@ -110,17 +110,17 @@ thirdShadow = secondShadow.getElementByI
 thirdShadow.innerHTML = '<content id="firstcontent"></content>';
 firstContent = thirdShadow.getElementById("firstcontent");
 var shadowChild = document.createElement("span");
 firstShadow.appendChild(shadowChild);
 
 is(firstContent.getDistributedNodes()[0], shadowChild, "Elements in shadow insertioin point should be projected into content insertion points.");
 
 // Remove child of ShadowRoot and check that projected node is removed from insertion point.
-firstShadow.removeChild(firstShadow.firstChild);
+firstShadow.firstChild.remove();
 
 is(firstContent.getDistributedNodes().length, 0, "Reprojected element was removed from ShadowRoot, thus it should be removed from content insertion point.");
 
 // Check deeply nested projection of <shadow> elements.
 host = document.createElement("span");
 firstShadow = host.createShadowRoot();
 firstShadow.innerHTML = '<content></content>';
 secondShadow = host.createShadowRoot();
@@ -130,17 +130,17 @@ thirdShadow.innerHTML = '<span id="first
 var fourthShadow = thirdShadow.getElementById("firstspan").createShadowRoot();
 fourthShadow.innerHTML = '<content id="firstcontent"></content>';
 firstContent = fourthShadow.getElementById("firstcontent");
 host.innerHTML = '<span></span>';
 
 is(firstContent.getDistributedNodes()[0], host.firstChild, "Child of host should be projected to insertion point.");
 
 // Remove node and make sure that it is removed from distributed nodes.
-host.removeChild(host.firstChild);
+host.firstChild.remove();
 
 is(firstContent.getDistributedNodes().length, 0, "Node removed from host should be removed from insertion point.");
 
 // Check projection of fallback content through <shadow> elements.
 host = document.createElement("span");
 firstShadow = host.createShadowRoot();
 firstShadow.innerHTML = '<content><span id="firstspan"></span></content>';
 secondShadow = host.createShadowRoot();
--- a/dom/vr/VRDisplay.cpp
+++ b/dom/vr/VRDisplay.cpp
@@ -7,17 +7,19 @@
 #include "nsWrapperCache.h"
 
 #include "mozilla/dom/Element.h"
 #include "mozilla/dom/ElementBinding.h"
 #include "mozilla/dom/Promise.h"
 #include "mozilla/dom/VRDisplay.h"
 #include "mozilla/HoldDropJSObjects.h"
 #include "mozilla/dom/VRDisplayBinding.h"
+#include "mozilla/EventStateManager.h"
 #include "Navigator.h"
+#include "gfxPrefs.h"
 #include "gfxVR.h"
 #include "VRDisplayClient.h"
 #include "VRManagerChild.h"
 #include "VRDisplayPresentation.h"
 #include "nsIObserverService.h"
 #include "nsIFrame.h"
 #include "nsISupportsPrimitives.h"
 
@@ -445,31 +447,41 @@ VRDisplay::GetPose()
 
 void
 VRDisplay::ResetPose()
 {
   mClient->ZeroSensor();
 }
 
 already_AddRefed<Promise>
-VRDisplay::RequestPresent(const nsTArray<VRLayer>& aLayers, ErrorResult& aRv)
+VRDisplay::RequestPresent(const nsTArray<VRLayer>& aLayers,
+                          CallerType aCallerType,
+                          ErrorResult& aRv)
 {
   nsCOMPtr<nsIGlobalObject> global = do_QueryInterface(GetParentObject());
   if (!global) {
     aRv.Throw(NS_ERROR_FAILURE);
     return nullptr;
   }
 
   RefPtr<Promise> promise = Promise::Create(global, aRv);
   NS_ENSURE_TRUE(!aRv.Failed(), nullptr);
 
   nsCOMPtr<nsIObserverService> obs = services::GetObserverService();
   NS_ENSURE_TRUE(obs, nullptr);
 
-  if (!IsPresenting() && IsAnyPresenting()) {
+  if (!EventStateManager::IsHandlingUserInput() &&
+      aCallerType != CallerType::System &&
+      gfxPrefs::VRRequireGesture()) {
+    // The WebVR API states that if called outside of a user gesture, the
+    // promise must be rejected.  We allow VR presentations to start within
+    // trusted events such as vrdisplayactivate, which triggers in response to
+    // HMD proximity sensors and when navigating within a VR presentation.
+    promise->MaybeRejectWithUndefined();
+  } else if (!IsPresenting() && IsAnyPresenting()) {
     // Only one presentation allowed per VRDisplay
     // on a first-come-first-serve basis.
     // If this Javascript context is presenting, then we can replace our
     // presentation with a new one containing new layers but we should never
     // replace the presentation of another context.
     promise->MaybeRejectWithUndefined();
   } else {
     mPresentation = mClient->BeginPresentation(aLayers);
--- a/dom/vr/VRDisplay.h
+++ b/dom/vr/VRDisplay.h
@@ -319,17 +319,19 @@ public:
   }
 
   void SetDepthFar(double aDepthFar) {
     // XXX When we start sending depth buffers to VRLayer's we will want
     // to communicate this with the VRDisplayHost
     mDepthFar = aDepthFar;
   }
 
-  already_AddRefed<Promise> RequestPresent(const nsTArray<VRLayer>& aLayers, ErrorResult& aRv);
+  already_AddRefed<Promise> RequestPresent(const nsTArray<VRLayer>& aLayers,
+                                           CallerType aCallerType,
+                                           ErrorResult& aRv);
   already_AddRefed<Promise> ExitPresent(ErrorResult& aRv);
   void GetLayers(nsTArray<VRLayer>& result);
   void SubmitFrame();
 
   int32_t RequestAnimationFrame(mozilla::dom::FrameRequestCallback& aCallback,
                                 mozilla::ErrorResult& aError);
   void CancelAnimationFrame(int32_t aHandle, mozilla::ErrorResult& aError);
 
--- a/dom/webidl/VRDisplay.webidl
+++ b/dom/webidl/VRDisplay.webidl
@@ -259,17 +259,17 @@ interface VRDisplay : EventTarget {
    * `cancelAnimationFrame` will unregister the callback.
    */
   [Throws] void cancelAnimationFrame(long handle);
 
   /**
    * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
    * Repeat calls while already presenting will update the VRLayers being displayed.
    */
-  [Throws] Promise<void> requestPresent(sequence<VRLayer> layers);
+  [Throws, NeedsCallerType] Promise<void> requestPresent(sequence<VRLayer> layers);
 
   /**
    * Stops presenting to the VRDisplay.
    */
   [Throws] Promise<void> exitPresent();
 
   /**
    * Get the layers currently being presented.
--- a/dom/workers/ScriptLoader.cpp
+++ b/dom/workers/ScriptLoader.cpp
@@ -2023,20 +2023,20 @@ ScriptExecutorRunnable::ShutdownScriptLo
     // 2) mScriptLoader.mRv succeeded.  As far as I can tell, this can only
     //    happen when loading the main worker script and
     //    GetOrCreateGlobalScope() fails or if ScriptExecutorRunnable::Cancel
     //    got called.  Does it matter what we throw in this case?  I'm not
     //    sure...
     if (mScriptLoader.mRv.Failed()) {
       if (aMutedError && mScriptLoader.mRv.IsJSException()) {
         LogExceptionToConsole(aCx, aWorkerPrivate);
-        mScriptLoader.mRv.Throw(NS_ERROR_DOM_NETWORK_ERR);
+        mScriptLoader.mRv.ThrowWithCustomCleanup(NS_ERROR_DOM_NETWORK_ERR);
       }
     } else {
-      mScriptLoader.mRv.Throw(NS_ERROR_DOM_INVALID_STATE_ERR);
+      mScriptLoader.mRv.ThrowWithCustomCleanup(NS_ERROR_DOM_INVALID_STATE_ERR);
     }
   }
 
   aWorkerPrivate->StopSyncLoop(mSyncLoopTarget, aResult);
 }
 
 void
 ScriptExecutorRunnable::LogExceptionToConsole(JSContext* aCx,
--- a/dom/workers/WorkerRunnable.cpp
+++ b/dom/workers/WorkerRunnable.cpp
@@ -582,24 +582,27 @@ WorkerMainThreadRunnable::Dispatch(Statu
     aRv.Throw(NS_ERROR_DOM_INVALID_STATE_ERR);
     return;
   }
 
   DebugOnly<nsresult> rv = mWorkerPrivate->DispatchToMainThread(this);
   MOZ_ASSERT(NS_SUCCEEDED(rv),
              "Should only fail after xpcom-shutdown-threads and we're gone by then");
 
-  if (!syncLoop.Run()) {
-    aRv.ThrowUncatchableException();
-  }
+  bool success = syncLoop.Run();
 
   Telemetry::Accumulate(Telemetry::SYNC_WORKER_OPERATION, mTelemetryKey,
                         static_cast<uint32_t>((TimeStamp::NowLoRes() - startTime)
-                                                .ToMilliseconds()));
+                                              .ToMilliseconds()));
+
   Unused << startTime; // Shut the compiler up.
+
+  if (!success) {
+    aRv.ThrowUncatchableException();
+  }
 }
 
 NS_IMETHODIMP
 WorkerMainThreadRunnable::Run()
 {
   AssertIsOnMainThread();
 
   bool runResult = MainThreadRun();
--- a/dom/workers/WorkerScope.cpp
+++ b/dom/workers/WorkerScope.cpp
@@ -876,16 +876,17 @@ WorkerDebuggerGlobalScope::WrapGlobalObj
 void
 WorkerDebuggerGlobalScope::GetGlobal(JSContext* aCx,
                                      JS::MutableHandle<JSObject*> aGlobal,
                                      ErrorResult& aRv)
 {
   WorkerGlobalScope* scope = mWorkerPrivate->GetOrCreateGlobalScope(aCx);
   if (!scope) {
     aRv.Throw(NS_ERROR_FAILURE);
+    return;
   }
 
   aGlobal.set(scope->GetWrapper());
 }
 
 void
 WorkerDebuggerGlobalScope::CreateSandbox(JSContext* aCx, const nsAString& aName,
                                          JS::Handle<JSObject*> aPrototype,
--- a/dom/workers/test/serviceworkers/test_serviceworker_interfaces.js
+++ b/dom/workers/test/serviceworkers/test_serviceworker_interfaces.js
@@ -201,17 +201,17 @@ var interfaceNamesInGlobalScope =
     "Response",
 // IMPORTANT: Do not change this list without review from a DOM peer!
     "ServiceWorker",
 // IMPORTANT: Do not change this list without review from a DOM peer!
     "ServiceWorkerGlobalScope",
 // IMPORTANT: Do not change this list without review from a DOM peer!
     "ServiceWorkerRegistration",
 // IMPORTANT: Do not change this list without review from a DOM peer!
-    {name: "StorageManager", nightly: true},
+    {name: "StorageManager", nightly: true, android: false},
 // IMPORTANT: Do not change this list without review from a DOM peer!
     "SubtleCrypto",
 // IMPORTANT: Do not change this list without review from a DOM peer!
     "TextDecoder",
 // IMPORTANT: Do not change this list without review from a DOM peer!
     "TextEncoder",
 // IMPORTANT: Do not change this list without review from a DOM peer!
     "URL",
--- a/dom/workers/test/test_worker_interfaces.js
+++ b/dom/workers/test/test_worker_interfaces.js
@@ -187,17 +187,17 @@ var interfaceNamesInGlobalScope =
     "PushSubscriptionOptions",
 // IMPORTANT: Do not change this list without review from a DOM peer!
     "Request",
 // IMPORTANT: Do not change this list without review from a DOM peer!
     "Response",
 // IMPORTANT: Do not change this list without review from a DOM peer!
     "ServiceWorkerRegistration",
 // IMPORTANT: Do not change this list without review from a DOM peer!
-    {name: "StorageManager", nightly: true, isSecureContext: true},
+    {name: "StorageManager", nightly: true, isSecureContext: true, android: false},
 // IMPORTANT: Do not change this list without review from a DOM peer!
     "SubtleCrypto",
 // IMPORTANT: Do not change this list without review from a DOM peer!
     "TextDecoder",
 // IMPORTANT: Do not change this list without review from a DOM peer!
     "TextEncoder",
 // IMPORTANT: Do not change this list without review from a DOM peer!
     "XMLHttpRequest",
--- a/dom/xhr/XMLHttpRequestWorker.cpp
+++ b/dom/xhr/XMLHttpRequestWorker.cpp
@@ -1823,25 +1823,27 @@ XMLHttpRequestWorker::SendInternal(SendR
   if (!isSyncXHR)  {
     autoUnpin.Clear();
     MOZ_ASSERT(!autoSyncLoop);
     return;
   }
 
   autoUnpin.Clear();
 
+  bool succeeded = autoSyncLoop->Run();
+  mStateData.mFlagSend = false;
+
   // Don't clobber an existing exception that we may have thrown on aRv
   // already... though can there really be one?  In any case, it seems to me
   // that this autoSyncLoop->Run() can never fail, since the StopSyncLoop call
   // for it will come from ProxyCompleteRunnable and that always passes true for
   // the second arg.
-  if (!autoSyncLoop->Run() && !aRv.Failed()) {
+  if (!succeeded && !aRv.Failed()) {
     aRv.Throw(NS_ERROR_FAILURE);
   }
-  mStateData.mFlagSend = false;
 }
 
 bool
 XMLHttpRequestWorker::Notify(Status aStatus)
 {
   mWorkerPrivate->AssertIsOnWorkerThread();
 
   if (aStatus >= Canceling && !mCanceled) {
--- a/dom/xslt/tests/mochitest/test_bug319374.xhtml
+++ b/dom/xslt/tests/mochitest/test_bug319374.xhtml
@@ -40,17 +40,17 @@ https://bugzilla.mozilla.org/show_bug.cg
                                document.getElementById('content'),
                                null,
                                XPathResult.UNORDERED_NODE_ITERATOR_TYPE,
                                null);
       var res = null;
       while (res = result.iterateNext()) {
         ++counter; 
         var anon = getAnonymousNodes(res);
-        anon[0].removeChild(anon[0].firstChild); // Removing a child node
+        anon[0].firstChild.remove(); // Removing a child node
         anon[0].removeAttribute("attr1"); // Removing an attribute
         anon[1].firstChild.data = "anon text changed" // Modifying text data
       }
     } catch (e) {
       error = e;
     }
     ok(!error, error);
     ok(counter == 3, "XPathEvaluator should have found 3 elements.")
--- a/dom/xul/templates/tests/chrome/test_sortservice.xul
+++ b/dom/xul/templates/tests/chrome/test_sortservice.xul
@@ -51,17 +51,17 @@ function doTests()
     for (let e = 0; e < box.childNodes.length; e++) {
       if (actual)
         actual += " ";
       actual += box.childNodes[e].getAttribute("value");
     }
     is(actual, test[2], "sorted step " + (t + 1));
 
     while(box.hasChildNodes())
-      box.removeChild(box.firstChild);
+      box.firstChild.remove();
     box.removeAttribute("sortDirection");
   }
 
   SimpleTest.finish();
 }
 
 window.addEventListener("load", doTests, false);
 
--- a/dom/xul/test/test_bug311681.xul
+++ b/dom/xul/test/test_bug311681.xul
@@ -76,17 +76,17 @@ https://bugzilla.mozilla.org/show_bug.cg
 
     // Check what getElementById returns now.
     is(getCont(), node, "Should be getting clone post-flush");
 
   }
 
   function clear(node) {
     while (node.hasChildNodes()) {
-      node.removeChild(node.firstChild);
+      node.firstChild.remove();
     }
   }
 
   addLoadEvent(testClone);
   addLoadEvent(SimpleTest.finish);
 ]]>
 </script>
 <p id="display"></p>
--- a/editor/composer/crashtests/407062-1.html
+++ b/editor/composer/crashtests/407062-1.html
@@ -2,17 +2,17 @@
 <head>
 
 <script type="text/javascript">
 
 function boom()
 {
   var r = document.documentElement;
   while(r.firstChild)
-    r.removeChild(r.firstChild);
+    r.firstChild.remove();
 
   document.execCommand("contentReadOnly", false, "");
   document.documentElement.focus();
 }
 
 </script>
 </head>
 
--- a/editor/libeditor/crashtests/1317718.html
+++ b/editor/libeditor/crashtests/1317718.html
@@ -1,14 +1,14 @@
 <!DOCTYPE html>
 <html>
 <script>
 addEventListener('DOMContentLoaded', function() {
   let root = document.documentElement;
   while(root.firstChild) {
-    root.removeChild(root.firstChild);
+    root.firstChild.remove();
   }
   document.designMode = 'on';
   document.removeChild(document.documentElement);
   document.execCommand('justifyleft', false, null);
 });
 </script>
 </html>
--- a/editor/libeditor/crashtests/1324505.html
+++ b/editor/libeditor/crashtests/1324505.html
@@ -1,15 +1,15 @@
 <!DOCTYPE html>
 <html>
 <script>
 addEventListener("DOMContentLoaded", function(){
   let root = document.documentElement;
   while(root.firstChild) {
-    root.removeChild(root.firstChild);
+    root.firstChild.remove();
   }
   let o_0 = document.createElement("body");
   root.appendChild(o_0);
   o_0.appendChild(document.createElement("table"));
   o_0.appendChild(document.createElement("canvas"));
   let o_1 = document.createElement("canvas");
   o_0.appendChild(o_1);
   o_1.setAttribute("contenteditable", "true");
--- a/editor/libeditor/crashtests/612565-1.html
+++ b/editor/libeditor/crashtests/612565-1.html
@@ -5,13 +5,13 @@
   </body>
   <script>
     onload = function() {
       var i = document.querySelector("iframe");
       var doc = i.contentDocument;
       doc.body.appendChild(doc.createTextNode("foo"));
       doc.designMode = "on";
       while (doc.body.firstChild) {
-        doc.body.removeChild(doc.body.firstChild);
+        doc.body.firstChild.remove();
       }
     };
   </script>
 </html>
--- a/editor/libeditor/crashtests/713427-2.xhtml
+++ b/editor/libeditor/crashtests/713427-2.xhtml
@@ -1,17 +1,17 @@
 <html xmlns="http://www.w3.org/1999/xhtml">
 <head>
 <script>
 <![CDATA[
 
 function boom()
 {
   while (document.documentElement.firstChild) {
-    document.documentElement.removeChild(document.documentElement.firstChild);
+    document.documentElement.firstChild.remove();
   }
 
   var td = document.createElementNS("http://www.w3.org/1999/xhtml", "td");
   td.setAttributeNS(null, "contenteditable", "true");
   (document.documentElement).appendChild(td);
   var head = document.createElementNS("http://www.w3.org/1999/xhtml", "head");
   (document.documentElement).appendChild(head);
 
--- a/editor/libeditor/crashtests/761861.html
+++ b/editor/libeditor/crashtests/761861.html
@@ -1,14 +1,14 @@
 <!doctype html>
 <script>
 function boom() {
   var r = document.documentElement;
   while (r.firstChild) {
-    r.removeChild(r.firstChild);
+    r.firstChild.remove();
   }
 
   document.documentElement.contentEditable = "true";
   document.documentElement.appendChild(document.createElement("span"));
   document.documentElement.firstChild.appendChild(document.createTextNode("_"));
   document.execCommand("forwarddelete");
 }
 </script>
--- a/editor/libeditor/crashtests/766413.html
+++ b/editor/libeditor/crashtests/766413.html
@@ -2,17 +2,17 @@
 <html>
 <head>
 <script>
 
 function boom()
 {
   var root = document.documentElement;
   while (root.firstChild) {
-    root.removeChild(root.firstChild);
+    root.firstChild.remove();
   }
 
   var space = document.createTextNode(" ");
   var body = document.createElementNS("http://www.w3.org/1999/xhtml", "body");
   root.contentEditable = "true";
   root.focus();
   document.execCommand("contentReadOnly", false, null);
   root.appendChild(body);
--- a/editor/libeditor/crashtests/767169.html
+++ b/editor/libeditor/crashtests/767169.html
@@ -2,17 +2,17 @@
 <head>
 <script>
 
 // Document must not have a doctype to trigger the bug
 
 function boom()
 {
   var root = document.documentElement;
-  while (root.firstChild) { root.removeChild(root.firstChild); }
+  while (root.firstChild) { root.firstChild.remove(); }
   root.contentEditable = "true";
   document.removeChild(root);
   document.appendChild(root);
   window.getSelection().collapse(root, 0);
   window.getSelection().extend(document, 1);
   document.removeChild(root);
 }
 
--- a/editor/libeditor/crashtests/768765.html
+++ b/editor/libeditor/crashtests/768765.html
@@ -2,17 +2,17 @@
 <html>
 <head>
 <script>
 
 function boom()
 {
   var root = document.documentElement;
 
-  while (root.firstChild) { root.removeChild(root.firstChild); }
+  while (root.firstChild) { root.firstChild.remove(); }
 
   var body = document.createElementNS("http://www.w3.org/1999/xhtml", "body");
   var div = document.createElementNS("http://www.w3.org/1999/xhtml", "div");
   root.contentEditable = "true";
   root.appendChild(div);
   root.removeChild(div);
   root.insertBefore(body, root.firstChild);
 
--- a/editor/libeditor/crashtests/772282.html
+++ b/editor/libeditor/crashtests/772282.html
@@ -1,17 +1,17 @@
 <!DOCTYPE html>
 <html>
 <head>
 <script>
 
 function boom()
 {
   var root = document.documentElement;
-  while(root.firstChild) { root.removeChild(root.firstChild); }
+  while(root.firstChild) { root.firstChild.remove(); }
   var body = document.createElementNS("http://www.w3.org/1999/xhtml", "body");
   body.setAttributeNS(null, "contenteditable", "true");
   var img = document.createElementNS("http://www.w3.org/1999/xhtml", "img");
   body.appendChild(img);
   root.appendChild(body);
   document.removeChild(root);
   document.appendChild(root);
   document.execCommand("insertText", false, "5");
--- a/editor/libeditor/tests/browserscope/lib/richtext2/richtext2/static/js/range.js
+++ b/editor/libeditor/tests/browserscope/lib/richtext2/richtext2/static/js/range.js
@@ -2104,31 +2104,31 @@ goog.dom.createTable_ = function(doc, ro
   rowHtml = rowHtml.join("");
   var totalHtml = ["<table>"];
   for(i = 0;i < rows;i++) {
     totalHtml.push(rowHtml)
   }
   totalHtml.push("</table>");
   var elem = doc.createElement(goog.dom.TagName.DIV);
   elem.innerHTML = totalHtml.join("");
-  return elem.removeChild(elem.firstChild)
+  return elem.firstChild.remove()
 };
 goog.dom.htmlToDocumentFragment = function(htmlString) {
   return goog.dom.htmlToDocumentFragment_(document, htmlString)
 };
 goog.dom.htmlToDocumentFragment_ = function(doc, htmlString) {
   var tempDiv = doc.createElement("div");
   if(goog.dom.BrowserFeature.INNER_HTML_NEEDS_SCOPED_ELEMENT) {
     tempDiv.innerHTML = "<br>" + htmlString;
-    tempDiv.removeChild(tempDiv.firstChild)
+    tempDiv.firstChild.remove()
   }else {
     tempDiv.innerHTML = htmlString
   }
   if(tempDiv.childNodes.length == 1) {
-    return tempDiv.removeChild(tempDiv.firstChild)
+    return tempDiv.firstChild.remove()
   }else {
     var fragment = doc.createDocumentFragment();
     while(tempDiv.firstChild) {
       fragment.appendChild(tempDiv.firstChild)
     }
     return fragment
   }
 };
--- a/editor/libeditor/tests/file_select_all_without_body.html
+++ b/editor/libeditor/tests/file_select_all_without_body.html
@@ -11,17 +11,17 @@ function unload()
 {
   window.opener.SimpleTest.finish();
 }
 
 function boom()
 {
   var root = document.documentElement;
   while(root.firstChild) {
-    root.removeChild(root.firstChild);
+    root.firstChild.remove();
   }
   root.appendChild(document.createTextNode("Mozilla"));
   root.focus();
   cespan = document.createElementNS("http://www.w3.org/1999/xhtml", "span");
   cespan.setAttributeNS(null, "contenteditable", "true");
   root.appendChild(cespan);
   try {
     document.execCommand("selectAll", false, null);
--- a/editor/libeditor/tests/test_bug612447.html
+++ b/editor/libeditor/tests/test_bug612447.html
@@ -39,31 +39,31 @@ SimpleTest.waitForFocus(function() {
   doc.designMode = "on";
   i.focus();
   b.focus();
   var beforeA = snapshotWindow(win, true);
   synthesizeKey("X", {});
   var beforeB = snapshotWindow(win, true);
   is(b.textContent, "X", "Typing should work");
   while (b.firstChild) {
-    b.removeChild(b.firstChild);
+    b.firstChild.remove();
   }
   ok(editorCommandsEnabled(), "The editor commands should work");
 
   i.style.display = "block";
   document.clientWidth;
 
   i.focus();
   b.focus();
   var afterA = snapshotWindow(win, true);
   synthesizeKey("X", {});
   var afterB = snapshotWindow(win, true);
   is(b.textContent, "X", "Typing should work");
   while (b.firstChild) {
-    b.removeChild(b.firstChild);
+    b.firstChild.remove();
   }
   ok(editorCommandsEnabled(), "The editor commands should work");
 
   ok(compareSnapshots(beforeA, afterA, true)[0], "The iframes should look the same before typing");
   ok(compareSnapshots(beforeB, afterB, true)[0], "The iframes should look the same after typing");
 
   SimpleTest.finish();
 });
--- a/extensions/spellcheck/locales/en-US/hunspell/en-US.dic
+++ b/extensions/spellcheck/locales/en-US/hunspell/en-US.dic
@@ -1,9 +1,9 @@
-52349
+52352
 0/nm
 0th/pt
 1/n1
 1st/p
 1th/tc
 2/nm
 2nd/p
 2th/tc
@@ -14444,16 +14444,19 @@ analyst/SM
 analytic
 analytical/Y
 analyticalally
 analyzable
 analyze/ADSG
 analyzer/SM
 anapest/SM
 anapestic/MS
+anaphylactic
+anaphylaxes
+anaphylaxis
 anarchic
 anarchically
 anarchism/M
 anarchist/MS
 anarchistic
 anarchy/M
 anathema/SM
 anathematize/DSG
--- a/gfx/config/gfxFeature.h
+++ b/gfx/config/gfxFeature.h
@@ -14,17 +14,16 @@
 
 namespace mozilla {
 namespace gfx {
 
 #define GFX_FEATURE_MAP(_)                                                        \
   /* Name,                        Type,         Description */                    \
   _(HW_COMPOSITING,               Feature,      "Compositing")                    \
   _(D3D11_COMPOSITING,            Feature,      "Direct3D11 Compositing")         \
-  _(D3D9_COMPOSITING,             Feature,      "Direct3D9 Compositing")          \
   _(OPENGL_COMPOSITING,           Feature,      "OpenGL Compositing")             \
   _(DIRECT2D,                     Feature,      "Direct2D")                       \
   _(D3D11_HW_ANGLE,               Feature,      "Direct3D11 hardware ANGLE")      \
   _(DIRECT_DRAW,                  Feature,      "DirectDraw")                     \
   _(GPU_PROCESS,                  Feature,      "GPU Process")                    \
   _(WEBRENDER,                    Feature,      "WebRender")                      \
   /* Add new entries above this comment */
 
--- a/gfx/ipc/GPUChild.cpp
+++ b/gfx/ipc/GPUChild.cpp
@@ -53,17 +53,16 @@ GPUChild::Init()
     prefs.AppendElement(GfxPrefSetting(pref->Index(), value));
   }
 
   nsTArray<GfxVarUpdate> updates = gfxVars::FetchNonDefaultVars();
 
   DevicePrefs devicePrefs;
   devicePrefs.hwCompositing() = gfxConfig::GetValue(Feature::HW_COMPOSITING);
   devicePrefs.d3d11Compositing() = gfxConfig::GetValue(Feature::D3D11_COMPOSITING);
-  devicePrefs.d3d9Compositing() = gfxConfig::GetValue(Feature::D3D9_COMPOSITING);
   devicePrefs.oglCompositing() = gfxConfig::GetValue(Feature::OPENGL_COMPOSITING);
   devicePrefs.useD2D1() = gfxConfig::GetValue(Feature::DIRECT2D);
 
   SendInit(prefs, updates, devicePrefs);
 
   gfxVars::AddReceiver(this);
 }
 
--- a/gfx/ipc/GPUParent.cpp
+++ b/gfx/ipc/GPUParent.cpp
@@ -33,17 +33,16 @@
 #include "nsExceptionHandler.h"
 #include "nsThreadManager.h"
 #include "prenv.h"
 #include "ProcessUtils.h"
 #include "VRManager.h"
 #include "VRManagerParent.h"
 #include "VsyncBridgeParent.h"
 #if defined(XP_WIN)
-# include "DeviceManagerD3D9.h"
 # include "mozilla/gfx/DeviceManagerDx.h"
 # include <process.h>
 #endif
 #ifdef MOZ_WIDGET_GTK
 # include <gtk/gtk.h>
 #endif
 
 namespace mozilla {
@@ -98,17 +97,16 @@ GPUParent::Init(base::ProcessId aParentP
   gfxPrefs::GetSingleton();
   gfxConfig::Init();
   gfxVars::Initialize();
   gfxPlatform::InitNullMetadata();
   // Ensure our Factory is initialised, mainly for gfx logging to work.
   gfxPlatform::InitMoz2DLogging();
 #if defined(XP_WIN)
   DeviceManagerDx::Init();
-  DeviceManagerD3D9::Init();
 #endif
 
   if (NS_FAILED(NS_InitMinimalXPCOM())) {
     return false;
   }
 
   CompositorThreadHolder::Start();
   APZThreadUtils::SetControllerThread(CompositorThreadHolder::Loop());
@@ -157,17 +155,16 @@ GPUParent::RecvInit(nsTArray<GfxPrefSett
   }
   for (const auto& var : vars) {
     gfxVars::ApplyUpdate(var);
   }
 
   // Inherit device preferences.
   gfxConfig::Inherit(Feature::HW_COMPOSITING, devicePrefs.hwCompositing());
   gfxConfig::Inherit(Feature::D3D11_COMPOSITING, devicePrefs.d3d11Compositing());
-  gfxConfig::Inherit(Feature::D3D9_COMPOSITING, devicePrefs.d3d9Compositing());
   gfxConfig::Inherit(Feature::OPENGL_COMPOSITING, devicePrefs.oglCompositing());
   gfxConfig::Inherit(Feature::DIRECT2D, devicePrefs.useD2D1());
 
 #if defined(XP_WIN)
   if (gfxConfig::IsEnabled(Feature::D3D11_COMPOSITING)) {
     DeviceManagerDx::Get()->CreateCompositorDevices();
   }
 #endif
@@ -270,17 +267,16 @@ CopyFeatureChange(Feature aFeature, Feat
 
   *aOut = FeatureFailure(feature.GetValue(), message, feature.GetFailureId());
 }
 
 mozilla::ipc::IPCResult
 GPUParent::RecvGetDeviceStatus(GPUDeviceData* aOut)
 {
   CopyFeatureChange(Feature::D3D11_COMPOSITING, &aOut->d3d11Compositing());
-  CopyFeatureChange(Feature::D3D9_COMPOSITING, &aOut->d3d9Compositing());
   CopyFeatureChange(Feature::OPENGL_COMPOSITING, &aOut->oglCompositing());
 
 #if defined(XP_WIN)
   if (DeviceManagerDx* dm = DeviceManagerDx::Get()) {
     D3D11DeviceStatus deviceStatus;
     dm->ExportDeviceInfo(&deviceStatus);
     aOut->gpuDevice() = deviceStatus;
   }
@@ -418,17 +414,16 @@ GPUParent::ActorDestroy(ActorDestroyReas
   dom::VideoDecoderManagerParent::ShutdownVideoBridge();
   CompositorThreadHolder::Shutdown();
   if (gfxVars::UseWebRender()) {
     wr::RenderThread::ShutDown();
   }
   Factory::ShutDown();
 #if defined(XP_WIN)
   DeviceManagerDx::Shutdown();
-  DeviceManagerD3D9::Shutdown();
 #endif
   LayerTreeOwnerTracker::Shutdown();
   gfxVars::Shutdown();
   gfxConfig::Shutdown();
   gfxPrefs::DestroySingleton();
 #ifdef MOZ_CRASHREPORTER
   CrashReporterClient::DestroySingleton();
 #endif
--- a/gfx/ipc/GraphicsMessages.ipdlh
+++ b/gfx/ipc/GraphicsMessages.ipdlh
@@ -22,17 +22,16 @@ struct D3D11DeviceStatus
   uint32_t featureLevel;
   DxgiAdapterDesc adapter;
 };
 
 struct DevicePrefs
 {
   FeatureStatus hwCompositing;
   FeatureStatus d3d11Compositing;
-  FeatureStatus d3d9Compositing;
   FeatureStatus oglCompositing;
   FeatureStatus useD2D1;
 };
 
 struct ContentDeviceData
 {
   DevicePrefs prefs;
   D3D11DeviceStatus d3d11;
@@ -58,17 +57,16 @@ union GPUDeviceStatus
 {
   null_t;
   D3D11DeviceStatus;
 };
 
 struct GPUDeviceData
 {
   FeatureChange d3d11Compositing;
-  FeatureChange d3d9Compositing;
   FeatureChange oglCompositing;
   GPUDeviceStatus gpuDevice;
 };
 
 union GfxVarValue
 {
   BackendType;
   bool;
--- a/gfx/layers/Compositor.h
+++ b/gfx/layers/Compositor.h
@@ -125,17 +125,16 @@ struct EffectChain;
 class Image;
 class Layer;
 class TextureSource;
 class DataTextureSource;
 class CompositingRenderTarget;
 class CompositorBridgeParent;
 class LayerManagerComposite;
 class CompositorOGL;
-class CompositorD3D9;
 class CompositorD3D11;
 class BasicCompositor;
 class TextureHost;
 class TextureReadLock;
 
 enum SurfaceInitMode
 {
   INIT_MODE_NONE,
@@ -465,17 +464,16 @@ public:
 
 #ifdef MOZ_DUMP_PAINTING
   virtual const char* Name() const = 0;
 #endif // MOZ_DUMP_PAINTING
 
   virtual LayersBackend GetBackendType() const = 0;
 
   virtual CompositorOGL* AsCompositorOGL() { return nullptr; }
-  virtual CompositorD3D9* AsCompositorD3D9() { return nullptr; }
   virtual CompositorD3D11* AsCompositorD3D11() { return nullptr; }
   virtual BasicCompositor* AsBasicCompositor() { return nullptr; }
 
   /**
    * Each Compositor has a unique ID.
    * This ID is used to keep references to each Compositor in a map accessed
    * from the compositor thread only, so that async compositables can find
    * the right compositor parent and schedule compositing even if the compositor
--- a/gfx/layers/D3D11ShareHandleImage.cpp
+++ b/gfx/layers/D3D11ShareHandleImage.cpp
@@ -7,33 +7,40 @@
 #include "D3D11ShareHandleImage.h"
 #include "gfxImageSurface.h"
 #include "gfxWindowsPlatform.h"
 #include "mozilla/layers/TextureClient.h"
 #include "mozilla/layers/TextureD3D11.h"
 #include "mozilla/layers/CompositableClient.h"
 #include "mozilla/layers/CompositableForwarder.h"
 #include "d3d11.h"
+#include "gfxPrefs.h"
+#include "DXVA2Manager.h"
+#include <memory>
 
 namespace mozilla {
 namespace layers {
 
 D3D11ShareHandleImage::D3D11ShareHandleImage(const gfx::IntSize& aSize,
                                              const gfx::IntRect& aRect)
  : Image(nullptr, ImageFormat::D3D11_SHARE_HANDLE_TEXTURE),
    mSize(aSize),
    mPictureRect(aRect)
 {
 }
 
 bool
 D3D11ShareHandleImage::AllocateTexture(D3D11RecycleAllocator* aAllocator, ID3D11Device* aDevice)
 {
   if (aAllocator) {
-    mTextureClient = aAllocator->CreateOrRecycleClient(gfx::SurfaceFormat::B8G8R8A8, mSize);
+    if (gfxPrefs::PDMWMFUseNV12Format()) {
+      mTextureClient = aAllocator->CreateOrRecycleClient(gfx::SurfaceFormat::NV12, mSize);
+    } else {
+      mTextureClient = aAllocator->CreateOrRecycleClient(gfx::SurfaceFormat::B8G8R8A8, mSize);
+    }
     if (mTextureClient) {
       mTexture = static_cast<D3D11TextureData*>(mTextureClient->GetInternalData())->GetD3D11Texture();
       return true;
     }
     return false;
   } else {
     MOZ_ASSERT(aDevice);
     CD3D11_TEXTURE2D_DESC newDesc(DXGI_FORMAT_B8G8R8A8_UNORM,
@@ -68,25 +75,49 @@ D3D11ShareHandleImage::GetAsSourceSurfac
   }
 
   RefPtr<ID3D11Device> device;
   texture->GetDevice(getter_AddRefs(device));
 
   D3D11_TEXTURE2D_DESC desc;
   texture->GetDesc(&desc);
 
+  HRESULT hr;
+
+  if (desc.Format == DXGI_FORMAT_NV12) {
+    nsAutoCString error;
+    std::unique_ptr<DXVA2Manager> manager(DXVA2Manager::CreateD3D11DXVA(nullptr, error, device));
+
+    if (!manager) {
+      gfxWarning() << "Failed to create DXVA2 manager!";
+      return nullptr;
+    }
+
+    RefPtr<ID3D11Texture2D> outTexture;
+
+    hr = manager->CopyToBGRATexture(texture, getter_AddRefs(outTexture));
+
+    if (FAILED(hr)) {
+      gfxWarning() << "Failed to copy NV12 to BGRA texture.";
+      return nullptr;
+    }
+
+    texture = outTexture;
+    texture->GetDesc(&desc);
+  }
+
   CD3D11_TEXTURE2D_DESC softDesc(desc.Format, desc.Width, desc.Height);
   softDesc.CPUAccessFlags = D3D11_CPU_ACCESS_READ;
   softDesc.BindFlags = 0;
   softDesc.MiscFlags = 0;
   softDesc.MipLevels = 1;
   softDesc.Usage = D3D11_USAGE_STAGING;
 
   RefPtr<ID3D11Texture2D> softTexture;
-  HRESULT hr = device->CreateTexture2D(&softDesc,
+  hr = device->CreateTexture2D(&softDesc,
                                        NULL,
                                        static_cast<ID3D11Texture2D**>(getter_AddRefs(softTexture)));
 
   if (FAILED(hr)) {
     NS_WARNING("Failed to create 2D staging texture.");
     return nullptr;
   }
 
@@ -156,20 +187,24 @@ D3D11RecycleAllocator::Allocate(gfx::Sur
                                             aTextureFlags, aAllocFlags,
                                             mDevice, mSurfaceAllocator->GetTextureForwarder());
 }
 
 already_AddRefed<TextureClient>
 D3D11RecycleAllocator::CreateOrRecycleClient(gfx::SurfaceFormat aFormat,
                                              const gfx::IntSize& aSize)
 {
+  TextureAllocationFlags allocFlags = TextureAllocationFlags::ALLOC_DEFAULT;
+  if (gfxPrefs::PDMWMFUseSyncTexture()) {
+    allocFlags = TextureAllocationFlags::ALLOC_MANUAL_SYNCHRONIZATION;
+  }
   RefPtr<TextureClient> textureClient =
     CreateOrRecycle(aFormat,
                     aSize,
                     BackendSelector::Content,
                     layers::TextureFlags::DEFAULT,
-                    TextureAllocationFlags::ALLOC_DEFAULT);
+                    allocFlags);
   return textureClient.forget();
 }
 
 
 } // namespace layers
 } // namespace mozilla
--- a/gfx/layers/D3D9SurfaceImage.cpp
+++ b/gfx/layers/D3D9SurfaceImage.cpp
@@ -1,24 +1,105 @@
 /* -*- 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/. */
 
 #include "D3D9SurfaceImage.h"
 #include "gfx2DGlue.h"
-#include "mozilla/layers/TextureD3D9.h"
+#include "gfxWindowsPlatform.h"
 #include "mozilla/layers/CompositableClient.h"
 #include "mozilla/layers/CompositableForwarder.h"
 #include "mozilla/layers/ImageBridgeChild.h"
 #include "mozilla/gfx/Types.h"
 
 namespace mozilla {
 namespace layers {
 
+DXGID3D9TextureData::DXGID3D9TextureData(gfx::SurfaceFormat aFormat,
+                                         IDirect3DTexture9* aTexture, HANDLE aHandle,
+                                         IDirect3DDevice9* aDevice)
+: mDevice(aDevice)
+, mTexture(aTexture)
+, mFormat(aFormat)
+, mHandle(aHandle)
+{
+  MOZ_COUNT_CTOR(DXGID3D9TextureData);
+}
+
+DXGID3D9TextureData::~DXGID3D9TextureData()
+{
+  gfxWindowsPlatform::sD3D9SharedTextures -= mDesc.Width * mDesc.Height * 4;
+  MOZ_COUNT_DTOR(DXGID3D9TextureData);
+}
+
+// static
+DXGID3D9TextureData*
+DXGID3D9TextureData::Create(gfx::IntSize aSize, gfx::SurfaceFormat aFormat,
+                            TextureFlags aFlags,
+                            IDirect3DDevice9* aDevice)
+{
+  PROFILER_LABEL_FUNC(js::ProfileEntry::Category::GRAPHICS);
+  MOZ_ASSERT(aFormat == gfx::SurfaceFormat::B8G8R8A8);
+  if (aFormat != gfx::SurfaceFormat::B8G8R8A8) {
+    return nullptr;
+  }
+
+  RefPtr<IDirect3DTexture9> texture;
+  HANDLE shareHandle = nullptr;
+  HRESULT hr = aDevice->CreateTexture(aSize.width, aSize.height,
+                                      1,
+                                      D3DUSAGE_RENDERTARGET,
+                                      D3DFMT_A8R8G8B8,
+                                      D3DPOOL_DEFAULT,
+                                      getter_AddRefs(texture),
+                                      &shareHandle);
+  if (FAILED(hr) || !shareHandle) {
+    return nullptr;
+  }
+
+  D3DSURFACE_DESC surfaceDesc;
+  hr = texture->GetLevelDesc(0, &surfaceDesc);
+  if (FAILED(hr)) {
+    return nullptr;
+  }
+  DXGID3D9TextureData* data = new DXGID3D9TextureData(aFormat, texture, shareHandle, aDevice);
+  data->mDesc = surfaceDesc;
+
+  gfxWindowsPlatform::sD3D9SharedTextures += aSize.width * aSize.height * 4;
+  return data;
+}
+
+void
+DXGID3D9TextureData::FillInfo(TextureData::Info& aInfo) const
+{
+  aInfo.size = GetSize();
+  aInfo.format = mFormat;
+  aInfo.supportsMoz2D = false;
+  aInfo.canExposeMappedData = false;
+  aInfo.hasIntermediateBuffer = false;
+  aInfo.hasSynchronization = false;
+}
+
+already_AddRefed<IDirect3DSurface9>
+DXGID3D9TextureData::GetD3D9Surface() const
+{
+  RefPtr<IDirect3DSurface9> textureSurface;
+  HRESULT hr = mTexture->GetSurfaceLevel(0, getter_AddRefs(textureSurface));
+  NS_ENSURE_TRUE(SUCCEEDED(hr), nullptr);
+
+  return textureSurface.forget();
+}
+
+bool
+DXGID3D9TextureData::Serialize(SurfaceDescriptor& aOutDescriptor)
+{
+  aOutDescriptor = SurfaceDescriptorD3D10((WindowsHandle)(mHandle), mFormat, GetSize());
+  return true;
+}
 
 D3D9SurfaceImage::D3D9SurfaceImage()
   : Image(nullptr, ImageFormat::D3D9_RGB32_TEXTURE)
   , mSize(0, 0)
   , mShareHandle(0)
   , mValid(true)
 {}
 
--- a/gfx/layers/D3D9SurfaceImage.h
+++ b/gfx/layers/D3D9SurfaceImage.h
@@ -35,16 +35,64 @@ protected:
            gfx::IntSize aSize,
            BackendSelector aSelector,
            TextureFlags aTextureFlags,
            TextureAllocationFlags aAllocFlags) override;
 
   RefPtr<IDirect3DDevice9> mDevice;
 };
 
+/**
+ * Wraps a D3D9 texture, shared with the compositor though DXGI.
+ * At the moment it is only used with D3D11 compositing, and the corresponding
+ * TextureHost is DXGITextureHostD3D11.
+ */
+class DXGID3D9TextureData : public TextureData
+{
+public:
+  static DXGID3D9TextureData*
+  Create(gfx::IntSize aSize, gfx::SurfaceFormat aFormat, TextureFlags aFlags, IDirect3DDevice9* aDevice);
+
+  ~DXGID3D9TextureData();
+
+  virtual void FillInfo(TextureData::Info& aInfo) const override;
+
+  virtual bool Lock(OpenMode) override { return true; }
+
+  virtual void Unlock() override {}
+
+  virtual bool Serialize(SurfaceDescriptor& aOutDescriptor) override;
+
+  virtual void Deallocate(LayersIPCChannel* aAllocator) override {}
+
+  IDirect3DDevice9* GetD3D9Device() { return mDevice; }
+  IDirect3DTexture9* GetD3D9Texture() { return mTexture; }
+  HANDLE GetShareHandle() const { return mHandle; }
+  already_AddRefed<IDirect3DSurface9> GetD3D9Surface() const;
+
+  const D3DSURFACE_DESC& GetDesc() const
+  {
+    return mDesc;
+  }
+
+  gfx::IntSize GetSize() const { return gfx::IntSize(mDesc.Width, mDesc.Height); }
+
+protected:
+  DXGID3D9TextureData(gfx::SurfaceFormat aFormat,
+                      IDirect3DTexture9* aTexture, HANDLE aHandle,
+                      IDirect3DDevice9* aDevice);
+
+  RefPtr<IDirect3DDevice9> mDevice;
+  RefPtr<IDirect3DTexture9> mTexture;
+  gfx::SurfaceFormat mFormat;
+  HANDLE mHandle;
+  D3DSURFACE_DESC mDesc;
+};
+
+
 // Image class that wraps a IDirect3DSurface9. This class copies the image
 // passed into SetData(), so that it can be accessed from other D3D devices.
 // This class also manages the synchronization of the copy, to ensure the
 // resource is ready to use.
 class D3D9SurfaceImage : public Image {
 public:
   explicit D3D9SurfaceImage();
   virtual ~D3D9SurfaceImage();
--- a/gfx/layers/IMFYCbCrImage.cpp
+++ b/gfx/layers/IMFYCbCrImage.cpp
@@ -1,15 +1,14 @@
 /* -*- 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/. */
 
 #include "IMFYCbCrImage.h"
-#include "DeviceManagerD3D9.h"
 #include "mozilla/layers/TextureD3D11.h"
 #include "mozilla/layers/CompositableClient.h"
 #include "mozilla/layers/CompositableForwarder.h"
 #include "mozilla/gfx/DeviceManagerDx.h"
 #include "mozilla/gfx/Types.h"
 #include "mozilla/layers/TextureClient.h"
 #include "d3d9.h"
 
@@ -128,101 +127,16 @@ FinishTextures(IDirect3DDevice9* aDevice
 
   hr = aDevice->UpdateSurface(aSurface, nullptr, dstSurface, nullptr);
   if (FAILED(hr)) {
     return false;
   }
   return true;
 }
 
-static bool UploadData(IDirect3DDevice9* aDevice,
-                       RefPtr<IDirect3DTexture9>& aTexture,
-                       HANDLE& aHandle,
-                       uint8_t* aSrc,
-                       const gfx::IntSize& aSrcSize,
-                       int32_t aSrcStride)
-{
-  RefPtr<IDirect3DSurface9> surf;
-  D3DLOCKED_RECT rect;
-  aTexture = InitTextures(aDevice, aSrcSize, D3DFMT_A8, surf, aHandle, rect);
-  if (!aTexture) {
-    return false;
-  }
-
-  if (aSrcStride == rect.Pitch) {
-    memcpy(rect.pBits, aSrc, rect.Pitch * aSrcSize.height);
-  } else {
-    for (int i = 0; i < aSrcSize.height; i++) {
-      memcpy((uint8_t*)rect.pBits + i * rect.Pitch,
-             aSrc + i * aSrcStride,
-             aSrcSize.width);
-    }
-  }
-
-  return FinishTextures(aDevice, aTexture, surf);
-}
-
-DXGIYCbCrTextureData*
-IMFYCbCrImage::GetD3D9TextureData(Data aData, gfx::IntSize aSize)
-{
-  RefPtr<IDirect3DDevice9> device = DeviceManagerD3D9::GetDevice();
-  if (!device) {
-    return nullptr;
-  }
-
-  RefPtr<IDirect3DTexture9> textureY;
-  HANDLE shareHandleY = 0;
-  if (!UploadData(device, textureY, shareHandleY,
-                  aData.mYChannel, aData.mYSize, aData.mYStride)) {
-    return nullptr;
-  }
-
-  RefPtr<IDirect3DTexture9> textureCb;
-  HANDLE shareHandleCb = 0;
-  if (!UploadData(device, textureCb, shareHandleCb,
-                  aData.mCbChannel, aData.mCbCrSize, aData.mCbCrStride)) {
-    return nullptr;
-  }
-
-  RefPtr<IDirect3DTexture9> textureCr;
-  HANDLE shareHandleCr = 0;
-  if (!UploadData(device, textureCr, shareHandleCr,
-                  aData.mCrChannel, aData.mCbCrSize, aData.mCbCrStride)) {
-    return nullptr;
-  }
-
-  RefPtr<IDirect3DQuery9> query;
-  HRESULT hr = device->CreateQuery(D3DQUERYTYPE_EVENT, getter_AddRefs(query));
-  hr = query->Issue(D3DISSUE_END);
-
-  int iterations = 0;
-  bool valid = false;
-  while (iterations < 10) {
-    HRESULT hr = query->GetData(nullptr, 0, D3DGETDATA_FLUSH);
-    if (hr == S_FALSE) {
-      Sleep(1);
-      iterations++;
-      continue;
-    }
-    if (hr == S_OK) {
-      valid = true;
-    }
-    break;
-  }
-
-  if (!valid) {
-    return nullptr;
-  }
-
-  return DXGIYCbCrTextureData::Create(TextureFlags::DEFAULT, textureY,
-                                      textureCb, textureCr, shareHandleY,
-                                      shareHandleCb, shareHandleCr, aSize,
-                                      aData.mYSize, aData.mCbCrSize);
-}
-
 DXGIYCbCrTextureData*
 IMFYCbCrImage::GetD3D11TextureData(Data aData, gfx::IntSize aSize)
 {
   HRESULT hr;
   RefPtr<ID3D10Multithread> mt;
 
   RefPtr<ID3D11Device> device =
     gfx::DeviceManagerDx::Get()->GetContentDevice();
@@ -309,32 +223,16 @@ IMFYCbCrImage::GetD3D11TextureData(Data 
   }
 
   return DXGIYCbCrTextureData::Create(TextureFlags::DEFAULT, textureY,
                                       textureCb, textureCr, aSize, aData.mYSize,
                                       aData.mCbCrSize);
 }
 
 TextureClient*
-IMFYCbCrImage::GetD3D9TextureClient(KnowsCompositor* aForwarder)
-{
-  DXGIYCbCrTextureData* textureData = GetD3D9TextureData(mData, GetSize());
-  if (textureData == nullptr) {
-   return nullptr;
-  }
-
-  mTextureClient = TextureClient::CreateWithData(
-    textureData, TextureFlags::DEFAULT,
-    aForwarder->GetTextureForwarder()
-  );
-
-  return mTextureClient;
-}
-
-TextureClient*
 IMFYCbCrImage::GetD3D11TextureClient(KnowsCompositor* aForwarder)
 {
   DXGIYCbCrTextureData* textureData = GetD3D11TextureData(mData, GetSize());
 
   if (textureData == nullptr) {
     return nullptr;
   }
 
@@ -357,19 +255,15 @@ IMFYCbCrImage::GetTextureClient(KnowsCom
     gfx::DeviceManagerDx::Get()->GetContentDevice();
   if (!device) {
     device =
       gfx::DeviceManagerDx::Get()->GetCompositorDevice();
   }
 
   LayersBackend backend = aForwarder->GetCompositorBackendType();
   if (!device || backend != LayersBackend::LAYERS_D3D11) {
-    if (backend == LayersBackend::LAYERS_D3D9 ||
-        backend == LayersBackend::LAYERS_D3D11) {
-      return GetD3D9TextureClient(aForwarder);
-    }
     return nullptr;
   }
   return GetD3D11TextureClient(aForwarder);
 }
 
 } // namespace layers
 } // namespace mozilla
--- a/gfx/layers/IMFYCbCrImage.h
+++ b/gfx/layers/IMFYCbCrImage.h
@@ -18,23 +18,19 @@ class IMFYCbCrImage : public RecyclingPl
 {
 public:
   IMFYCbCrImage(IMFMediaBuffer* aBuffer, IMF2DBuffer* a2DBuffer);
 
   virtual bool IsValid() { return true; }
 
   virtual TextureClient* GetTextureClient(KnowsCompositor* aForwarder) override;
 
-  static DXGIYCbCrTextureData* GetD3D9TextureData(Data aData,
-                                                 gfx::IntSize aSize);
   static DXGIYCbCrTextureData* GetD3D11TextureData(Data aData,
                                                   gfx::IntSize aSize);
 protected:
-
-  TextureClient* GetD3D9TextureClient(KnowsCompositor* aForwarder);
   TextureClient* GetD3D11TextureClient(KnowsCompositor* aForwarder);
 
   ~IMFYCbCrImage();
 
   RefPtr<IMFMediaBuffer> mBuffer;
   RefPtr<IMF2DBuffer> m2DBuffer;
   RefPtr<TextureClient> mTextureClient;
 };
--- a/gfx/layers/client/CompositableClient.cpp
+++ b/gfx/layers/client/CompositableClient.cpp
@@ -10,17 +10,16 @@
 #include "mozilla/layers/ImageBridgeChild.h"
 #include "mozilla/layers/TextureClient.h"  // for TextureClient, etc
 #include "mozilla/layers/TextureClientOGL.h"
 #include "mozilla/mozalloc.h"           // for operator delete, etc
 #include "mozilla/layers/TextureClientRecycleAllocator.h"
 #ifdef XP_WIN
 #include "gfxWindowsPlatform.h"         // for gfxWindowsPlatform
 #include "mozilla/layers/TextureD3D11.h"
-#include "mozilla/layers/TextureD3D9.h"
 #endif
 #include "gfxUtils.h"
 #include "IPDLActor.h"
 
 namespace mozilla {
 namespace layers {
 
 using namespace mozilla::gfx;
--- a/gfx/layers/client/TextureClient.cpp
+++ b/gfx/layers/client/TextureClient.cpp
@@ -29,19 +29,17 @@
 #include "gfxUtils.h"                   // for gfxUtils::GetAsLZ4Base64Str
 #include "IPDLActor.h"
 #include "BufferTexture.h"
 #include "gfxPrefs.h"
 #include "mozilla/layers/ShadowLayers.h"
 #include "mozilla/ipc/CrossProcessSemaphore.h"
 
 #ifdef XP_WIN
-#include "DeviceManagerD3D9.h"
 #include "mozilla/gfx/DeviceManagerDx.h"
-#include "mozilla/layers/TextureD3D9.h"
 #include "mozilla/layers/TextureD3D11.h"
 #include "mozilla/layers/TextureDIB.h"
 #include "gfxWindowsPlatform.h"
 #include "gfx2DGlue.h"
 #endif
 #ifdef MOZ_X11
 #include "mozilla/layers/TextureClientX11.h"
 #ifdef GL_PROVIDER_GLX
@@ -1046,25 +1044,16 @@ TextureClient::CreateForDrawing(TextureF
        (!!(aAllocFlags & ALLOC_FOR_OUT_OF_BAND_CONTENT) &&
         DeviceManagerDx::Get()->GetContentDevice())) &&
       aSize.width <= aMaxTextureSize &&
       aSize.height <= aMaxTextureSize &&
       !(aAllocFlags & ALLOC_UPDATE_FROM_SURFACE))
   {
     data = DXGITextureData::Create(aSize, aFormat, aAllocFlags);
   }
-  if (aLayersBackend == LayersBackend::LAYERS_D3D9 &&
-      moz2DBackend == gfx::BackendType::CAIRO &&
-      aAllocator->IsSameProcess() &&
-      aSize.width <= aMaxTextureSize &&
-      aSize.height <= aMaxTextureSize &&
-      NS_IsMainThread() &&
-      DeviceManagerD3D9::GetDevice()) {
-    data = D3D9TextureData::Create(aSize, aFormat, aAllocFlags);
-  }
 
   if (aLayersBackend != LayersBackend::LAYERS_WR &&
       !data && aFormat == SurfaceFormat::B8G8R8X8 &&
       moz2DBackend == gfx::BackendType::CAIRO &&
       NS_IsMainThread()) {
     data = DIBTextureData::Create(aSize, aFormat, aAllocator);
   }
 #endif
@@ -1708,24 +1697,28 @@ UpdateYCbCrTextureClient(TextureClient* 
     // We don't have support for proper locking yet, so we'll
     // have to be immutable instead.
     aTexture->MarkImmutable();
   }
   return true;
 }
 
 already_AddRefed<SyncObject>
-SyncObject::CreateSyncObject(SyncHandle aHandle)
+SyncObject::CreateSyncObject(SyncHandle aHandle
+#ifdef XP_WIN
+                             , ID3D11Device* aDevice
+#endif
+                             )
 {
   if (!aHandle) {
     return nullptr;
   }
 
 #ifdef XP_WIN
-  return MakeAndAddRef<SyncObjectD3D11>(aHandle);
+  return MakeAndAddRef<SyncObjectD3D11>(aHandle, aDevice);
 #else
   MOZ_ASSERT_UNREACHABLE();
   return nullptr;
 #endif
 }
 
 already_AddRefed<TextureClient>
 TextureClient::CreateWithData(TextureData* aData, TextureFlags aFlags, LayersIPCChannel* aAllocator)
--- a/gfx/layers/client/TextureClient.h
+++ b/gfx/layers/client/TextureClient.h
@@ -27,16 +27,17 @@
 #include "mozilla/gfx/CriticalSection.h"
 #include "nsCOMPtr.h"                   // for already_AddRefed
 #include "nsISupportsImpl.h"            // for TextureImage::AddRef, etc
 #include "GfxTexturesReporter.h"
 #include "pratom.h"
 #include "nsThreadUtils.h"
 
 class gfxImageSurface;
+struct ID3D11Device;
 
 namespace mozilla {
 
 // When defined, we track which pool the tile came from and test for
 // any inconsistencies.  This can be defined in release build as well.
 #ifdef DEBUG
 #define GFX_DEBUG_TRACK_CLIENTS_IN_POOL 1
 #endif
@@ -98,17 +99,21 @@ typedef uintptr_t SyncHandle;
 #endif // XP_WIN
 
 class SyncObject : public RefCounted<SyncObject>
 {
 public:
   MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(SyncObject)
   virtual ~SyncObject() { }
 
-  static already_AddRefed<SyncObject> CreateSyncObject(SyncHandle aHandle);
+  static already_AddRefed<SyncObject> CreateSyncObject(SyncHandle aHandle
+#ifdef XP_WIN
+                                                       , ID3D11Device* aDevice = nullptr
+#endif
+                                                       );
 
   enum class SyncType {
     D3D11,
   };
 
   virtual SyncType GetSyncType() = 0;
   virtual void FinalizeFrame() = 0;
   virtual bool IsSyncObjectValid() = 0;
--- a/gfx/layers/composite/TextureHost.cpp
+++ b/gfx/layers/composite/TextureHost.cpp
@@ -168,21 +168,16 @@ already_AddRefed<TextureHost> CreateText
                                                  ISurfaceAllocator* aDeallocator,
                                                  TextureFlags aFlags);
 
 // implemented in TextureD3D11.cpp
 already_AddRefed<TextureHost> CreateTextureHostD3D11(const SurfaceDescriptor& aDesc,
                                                  ISurfaceAllocator* aDeallocator,
                                                  TextureFlags aFlags);
 
-// implemented in TextureD3D9.cpp
-already_AddRefed<TextureHost> CreateTextureHostD3D9(const SurfaceDescriptor& aDesc,
-                                                ISurfaceAllocator* aDeallocator,
-                                                TextureFlags aFlags);
-
 already_AddRefed<TextureHost>
 TextureHost::Create(const SurfaceDescriptor& aDesc,
                     ISurfaceAllocator* aDeallocator,
                     LayersBackend aBackend,
                     TextureFlags aFlags)
 {
   switch (aDesc.type()) {
     case SurfaceDescriptor::TSurfaceDescriptorBuffer:
@@ -207,26 +202,19 @@ TextureHost::Create(const SurfaceDescrip
 #ifdef MOZ_X11
     case SurfaceDescriptor::TSurfaceDescriptorX11: {
       const SurfaceDescriptorX11& desc = aDesc.get_SurfaceDescriptorX11();
       return MakeAndAddRef<X11TextureHost>(aFlags, desc);
     }
 #endif
 
 #ifdef XP_WIN
-    case SurfaceDescriptor::TSurfaceDescriptorD3D9:
-      return CreateTextureHostD3D9(aDesc, aDeallocator, aFlags);
-
     case SurfaceDescriptor::TSurfaceDescriptorD3D10:
     case SurfaceDescriptor::TSurfaceDescriptorDXGIYCbCr:
-      if (aBackend == LayersBackend::LAYERS_D3D9) {
-        return CreateTextureHostD3D9(aDesc, aDeallocator, aFlags);
-      } else {
-        return CreateTextureHostD3D11(aDesc, aDeallocator, aFlags);
-      }
+      return CreateTextureHostD3D11(aDesc, aDeallocator, aFlags);
 #endif
     default:
       MOZ_CRASH("GFX: Unsupported Surface type host");
   }
 }
 
 already_AddRefed<TextureHost>
 CreateBackendIndependentTextureHost(const SurfaceDescriptor& aDesc,
--- a/gfx/layers/composite/TextureHost.h
+++ b/gfx/layers/composite/TextureHost.h
@@ -44,17 +44,16 @@ class CompositableParentManager;
 class ReadLockDescriptor;
 class CompositorBridgeParent;
 class SurfaceDescriptor;
 class HostIPCAllocator;
 class ISurfaceAllocator;
 class TextureHostOGL;
 class TextureReadLock;
 class TextureSourceOGL;
-class TextureSourceD3D9;
 class TextureSourceD3D11;
 class TextureSourceBasic;
 class DataTextureSource;
 class PTextureParent;
 class TextureParent;
 class WrappingTextureSourceYCbCrBasic;
 
 /**
@@ -115,17 +114,16 @@ public:
 
   /**
    * Cast to a TextureSource for for each backend..
    */
   virtual TextureSourceOGL* AsSourceOGL() {
     gfxCriticalNote << "Failed to cast " << Name() << " into a TextureSourceOGL";
     return nullptr;
   }
-  virtual TextureSourceD3D9* AsSourceD3D9() { return nullptr; }
   virtual TextureSourceD3D11* AsSourceD3D11() { return nullptr; }
   virtual TextureSourceBasic* AsSourceBasic() { return nullptr; }
   /**
    * Cast to a DataTextureSurce.
    */
   virtual DataTextureSource* AsDataTextureSource() { return nullptr; }
   virtual WrappingTextureSourceYCbCrBasic* AsWrappingTextureSourceYCbCrBasic() { return nullptr; }
 
--- a/gfx/layers/d3d11/BlendShaderConstants.h
+++ b/gfx/layers/d3d11/BlendShaderConstants.h
@@ -6,16 +6,17 @@
 #ifndef MOZILLA_GFX_LAYERS_D3D11_BLENDSHADERCONSTANTS_H_
 #define MOZILLA_GFX_LAYERS_D3D11_BLENDSHADERCONSTANTS_H_
 
 // These constants are shared between CompositorD3D11 and the blend pixel shader.
 #define PS_LAYER_RGB          0
 #define PS_LAYER_RGBA         1
 #define PS_LAYER_YCBCR        2
 #define PS_LAYER_COLOR        3
+#define PS_LAYER_NV12         4
 
 // These must be in the same order as the Mask enum.
 #define PS_MASK_NONE         0
 #define PS_MASK              1
 
 // These must be in the same order as CompositionOp.
 #define PS_BLEND_MULTIPLY    0
 #define PS_BLEND_SCREEN      1
--- a/gfx/layers/d3d11/CompositorD3D11.cpp
+++ b/gfx/layers/d3d11/CompositorD3D11.cpp
@@ -25,17 +25,16 @@
 #include "mozilla/Services.h"
 #include "mozilla/widget/WinCompositorWidget.h"
 
 #include "mozilla/EnumeratedArray.h"
 #include "mozilla/Telemetry.h"
 #include "BlendShaderConstants.h"
 
 #include "D3D11ShareHandleImage.h"
-#include "D3D9SurfaceImage.h"
 
 #include <dxgi1_2.h>
 
 namespace mozilla {
 
 using namespace gfx;
 
 namespace layers {
@@ -102,16 +101,17 @@ struct DeviceAttachmentsD3D11
 
   VertexShaderArray mVSDynamicShader;
   VertexShaderArray mVSDynamicBlendShader;
 
   PixelShaderArray mSolidColorShader;
   PixelShaderArray mRGBAShader;
   PixelShaderArray mRGBShader;
   PixelShaderArray mYCbCrShader;
+  PixelShaderArray mNV12Shader;
   PixelShaderArray mComponentAlphaShader;
   PixelShaderArray mBlendShader;
   RefPtr<ID3D11Buffer> mPSConstantBuffer;
   RefPtr<ID3D11Buffer> mVSConstantBuffer;
   RefPtr<ID3D11RasterizerState> mRasterizerState;
   RefPtr<ID3D11SamplerState> mLinearSamplerState;
   RefPtr<ID3D11SamplerState> mPointSamplerState;
 
@@ -761,16 +761,18 @@ CompositorD3D11::GetPSForEffect(Effect* 
   case EffectTypes::RENDER_TARGET:
     return mAttachments->mRGBAShader[aMaskType];
   case EffectTypes::RGB: {
     SurfaceFormat format = static_cast<TexturedEffect*>(aEffect)->mTexture->GetFormat();
     return (format == SurfaceFormat::B8G8R8A8 || format == SurfaceFormat::R8G8B8A8)
            ? mAttachments->mRGBAShader[aMaskType]
            : mAttachments->mRGBShader[aMaskType];
   }
+  case EffectTypes::NV12:
+    return mAttachments->mNV12Shader[aMaskType];
   case EffectTypes::YCBCR:
     return mAttachments->mYCbCrShader[aMaskType];
   case EffectTypes::COMPONENT_ALPHA:
     return mAttachments->mComponentAlphaShader[aMaskType];
   default:
     NS_WARNING("No shader to load");
     return nullptr;
   }
@@ -834,16 +836,18 @@ EffectToBlendLayerType(Effect* aEffect)
     return (format == gfx::SurfaceFormat::B8G8R8A8 || format == gfx::SurfaceFormat::R8G8B8A8)
            ? PS_LAYER_RGBA
            : PS_LAYER_RGB;
   }
   case EffectTypes::RENDER_TARGET:
     return PS_LAYER_RGBA;
   case EffectTypes::YCBCR:
     return PS_LAYER_YCBCR;
+  case EffectTypes::NV12:
+    return PS_LAYER_NV12;
   default:
     MOZ_ASSERT_UNREACHABLE("blending not supported for this layer type");
     return 0;
   }
 }
 
 void
 CompositorD3D11::DrawQuad(const gfx::Rect& aRect,
@@ -1095,16 +1099,57 @@ CompositorD3D11::DrawGeometry(const Geom
       if (!texturedEffect->mPremultiplied) {
         mContext->OMSetBlendState(mAttachments->mNonPremulBlendState, sBlendFactor, 0xFFFFFFFF);
         restoreBlendMode = true;
       }
 
       SetSamplerForSamplingFilter(texturedEffect->mSamplingFilter);
     }
     break;
+  case EffectTypes::NV12:
+    {
+      TexturedEffect* texturedEffect =
+        static_cast<TexturedEffect*>(aEffectChain.mPrimaryEffect.get());
+
+      pTexCoordRect = &texturedEffect->mTextureCoords;
+
+      TextureSourceD3D11* source = texturedEffect->mTexture->AsSourceD3D11();
+      if (!source) {
+        NS_WARNING("Missing texture source!");
+        return;
+      }
+
+      RefPtr<ID3D11Texture2D> texture = source->GetD3D11Texture();
+      if (!texture) {
+        NS_WARNING("No texture found in texture source!");
+      }
+
+      // Might want to cache these for efficiency.
+      RefPtr<ID3D11ShaderResourceView> srViewY;
+      RefPtr<ID3D11ShaderResourceView> srViewCbCr;
+      D3D11_SHADER_RESOURCE_VIEW_DESC srvDesc =
+        CD3D11_SHADER_RESOURCE_VIEW_DESC(D3D11_SRV_DIMENSION_TEXTURE2D,
+                                         DXGI_FORMAT_R8_UNORM);
+      mDevice->CreateShaderResourceView(texture,
+                                        &srvDesc,
+                                        getter_AddRefs(srViewY));
+      srvDesc.Format = DXGI_FORMAT_R8G8_UNORM;
+      mDevice->CreateShaderResourceView(texture,
+                                        &srvDesc,
+                                        getter_AddRefs(srViewCbCr));
+
+      ID3D11ShaderResourceView* views[] = { srViewY, srViewCbCr };
+      mContext->PSSetShaderResources(TexSlot::Y, 2, views);
+
+      const float* yuvToRgb = gfxUtils::YuvToRgbMatrix4x3RowMajor(YUVColorSpace::BT601);
+      memcpy(&mPSConstants.yuvColorMatrix, yuvToRgb, sizeof(mPSConstants.yuvColorMatrix));
+
+      SetSamplerForSamplingFilter(texturedEffect->mSamplingFilter);
+    }
+    break;
   case EffectTypes::YCBCR: {
       EffectYCbCr* ycbcrEffect =
         static_cast<EffectYCbCr*>(aEffectChain.mPrimaryEffect.get());
 
       SetSamplerForSamplingFilter(SamplingFilter::LINEAR);
 
       pTexCoordRect = &ycbcrEffect->mTextureCoords;
 
@@ -1631,16 +1676,18 @@ DeviceAttachmentsD3D11::CreateShaders()
   InitPixelShader(sSolidColorShader, mSolidColorShader, MaskType::MaskNone);
   InitPixelShader(sSolidColorShaderMask, mSolidColorShader, MaskType::Mask);
   InitPixelShader(sRGBShader, mRGBShader, MaskType::MaskNone);
   InitPixelShader(sRGBShaderMask, mRGBShader, MaskType::Mask);
   InitPixelShader(sRGBAShader, mRGBAShader, MaskType::MaskNone);
   InitPixelShader(sRGBAShaderMask, mRGBAShader, MaskType::Mask);
   InitPixelShader(sYCbCrShader, mYCbCrShader, MaskType::MaskNone);
   InitPixelShader(sYCbCrShaderMask, mYCbCrShader, MaskType::Mask);
+  InitPixelShader(sNV12Shader, mNV12Shader, MaskType::MaskNone);
+  InitPixelShader(sNV12ShaderMask, mNV12Shader, MaskType::Mask);
   if (gfxPrefs::ComponentAlphaEnabled()) {
     InitPixelShader(sComponentAlphaShader, mComponentAlphaShader, MaskType::MaskNone);
     InitPixelShader(sComponentAlphaShaderMask, mComponentAlphaShader, MaskType::Mask);
   }
 
   return mInitOkay;
 }
 
--- a/gfx/layers/d3d11/CompositorD3D11.hlsl
+++ b/gfx/layers/d3d11/CompositorD3D11.hlsl
@@ -250,24 +250,47 @@ float4 CalculateYCbCrColor(const float2 
   yuv.z = tCr.Sample(sSampler, aTexCoords).r - 0.50196;
 
   color.rgb = mul(mYuvColorMatrix, yuv);
   color.a = 1.0f;
 
   return color;
 }
 
+float4 CalculateNV12Color(const float2 aTexCoords)
+{
+  float3 yuv;
+  float4 color;
+
+  yuv.x = tY.Sample(sSampler, aTexCoords).r  - 0.06275;
+  yuv.y = tCb.Sample(sSampler, aTexCoords).r - 0.50196;
+  yuv.z = tCb.Sample(sSampler, aTexCoords).g - 0.50196;
+
+  color.rgb = mul(mYuvColorMatrix, yuv);
+  color.a = 1.0f;
+
+  return color;
+}
+
 float4 YCbCrShaderMask(const VS_MASK_OUTPUT aVertex) : SV_Target
 {
   float2 maskCoords = aVertex.vMaskCoords.xy / aVertex.vMaskCoords.z;
   float mask = tMask.Sample(sSampler, maskCoords).r;
 
   return CalculateYCbCrColor(aVertex.vTexCoords) * fLayerOpacity * mask;
 }
 
+float4 NV12ShaderMask(const VS_MASK_OUTPUT aVertex) : SV_Target
+{
+  float2 maskCoords = aVertex.vMaskCoords.xy / aVertex.vMaskCoords.z;
+  float mask = tMask.Sample(sSampler, maskCoords).r;
+
+  return CalculateNV12Color(aVertex.vTexCoords) * fLayerOpacity * mask;
+}
+
 PS_OUTPUT ComponentAlphaShaderMask(const VS_MASK_OUTPUT aVertex) : SV_Target
 {
   PS_OUTPUT result;
 
   result.vSrc = tRGB.Sample(sSampler, aVertex.vTexCoords);
   result.vAlpha = 1.0 - tRGBWhite.Sample(sSampler, aVertex.vTexCoords) + result.vSrc;
   result.vSrc.a = result.vAlpha.g;
 
@@ -303,16 +326,21 @@ float4 RGBShader(const VS_OUTPUT aVertex
   return result;
 }
 
 float4 YCbCrShader(const VS_OUTPUT aVertex) : SV_Target
 {
   return CalculateYCbCrColor(aVertex.vTexCoords) * fLayerOpacity;
 }
 
+float4 NV12Shader(const VS_OUTPUT aVertex) : SV_Target
+{
+  return CalculateNV12Color(aVertex.vTexCoords) * fLayerOpacity;
+}
+
 PS_OUTPUT ComponentAlphaShader(const VS_OUTPUT aVertex) : SV_Target
 {
   PS_OUTPUT result;
 
   result.vSrc = tRGB.Sample(sSampler, aVertex.vTexCoords);
   result.vAlpha = 1.0 - tRGBWhite.Sample(sSampler, aVertex.vTexCoords) + result.vSrc;
   result.vSrc.a = result.vAlpha.g;
   result.vSrc *= fLayerOpacity;
@@ -385,30 +413,34 @@ float4 ComputeBlendSourceColor(const VS_
     tmp.vPosition = aVertex.vPosition;
     tmp.vTexCoords = aVertex.vTexCoords;
     if (iBlendConfig.x == PS_LAYER_RGB) {
       return RGBShader(tmp);
     } else if (iBlendConfig.x == PS_LAYER_RGBA) {
       return RGBAShader(tmp);
     } else if (iBlendConfig.x == PS_LAYER_YCBCR) {
       return YCbCrShader(tmp);
+    } else if (iBlendConfig.x == PS_LAYER_NV12) {
+      return NV12Shader(tmp);
     }
     return SolidColorShader(tmp);
   } else if (iBlendConfig.y == PS_MASK) {
     VS_MASK_OUTPUT tmp;
     tmp.vPosition = aVertex.vPosition;
     tmp.vTexCoords = aVertex.vTexCoords;
     tmp.vMaskCoords = aVertex.vMaskCoords;
 
     if (iBlendConfig.x == PS_LAYER_RGB) {
       return RGBShaderMask(tmp);
     } else if (iBlendConfig.x == PS_LAYER_RGBA) {
       return RGBAShaderMask(tmp);
     } else if (iBlendConfig.x == PS_LAYER_YCBCR) {
       return YCbCrShaderMask(tmp);
+    } else if (iBlendConfig.x == PS_LAYER_NV12) {
+      return NV12ShaderMask(tmp);
     }
     return SolidColorShaderMask(tmp);
   }
 
   return float4(0.0, 0.0, 0.0, 1.0);
 }
 
 float3 ChooseBlendFunc(float3 dest, float3 src)
--- a/gfx/layers/d3d11/CompositorD3D11Shaders.h
+++ b/gfx/layers/d3d11/CompositorD3D11Shaders.h
@@ -1,12 +1,12 @@
 struct ShaderBytes { const void* mData; size_t mLength; };
 #if 0
 //
-// Generated by Microsoft (R) HLSL Shader Compiler 10.1
+// Generated by Microsoft (R) HLSL Shader Compiler 6.3.9600.16384
 //
 //
 // Buffer Definitions: 
 //
 // cbuffer $Globals
 // {
 //
 //   float4x4 mLayerTransform;          // Offset:    0 Size:    64
@@ -21,19 +21,19 @@ struct ShaderBytes { const void* mData; 
 //   uint4 iBlendConfig;                // Offset:  288 Size:    16 [unused]
 //   row_major float3x3 mYuvColorMatrix;// Offset:  304 Size:    44 [unused]
 //
 // }
 //
 //
 // Resource Bindings:
 //
-// Name                                 Type  Format         Dim      HLSL Bind  Count
-// ------------------------------ ---------- ------- ----------- -------------- ------
-// $Globals                          cbuffer      NA          NA            cb0      1 
+// Name                                 Type  Format         Dim Slot Elements
+// ------------------------------ ---------- ------- ----------- ---- --------
+// $Globals                          cbuffer      NA          NA    0        1
 //
 //
 //
 // Input signature:
 //
 // Name                 Index   Mask Register SysValue  Format   Used
 // -------------------- ----- ------ -------- -------- ------- ------
 // POSITION                 0   xy          0     NONE   float   xy  
@@ -79,17 +79,17 @@ struct ShaderBytes { const void* mData; 
     mad r1, c4, r0.x, r1
     mad r1, c6, r0.z, r1
     mad r0, c7, r0.w, r1
     mad oPos.xy, r0.w, c0, r0
     mov oPos.zw, r0
 
 // approximately 15 instruction slots used
 vs_4_0
-dcl_constantbuffer CB0[11], immediateIndexed
+dcl_constantbuffer cb0[11], immediateIndexed
 dcl_input v0.xy
 dcl_output_siv o0.xyzw, position
 dcl_output o1.xy
 dcl_temps 2
 mad r0.xy, v0.xyxx, cb0[10].zwzz, cb0[10].xyxx
 mul r1.xyzw, r0.yyyy, cb0[1].xyzw
 mad r0.xyzw, cb0[0].xyzw, r0.xxxx, r1.xyzw
 add r0.xyzw, r0.xyzw, cb0[3].xyzw
@@ -102,25 +102,25 @@ mad r1.xyzw, cb0[6].xyzw, r0.zzzz, r1.xy
 mad o0.xyzw, cb0[7].xyzw, r0.wwww, r1.xyzw
 mad o1.xy, v0.xyxx, cb0[9].zwzz, cb0[9].xyxx
 ret 
 // Approximately 13 instruction slots used
 #endif
 
 const BYTE LayerQuadVS[] =
 {
-     68,  88,  66,  67, 250,  65, 
-     94, 205, 254, 155,  52,  90, 
-     43, 147, 203, 201, 141,  74, 
-     80, 143,   1,   0,   0,   0, 
-     68,   7,   0,   0,   6,   0, 
+     68,  88,  66,  67, 169, 137, 
+    186,  74,  85, 148,   0, 249, 
+    101, 235, 214,  10,  35,  11, 
+    230, 137,   1,   0,   0,   0, 
+     80,   7,   0,   0,   6,   0, 
       0,   0,  56,   0,   0,   0, 
     152,   1,   0,   0, 160,   3, 
       0,   0,  28,   4,   0,   0, 
-    184,   6,   0,   0, 236,   6, 
+    196,   6,   0,   0, 248,   6, 
       0,   0,  65, 111, 110,  57, 
      88,   1,   0,   0,  88,   1, 
       0,   0,   0,   2, 254, 255, 
      24,   1,   0,   0,  64,   0, 
       0,   0,   2,   0,  36,   0, 
       0,   0,  60,   0,   0,   0, 
      60,   0,   0,   0,  36,   0, 
       1,   0,  60,   0,   0,   0, 
@@ -278,17 +278,17 @@ const BYTE LayerQuadVS[] =
       0,   0,   0,   0,   0,   0, 
       0,   0,   0,   0,   0,   0, 
       0,   0,   0,   0,   0,   0, 
       0,   0,   0,   0,   0,   0, 
       0,   0,   0,   0,   0,   0, 
       0,   0,   0,   0,   0,   0, 
       0,   0,   0,   0,   0,   0, 
       0,   0,  82,  68,  69,  70, 
-    148,   2,   0,   0,   1,   0, 
+    160,   2,   0,   0,   1,   0, 
       0,   0,  72,   0,   0,   0, 
       1,   0,   0,   0,  28,   0, 
       0,   0,   0,   4, 254, 255, 
       0,   1,   0,   0, 108,   2, 
       0,   0,  60,   0,   0,   0, 
       0,   0,   0,   0,   0,   0, 
       0,   0,   0,   0,   0,   0, 
       0,   0,   0,   0,   0,   0, 
@@ -387,18 +387,20 @@ const BYTE LayerQuadVS[] =
     120,   0,   2,   0,   3,   0, 
       3,   0,   3,   0,   0,   0, 
       0,   0,   0,   0,   0,   0, 
      77, 105,  99, 114, 111, 115, 
     111, 102, 116,  32,  40,  82, 
      41,  32,  72,  76,  83,  76, 
      32,  83, 104,  97, 100, 101, 
     114,  32,  67, 111, 109, 112, 
-    105, 108, 101, 114,  32,  49, 
-     48,  46,  49,   0,  73,  83, 
+    105, 108, 101, 114,  32,  54, 
+     46,  51,  46,  57,  54,  48, 
+     48,  46,  49,  54,  51,  56, 
+     52,   0, 171, 171,  73,  83, 
      71,  78,  44,   0,   0,   0, 
       1,   0,   0,   0,   8,   0, 
       0,   0,  32,   0,   0,   0, 
       0,   0,   0,   0,   0,   0, 
       0,   0,   3,   0,   0,   0, 
       0,   0,   0,   0,   3,   3, 
       0,   0,  80,  79,  83,  73, 
      84,  73,  79,  78,   0, 171, 
@@ -416,17 +418,17 @@ const BYTE LayerQuadVS[] =
      83,  86,  95,  80, 111, 115, 
     105, 116, 105, 111, 110,   0, 
      84,  69,  88,  67,  79,  79, 
      82,  68,   0, 171, 171, 171
 };
 ShaderBytes sLayerQuadVS = { LayerQuadVS, sizeof(LayerQuadVS) };
 #if 0
 //
-// Generated by Microsoft (R) HLSL Shader Compiler 10.1
+// Generated by Microsoft (R) HLSL Shader Compiler 6.3.9600.16384
 //
 //
 // Buffer Definitions: 
 //
 // cbuffer $Globals
 // {
 //
 //   float4x4 mLayerTransform;          // Offset:    0 Size:    64
@@ -856,19 +858,19 @@ ShaderBytes sLayerDynamicVS = { LayerDyn
 //   float4 vMaskQuad;                  // Offset:  272 Size:    16 [unused]
 //   float4x4 mBackdropTransform;       // Offset:  288 Size:    64 [unused]
 //
 // }
 //
 //
 // Resource Bindings:
 //
-// Name                                 Type  Format         Dim      HLSL Bind  Count
-// ------------------------------ ---------- ------- ----------- -------------- ------
-// $Globals                          cbuffer      NA          NA            cb0      1 
+// Name                                 Type  Format         Dim Slot Elements
+// ------------------------------ ---------- ------- ----------- ---- --------
+// $Globals                          cbuffer      NA          NA    0        1
 //
 //
 //
 // Input signature:
 //
 // Name                 Index   Mask Register SysValue  Format   Used
 // -------------------- ----- ------ -------- -------- ------- ------
 // SV_Position              0   xyzw        0      POS   float       
@@ -891,34 +893,34 @@ ShaderBytes sLayerDynamicVS = { LayerDyn
 //
 // Level9 shader bytecode:
 //
     ps_2_x
     mov oC0, c0
 
 // approximately 1 instruction slot used
 ps_4_0
-dcl_constantbuffer CB0[1], immediateIndexed
+dcl_constantbuffer cb0[1], immediateIndexed
 dcl_output o0.xyzw
 mov o0.xyzw, cb0[0].xyzw
 ret 
 // Approximately 2 instruction slots used
 #endif
 
 const BYTE SolidColorShader[] =
 {
-     68,  88,  66,  67, 181,   3, 
-     20,   0, 202,  78, 164,  59, 
-    210, 171, 118, 253, 118, 104, 
-    133, 184,   1,   0,   0,   0, 
-    112,   4,   0,   0,   6,   0, 
+     68,  88,  66,  67, 156,  36, 
+     85, 115, 249,   2,  97, 236, 
+    182, 204,  98, 136, 164, 213, 
+    133, 234,   1,   0,   0,   0, 
+    124,   4,   0,   0,   6,   0, 
       0,   0,  56,   0,   0,   0, 
     132,   0,   0,   0, 204,   0, 
       0,   0,  72,   1,   0,   0, 
-    228,   3,   0,   0,  60,   4, 
+    240,   3,   0,   0,  72,   4, 
       0,   0,  65, 111, 110,  57, 
      68,   0,   0,   0,  68,   0, 
       0,   0,   0,   2, 255, 255, 
      20,   0,   0,   0,  48,   0, 
       0,   0,   1,   0,  36,   0, 
       0,   0,  48,   0,   0,   0, 
      48,   0,   0,   0,  36,   0, 
       0,   0,  48,   0,   0,   0, 
@@ -955,17 +957,17 @@ const BYTE SolidColorShader[] =
       0,   0,   0,   0,   0,   0, 
       1,   0,   0,   0,   0,   0, 
       0,   0,   0,   0,   0,   0, 
       0,   0,   0,   0,   0,   0, 
       0,   0,   0,   0,   0,   0, 
       0,   0,   0,   0,   0,   0, 
       0,   0,   0,   0,   0,   0, 
       0,   0,   0,   0,  82,  68, 
-     69,  70, 148,   2,   0,   0, 
+     69,  70, 160,   2,   0,   0, 
       1,   0,   0,   0,  72,   0, 
       0,   0,   1,   0,   0,   0, 
      28,   0,   0,   0,   0,   4, 
     255, 255,   0,   1,   0,   0, 
     108,   2,   0,   0,  60,   0, 
       0,   0,   0,   0,   0,   0, 
       0,   0,   0,   0,   0,   0, 
       0,   0,   0,   0,   0,   0, 
@@ -1065,17 +1067,19 @@ const BYTE SolidColorShader[] =
     100, 114, 111, 112,  84, 114, 
      97, 110, 115, 102, 111, 114, 
     109,   0,  77, 105,  99, 114, 
     111, 115, 111, 102, 116,  32, 
      40,  82,  41,  32,  72,  76, 
      83,  76,  32,  83, 104,  97, 
     100, 101, 114,  32,  67, 111, 
     109, 112, 105, 108, 101, 114, 
-     32,  49,  48,  46,  49,   0, 
+     32,  54,  46,  51,  46,  57, 
+     54,  48,  48,  46,  49,  54, 
+     51,  56,  52,   0, 171, 171, 
      73,  83,  71,  78,  80,   0, 
       0,   0,   2,   0,   0,   0, 
       8,   0,   0,   0,  56,   0, 
       0,   0,   0,   0,   0,   0, 
       1,   0,   0,   0,   3,   0, 
       0,   0,   0,   0,   0,   0, 
      15,   0,   0,   0,  68,   0, 
       0,   0,   0,   0,   0,   0, 
@@ -1094,17 +1098,17 @@ const BYTE SolidColorShader[] =
       0,   0,   0,   0,  15,   0, 
       0,   0,  83,  86,  95,  84, 
      97, 114, 103, 101, 116,   0, 
     171, 171
 };
 ShaderBytes sSolidColorShader = { SolidColorShader, sizeof(SolidColorShader) };
 #if 0
 //
-// Generated by Microsoft (R) HLSL Shader Compiler 10.1
+// Generated by Microsoft (R) HLSL Shader Compiler 6.3.9600.16384
 //
 //
 // Buffer Definitions: 
 //
 // cbuffer $Globals
 // {
 //
 //   float4 fLayerColor;                // Offset:    0 Size:    16 [unused]
@@ -1119,21 +1123,21 @@ ShaderBytes sSolidColorShader = { SolidC
 //   float4 vMaskQuad;                  // Offset:  272 Size:    16 [unused]
 //   float4x4 mBackdropTransform;       // Offset:  288 Size:    64 [unused]
 //
 // }
 //
 //
 // Resource Bindings:
 //
-// Name                                 Type  Format         Dim      HLSL Bind  Count
-// ------------------------------ ---------- ------- ----------- -------------- ------
-// sSampler                          sampler      NA          NA             s0      1 
-// tRGB                              texture  float4          2d             t0      1 
-// $Globals                          cbuffer      NA          NA            cb0      1 
+// Name                                 Type  Format         Dim Slot Elements
+// ------------------------------ ---------- ------- ----------- ---- --------
+// sSampler                          sampler      NA          NA    0        1
+// tRGB                              texture  float4          2d    0        1
+// $Globals                          cbuffer      NA          NA    0        1
 //
 //
 //
 // Input signature:
 //
 // Name                 Index   Mask Register SysValue  Format   Used
 // -------------------- ----- ------ -------- -------- ------- ------
 // SV_Position              0   xyzw        0      POS   float       
@@ -1168,40 +1172,40 @@ ShaderBytes sSolidColorShader = { SolidC
     dcl_2d s0
     texld r0, t0, s0
     mul r0.xyz, r0, c0.x
     mov r0.w, c0.x
     mov oC0, r0
 
 // approximately 4 instruction slots used (1 texture, 3 arithmetic)
 ps_4_0
-dcl_constantbuffer CB0[2], immediateIndexed
+dcl_constantbuffer cb0[2], immediateIndexed
 dcl_sampler s0, mode_default
 dcl_resource_texture2d (float,float,float,float) t0
 dcl_input_ps linear v1.xy
 dcl_output o0.xyzw
 dcl_temps 1
 sample r0.xyzw, v1.xyxx, t0.xyzw, s0
 mul o0.xyz, r0.xyzx, cb0[1].xxxx
 mov o0.w, cb0[1].x
 ret 
 // Approximately 4 instruction slots used
 #endif
 
 const BYTE RGBShader[] =
 {
-     68,  88,  66,  67, 181,  57, 
-    113, 191, 104, 206, 206,  65, 
-    235, 158,  87, 241, 179, 224, 
-     69, 235,   1,   0,   0,   0, 
-    120,   5,   0,   0,   6,   0, 
+     68,  88,  66,  67, 160,  15, 
+    174, 178, 100, 241,  44,  13, 
+    161, 155, 205,  21,  72, 246, 
+    233,  55,   1,   0,   0,   0, 
+    132,   5,   0,   0,   6,   0, 
       0,   0,  56,   0,   0,   0, 
     204,   0,   0,   0, 136,   1, 
       0,   0,   4,   2,   0,   0, 
-    236,   4,   0,   0,  68,   5, 
+    248,   4,   0,   0,  80,   5, 
       0,   0,  65, 111, 110,  57, 
     140,   0,   0,   0, 140,   0, 
       0,   0,   0,   2, 255, 255, 
      88,   0,   0,   0,  52,   0, 
       0,   0,   1,   0,  40,   0, 
       0,   0,  52,   0,   0,   0, 
      52,   0,   1,   0,  36,   0, 
       0,   0,  52,   0,   0,   0, 
@@ -1269,17 +1273,17 @@ const BYTE RGBShader[] =
       0,   0,   0,   0,   0,   0, 
       0,   0,   1,   0,   0,   0, 
       0,   0,   0,   0,   0,   0, 
       0,   0,   0,   0,   0,   0, 
       0,   0,   0,   0,   0,   0, 
       0,   0,   0,   0,   0,   0, 
       0,   0,   0,   0,   0,   0, 
       0,   0,   0,   0,   0,   0, 
-     82,  68,  69,  70, 224,   2, 
+     82,  68,  69,  70, 236,   2, 
       0,   0,   1,   0,   0,   0, 
     148,   0,   0,   0,   3,   0, 
       0,   0,  28,   0,   0,   0, 
       0,   4, 255, 255,   0,   1, 
       0,   0, 184,   2,   0,   0, 
     124,   0,   0,   0,   3,   0, 
       0,   0,   0,   0,   0,   0, 
       0,   0,   0,   0,   0,   0, 
@@ -1392,17 +1396,19 @@ const BYTE RGBShader[] =
     100, 114, 111, 112,  84, 114, 
      97, 110, 115, 102, 111, 114, 
     109,   0,  77, 105,  99, 114, 
     111, 115, 111, 102, 116,  32, 
      40,  82,  41,  32,  72,  76, 
      83,  76,  32,  83, 104,  97, 
     100, 101, 114,  32,  67, 111, 
     109, 112, 105, 108, 101, 114, 
-     32,  49,  48,  46,  49,   0, 
+     32,  54,  46,  51,  46,  57, 
+     54,  48,  48,  46,  49,  54, 
+     51,  56,  52,   0, 171, 171, 
      73,  83,  71,  78,  80,   0, 
       0,   0,   2,   0,   0,   0, 
       8,   0,   0,   0,  56,   0, 
       0,   0,   0,   0,   0,   0, 
       1,   0,   0,   0,   3,   0, 
       0,   0,   0,   0,   0,   0, 
      15,   0,   0,   0,  68,   0, 
       0,   0,   0,   0,   0,   0, 
@@ -1421,17 +1427,17 @@ const BYTE RGBShader[] =
       0,   0,   0,   0,  15,   0, 
       0,   0,  83,  86,  95,  84, 
      97, 114, 103, 101, 116,   0, 
     171, 171
 };
 ShaderBytes sRGBShader = { RGBShader, sizeof(RGBShader) };
 #if 0
 //
-// Generated by Microsoft (R) HLSL Shader Compiler 10.1
+// Generated by Microsoft (R) HLSL Shader Compiler 6.3.9600.16384
 //
 //
 // Buffer Definitions: 
 //
 // cbuffer $Globals
 // {
 //
 //   float4 fLayerColor;                // Offset:    0 Size:    16 [unused]
@@ -1446,21 +1452,21 @@ ShaderBytes sRGBShader = { RGBShader, si
 //   float4 vMaskQuad;                  // Offset:  272 Size:    16 [unused]
 //   float4x4 mBackdropTransform;       // Offset:  288 Size:    64 [unused]
 //
 // }
 //
 //
 // Resource Bindings:
 //
-// Name                                 Type  Format         Dim      HLSL Bind  Count
-// ------------------------------ ---------- ------- ----------- -------------- ------
-// sSampler                          sampler      NA          NA             s0      1 
-// tRGB                              texture  float4          2d             t0      1 
-// $Globals                          cbuffer      NA          NA            cb0      1 
+// Name                                 Type  Format         Dim Slot Elements
+// ------------------------------ ---------- ------- ----------- ---- --------
+// sSampler                          sampler      NA          NA    0        1
+// tRGB                              texture  float4          2d    0        1
+// $Globals                          cbuffer      NA          NA    0        1
 //
 //
 //
 // Input signature:
 //
 // Name                 Index   Mask Register SysValue  Format   Used
 // -------------------- ----- ------ -------- -------- ------- ------
 // SV_Position              0   xyzw        0      POS   float       
@@ -1494,39 +1500,39 @@ ShaderBytes sRGBShader = { RGBShader, si
     dcl t0.xy
     dcl_2d s0
     texld r0, t0, s0
     mul r0, r0, c0.x
     mov oC0, r0
 
 // approximately 3 instruction slots used (1 texture, 2 arithmetic)
 ps_4_0
-dcl_constantbuffer CB0[2], immediateIndexed
+dcl_constantbuffer cb0[2], immediateIndexed
 dcl_sampler s0, mode_default
 dcl_resource_texture2d (float,float,float,float) t0
 dcl_input_ps linear v1.xy
 dcl_output o0.xyzw
 dcl_temps 1
 sample r0.xyzw, v1.xyxx, t0.xyzw, s0
 mul o0.xyzw, r0.xyzw, cb0[1].xxxx
 ret 
 // Approximately 3 instruction slots used
 #endif
 
 const BYTE RGBAShader[] =
 {
-     68,  88,  66,  67,   0,  64, 
-     93, 222,  73, 216, 128,  20, 
-     42,  69,  82, 179, 209, 122, 
-    136, 190,   1,   0,   0,   0, 
-     84,   5,   0,   0,   6,   0, 
+     68,  88,  66,  67, 115, 228, 
+    124, 193, 199, 195, 231, 151, 
+    155,  86, 202, 199, 245, 170, 
+     45, 241,   1,   0,   0,   0, 
+     96,   5,   0,   0,   6,   0, 
       0,   0,  56,   0,   0,   0, 
     192,   0,   0,   0, 100,   1, 
       0,   0, 224,   1,   0,   0, 
-    200,   4,   0,   0,  32,   5, 
+    212,   4,   0,   0,  44,   5, 
       0,   0,  65, 111, 110,  57, 
     128,   0,   0,   0, 128,   0, 
       0,   0,   0,   2, 255, 255, 
      76,   0,   0,   0,  52,   0, 
       0,   0,   1,   0,  40,   0, 
       0,   0,  52,   0,   0,   0, 
      52,   0,   1,   0,  36,   0, 
       0,   0,  52,   0,   0,   0, 
@@ -1588,17 +1594,17 @@ const BYTE RGBAShader[] =
       0,   0,   0,   0,   0,   0, 
       0,   0,   0,   0,   0,   0, 
       0,   0,   0,   0,   0,   0, 
       0,   0,   0,   0,   0,   0, 
       0,   0,   0,   0,   0,   0, 
       0,   0,   0,   0,   0,   0, 
       0,   0,   0,   0,   0,   0, 
       0,   0,   0,   0,   0,   0, 
-     82,  68,  69,  70, 224,   2, 
+     82,  68,  69,  70, 236,   2, 
       0,   0,   1,   0,   0,   0, 
     148,   0,   0,   0,   3,   0, 
       0,   0,  28,   0,   0,   0, 
       0,   4, 255, 255,   0,   1, 
       0,   0, 184,   2,   0,   0, 
     124,   0,   0,   0,   3,   0, 
       0,   0,   0,   0,   0,   0, 
       0,   0,   0,   0,   0,   0, 
@@ -1711,17 +1717,19 @@ const BYTE RGBAShader[] =
     100, 114, 111, 112,  84, 114, 
      97, 110, 115, 102, 111, 114, 
     109,   0,  77, 105,  99, 114, 
     111, 115, 111, 102, 116,  32, 
      40,  82,  41,  32,  72,  76, 
      83,  76,  32,  83, 104,  97, 
     100, 101, 114,  32,  67, 111, 
     109, 112, 105, 108, 101, 114, 
-     32,  49,  48,  46,  49,   0, 
+     32,  54,  46,  51,  46,  57, 
+     54,  48,  48,  46,  49,  54, 
+     51,  56,  52,   0, 171, 171, 
      73,  83,  71,  78,  80,   0, 
       0,   0,   2,   0,   0,   0, 
       8,   0,   0,   0,  56,   0, 
       0,   0,   0,   0,   0,   0, 
       1,   0,   0,   0,   3,   0, 
       0,   0,   0,   0,   0,   0, 
      15,   0,   0,   0,  68,   0, 
       0,   0,   0,   0,   0,   0, 
@@ -1740,17 +1748,17 @@ const BYTE RGBAShader[] =
       0,   0,   0,   0,  15,   0, 
       0,   0,  83,  86,  95,  84, 
      97, 114, 103, 101, 116,   0, 
     171, 171
 };
 ShaderBytes sRGBAShader = { RGBAShader, sizeof(RGBAShader) };
 #if 0
 //
-// Generated by Microsoft (R) HLSL Shader Compiler 10.1
+// Generated by Microsoft (R) HLSL Shader Compiler 6.3.9600.16384
 //
 //
 // Buffer Definitions: 
 //
 // cbuffer $Globals
 // {
 //
 //   float4 fLayerColor;                // Offset:    0 Size:    16 [unused]
@@ -1765,22 +1773,22 @@ ShaderBytes sRGBAShader = { RGBAShader, 
 //   float4 vMaskQuad;                  // Offset:  272 Size:    16 [unused]
 //   float4x4 mBackdropTransform;       // Offset:  288 Size:    64 [unused]
 //
 // }
 //
 //
 // Resource Bindings:
 //
-// Name                                 Type  Format         Dim      HLSL Bind  Count
-// ------------------------------ ---------- ------- ----------- -------------- ------
-// sSampler                          sampler      NA          NA             s0      1 
-// tRGB                              texture  float4          2d             t0      1 
-// tRGBWhite                         texture  float4          2d             t4      1 
-// $Globals                          cbuffer      NA          NA            cb0      1 
+// Name                                 Type  Format         Dim Slot Elements
+// ------------------------------ ---------- ------- ----------- ---- --------
+// sSampler                          sampler      NA          NA    0        1
+// tRGB                              texture  float4          2d    0        1
+// tRGBWhite                         texture  float4          2d    4        1
+// $Globals                          cbuffer      NA          NA    0        1
 //
 //
 //
 // Input signature:
 //
 // Name                 Index   Mask Register SysValue  Format   Used
 // -------------------- ----- ------ -------- -------- ------- ------
 // SV_Position              0   xyzw        0      POS   float       
@@ -1824,17 +1832,17 @@ ShaderBytes sRGBAShader = { RGBAShader, 
     mov r0.w, r1.y
     mul r1, r1, c0.x
     mov oC1, r1
     mul r0, r0, c0.x
     mov oC0, r0
 
 // approximately 9 instruction slots used (2 texture, 7 arithmetic)
 ps_4_0
-dcl_constantbuffer CB0[2], immediateIndexed
+dcl_constantbuffer cb0[2], immediateIndexed
 dcl_sampler s0, mode_default
 dcl_resource_texture2d (float,float,float,float) t0
 dcl_resource_texture2d (float,float,float,float) t4
 dcl_input_ps linear v1.xy
 dcl_output o0.xyzw
 dcl_output o1.xyzw
 dcl_temps 2
 sample r0.xyzw, v1.xyxx, t4.xyzw, s0
@@ -1845,25 +1853,25 @@ mov r1.w, r0.y
 mul o1.xyzw, r0.xyzw, cb0[1].xxxx
 mul o0.xyzw, r1.xyzw, cb0[1].xxxx
 ret 
 // Approximately 8 instruction slots used
 #endif
 
 const BYTE ComponentAlphaShader[] =
 {
-     68,  88,  66,  67, 168, 127, 
-    203,  56, 125, 182, 211,  23, 
-    166, 215, 189, 218, 181,  48, 
-    227,  73,   1,   0,   0,   0, 
-    212,   6,   0,   0,   6,   0, 
+     68,  88,  66,  67,  21, 227, 
+    149,  86, 182, 246,  85,  57, 
+    167,  85, 241,  51, 157,  75, 
+     49, 112,   1,   0,   0,   0, 
+    224,   6,   0,   0,   6,   0, 
       0,   0,  56,   0,   0,   0, 
      64,   1,   0,   0, 160,   2, 
       0,   0,  28,   3,   0,   0, 
-     48,   6,   0,   0, 136,   6, 
+     60,   6,   0,   0, 148,   6, 
       0,   0,  65, 111, 110,  57, 
       0,   1,   0,   0,   0,   1, 
       0,   0,   0,   2, 255, 255, 
     200,   0,   0,   0,  56,   0, 
       0,   0,   1,   0,  44,   0, 
       0,   0,  56,   0,   0,   0, 
      56,   0,   2,   0,  36,   0, 
       0,   0,  56,   0,   0,   0, 
@@ -1978,17 +1986,17 @@ const BYTE ComponentAlphaShader[] =
       0,   0,   0,   0,   0,   0, 
       1,   0,   0,   0,   0,   0, 
       0,   0,   0,   0,   0,   0, 
       0,   0,   0,   0,   0,   0, 
       0,   0,   0,   0,   0,   0, 
       0,   0,   0,   0,   0,   0, 
       0,   0,   0,   0,   0,   0, 
       0,   0,   0,   0,  82,  68, 
-     69,  70,  12,   3,   0,   0, 
+     69,  70,  24,   3,   0,   0, 
       1,   0,   0,   0, 192,   0, 
       0,   0,   4,   0,   0,   0, 
      28,   0,   0,   0,   0,   4, 
     255, 255,   0,   1,   0,   0, 
     228,   2,   0,   0, 156,   0, 
       0,   0,   3,   0,   0,   0, 
       0,   0,   0,   0,   0,   0, 
       0,   0,   0,   0,   0,   0, 
@@ -2108,17 +2116,19 @@ const BYTE ComponentAlphaShader[] =
     100, 114, 111, 112,  84, 114, 
      97, 110, 115, 102, 111, 114, 
     109,   0,  77, 105,  99, 114, 
     111, 115, 111, 102, 116,  32, 
      40,  82,  41,  32,  72,  76, 
      83,  76,  32,  83, 104,  97, 
     100, 101, 114,  32,  67, 111, 
     109, 112, 105, 108, 101, 114, 
-     32,  49,  48,  46,  49,   0, 
+     32,  54,  46,  51,  46,  57, 
+     54,  48,  48,  46,  49,  54, 
+     51,  56,  52,   0, 171, 171, 
      73,  83,  71,  78,  80,   0, 
       0,   0,   2,   0,   0,   0, 
       8,   0,   0,   0,  56,   0, 
       0,   0,   0,   0,   0,   0, 
       1,   0,   0,   0,   3,   0, 
       0,   0,   0,   0,   0,   0, 
      15,   0,   0,   0,  68,   0, 
       0,   0,   0,   0,   0,   0, 
@@ -2141,17 +2151,17 @@ const BYTE ComponentAlphaShader[] =
       1,   0,   0,   0,  15,   0, 
       0,   0,  83,  86,  95,  84, 
      97, 114, 103, 101, 116,   0, 
     171, 171
 };
 ShaderBytes sComponentAlphaShader = { ComponentAlphaShader, sizeof(ComponentAlphaShader) };
 #if 0
 //
-// Generated by Microsoft (R) HLSL Shader Compiler 10.1
+// Generated by Microsoft (R) HLSL Shader Compiler 6.3.9600.16384
 //
 //
 // Buffer Definitions: 
 //
 // cbuffer $Globals
 // {
 //
 //   float4 fLayerColor;                // Offset:    0 Size:    16 [unused]
@@ -2166,23 +2176,23 @@ ShaderBytes sComponentAlphaShader = { Co
 //   float4 vMaskQuad;                  // Offset:  272 Size:    16 [unused]
 //   float4x4 mBackdropTransform;       // Offset:  288 Size:    64 [unused]
 //
 // }
 //
 //
 // Resource Bindings:
 //
-// Name                                 Type  Format         Dim      HLSL Bind  Count
-// ------------------------------ ---------- ------- ----------- -------------- ------
-// sSampler                          sampler      NA          NA             s0      1 
-// tY                                texture  float4          2d             t1      1 
-// tCb                               texture  float4          2d             t2      1 
-// tCr                               texture  float4          2d             t3      1 
-// $Globals                          cbuffer      NA          NA            cb0      1 
+// Name                                 Type  Format         Dim Slot Elements
+// ------------------------------ ---------- ------- ----------- ---- --------
+// sSampler                          sampler      NA          NA    0        1
+// tY                                texture  float4          2d    1        1
+// tCb                               texture  float4          2d    2        1
+// tCr                               texture  float4          2d    3        1
+// $Globals                          cbuffer      NA          NA    0        1
 //
 //
 //
 // Input signature:
 //
 // Name                 Index   Mask Register SysValue  Format   Used
 // -------------------- ----- ------ -------- -------- ------- ------
 // SV_Position              0   xyzw        0      POS   float       
@@ -2231,17 +2241,17 @@ ShaderBytes sComponentAlphaShader = { Co
     dp3 r0.x, c1, r2
     dp3 r0.y, c2, r2
     dp3 r0.z, c3, r2
     mul r0, r0, c0.x
     mov oC0, r0
 
 // approximately 12 instruction slots used (3 texture, 9 arithmetic)
 ps_4_0
-dcl_constantbuffer CB0[6], immediateIndexed
+dcl_constantbuffer cb0[6], immediateIndexed
 dcl_sampler s0, mode_default
 dcl_resource_texture2d (float,float,float,float) t1
 dcl_resource_texture2d (float,float,float,float) t2
 dcl_resource_texture2d (float,float,float,float) t3
 dcl_input_ps linear v1.xy
 dcl_output o0.xyzw
 dcl_temps 3
 mov r0.w, l(1.000000)
@@ -2256,25 +2266,25 @@ dp3 r0.y, cb0[4].xyzx, r1.xyzx
 dp3 r0.z, cb0[5].xyzx, r1.xyzx
 mul o0.xyzw, r0.xyzw, cb0[1].xxxx
 ret 
 // Approximately 12 instruction slots used
 #endif
 
 const BYTE YCbCrShader[] =
 {
-     68,  88,  66,  67,  56, 199, 
-     91,   5, 215, 233, 204,  14, 
-    193, 166, 163,  11, 246, 123, 
-    165,  88,   1,   0,   0,   0, 
-    156,   7,   0,   0,   6,   0, 
+     68,  88,  66,  67, 239,  64, 
+    176,  25, 191, 201, 146,  39, 
+    143, 201,  64,  49, 208, 121, 
+    166,  95,   1,   0,   0,   0, 
+    168,   7,   0,   0,   6,   0, 
       0,   0,  56,   0,   0,   0, 
     144,   1,   0,   0, 100,   3, 
       0,   0, 224,   3,   0,   0, 
-     16,   7,   0,   0, 104,   7, 
+     28,   7,   0,   0, 116,   7, 
       0,   0,  65, 111, 110,  57, 
      80,   1,   0,   0,  80,   1, 
       0,   0,   0,   2, 255, 255, 
       8,   1,   0,   0,  72,   0, 
       0,   0,   2,   0,  48,   0, 
       0,   0,  72,   0,   0,   0, 
      72,   0,   3,   0,  36,   0, 
       0,   0,  72,   0,   1,   0, 
@@ -2422,17 +2432,17 @@ const BYTE YCbCrShader[] =
       0,   0,   0,   0,   1,   0, 
       0,   0,   0,   0,   0,   0, 
       0,   0,   0,   0,   0,   0, 
       0,   0,   0,   0,   0,   0, 
       0,   0,   0,   0,   0,   0, 
       0,   0,   0,   0,   0,   0, 
       0,   0,   0,   0,   0,   0, 
       0,   0,  82,  68,  69,  70, 
-     40,   3,   0,   0,   1,   0, 
+     52,   3,   0,   0,   1,   0, 
       0,   0, 220,   0,   0,   0, 
       5,   0,   0,   0,  28,   0, 
       0,   0,   0,   4, 255, 255, 
       0,   1,   0,   0,   0,   3, 
       0,   0, 188,   0,   0,   0, 
       3,   0,   0,   0,   0,   0, 
       0,   0,   0,   0,   0,   0, 
       0,   0,   0,   0,   0,   0, 
@@ -2556,18 +2566,20 @@ const BYTE YCbCrShader[] =
      99, 107, 100, 114, 111, 112, 
      84, 114,  97, 110, 115, 102, 
     111, 114, 109,   0,  77, 105, 
      99, 114, 111, 115, 111, 102, 
     116,  32,  40,  82,  41,  32, 
      72,  76,  83,  76,  32,  83, 
     104,  97, 100, 101, 114,  32, 
      67, 111, 109, 112, 105, 108, 
-    101, 114,  32,  49,  48,  46, 
-     49,   0,  73,  83,  71,  78, 
+    101, 114,  32,  54,  46,  51, 
+     46,  57,  54,  48,  48,  46, 
+     49,  54,  51,  56,  52,   0, 
+    171, 171,  73,  83,  71,  78, 
      80,   0,   0,   0,   2,   0, 
       0,   0,   8,   0,   0,   0, 
      56,   0,   0,   0,   0,   0, 
       0,   0,   1,   0,   0,   0, 
       3,   0,   0,   0,   0,   0, 
       0,   0,  15,   0,   0,   0, 
      68,   0,   0,   0,   0,   0, 
       0,   0,   0,   0,   0,   0, 
@@ -2585,17 +2597,430 @@ const BYTE YCbCrShader[] =
       0,   0,   0,   0,   0,   0, 
      15,   0,   0,   0,  83,  86, 
      95,  84,  97, 114, 103, 101, 
     116,   0, 171, 171
 };
 ShaderBytes sYCbCrShader = { YCbCrShader, sizeof(YCbCrShader) };
 #if 0
 //
-// Generated by Microsoft (R) HLSL Shader Compiler 10.1
+// Generated by Microsoft (R) HLSL Shader Compiler 6.3.9600.16384
+//
+//
+// Buffer Definitions: 
+//
+// cbuffer $Globals
+// {
+//
+//   float4 fLayerColor;                // Offset:    0 Size:    16 [unused]
+//   float fLayerOpacity;               // Offset:   16 Size:     4
+//   uint4 iBlendConfig;                // Offset:   32 Size:    16 [unused]
+//   row_major float3x3 mYuvColorMatrix;// Offset:   48 Size:    44
+//   float4x4 mLayerTransform;          // Offset:   96 Size:    64 [unused]
+//   float4x4 mProjection;              // Offset:  160 Size:    64 [unused]
+//   float4 vRenderTargetOffset;        // Offset:  224 Size:    16 [unused]
+//   float4 vTextureCoords;             // Offset:  240 Size:    16 [unused]
+//   float4 vLayerQuad;                 // Offset:  256 Size:    16 [unused]
+//   float4 vMaskQuad;                  // Offset:  272 Size:    16 [unused]
+//   float4x4 mBackdropTransform;       // Offset:  288 Size:    64 [unused]
+//
+// }
+//
+//
+// Resource Bindings:
+//
+// Name                                 Type  Format         Dim Slot Elements
+// ------------------------------ ---------- ------- ----------- ---- --------
+// sSampler                          sampler      NA          NA    0        1
+// tY                                texture  float4          2d    1        1
+// tCb                               texture  float4          2d    2        1
+// $Globals                          cbuffer      NA          NA    0        1
+//
+//
+//
+// Input signature:
+//
+// Name                 Index   Mask Register SysValue  Format   Used
+// -------------------- ----- ------ -------- -------- ------- ------
+// SV_Position              0   xyzw        0      POS   float       
+// TEXCOORD                 0   xy          1     NONE   float   xy  
+//
+//
+// Output signature:
+//
+// Name                 Index   Mask Register SysValue  Format   Used
+// -------------------- ----- ------ -------- -------- ------- ------
+// SV_Target                0   xyzw        0   TARGET   float   xyzw
+//
+//
+// Constant buffer to DX9 shader constant mappings:
+//
+// Target Reg Buffer  Start Reg # of Regs        Data Conversion
+// ---------- ------- --------- --------- ----------------------
+// c0         cb0             1         1  ( FLT, FLT, FLT, FLT)
+// c1         cb0             3         3  ( FLT, FLT, FLT, FLT)
+//
+//
+// Sampler/Resource to DX9 shader sampler mappings:
+//
+// Target Sampler Source Sampler  Source Resource
+// -------------- --------------- ----------------
+// s0             s0              t1               
+// s1             s0              t2               
+//
+//
+// Level9 shader bytecode:
+//
+    ps_2_x
+    def c4, -0.0627499968, -0.50195998, 1, 0
+    dcl t0.xy
+    dcl_2d s0
+    dcl_2d s1
+    mov r0.w, c4.z
+    texld r1, t0, s1
+    texld r2, t0, s0
+    add r2.x, r2.x, c4.x
+    add r2.yz, r1.xxyw, c4.y
+    dp3 r0.x, c1, r2
+    dp3 r0.y, c2, r2
+    dp3 r0.z, c3, r2
+    mul r0, r0, c0.x
+    mov oC0, r0
+
+// approximately 10 instruction slots used (2 texture, 8 arithmetic)
+ps_4_0
+dcl_constantbuffer cb0[6], immediateIndexed
+dcl_sampler s0, mode_default
+dcl_resource_texture2d (float,float,float,float) t1
+dcl_resource_texture2d (float,float,float,float) t2
+dcl_input_ps linear v1.xy
+dcl_output o0.xyzw
+dcl_temps 3
+mov r0.w, l(1.000000)
+sample r1.xyzw, v1.xyxx, t1.xyzw, s0
+add r1.x, r1.x, l(-0.062750)
+sample r2.xyzw, v1.xyxx, t2.xyzw, s0
+add r1.yz, r2.xxyx, l(0.000000, -0.501960, -0.501960, 0.000000)
+dp3 r0.x, cb0[3].xyzx, r1.xyzx
+dp3 r0.y, cb0[4].xyzx, r1.xyzx
+dp3 r0.z, cb0[5].xyzx, r1.xyzx
+mul o0.xyzw, r0.xyzw, cb0[1].xxxx
+ret 
+// Approximately 10 instruction slots used
+#endif
+
+const BYTE NV12Shader[] =
+{
+     68,  88,  66,  67, 218, 231, 
+     15, 217, 244, 161,  84,  31, 
+     40, 169,  22, 115, 159,  74, 
+      1, 232,   1,   0,   0,   0, 
+     16,   7,   0,   0,   6,   0, 
+      0,   0,  56,   0,   0,   0, 
+     96,   1,   0,   0, 240,   2, 
+      0,   0, 108,   3,   0,   0, 
+    132,   6,   0,   0, 220,   6, 
+      0,   0,  65, 111, 110,  57, 
+     32,   1,   0,   0,  32,   1, 
+      0,   0,   0,   2, 255, 255, 
+    220,   0,   0,   0,  68,   0, 
+      0,   0,   2,   0,  44,   0, 
+      0,   0,  68,   0,   0,   0, 
+     68,   0,   2,   0,  36,   0, 
+      0,   0,  68,   0,   1,   0, 
+      0,   0,   2,   0,   1,   0, 
+      0,   0,   1,   0,   1,   0, 
+      0,   0,   0,   0,   0,   0, 
+      0,   0,   3,   0,   3,   0, 
+      1,   0,   0,   0,   0,   0, 
+      1,   2, 255, 255,  81,   0, 
+      0,   5,   4,   0,  15, 160, 
+     18, 131, 128, 189, 115, 128, 
+      0, 191,   0,   0, 128,  63, 
+      0,   0,   0,   0,  31,   0, 
+      0,   2,   0,   0,   0, 128, 
+      0,   0,   3, 176,  31,   0, 
+      0,   2,   0,   0,   0, 144, 
+      0,   8,  15, 160,  31,   0, 
+      0,   2,   0,   0,   0, 144, 
+      1,   8,  15, 160,   1,   0, 
+      0,   2,   0,   0,   8, 128, 
+      4,   0, 170, 160,  66,   0, 
+      0,   3,   1,   0,  15, 128, 
+      0,   0, 228, 176,   1,   8, 
+    228, 160,  66,   0,   0,   3, 
+      2,   0,  15, 128,   0,   0, 
+    228, 176,   0,   8, 228, 160, 
+      2,   0,   0,   3,   2,   0, 
+      1, 128,   2,   0,   0, 128, 
+      4,   0,   0, 160,   2,   0, 
+      0,   3,   2,   0,   6, 128, 
+      1,   0, 208, 128,   4,   0, 
+     85, 160,   8,   0,   0,   3, 
+      0,   0,   1, 128,   1,   0, 
+    228, 160,   2,   0, 228, 128, 
+      8,   0,   0,   3,   0,   0, 
+      2, 128,   2,   0, 228, 160, 
+      2,   0, 228, 128,   8,   0, 
+      0,   3,   0,   0,   4, 128, 
+      3,   0, 228, 160,   2,   0, 
+    228, 128,   5,   0,   0,   3, 
+      0,   0,  15, 128,   0,   0, 
+    228, 128,   0,   0,   0, 160, 
+      1,   0,   0,   2,   0,   8, 
+     15, 128,   0,   0, 228, 128, 
+    255, 255,   0,   0,  83,  72, 
+     68,  82, 136,   1,   0,   0, 
+     64,   0,   0,   0,  98,   0, 
+      0,   0,  89,   0,   0,   4, 
+     70, 142,  32,   0,   0,   0, 
+      0,   0,   6,   0,   0,   0, 
+     90,   0,   0,   3,   0,  96, 
+     16,   0,   0,   0,   0,   0, 
+     88,  24,   0,   4,   0, 112, 
+     16,   0,   1,   0,   0,   0, 
+     85,  85,   0,   0,  88,  24, 
+      0,   4,   0, 112,  16,   0, 
+      2,   0,   0,   0,  85,  85, 
+      0,   0,  98,  16,   0,   3, 
+     50,  16,  16,   0,   1,   0, 
+      0,   0, 101,   0,   0,   3, 
+    242,  32,  16,   0,   0,   0, 
+      0,   0, 104,   0,   0,   2, 
+      3,   0,   0,   0,  54,   0, 
+      0,   5, 130,   0,  16,   0, 
+      0,   0,   0,   0,   1,  64, 
+      0,   0,   0,   0, 128,  63, 
+     69,   0,   0,   9, 242,   0, 
+     16,   0,   1,   0,   0,   0, 
+     70,  16,  16,   0,   1,   0, 
+      0,   0,  70, 126,  16,   0, 
+      1,   0,   0,   0,   0,  96, 
+     16,   0,   0,   0,   0,   0, 
+      0,   0,   0,   7,  18,   0, 
+     16,   0,   1,   0,   0,   0, 
+     10,   0,  16,   0,   1,   0, 
+      0,   0,   1,  64,   0,   0, 
+     18, 131, 128, 189,  69,   0, 
+      0,   9, 242,   0,  16,   0, 
+      2,   0,   0,   0,  70,  16, 
+     16,   0,   1,   0,   0,   0, 
+     70, 126,  16,   0,   2,   0, 
+      0,   0,   0,  96,  16,   0, 
+      0,   0,   0,   0,   0,   0, 
+      0,  10,  98,   0,  16,   0, 
+      1,   0,   0,   0,   6,   1, 
+     16,   0,   2,   0,   0,   0, 
+      2,  64,   0,   0,   0,   0, 
+      0,   0, 115, 128,   0, 191, 
+    115, 128,   0, 191,   0,   0, 
+      0,   0,  16,   0,   0,   8, 
+     18,   0,  16,   0,   0,   0, 
+      0,   0,  70, 130,  32,   0, 
+      0,   0,   0,   0,   3,   0, 
+      0,   0,  70,   2,  16,   0, 
+      1,   0,   0,   0,  16,   0, 
+      0,   8,  34,   0,  16,   0, 
+      0,   0,   0,   0,  70, 130, 
+     32,   0,   0,   0,   0,   0, 
+      4,   0,   0,   0,  70,   2, 
+     16,   0,   1,   0,   0,   0, 
+     16,   0,   0,   8,  66,   0, 
+     16,   0,   0,   0,   0,   0, 
+     70, 130,  32,   0,   0,   0, 
+      0,   0,   5,   0,   0,   0, 
+     70,   2,  16,   0,   1,   0, 
+      0,   0,  56,   0,   0,   8, 
+    242,  32,  16,   0,   0,   0, 
+      0,   0,  70,  14,  16,   0, 
+      0,   0,   0,   0,   6, 128, 
+     32,   0,   0,   0,   0,   0, 
+      1,   0,   0,   0,  62,   0, 
+      0,   1,  83,  84,  65,  84, 
+    116,   0,   0,   0,  10,   0, 
+      0,   0,   3,   0,   0,   0, 
+      0,   0,   0,   0,   2,   0, 
+      0,   0,   6,   0,   0,   0, 
+      0,   0,   0,   0,   0,   0, 
+      0,   0,   1,   0,   0,   0, 
+      0,   0,   0,   0,   0,   0, 
+      0,   0,   0,   0,   0,   0, 
+      0,   0,   0,   0,   0,   0, 
+      0,   0,   0,   0,   0,   0, 
+      2,   0,   0,   0,   0,   0, 
+      0,   0,   0,   0,   0,   0, 
+      0,   0,   0,   0,   0,   0, 
+      0,   0,   1,   0,   0,   0, 
+      0,   0,   0,   0,   0,   0, 
+      0,   0,   0,   0,   0,   0, 
+      0,   0,   0,   0,   0,   0, 
+      0,   0,   0,   0,   0,   0, 
+      0,   0,   0,   0,   0,   0, 
+      0,   0,   0,   0,   0,   0, 
+     82,  68,  69,  70,  16,   3, 
+      0,   0,   1,   0,   0,   0, 
+    184,   0,   0,   0,   4,   0, 
+      0,   0,  28,   0,   0,   0, 
+      0,   4, 255, 255,   0,   1, 
+      0,   0, 220,   2,   0,   0, 
+    156,   0,   0,   0,   3,   0, 
+      0,   0,   0,   0,   0,   0, 
+      0,   0,   0,   0,   0,   0, 
+      0,   0,   0,   0,   0,   0, 
+      1,   0,   0,   0,   1,   0, 
+      0,   0, 165,   0,   0,   0, 
+      2,   0,   0,   0,   5,   0, 
+      0,   0,   4,   0,   0,   0, 
+    255, 255, 255, 255,   1,   0, 
+      0,   0,   1,   0,   0,   0, 
+     13,   0,   0,   0, 168,   0, 
+      0,   0,   2,   0,   0,   0, 
+      5,   0,   0,   0,   4,   0, 
+      0,   0, 255, 255, 255, 255, 
+      2,   0,   0,   0,   1,   0, 
+      0,   0,  13,   0,   0,   0, 
+    172,   0,   0,   0,   0,   0, 
+      0,   0,   0,   0,   0,   0, 
+      0,   0,   0,   0,   0,   0, 
+      0,   0,   0,   0,   0,   0, 
+      1,   0,   0,   0,   0,   0, 
+      0,   0, 115,  83,  97, 109, 
+    112, 108, 101, 114,   0, 116, 
+     89,   0, 116,  67,  98,   0, 
+     36,  71, 108, 111,  98,  97, 
+    108, 115,   0, 171, 171, 171, 
+    172,   0,   0,   0,  11,   0, 
+      0,   0, 208,   0,   0,   0, 
+     96,   1,   0,   0,   0,   0, 
+      0,   0,   0,   0,   0,   0, 
+    216,   1,   0,   0,   0,   0, 
+      0,   0,  16,   0,   0,   0, 
+      0,   0,   0,   0, 228,   1, 
+      0,   0,   0,   0,   0,   0, 
+    244,   1,   0,   0,  16,   0, 
+      0,   0,   4,   0,   0,   0, 
+      2,   0,   0,   0,   4,   2, 
+      0,   0,   0,   0,   0,   0, 
+     20,   2,   0,   0,  32,   0, 
+      0,   0,  16,   0,   0,   0, 
+      0,   0,   0,   0,  36,   2, 
+      0,   0,   0,   0,   0,   0, 
+     52,   2,   0,   0,  48,   0, 
+      0,   0,  44,   0,   0,   0, 
+      2,   0,   0,   0,  68,   2, 
+      0,   0,   0,   0,   0,   0, 
+     84,   2,   0,   0,  96,   0, 
+      0,   0,  64,   0,   0,   0, 
+      0,   0,   0,   0, 100,   2, 
+      0,   0,   0,   0,   0,   0, 
+    116,   2,   0,   0, 160,   0, 
+      0,   0,  64,   0,   0,   0, 
+      0,   0,   0,   0, 100,   2, 
+      0,   0,   0,   0,   0,   0, 
+    128,   2,   0,   0, 224,   0, 
+      0,   0,  16,   0,   0,   0, 
+      0,   0,   0,   0, 228,   1, 
+      0,   0,   0,   0,   0,   0, 
+    148,   2,   0,   0, 240,   0, 
+      0,   0,  16,   0,   0,   0, 
+      0,   0,   0,   0, 164,   2, 
+      0,   0,   0,   0,   0,   0, 
+    180,   2,   0,   0,   0,   1, 
+      0,   0,  16,   0,   0,   0, 
+      0,   0,   0,   0, 164,   2, 
+      0,   0,   0,   0,   0,   0, 
+    191,   2,   0,   0,  16,   1, 
+      0,   0,  16,   0,   0,   0, 
+      0,   0,   0,   0, 164,   2, 
+      0,   0,   0,   0,   0,   0, 
+    201,   2,   0,   0,  32,   1, 
+      0,   0,  64,   0,   0,   0, 
+      0,   0,   0,   0, 100,   2, 
+      0,   0,   0,   0,   0,   0, 
+    102,  76,  97, 121, 101, 114, 
+     67, 111, 108, 111, 114,   0, 
+      1,   0,   3,   0,   1,   0, 
+      4,   0,   0,   0,   0,   0, 
+      0,   0,   0,   0, 102,  76, 
+     97, 121, 101, 114,  79, 112, 
+     97,  99, 105, 116, 121,   0, 
+    171, 171,   0,   0,   3,   0, 
+      1,   0,   1,   0,   0,   0, 
+      0,   0,   0,   0,   0,   0, 
+    105,  66, 108, 101, 110, 100, 
+     67, 111, 110, 102, 105, 103, 
+      0, 171, 171, 171,   1,   0, 
+     19,   0,   1,   0,   4,   0, 
+      0,   0,   0,   0,   0,   0, 
+      0,   0, 109,  89, 117, 118, 
+     67, 111, 108, 111, 114,  77, 
+     97, 116, 114, 105, 120,   0, 
+      2,   0,   3,   0,   3,   0, 
+      3,   0,   0,   0,   0,   0, 
+      0,   0,   0,   0, 109,  76, 
+     97, 121, 101, 114,  84, 114, 
+     97, 110, 115, 102, 111, 114, 
+    109,   0,   3,   0,   3,   0, 
+      4,   0,   4,   0,   0,   0, 
+      0,   0,   0,   0,   0,   0, 
+    109,  80, 114, 111, 106, 101, 
+     99, 116, 105, 111, 110,   0, 
+    118,  82, 101, 110, 100, 101, 
+    114,  84,  97, 114, 103, 101, 
+    116,  79, 102, 102, 115, 101, 
+    116,   0, 118,  84, 101, 120, 
+    116, 117, 114, 101,  67, 111, 
+    111, 114, 100, 115,   0, 171, 
+      1,   0,   3,   0,   1,   0, 
+      4,   0,   0,   0,   0,   0, 
+      0,   0,   0,   0, 118,  76, 
+     97, 121, 101, 114,  81, 117, 
+     97, 100,   0, 118,  77,  97, 
+    115, 107,  81, 117,  97, 100, 
+      0, 109,  66,  97,  99, 107, 
+    100, 114, 111, 112,  84, 114, 
+     97, 110, 115, 102, 111, 114, 
+    109,   0,  77, 105,  99, 114, 
+    111, 115, 111, 102, 116,  32, 
+     40,  82,  41,  32,  72,  76, 
+     83,  76,  32,  83, 104,  97, 
+    100, 101, 114,  32,  67, 111, 
+    109, 112, 105, 108, 101, 114, 
+     32,  54,  46,  51,  46,  57, 
+     54,  48,  48,  46,  49,  54, 
+     51,  56,  52,   0, 171, 171, 
+     73,  83,  71,  78,  80,   0, 
+      0,   0,   2,   0,   0,   0, 
+      8,   0,   0,   0,  56,   0, 
+      0,   0,   0,   0,   0,   0, 
+      1,   0,   0,   0,   3,   0, 
+      0,   0,   0,   0,   0,   0, 
+     15,   0,   0,   0,  68,   0, 
+      0,   0,   0,   0,   0,   0, 
+      0,   0,   0,   0,   3,   0, 
+      0,   0,   1,   0,   0,   0, 
+      3,   3,   0,   0,  83,  86, 
+     95,  80, 111, 115, 105, 116, 
+    105, 111, 110,   0,  84,  69, 
+     88,  67,  79,  79,  82,  68, 
+      0, 171, 171, 171,  79,  83, 
+     71,  78,  44,   0,   0,   0, 
+      1,   0,   0,   0,   8,   0, 
+      0,   0,  32,   0,   0,   0, 
+      0,   0,   0,   0,   0,   0, 
+      0,   0,   3,   0,   0,   0, 
+      0,   0,   0,   0,  15,   0, 
+      0,   0,  83,  86,  95,  84, 
+     97, 114, 103, 101, 116,   0, 
+    171, 171
+};
+ShaderBytes sNV12Shader = { NV12Shader, sizeof(NV12Shader) };
+#if 0
+//
+// Generated by Microsoft (R) HLSL Shader Compiler 6.3.9600.16384
 //
 //
 // Buffer Definitions: 
 //
 // cbuffer $Globals
 // {
 //
 //   float4x4 mLayerTransform;          // Offset:    0 Size:    64
@@ -2610,19 +3035,19 @@ ShaderBytes sYCbCrShader = { YCbCrShader
 //   uint4 iBlendConfig;                // Offset:  288 Size:    16 [unused]
 //   row_major float3x3 mYuvColorMatrix;// Offset:  304 Size:    44 [unused]
 //
 // }
 //
 //
 // Resource Bindings:
 //
-// Name                                 Type  Format         Dim      HLSL Bind  Count
-// ------------------------------ ---------- ------- ----------- -------------- ------
-// $Globals                          cbuffer      NA          NA            cb0      1 
+// Name                                 Type  Format         Dim Slot Elements
+// ------------------------------ ---------- ------- ----------- ---- --------
+// $Globals                          cbuffer      NA          NA    0        1
 //
 //
 //
 // Input signature:
 //
 // Name                 Index   Mask Register SysValue  Format   Used
 // -------------------- ----- ------ -------- -------- ------- ------
 // POSITION                 0   xy          0     NONE   float   xy  
@@ -2677,17 +3102,17 @@ ShaderBytes sYCbCrShader = { YCbCrShader
     mad r1, c4, r0.x, r1
     mad r1, c6, r0.z, r1
     mad r0, c7, r0.w, r1
     mad oPos.xy, r0.w, c0, r0
     mov oPos.zw, r0
 
 // approximately 22 instruction slots used
 vs_4_0
-dcl_constantbuffer CB0[12], immediateIndexed
+dcl_constantbuffer cb0[12], immediateIndexed
 dcl_input v0.xy
 dcl_output_siv o0.xyzw, position
 dcl_output o1.xy
 dcl_output o2.xyz
 dcl_temps 4
 mad r0.xy, v0.xyxx, cb0[10].zwzz, cb0[10].xyxx
 mul r1.xyzw, r0.yyyy, cb0[1].xyzw
 mad r0.xyzw, cb0[0].xyzw, r0.xxxx, r1.xyzw
@@ -2706,25 +3131,25 @@ div r0.xy, r0.xyxx, cb0[11].zwzz
 mov r0.z, l(1.000000)
 mul o2.xyz, r1.wwww, r0.xyzx
 ret 
 // Approximately 18 instruction slots used
 #endif
 
 const BYTE LayerQuadMaskVS[] =
 {
-     68,  88,  66,  67,  47,  28, 
-    196, 228,  98,  79,  27, 152, 
-    192,  25, 215, 128,  59, 234, 
-    245, 240,   1,   0,   0,   0, 
-    108,   8,   0,   0,   6,   0, 
+     68,  88,  66,  67,  49, 180, 
+    132, 220, 248,  20, 100, 179, 
+    133, 183,  38, 139, 110, 187, 
+      8,  59,   1,   0,   0,   0, 
+    120,   8,   0,   0,   6,   0, 
       0,   0,  56,   0,   0,   0, 
      20,   2,   0,   0, 176,   4, 
       0,   0,  44,   5,   0,   0, 
-    200,   7,   0,   0, 252,   7, 
+    212,   7,   0,   0,   8,   8, 
       0,   0,  65, 111, 110,  57, 
     212,   1,   0,   0, 212,   1, 
       0,   0,   0,   2, 254, 255, 
     148,   1,   0,   0,  64,   0, 
       0,   0,   2,   0,  36,   0, 
       0,   0,  60,   0,   0,   0, 
      60,   0,   0,   0,  36,   0, 
       1,   0,  60,   0,   0,   0, 
@@ -2927,17 +3352,17 @@ const BYTE LayerQuadMaskVS[] =
       0,   0,   0,   0,   0,   0, 
       2,   0,   0,   0,   0,   0, 
       0,   0,   0,   0,   0,   0, 
       0,   0,   0,   0,   0,   0, 
       0,   0,   0,   0,   0,   0, 
       0,   0,   0,   0,   0,   0, 
       0,   0,   0,   0,   0,   0, 
       0,   0,   0,   0,  82,  68, 
-     69,  70, 148,   2,   0,   0, 
+     69,  70, 160,   2,   0,   0, 
       1,   0,   0,   0,  72,   0, 
       0,   0,   1,   0,   0,   0, 
      28,   0,   0,   0,   0,   4, 
     254, 255,   0,   1,   0,   0, 
     108,   2,   0,   0,  60,   0, 
       0,   0,   0,   0,   0,   0, 
       0,   0,   0,   0,   0,   0, 
       0,   0,   0,   0,   0,   0, 
@@ -3037,17 +3462,19 @@ const BYTE LayerQuadMaskVS[] =
       3,   0,   3,   0,   3,   0, 
       0,   0,   0,   0,   0,   0, 
       0,   0,  77, 105,  99, 114, 
     111, 115, 111, 102, 116,  32, 
      40,  82,  41,  32,  72,  76, 
      83,  76,  32,  83, 104,  97, 
     100, 101, 114,  32,  67, 111, 
     109, 112, 105, 108, 101, 114, 
-     32,  49,  48,  46,  49,   0, 
+     32,  54,  46,  51,  46,  57, 
+     54,  48,  48,  46,  49,  54, 
+     51,  56,  52,   0, 171, 171, 
      73,  83,  71,  78,  44,   0, 
       0,   0,   1,   0,   0,   0, 
       8,   0,   0,   0,  32,   0, 
       0,   0,   0,   0,   0,   0, 
       0,   0,   0,   0,   3,   0, 
       0,   0,   0,   0,   0,   0, 
       3,   3,   0,   0,  80,  79, 
      83,  73,  84,  73,  79,  78, 
@@ -3070,17 +3497,17 @@ const BYTE LayerQuadMaskVS[] =
     111, 115, 105, 116, 105, 111, 
     110,   0,  84,  69,  88,  67, 
      79,  79,  82,  68,   0, 171, 
     171, 171
 };
 ShaderBytes sLayerQuadMaskVS = { LayerQuadMaskVS, sizeof(LayerQuadMaskVS) };
 #if 0
 //
-// Generated by Microsoft (R) HLSL Shader Compiler 10.1
+// Generated by Microsoft (R) HLSL Shader Compiler 6.3.9600.16384
 //
 //
 // Buffer Definitions: 
 //
 // cbuffer $Globals
 // {
 //
 //   float4x4 mLayerTransform;          // Offset:    0 Size:    64
@@ -3577,21 +4004,21 @@ ShaderBytes sLayerDynamicMaskVS = { Laye
 //   float4 vMaskQuad;                  // Offset:  272 Size:    16 [unused]
 //   float4x4 mBackdropTransform;       // Offset:  288 Size:    64 [unused]
 //
 // }
 //
 //
 // Resource Bindings:
 //
-// Name                                 Type  Format         Dim      HLSL Bind  Count
-// ------------------------------ ---------- ------- ----------- -------------- ------
-// sSampler                          sampler      NA          NA             s0      1 
-// tMask                             texture  float4          2d             t5      1 
-// $Globals                          cbuffer      NA          NA            cb0      1 
+// Name                                 Type  Format         Dim Slot Elements
+// ------------------------------ ---------- ------- ----------- ---- --------
+// sSampler                          sampler      NA          NA    0        1
+// tMask                             texture  float4          2d    5        1
+// $Globals                          cbuffer      NA          NA    0        1
 //
 //
 //
 // Input signature:
 //
 // Name                 Index   Mask Register SysValue  Format   Used
 // -------------------- ----- ------ -------- -------- ------- ------
 // SV_Position              0   xyzw        0      POS   float       
@@ -3628,40 +4055,40 @@ ShaderBytes sLayerDynamicMaskVS = { Laye
     rcp r0.w, t1.z
     mul r0.xy, r0.w, t1
     texld r0, r0, s0
     mul r0, r0.x, c0
     mov oC0, r0
 
 // approximately 5 instruction slots used (1 texture, 4 arithmetic)
 ps_4_0
-dcl_constantbuffer CB0[1], immediateIndexed
+dcl_constantbuffer cb0[1], immediateIndexed
 dcl_sampler s0, mode_default
 dcl_resource_texture2d (float,float,float,float) t5
 dcl_input_ps linear v2.xyz
 dcl_output o0.xyzw
 dcl_temps 1
 div r0.xy, v2.xyxx, v2.zzzz
 sample r0.xyzw, r0.xyxx, t5.xyzw, s0
 mul o0.xyzw, r0.xxxx, cb0[0].xyzw
 ret 
 // Approximately 4 instruction slots used
 #endif
 
 const BYTE SolidColorShaderMask[] =
 {
-     68,  88,  66,  67,  11,   0, 
-     43, 127, 123,  42, 253, 228, 
-      4, 220,   7, 130,  11,  94, 
-    213, 177,   1,   0,   0,   0, 
-    164,   5,   0,   0,   6,   0, 
+     68,  88,  66,  67, 173,  54, 
+    246,  72,  40,  33, 131, 132, 
+    203,  91, 150, 154,  22, 238, 
+    197,  53,   1,   0,   0,   0, 
+    176,   5,   0,   0,   6,   0, 
       0,   0,  56,   0,   0,   0, 
     220,   0,   0,   0, 156,   1, 
       0,   0,  24,   2,   0,   0, 
-      0,   5,   0,   0, 112,   5, 
+     12,   5,   0,   0, 124,   5, 
       0,   0,  65, 111, 110,  57, 
     156,   0,   0,   0, 156,   0, 
       0,   0,   0,   2, 255, 255, 
     104,   0,   0,   0,  52,   0, 
       0,   0,   1,   0,  40,   0, 
       0,   0,  52,   0,   0,   0, 
      52,   0,   1,   0,  36,   0, 
       0,   0,  52,   0,   5,   0, 
@@ -3733,17 +4160,17 @@ const BYTE SolidColorShaderMask[] =
       0,   0,   0,   0,   0,   0, 
       0,   0,   0,   0,   0,   0, 
       0,   0,   0,   0,   0,   0, 
       0,   0,   0,   0,   0,   0, 
       0,   0,   0,   0,   0,   0, 
       0,   0,   0,   0,   0,   0, 
       0,   0,   0,   0,   0,   0, 
       0,   0,  82,  68,  69,  70, 
-    224,   2,   0,   0,   1,   0, 
+    236,   2,   0,   0,   1,   0, 
       0,   0, 148,   0,   0,   0, 
       3,   0,   0,   0,  28,   0, 
       0,   0,   0,   4, 255, 255, 
       0,   1,   0,   0, 184,   2, 
       0,   0, 124,   0,   0,   0, 
       3,   0,   0,   0,   0,   0, 
       0,   0,   0,   0,   0,   0, 
       0,   0,   0,   0,   0,   0, 
@@ -3855,18 +4282,20 @@ const BYTE SolidColorShaderMask[] =
      99, 107, 100, 114, 111, 112, 
      84, 114,  97, 110, 115, 102, 
     111, 114, 109,   0,  77, 105, 
      99, 114, 111, 115, 111, 102, 
     116,  32,  40,  82,  41,  32, 
      72,  76,  83,  76,  32,  83, 
     104,  97, 100, 101, 114,  32, 
      67, 111, 109, 112, 105, 108, 
-    101, 114,  32,  49,  48,  46, 
-     49,   0,  73,  83,  71,  78, 
+    101, 114,  32,  54,  46,  51, 
+     46,  57,  54,  48,  48,  46, 
+     49,  54,  51,  56,  52,   0, 
+    171, 171,  73,  83,  71,  78, 
     104,   0,   0,   0,   3,   0, 
       0,   0,   8,   0,   0,   0, 
      80,   0,   0,   0,   0,   0, 
       0,   0,   1,   0,   0,   0, 
       3,   0,   0,   0,   0,   0, 
       0,   0,  15,   0,   0,   0, 
      92,   0,   0,   0,   0,   0, 
       0,   0,   0,   0,   0,   0, 
@@ -3888,17 +4317,17 @@ const BYTE SolidColorShaderMask[] =
       0,   0,   0,   0,   0,   0, 
      15,   0,   0,   0,  83,  86, 
      95,  84,  97, 114, 103, 101, 
     116,   0, 171, 171
 };
 ShaderBytes sSolidColorShaderMask = { SolidColorShaderMask, sizeof(SolidColorShaderMask) };
 #if 0
 //
-// Generated by Microsoft (R) HLSL Shader Compiler 10.1
+// Generated by Microsoft (R) HLSL Shader Compiler 6.3.9600.16384
 //
 //
 // Buffer Definitions: 
 //
 // cbuffer $Globals
 // {
 //
 //   float4 fLayerColor;                // Offset:    0 Size:    16 [unused]
@@ -3913,22 +4342,22 @@ ShaderBytes sSolidColorShaderMask = { So
 //   float4 vMaskQuad;                  // Offset:  272 Size:    16 [unused]
 //   float4x4 mBackdropTransform;       // Offset:  288 Size:    64 [unused]
 //
 // }
 //
 //
 // Resource Bindings:
 //
-// Name                                 Type  Format         Dim      HLSL Bind  Count
-// ------------------------------ ---------- ------- ----------- -------------- ------
-// sSampler                          sampler      NA          NA             s0      1 
-// tRGB                              texture  float4          2d             t0      1 
-// tMask                             texture  float4          2d             t5      1 
-// $Globals                          cbuffer      NA          NA            cb0      1 
+// Name                                 Type  Format         Dim Slot Elements
+// ------------------------------ ---------- ------- ----------- ---- --------
+// sSampler                          sampler      NA          NA    0        1
+// tRGB                              texture  float4          2d    0        1
+// tMask                             texture  float4          2d    5        1
+// $Globals                          cbuffer      NA          NA    0        1
 //
 //
 //
 // Input signature:
 //
 // Name                 Index   Mask Register SysValue  Format   Used
 // -------------------- ----- ------ -------- -------- ------- ------
 // SV_Position              0   xyzw        0      POS   float       
@@ -3971,17 +4400,17 @@ ShaderBytes sSolidColorShaderMask = { So
     texld r0, r0, s1
     mul r1.xyz, r1, c0.x
     mov r1.w, c0.x
     mul r0, r0.x, r1
     mov oC0, r0
 
 // approximately 8 instruction slots used (2 texture, 6 arithmetic)
 ps_4_0
-dcl_constantbuffer CB0[2], immediateIndexed
+dcl_constantbuffer cb0[2], immediateIndexed
 dcl_sampler s0, mode_default
 dcl_resource_texture2d (float,float,float,float) t0
 dcl_resource_texture2d (float,float,float,float) t5
 dcl_input_ps linear v1.xy
 dcl_input_ps linear v2.xyz
 dcl_output o0.xyzw
 dcl_temps 2
 sample r0.xyzw, v1.xyxx, t0.xyzw, s0
@@ -3991,25 +4420,25 @@ sample r1.xyzw, r1.xyxx, t5.xyzw, s0
 mov r0.w, cb0[1].x
 mul o0.xyzw, r0.xyzw, r1.xxxx
 ret 
 // Approximately 7 instruction slots used
 #endif
 
 const BYTE RGBShaderMask[] =
 {
-     68,  88,  66,  67,  89, 221, 
-     15,  22, 232, 140, 114, 122, 
-    200,  15, 217, 125, 153,  18, 
-    224,   0,   1,   0,   0,   0, 
-    136,   6,   0,   0,   6,   0, 
+     68,  88,  66,  67, 175, 239, 
+    130,  78, 213,  58,   7, 106, 
+    239, 127, 178, 225,  51, 170, 
+    231,  60,   1,   0,   0,   0, 
+    148,   6,   0,   0,   6,   0, 
       0,   0,  56,   0,   0,   0, 
      36,   1,   0,   0,  88,   2, 
       0,   0, 212,   2,   0,   0, 
-    228,   5,   0,   0,  84,   6, 
+    240,   5,   0,   0,  96,   6, 
       0,   0,  65, 111, 110,  57, 
     228,   0,   0,   0, 228,   0, 
       0,   0,   0,   2, 255, 255, 
     172,   0,   0,   0,  56,   0, 
       0,   0,   1,   0,  44,   0, 
       0,   0,  56,   0,   0,   0, 
      56,   0,   2,   0,  36,   0, 
       0,   0,  56,   0,   0,   0, 
@@ -4112,17 +4541,17 @@ const BYTE RGBShaderMask[] =
       0,   0,   0,   0,   0,   0, 
       1,   0,   0,   0,   0,   0, 
       0,   0,   0,   0,   0,   0, 
       0,   0,   0,   0,   0,   0, 
       0,   0,   0,   0,   0,   0, 
       0,   0,   0,   0,   0,   0, 
       0,   0,   0,   0,   0,   0, 
       0,   0,   0,   0,  82,  68, 
-     69,  70,   8,   3,   0,   0, 
+     69,  70,  20,   3,   0,   0, 
       1,   0,   0,   0, 188,   0, 
       0,   0,   4,   0,   0,   0, 
      28,   0,   0,   0,   0,   4, 
     255, 255,   0,   1,   0,   0, 
     224,   2,   0,   0, 156,   0, 
       0,   0,   3,   0,   0,   0, 
       0,   0,   0,   0,   0,   0, 
       0,   0,   0,   0,   0,   0, 
@@ -4241,18 +4670,20 @@ const BYTE RGBShaderMask[] =
      99, 107, 100, 114, 111, 112, 
      84, 114,  97, 110, 115, 102, 
     111, 114, 109,   0,  77, 105, 
      99, 114, 111, 115, 111, 102, 
     116,  32,  40,  82,  41,  32, 
      72,  76,  83,  76,  32,  83, 
     104,  97, 100, 101, 114,  32, 
      67, 111, 109, 112, 105, 108, 
-    101, 114,  32,  49,  48,  46, 
-     49,   0,  73,  83,  71,  78, 
+    101, 114,  32,  54,  46,  51, 
+     46,  57,  54,  48,  48,  46, 
+     49,  54,  51,  56,  52,   0, 
+    171, 171,  73,  83,  71,  78, 
     104,   0,   0,   0,   3,   0, 
       0,   0,   8,   0,   0,   0, 
      80,   0,   0,   0,   0,   0, 
       0,   0,   1,   0,   0,   0, 
       3,   0,   0,   0,   0,   0, 
       0,   0,  15,   0,   0,   0, 
      92,   0,   0,   0,   0,   0, 
       0,   0,   0,   0,   0,   0, 
@@ -4274,17 +4705,17 @@ const BYTE RGBShaderMask[] =
       0,   0,   0,   0,   0,   0, 
      15,   0,   0,   0,  83,  86, 
      95,  84,  97, 114, 103, 101, 
     116,   0, 171, 171
 };
 ShaderBytes sRGBShaderMask = { RGBShaderMask, sizeof(RGBShaderMask) };
 #if 0
 //
-// Generated by Microsoft (R) HLSL Shader Compiler 10.1
+// Generated by Microsoft (R) HLSL Shader Compiler 6.3.9600.16384
 //
 //
 // Buffer Definitions: 
 //
 // cbuffer $Globals
 // {
 //
 //   float4 fLayerColor;                // Offset:    0 Size:    16 [unused]
@@ -4299,22 +4730,22 @@ ShaderBytes sRGBShaderMask = { RGBShader
 //   float4 vMaskQuad;                  // Offset:  272 Size:    16 [unused]
 //   float4x4 mBackdropTransform;       // Offset:  288 Size:    64 [unused]
 //
 // }
 //
 //
 // Resource Bindings:
 //
-// Name                                 Type  Format         Dim      HLSL Bind  Count
-// ------------------------------ ---------- ------- ----------- -------------- ------
-// sSampler                          sampler      NA          NA             s0      1 
-// tRGB                              texture  float4          2d             t0      1 
-// tMask                             texture  float4          2d             t5      1 
-// $Globals                          cbuffer      NA          NA            cb0      1 
+// Name                                 Type  Format         Dim Slot Elements
+// ------------------------------ ---------- ------- ----------- ---- --------
+// sSampler                          sampler      NA          NA    0        1
+// tRGB                              texture  float4          2d    0        1
+// tMask                             texture  float4          2d    5        1
+// $Globals                          cbuffer      NA          NA    0        1
 //
 //
 //
 // Input signature:
 //
 // Name                 Index   Mask Register SysValue  Format   Used
 // -------------------- ----- ------ -------- -------- ------- ------
 // SV_Position              0   xyzw        0      POS   float       
@@ -4356,17 +4787,17 @@ ShaderBytes sRGBShaderMask = { RGBShader
     texld r1, t0, s0
     texld r0, r0, s1
     mul r1, r1, c0.x
     mul r0, r0.x, r1
     mov oC0, r0
 
 // approximately 7 instruction slots used (2 texture, 5 arithmetic)
 ps_4_0
-dcl_constantbuffer CB0[2], immediateIndexed
+dcl_constantbuffer cb0[2], immediateIndexed
 dcl_sampler s0, mode_default
 dcl_resource_texture2d (float,float,float,float) t0
 dcl_resource_texture2d (float,float,float,float) t5
 dcl_input_ps linear v1.xy
 dcl_input_ps linear v2.xyz
 dcl_output o0.xyzw
 dcl_temps 2
 div r0.xy, v2.xyxx, v2.zzzz
@@ -4375,25 +4806,25 @@ sample r1.xyzw, v1.xyxx, t0.xyzw, s0
 mul r1.xyzw, r1.xyzw, cb0[1].xxxx
 mul o0.xyzw, r0.xxxx, r1.xyzw
 ret 
 // Approximately 6 instruction slots used
 #endif
 
 const BYTE RGBAShaderMask[] =
 {
-     68,  88,  66,  67, 195, 236, 
-    129, 118, 244,  48, 247, 117, 
-    155, 208,   5,  31,   9, 224, 
-     75,  19,   1,   0,   0,   0, 
-    100,   6,   0,   0,   6,   0, 
+     68,  88,  66,  67,  36, 253, 
+     85, 137, 135, 245,  76,  25, 
+     35, 167,  21, 130, 234, 242, 
+     11,  83,   1,   0,   0,   0, 
+    112,   6,   0,   0,   6,   0, 
       0,   0,  56,   0,   0,   0, 
      24,   1,   0,   0,  52,   2, 
       0,   0, 176,   2,   0,   0, 
-    192,   5,   0,   0,  48,   6, 
+    204,   5,   0,   0,  60,   6, 
       0,   0,  65, 111, 110,  57, 
     216,   0,   0,   0, 216,   0, 
       0,   0,   0,   2, 255, 255, 
     160,   0,   0,   0,  56,   0, 
       0,   0,   1,   0,  44,   0, 
       0,   0,  56,   0,   0,   0, 
      56,   0,   2,   0,  36,   0, 
       0,   0,  56,   0,   0,   0, 
@@ -4490,17 +4921,17 @@ const BYTE RGBAShaderMask[] =
       0,   0,   0,   0,   0,   0, 
       0,   0,   0,   0,   0,   0, 
       0,   0,   0,   0,   0,   0, 
       0,   0,   0,   0,   0,   0, 
       0,   0,   0,   0,   0,   0, 
       0,   0,   0,   0,   0,   0, 
       0,   0,   0,   0,   0,   0, 
       0,   0,   0,   0,  82,  68, 
-     69,  70,   8,   3,   0,   0, 
+     69,  70,  20,   3,   0,   0, 
       1,   0,   0,   0, 188,   0, 
       0,   0,   4,   0,   0,   0, 
      28,   0,   0,   0,   0,   4, 
     255, 255,   0,   1,   0,   0, 
     224,   2,   0,   0, 156,   0, 
       0,   0,   3,   0,   0,   0, 
       0,   0,   0,   0,   0,   0, 
       0,   0,   0,   0,   0,   0, 
@@ -4619,18 +5050,20 @@ const BYTE RGBAShaderMask[] =
      99, 107, 100, 114, 111, 112, 
      84, 114,  97, 110, 115, 102, 
     111, 114, 109,   0,  77, 105, 
      99, 114, 111, 115, 111, 102, 
     116,  32,  40,  82,  41,  32, 
      72,  76,  83,  76,  32,  83, 
     104,  97, 100, 101, 114,  32, 
      67, 111, 109, 112, 105, 108, 
-    101, 114,  32,  49,  48,  46, 
-     49,   0,  73,  83,  71,  78, 
+    101, 114,  32,  54,  46,  51, 
+     46,  57,  54,  48,  48,  46, 
+     49,  54,  51,  56,  52,   0, 
+    171, 171,  73,  83,  71,  78, 
     104,   0,   0,   0,   3,   0, 
       0,   0,   8,   0,   0,   0, 
      80,   0,   0,   0,   0,   0, 
       0,   0,   1,   0,   0,   0, 
       3,   0,   0,   0,   0,   0, 
       0,   0,  15,   0,   0,   0, 
      92,   0,   0,   0,   0,   0, 
       0,   0,   0,   0,   0,   0, 
@@ -4652,17 +5085,17 @@ const BYTE RGBAShaderMask[] =
       0,   0,   0,   0,   0,   0, 
      15,   0,   0,   0,  83,  86, 
      95,  84,  97, 114, 103, 101, 
     116,   0, 171, 171
 };
 ShaderBytes sRGBAShaderMask = { RGBAShaderMask, sizeof(RGBAShaderMask) };
 #if 0
 //
-// Generated by Microsoft (R) HLSL Shader Compiler 10.1
+// Generated by Microsoft (R) HLSL Shader Compiler 6.3.9600.16384
 //
 //
 // Buffer Definitions: 
 //
 // cbuffer $Globals
 // {
 //
 //   float4 fLayerColor;                // Offset:    0 Size:    16 [unused]
@@ -4677,24 +5110,24 @@ ShaderBytes sRGBAShaderMask = { RGBAShad
 //   float4 vMaskQuad;                  // Offset:  272 Size:    16 [unused]
 //   float4x4 mBackdropTransform;       // Offset:  288 Size:    64 [unused]
 //
 // }
 //
 //
 // Resource Bindings:
 //
-// Name                                 Type  Format         Dim      HLSL Bind  Count
-// ------------------------------ ---------- ------- ----------- -------------- ------
-// sSampler                          sampler      NA          NA             s0      1 
-// tY                                texture  float4          2d             t1      1 
-// tCb                               texture  float4          2d             t2      1 
-// tCr                               texture  float4          2d             t3      1 
-// tMask                             texture  float4          2d             t5      1 
-// $Globals                          cbuffer      NA          NA            cb0      1 
+// Name                                 Type  Format         Dim Slot Elements
+// ------------------------------ ---------- ------- ----------- ---- --------
+// sSampler                          sampler      NA          NA    0        1
+// tY                                texture  float4          2d    1        1
+// tCb                               texture  float4          2d    2        1
+// tCr                               texture  float4          2d    3        1
+// tMask                             texture  float4          2d    5        1
+// $Globals                          cbuffer      NA          NA    0        1
 //
 //
 //
 // Input signature:
 //
 // Name                 Index   Mask Register SysValue  Format   Used
 // -------------------- ----- ------ -------- -------- ------- ------
 // SV_Position              0   xyzw        0      POS   float       
@@ -4751,17 +5184,17 @@ ShaderBytes sRGBAShaderMask = { RGBAShad
     dp3 r0.y, c2, r2
     dp3 r0.z, c3, r2
     mul r0, r0, c0.x
     mul r0, r1.x, r0
     mov oC0, r0
 
 // approximately 16 instruction slots used (4 texture, 12 arithmetic)
 ps_4_0
-dcl_constantbuffer CB0[6], immediateIndexed
+dcl_constantbuffer cb0[6], immediateIndexed
 dcl_sampler s0, mode_default
 dcl_resource_texture2d (float,float,float,float) t1
 dcl_resource_texture2d (float,float,float,float) t2
 dcl_resource_texture2d (float,float,float,float) t3
 dcl_resource_texture2d (float,float,float,float) t5
 dcl_input_ps linear v1.xy
 dcl_input_ps linear v2.xyz
 dcl_output o0.xyzw
@@ -4781,25 +5214,25 @@ div r1.xy, v2.xyxx, v2.zzzz
 sample r1.xyzw, r1.xyxx, t5.xyzw, s0
 mul o0.xyzw, r0.xyzw, r1.xxxx
 ret 
 // Approximately 15 instruction slots used
 #endif
 
 const BYTE YCbCrShaderMask[] =
 {
-     68,  88,  66,  67, 239, 174, 
-    189, 163,  31,  16, 244, 108, 
-     86, 227,  23,   8,  28, 147, 
-     43,  62,   1,   0,   0,   0, 
-    168,   8,   0,   0,   6,   0, 
+     68,  88,  66,  67, 154, 143, 
+      6,  70,  56, 178, 199, 162, 
+     76,  31, 248, 139, 158, 135, 
+    163, 170,   1,   0,   0,   0, 
+    180,   8,   0,   0,   6,   0, 
       0,   0,  56,   0,   0,   0, 
     232,   1,   0,   0,  52,   4, 
       0,   0, 176,   4,   0,   0, 
-      4,   8,   0,   0, 116,   8, 
+     16,   8,   0,   0, 128,   8, 
       0,   0,  65, 111, 110,  57, 
     168,   1,   0,   0, 168,   1, 
       0,   0,   0,   2, 255, 255, 
      92,   1,   0,   0,  76,   0, 
       0,   0,   2,   0,  52,   0, 
       0,   0,  76,   0,   0,   0, 
      76,   0,   4,   0,  36,   0, 
       0,   0,  76,   0,   1,   0, 
@@ -4981,17 +5414,17 @@ const BYTE YCbCrShaderMask[] =
       0,   0,   0,   0,   0,   0, 
       0,   0,   1,   0,   0,   0, 
       0,   0,   0,   0,   0,   0, 
       0,   0,   0,   0,   0,   0, 
       0,   0,   0,   0,   0,   0, 
       0,   0,   0,   0,   0,   0, 
       0,   0,   0,   0,   0,   0, 
       0,   0,   0,   0,   0,   0, 
-     82,  68,  69,  70,  76,   3, 
+     82,  68,  69,  70,  88,   3, 
       0,   0,   1,   0,   0,   0, 
       0,   1,   0,   0,   6,   0, 
       0,   0,  28,   0,   0,   0, 
       0,   4, 255, 255,   0,   1, 
       0,   0,  36,   3,   0,   0, 
     220,   0,   0,   0,   3,   0, 
       0,   0,   0,   0,   0,   0, 
       0,   0,   0,   0,   0,   0, 
@@ -5122,17 +5555,19 @@ const BYTE YCbCrShaderMask[] =
     100, 114, 111, 112,  84, 114, 
      97, 110, 115, 102, 111, 114, 
     109,   0,  77, 105,  99, 114, 
     111, 115, 111, 102, 116,  32, 
      40,  82,  41,  32,  72,  76, 
      83,  76,  32,  83, 104,  97, 
     100, 101, 114,  32,  67, 111, 
     109, 112, 105, 108, 101, 114, 
-     32,  49,  48,  46,  49,   0, 
+     32,  54,  46,  51,  46,  57, 
+     54,  48,  48,  46,  49,  54, 
+     51,  56,  52,   0, 171, 171, 
      73,  83,  71,  78, 104,   0, 
       0,   0,   3,   0,   0,   0, 
       8,   0,   0,   0,  80,   0, 
       0,   0,   0,   0,   0,   0, 
       1,   0,   0,   0,   3,   0, 
       0,   0,   0,   0,   0,   0, 
      15,   0,   0,   0,  92,   0, 
       0,   0,   0,   0,   0,   0, 
@@ -5155,17 +5590,488 @@ const BYTE YCbCrShaderMask[] =
       0,   0,   0,   0,  15,   0, 
       0,   0,  83,  86,  95,  84, 
      97, 114, 103, 101, 116,   0, 
     171, 171
 };
 ShaderBytes sYCbCrShaderMask = { YCbCrShaderMask, sizeof(YCbCrShaderMask) };
 #if 0
 //
-// Generated by Microsoft (R) HLSL Shader Compiler 10.1
+// Generated by Microsoft (R) HLSL Shader Compiler 6.3.9600.16384
+//
+//
+// Buffer Definitions: 
+//
+// cbuffer $Globals
+// {
+//
+//   float4 fLayerColor;                // Offset:    0 Size:    16 [unused]
+//   float fLayerOpacity;               // Offset:   16 Size:     4
+//   uint4 iBlendConfig;                // Offset:   32 Size:    16 [unused]
+//   row_major float3x3 mYuvColorMatrix;// Offset:   48 Size:    44
+//   float4x4 mLayerTransform;          // Offset:   96 Size:    64 [unused]
+//   float4x4 mProjection;              // Offset:  160 Size:    64 [unused]
+//   float4 vRenderTargetOffset;        // Offset:  224 Size:    16 [unused]
+//   float4 vTextureCoords;             // Offset:  240 Size:    16 [unused]
+//   float4 vLayerQuad;                 // Offset:  256 Size:    16 [unused]
+//   float4 vMaskQuad;                  // Offset:  272 Size:    16 [unused]
+//   float4x4 mBackdropTransform;       // Offset:  288 Size:    64 [unused]
+//
+// }
+//
+//
+// Resource Bindings:
+//
+// Name                                 Type  Format         Dim Slot Elements
+// ------------------------------ ---------- ------- ----------- ---- --------
+// sSampler                          sampler      NA          NA    0        1
+// tY                                texture  float4          2d    1        1
+// tCb                               texture  float4          2d    2        1
+// tMask                             texture  float4          2d    5        1
+// $Globals                          cbuffer      NA          NA    0        1
+//
+//
+//
+// Input signature:
+//
+// Name                 Index   Mask Register SysValue  Format   Used
+// -------------------- ----- ------ -------- -------- ------- ------
+// SV_Position              0   xyzw        0      POS   float       
+// TEXCOORD                 0   xy          1     NONE   float   xy  
+// TEXCOORD                 1   xyz         2     NONE   float   xyz 
+//
+//
+// Output signature:
+//
+// Name                 Index   Mask Register SysValue  Format   Used
+// -------------------- ----- ------ -------- -------- ------- ------
+// SV_Target                0   xyzw        0   TARGET   float   xyzw
+//
+//
+// Constant buffer to DX9 shader constant mappings:
+//
+// Target Reg Buffer  Start Reg # of Regs        Data Conversion
+// ---------- ------- --------- --------- ----------------------
+// c0         cb0             1         1  ( FLT, FLT, FLT, FLT)
+// c1         cb0             3         3  ( FLT, FLT, FLT, FLT)
+//
+//
+// Sampler/Resource to DX9 shader sampler mappings:
+//
+// Target Sampler Source Sampler  Source Resource
+// -------------- --------------- ----------------
+// s0             s0              t1               
+// s1             s0              t2               
+// s2             s0              t5               
+//
+//
+// Level9 shader bytecode:
+//
+    ps_2_x
+    def c4, -0.0627499968, -0.50195998, 1, 0
+    dcl t0.xy
+    dcl t1.xyz
+    dcl_2d s0
+    dcl_2d s1
+    dcl_2d s2
+    mov r0.w, c4.z
+    texld r1, t0, s1
+    texld r2, t0, s0
+    add r2.x, r2.x, c4.x
+    add r2.yz, r1.xxyw, c4.y
+    dp3 r0.x, c1, r2
+    dp3 r0.y, c2, r2
+    dp3 r0.z, c3, r2
+    mul r0, r0, c0.x
+    rcp r1.x, t1.z
+    mul r1.xy, r1.x, t1
+    texld r1, r1, s2
+    mul r0, r0, r1.x
+    mov oC0, r0
+
+// approximately 14 instruction slots used (3 texture, 11 arithmetic)
+ps_4_0
+dcl_constantbuffer cb0[6], immediateIndexed
+dcl_sampler s0, mode_default
+dcl_resource_texture2d (float,float,float,float) t1
+dcl_resource_texture2d (float,float,float,float) t2
+dcl_resource_texture2d (float,float,float,float) t5
+dcl_input_ps linear v1.xy
+dcl_input_ps linear v2.xyz
+dcl_output o0.xyzw
+dcl_temps 3
+mov r0.w, l(1.000000)
+sample r1.xyzw, v1.xyxx, t1.xyzw, s0
+add r1.x, r1.x, l(-0.062750)
+sample r2.xyzw, v1.xyxx, t2.xyzw, s0
+add r1.yz, r2.xxyx, l(0.000000, -0.501960, -0.501960, 0.000000)
+dp3 r0.x, cb0[3].xyzx, r1.xyzx
+dp3 r0.y, cb0[4].xyzx, r1.xyzx
+dp3 r0.z, cb0[5].xyzx, r1.xyzx
+mul r0.xyzw, r0.xyzw, cb0[1].xxxx
+div r1.xy, v2.xyxx, v2.zzzz
+sample r1.xyzw, r1.xyxx, t5.xyzw, s0
+mul o0.xyzw, r0.xyzw, r1.xxxx
+ret 
+// Approximately 13 instruction slots used
+#endif
+
+const BYTE NV12ShaderMask[] =
+{
+     68,  88,  66,  67,  33, 240, 
+     18,  59,  15, 160,   9, 125, 
+    220, 233, 156, 176, 226,  26, 
+    112, 172,   1,   0,   0,   0, 
+     28,   8,   0,   0,   6,   0, 
+      0,   0,  56,   0,   0,   0, 
+    184,   1,   0,   0, 192,   3, 
+      0,   0,  60,   4,   0,   0, 
+    120,   7,   0,   0, 232,   7, 
+      0,   0,  65, 111, 110,  57, 
+    120,   1,   0,   0, 120,   1, 
+      0,   0,   0,   2, 255, 255, 
+     48,   1,   0,   0,  72,   0, 
+      0,   0,   2,   0,  48,   0, 
+      0,   0,  72,   0,   0,   0, 
+     72,   0,   3,   0,  36,   0, 
+      0,   0,  72,   0,   1,   0, 
+      0,   0,   2,   0,   1,   0, 
+      5,   0,   2,   0,   0,   0, 
+      1,   0,   1,   0,   0,   0, 
+      0,   0,   0,   0,   0,   0, 
+      3,   0,   3,   0,   1,   0, 
+      0,   0,   0,   0,   1,   2, 
+    255, 255,  81,   0,   0,   5, 
+      4,   0,  15, 160,  18, 131, 
+    128, 189, 115, 128,   0, 191, 
+      0,   0, 128,  63,   0,   0, 
+      0,   0,  31,   0,   0,   2, 
+      0,   0,   0, 128,   0,   0, 
+      3, 176,  31,   0,   0,   2, 
+      0,   0,   0, 128,   1,   0, 
+      7, 176,  31,   0,   0,   2, 
+      0,   0,   0, 144,   0,   8, 
+     15, 160,  31,   0,   0,   2, 
+      0,   0,   0, 144,   1,   8, 
+     15, 160,  31,   0,   0,   2, 
+      0,   0,   0, 144,   2,   8, 
+     15, 160,   1,   0,   0,   2, 
+      0,   0,   8, 128,   4,   0, 
+    170, 160,  66,   0,   0,   3, 
+      1,   0,  15, 128,   0,   0, 
+    228, 176,   1,   8, 228, 160, 
+     66,   0,   0,   3,   2,   0, 
+     15, 128,   0,   0, 228, 176, 
+      0,   8, 228, 160,   2,   0, 
+      0,   3,   2,   0,   1, 128, 
+      2,   0,   0, 128,   4,   0, 
+      0, 160,   2,   0,   0,   3, 
+      2,   0,   6, 128,   1,   0, 
+    208, 128,   4,   0,  85, 160, 
+      8,   0,   0,   3,   0,   0, 
+      1, 128,   1,   0, 228, 160, 
+      2,   0, 228, 128,   8,   0, 
+      0,   3,   0,   0,   2, 128, 
+      2,   0, 228, 160,   2,   0, 
+    228, 128,   8,   0,   0,   3, 
+      0,   0,   4, 128,   3,   0, 
+    228, 160,   2,   0, 228, 128, 
+      5,   0,   0,   3,   0,   0, 
+     15, 128,   0,   0, 228, 128, 
+      0,   0,   0, 160,   6,   0, 
+      0,   2,   1,   0,   1, 128, 
+      1,   0, 170, 176,   5,   0, 
+      0,   3,   1,   0,   3, 128, 
+      1,   0,   0, 128,   1,   0, 
+    228, 176,  66,   0,   0,   3, 
+      1,   0,  15, 128,   1,   0, 
+    228, 128,   2,   8, 228, 160, 
+      5,   0,   0,   3,   0,   0, 
+     15, 128,   0,   0, 228, 128, 
+      1,   0,   0, 128,   1,   0, 
+      0,   2,   0,   8,  15, 128, 
+      0,   0, 228, 128, 255, 255, 
+      0,   0,  83,  72,  68,  82, 
+      0,   2,   0,   0,  64,   0, 
+      0,   0, 128,   0,   0,   0, 
+     89,   0,   0,   4,  70, 142, 
+     32,   0,   0,   0,   0,   0, 
+      6,   0,   0,   0,  90,   0, 
+      0,   3,   0,  96,  16,   0, 
+      0,   0,   0,   0,  88,  24, 
+      0,   4,   0, 112,  16,   0, 
+      1,   0,   0,   0,  85,  85, 
+      0,   0,  88,  24,   0,   4, 
+      0, 112,  16,   0,   2,   0, 
+      0,   0,  85,  85,   0,   0, 
+     88,  24,   0,   4,   0, 112, 
+     16,   0,   5,   0,   0,   0, 
+     85,  85,   0,   0,  98,  16, 
+      0,   3,  50,  16,  16,   0, 
+      1,   0,   0,   0,  98,  16, 
+      0,   3, 114,  16,  16,   0, 
+      2,   0,   0,   0, 101,   0, 
+      0,   3, 242,  32,  16,   0, 
+      0,   0,   0,   0, 104,   0, 
+      0,   2,   3,   0,   0,   0, 
+     54,   0,   0,   5, 130,   0, 
+     16,   0,   0,   0,   0,   0, 
+      1,  64,   0,   0,   0,   0, 
+    128,  63,  69,   0,   0,   9, 
+    242,   0,  16,   0,   1,   0, 
+      0,   0,  70,  16,  16,   0, 
+      1,   0,   0,   0,  70, 126, 
+     16,   0,   1,   0,   0,   0, 
+      0,  96,  16,   0,   0,   0, 
+      0,   0,   0,   0,   0,   7, 
+     18,   0,  16,   0,   1,   0, 
+      0,   0,  10,   0,  16,   0, 
+      1,   0,   0,   0,   1,  64, 
+      0,   0,  18, 131, 128, 189, 
+     69,   0,   0,   9, 242,   0, 
+     16,   0,   2,   0,   0,   0, 
+     70,  16,  16,   0,   1,   0, 
+      0,   0,  70, 126,  16,   0, 
+      2,   0,   0,   0,   0,  96, 
+     16,   0,   0,   0,   0,   0, 
+      0,   0,   0,  10,  98,   0, 
+     16,   0,   1,   0,   0,   0, 
+      6,   1,  16,   0,   2,   0, 
+      0,   0,   2,  64,   0,   0, 
+      0,   0,   0,   0, 115, 128, 
+      0, 191, 115, 128,   0, 191, 
+      0,   0,   0,   0,  16,   0, 
+      0,   8,  18,   0,  16,   0, 
+      0,   0,   0,   0,  70, 130, 
+     32,   0,   0,   0,   0,   0, 
+      3,   0,   0,   0,  70,   2, 
+     16,   0,   1,   0,   0,   0, 
+     16,   0,   0,   8,  34,   0, 
+     16,   0,   0,   0,   0,   0, 
+     70, 130,  32,   0,   0,   0, 
+      0,   0,   4,   0,   0,   0, 
+     70,   2,  16,   0,   1,   0, 
+      0,   0,  16,   0,   0,   8, 
+     66,   0,  16,   0,   0,   0, 
+      0,   0,  70, 130,  32,   0, 
+      0,   0,   0,   0,   5,   0, 
+      0,   0,  70,   2,  16,   0, 
+      1,   0,   0,   0,  56,   0, 
+      0,   8, 242,   0,  16,   0, 
+      0,   0,   0,   0,  70,  14, 
+     16,   0,   0,   0,   0,   0, 
+      6, 128,  32,   0,   0,   0, 
+      0,   0,   1,   0,   0,   0, 
+     14,   0,   0,   7,  50,   0, 
+     16,   0,   1,   0,   0,   0, 
+     70,  16,  16,   0,   2,   0, 
+      0,   0, 166,  26,  16,   0, 
+      2,   0,   0,   0,  69,   0, 
+      0,   9, 242,   0,  16,   0, 
+      1,   0,   0,   0,  70,   0, 
+     16,   0,   1,   0,   0,   0, 
+     70, 126,  16,   0,   5,   0, 
+      0,   0,   0,  96,  16,   0, 
+      0,   0,   0,   0,  56,   0, 
+      0,   7, 242,  32,  16,   0, 
+      0,   0,   0,   0,  70,  14, 
+     16,   0,   0,   0,   0,   0, 
+      6,   0,  16,   0,   1,   0, 
+      0,   0,  62,   0,   0,   1, 
+     83,  84,  65,  84, 116,   0, 
+      0,   0,  13,   0,   0,   0, 
+      3,   0,   0,   0,   0,   0, 
+      0,   0,   3,   0,   0,   0, 
+      8,   0,   0,   0,   0,   0, 
+      0,   0,   0,   0,   0,   0, 
+      1,   0,   0,   0,   0,   0, 
+      0,   0,   0,   0,   0,   0, 
+      0,   0,   0,   0,   0,   0, 
+      0,   0,   0,   0,   0,   0, 
+      0,   0,   0,   0,   3,   0, 
+      0,   0,   0,   0,   0,   0, 
+      0,   0,   0,   0,   0,   0, 
+      0,   0,   0,   0,   0,   0, 
+      1,   0,   0,   0,   0,   0, 
+      0,   0,   0,   0,   0,   0, 
+      0,   0,   0,   0,   0,   0, 
+      0,   0,   0,   0,   0,   0, 
+      0,   0,   0,   0,   0,   0, 
+      0,   0,   0,   0,   0,   0, 
+      0,   0,   0,   0,  82,  68, 
+     69,  70,  52,   3,   0,   0, 
+      1,   0,   0,   0, 220,   0, 
+      0,   0,   5,   0,   0,   0, 
+     28,   0,   0,   0,   0,   4, 
+    255, 255,   0,   1,   0,   0, 
+      0,   3,   0,   0, 188,   0, 
+      0,   0,   3,   0,   0,   0, 
+      0,   0,   0,   0,   0,   0, 
+      0,   0,   0,   0,   0,   0, 
+      0,   0,   0,   0,   1,   0, 
+      0,   0,   1,   0,   0,   0, 
+    197,   0,   0,   0,   2,   0, 
+      0,   0,   5,   0,   0,   0, 
+      4,   0,   0,   0, 255, 255, 
+    255, 255,   1,   0,   0,   0, 
+      1,   0,   0,   0,  13,   0, 
+      0,   0, 200,   0,   0,   0, 
+      2,   0,   0,   0,   5,   0, 
+      0,   0,   4,   0,   0,   0, 
+    255, 255, 255, 255,   2,   0, 
+      0,   0,   1,   0,   0,   0, 
+     13,   0,   0,   0, 204,   0, 
+      0,   0,   2,   0,   0,   0, 
+      5,   0,   0,   0,   4,   0, 
+      0,   0, 255, 255, 255, 255, 
+      5,   0,   0,   0,   1,   0, 
+      0,   0,  13,   0,   0,   0, 
+    210,   0,   0,   0,   0,   0, 
+      0,   0,   0,   0,   0,   0, 
+      0,   0,   0,   0,   0,   0, 
+      0,   0,   0,   0,   0,   0, 
+      1,   0,   0,   0,   0,   0, 
+      0,   0, 115,  83,  97, 109, 
+    112, 108, 101, 114,   0, 116, 
+     89,   0, 116,  67,  98,   0, 
+    116,  77,  97, 115, 107,   0, 
+     36,  71, 108, 111,  98,  97, 
+    108, 115,   0, 171, 210,   0, 
+      0,   0,  11,   0,   0,   0, 
+    244,   0,   0,   0,  96,   1, 
+      0,   0,   0,   0,   0,   0, 
+      0,   0,   0,   0, 252,   1, 
+      0,   0,   0,   0,   0,   0, 
+     16,   0,   0,   0,   0,   0, 
+      0,   0,   8,   2,   0,   0, 
+      0,   0,   0,   0,  24,   2, 
+      0,   0,  16,   0,   0,   0, 
+      4,   0,   0,   0,   2,   0, 
+      0,   0,  40,   2,   0,   0, 
+      0,   0,   0,   0,  56,   2, 
+      0,   0,  32,   0,   0,   0, 
+     16,   0,   0,   0,   0,   0, 
+      0,   0,  72,   2,   0,   0, 
+      0,   0,   0,   0,  88,   2, 
+      0,   0,  48,   0,   0,   0, 
+     44,   0,   0,   0,   2,   0, 
+      0,   0, 104,   2,   0,   0, 
+      0,   0,   0,   0, 120,   2, 
+      0,   0,  96,   0,   0,   0, 
+     64,   0,   0,   0,   0,   0, 
+      0,   0, 136,   2,   0,   0, 
+      0,   0,   0,   0, 152,   2, 
+      0,   0, 160,   0,   0,   0, 
+     64,   0,   0,   0,   0,   0, 
+      0,   0, 136,   2,   0,   0, 
+      0,   0,   0,   0, 164,   2, 
+      0,   0, 224,   0,   0,   0, 
+     16,   0,   0,   0,   0,   0, 
+      0,   0,   8,   2,   0,   0, 
+      0,   0,   0,   0, 184,   2, 
+      0,   0, 240,   0,   0,   0, 
+     16,   0,   0,   0,   0,   0, 
+      0,   0, 200,   2,   0,   0, 
+      0,   0,   0,   0, 216,   2, 
+      0,   0,   0,   1,   0,   0, 
+     16,   0,   0,   0,   0,   0, 
+      0,   0, 200,   2,   0,   0, 
+      0,   0,   0,   0, 227,   2, 
+      0,   0,  16,   1,   0,   0, 
+     16,   0,   0,   0,   0,   0, 
+      0,   0, 200,   2,   0,   0, 
+      0,   0,   0,   0, 237,   2, 
+      0,   0,  32,   1,   0,   0, 
+     64,   0,   0,   0,   0,   0, 
+      0,   0, 136,   2,   0,   0, 
+      0,   0,   0,   0, 102,  76, 
+     97, 121, 101, 114,  67, 111, 
+    108, 111, 114,   0,   1,   0, 
+      3,   0,   1,   0,   4,   0, 
+      0,   0,   0,   0,   0,   0, 
+      0,   0, 102,  76,  97, 121, 
+    101, 114,  79, 112,  97,  99, 
+    105, 116, 121,   0, 171, 171, 
+      0,   0,   3,   0,   1,   0, 
+      1,   0,   0,   0,   0,   0, 
+      0,   0,   0,   0, 105,  66, 
+    108, 101, 110, 100,  67, 111, 
+    110, 102, 105, 103,   0, 171, 
+    171, 171,   1,   0,  19,   0, 
+      1,   0,   4,   0,   0,   0, 
+      0,   0,   0,   0,   0,   0, 
+    109,  89, 117, 118,  67, 111, 
+    108, 111, 114,  77,  97, 116, 
+    114, 105, 120,   0,   2,   0, 
+      3,   0,   3,   0,   3,   0, 
+      0,   0,   0,   0,   0,   0, 
+      0,   0, 109,  76,  97, 121, 
+    101, 114,  84, 114,  97, 110, 
+    115, 102, 111, 114, 109,   0, 
+      3,   0,   3,   0,   4,   0, 
+      4,   0,   0,   0,   0,   0, 
+      0,   0,   0,   0, 109,  80, 
+    114, 111, 106, 101,  99, 116, 
+    105, 111, 110,   0, 118,  82, 
+    101, 110, 100, 101, 114,  84, 
+     97, 114, 103, 101, 116,  79, 
+    102, 102, 115, 101, 116,   0, 
+    118,  84, 101, 120, 116, 117, 
+    114, 101,  67, 111, 111, 114, 
+    100, 115,   0, 171,   1,   0, 
+      3,   0,   1,   0,   4,   0, 
+      0,   0,   0,   0,   0,   0, 
+      0,   0, 118,  76,  97, 121, 
+    101, 114,  81, 117,  97, 100, 
+      0, 118,  77,  97, 115, 107, 
+     81, 117,  97, 100,   0, 109, 
+     66,  97,  99, 107, 100, 114, 
+    111, 112,  84, 114,  97, 110, 
+    115, 102, 111, 114, 109,   0, 
+     77, 105,  99, 114, 111, 115, 
+    111, 102, 116,  32,  40,  82, 
+     41,  32,  72,  76,  83,  76, 
+     32,  83, 104,  97, 100, 101, 
+    114,  32,  67, 111, 109, 112, 
+    105, 108, 101, 114,  32,  54, 
+     46,  51,  46,  57,  54,  48, 
+     48,  46,  49,  54,  51,  56, 
+     52,   0, 171, 171,  73,  83, 
+     71,  78, 104,   0,   0,   0, 
+      3,   0,   0,   0,   8,   0, 
+      0,   0,  80,   0,   0,   0, 
+      0,   0,   0,   0,   1,   0, 
+      0,   0,   3,   0,   0,   0, 
+      0,   0,   0,   0,  15,   0, 
+      0,   0,  92,   0,   0,   0, 
+      0,   0,   0,   0,   0,   0, 
+      0,   0,   3,   0,   0,   0, 
+      1,   0,   0,   0,   3,   3, 
+      0,   0,  92,   0,   0,   0, 
+      1,   0,   0,   0,   0,   0, 
+      0,   0,   3,   0,   0,   0, 
+      2,   0,   0,   0,   7,   7, 
+      0,   0,  83,  86,  95,  80, 
+    111, 115, 105, 116, 105, 111, 
+    110,   0,  84,  69,  88,  67, 
+     79,  79,  82,  68,   0, 171, 
+    171, 171,  79,  83,  71,  78, 
+     44,   0,   0,   0,   1,   0, 
+      0,   0,   8,   0,   0,   0, 
+     32,   0,   0,   0,   0,   0, 
+      0,   0,   0,   0,   0,   0, 
+      3,   0,   0,   0,   0,   0, 
+      0,   0,  15,   0,   0,   0, 
+     83,  86,  95,  84,  97, 114, 
+    103, 101, 116,   0, 171, 171
+};
+ShaderBytes sNV12ShaderMask = { NV12ShaderMask, sizeof(NV12ShaderMask) };
+#if 0
+//
+// Generated by Microsoft (R) HLSL Shader Compiler 6.3.9600.16384
 //
 //
 // Buffer Definitions: 
 //
 // cbuffer $Globals
 // {
 //
 //   float4 fLayerColor;                // Offset:    0 Size:    16 [unused]
@@ -5180,23 +6086,23 @@ ShaderBytes sYCbCrShaderMask = { YCbCrSh
 //   float4 vMaskQuad;                  // Offset:  272 Size:    16 [unused]
 //   float4x4 mBackdropTransform;       // Offset:  288 Size:    64 [unused]
 //
 // }
 //
 //
 // Resource Bindings:
 //
-// Name                                 Type  Format         Dim      HLSL Bind  Count
-// ------------------------------ ---------- ------- ----------- -------------- ------
-// sSampler                          sampler      NA          NA             s0      1 
-// tRGB                              texture  float4          2d             t0      1 
-// tRGBWhite                         texture  float4          2d             t4      1 
-// tMask                             texture  float4          2d             t5      1 
-// $Globals                          cbuffer      NA          NA            cb0      1 
+// Name                                 Type  Format         Dim Slot Elements
+// ------------------------------ ---------- ------- ----------- ---- --------
+// sSampler                          sampler      NA          NA    0        1
+// tRGB                              texture  float4          2d    0        1
+// tRGBWhite                         texture  float4          2d    4        1
+// tMask                             texture  float4          2d    5        1
+// $Globals                          cbuffer      NA          NA    0        1
 //
 //
 //
 // Input signature:
 //
 // Name                 Index   Mask Register SysValue  Format   Used
 // -------------------- ----- ------ -------- -------- ------- ------
 // SV_Position              0   xyzw        0      POS   float       
@@ -5248,17 +6154,17 @@ ShaderBytes sYCbCrShaderMask = { YCbCrSh
     mov r1.w, r2.y
     mul r2, r0.x, r2
     mul r0, r0.x, r1
     mov oC0, r0
     mov oC1, r2
 
 // approximately 13 instruction slots used (3 texture, 10 arithmetic)
 ps_4_0
-dcl_constantbuffer CB0[2], immediateIndexed
+dcl_constantbuffer cb0[2], immediateIndexed
 dcl_sampler s0, mode_default
 dcl_resource_texture2d (float,float,float,float) t0
 dcl_resource_texture2d (float,float,float,float) t4
 dcl_resource_texture2d (float,float,float,float) t5
 dcl_input_ps linear v1.xy
 dcl_input_ps linear v2.xyz
 dcl_output o0.xyzw
 dcl_output o1.xyzw
@@ -5274,25 +6180,25 @@ mov r2.w, r1.y
 mul o1.xyzw, r0.xxxx, r1.xyzw
 mul o0.xyzw, r0.xxxx, r2.xyzw
 ret 
 // Approximately 11 instruction slots used
 #endif
 
 const BYTE ComponentAlphaShaderMask[] =
 {
-     68,  88,  66,  67,  53,   1, 
-    100, 182,   2, 181, 247, 136, 
-     91, 215, 208, 183, 243,   6, 
-     78,  16,   1,   0,   0,   0, 
-    220,   7,   0,   0,   6,   0, 
+     68,  88,  66,  67, 146, 223, 
+    184,  52, 165,  15,  33,  27, 
+    188, 224, 169,  72,  82, 118, 
+     81,  24,   1,   0,   0,   0, 
+    232,   7,   0,   0,   6,   0, 
       0,   0,  56,   0,   0,   0, 
     152,   1,   0,   0, 108,   3, 
       0,   0, 232,   3,   0,   0, 
-     32,   7,   0,   0, 144,   7, 
+     44,   7,   0,   0, 156,   7, 
       0,   0,  65, 111, 110,  57, 
      88,   1,   0,   0,  88,   1, 
       0,   0,   0,   2, 255, 255, 
      28,   1,   0,   0,  60,   0, 
       0,   0,   1,   0,  48,   0, 
       0,   0,  60,   0,   0,   0, 
      60,   0,   3,   0,  36,   0, 
       0,   0,  60,   0,   0,   0, 
@@ -5441,17 +6347,17 @@ const BYTE ComponentAlphaShaderMask[] =
       0,   0,   0,   0,   0,   0, 
       1,   0,   0,   0,   0,   0, 
       0,   0,   0,   0,   0,   0, 
       0,   0,   0,   0,   0,   0, 
       0,   0,   0,   0,   0,   0, 
       0,   0,   0,   0,   0,   0, 
       0,   0,   0,   0,   0,   0, 
       0,   0,   0,   0,  82,  68, 
-     69,  70,  48,   3,   0,   0, 
+     69,  70,  60,   3,   0,   0, 
       1,   0,   0,   0, 228,   0, 
       0,   0,   5,   0,   0,   0, 
      28,   0,   0,   0,   0,   4, 
     255, 255,   0,   1,   0,   0, 
       8,   3,   0,   0, 188,   0, 
       0,   0,   3,   0,   0,   0, 
       0,   0,   0,   0,   0,   0, 
       0,   0,   0,   0,   0,   0, 
@@ -5577,17 +6483,19 @@ const BYTE ComponentAlphaShaderMask[] =
     100, 114, 111, 112,  84, 114, 
      97, 110, 115, 102, 111, 114, 
     109,   0,  77, 105,  99, 114, 
     111, 115, 111, 102, 116,  32, 
      40,  82,  41,  32,  72,  76, 
      83,  76,  32,  83, 104,  97, 
     100, 101, 114,  32,  67, 111, 
     109, 112, 105, 108, 101, 114, 
-     32,  49,  48,  46,  49,   0, 
+     32,  54,  46,  51,  46,  57, 
+     54,  48,  48,  46,  49,  54, 
+     51,  56,  52,   0, 171, 171, 
      73,  83,  71,  78, 104,   0, 
       0,   0,   3,   0,   0,   0, 
       8,   0,   0,   0,  80,   0, 
       0,   0,   0,   0,   0,   0, 
       1,   0,   0,   0,   3,   0, 
       0,   0,   0,   0,   0,   0, 
      15,   0,   0,   0,  92,   0, 
       0,   0,   0,   0,   0,   0, 
@@ -5614,17 +6522,17 @@ const BYTE ComponentAlphaShaderMask[] =
       1,   0,   0,   0,  15,   0, 
       0,   0,  83,  86,  95,  84, 
      97, 114, 103, 101, 116,   0, 
     171, 171
 };
 ShaderBytes sComponentAlphaShaderMask = { ComponentAlphaShaderMask, sizeof(ComponentAlphaShaderMask) };
 #if 0
 //
-// Generated by Microsoft (R) HLSL Shader Compiler 10.1
+// Generated by Microsoft (R) HLSL Shader Compiler 6.3.9600.16384
 //
 //
 // Buffer Definitions: 
 //
 // cbuffer $Globals
 // {
 //
 //   float4x4 mLayerTransform;          // Offset:    0 Size:    64
@@ -5639,19 +6547,19 @@ ShaderBytes sComponentAlphaShaderMask = 
 //   uint4 iBlendConfig;                // Offset:  288 Size:    16 [unused]
 //   row_major float3x3 mYuvColorMatrix;// Offset:  304 Size:    44 [unused]
 //
 // }
 //
 //
 // Resource Bindings:
 //
-// Name                                 Type  Format         Dim      HLSL Bind  Count
-// ------------------------------ ---------- ------- ----------- -------------- ------
-// $Globals                          cbuffer      NA          NA            cb0      1 
+// Name                                 Type  Format         Dim Slot Elements
+// ------------------------------ ---------- ------- ----------- ---- --------
+// $Globals                          cbuffer      NA          NA    0        1
 //
 //
 //
 // Input signature:
 //
 // Name                 Index   Mask Register SysValue  Format   Used
 // -------------------- ----- ------ -------- -------- ------- ------
 // POSITION                 0   xy          0     NONE   float   xy  
@@ -5709,17 +6617,17 @@ ShaderBytes sComponentAlphaShaderMask = 
     mad r1.xy, c11.yxzw, r1.x, r1.yzzw
     add oT0.zw, r1.xyxy, c13.xyyx
     mad oPos.xy, r0.w, c0, r0
     mov oPos.zw, r0
     mov oT1.xyz, c14.z
 
 // approximately 22 instruction slots used
 vs_4_0
-dcl_constantbuffer CB0[16], immediateIndexed
+dcl_constantbuffer cb0[16], immediateIndexed
 dcl_input v0.xy
 dcl_output_siv o0.xyzw, position
 dcl_output o1.xy
 dcl_output o1.zw
 dcl_output o2.xyz
 dcl_temps 2
 mad r0.xy, v0.xyxx, cb0[10].zwzz, cb0[10].xyxx
 mul r1.xyzw, r0.yyyy, cb0[1].xyzw
@@ -5742,25 +6650,25 @@ add o1.zw, r0.xxxy, cb0[15].xxxy
 mad o1.xy, v0.xyxx, cb0[9].zwzz, cb0[9].xyxx
 mov o2.xyz, l(0,0,0,0)
 ret 
 // Approximately 21 instruction slots used
 #endif
 
 const BYTE LayerQuadBlendVS[] =
 {
-     68,  88,  66,  67,  36,   1, 
-    251,  17, 122,  90,  56,  20, 
-     13, 210,  38,  20, 162, 170, 
-    120, 203,   1,   0,   0,   0, 
-     56,   9,   0,   0,   6,   0, 
+     68,  88,  66,  67, 118, 221, 
+    235, 142,  96,  69, 211, 182, 
+    164, 123,  38, 107,  11,  42, 
+    161,  69,   1,   0,   0,   0, 
+     68,   9,   0,   0,   6,   0, 
       0,   0,  56,   0,   0,   0, 
      60,   2,   0,   0, 100,   5, 
       0,   0, 224,   5,   0,   0, 
-    124,   8,   0,   0, 176,   8, 
+    136,   8,   0,   0, 188,   8, 
       0,   0,  65, 111, 110,  57, 
     252,   1,   0,   0, 252,   1, 
       0,   0,   0,   2, 254, 255, 
     164,   1,   0,   0,  88,   0, 
       0,   0,   4,   0,  36,   0, 
       0,   0,  84,   0,   0,   0, 
      84,   0,   0,   0,  36,   0, 
       1,   0,  84,   0,   0,   0, 
@@ -5993,17 +6901,17 @@ const BYTE LayerQuadBlendVS[] =
       0,   0,   0,   0,   0,   0, 
       2,   0,   0,   0,   0,   0, 
       0,   0,   0,   0,   0,   0, 
       0,   0,   0,   0,   0,   0, 
       0,   0,   0,   0,   0,   0, 
       0,   0,   0,   0,   0,   0, 
       0,   0,   0,   0,   0,   0, 
       0,   0,   0,   0,  82,  68, 
-     69,  70, 148,   2,   0,   0, 
+     69,  70, 160,   2,   0,   0, 
       1,   0,   0,   0,  72,   0, 
       0,   0,   1,   0,   0,   0, 
      28,   0,   0,   0,   0,   4, 
     254, 255,   0,   1,   0,   0, 
     108,   2,   0,   0,  60,   0, 
       0,   0,   0,   0,   0,   0, 
       0,   0,   0,   0,   0,   0, 
       0,   0,   0,   0,   0,   0, 
@@ -6103,17 +7011,19 @@ const BYTE LayerQuadBlendVS[] =
       3,   0,   3,   0,   3,   0, 
       0,   0,   0,   0,   0,   0, 
       0,   0,  77, 105,  99, 114, 
     111, 115, 111, 102, 116,  32, 
      40,  82,  41,  32,  72,  76, 
      83,  76,  32,  83, 104,  97, 
     100, 101, 114,  32,  67, 111, 
     109, 112, 105, 108, 101, 114, 
-     32,  49,  48,  46,  49,   0, 
+     32,  54,  46,  51,  46,  57, 
+     54,  48,  48,  46,  49,  54, 
+     51,  56,  52,   0, 171, 171, 
      73,  83,  71,  78,  44,   0, 
       0,   0,   1,   0,   0,   0, 
       8,   0,   0,   0,  32,   0, 
       0,   0,   0,   0,   0,   0, 
       0,   0,   0,   0,   3,   0, 
       0,   0,   0,   0,   0,   0, 
       3,   3,   0,   0,  80,  79, 
      83,  73,  84,  73,  79,  78, 
@@ -6140,17 +7050,17 @@ const BYTE LayerQuadBlendVS[] =
     111, 115, 105, 116, 105, 111, 
     110,   0,  84,  69,  88,  67, 
      79,  79,  82,  68,   0, 171, 
     171, 171
 };
 ShaderBytes sLayerQuadBlendVS = { LayerQuadBlendVS, sizeof(LayerQuadBlendVS) };
 #if 0
 //
-// Generated by Microsoft (R) HLSL Shader Compiler 10.1
+// Generated by Microsoft (R) HLSL Shader Compiler 6.3.9600.16384
 //
 //
 // Buffer Definitions: 
 //
 // cbuffer $Globals
 // {
 //
 //   float4x4 mLayerTransform;          // Offset:    0 Size:    64
@@ -6165,19 +7075,19 @@ ShaderBytes sLayerQuadBlendVS = { LayerQ
 //   uint4 iBlendConfig;                // Offset:  288 Size:    16 [unused]
 //   row_major float3x3 mYuvColorMatrix;// Offset:  304 Size:    44 [unused]
 //
 // }
 //
 //
 // Resource Bindings:
 //
-// Name                                 Type  Format         Dim      HLSL Bind  Count
-// ------------------------------ ---------- ------- ----------- -------------- ------
-// $Globals                          cbuffer      NA          NA            cb0      1 
+// Name                                 Type  Format         Dim Slot Elements
+// ------------------------------ ---------- ------- ----------- ---- --------
+// $Globals                          cbuffer      NA          NA    0        1
 //
 //
 //
 // Input signature:
 //
 // Name                 Index   Mask Register SysValue  Format   Used
 // -------------------- ----- ------ -------- -------- ------- ------
 // POSITION                 0   xy          0     NONE   float   xy  
@@ -6240,17 +7150,17 @@ ShaderBytes sLayerQuadBlendVS = { LayerQ
     mul r1.yz, r1.y, c13.xyxw
     mad r1.xy, c12.yxzw, r1.x, r1.yzzw
     add oT0.zw, r1.xyxy, c14.xyyx
     mad oPos.xy, r0.w, c0, r0
     mov oPos.zw, r0
 
 // approximately 28 instruction slots used
 vs_4_0
-dcl_constantbuffer CB0[16], immediateIndexed
+dcl_constantbuffer cb0[16], immediateIndexed
 dcl_input v0.xy
 dcl_output_siv o0.xyzw, position
 dcl_output o1.xy
 dcl_output o1.zw
 dcl_output o2.xyz
 dcl_temps 4
 mad r0.xy, v0.xyxx, cb0[10].zwzz, cb0[10].xyxx
 mul r1.xyzw, r0.yyyy, cb0[1].xyzw
@@ -6277,25 +7187,25 @@ div r0.xy, r0.xyxx, cb0[11].zwzz
 mov r0.z, l(1.000000)
 mul o2.xyz, r1.wwww, r0.xyzx
 ret 
 // Approximately 25 instruction slots used
 #endif
 
 const BYTE LayerQuadBlendMaskVS[] =
 {
-     68,  88,  66,  67, 206, 205, 
-    172,  45,  15, 157, 207,  85, 
-    247,  28, 223, 137,  10,  58, 
-     17, 237,   1,   0,   0,   0, 
-    236,   9,   0,   0,   6,   0, 
+     68,  88,  66,  67, 196, 248, 
+     25, 209, 193, 147,  20, 174, 
+     68,  77, 116,  97, 162, 166, 
+    205, 199,   1,   0,   0,   0, 
+    248,   9,   0,   0,   6,   0, 
       0,   0,  56,   0,   0,   0, 
     136,   2,   0,   0,  24,   6, 
       0,   0, 148,   6,   0,   0, 
-     48,   9,   0,   0, 100,   9, 
+     60,   9,   0,   0, 112,   9, 
       0,   0,  65, 111, 110,  57, 
      72,   2,   0,   0,  72,   2, 
       0,   0,   0,   2, 254, 255, 
     252,   1,   0,   0,  76,   0, 
       0,   0,   3,   0,  36,   0, 
       0,   0,  72,   0,   0,   0, 
      72,   0,   0,   0,  36,   0, 
       1,   0,  72,   0,   0,   0, 
@@ -6558,17 +7468,17 @@ const BYTE LayerQuadBlendMaskVS[] =
       0,   0,   0,   0,   0,   0, 
       3,   0,   0,   0,   0,   0, 
       0,   0,   0,   0,   0,   0, 
       0,   0,   0,   0,   0,   0, 
       0,   0,   0,   0,   0,   0, 
       0,   0,   0,   0,   0,   0, 
       0,   0,   0,   0,   0,   0, 
       0,   0,   0,   0,  82,  68, 
-     69,  70, 148,   2,   0,   0, 
+     69,  70, 160,   2,   0,   0, 
       1,   0,   0,   0,  72,   0, 
       0,   0,   1,   0,   0,   0, 
      28,   0,   0,   0,   0,   4, 
     254, 255,   0,   1,   0,   0, 
     108,   2,   0,   0,  60,   0, 
       0,   0,   0,   0,   0,   0, 
       0,   0,   0,   0,   0,   0, 
       0,   0,   0,   0,   0,   0, 
@@ -6668,17 +7578,19 @@ const BYTE LayerQuadBlendMaskVS[] =
       3,   0,   3,   0,   3,   0, 
       0,   0,   0,   0,   0,   0, 
       0,   0,  77, 105,  99, 114, 
     111, 115, 111, 102, 116,  32, 
      40,  82,  41,  32,  72,  76, 
      83,  76,  32,  83, 104,  97, 
     100, 101, 114,  32,  67, 111, 
     109, 112, 105, 108, 101, 114, 
-     32,  49,  48,  46,  49,   0, 
+     32,  54,  46,  51,  46,  57, 
+     54,  48,  48,  46,  49,  54, 
+     51,  56,  52,   0, 171, 171, 
      73,  83,  71,  78,  44,   0, 
       0,   0,   1,   0,   0,   0, 
       8,   0,   0,   0,  32,   0, 
       0,   0,   0,   0,   0,   0, 
       0,   0,   0,   0,   3,   0, 
       0,   0,   0,   0,   0,   0, 
       3,   3,   0,   0,  80,  79, 
      83,  73,  84,  73,  79,  78, 
@@ -6705,17 +7617,17 @@ const BYTE LayerQuadBlendMaskVS[] =
     111, 115, 105, 116, 105, 111, 
     110,   0,  84,  69,  88,  67, 
      79,  79,  82,  68,   0, 171, 
     171, 171
 };
 ShaderBytes sLayerQuadBlendMaskVS = { LayerQuadBlendMaskVS, sizeof(LayerQuadBlendMaskVS) };
 #if 0
 //
-// Generated by Microsoft (R) HLSL Shader Compiler 10.1
+// Generated by Microsoft (R) HLSL Shader Compiler 6.3.9600.16384
 //
 //
 // Buffer Definitions: 
 //
 // cbuffer $Globals
 // {
 //
 //   float4x4 mLayerTransform;          // Offset:    0 Size:    64
@@ -7812,26 +8724,26 @@ ShaderBytes sLayerDynamicBlendMaskVS = {
 //   float4 vMaskQuad;                  // Offset:  272 Size:    16 [unused]
 //   float4x4 mBackdropTransform;       // Offset:  288 Size:    64 [unused]
 //
 // }
 //
 //
 // Resource Bindings:
 //
-// Name                                 Type  Format         Dim      HLSL Bind  Count
-// ------------------------------ ---------- ------- ----------- -------------- ------
-// sSampler                          sampler      NA          NA             s0      1 
-// tRGB                              texture  float4          2d             t0      1 
-// tY                                texture  float4          2d             t1      1 
-// tCb                               texture  float4          2d             t2      1 
-// tCr                               texture  float4          2d             t3      1 
-// tMask                             texture  float4          2d             t5      1 
-// tBackdrop                         texture  float4          2d             t6      1 
-// $Globals                          cbuffer      NA          NA            cb0      1 
+// Name                                 Type  Format         Dim Slot Elements
+// ------------------------------ ---------- ------- ----------- ---- --------
+// sSampler                          sampler      NA          NA    0        1
+// tRGB                              texture  float4          2d    0        1
+// tY                                texture  float4          2d    1        1
+// tCb                               texture  float4          2d    2        1
+// tCr                               texture  float4          2d    3        1
+// tMask                             texture  float4          2d    5        1
+// tBackdrop                         texture  float4          2d    6        1
+// $Globals                          cbuffer      NA          NA    0        1
 //
 //
 //
 // Input signature:
 //
 // Name                 Index   Mask Register SysValue  Format   Used
 // -------------------- ----- ------ -------- -------- ------- ------
 // SV_Position              0   xyzw        0      POS   float       
@@ -7866,359 +8778,369 @@ ShaderBytes sLayerDynamicBlendMaskVS = {
 // s3             s0              t3               
 // s4             s0              t5               
 // s5             s0              t6               
 //
 //
 // Level9 shader bytecode:
 //
     ps_2_x
-    def c6, -1, -2, -0.0627499968, -0.50195998
-    def c7, -2, -3, -4, -5
-    def c8, -6, -7, -8, -9
-    def c9, 0.5, 1, 0.25, -2
-    def c10, 16, -12, -14, 0
-    def c11, -10, -11, -12, -13
-    def c12, 0.300000012, 0.589999974, 0.109999999, 0
-    def c13, -1, -0, 0, 1
+    def c6, -0.50195998, -1, -0, -0.5
+    def c7, -1, -2, -4, -0.0627499968
+    def c8, -1, -2, -3, -4
+    def c9, -5, -6, -7, -8
+    def c10, 1, 0.25, 2, -1
+    def c11, 16, -12, -13, -14
+    def c12, -9, -10, -11, -12
+    def c13, 0.300000012, 0.589999974, 0.109999999, 0
     dcl t0
     dcl t1.xyz
     dcl_2d s0
     dcl_2d s1
     dcl_2d s2
     dcl_2d s3
     dcl_2d s4
     dcl_2d s5
-    mov r0.x, c13.z
-    mov r1.x, c13.z
-    mov r2.z, c13.z
-    mov r3.w, -c6.x
-    texld r4, t0, s2
-    texld r5, t0, s1
-    add r5.x, r5.x, c6.z
-    add r5.y, r4.x, c6.w
+    mov r0.x, -c6.z
+    mov r1.x, -c6.z
+    mov r2.z, -c6.z
+    mov r3.w, -c7.x
+    texld r4, t0, s1
+    texld r5, t0, s3
+    add r5.w, r5.x, c6.x
+    add r5.x, r4.x, c7.w
     rcp r0.w, t1.z
     mul r4.xy, r0.w, t1
-    texld r6, t0, s3
+    texld r6, t0, s2
     texld r4, r4, s4
-    add r5.z, r6.x, c6.w
-    dp3 r3.x, c3, r5
-    dp3 r3.y, c4, r5
-    dp3 r3.z, c5, r5
+    add r5.yz, r6.xxyw, c6.x
+    dp3 r3.x, c3, r5.xyww
+    dp3 r3.y, c4, r5.xyww
+    dp3 r3.z, c5, r5.xyww
     mul r3, r3, c1.x
-    mul r5, r4.x, r3
-    mov r6.xy, t0.wzzw
-    texld r7, t0, s0
-    texld r6, r6, s5
-    mul r7, r7, c1.x
-    mul r8, r4.x, r7
-    mov r9.xy, c6
-    add r10, r9.xyxx, c2.xxyz
-    mul r10, r10, r10
-    cmp r5, -r10.x, r8, r5
-    cmp r3, -r10.x, r7, r3
-    mov r7.w, c1.x
-    mul r8, r4.x, r7
-    cmp r3, -c2.x, r7, r3
+    mul r6, r4.x, r3
+    dp3 r7.x, c3, r5
+    dp3 r7.y, c4, r5
+    dp3 r7.z, c5, r5
+    mov r7.w, -c7.x
+    mul r5, r7, c1.x
+    mul r7, r4.x, r5
+    mov r8.xyz, c7
+    add r9, r8.xyzx, c2.xxxy
+    mul r9, r9, r9
+    cmp r6, -r9.y, r6, r7
+    mov r7.xy, t0.wzzw
+    texld r10, t0, s0
+    texld r7, r7, s5
+    mul r10, r10, c1.x
+    mul r11, r4.x, r10
+    cmp r6, -r9.x, r11, r6
+    mov r11.xyz, r10
+    mov r11.w, c1.x
+    mul r12, r4.x, r11
     mul r4, r4.x, c0
-    cmp r5, -c2.x, r8, r5
-    cmp r7.xy, -r10.yzzw, c13.x, c13.y
-    cmp r0.w, -r10.x, c6.x, r7.x
-    cmp r1.w, -c2.y, r9.x, r7.y
-    cmp r0.w, -c2.x, r9.x, r0.w
-    cmp r4, r0.w, r4, r5
+    cmp r6, -c2.x, r12, r6
+    cmp r8.yz, -r9.xzww, c6.y, c6.z
+    cmp r0.w, -r9.y, c7.x, r8.y
+    cmp r1.w, -c2.y, r8.x, r8.z
+    cmp r0.w, -r9.x, c7.x, r0.w
+    cmp r0.w, -c2.x, r8.x, r0.w
+    cmp r4, r0.w, r4, r6
+    cmp r3, -r9.y, r3, r5
+    cmp r3, -r9.x, r10, r3
+    cmp r3, -c2.x, r11, r3
     cmp r3, r0.w, c0, r3
     cmp r3, -c2.y, r3, r4
-    cmp r3, r1.w, c13.zzzw, r3
+    cmp r3, r1.w, -c6.zzzy, r3
     rcp r0.w, r3.w
     mul r4.xyz, r0.w, r3
     cmp r4.xyz, -c2.w, r3, r4
     add r5.xy, -r4.yzzw, r4
     cmp r5.zw, r5.x, r4.xyxy, r4.xyyx
     max r0.w, r5.z, r4.z
     min r1.w, r4.z, r5.w
-    add r7.w, r0.w, -r1.w
-    rcp r0.w, r6.w
-    mul r8.xyz, r0.w, r6
-    mad r5.zw, r6.xyzy, r0.w, -r8.xyxz
-    mul r9.xy, r7.w, r5.zwzw
-    mad r11, r6.yxxz, r0.w, -r8.xzyy
-    rcp r1.w, r11.x
-    mul r7.y, r1.w, r9.x
-    cmp r1.yz, r11.z, c13.z, r7.xwyw
-    mul r12, r7.w, r11
+    add r6.w, r0.w, -r1.w
+    rcp r0.w, r7.w
+    mul r8.xyz, r0.w, r7
+    mad r5.zw, r7.xyzy, r0.w, -r8.xyxz
+    mul r9.xy, r6.w, r5.zwzw
+    mad r10, r7.yxxz, r0.w, -r8.xzyy
+    rcp r1.w, r10.x
+    mul r6.y, r1.w, r9.x
+    cmp r1.yz, r10.z, -c6.z, r6.xwyw
+    mul r11, r6.w, r10
     rcp r1.w, r5.w
-    mul r7.x, r1.w, r12.y
-    cmp r2.xy, r11.w, c13.z, r7.xwzw
+    mul r6.x, r1.w, r11.y
+    cmp r2.xy, r10.w, -c6.z, r6.xwzw
     cmp r1.xyz, r5.z, r1, r2
     rcp r1.w, r5.z
-    mul r7.z, r1.w, r12.x
-    cmp r0.yz, r11.y, c13.z, r7.xzww
-    cmp r0.xyz, r11.w, r0, r1
-    mov r1.y, c13.z
-    mov r2.y, c13.z
-    mov r10.z, c13.z
-    rcp r1.w, r11.z
-    mul r7.y, r1.w, r12.w
-    cmp r2.xz, r11.x, c13.z, r7.wyyw
-    rcp r1.w, r11.y
-    mul r7.x, r1.w, r9.y
-    cmp r10.xy, r5.z, c13.z, r7.wxzw
-    cmp r2.xyz, r11.w, r2, r10
-    rcp r1.w, r11.w
-    mul r7.z, r1.w, r12.z
-    cmp r1.xz, r5.w, c13.z, r7.zyww
+    mul r6.z, r1.w, r11.x
+    cmp r0.yz, r10.y, -c6.z, r6.xzww
+    cmp r0.xyz, r10.w, r0, r1
+    mov r1.y, -c6.z
+    mov r2.y, -c6.z
+    mov r12.z, -c6.z
+    rcp r1.w, r10.z
+    mul r6.y, r1.w, r11.w
+    cmp r2.xz, r10.x, -c6.z, r6.wyyw
+    rcp r1.w, r10.y
+    mul r6.x, r1.w, r9.y
+    cmp r12.xy, r5.z, -c6.z, r6.wxzw
+    cmp r2.xyz, r10.w, r2, r12
+    rcp r1.w, r10.w
+    mul r6.z, r1.w, r11.z
+    cmp r1.xz, r5.w, -c6.z, r6.zyww
     cmp r1.xyz, r5.z, r1, r2
-    cmp r0.xyz, r11.x, r0, r1
-    cmp r1.xy, r11.z, r8, r8.yxzw
-    dp3 r4.w, c12, r0
-    dp3 r8.w, c12, r8
+    cmp r0.xyz, r10.x, r0, r1
+    cmp r1.xy, r10.z, r8, r8.yxzw
+    dp3 r4.w, c13, r0
+    dp3 r8.w, c13, r8
     add r4.w, -r4.w, r8.w
     add r0.xyz, r0, r4.w
     add r4.w, -r0.y, r0.x
     cmp r1.zw, r4.w, r0.xyyx, r0.xyxy
     min r4.w, r0.z, r1.z
     max r2.x, r1.w, r0.z
-    dp3 r1.z, c12, r0
+    dp3 r1.z, c13, r0
     add r1.w, -r4.w, r1.z
     rcp r1.w, r1.w
     add r2.yzw, r0.xxyz, -r1.z
     mul r2.yzw, r1.z, r2
     mad r2.yzw, r2, r1.w, r1.z
     cmp r0.xyz, r4.w, r0, r2.yzww
     add r2.yzw, -r1.z, r0.xxyz
-    add r1.w, -r1.z, -c6.x
+    add r1.w, -r1.z, -c7.x
     mul r2.yzw, r1.w, r2
     add r1.w, -r1.z, r2.x
-    add r4.w, -r2.x, -c6.x
+    add r4.w, -r2.x, -c7.x
     rcp r1.w, r1.w
     mad r2.xyz, r2.yzww, r1.w, r1.z
     cmp r0.xyz, r4.w, r0, r2
     mov r4.w, c2.z
-    add r1.z, r4.w, c10.z
-    mul r1.z, r1.z, r1.z
-    dp3 r1.w, c12, r4
-    add r2.x, -r8.w, r1.w
-    add r1.w, -r1.w, r8.w
-    add r2.yzw, r1.w, r4.xxyz
-    mad r7.xyz, r6, r0.w, r2.x
-    add r1.w, -r7.y, r7.x
-    cmp r5.zw, r1.w, r7.xyyx, r7.xyxy
-    min r1.w, r7.z, r5.z
-    max r2.x, r5.w, r7.z
-    dp3 r7.w, c12, r7
-    add r5.z, -r1.w, r7.w
+    add r1.zw, r4.w, c11
+    mul r1.zw, r1, r1
+    dp3 r2.x, c13, r4
+    add r2.y, -r8.w, r2.x
+    add r2.x, -r2.x, r8.w
+    add r2.xzw, r2.x, r4.xyyz
+    mad r6.xyz, r7, r0.w, r2.y
+    add r6.w, -r6.y, r6.x
+    cmp r5.zw, r6.w, r6.xyyx, r6.xyxy
+    min r2.y, r6.z, r5.z
+    max r9.x, r5.w, r6.z
+    dp3 r6.w, c13, r6
+    add r5.z, -r2.y, r6.w
     rcp r5.z, r5.z
-    add r9.xyz, -r7.w, r7
-    mul r9.xyz, r7.w, r9
-    mad r9.xyz, r9, r5.z, r7.w
-    cmp r7.xyz, r1.w, r7, r9
-    add r9.xyz, -r7.w, r7
-    add r1.w, -r7.w, -c6.x
+    add r9.yzw, -r6.w, r6.xxyz
+    mul r9.yzw, r6.w, r9
+    mad r9.yzw, r9, r5.z, r6.w
+    cmp r6.xyz, r2.y, r6, r9.yzww
+    add r9.yzw, -r6.w, r6.xxyz
+    add r2.y, -r6.w, -c7.x
+    mul r9.yzw, r2.y, r9
+    add r2.y, -r6.w, r9.x
+    add r5.z, -r9.x, -c7.x
+    rcp r5.w, r2.y
+    mad r9.xyz, r9.yzww, r5.w, r6.w
+    cmp r6.xyz, r5.z, r6, r9
+    cmp r6.xyz, -r1.w, r6, -c6.z
+    add r1.w, -r2.z, r2.x
+    cmp r5.zw, r1.w, r2.xyzx, r2.xyxz
+    min r1.w, r2.w, r5.z
+    max r6.w, r5.w, r2.w
+    dp3 r2.y, c13, r2.xzww
+    add r5.z, -r1.w, r2.y
+    rcp r5.z, r5.z
+    add r9.xyz, -r2.y, r2.xzww
+    mul r9.xyz, r2.y, r9
+    mad r9.xyz, r9, r5.z, r2.y
+    cmp r2.xzw, r1.w, r2, r9.xyyz
+    add r9.xyz, -r2.y, r2.xzww
+    add r1.w, -r2.y, -c7.x
     mul r9.xyz, r1.w, r9
-    add r1.w, r2.x, -r7.w
-    add r9.w, -r2.x, -c6.x
+    add r1.w, -r2.y, r6.w
+    add r6.w, -r6.w, -c7.x
     rcp r1.w, r1.w
-    mad r9.xyz, r9, r1.w, r7.w
-    cmp r7.xyz, r9.w, r7, r9
-    cmp r7.xyz, -r1.z, r7, c13.z
-    add r7.w, -r2.z, r2.y
-    cmp r1.zw, r7.w, r2.xyzy, r2.xyyz
-    min r7.w, r2.w, r1.z
-    max r5.z, r1.w, r2.w
-    dp3 r5.w, c12, r2.yzww
-    add r1.z, -r7.w, r5.w
-    rcp r1.z, r1.z
-    add r9.xyz, r2.yzww, -r5.w
-    mul r9.xyz, r5.w, r9
-    mad r9.xyz, r9, r1.z, r5.w
-    cmp r2.xyz, r7.w, r2.yzww, r9
-    add r9.xyz, -r5.w, r2
-    add r2.w, -r5.w, -c6.x
-    mul r9.xyz, r2.w, r9
-    add r2.w, -r5.w, r5.z
-    add r7.w, -r5.z, -c6.x
-    rcp r2.w, r2.w
-    mad r9.xyz, r9, r2.w, r5.w
-    cmp r2.xyz, r7.w, r2, r9
-    add r9, r4.w, c11
-    mul r9, r9, r9
-    cmp r2.xyz, -r9.w, r2, r7
-    cmp r0.xyz, -r9.z, r0, r2
+    mad r9.xyz, r9, r1.w, r2.y
+    cmp r2.xyz, r6.w, r2.xzww, r9
+    cmp r2.xyz, -r1.z, r2, r6
+    add r6, r4.w, c12
+    mul r6, r6, r6
+    cmp r0.xyz, -r6.w, r0, r2
     add r2, -r4.xxzy, r4.yzxz
-    mov r7.y, c13.z
-    mov r10.y, c13.z
-    mov r11.z, c13.z
-    rcp r7.w, r2.z
-    max r11.w, r1.x, r8.z
-    min r5.z, r8.z, r1.y
-    add r1.w, -r5.z, r11.w
+    mov r9.y, -c6.z
+    mov r10.y, -c6.z
+    mov r11.z, -c6.z
+    rcp r6.w, r2.z
+    max r9.w, r1.x, r8.z
+    min r10.w, r8.z, r1.y
+    add r1.w, r9.w, -r10.w
     mul r5.zw, r1.w, r5.xyxy
-    mul r1.x, r7.w, r5.w
-    cmp r11.xy, r2.y, c13.z, r1.wxzw
+    mul r1.x, r6.w, r5.w
+    cmp r11.xy, r2.y, -c6.z, r1.wxzw
     rcp r5.w, r5.x
     mul r12, r1.w, r2
     mul r1.y, r5.w, r12.w
-    cmp r10.xz, r2.x, c13.z, r1.wyyw
+    cmp r10.xz, r2.x, -c6.z, r1.wyyw
     cmp r10.xyz, r2.w, r10, r11
     rcp r5.w, r2.w
     mul r1.z, r5.w, r5.z
-    cmp r7.xz, r5.y, c13.z, r1.zyww
-    cmp r7.xyz, r2.y, r7, r10
-    mov r10.x, c13.z
-    mov r11.x, c13.z
-    mov r13.z, c13.z
-    rcp r7.w, r2.x
-    mul r1.y, r7.w, r12.y
-    cmp r11.yz, r5.x, c13.z, r1.xwyw
-    rcp r7.w, r5.y
-    mul r1.x, r7.w, r12.z
-    cmp r13.xy, r2.w, c13.z, r1.xwzw
+    cmp r9.xz, r5.y, -c6.z, r1.zyww
+    cmp r9.xyz, r2.y, r9, r10
+    mov r10.x, -c6.z
+    mov r11.x, -c6.z
+    mov r13.z, -c6.z
+    rcp r6.w, r2.x
+    mul r1.y, r6.w, r12.y
+    cmp r11.yz, r5.x, -c6.z, r1.xwyw
+    rcp r6.w, r5.y
+    mul r1.x, r6.w, r12.z
+    cmp r13.xy, r2.w, -c6.z, r1.xwzw
     cmp r5.xyz, r2.y, r11, r13
     rcp r5.w, r2.y
     mul r1.z, r5.w, r12.x
-    cmp r10.yz, r2.z, c13.z, r1.xzww
+    cmp r10.yz, r2.z, -c6.z, r1.xzww
     cmp r1.xyz, r2.w, r10, r5
-    cmp r1.xyz, r2.x, r1, r7
-    dp3 r1.w, c12, r1
+    cmp r1.xyz, r2.x, r1, r9
+    dp3 r1.w, c13, r1
     add r1.w, -r1.w, r8.w
     add r1.xyz, r1.w, r1
     add r1.w, -r1.y, r1.x
     cmp r2.xy, r1.w, r1.yxzw, r1
-    min r8.w, r1.z, r2.x
-    max r5.x, r2.y, r1.z
-    dp3 r1.w, c12, r1
-    add r2.x, -r8.w, r1.w
+    min r6.w, r1.z, r2.x
+    max r8.w, r2.y, r1.z
+    dp3 r1.w, c13, r1
+    add r2.x, -r6.w, r1.w
     rcp r2.x, r2.x
     add r2.yzw, -r1.w, r1.xxyz
     mul r2.yzw, r1.w, r2
     mad r2.xyz, r2.yzww, r2.x, r1.w
-    cmp r1.xyz, r8.w, r1, r2
+    cmp r1.xyz, r6.w, r1, r2
     add r2.xyz, -r1.w, r1
-    add r2.w, -r1.w, -c6.x
+    add r2.w, -r1.w, -c7.x
     mul r2.xyz, r2.w, r2
-    add r2.w, -r1.w, r5.x
-    add r8.w, -r5.x, -c6.x
+    add r2.w, -r1.w, r8.w
+    add r6.w, -r8.w, -c7.x
     rcp r2.w, r2.w
     mad r2.xyz, r2, r2.w, r1.w
-    cmp r1.xyz, r8.w, r1, r2
-    cmp r0.xyz, -r9.y, r1, r0
-    mad r1.xyz, r6, r0.w, r4
+    cmp r1.xyz, r6.w, r1, r2
+    cmp r0.xyz, -r6.z, r1, r0
+    mad r1.xyz, r7, r0.w, r4
     mul r2.xyz, r4, r8
-    mad r5.xyz, r2, c6.y, r1
+    mad r5.xyz, r2, c7.y, r1
     mad r1.xyz, r8, -r4, r1
-    cmp r0.xyz, -r9.x, r5, r0
-    mad r5.xyz, r6, r0.w, -r4
+    cmp r0.xyz, -r6.y, r5, r0
+    mad r5.xyz, r7, r0.w, -r4
     abs r5.xyz, r5
-    add r7, r4.w, c8
-    mul r7, r7, r7
-    cmp r0.xyz, -r7.w, r5, r0
-    add r5.xy, -r4.yzzw, c9.x
-    mad r9.xyz, r4, -c9.w, -c9.y
-    mad r1.w, r6.z, -r0.w, c9.z
-    mad r10.xyz, r8, c10.x, c10.y
-    mad r10.xyz, r10, r8, -c7.z
-    mul r10.xyz, r8, r10
+    cmp r0.xyz, -r6.x, r5, r0
+    add r5.xy, -r4.yzzw, -c6.w
+    mad r6.xyz, r4, c10.z, c10.w
+    mad r1.w, r7.z, -r0.w, c10.y
+    mad r9.xyz, r8, c11.x, c11.y
+    mad r9.xyz, r9, r8, -c7.z
+    mul r9.xyz, r8, r9
     rsq r2.w, r8.z
     rcp r2.w, r2.w
-    cmp r1.w, r1.w, r10.z, r2.w
-    mad r1.w, r6.z, -r0.w, r1.w
-    mad r1.w, r9.z, r1.w, r8.z
-    mad r11.xyz, r4, c6.y, -c6.x
-    mul r11.xyz, r8, r11
-    mad r12, r6.yzxy, -r0.w, c9.yyzz
-    mad r5.zw, r11.xyyz, -r12.xyxy, r8.xyyz
-    cmp r13.z, r5.y, r5.w, r1.w
+    cmp r1.w, r1.w, r9.z, r2.w
+    mad r1.w, r7.z, -r0.w, r1.w
+    mad r1.w, r6.z, r1.w, r8.z
+    mad r10.xyz, r4, c7.y, -c7.x
+    mul r10.xyz, r8, r10
+    mad r11, r7.yzxy, -r0.w, c10.xxyy
+    mad r5.zw, r10.xyyz, -r11.xyxy, r8.xyyz
+    cmp r12.z, r5.y, r5.w, r1.w
     rsq r1.w, r8.y
     rcp r1.w, r1.w
-    cmp r1.w, r12.w, r10.y, r1.w
-    mad r1.w, r6.y, -r0.w, r1.w
-    mad r1.w, r9.y, r1.w, r8.y
-    cmp r13.y, r5.x, r5.z, r1.w
-    add r14, -r4.xyzx, c9.yyyx
+    cmp r1.w, r11.w, r9.y, r1.w
+    mad r1.w, r7.y, -r0.w, r1.w
+    mad r1.w, r6.y, r1.w, r8.y
+    cmp r12.y, r5.x, r5.z, r1.w
+    add r13, -r4.xyzx, -c6.yyyw
     rsq r1.w, r8.x
     rcp r1.w, r1.w
-    cmp r1.w, r12.z, r10.x, r1.w
-    mad r1.w, r6.x, -r0.w, r1.w
-    mad r1.w, r9.x, r1.w, r8.x
-    mad r9, r6.xyzx, -r0.w, c9.xxxy
-    mad r6.xyz, r6, r0.w, c6.x
-    mul r6.xyz, r6, r6
-    mad r0.w, r11.x, -r9.w, r8.x
-    cmp r13.x, r14.w, r0.w, r1.w
-    cmp r0.xyz, -r7.z, r13, r0
+    cmp r1.w, r11.z, r9.x, r1.w
+    mad r1.w, r7.x, -r0.w, r1.w
+    mad r1.w, r6.x, r1.w, r8.x
+    mad r6, r7.xyzx, -r0.w, -c6.wwwy
+    mad r7.xyz, r7, r0.w, c7.x
+    mul r7.xyz, r7, r7
+    mad r0.w, r10.x, -r6.w, r8.x
+    cmp r12.x, r13.w, r0.w, r1.w
+    add r9, r4.w, c9
+    mul r9, r9, r9
+    cmp r0.xyz, -r9.w, r12, r0
     add r10.xyz, r8, r8
-    mad r11.xyz, r4, -c6.y, r10
-    add r11.xyz, r11, c6.x
-    mad r13.xyz, r4, -r10, r11
+    mad r12.xyz, r4, -c7.y, r10
+    add r12.xyz, r12, c7.x
+    mad r14.xyz, r4, -r10, r12
     mul r10.xyz, r4, r10
     add r15.xyz, r4, r4
     mul r16.xyz, r8, r15
-    mad r11.xyz, r15, -r8, r11
-    cmp r9.xyz, r9, r10, r11
-    cmp r5.yz, r5.xxyw, r16, r13
-    cmp r5.x, r14.w, r16.x, r13.x
-    cmp r0.xyz, -r7.y, r5, r0
+    mad r12.xyz, r15, -r8, r12
+    cmp r6.xyz, r6, r10, r12
+    cmp r5.yz, r5.xxyw, r16, r14
+    cmp r5.x, r13.w, r16.x, r14.x
+    cmp r0.xyz, -r9.z, r5, r0
     rcp r0.w, r4.x
-    mad r0.w, r9.w, -r0.w, -c6.x
-    max r1.w, r0.w, c13.z
+    mad r0.w, r6.w, -r0.w, -c7.x
+    max r1.w, r0.w, -c6.z
     mul r5.xyz, r4, r4
-    cmp r0.w, -r5.x, c13.z, r1.w
-    cmp r10.x, -r6.x, -c6.x, r0.w
+    cmp r0.w, -r5.x, -c6.z, r1.w
+    cmp r10.x, -r7.x, -c7.x, r0.w
     rcp r0.w, r4.y
-    mad r0.w, r12.x, -r0.w, -c6.x
-    max r1.w, r0.w, c13.z
-    cmp r0.w, -r5.y, c13.z, r1.w
-    cmp r10.y, -r6.y, -c6.x, r0.w
+    mad r0.w, r11.x, -r0.w, -c7.x
+    max r1.w, r0.w, -c6.z
+    cmp r0.w, -r5.y, -c6.z, r1.w
+    cmp r10.y, -r7.y, -c7.x, r0.w
     rcp r0.w, r4.z
-    mad r0.w, r12.y, -r0.w, -c6.x
-    max r1.w, r0.w, c13.z
-    cmp r0.w, -r5.z, c13.z, r1.w
-    cmp r10.z, -r6.z, -c6.x, r0.w
-    cmp r0.xyz, -r7.x, r10, r0
-    add r5, r4.w, c7
+    mad r0.w, r11.y, -r0.w, -c7.x
+    max r1.w, r0.w, -c6.z
+    cmp r0.w, -r5.z, -c6.z, r1.w
+    cmp r10.z, -r7.z, -c7.x, r0.w
+    cmp r0.xyz, -r9.y, r10, r0
+    add r5.xyz, r4, c7.x
+    mul r5.xyz, r5, r5
+    rcp r0.w, r13.x
+    mul r0.w, r0.w, r8.x
+    min r1.w, r0.w, -c7.x
+    cmp r0.w, -r5.x, -c7.x, r1.w
+    mul r7.xyz, r8, r8
+    cmp r10.x, -r7.x, -c6.z, r0.w
+    rcp r0.w, r13.y
+    rcp r1.w, r13.z
+    mul r1.w, r1.w, r8.z
+    min r2.w, r1.w, -c7.x
+    cmp r1.w, -r5.z, -c7.x, r2.w
+    cmp r10.z, -r7.z, -c6.z, r1.w
+    mul r0.w, r0.w, r8.y
+    min r1.w, r0.w, -c7.x
+    cmp r0.w, -r5.y, -c7.x, r1.w
+    cmp r10.y, -r7.y, -c6.z, r0.w
+    cmp r0.xyz, -r9.x, r10, r0
+    add r5, r4.w, c8
     mul r5, r5, r5
-    add r6.xyz, r4, c6.x
-    mul r6.xyz, r6, r6
-    rcp r0.w, r14.x
-    mul r0.w, r0.w, r8.x
-    min r1.w, r0.w, -c6.x
-    cmp r0.w, -r6.x, -c6.x, r1.w
-    mul r7.xyz, r8, r8
-    cmp r10.x, -r7.x, c13.z, r0.w
-    rcp r0.w, r14.y
-    rcp r1.w, r14.z
-    mul r1.w, r1.w, r8.z
-    min r2.w, r1.w, -c6.x
-    cmp r1.w, -r6.z, -c6.x, r2.w
-    cmp r10.z, -r7.z, c13.z, r1.w
-    mul r0.w, r0.w, r8.y
-    min r1.w, r0.w, -c6.x
-    cmp r0.w, -r6.y, -c6.x, r1.w
-    cmp r10.y, -r7.y, c13.z, r0.w
-    cmp r0.xyz, -r5.w, r10, r0
-    max r6.xyz, r8, r4
-    min r7.xyz, r4, r8
-    cmp r0.xyz, -r5.z, r6, r0
-    cmp r0.xyz, -r5.y, r7, r0
-    cmp r0.xyz, -r5.x, r9, r0
-    cmp r0.xyz, -r10.w, r1, r0
+    max r7.xyz, r8, r4
+    min r9.xyz, r4, r8
+    cmp r0.xyz, -r5.w, r7, r0
+    cmp r0.xyz, -r5.z, r9, r0
+    cmp r0.xyz, -r5.y, r6, r0
+    cmp r0.xyz, -r5.x, r1, r0
     cmp r0.xyz, -c2.z, r2, r0
-    lrp r1.xyz, r6.w, r0, r4
-    mul r1.w, r6.w, r6.w
+    lrp r1.xyz, r7.w, r0, r4
+    mul r1.w, r7.w, r7.w
     mul r0.xyz, r3.w, r1
     mul r1.x, r3.w, r3.w
     mov r0.w, r3.w
-    cmp r0, -r1.x, c13.z, r0
+    cmp r0, -r1.x, -c6.z, r0
     cmp r0, -r1.w, r3, r0
     mov oC0, r0
 
-// approximately 323 instruction slots used (6 texture, 317 arithmetic)
+// approximately 333 instruction slots used (6 texture, 327 arithmetic)
 ps_4_0
-dcl_constantbuffer CB0[6], immediateIndexed
+dcl_constantbuffer cb0[6], immediateIndexed
 dcl_sampler s0, mode_default
 dcl_resource_texture2d (float,float,float,float) t0
 dcl_resource_texture2d (float,float,float,float) t1
 dcl_resource_texture2d (float,float,float,float) t2
 dcl_resource_texture2d (float,float,float,float) t3
 dcl_resource_texture2d (float,float,float,float) t5
 dcl_resource_texture2d (float,float,float,float) t6
 dcl_input_ps linear v1.xy
@@ -8235,29 +9157,43 @@ if_z cb0[2].y
     mov r2.x, l(-1)
   else 
     ieq r2.y, l(1), cb0[2].x
     if_nz r2.y
       sample r3.xyzw, v1.xyxx, t0.xyzw, s0
       mul r1.xyzw, r3.xyzw, cb0[1].xxxx
       mov r2.x, l(-1)
     else 
-      ieq r2.x, l(2), cb0[2].x
-      if_nz r2.x
+      ieq r2.y, l(2), cb0[2].x
+      if_nz r2.y
         sample r3.xyzw, v1.xyxx, t1.xyzw, s0
         add r3.x, r3.x, l(-0.062750)
         sample r4.xyzw, v1.xyxx, t2.xyzw, s0
         add r3.y, r4.x, l(-0.501960)
         sample r4.xyzw, v1.xyxx, t3.xyzw, s0
         add r3.z, r4.x, l(-0.501960)
         dp3 r4.x, cb0[3].xyzx, r3.xyzx
         dp3 r4.y, cb0[4].xyzx, r3.xyzx
         dp3 r4.z, cb0[5].xyzx, r3.xyzx
         mov r4.w, l(1.000000)
         mul r1.xyzw, r4.xyzw, cb0[1].xxxx
+        mov r2.x, l(-1)
+      else 
+        ieq r2.x, l(4), cb0[2].x
+        if_nz r2.x
+          sample r3.xyzw, v1.xyxx, t1.xyzw, s0
+          add r3.x, r3.x, l(-0.062750)
+          sample r4.xyzw, v1.xyxx, t2.xyzw, s0
+          add r3.yz, r4.xxyx, l(0.000000, -0.501960, -0.501960, 0.000000)
+          dp3 r4.x, cb0[3].xyzx, r3.xyzx
+          dp3 r4.y, cb0[4].xyzx, r3.xyzx
+          dp3 r4.z, cb0[5].xyzx, r3.xyzx
+          mov r4.w, l(1.000000)
+          mul r1.xyzw, r4.xyzw, cb0[1].xxxx
+        endif 
       endif 
     endif 
   endif 
   movc r1.xyzw, r2.xxxx, r1.xyzw, cb0[0].xyzw
   mov r2.x, l(-1)
 else 
   ieq r2.x, l(1), cb0[2].y
   if_nz r2.x
@@ -8274,32 +9210,49 @@ else
       if_nz r2.z
         div r2.zw, v2.xxxy, v2.zzzz
         sample r3.xyzw, r2.zwzz, t5.xyzw, s0
         sample r4.xyzw, v1.xyxx, t0.xyzw, s0
         mul r4.xyzw, r4.xyzw, cb0[1].xxxx
         mul r1.xyzw, r3.xxxx, r4.xyzw
         mov r2.y, l(-1)
       else 
-        ieq r2.y, l(2), cb0[2].x
-        if_nz r2.y
+        ieq r2.z, l(2), cb0[2].x
+        if_nz r2.z
           div r2.zw, v2.xxxy, v2.zzzz
           sample r3.xyzw, r2.zwzz, t5.xyzw, s0
           sample r4.xyzw, v1.xyxx, t1.xyzw, s0
           add r4.x, r4.x, l(-0.062750)
           sample r5.xyzw, v1.xyxx, t2.xyzw, s0
           add r4.y, r5.x, l(-0.501960)
           sample r5.xyzw, v1.xyxx, t3.xyzw, s0
           add r4.z, r5.x, l(-0.501960)
           dp3 r5.x, cb0[3].xyzx, r4.xyzx
           dp3 r5.y, cb0[4].xyzx, r4.xyzx
           dp3 r5.z, cb0[5].xyzx, r4.xyzx
           mov r5.w, l(1.000000)
           mul r4.xyzw, r5.xyzw, cb0[1].xxxx
           mul r1.xyzw, r3.xxxx, r4.xyzw
+          mov r2.y, l(-1)
+        else 
+          ieq r2.y, l(4), cb0[2].x
+          if_nz r2.y
+            div r2.zw, v2.xxxy, v2.zzzz
+            sample r3.xyzw, r2.zwzz, t5.xyzw, s0
+            sample r4.xyzw, v1.xyxx, t1.xyzw, s0
+            add r4.x, r4.x, l(-0.062750)
+            sample r5.xyzw, v1.xyxx, t2.xyzw, s0
+            add r4.yz, r5.xxyx, l(0.000000, -0.501960, -0.501960, 0.000000)
+            dp3 r5.x, cb0[3].xyzx, r4.xyzx
+            dp3 r5.y, cb0[4].xyzx, r4.xyzx
+            dp3 r5.z, cb0[5].xyzx, r4.xyzx
+            mov r5.w, l(1.000000)
+            mul r4.xyzw, r5.xyzw, cb0[1].xxxx
+            mul r1.xyzw, r3.xxxx, r4.xyzw
+          endif 
         endif 
       endif 
     endif 
     if_z r2.y
       div r2.yz, v2.xxyx, v2.zzzz
       sample r3.xyzw, r2.yzyy, t5.xyzw, s0
       mul r1.xyzw, r3.xxxx, cb0[0].xyzw
     endif 
@@ -8554,1301 +9507,1463 @@ movc r0.xyz, r8.yyyy, r5.xyzx, r0.xyzx
 movc r0.xyz, r8.xxxx, r4.xyzx, r0.xyzx
 movc r0.xyz, cb0[2].zzzz, r0.xyzx, r2.xyzx
 add r2.x, -r0.w, l(1.000000)
 mul r0.xyz, r0.xyzx, r0.wwww
 mad r0.xyz, r2.xxxx, r1.xyzx, r0.xyzx
 mul o0.xyz, r1.wwww, r0.xyzx
 mov o0.w, r1.w
 ret 
-// Approximately 333 instruction slots used
+// Approximately 364 instruction slots used
 #endif
 
 const BYTE BlendShader[] =
 {
-     68,  88,  66,  67,  28, 114, 
-    244,  41, 206,   5, 116, 244, 
-     79, 130, 118, 154,  72, 188, 
-     36,  32,   1,   0,   0,   0, 
-    172,  66,   0,   0,   6,   0, 
+     68,  88,  66,  67,   6,  79, 
+    168, 227, 221,  67,   5, 116, 
+      6, 117, 235, 213,  93,  30, 
+    142, 103,   1,   0,   0,   0, 
+    136,  70,   0,   0,   6,   0, 
       0,   0,  56,   0,   0,   0, 
-     16,  23,   0,   0, 208,  61, 
-      0,   0,  76,  62,   0,   0, 
-    240,  65,   0,   0, 120,  66, 
+    180,  23,   0,   0, 160,  65, 
+      0,   0,  28,  66,   0,   0, 
+    204,  69,   0,   0,  84,  70, 
       0,   0,  65, 111, 110,  57, 
-    208,  22,   0,   0, 208,  22, 
+    116,  23,   0,   0, 116,  23, 
       0,   0,   0,   2, 255, 255, 
-    112,  22,   0,   0,  96,   0, 
+     20,  23,   0,   0,  96,   0, 
       0,   0,   3,   0,  60,   0, 
       0,   0,  96,   0,   0,   0, 
      96,   0,   6,   0,  36,   0, 
       0,   0,  96,   0,   0,   0, 
       0,   0,   1,   0,   1,   0, 
       2,   0,   2,   0,   3,   0, 
       3,   0,   5,   0,   4,   0, 
       6,   0,   5,   0,   0,   0, 
       0,   0,   2,   0,   0,   0, 
       0,   0,   0,   0,   0,   0, 
       2,   0,   1,   0,   2,   0, 
       3,   3,   3,   3,   0,   0, 
       3,   0,   3,   0,   3,   0, 
       0,   0,   0,   0,   1,   2, 
     255, 255,  81,   0,   0,   5, 
-      6,   0,  15, 160,   0,   0, 
-    128, 191,   0,   0,   0, 192, 
-     18, 131, 128, 189, 115, 128, 
+      6,   0,  15, 160, 115, 128, 
+      0, 191,   0,   0, 128, 191, 
+      0,   0,   0, 128,   0,   0, 
       0, 191,  81,   0,   0,   5, 
       7,   0,  15, 160,   0,   0, 
-      0, 192,   0,   0,  64, 192, 
-      0,   0, 128, 192,   0,   0, 
-    160, 192,  81,   0,   0,   5, 
+    128, 191,   0,   0,   0, 192, 
+      0,   0, 128, 192,  18, 131, 
+    128, 189,  81,   0,   0,   5, 
       8,   0,  15, 160,   0,   0, 
-    192, 192,   0,   0, 224, 192, 
-      0,   0,   0, 193,   0,   0, 
-     16, 193,  81,   0,   0,   5, 
+    128, 191,   0,   0,   0, 192, 
+      0,   0,  64, 192,   0,   0, 
+    128, 192,  81,   0,   0,   5, 
       9,   0,  15, 160,   0,   0, 
-      0,  63,   0,   0, 128,  63, 
-      0,   0, 128,  62,   0,   0, 
-      0, 192,  81,   0,   0,   5, 
+    160, 192,   0,   0, 192, 192, 
+      0,   0, 224, 192,   0,   0, 
+      0, 193,  81,   0,   0,   5, 
      10,   0,  15, 160,   0,   0, 
+    128,  63,   0,   0, 128,  62, 
+      0,   0,   0,  64,   0,   0, 
+    128, 191,  81,   0,   0,   5, 
+     11,   0,  15, 160,   0,   0, 
     128,  65,   0,   0,  64, 193, 
-      0,   0,  96, 193,   0,   0, 
-      0,   0,  81,   0,   0,   5, 
-     11,   0,  15, 160,   0,   0, 
-     32, 193,   0,   0,  48, 193, 
-      0,   0,  64, 193,   0,   0, 
-     80, 193,  81,   0,   0,   5, 
-     12,   0,  15, 160, 154, 153, 
+      0,   0,  80, 193,   0,   0, 
+     96, 193,  81,   0,   0,   5, 
+     12,   0,  15, 160,   0,   0, 
+     16, 193,   0,   0,  32, 193, 
+      0,   0,  48, 193,   0,   0, 
+     64, 193,  81,   0,   0,   5, 
+     13,   0,  15, 160, 154, 153, 
     153,  62,  61,  10,  23,  63, 
     174,  71, 225,  61,   0,   0, 
-      0,   0,  81,   0,   0,   5, 
-     13,   0,  15, 160,   0,   0, 
-    128, 191,   0,   0,   0, 128, 
-      0,   0,   0,   0,   0,   0, 
-    128,  63,  31,   0,   0,   2, 
+      0,   0,  31,   0,   0,   2, 
       0,   0,   0, 128,   0,   0, 
      15, 176,  31,   0,   0,   2, 
       0,   0,   0, 128,   1,   0, 
       7, 176,  31,   0,   0,   2, 
       0,   0,   0, 144,   0,   8, 
      15, 160,  31,   0,   0,   2, 
       0,   0,   0, 144,   1,   8, 
      15, 160,  31,   0,   0,   2, 
       0,   0,   0, 144,   2,   8, 
      15, 160,  31,   0,   0,   2, 
       0,   0,   0, 144,   3,   8, 
      15, 160,  31,   0,   0,   2, 
       0,   0,   0, 144,   4,   8, 
      15, 160,  31,   0,   0,   2, 
       0,   0,   0, 144,   5,   8, 
      15, 160,   1,   0,   0,   2, 
-      0,   0,   1, 128,  13,   0, 
-    170, 160,   1,   0,   0,   2, 
-      1,   0,   1, 128,  13,   0, 
-    170, 160,   1,   0,   0,   2, 
-      2,   0,   4, 128,  13,   0, 
-    170, 160,   1,   0,   0,   2, 
-      3,   0,   8, 128,   6,   0, 
+      0,   0,   1, 128,   6,   0, 
+    170, 161,   1,   0,   0,   2, 
+      1,   0,   1, 128,   6,   0, 
+    170, 161,   1,   0,   0,   2, 
+      2,   0,   4, 128,   6,   0, 
+    170, 161,   1,   0,   0,   2, 
+      3,   0,   8, 128,   7,   0, 
       0, 161,  66,   0,   0,   3, 
       4,   0,  15, 128,   0,   0, 
-    228, 176,   2,   8, 228, 160, 
+    228, 176,   1,   8, 228, 160, 
      66,   0,   0,   3,   5,   0, 
      15, 128,   0,   0, 228, 176, 
-      1,   8, 228, 160,   2,   0, 
-      0,   3,   5,   0,   1, 128, 
+      3,   8, 228, 160,   2,   0, 
+      0,   3,   5,   0,   8, 128, 
       5,   0,   0, 128,   6,   0, 
-    170, 160,   2,   0,   0,   3, 
-      5,   0,   2, 128,   4,   0, 
-      0, 128,   6,   0, 255, 160, 
+      0, 160,   2,   0,   0,   3, 
+      5,   0,   1, 128,   4,   0, 
+      0, 128,   7,   0, 255, 160, 
       6,   0,   0,   2,   0,   0, 
       8, 128,   1,   0, 170, 176, 
       5,   0,   0,   3,   4,   0, 
       3, 128,   0,   0, 255, 128, 
       1,   0, 228, 176,  66,   0, 
       0,   3,   6,   0,  15, 128, 
-      0,   0, 228, 176,   3,   8, 
+      0,   0, 228, 176,   2,   8, 
     228, 160,  66,   0,   0,   3, 
       4,   0,  15, 128,   4,   0, 
     228, 128,   4,   8, 228, 160, 
       2,   0,   0,   3,   5,   0, 
-      4, 128,   6,   0,   0, 128, 
-      6,   0, 255, 160,   8,   0, 
+      6, 128,   6,   0, 208, 128, 
+      6,   0,   0, 160,   8,   0, 
       0,   3,   3,   0,   1, 128, 
       3,   0, 228, 160,   5,   0, 
-    228, 128,   8,   0,   0,   3, 
+    244, 128,   8,   0,   0,   3, 
       3,   0,   2, 128,   4,   0, 
-    228, 160,   5,   0, 228, 128, 
+    228, 160,   5,   0, 244, 128, 
       8,   0,   0,   3,   3,   0, 
       4, 128,   5,   0, 228, 160, 
-      5,   0, 228, 128,   5,   0, 
+      5,   0, 244, 128,   5,   0, 
       0,   3,   3,   0,  15, 128, 
       3,   0, 228, 128,   1,   0, 
       0, 160,   5,   0,   0,   3, 
-      5,   0,  15, 128,   4,   0, 
+      6,   0,  15, 128,   4,   0, 
       0, 128,   3,   0, 228, 128, 
-      1,   0,   0,   2,   6,   0, 
+      8,   0,   0,   3,   7,   0, 
+      1, 128,   3,   0, 228, 160, 
+      5,   0, 228, 128,   8,   0, 
+      0,   3,   7,   0,   2, 128, 
+      4,   0, 228, 160,   5,   0, 
+    228, 128,   8,   0,   0,   3, 
+      7,   0,   4, 128,   5,   0, 
+    228, 160,   5,   0, 228, 128, 
+      1,   0,   0,   2,   7,   0, 
+      8, 128,   7,   0,   0, 161, 
+      5,   0,   0,   3,   5,   0, 
+     15, 128,   7,   0, 228, 128, 
+      1,   0,   0, 160,   5,   0, 
+      0,   3,   7,   0,  15, 128, 
+      4,   0,   0, 128,   5,   0, 
+    228, 128,   1,   0,   0,   2, 
+      8,   0,   7, 128,   7,   0, 
+    228, 160,   2,   0,   0,   3, 
+      9,   0,  15, 128,   8,   0, 
+     36, 128,   2,   0,  64, 160, 
+      5,   0,   0,   3,   9,   0, 
+     15, 128,   9,   0, 228, 128, 
+      9,   0, 228, 128,  88,   0, 
+      0,   4,   6,   0,  15, 128, 
+      9,   0,  85, 129,   6,   0, 
+    228, 128,   7,   0, 228, 128, 
+      1,   0,   0,   2,   7,   0, 
       3, 128,   0,   0, 235, 176, 
-     66,   0,   0,   3,   7,   0, 
+     66,   0,   0,   3,  10,   0, 
      15, 128,   0,   0, 228, 176, 
       0,   8, 228, 160,  66,   0, 
-      0,   3,   6,   0,  15, 128, 
-      6,   0, 228, 128,   5,   8, 
+      0,   3,   7,   0,  15, 128, 
+      7,   0, 228, 128,   5,   8, 
     228, 160,   5,   0,   0,   3, 
-      7,   0,  15, 128,   7,   0, 
-    228, 128,   1,   0,   0, 160, 
-      5,   0,   0,   3,   8,   0, 
-     15, 128,   4,   0,   0, 128, 
-      7,   0, 228, 128,   1,   0, 
-      0,   2,   9,   0,   3, 128, 
-      6,   0, 228, 160,   2,   0, 
-      0,   3,  10,   0,  15, 128, 
-      9,   0,   4, 128,   2,   0, 
-    144, 160,   5,   0,   0,   3, 
      10,   0,  15, 128,  10,   0, 
-    228, 128,  10,   0, 228, 128, 
-     88,   0,   0,   4,   5,   0, 
-     15, 128,  10,   0,   0, 129, 
-      8,   0, 228, 128,   5,   0, 
-    228, 128,  88,   0,   0,   4, 
-      3,   0,  15, 128,  10,   0, 
-      0, 129,   7,   0, 228, 128, 
-      3,   0, 228, 128,   1,   0, 
-      0,   2,   7,   0,   8, 128, 
-      1,   0,   0, 160,   5,   0, 
-      0,   3,   8,   0,  15, 128, 
-      4,   0,   0, 128,   7,   0, 
-    228, 128,  88,   0,   0,   4, 
-      3,   0,  15, 128,   2,   0, 
-      0, 161,   7,   0, 228, 128, 
-      3,   0, 228, 128,   5,   0, 
+    228, 128,   1,   0,   0, 160, 
+      5,   0,   0,   3,  11,   0, 
+     15, 128,   4,   0,   0, 128, 
+     10,   0, 228, 128,  88,   0, 
+      0,   4,   6,   0,  15, 128, 
+      9,   0,   0, 129,  11,   0, 
+    228, 128,   6,   0, 228, 128, 
+      1,   0,   0,   2,  11,   0, 
+      7, 128,  10,   0, 228, 128, 
+      1,   0,   0,   2,  11,   0, 
+      8, 128,   1,   0,   0, 160, 
+      5,   0,   0,   3,  12,   0, 
+     15, 128,   4,   0,   0, 128, 
+     11,   0, 228, 128,   5,   0, 
       0,   3,   4,   0,  15, 128, 
       4,   0,   0, 128,   0,   0, 
     228, 160,  88,   0,   0,   4, 
-      5,   0,  15, 128,   2,   0, 
-      0, 161,   8,   0, 228, 128, 
-      5,   0, 228, 128,  88,   0, 
-      0,   4,   7,   0,   3, 128, 
-     10,   0, 233, 129,  13,   0, 
-      0, 160,  13,   0,  85, 160, 
+      6,   0,  15, 128,   2,   0, 
+      0, 161,  12,   0, 228, 128, 
+      6,   0, 228, 128,  88,   0, 
+      0,   4,   8,   0,   6, 128, 
+      9,   0, 248, 129,   6,   0, 
+     85, 160,   6,   0, 170, 160, 
      88,   0,   0,   4,   0,   0, 
-      8, 128,  10,   0,   0, 129, 
-      6,   0,   0, 160,   7,   0, 
-      0, 128,  88,   0,   0,   4, 
+      8, 128,   9,   0,  85, 129, 
+      7,   0,   0, 160,   8,   0, 
+     85, 128,  88,   0,   0,   4, 
       1,   0,   8, 128,   2,   0, 
-     85, 161,   9,   0,   0, 128, 
-      7,   0,  85, 128,  88,   0, 
+     85, 161,   8,   0,   0, 128, 
+      8,   0, 170, 128,  88,   0, 
       0,   4,   0,   0,   8, 128, 
-      2,   0,   0, 161,   9,   0, 
-      0, 128,   0,   0, 255, 128, 
-     88,   0,   0,   4,   4,   0, 
-     15, 128,   0,   0, 255, 128, 
-      4,   0, 228, 128,   5,   0, 
+      9,   0,   0, 129,   7,   0, 
+      0, 160,   0,   0, 255, 128, 
+     88,   0,   0,   4,   0,   0, 
+      8, 128,   2,   0,   0, 161, 
+      8,   0,   0, 128,   0,   0, 
+    255, 128,  88,   0,   0,   4, 
+      4,   0,  15, 128,   0,   0, 
+    255, 128,   4,   0, 228, 128, 
+      6,   0, 228, 128,  88,   0, 
+      0,   4,   3,   0,  15, 128, 
+      9,   0,  85, 129,   3,   0, 
+    228, 128,   5,   0, 228, 128, 
+     88,   0,   0,   4,   3,   0, 
+     15, 128,   9,   0,   0, 129, 
+     10,   0, 228, 128,   3,   0, 
     228, 128,  88,   0,   0,   4, 
-      3,   0,  15, 128,   0,   0, 
-    255, 128,   0,   0, 228, 160, 
+      3,   0,  15, 128,   2,   0, 
+      0, 161,  11,   0, 228, 128, 
       3,   0, 228, 128,  88,   0, 
       0,   4,   3,   0,  15, 128, 
-      2,   0,  85, 161,   3,   0, 
-    228, 128,   4,   0, 228, 128, 
+      0,   0, 255, 128,   0,   0, 
+    228, 160,   3,   0, 228, 128, 
      88,   0,   0,   4,   3,   0, 
-     15, 128,   1,   0, 255, 128, 
-     13,   0, 234, 160,   3,   0, 
-    228, 128,   6,   0,   0,   2, 
-      0,   0,   8, 128,   3,   0, 
-    255, 128,   5,   0,   0,   3, 
-      4,   0,   7, 128,   0,   0, 
-    255, 128,   3,   0, 228, 128, 
-     88,   0,   0,   4,   4,   0, 
-      7, 128,   2,   0, 255, 161, 
+     15, 128,   2,   0,  85, 161, 
       3,   0, 228, 128,   4,   0, 
-    228, 128,   2,   0,   0,   3, 
-      5,   0,   3, 128,   4,   0, 
-    233, 129,   4,   0, 228, 128, 
-     88,   0,   0,   4,   5,   0, 
-     12, 128,   5,   0,   0, 128, 
-      4,   0,  68, 128,   4,   0, 
-     20, 128,  11,   0,   0,   3, 
-      0,   0,   8, 128,   5,   0, 
-    170, 128,   4,   0, 170, 128, 
-     10,   0,   0,   3,   1,   0, 
-      8, 128,   4,   0, 170, 128, 
-      5,   0, 255, 128,   2,   0, 
-      0,   3,   7,   0,   8, 128, 
-      0,   0, 255, 128,   1,   0, 
-    255, 129,   6,   0,   0,   2, 
-      0,   0,   8, 128,   6,   0, 
-    255, 128,   5,   0,   0,   3, 
-      8,   0,   7, 128,   0,   0, 
-    255, 128,   6,   0, 228, 128, 
-      4,   0,   0,   4,   5,   0, 
-     12, 128,   6,   0, 100, 128, 
-      0,   0, 255, 128,   8,   0, 
-    132, 129,   5,   0,   0,   3, 
-      9,   0,   3, 128,   7,   0, 
-    255, 128,   5,   0, 238, 128, 
-      4,   0,   0,   4,  11,   0, 
-     15, 128,   6,   0, 129, 128, 
-      0,   0, 255, 128,   8,   0, 
-     88, 129,   6,   0,   0,   2, 
-      1,   0,   8, 128,  11,   0, 
-      0, 128,   5,   0,   0,   3, 
-      7,   0,   2, 128,   1,   0, 
-    255, 128,   9,   0,   0, 128, 
-     88,   0,   0,   4,   1,   0, 
-      6, 128,  11,   0, 170, 128, 
-     13,   0, 170, 160,   7,   0, 
-    220, 128,   5,   0,   0,   3, 
-     12,   0,  15, 128,   7,   0, 
-    255, 128,  11,   0, 228, 128, 
-      6,   0,   0,   2,   1,   0, 
-      8, 128,   5,   0, 255, 128, 
-      5,   0,   0,   3,   7,   0, 
-      1, 128,   1,   0, 255, 128, 
-     12,   0,  85, 128,  88,   0, 
-      0,   4,   2,   0,   3, 128, 
-     11,   0, 255, 128,  13,   0, 
-    170, 160,   7,   0, 236, 128, 
-     88,   0,   0,   4,   1,   0, 
-      7, 128,   5,   0, 170, 128, 
-      1,   0, 228, 128,   2,   0, 
+    228, 128,  88,   0,   0,   4, 
+      3,   0,  15, 128,   1,   0, 
+    255, 128,   6,   0, 106, 161, 
+      3,   0, 228, 128,   6,   0, 
+      0,   2,   0,   0,   8, 128, 
+      3,   0, 255, 128,   5,   0, 
+      0,   3,   4,   0,   7, 128, 
+      0,   0, 255, 128,   3,   0, 
+    228, 128,  88,   0,   0,   4, 
+      4,   0,   7, 128,   2,   0, 
+    255, 161,   3,   0, 228, 128, 
+      4,   0, 228, 128,   2,   0, 
+      0,   3,   5,   0,   3, 128, 
+      4,   0, 233, 129,   4,   0, 
+    228, 128,  88,   0,   0,   4, 
+      5,   0,  12, 128,   5,   0, 
+      0, 128,   4,   0,  68, 128, 
+      4,   0,  20, 128,  11,   0, 
+      0,   3,   0,   0,   8, 128, 
+      5,   0, 170, 128,   4,   0, 
+    170, 128,  10,   0,   0,   3, 
+      1,   0,   8, 128,   4,   0, 
+    170, 128,   5,   0, 255, 128, 
+      2,   0,   0,   3,   6,   0, 
+      8, 128,   0,   0, 255, 128, 
+      1,   0, 255, 129,   6,   0, 
+      0,   2,   0,   0,   8, 128, 
+      7,   0, 255, 128,   5,   0, 
+      0,   3,   8,   0,   7, 128, 
+      0,   0, 255, 128,   7,   0, 
+    228, 128,   4,   0,   0,   4, 
+      5,   0,  12, 128,   7,   0, 
+    100, 128,   0,   0, 255, 128, 
+      8,   0, 132, 129,   5,   0, 
+      0,   3,   9,   0,   3, 128, 
+      6,   0, 255, 128,   5,   0, 
+    238, 128,   4,   0,   0,   4, 
+     10,   0,  15, 128,   7,   0, 
+    129, 128,   0,   0, 255, 128, 
+      8,   0,  88, 129,   6,   0, 
+      0,   2,   1,   0,   8, 128, 
+     10,   0,   0, 128,   5,   0, 
+      0,   3,   6,   0,   2, 128, 
+      1,   0, 255, 128,   9,   0, 
+      0, 128,  88,   0,   0,   4, 
+      1,   0,   6, 128,  10,   0, 
+    170, 128,   6,   0, 170, 161, 
+      6,   0, 220, 128,   5,   0, 
+      0,   3,  11,   0,  15, 128, 
+      6,   0, 255, 128,  10,   0, 
     228, 128,   6,   0,   0,   2, 
       1,   0,   8, 128,   5,   0, 
-    170, 128,   5,   0,