Bug 951635 - Move CrossSlide.Handler instantiation to be driven by the View via _adjustDOMforViewState method. r=mbrubeck a=metro-only
authorSam Foster <sfoster@mozilla.com>
Thu, 09 Jan 2014 14:46:19 -0800
changeset 175934 98aef209260c14bbffd0653f548f2c5a65e7db61
parent 175933 71353423c327012cce168314fe27da2837b3d377
child 175935 88443d38a05f677456e46b148aa6de3c6c64d889
push id445
push userffxbld
push dateMon, 10 Mar 2014 22:05:19 +0000
treeherdermozilla-release@dc38b741b04e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmbrubeck, metro-only
bugs951635
milestone28.0a2
Bug 951635 - Move CrossSlide.Handler instantiation to be driven by the View via _adjustDOMforViewState method. r=mbrubeck a=metro-only
browser/metro/base/content/bindings/grid.xml
browser/metro/modules/View.jsm
--- a/browser/metro/base/content/bindings/grid.xml
+++ b/browser/metro/base/content/bindings/grid.xml
@@ -632,47 +632,59 @@
       <field name="_xslideHandler"/>
       <constructor>
         <![CDATA[
           // create our quota of item slots
           for (let count = this.childElementCount, slotCount = this.minSlots;
               count < slotCount; count++) {
             this.appendChild( this._createItemElement() );
           }
-
           if (this.controller && this.controller.gridBoundCallback != undefined)
             this.controller.gridBoundCallback();
-
-          // set up cross-slide gesture handling for multiple-selection grids
-          if ("undefined" !== typeof CrossSlide && !this.noContext) {
-            this._xslideHandler = new CrossSlide.Handler(this, {
-                  REARRANGESTART: this.crossSlideBoundary
-            });
-          }
-
           // XXX This event was never actually implemented (bug 223411).
           let event = document.createEvent("Events");
           event.initEvent("contentgenerated", true, true);
           this.dispatchEvent(event);
         ]]>
       </constructor>
+
       <destructor>
         <![CDATA[
-          if (this._xslideHandler) {
-            this.removeEventListener("touchstart", this._xslideHandler);
-            this.removeEventListener("touchmove", this._xslideHandler);
-            this.removeEventListener("touchend", this._xslideHandler);
-            this._xslideHandler = null;
-          }
+          this.disableCrossSlide();
         ]]>
       </destructor>
+      <method name="enableCrossSlide">
+        <body>
+          <![CDATA[
+            // set up cross-slide gesture handling for multiple-selection grids
+            if (!this._xslideHandler &&
+                "undefined" !== typeof CrossSlide && !this.noContext) {
+              this._xslideHandler = new CrossSlide.Handler(this, {
+                    REARRANGESTART: this.crossSlideBoundary
+              });
+            }
+          ]]>
+        </body>
+      </method>
+
+      <method name="disableCrossSlide">
+        <body>
+          <![CDATA[
+            if (this._xslideHandler) {
+              this.removeEventListener("touchstart", this._xslideHandler);
+              this.removeEventListener("touchmove", this._xslideHandler);
+              this.removeEventListener("touchend", this._xslideHandler);
+              this._xslideHandler = null;
+            }
+          ]]>
+        </body>
+      </method>
 
       <property name="tileWidth" readonly="true" onget="return this._itemSize.width"/>
       <property name="tileHeight" readonly="true" onget="return this._itemSize.height"/>
-
       <field name="_tileStyleSheetName">"tiles.css"</field>
       <method name="_getTileSizes">
         <body>
           <![CDATA[
             // Tile sizes are constants, this avoids the need to measure a rendered item before grid layout
             // The defines.inc used by the theme CSS is the single source of truth for these values
             // This method locates and parses out (just) those dimensions from the stylesheet
 
--- a/browser/metro/modules/View.jsm
+++ b/browser/metro/modules/View.jsm
@@ -48,24 +48,27 @@ View.prototype = {
     }
     if (!aState) {
       aState = grid.getAttribute("viewstate");
     }
     switch (aState) {
       case "snapped":
         grid.setAttribute("nocontext", true);
         grid.selectNone();
+        grid.disableCrossSlide();
         break;
       case "portrait":
         grid.removeAttribute("nocontext");
         grid.setAttribute("vertical", true);
+        grid.enableCrossSlide();
         break;
       default:
         grid.removeAttribute("nocontext");
         grid.removeAttribute("vertical");
+        grid.enableCrossSlide();
     }
     if ("arrangeItems" in grid) {
       grid.arrangeItems();
     }
   },
 
   _updateFavicon: function pv__updateFavicon(aItem, aUri) {
     if ("string" == typeof aUri) {