Bug 546071. Compute view-to-widget offset for plugin views. r=mats
☠☠ backed out by 77c899130037 ☠ ☠
authorRobert O'Callahan <robert@ocallahan.org>
Wed, 24 Feb 2010 00:33:41 -0800
changeset 38963 78318b260f18179ac961587adf21ed7b1ca5339d
parent 38962 34b13470f8efe96ad51ed8334721dbf295cf62bf
child 38964 290ebc6801addd3f854711f91d610f88f508a2b3
child 38973 77c8991300372bf5e55821fa7f9b2672980fc151
push id11956
push userrocallahan@mozilla.com
push dateFri, 05 Mar 2010 00:12:17 +0000
treeherdermozilla-central@af5cdd5966d9 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmats
bugs546071
milestone1.9.3a3pre
Bug 546071. Compute view-to-widget offset for plugin views. r=mats
layout/generic/nsObjectFrame.cpp
layout/reftests/bugs/546071-1-ref.html
layout/reftests/bugs/546071-1.html
layout/reftests/bugs/reftest.list
view/public/nsIView.h
view/src/nsView.cpp
view/src/nsView.h
--- a/layout/generic/nsObjectFrame.cpp
+++ b/layout/generic/nsObjectFrame.cpp
@@ -1203,16 +1203,21 @@ nsObjectFrame::ComputeWidgetGeometry(con
     return;
   configuration->mChild = mWidget;
 
   PRInt32 appUnitsPerDevPixel = presContext->AppUnitsPerDevPixel();
   nsIFrame* rootFrame = rootPC->PresShell()->FrameManager()->GetRootFrame();
   nsRect bounds = GetContentRect() + GetParent()->GetOffsetTo(rootFrame);
   configuration->mBounds = bounds.ToNearestPixels(appUnitsPerDevPixel);
 
+  // This should produce basically the same rectangle (but not relative
+  // to the root frame). We only call this here for the side-effect of
+  // setting mViewToWidgetOffset on the view.
+  mInnerView->CalcWidgetBounds(eWindowType_plugin);
+
   nsRegionRectIterator iter(aRegion);
   nsIntPoint pluginOrigin = aPluginOrigin.ToNearestPixels(appUnitsPerDevPixel);
   for (const nsRect* r = iter.Next(); r; r = iter.Next()) {
     // Snap *r to pixels while it's relative to the painted widget, to
     // improve consistency with rectangle and image drawing
     nsIntRect pixRect =
       r->ToNearestPixels(appUnitsPerDevPixel) - pluginOrigin;
     if (!pixRect.IsEmpty()) {
new file mode 100644
--- /dev/null
+++ b/layout/reftests/bugs/546071-1-ref.html
@@ -0,0 +1,8 @@
+<!DOCTYPE HTML>
+<html>
+<body>
+<div style="width:200px; border:2px solid black; overflow:hidden;">
+  <embed style="padding-left:1px;" type="application/x-test"></embed>
+</div>
+</body>
+</html>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/bugs/546071-1.html
@@ -0,0 +1,8 @@
+<!DOCTYPE HTML>
+<html>
+<body>
+<div style="width:200px; border:2px solid black; overflow:hidden;">
+  <embed style="padding-left:0.5px;" type="application/x-test"></embed>
+</div>
+</body>
+</html>
--- a/layout/reftests/bugs/reftest.list
+++ b/layout/reftests/bugs/reftest.list
@@ -1388,8 +1388,9 @@ fails HTTP(..) == 518172-2b.html 518172-
 == 539226-1.html about:blank
 == 539323-1.html 539323-1-ref.html
 == 539323-2.html 539323-2-ref.html
 == 539323-3.html 539323-3-ref.html
 == 542620-1.html 542620-1-ref.html
 == 541382-1.html 541382-1-ref.html
 == 541406-1.html 541406-1-ref.html
 == 546033-1.html 546033-1-ref.html
+== 546071-1.html 546071-1-ref.html
--- a/view/public/nsIView.h
+++ b/view/public/nsIView.h
@@ -58,18 +58,18 @@ class nsIWidget;
 //        the layer's parent.
 enum nsViewVisibility {
   nsViewVisibility_kHide = 0,
   nsViewVisibility_kShow = 1
 };
 
 // IID for the nsIView interface
 #define NS_IVIEW_IID    \
-  { 0x4435167c, 0xb627, 0x4073, \
-    { 0x9c, 0x92, 0xbc, 0x34, 0x39, 0xd9, 0xf8, 0xd2 } }
+  { 0xe981334b, 0x756e, 0x417a, \
+    { 0xbf, 0x18, 0x47, 0x4a, 0x2d, 0xfe, 0xc3, 0x87 } }
 
 // Public view flags are defined in this file
 #define NS_VIEW_FLAGS_PUBLIC              0x00FF
 // Private view flags are private to the view module,
 // and are defined in nsView.h
 #define NS_VIEW_FLAGS_PRIVATE             0xFF00
 
 // Public view flags
@@ -329,28 +329,34 @@ public:
   /**
    * @result true iff this is the root view for its view manager
    */
   PRBool IsRoot() const;
 
   virtual PRBool ExternalIsRoot() const;
 
   void SetDeletionObserver(nsWeakView* aDeletionObserver);
+
+  nsIntRect CalcWidgetBounds(nsWindowType aType);
+
+  PRBool IsEffectivelyVisible();
+
 protected:
   friend class nsWeakView;
   nsViewManager     *mViewManager;
   nsView            *mParent;
   nsIWidget         *mWindow;
   nsView            *mNextSibling;
   nsView            *mFirstChild;
   void              *mClientData;
   PRInt32           mZIndex;
   nsViewVisibility  mVis;
   nscoord           mPosX, mPosY;
   nsRect            mDimBounds; // relative to parent
+  nsPoint           mViewToWidgetOffset;
   float             mOpacity;
   PRUint32          mVFlags;
   nsWeakView*       mDeletionObserver;
 
   virtual ~nsIView() {}
 };
 
 NS_DEFINE_STATIC_IID_ACCESSOR(nsIView, NS_IVIEW_IID)
--- a/view/src/nsView.cpp
+++ b/view/src/nsView.cpp
@@ -323,26 +323,26 @@ void nsView::ResetWidgetBounds(PRBool aR
   } else if (aRecurse) {
     // reposition any widgets under this view
     for (nsView* v = GetFirstChild(); v; v = v->GetNextSibling()) {
       v->ResetWidgetBounds(PR_TRUE, aMoveOnly, aInvalidateChangedSize);
     }
   }
 }
 
-PRBool nsView::IsEffectivelyVisible()
+PRBool nsIView::IsEffectivelyVisible()
 {
-  for (nsView* v = this; v; v = v->mParent) {
+  for (nsIView* v = this; v; v = v->mParent) {
     if (v->GetVisibility() == nsViewVisibility_kHide)
       return PR_FALSE;
   }
   return PR_TRUE;
 }
 
-nsIntRect nsView::CalcWidgetBounds(nsWindowType aType)
+nsIntRect nsIView::CalcWidgetBounds(nsWindowType aType)
 {
   nsCOMPtr<nsIDeviceContext> dx;
   mViewManager->GetDeviceContext(*getter_AddRefs(dx));
   NS_ASSERTION(dx, "View manager can't be created without a device context");
   PRInt32 p2a = dx->AppUnitsPerDevPixel();
 
   nsRect viewBounds(mDimBounds);
 
--- a/view/src/nsView.h
+++ b/view/src/nsView.h
@@ -190,22 +190,17 @@ public:
       // widget top-left is always positioned at that inner view's widget's
       // top-left, so its ViewToWidgetOffset is actually the same as
       // its parent's.
       return mParent->ViewToWidgetOffset();
     }
     return mViewToWidgetOffset;
   }
 
-  nsIntRect CalcWidgetBounds(nsWindowType aType);
-
-  PRBool IsEffectivelyVisible();
-
 protected:
   // Do the actual work of ResetWidgetBounds, unconditionally.  Don't
   // call this method if we have no widget.
   void DoResetWidgetBounds(PRBool aMoveOnly, PRBool aInvalidateChangedSize);
 
   nsRegion*    mDirtyRegion;
-  nsPoint      mViewToWidgetOffset;
 };
 
 #endif