Commit d71235b9 authored by pinkerton%netscape.com's avatar pinkerton%netscape.com
Browse files

removing nsMacMessageSink for standalone and embedding. Replacing with...

removing nsMacMessageSink for standalone and embedding. Replacing with nsIEventSink and a couple of internal interfaces. r=ccarlen/sr=sfraser. bug#110851
parent fdf1c1da
Loading
Loading
Loading
Loading
+20 −11
Original line number Diff line number Diff line
@@ -79,9 +79,6 @@

static NS_DEFINE_IID(kWindowCID, NS_WINDOW_CID);

// CBrowserShell static variables
nsMacMessageSink	CBrowserShell::mMessageSink;


//*****************************************************************************
//***    CBrowserShell: constructors/destructor
@@ -157,6 +154,11 @@ void CBrowserShell::FinishCreateSelf()
	ourWindow->GetWidget(getter_AddRefs(aWidget));
	ThrowIfNil_(aWidget);
	
	// the widget is also our avenue for dispatching events into Gecko via
	// nsIEventSink. Save this sink for later.
	mEventSink = do_QueryInterface(aWidget);
	ThrowIfNil_(mEventSink);

	Rect portFrame;
	CalcPortFrameRect(portFrame);
	nsRect   r(portFrame.left, portFrame.top, portFrame.right - portFrame.left, portFrame.bottom - portFrame.top);
@@ -209,7 +211,8 @@ void CBrowserShell::DrawSelf()
{
    EventRecord osEvent;
    osEvent.what = updateEvt;
    mMessageSink.DispatchOSEvent(osEvent, Compat_GetMacWindow());
    PRBool handled = PR_FALSE;
    mEventSink->DispatchEvent(&osEvent, &handled);
}

	
@@ -219,14 +222,16 @@ void CBrowserShell::ClickSelf(const SMouseDownEvent &inMouseDown)
		SwitchTarget(this);

	FocusDraw();
	mMessageSink.DispatchOSEvent((EventRecord&)inMouseDown.macEvent, Compat_GetMacWindow());
  PRBool handled = PR_FALSE;
	mEventSink->DispatchEvent(&const_cast<EventRecord&>(inMouseDown.macEvent), &handled);
}


void CBrowserShell::EventMouseUp(const EventRecord	&inMacEvent)
{
    FocusDraw();
    mMessageSink.DispatchOSEvent((EventRecord&)inMacEvent, Compat_GetMacWindow());
    PRBool handled = PR_FALSE;
    mEventSink->DispatchEvent(&const_cast<EventRecord&>(inMacEvent), &handled);
    
    LEventDispatcher *dispatcher = LEventDispatcher::GetCurrentEventDispatcher();
    if (dispatcher)
@@ -288,7 +293,8 @@ Boolean CBrowserShell::HandleKeyPress(const EventRecord &inKeyEvent)
	FocusDraw();

	// dispatch the event
	Boolean keyHandled = mMessageSink.DispatchOSEvent((EventRecord&)inKeyEvent, Compat_GetMacWindow());
  PRBool handled = PR_FALSE;
	Boolean keyHandled = mEventSink->DispatchEvent(&const_cast<EventRecord&>(inKeyEvent), &handled);

	return keyHandled;
}
@@ -466,12 +472,14 @@ void CBrowserShell::SpendTime(const EventRecord& inMacEvent)
    {
        case osEvt:
        {
            // The MacMessageSink will not set the cursor if we are in the background - which is right.
            // The event sink will not set the cursor if we are in the background - which is right.
            // We have to feed it suspendResumeMessages for it to know

            unsigned char eventType = ((inMacEvent.message >> 24) & 0x00ff);
            if (eventType == suspendResumeMessage)
            mMessageSink.DispatchOSEvent(const_cast<EventRecord&>(inMacEvent), Compat_GetMacWindow());
            if (eventType == suspendResumeMessage) {
              PRBool handled = PR_FALSE;
              mEventSink->DispatchEvent(&const_cast<EventRecord&>(inMacEvent), &handled);
            }
        }
        break;
    }
@@ -872,7 +880,8 @@ void CBrowserShell::HandleMouseMoved(const EventRecord& inMacEvent)
    if (IsActive())
    {
        FocusDraw();
        mMessageSink.DispatchOSEvent(const_cast<EventRecord&>(inMacEvent), Compat_GetMacWindow());
        PRBool handled = PR_FALSE;
        mEventSink->DispatchEvent(&const_cast<EventRecord&>(inMacEvent), &handled);
    }
}

+3 −3
Original line number Diff line number Diff line
@@ -33,6 +33,7 @@
#include "nsIBaseWindow.h"
#include "nsIWebNavigation.h"
#include "nsIWidget.h"
#include "nsIEventSink.h"
#include "nsMacMessageSink.h"
#include "nsIDocShellTreeItem.h"
#include "nsIWebProgress.h"
@@ -163,10 +164,9 @@ protected:
   Boolean                  HasFormElements();
	
protected:   
   static nsMacMessageSink mMessageSink;
   
   LStr255                 mInitURL;
      
   nsCOMPtr<nsIEventSink>        mEventSink;             // for event dispatch
   nsCOMPtr<nsIWebBrowser>       mWebBrowser;            // The thing we actually create
   nsCOMPtr<nsIBaseWindow>       mWebBrowserAsBaseWin;   // Convenience interface to above 
   nsCOMPtr<nsIWebNavigation>    mWebBrowserAsWebNav;    // Ditto
+1 −1
Original line number Diff line number Diff line
@@ -163,7 +163,7 @@ void CThrobber::DrawSelf()
{
#if 0
   // Draw directly with the rendering context instead of passing an
   // update event through nsMacMessageSink. By the time this routine is
   // update event through event sink. By the time this routine is
   // called, PowerPlant has taken care of the location, z order, and clipping
   // of each view. Since focusing puts the the origin at our top left corner,
   // all we have to do is get the bounds of the widget and put that at (0,0)
+84 −12
Original line number Diff line number Diff line
@@ -26,9 +26,12 @@
#include "prthread.h"
#include "SIOUX.h"

#include "nsIWidget.h"
#include "nsIEventSink.h"
#include "nsCOMPtr.h"

// Static Variables

nsMacMessageSink CEmbedEventAttachment::mMessageSink;
WindowPtr        CEmbedEventAttachment::mLastAlienWindowClicked;

//*****************************************************************************
@@ -46,6 +49,46 @@ CEmbedEventAttachment::~CEmbedEventAttachment()
{
}


//
// GetTopWidget
//
// We've stashed the nsIWidget for the given windowPtr in the data 
// properties of the window. Fetch it.
//
void
CEmbedEventAttachment::GetTopWidget ( WindowPtr aWindow, nsIWidget** outWidget )
{
  nsIWidget* topLevelWidget = nsnull;
	::GetWindowProperty ( aWindow, 'MOSS', 'GEKO', sizeof(nsIWidget*), nsnull, (void*)&topLevelWidget);
  if ( topLevelWidget ) {
    *outWidget = topLevelWidget;
    NS_ADDREF(*outWidget);
  }
}


//
// GetWindowEventSink
//
// We've stashed the nsIEventSink for the given windowPtr in the data of the
// root control. Fetch it.
//
void
CEmbedEventAttachment::GetWindowEventSink ( WindowPtr aWindow, nsIEventSink** outSink )
{
  *outSink = nsnull;
  
  nsCOMPtr<nsIWidget> topWidget;
  GetTopWidget ( aWindow, getter_AddRefs(topWidget) );
  nsCOMPtr<nsIEventSink> sink ( do_QueryInterface(topWidget) );
  if ( sink ) {
    *outSink = sink;
    NS_ADDREF(*outSink);
  }
}


void CEmbedEventAttachment::ExecuteSelf(MessageT	inMessage,
	                                    void*		ioParam)
{
@@ -65,9 +108,14 @@ void CEmbedEventAttachment::ExecuteSelf(MessageT inMessage,
        inMacEvent = static_cast<EventRecord*>(ioParam);
        ::MacFindWindow(inMacEvent->where, &macWindowP);
        if (IsAlienGeckoWindow(macWindowP)) {
            mMessageSink.DispatchOSEvent(*inMacEvent, macWindowP);
            nsCOMPtr<nsIEventSink> sink;
            GetWindowEventSink(macWindowP, getter_AddRefs(sink));
            if ( sink ) {
              PRBool handled = PR_FALSE;
              sink->DispatchEvent(inMacEvent, &handled);
              SetExecuteHost(false);
            }
        }
		
	} else if (inMessage == msg_Event) {
        inMacEvent = static_cast<EventRecord*>(ioParam);
@@ -97,10 +145,15 @@ void CEmbedEventAttachment::ExecuteSelf(MessageT inMessage,
  		    {
	            SInt16 thePart = ::MacFindWindow(inMacEvent->where, &macWindowP);
	            if (thePart == inContent && IsAlienGeckoWindow(macWindowP)) {
	                mMessageSink.DispatchOSEvent(*inMacEvent, macWindowP);
                  nsCOMPtr<nsIEventSink> sink;
                  GetWindowEventSink(macWindowP, getter_AddRefs(sink));
                  if ( sink ) {
                    PRBool handled = PR_FALSE;
  	                sink->DispatchEvent(inMacEvent, &handled);
  	                mLastAlienWindowClicked = macWindowP;
  	                SetExecuteHost(false);
  	              }
	            }
	            else
	                mLastAlienWindowClicked = nil;
	        }
@@ -109,11 +162,16 @@ void CEmbedEventAttachment::ExecuteSelf(MessageT inMessage,
  		    case mouseUp:
  		    {
  		        if (mLastAlienWindowClicked) {
  		            mMessageSink.DispatchOSEvent(*inMacEvent, mLastAlienWindowClicked);
                nsCOMPtr<nsIEventSink> sink;
                GetWindowEventSink(mLastAlienWindowClicked, getter_AddRefs(sink));
                if ( sink ) {
                  PRBool handled = PR_FALSE;
  		            sink->DispatchEvent(inMacEvent, &handled);
  		            mLastAlienWindowClicked = nil;
  		            SetExecuteHost(false);
  		          }
  		        }
  		    }
  			break;
  			  	
  		    case updateEvt:
@@ -121,10 +179,15 @@ void CEmbedEventAttachment::ExecuteSelf(MessageT inMessage,
  		    {
  		      macWindowP = (WindowPtr)inMacEvent->message;
  			    if (IsAlienGeckoWindow(macWindowP)) {
  		            mMessageSink.DispatchOSEvent(*inMacEvent, macWindowP);
                nsCOMPtr<nsIEventSink> sink;
                GetWindowEventSink(macWindowP, getter_AddRefs(sink));
                if ( sink ) {
                  PRBool handled = PR_FALSE;
  		            sink->DispatchEvent(inMacEvent, &handled);
  		            SetExecuteHost(false);
  		          }
  			    }
  			}
  			break;  			
  	    }
	}
@@ -133,9 +196,18 @@ void CEmbedEventAttachment::ExecuteSelf(MessageT inMessage,

Boolean CEmbedEventAttachment::IsAlienGeckoWindow(WindowPtr inMacWindow)
{
    return (inMacWindow &&
            !LWindow::FetchWindowObject(inMacWindow) &&
	        mMessageSink.IsRaptorWindow(inMacWindow));
    PRBool isAlien = PR_FALSE;
    
    // it's an 'alien' window if there's no LWindow object and there is
    // an nsIEventSink stashed in the window's root control.
    if (inMacWindow && !LWindow::FetchWindowObject(inMacWindow)) {
      nsCOMPtr<nsIEventSink> sink;
      GetWindowEventSink ( inMacWindow, getter_AddRefs(sink) );
      if ( sink )
        isAlien = PR_TRUE;   
    }
    
    return isAlien;
}


Loading