Bug 563878. Part 2. Some view/ cleanup. r=mats
authorTimothy Nikkel <tnikkel@gmail.com>
Sat, 05 Jun 2010 15:29:49 -0500
changeset 43139 5702bf7ea7eb85e1dbbd23a74f6e747e3b26edcd
parent 43138 2c4a36b7e9ea2125b9daaab242202be4c34e46a5
child 43140 83d0cd161be2d3cad1e97a1deebab5f248f4bc7d
push idunknown
push userunknown
push dateunknown
reviewersmats
bugs563878
milestone1.9.3a5pre
Bug 563878. Part 2. Some view/ cleanup. r=mats
gfx/public/nsGfxCIID.h
view/src/nsViewManager.cpp
view/src/nsViewManager.h
--- a/gfx/public/nsGfxCIID.h
+++ b/gfx/public/nsGfxCIID.h
@@ -65,17 +65,13 @@
 #define NS_REGION_CID \
 { 0xe12752f0, 0xee9a, 0x11d1, \
 { 0xa8, 0x2a, 0x00, 0x40, 0x95, 0x9a, 0x28, 0xc9 } }
 
 #define NS_SCRIPTABLE_REGION_CID \
 { 0xda5b130a, 0x1dd1, 0x11b2, \
 { 0xad, 0x47, 0xf4, 0x55, 0xb1, 0x81, 0x4a, 0x78 } }
 
-#define NS_BLENDER_CID \
-{ 0x6049b264, 0xc1e6, 0x11d1, \
-{ 0xa8, 0x27, 0x00, 0x40, 0x95, 0x9a, 0x28, 0xc9 } }
-
 #define NS_DRAWING_SURFACE_CID \
 { 0x199c7040, 0xcab0, 0x11d2, \
 { 0xa8, 0x49, 0x00, 0x40, 0x95, 0x9a, 0x28, 0xc9 } }
 
 #endif
--- a/view/src/nsViewManager.cpp
+++ b/view/src/nsViewManager.cpp
@@ -39,38 +39,34 @@
  *
  * ***** END LICENSE BLOCK ***** */
 
 #define PL_ARENA_CONST_ALIGN_MASK (sizeof(void*)-1)
 #include "plarena.h"
 
 #include "nsAutoPtr.h"
 #include "nsViewManager.h"
-#include "nsIRenderingContext.h"
 #include "nsIDeviceContext.h"
 #include "nsGfxCIID.h"
 #include "nsView.h"
 #include "nsISupportsArray.h"
 #include "nsCOMPtr.h"
 #include "nsIServiceManager.h"
 #include "nsGUIEvent.h"
 #include "nsIPrefBranch.h"
 #include "nsIPrefService.h"
 #include "nsRegion.h"
 #include "nsInt64.h"
 #include "nsHashtable.h"
 #include "nsCOMArray.h"
 #include "nsThreadUtils.h"
 #include "nsContentUtils.h"
-#include "gfxContext.h"
 #include "nsIPluginWidget.h"
 
-static NS_DEFINE_IID(kBlenderCID, NS_BLENDER_CID);
 static NS_DEFINE_IID(kRegionCID, NS_REGION_CID);
-static NS_DEFINE_IID(kRenderingContextCID, NS_RENDERING_CONTEXT_CID);
 
 /**
    XXX TODO XXX
 
    DeCOMify newly private methods
    Optimize view storage
 */
 
@@ -82,20 +78,16 @@ static NS_DEFINE_IID(kRenderingContextCI
    We assume that a widget is z-ordered on top of its parent.
    
    We do NOT assume anything about the relative z-ordering of sibling widgets. Even though
    we ask for a specific z-order, we don't assume that widget z-ordering actually works.
 */
 
 #define NSCOORD_NONE      PR_INT32_MIN
 
-#ifdef NS_VM_PERF_METRICS
-#include "nsITimeRecorder.h"
-#endif
-
 //-------------- Begin Invalidate Event Definition ------------------------
 
 class nsInvalidateEvent : public nsViewManagerEvent {
 public:
   nsInvalidateEvent(nsViewManager *vm) : nsViewManagerEvent(vm) {}
 
   NS_IMETHOD Run() {
     if (mViewManager)
@@ -131,40 +123,32 @@ nsViewManager::PostInvalidateEvent()
       mInvalidateEvent = ev;
     }
   }
 }
 
 #undef DEBUG_MOUSE_LOCATION
 
 PRInt32 nsViewManager::mVMCount = 0;
-nsIRenderingContext* nsViewManager::gCleanupContext = nsnull;
 
 // Weakly held references to all of the view managers
 nsVoidArray* nsViewManager::gViewManagers = nsnull;
 PRUint32 nsViewManager::gLastUserEventTime = 0;
 
 nsViewManager::nsViewManager()
   : mMouseLocation(NSCOORD_NONE, NSCOORD_NONE)
   , mDelayedResize(NSCOORD_NONE, NSCOORD_NONE)
   , mRootViewManager(this)
 {
   if (gViewManagers == nsnull) {
     NS_ASSERTION(mVMCount == 0, "View Manager count is incorrect");
     // Create an array to hold a list of view managers
     gViewManagers = new nsVoidArray;
   }
  
-  if (gCleanupContext == nsnull) {
-    /* XXX: This should use a device to create a matching |nsIRenderingContext| object */
-    CallCreateInstance(kRenderingContextCID, &gCleanupContext);
-    NS_ASSERTION(gCleanupContext,
-                 "Wasn't able to create a graphics context for cleanup");
-  }
-
   gViewManagers->AppendElement(this);
 
   ++mVMCount;
 
   // NOTE:  we use a zeroing operator new, so all data members are
   // assumed to be cleared here.
   mHasPendingUpdates = PR_FALSE;
   mRecursiveRefreshPending = PR_FALSE;
@@ -200,24 +184,16 @@ nsViewManager::~nsViewManager()
 
   if (0 == mVMCount) {
     // There aren't any more view managers so
     // release the global array of view managers
    
     NS_ASSERTION(gViewManagers != nsnull, "About to delete null gViewManagers");
     delete gViewManagers;
     gViewManagers = nsnull;
-
-    // Cleanup all of the offscreen drawing surfaces if the last view manager
-    // has been destroyed and there is something to cleanup
-
-    // Note: A global rendering context is needed because it is not possible 
-    // to create a nsIRenderingContext during the shutdown of XPCOM. The last
-    // viewmanager is typically destroyed during XPCOM shutdown.
-    NS_IF_RELEASE(gCleanupContext);
   }
 
   mObserver = nsnull;
 }
 
 NS_IMPL_ISUPPORTS1(nsViewManager, nsIViewManager)
 
 nsresult
@@ -1019,53 +995,28 @@ NS_IMETHODIMP nsViewManager::DispatchEve
 #ifdef DEBUG_MOUSE_LOCATION
             printf("[vm=%p]got mouse exit for %p\n",
                    this, aEvent->widget);
             printf("[vm=%p]clearing mouse location\n",
                    this);
 #endif
           }
 
-          //Calculate the proper offset for the view we're going to
-          nsPoint offset(0, 0);
-
-          if (view != baseView) {
-            //Get offset from root of baseView
-            nsView *parent;
-            for (parent = baseView; parent; parent = parent->GetParent())
-              parent->ConvertToParentCoords(&offset.x, &offset.y);
-
-            //Subtract back offset from root of view
-            for (parent = view; parent; parent = parent->GetParent())
-              parent->ConvertFromParentCoords(&offset.x, &offset.y);
-          }
-
-          // Dispatch the event
-          nsRect baseViewDimensions;
-          baseView->GetDimensions(baseViewDimensions);
-
-          nsPoint pt;
-          pt.x = baseViewDimensions.x + 
-            NSFloatPixelsToAppUnits(float(aEvent->refPoint.x) + 0.5f, p2a);
-          pt.y = baseViewDimensions.y + 
-            NSFloatPixelsToAppUnits(float(aEvent->refPoint.y) + 0.5f, p2a);
-          pt += offset;
-
-          *aStatus = HandleEvent(view, pt, aEvent);
+          *aStatus = HandleEvent(view, aEvent);
         }
     
         break;
       }
     }
 
   return NS_OK;
 }
 
-nsEventStatus nsViewManager::HandleEvent(nsView* aView, nsPoint aPoint,
-                                         nsGUIEvent* aEvent) {
+nsEventStatus nsViewManager::HandleEvent(nsView* aView, nsGUIEvent* aEvent)
+{
 //printf(" %d %d %d %d (%d,%d) \n", this, event->widget, event->widgetSupports, 
 //       event->message, event->point.x, event->point.y);
 
   // Hold a refcount to the observer. The continued existence of the observer will
   // delay deletion of this view hierarchy should the event want to cause its
   // destruction in, say, some JavaScript event handler.
   nsCOMPtr<nsIViewObserver> obs = aView->GetViewManager()->GetViewObserver();
   nsEventStatus status = nsEventStatus_eIgnore;
@@ -1239,25 +1190,16 @@ NS_IMETHODIMP nsViewManager::RemoveChild
     {
       UpdateView(child, NS_VMREFRESH_NO_SYNC);
       parent->RemoveChild(child);
     }
 
   return NS_OK;
 }
 
-NS_IMETHODIMP nsViewManager::MoveViewBy(nsIView *aView, nscoord aX, nscoord aY)
-{
-  nsView* view = static_cast<nsView*>(aView);
-
-  nsPoint pt = view->GetPosition();
-  MoveViewTo(view, aX + pt.x, aY + pt.y);
-  return NS_OK;
-}
-
 NS_IMETHODIMP nsViewManager::MoveViewTo(nsIView *aView, nscoord aX, nscoord aY)
 {
   nsView* view = static_cast<nsView*>(aView);
   nsPoint oldPt = view->GetPosition();
   nsRect oldArea = view->GetBounds();
   view->SetPosition(aX, aY);
 
   // only do damage control if the view is visible
--- a/view/src/nsViewManager.h
+++ b/view/src/nsViewManager.h
@@ -44,19 +44,16 @@
 #include "prtime.h"
 #include "prinrval.h"
 #include "nsVoidArray.h"
 #include "nsThreadUtils.h"
 #include "nsIRegion.h"
 #include "nsView.h"
 #include "nsIViewObserver.h"
 
-//Uncomment the following line to enable generation of viewmanager performance data.
-//#define NS_VM_PERF_METRICS 1
-
 
 /**
    Invalidation model:
 
    1) Callers call into the view manager and ask it to update a view.
    
    2) The view manager finds the "right" widget for the view, henceforth called
       the root widget.
@@ -127,18 +124,16 @@ public:
   NS_IMETHOD  InsertChild(nsIView *parent, nsIView *child, nsIView *sibling,
                           PRBool above);
 
   NS_IMETHOD  InsertChild(nsIView *parent, nsIView *child,
                           PRInt32 zindex);
 
   NS_IMETHOD  RemoveChild(nsIView *parent);
 
-  NS_IMETHOD  MoveViewBy(nsIView *aView, nscoord aX, nscoord aY);
-
   NS_IMETHOD  MoveViewTo(nsIView *aView, nscoord aX, nscoord aY);
 
   NS_IMETHOD  ResizeView(nsIView *aView, const nsRect &aRect, PRBool aRepaintExposedAreaOnly = PR_FALSE);
 
   NS_IMETHOD  SetViewFloating(nsIView *aView, PRBool aFloating);
 
   NS_IMETHOD  SetViewVisibility(nsIView *aView, nsViewVisibility aVisible);
 
@@ -260,17 +255,17 @@ private:
     RootViewManager()->mPainting = aPainting;
   }
 
 public: // NOT in nsIViewManager, so private to the view module
   nsView* GetRootView() const { return mRootView; }
   nsViewManager* RootViewManager() const { return mRootViewManager; }
   PRBool IsRootVM() const { return this == RootViewManager(); }
 
-  nsEventStatus HandleEvent(nsView* aView, nsPoint aPoint, nsGUIEvent* aEvent);
+  nsEventStatus HandleEvent(nsView* aView, nsGUIEvent* aEvent);
 
   virtual nsresult WillBitBlit(nsIView* aView, const nsRect& aRect,
                                nsPoint aScrollAmount);
   virtual void UpdateViewAfterScroll(nsIView *aView,
                                      const nsRegion& aUpdateRegion);
 
   nsresult CreateRegion(nsIRegion* *result);
 
@@ -313,19 +308,16 @@ private:
   PRPackedBool      mPainting;
   PRPackedBool      mRecursiveRefreshPending;
   PRPackedBool      mHasPendingUpdates;
   PRPackedBool      mInScroll;
 
   //from here to public should be static and locked... MMP
   static PRInt32           mVMCount;        //number of viewmanagers
 
-  //Rendering context used to cleanup the blending buffers
-  static nsIRenderingContext* gCleanupContext;
-
   //list of view managers
   static nsVoidArray       *gViewManagers;
 
   void PostInvalidateEvent();
 };
 
 //when the refresh happens, should it be double buffered?
 #define NS_VMREFRESH_DOUBLE_BUFFER      0x0001