Bug 1473029, have nsTreeBodyFrame::GetSelectionRegion use nsIntRegion instead of nsIScriptableRegion, r=mstange
authorNeil Deakin <neil@mozilla.com>
Tue, 07 Aug 2018 09:32:08 -0400
changeset 488463 74554b2b65bf79fe3682ed6176e4f524a131e4fd
parent 488462 8727297a02487d109bf96fecd992375b5e1d31bb
child 488464 937420fdce43db7d8c50c0ebf12b0a5988ead6b1
push id1815
push userffxbld-merge
push dateMon, 15 Oct 2018 10:40:45 +0000
treeherdermozilla-release@18d4c09e9378 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmstange
bugs1473029
milestone63.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 1473029, have nsTreeBodyFrame::GetSelectionRegion use nsIntRegion instead of nsIScriptableRegion, r=mstange
layout/xul/tree/nsTreeBodyFrame.cpp
layout/xul/tree/nsTreeBodyFrame.h
widget/nsBaseDragService.cpp
widget/nsBaseDragService.h
--- a/layout/xul/tree/nsTreeBodyFrame.cpp
+++ b/layout/xul/tree/nsTreeBodyFrame.cpp
@@ -58,17 +58,16 @@
 #include "nsIScrollableFrame.h"
 #include "nsDisplayList.h"
 #include "mozilla/dom/CustomEvent.h"
 #include "mozilla/dom/Event.h"
 #include "mozilla/dom/ScriptSettings.h"
 #include "mozilla/dom/ToJSValue.h"
 #include "mozilla/dom/TreeBoxObject.h"
 #include "mozilla/dom/TreeColumnBinding.h"
-#include "nsIScriptableRegion.h"
 #include <algorithm>
 #include "ScrollbarActivity.h"
 
 #ifdef ACCESSIBILITY
 #include "nsAccessibilityService.h"
 #include "nsIWritablePropertyBag2.h"
 #endif
 #include "nsBidiUtils.h"
@@ -563,57 +562,54 @@ nsTreeBodyFrame::RowWidth()
 }
 
 int32_t
 nsTreeBodyFrame::GetHorizontalPosition() const
 {
   return nsPresContext::AppUnitsToIntCSSPixels(mHorzPosition);
 }
 
-nsresult
-nsTreeBodyFrame::GetSelectionRegion(nsIScriptableRegion **aRegion)
+Maybe<CSSIntRegion>
+nsTreeBodyFrame::GetSelectionRegion()
 {
-  *aRegion = nullptr;
-
   nsCOMPtr<nsITreeSelection> selection;
   mView->GetSelection(getter_AddRefs(selection));
-  NS_ENSURE_TRUE(selection, NS_OK);
-
-  // XXXbz should we just construct as |new ScriptableRegion()|
-  // instead, and make this method return void?
-  nsCOMPtr<nsIScriptableRegion> region = do_CreateInstance("@mozilla.org/gfx/region;1");
-  NS_ENSURE_TRUE(region, NS_ERROR_FAILURE);
-  region->Init();
+  if (!selection) {
+    return Nothing();
+  }
+
 
   RefPtr<nsPresContext> presContext = PresContext();
   nsIntRect rect = mRect.ToOutsidePixels(presContext->AppUnitsPerCSSPixel());
 
   nsIFrame* rootFrame = presContext->PresShell()->GetRootFrame();
   nsPoint origin = GetOffsetTo(rootFrame);
 
+  CSSIntRegion region;
+
   // iterate through the visible rows and add the selected ones to the
   // drag region
   int32_t x = nsPresContext::AppUnitsToIntCSSPixels(origin.x);
   int32_t y = nsPresContext::AppUnitsToIntCSSPixels(origin.y);
   int32_t top = y;
   int32_t end = LastVisibleRow();
   int32_t rowHeight = nsPresContext::AppUnitsToIntCSSPixels(mRowHeight);
   for (int32_t i = mTopRowIndex; i <= end; i++) {
     bool isSelected;
     selection->IsSelected(i, &isSelected);
-    if (isSelected)
-      region->UnionRect(x, y, rect.width, rowHeight);
+    if (isSelected) {
+      region.OrWith(CSSIntRect(x, y, rect.width, rowHeight));
+    }
     y += rowHeight;
   }
 
   // clip to the tree boundary in case one row extends past it
-  region->IntersectRect(x, top, rect.width, rect.height);
-
-  region.forget(aRegion);
-  return NS_OK;
+  region.AndWith(CSSIntRect(x, top, rect.width, rect.height));
+
+  return Some(region);
 }
 
 nsresult
 nsTreeBodyFrame::Invalidate()
 {
   if (mUpdateBatchNest)
     return NS_OK;
 
--- a/layout/xul/tree/nsTreeBodyFrame.h
+++ b/layout/xul/tree/nsTreeBodyFrame.h
@@ -23,17 +23,16 @@
 #include "imgINotificationObserver.h"
 #include "nsScrollbarFrame.h"
 #include "nsThreadUtils.h"
 #include "mozilla/LookAndFeel.h"
 
 class nsFontMetrics;
 class nsOverflowChecker;
 class nsTreeImageListener;
-class nsIScriptableRegion;
 
 namespace mozilla {
 namespace layout {
 class ScrollbarActivity;
 } // namespace layout
 } // namespace mozilla
 
 // An entry in the tree's image cache
@@ -85,17 +84,17 @@ public:
   nsresult GetView(nsITreeView **aView);
   nsresult SetView(nsITreeView *aView);
   bool GetFocused() const { return mFocused; }
   nsresult SetFocused(bool aFocused);
   nsresult GetTreeBody(mozilla::dom::Element **aElement);
   int32_t RowHeight() const;
   int32_t RowWidth();
   int32_t GetHorizontalPosition() const;
-  nsresult GetSelectionRegion(nsIScriptableRegion **aRegion);
+  mozilla::Maybe<mozilla::CSSIntRegion> GetSelectionRegion();
   int32_t FirstVisibleRow() const { return mTopRowIndex; }
   int32_t LastVisibleRow() const { return mTopRowIndex + mPageLength; }
   int32_t PageLength() const { return mPageLength; }
   nsresult EnsureRowIsVisible(int32_t aRow);
   nsresult EnsureCellIsVisible(int32_t aRow, nsTreeColumn *aCol);
   void ScrollToRow(int32_t aRow);
   void ScrollByLines(int32_t aNumLines);
   void ScrollByPages(int32_t aNumPages);
--- a/widget/nsBaseDragService.cpp
+++ b/widget/nsBaseDragService.cpp
@@ -304,23 +304,17 @@ nsBaseDragService::InvokeDragSessionWith
   mRegion = Nothing();
 #ifdef MOZ_XUL
   if (aDOMNode && aDOMNode->IsContent() && !aImage) {
     if (aDOMNode->NodeInfo()->Equals(nsGkAtoms::treechildren,
                                      kNameSpaceID_XUL)) {
       nsTreeBodyFrame* treeBody =
         do_QueryFrame(aDOMNode->AsContent()->GetPrimaryFrame());
       if (treeBody) {
-        nsCOMPtr<nsIScriptableRegion> region;
-        treeBody->GetSelectionRegion(getter_AddRefs(region));
-        if (region) {
-          nsIntRegion intRegion;
-          region->GetRegion(&intRegion);
-          mRegion.emplace(CSSIntRegion::FromUnknownRegion(intRegion));
-        }
+        mRegion = treeBody->GetSelectionRegion();
       }
     }
   }
 #endif
 
   nsresult rv = InvokeDragSession(aDOMNode, aPrincipalURISpec,
                                   aTransferableArray,
                                   aActionType,
--- a/widget/nsBaseDragService.h
+++ b/widget/nsBaseDragService.h
@@ -3,17 +3,16 @@
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef nsBaseDragService_h__
 #define nsBaseDragService_h__
 
 #include "nsIDragService.h"
 #include "nsIDragSession.h"
-#include "nsIScriptableRegion.h"
 #include "nsITransferable.h"
 #include "nsCOMPtr.h"
 #include "nsRect.h"
 #include "nsPoint.h"
 #include "nsString.h"
 #include "mozilla/RefPtr.h"
 #include "mozilla/dom/ContentParent.h"
 #include "mozilla/dom/HTMLCanvasElement.h"