Bug 683394, resizer in content check is reversed, r=neil
authorNeil Deakin <neil@mozilla.com>
Thu, 29 Sep 2011 16:05:10 -0400
changeset 77878 df24b0cffd01c94f421de270b93fec010b6b4fb8
parent 77877 6cc4966475c2431c24e688580e6946e336552009
child 77879 77b3b28682690a9a0d35d719a4ff09715d2319aa
push id21248
push usermbrubeck@mozilla.com
push dateFri, 30 Sep 2011 03:30:04 +0000
treeherdermozilla-central@3f06d09e2e93 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersneil
bugs683394
milestone10.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 683394, resizer in content check is reversed, r=neil
layout/xul/base/src/nsResizerFrame.cpp
--- a/layout/xul/base/src/nsResizerFrame.cpp
+++ b/layout/xul/base/src/nsResizerFrame.cpp
@@ -118,44 +118,46 @@ nsResizerFrame::HandleEvent(nsPresContex
               rect.Deflate(frameToResize->GetUsedPadding());
             case NS_STYLE_BOX_SIZING_PADDING:
               rect.Deflate(frameToResize->GetUsedBorder());
             default:
               break;
           }
 
           mMouseDownRect = rect.ToNearestPixels(aPresContext->AppUnitsPerDevPixel());
+          doDefault = PR_FALSE;
         }
         else {
+          // If there is no window, then resizing isn't allowed.
+          if (!window)
+            break;
+
+          doDefault = PR_FALSE;
+            
           // ask the widget implementation to begin a resize drag if it can
           Direction direction = GetDirection();
           nsresult rv = aEvent->widget->BeginResizeDrag(aEvent,
                         direction.mHorizontal, direction.mVertical);
-          if (rv == NS_ERROR_NOT_IMPLEMENTED && window) {
-            // if there's no native resize support, we need to do window
-            // resizing ourselves
-            window->GetPositionAndSize(&mMouseDownRect.x, &mMouseDownRect.y,
-                                       &mMouseDownRect.width, &mMouseDownRect.height);
-          }
-          else {
-            // for native drags, don't set the fields below
-            doDefault = PR_FALSE;
-            break;
-          }
+          // for native drags, don't set the fields below
+          if (rv != NS_ERROR_NOT_IMPLEMENTED)
+             break;
+             
+          // if there's no native resize support, we need to do window
+          // resizing ourselves
+          window->GetPositionAndSize(&mMouseDownRect.x, &mMouseDownRect.y,
+                                     &mMouseDownRect.width, &mMouseDownRect.height);
         }
 
         // we're tracking
         mTrackingMouseMove = PR_TRUE;
 
         // remember current mouse coordinates
         mMouseDownPoint = aEvent->refPoint + aEvent->widget->WidgetToScreenOffset();
 
         nsIPresShell::SetCapturingContent(GetContent(), CAPTURE_IGNOREALLOWED);
-
-        doDefault = PR_FALSE;
       }
     }
     break;
 
   case NS_MOUSE_BUTTON_UP: {
 
     if (mTrackingMouseMove && aEvent->eventStructType == NS_MOUSE_EVENT &&
         static_cast<nsMouseEvent*>(aEvent)->button == nsMouseEvent::eLeftButton)
@@ -353,17 +355,17 @@ nsResizerFrame::GetContentToResize(nsIPr
       isChromeShell = (NS_SUCCEEDED(dsti->GetItemType(&type)) &&
                        type == nsIDocShellTreeItem::typeChrome);
     }
 
     if (!isChromeShell) {
       // don't allow resizers in content shells, except for the viewport
       // scrollbar which doesn't have a parent
       nsIContent* nonNativeAnon = mContent->FindFirstNonNativeAnonymous();
-      if (nonNativeAnon && !nonNativeAnon->GetParent()) {
+      if (!nonNativeAnon || nonNativeAnon->GetParent()) {
         return nsnull;
       }
     }
 
     // get the document and the window - should this be cached?
     nsPIDOMWindow *domWindow = aPresShell->GetDocument()->GetWindow();
     if (domWindow) {
       nsCOMPtr<nsIDocShellTreeItem> docShellAsItem =