Bug 894099 - Use WindowDraggingUtils.jsm for dragging the window on XP because the hit test is slow, r=jimm,felipe,dao
☠☠ backed out by c99eac4a75c6 ☠ ☠
authorGijs Kruitbosch <gijskruitbosch@gmail.com>
Mon, 22 Jul 2013 23:08:09 -0700
changeset 139964 0593679c47a90ff9144ba9d8568706352d8eabec
parent 139963 1ae3aef92373907750726448d1c19aebbca8062c
child 139965 c99eac4a75c6fe8765149ed5b88fb5c10091c922
push idunknown
push userunknown
push dateunknown
reviewersjimm, felipe, dao
bugs894099
milestone25.0a1
Bug 894099 - Use WindowDraggingUtils.jsm for dragging the window on XP because the hit test is slow, r=jimm,felipe,dao
toolkit/modules/WindowDraggingUtils.jsm
widget/windows/nsWindow.cpp
--- a/toolkit/modules/WindowDraggingUtils.jsm
+++ b/toolkit/modules/WindowDraggingUtils.jsm
@@ -1,29 +1,31 @@
 /* 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/. */
 
-#ifdef XP_WIN
-#define USE_HITTEST
-#elifdef MOZ_WIDGET_COCOA
-#define USE_HITTEST
+#ifdef MOZ_WIDGET_COCOA
+let useHitTest = true;
+#elifdef XP_WIN
+let sysInfo = Components.classes["@mozilla.org/system-info;1"]
+              .getService(Components.interfaces.nsIPropertyBag2);
+let useHitTest = parseFloat(sysInfo.getProperty("version")) >= 6;
+#else
+let useHitTest = false;
 #endif
 
 this.EXPORTED_SYMBOLS = [ "WindowDraggingElement" ];
 
 this.WindowDraggingElement = function WindowDraggingElement(elem) {
   this._elem = elem;
   this._window = elem.ownerDocument.defaultView;
-#ifdef USE_HITTEST
-  if (!this.isPanel())
+  if (useHitTest && !this.isPanel())
     this._elem.addEventListener("MozMouseHittest", this, false);
   else
-#endif
-  this._elem.addEventListener("mousedown", this, false);
+    this._elem.addEventListener("mousedown", this, false);
 };
 
 WindowDraggingElement.prototype = {
   mouseDownCheck: function(e) { return true; },
   dragTags: ["box", "hbox", "vbox", "spacer", "label", "statusbarpanel", "stack",
              "toolbaritem", "toolbarseparator", "toolbarspring", "toolbarspacer",
              "radiogroup", "deck", "scrollbox", "arrowscrollbox", "tabs"],
   shouldDrag: function(aEvent) {
@@ -55,23 +57,21 @@ WindowDraggingElement.prototype = {
     return true;
   },
   isPanel : function() {
     return this._elem instanceof Components.interfaces.nsIDOMXULElement &&
            this._elem.localName == "panel";
   },
   handleEvent: function(aEvent) {
     let isPanel = this.isPanel();
-#ifdef USE_HITTEST
-    if (!isPanel) {
+    if (useHitTest && !isPanel) {
       if (this.shouldDrag(aEvent))
         aEvent.preventDefault();
       return;
     }
-#endif
 
     switch (aEvent.type) {
       case "mousedown":
         if (!this.shouldDrag(aEvent))
           return;
 
 #ifdef MOZ_WIDGET_GTK2
         // On GTK, there is a toolkit-level function which handles
--- a/widget/windows/nsWindow.cpp
+++ b/widget/windows/nsWindow.cpp
@@ -5490,21 +5490,26 @@ nsWindow::ClientMarginHitTestPoint(int32
                                      kResizableBorderMinSize),
                             std::max(mHorResizeMargin - mNonClientOffset.right,
                                      kResizableBorderMinSize),
                             std::max(mVertResizeMargin - mNonClientOffset.bottom,
                                      kResizableBorderMinSize),
                             std::max(mHorResizeMargin - mNonClientOffset.left,
                                      kResizableBorderMinSize));
 
-  bool allowContentOverride = mSizeMode == nsSizeMode_Maximized ||
-                              (mx >= winRect.left + nonClientSize.left &&
-                               mx <= winRect.right - nonClientSize.right &&
-                               my >= winRect.top + nonClientSize.top &&
-                               my <= winRect.bottom - nonClientSize.bottom);
+  bool allowContentOverride = false;
+  // We can skip content hit testing pre-Vista because there's no Aero Snap
+  // or similar, so there is no need for OS integration:
+  if (WinUtils::GetWindowsVersion() >= WinUtils::VISTA_VERSION) {
+    allowContentOverride = mSizeMode == nsSizeMode_Maximized ||
+                           (mx >= winRect.left + nonClientSize.left &&
+                            mx <= winRect.right - nonClientSize.right &&
+                            my >= winRect.top + nonClientSize.top &&
+                            my <= winRect.bottom - nonClientSize.bottom);
+  }
 
   // The border size.  If there is no content under mouse cursor, the border
   // size should be larger than the values in system settings.  Otherwise,
   // contents under the mouse cursor should be able to override the behavior.
   // E.g., user must expect that Firefox button always opens the popup menu
   // even when the user clicks on the above edge of it.
   nsIntMargin borderSize(std::max(nonClientSize.top,    mVertResizeMargin),
                          std::max(nonClientSize.right,  mHorResizeMargin),