Bug 1301673, use css pixels for the drag region, add each rectangle to the clip region so that tree drag feedback in drawn properly, r=tn
authorNeil Deakin <neil@mozilla.com>
Wed, 19 Oct 2016 15:01:39 -0400
changeset 318596 4c5656f3e0707a4ef8f885310dad4964a0f2c11c
parent 318595 20162ef28859450116f183a6922a6d8c63b68780
child 318597 4afa256ec14fc12798346eaf423ecc02c7135020
push id82962
push userneil@mozilla.com
push dateWed, 19 Oct 2016 19:01:55 +0000
treeherdermozilla-inbound@e6f320965d24 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerstn
bugs1301673
milestone52.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 1301673, use css pixels for the drag region, add each rectangle to the clip region so that tree drag feedback in drawn properly, r=tn
layout/base/nsPresShell.cpp
--- a/layout/base/nsPresShell.cpp
+++ b/layout/base/nsPresShell.cpp
@@ -5051,24 +5051,34 @@ PresShell::PaintRangePaintInfo(const nsT
   if (!dt || !dt->IsValid()) {
     return nullptr;
   }
 
   RefPtr<gfxContext> ctx = gfxContext::CreateOrNull(dt);
   MOZ_ASSERT(ctx); // already checked the draw target above
 
   if (aRegion) {
+    RefPtr<PathBuilder> builder = dt->CreatePathBuilder(FillRule::FILL_WINDING);
+    
     // Convert aRegion from CSS pixels to dev pixels
     nsIntRegion region =
       aRegion->ToAppUnits(nsPresContext::AppUnitsPerCSSPixel())
         .ToOutsidePixels(pc->AppUnitsPerDevPixel());
     for (auto iter = region.RectIter(); !iter.Done(); iter.Next()) {
       const nsIntRect& rect = iter.Get();
-      ctx->Clip(gfxRect(rect.x, rect.y, rect.width, rect.height));
-    }
+
+      builder->MoveTo(rect.TopLeft());
+      builder->LineTo(rect.TopRight());
+      builder->LineTo(rect.BottomRight());
+      builder->LineTo(rect.BottomLeft());
+      builder->LineTo(rect.TopLeft());
+    }
+
+    RefPtr<Path> path = builder->Finish();
+    ctx->Clip(path);
   }
 
   nsRenderingContext rc(ctx);
 
   gfxMatrix initialTM = ctx->CurrentMatrix();
 
   if (resize)
     initialTM.Scale(scale, scale);
@@ -5146,18 +5156,18 @@ PresShell::RenderNode(nsIDOMNode* aNode,
     nsRect rrect = ToAppUnits(rrectPixels, nsPresContext::AppUnitsPerCSSPixel());
     area.IntersectRect(area, rrect);
 
     nsPresContext* pc = GetPresContext();
     if (!pc)
       return nullptr;
 
     // move the region so that it is offset from the topleft corner of the surface
-    aRegion->MoveBy(-pc->AppUnitsToDevPixels(area.x),
-                    -pc->AppUnitsToDevPixels(area.y));
+    aRegion->MoveBy(-nsPresContext::AppUnitsToIntCSSPixels(area.x),
+                    -nsPresContext::AppUnitsToIntCSSPixels(area.y));
   }
 
   return PaintRangePaintInfo(rangeItems, nullptr, aRegion, area, aPoint,
                              aScreenRect, aFlags);
 }
 
 already_AddRefed<SourceSurface>
 PresShell::RenderSelection(nsISelection* aSelection,