Bug 352093. Part 1: Add view parameter to nsViewManager::DispatchEvent so we can target view system events to widget-less documents. r=bzbarsky

This commit is contained in:
Robert O'Callahan 2009-07-22 12:44:59 +12:00
Родитель 40d4fa9b66
Коммит e59d6268de
6 изменённых файлов: 28 добавлений и 25 удалений

Просмотреть файл

@ -299,7 +299,7 @@ nsWidgetUtils::MouseMove(nsIDOMEvent* aDOMEvent)
nsMouseScrollEvent scrollEventX(PR_TRUE, NS_MOUSE_SCROLL, mWidget);
scrollEventX.delta = dx;
scrollEventX.scrollFlags = nsMouseScrollEvent::kIsHorizontal | nsMouseScrollEvent::kIsPixels;
mViewManager->DispatchEvent(&scrollEventX, &statusX);
mViewManager->DispatchEvent(&scrollEventX, aView, &statusX);
if(statusX != nsEventStatus_eIgnore ){
if (dx > 5)
g_panning = PR_TRUE;
@ -310,7 +310,7 @@ nsWidgetUtils::MouseMove(nsIDOMEvent* aDOMEvent)
nsMouseScrollEvent scrollEventY(PR_TRUE, NS_MOUSE_SCROLL, mWidget);
scrollEventY.delta = dy;
scrollEventY.scrollFlags = nsMouseScrollEvent::kIsVertical | nsMouseScrollEvent::kIsPixels;
mViewManager->DispatchEvent(&scrollEventY, &statusY);
mViewManager->DispatchEvent(&scrollEventY, aView, &statusY);
if(statusY != nsEventStatus_eIgnore ){
if (dy > 5)
g_panning = PR_TRUE;

Просмотреть файл

@ -4476,7 +4476,9 @@ PresShell::DispatchSynthMouseMove(nsGUIEvent *aEvent,
{
PRUint32 hoverGenerationBefore = mFrameConstructor->GetHoverGeneration();
nsEventStatus status;
mViewManager->DispatchEvent(aEvent, &status);
nsIView* rootView;
mViewManager->GetRootView(rootView);
mViewManager->DispatchEvent(aEvent, rootView, &status);
if (aFlushOnHoverChange &&
hoverGenerationBefore != mFrameConstructor->GetHoverGeneration()) {
// Flush so that the resulting reflow happens now so that our caller

Просмотреть файл

@ -59,10 +59,10 @@ enum nsRectVisibility {
nsRectVisibility_kZeroAreaRect
};
// fa490965-ebd0-4203-836c-51c42d01fedb
// 98f676da-eb1a-467d-9c0e-0d64c2c88d85
#define NS_IVIEWMANAGER_IID \
{ 0xfa490965, 0xebd0, 0x4203, \
{ 0x83, 0x6c, 0x51, 0xc4, 0x2d, 0x01, 0xfe, 0xdb } }
{ 0x98f676da, 0xeb1a, 0x467d, \
{ 0x9c, 0x0e, 0x0d, 0x64, 0xc2, 0xc8, 0x8d, 0x85 } }
class nsIViewManager : public nsISupports
{
@ -181,10 +181,12 @@ public:
* Called to dispatch an event to the appropriate view. Often called
* as a result of receiving a mouse or keyboard event from the widget
* event system.
* @param event event to dispatch
* @result event handling status
* @param aEvent event to dispatch
* @param aViewTarget dispatch the event to this view
* @param aStatus event handling status
*/
NS_IMETHOD DispatchEvent(nsGUIEvent *aEvent, nsEventStatus* aStatus) = 0;
NS_IMETHOD DispatchEvent(nsGUIEvent *aEvent,
nsIView* aViewTarget, nsEventStatus* aStatus) = 0;
/**
* Used to grab/capture all mouse events for a specific view,

Просмотреть файл

@ -165,7 +165,7 @@ nsEventStatus HandleEvent(nsGUIEvent *aEvent)
if (view)
{
nsCOMPtr<nsIViewManager> vm = view->GetViewManager();
vm->DispatchEvent(aEvent, &result);
vm->DispatchEvent(aEvent, view, &result);
}
return result;

Просмотреть файл

@ -863,7 +863,8 @@ void nsViewManager::UpdateViews(nsView *aView, PRUint32 aUpdateFlags)
}
}
NS_IMETHODIMP nsViewManager::DispatchEvent(nsGUIEvent *aEvent, nsEventStatus *aStatus)
NS_IMETHODIMP nsViewManager::DispatchEvent(nsGUIEvent *aEvent,
nsIView* aView, nsEventStatus *aStatus)
{
*aStatus = nsEventStatus_eIgnore;
@ -871,9 +872,7 @@ NS_IMETHODIMP nsViewManager::DispatchEvent(nsGUIEvent *aEvent, nsEventStatus *aS
{
case NS_SIZE:
{
nsView* view = nsView::GetViewFor(aEvent->widget);
if (nsnull != view)
if (aView)
{
nscoord width = ((nsSizeEvent*)aEvent)->windowSize->width;
nscoord height = ((nsSizeEvent*)aEvent)->windowSize->height;
@ -883,7 +882,7 @@ NS_IMETHODIMP nsViewManager::DispatchEvent(nsGUIEvent *aEvent, nsEventStatus *aS
// The root view may not be set if this is the resize associated with
// window creation
if (view == mRootView)
if (aView == mRootView)
{
PRInt32 p2a = mContext->AppUnitsPerDevPixel();
SetWindowDimensions(NSIntPixelsToAppUnits(width, p2a),
@ -898,9 +897,8 @@ NS_IMETHODIMP nsViewManager::DispatchEvent(nsGUIEvent *aEvent, nsEventStatus *aS
case NS_PAINT:
{
nsPaintEvent *event = static_cast<nsPaintEvent*>(aEvent);
nsView *view = nsView::GetViewFor(aEvent->widget);
if (!view || !mContext)
if (!aView || !mContext)
break;
*aStatus = nsEventStatus_eConsumeNoDefault;
@ -957,6 +955,7 @@ NS_IMETHODIMP nsViewManager::DispatchEvent(nsGUIEvent *aEvent, nsEventStatus *aS
if (widget)
transparentWindow = widget->GetTransparencyMode() == eTransparencyTransparent;
nsView* view = static_cast<nsView*>(aView);
if (rootVM->mScrollCnt == 0 && !transparentWindow) {
nsIViewObserver* observer = GetViewObserver();
if (observer) {
@ -1003,10 +1002,10 @@ NS_IMETHODIMP nsViewManager::DispatchEvent(nsGUIEvent *aEvent, nsEventStatus *aS
nsCOMPtr<nsIRenderingContext> context = event->renderingContext;
if (!context)
context = CreateRenderingContext(*view);
context = CreateRenderingContext(*static_cast<nsView*>(aView));
if (context)
mObserver->PaintDefaultBackground(view, context, damRect);
mObserver->PaintDefaultBackground(aView, context, damRect);
else
NS_WARNING("nsViewManager: no rc for default refresh");
@ -1034,7 +1033,7 @@ NS_IMETHODIMP nsViewManager::DispatchEvent(nsGUIEvent *aEvent, nsEventStatus *aS
// ScrollingView's viewable area. (See bug 97674 for this
// alternate patch.)
UpdateView(view, damRect, NS_VMREFRESH_NO_SYNC);
UpdateView(aView, damRect, NS_VMREFRESH_NO_SYNC);
}
break;
@ -1064,10 +1063,9 @@ NS_IMETHODIMP nsViewManager::DispatchEvent(nsGUIEvent *aEvent, nsEventStatus *aS
// 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.
nsView *view = nsView::GetViewFor(aEvent->widget);
nsCOMPtr<nsIViewObserver> obs = GetViewObserver();
if (obs) {
obs->HandleEvent(view, aEvent, aStatus);
obs->HandleEvent(aView, aEvent, aStatus);
}
}
break;
@ -1095,7 +1093,7 @@ NS_IMETHODIMP nsViewManager::DispatchEvent(nsGUIEvent *aEvent, nsEventStatus *aS
}
//Find the view whose coordinates system we're in.
nsView* baseView = nsView::GetViewFor(aEvent->widget);
nsView* baseView = static_cast<nsView*>(aView);
nsView* view = baseView;
PRBool capturedEvent = PR_FALSE;
@ -1177,7 +1175,7 @@ NS_IMETHODIMP nsViewManager::DispatchEvent(nsGUIEvent *aEvent, nsEventStatus *aS
// Dispatch the event
nsRect baseViewDimensions;
if (baseView != nsnull) {
if (baseView) {
baseView->GetDimensions(baseViewDimensions);
}

Просмотреть файл

@ -130,7 +130,8 @@ public:
NS_IMETHOD UpdateView(nsIView *aView, const nsRect &aRect, PRUint32 aUpdateFlags);
NS_IMETHOD UpdateAllViews(PRUint32 aUpdateFlags);
NS_IMETHOD DispatchEvent(nsGUIEvent *aEvent, nsEventStatus* aStatus);
NS_IMETHOD DispatchEvent(nsGUIEvent *aEvent,
nsIView* aTargetView, nsEventStatus* aStatus);
NS_IMETHOD GrabMouseEvents(nsIView *aView, PRBool &aResult);