Bug 626343. Check return value when creating a plugin widget. r=roc a=blocking
authorTimothy Nikkel <tnikkel@gmail.com>
Mon, 31 Jan 2011 17:31:34 -0600
changeset 61670 73f7643d522d8d167b35c87b071ddfeaff7b7863
parent 61669 4a62f7e1f1289161b9e47d7bf2e5435bc4f5d818
child 61671 d94a56d7812335f29492a373a4e843865c2f9909
push id18442
push usertnikkel@gmail.com
push dateMon, 31 Jan 2011 23:31:51 +0000
treeherdermozilla-central@73f7643d522d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersroc, blocking
bugs626343
milestone2.0b11pre
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 626343. Check return value when creating a plugin widget. r=roc a=blocking
layout/base/FrameLayerBuilder.cpp
layout/generic/nsObjectFrame.cpp
--- a/layout/base/FrameLayerBuilder.cpp
+++ b/layout/base/FrameLayerBuilder.cpp
@@ -753,18 +753,31 @@ ContainerState::CreateOrRecycleThebesLay
     // Mark this layer as being used for Thebes-painting display items
     layer->SetUserData(&gThebesDisplayItemLayerUserData,
         new ThebesDisplayItemLayerUserData());
   }
 
   // Set up transform so that 0,0 in the Thebes layer corresponds to the
   // (pixel-snapped) top-left of the aActiveScrolledRoot.
   nsPoint offset = mBuilder->ToReferenceFrame(aActiveScrolledRoot);
-  nsIntPoint pixOffset = offset.ToNearestPixels(
+  nsIntPoint pixOffset;
+  pixOffset.x = NSToIntRound(NSAppUnitsToFloatPixels(offset.x, float(aActiveScrolledRoot->PresContext()->AppUnitsPerDevPixel())));
+  pixOffset.y = NSToIntRound(NSAppUnitsToFloatPixels(offset.y, float(aActiveScrolledRoot->PresContext()->AppUnitsPerDevPixel())));
+  nsIntPoint pixOffset2 = offset.ToNearestPixels(
       aActiveScrolledRoot->PresContext()->AppUnitsPerDevPixel());
+  if (pixOffset != pixOffset2) {
+    printf("offset %d %d offset/60 %d %d pixoffset %d %d pixoffset2 %d %d", offset.x, offset.y, offset.x/60, offset.y/60, pixOffset.x, pixOffset.y, pixOffset2.x, pixOffset2.y);
+    if (offset.y % 60 == 0) printf(" exact");
+    if ((offset.y / 60)*60 == offset.y) printf(" exact2");
+    printf(" float val %f double val %fL", NSAppUnitsToFloatPixels(offset.y, float(aActiveScrolledRoot->PresContext()->AppUnitsPerDevPixel())),
+      double(offset.y)/double(aActiveScrolledRoot->PresContext()->AppUnitsPerDevPixel()));
+    printf("\n");
+  }
+  pixOffset.x = NSToIntRound(float(double(offset.x)/double(aActiveScrolledRoot->PresContext()->AppUnitsPerDevPixel())));
+  pixOffset.y = NSToIntRound(float(double(offset.y)/double(aActiveScrolledRoot->PresContext()->AppUnitsPerDevPixel())));
   gfxMatrix matrix;
   matrix.Translate(gfxPoint(pixOffset.x, pixOffset.y));
   layer->SetTransform(gfx3DMatrix::From2D(matrix));
 
   return layer.forget();
 }
 
 /**
--- a/layout/generic/nsObjectFrame.cpp
+++ b/layout/generic/nsObjectFrame.cpp
@@ -782,18 +782,23 @@ nsObjectFrame::CreateWidget(nscoord aWid
     initData.mUnicode = PR_FALSE;
     initData.clipChildren = PR_TRUE;
     initData.clipSiblings = PR_TRUE;
     // We want mWidget to be able to deliver events to us, especially on
     // Mac where events to the plugin are routed through Gecko. So we
     // allow the view to attach its event handler to mWidget even though
     // mWidget isn't the view's designated widget.
     EVENT_CALLBACK eventHandler = mInnerView->AttachWidgetEventHandler(mWidget);
-    mWidget->Create(parentWidget, nsnull, nsIntRect(0,0,0,0),
-                    eventHandler, dx, nsnull, nsnull, &initData);
+    rv = mWidget->Create(parentWidget, nsnull, nsIntRect(0,0,0,0),
+                         eventHandler, dx, nsnull, nsnull, &initData);
+    if (NS_FAILED(rv)) {
+      mWidget->Destroy();
+      mWidget = nsnull;
+      return rv;
+    }
 
     mWidget->EnableDragDrop(PR_TRUE);
 
     // If this frame has an ancestor with a widget which is not
     // the root prescontext's widget, then this plugin should not be
     // displayed, so don't show the widget. If we show the widget, the
     // plugin may appear in the main window. In Web content this would
     // only happen with a plugin in a XUL popup.