зеркало из https://github.com/mozilla/gecko-dev.git
Adding scrolling fixes to fix bug #3999, A: chofmann
This commit is contained in:
Родитель
f27057e20e
Коммит
d1f2b3ef88
|
@ -27,6 +27,7 @@ class nsIContent;
|
|||
class nsIPresContext;
|
||||
class nsIDOMEvent;
|
||||
class nsIFrame;
|
||||
class nsIView;
|
||||
|
||||
/*
|
||||
* Event listener manager interface.
|
||||
|
@ -48,7 +49,8 @@ public:
|
|||
NS_IMETHOD PostHandleEvent(nsIPresContext& aPresContext,
|
||||
nsGUIEvent *aEvent,
|
||||
nsIFrame* aTargetFrame,
|
||||
nsEventStatus& aStatus) = 0;
|
||||
nsEventStatus& aStatus,
|
||||
nsIView* aView) = 0;
|
||||
|
||||
NS_IMETHOD SetPresContext(nsIPresContext* aPresContext) = 0;
|
||||
NS_IMETHOD ClearFrameRefs(nsIFrame* aFrame) = 0;
|
||||
|
|
|
@ -37,6 +37,7 @@
|
|||
#include "nsINameSpaceManager.h" // for kNameSpaceID_HTML
|
||||
#include "nsIWebShell.h"
|
||||
#include "nsIFocusableContent.h"
|
||||
#include "nsIScrollableView.h"
|
||||
|
||||
static NS_DEFINE_IID(kIEventStateManagerIID, NS_IEVENTSTATEMANAGER_IID);
|
||||
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
|
||||
|
@ -49,6 +50,7 @@ static NS_DEFINE_IID(kIDOMHTMLObjectElementIID, NS_IDOMHTMLOBJECTELEMENT_IID);
|
|||
static NS_DEFINE_IID(kIDOMHTMLButtonElementIID, NS_IDOMHTMLBUTTONELEMENT_IID);
|
||||
static NS_DEFINE_IID(kIWebShellIID, NS_IWEB_SHELL_IID);
|
||||
static NS_DEFINE_IID(kIFocusableContentIID, NS_IFOCUSABLECONTENT_IID);
|
||||
static NS_DEFINE_IID(kIScrollableViewIID, NS_ISCROLLABLEVIEW_IID);
|
||||
|
||||
nsEventStateManager::nsEventStateManager() {
|
||||
mLastMouseOverFrame = nsnull;
|
||||
|
@ -114,7 +116,8 @@ NS_IMETHODIMP
|
|||
nsEventStateManager::PostHandleEvent(nsIPresContext& aPresContext,
|
||||
nsGUIEvent *aEvent,
|
||||
nsIFrame* aTargetFrame,
|
||||
nsEventStatus& aStatus)
|
||||
nsEventStatus& aStatus,
|
||||
nsIView* aView)
|
||||
{
|
||||
mCurrentTarget = aTargetFrame;
|
||||
nsresult ret = NS_OK;
|
||||
|
@ -139,6 +142,7 @@ nsEventStateManager::PostHandleEvent(nsIPresContext& aPresContext,
|
|||
if (nsnull != aEvent->widget) {
|
||||
aEvent->widget->SetFocus();
|
||||
}
|
||||
SetContentState(nsnull, NS_EVENT_STATE_FOCUS);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -166,9 +170,24 @@ nsEventStateManager::PostHandleEvent(nsIPresContext& aPresContext,
|
|||
break;
|
||||
case NS_VK_PAGE_DOWN:
|
||||
case NS_VK_PAGE_UP:
|
||||
case NS_VK_SPACE:
|
||||
if (!mCurrentFocus) {
|
||||
nsIScrollableView* sv = GetNearestScrollingView(aView);
|
||||
if (sv) {
|
||||
nsKeyEvent * keyEvent = (nsKeyEvent *)aEvent;
|
||||
sv->ScrollByPages((keyEvent->keyCode != NS_VK_PAGE_UP) ? 1 : -1);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case NS_VK_DOWN:
|
||||
case NS_VK_UP:
|
||||
if (!mCurrentFocus) {
|
||||
nsIScrollableView* sv = GetNearestScrollingView(aView);
|
||||
if (sv) {
|
||||
nsKeyEvent * keyEvent = (nsKeyEvent *)aEvent;
|
||||
sv->ScrollByLines((keyEvent->keyCode == NS_VK_DOWN) ? 1 : -1);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -196,6 +215,24 @@ nsEventStateManager::ClearFrameRefs(nsIFrame* aFrame)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
nsIScrollableView*
|
||||
nsEventStateManager::GetNearestScrollingView(nsIView* aView)
|
||||
{
|
||||
nsIScrollableView* sv;
|
||||
if (NS_OK == aView->QueryInterface(kIScrollableViewIID, (void**)&sv)) {
|
||||
return sv;
|
||||
}
|
||||
|
||||
nsIView* parent;
|
||||
aView->GetParent(parent);
|
||||
|
||||
if (nsnull != parent) {
|
||||
return GetNearestScrollingView(parent);
|
||||
}
|
||||
|
||||
return nsnull;
|
||||
}
|
||||
|
||||
void
|
||||
nsEventStateManager::UpdateCursor(nsIPresContext& aPresContext, nsPoint& aPoint, nsIFrame* aTargetFrame,
|
||||
nsEventStatus& aStatus)
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
#include "nsIEventStateManager.h"
|
||||
#include "nsGUIEvent.h"
|
||||
class nsIDocument;
|
||||
class nsIScrollableView;
|
||||
|
||||
/*
|
||||
* Event listener manager
|
||||
|
@ -43,7 +44,8 @@ public:
|
|||
NS_IMETHOD PostHandleEvent(nsIPresContext& aPresContext,
|
||||
nsGUIEvent *aEvent,
|
||||
nsIFrame* aTargetFrame,
|
||||
nsEventStatus& aStatus);
|
||||
nsEventStatus& aStatus,
|
||||
nsIView* aView);
|
||||
|
||||
NS_IMETHOD SetPresContext(nsIPresContext* aPresContext);
|
||||
NS_IMETHOD ClearFrameRefs(nsIFrame* aFrame);
|
||||
|
@ -63,6 +65,7 @@ protected:
|
|||
nsIContent* GetNextTabbableContent(nsIContent* aParent, nsIContent* aChild, nsIContent* aTop, PRBool foward);
|
||||
PRInt32 GetNextTabIndex(nsIContent* aParent, PRBool foward);
|
||||
NS_IMETHOD SendFocusBlur(nsIContent *aContent);
|
||||
nsIScrollableView* GetNearestScrollingView(nsIView* aView);
|
||||
|
||||
//Any frames here must be checked for validity in ClearFrameRefs
|
||||
nsIFrame* mCurrentTarget;
|
||||
|
|
|
@ -188,16 +188,23 @@ nsTextEditorKeyListener::KeyDown(nsIDOMEvent* aKeyEvent)
|
|||
case nsIDOMEvent::VK_DOWN:
|
||||
// these have already been handled in nsRangeList. Why are we getting them
|
||||
// again here (Mac)? In switch to avoid putting in bogus chars.
|
||||
|
||||
//return NS_OK to allow page scrolling.
|
||||
return NS_OK;
|
||||
break;
|
||||
|
||||
case nsIDOMEvent::VK_HOME:
|
||||
case nsIDOMEvent::VK_END:
|
||||
case nsIDOMEvent::VK_PAGE_UP:
|
||||
case nsIDOMEvent::VK_PAGE_DOWN:
|
||||
// who handles these?
|
||||
#if DEBUG
|
||||
printf("Key not handled\n");
|
||||
#endif
|
||||
break;
|
||||
|
||||
case nsIDOMEvent::VK_PAGE_UP:
|
||||
case nsIDOMEvent::VK_PAGE_DOWN:
|
||||
//return NS_OK to allow page scrolling.
|
||||
return NS_OK;
|
||||
break;
|
||||
|
||||
default:
|
||||
|
|
|
@ -188,16 +188,23 @@ nsTextEditorKeyListener::KeyDown(nsIDOMEvent* aKeyEvent)
|
|||
case nsIDOMEvent::VK_DOWN:
|
||||
// these have already been handled in nsRangeList. Why are we getting them
|
||||
// again here (Mac)? In switch to avoid putting in bogus chars.
|
||||
|
||||
//return NS_OK to allow page scrolling.
|
||||
return NS_OK;
|
||||
break;
|
||||
|
||||
case nsIDOMEvent::VK_HOME:
|
||||
case nsIDOMEvent::VK_END:
|
||||
case nsIDOMEvent::VK_PAGE_UP:
|
||||
case nsIDOMEvent::VK_PAGE_DOWN:
|
||||
// who handles these?
|
||||
#if DEBUG
|
||||
printf("Key not handled\n");
|
||||
#endif
|
||||
break;
|
||||
|
||||
case nsIDOMEvent::VK_PAGE_UP:
|
||||
case nsIDOMEvent::VK_PAGE_DOWN:
|
||||
//return NS_OK to allow page scrolling.
|
||||
return NS_OK;
|
||||
break;
|
||||
|
||||
default:
|
||||
|
|
|
@ -2005,7 +2005,7 @@ PresShell::HandleEvent(nsIView *aView,
|
|||
|
||||
//4. Give event to event manager for post event state changes and generation of synthetic events.
|
||||
if (nsnull != mCurrentEventFrame && NS_OK == rv) {
|
||||
rv = manager->PostHandleEvent(*mPresContext, aEvent, mCurrentEventFrame, aEventStatus);
|
||||
rv = manager->PostHandleEvent(*mPresContext, aEvent, mCurrentEventFrame, aEventStatus, aView);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -27,6 +27,7 @@ class nsIContent;
|
|||
class nsIPresContext;
|
||||
class nsIDOMEvent;
|
||||
class nsIFrame;
|
||||
class nsIView;
|
||||
|
||||
/*
|
||||
* Event listener manager interface.
|
||||
|
@ -48,7 +49,8 @@ public:
|
|||
NS_IMETHOD PostHandleEvent(nsIPresContext& aPresContext,
|
||||
nsGUIEvent *aEvent,
|
||||
nsIFrame* aTargetFrame,
|
||||
nsEventStatus& aStatus) = 0;
|
||||
nsEventStatus& aStatus,
|
||||
nsIView* aView) = 0;
|
||||
|
||||
NS_IMETHOD SetPresContext(nsIPresContext* aPresContext) = 0;
|
||||
NS_IMETHOD ClearFrameRefs(nsIFrame* aFrame) = 0;
|
||||
|
|
|
@ -37,6 +37,7 @@
|
|||
#include "nsINameSpaceManager.h" // for kNameSpaceID_HTML
|
||||
#include "nsIWebShell.h"
|
||||
#include "nsIFocusableContent.h"
|
||||
#include "nsIScrollableView.h"
|
||||
|
||||
static NS_DEFINE_IID(kIEventStateManagerIID, NS_IEVENTSTATEMANAGER_IID);
|
||||
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
|
||||
|
@ -49,6 +50,7 @@ static NS_DEFINE_IID(kIDOMHTMLObjectElementIID, NS_IDOMHTMLOBJECTELEMENT_IID);
|
|||
static NS_DEFINE_IID(kIDOMHTMLButtonElementIID, NS_IDOMHTMLBUTTONELEMENT_IID);
|
||||
static NS_DEFINE_IID(kIWebShellIID, NS_IWEB_SHELL_IID);
|
||||
static NS_DEFINE_IID(kIFocusableContentIID, NS_IFOCUSABLECONTENT_IID);
|
||||
static NS_DEFINE_IID(kIScrollableViewIID, NS_ISCROLLABLEVIEW_IID);
|
||||
|
||||
nsEventStateManager::nsEventStateManager() {
|
||||
mLastMouseOverFrame = nsnull;
|
||||
|
@ -114,7 +116,8 @@ NS_IMETHODIMP
|
|||
nsEventStateManager::PostHandleEvent(nsIPresContext& aPresContext,
|
||||
nsGUIEvent *aEvent,
|
||||
nsIFrame* aTargetFrame,
|
||||
nsEventStatus& aStatus)
|
||||
nsEventStatus& aStatus,
|
||||
nsIView* aView)
|
||||
{
|
||||
mCurrentTarget = aTargetFrame;
|
||||
nsresult ret = NS_OK;
|
||||
|
@ -139,6 +142,7 @@ nsEventStateManager::PostHandleEvent(nsIPresContext& aPresContext,
|
|||
if (nsnull != aEvent->widget) {
|
||||
aEvent->widget->SetFocus();
|
||||
}
|
||||
SetContentState(nsnull, NS_EVENT_STATE_FOCUS);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -166,9 +170,24 @@ nsEventStateManager::PostHandleEvent(nsIPresContext& aPresContext,
|
|||
break;
|
||||
case NS_VK_PAGE_DOWN:
|
||||
case NS_VK_PAGE_UP:
|
||||
case NS_VK_SPACE:
|
||||
if (!mCurrentFocus) {
|
||||
nsIScrollableView* sv = GetNearestScrollingView(aView);
|
||||
if (sv) {
|
||||
nsKeyEvent * keyEvent = (nsKeyEvent *)aEvent;
|
||||
sv->ScrollByPages((keyEvent->keyCode != NS_VK_PAGE_UP) ? 1 : -1);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case NS_VK_DOWN:
|
||||
case NS_VK_UP:
|
||||
if (!mCurrentFocus) {
|
||||
nsIScrollableView* sv = GetNearestScrollingView(aView);
|
||||
if (sv) {
|
||||
nsKeyEvent * keyEvent = (nsKeyEvent *)aEvent;
|
||||
sv->ScrollByLines((keyEvent->keyCode == NS_VK_DOWN) ? 1 : -1);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -196,6 +215,24 @@ nsEventStateManager::ClearFrameRefs(nsIFrame* aFrame)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
nsIScrollableView*
|
||||
nsEventStateManager::GetNearestScrollingView(nsIView* aView)
|
||||
{
|
||||
nsIScrollableView* sv;
|
||||
if (NS_OK == aView->QueryInterface(kIScrollableViewIID, (void**)&sv)) {
|
||||
return sv;
|
||||
}
|
||||
|
||||
nsIView* parent;
|
||||
aView->GetParent(parent);
|
||||
|
||||
if (nsnull != parent) {
|
||||
return GetNearestScrollingView(parent);
|
||||
}
|
||||
|
||||
return nsnull;
|
||||
}
|
||||
|
||||
void
|
||||
nsEventStateManager::UpdateCursor(nsIPresContext& aPresContext, nsPoint& aPoint, nsIFrame* aTargetFrame,
|
||||
nsEventStatus& aStatus)
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
#include "nsIEventStateManager.h"
|
||||
#include "nsGUIEvent.h"
|
||||
class nsIDocument;
|
||||
class nsIScrollableView;
|
||||
|
||||
/*
|
||||
* Event listener manager
|
||||
|
@ -43,7 +44,8 @@ public:
|
|||
NS_IMETHOD PostHandleEvent(nsIPresContext& aPresContext,
|
||||
nsGUIEvent *aEvent,
|
||||
nsIFrame* aTargetFrame,
|
||||
nsEventStatus& aStatus);
|
||||
nsEventStatus& aStatus,
|
||||
nsIView* aView);
|
||||
|
||||
NS_IMETHOD SetPresContext(nsIPresContext* aPresContext);
|
||||
NS_IMETHOD ClearFrameRefs(nsIFrame* aFrame);
|
||||
|
@ -63,6 +65,7 @@ protected:
|
|||
nsIContent* GetNextTabbableContent(nsIContent* aParent, nsIContent* aChild, nsIContent* aTop, PRBool foward);
|
||||
PRInt32 GetNextTabIndex(nsIContent* aParent, PRBool foward);
|
||||
NS_IMETHOD SendFocusBlur(nsIContent *aContent);
|
||||
nsIScrollableView* GetNearestScrollingView(nsIView* aView);
|
||||
|
||||
//Any frames here must be checked for validity in ClearFrameRefs
|
||||
nsIFrame* mCurrentTarget;
|
||||
|
|
|
@ -2005,7 +2005,7 @@ PresShell::HandleEvent(nsIView *aView,
|
|||
|
||||
//4. Give event to event manager for post event state changes and generation of synthetic events.
|
||||
if (nsnull != mCurrentEventFrame && NS_OK == rv) {
|
||||
rv = manager->PostHandleEvent(*mPresContext, aEvent, mCurrentEventFrame, aEventStatus);
|
||||
rv = manager->PostHandleEvent(*mPresContext, aEvent, mCurrentEventFrame, aEventStatus, aView);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -745,131 +745,6 @@ void nsScrollingView :: Notify(nsITimer * aTimer)
|
|||
mScrollingTimer->Init(this, 25);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsScrollingView :: HandleEvent(nsGUIEvent *aEvent, PRUint32 aEventFlags,
|
||||
nsEventStatus &aStatus)
|
||||
{
|
||||
switch (aEvent->message)
|
||||
{
|
||||
case NS_KEY_DOWN:
|
||||
{
|
||||
nsKeyEvent * keyEvent = (nsKeyEvent *)aEvent;
|
||||
|
||||
switch (keyEvent->keyCode)
|
||||
{
|
||||
case NS_VK_PAGE_DOWN:
|
||||
case NS_VK_PAGE_UP:
|
||||
case NS_VK_SPACE:
|
||||
ScrollByPages((keyEvent->keyCode != NS_VK_PAGE_UP) ? 1 : -1);
|
||||
break;
|
||||
|
||||
case NS_VK_DOWN:
|
||||
case NS_VK_UP:
|
||||
ScrollByLines((keyEvent->keyCode == NS_VK_DOWN) ? 1 : -1);
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
#if 0
|
||||
case NS_MOUSE_MOVE:
|
||||
{
|
||||
nsRect brect;
|
||||
nscoord lx, ly;
|
||||
|
||||
GetWidget(win);
|
||||
|
||||
GetBounds(brect);
|
||||
|
||||
// XXX Huh. We shouldn't just be doing this for any mouse move.
|
||||
// If this is for auto-scrolling then only on mouse press and drag...
|
||||
lx = aEvent->point.x - (brect.x);
|
||||
ly = aEvent->point.y - (brect.y);
|
||||
|
||||
//nscoord xoff, yoff;
|
||||
//GetScrolledView()->GetScrollOffset(&xoff, &yoff);
|
||||
//printf("%d %d %d\n", trect.y, trect.height, yoff);
|
||||
//printf("mouse %d %d \n", aEvent->point.x, aEvent->point.y);
|
||||
|
||||
if (!brect.Contains(lx, ly))
|
||||
{
|
||||
if (mScrollingTimer == nsnull)
|
||||
{
|
||||
if (nsnull != mClientData)
|
||||
{
|
||||
if (ly < 0 || ly > brect.y)
|
||||
{
|
||||
mScrollingDelta = ly < 0 ? -100 : 100;
|
||||
NS_NewTimer(&mScrollingTimer);
|
||||
mScrollingTimer->Init(this, 25);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (mScrollingTimer != nsnull)
|
||||
{
|
||||
mScrollingTimer->Cancel();
|
||||
NS_RELEASE(mScrollingTimer);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case NS_MOUSE_LEFT_BUTTON_UP:
|
||||
case NS_MOUSE_MIDDLE_BUTTON_UP:
|
||||
case NS_MOUSE_RIGHT_BUTTON_UP:
|
||||
{
|
||||
if (mScrollingTimer != nsnull)
|
||||
{
|
||||
mScrollingTimer->Cancel();
|
||||
NS_RELEASE(mScrollingTimer);
|
||||
mScrollingTimer = nsnull;
|
||||
}
|
||||
|
||||
nsRect trect;
|
||||
nscoord lx, ly;
|
||||
|
||||
GetBounds(trect);
|
||||
|
||||
//GetWidget(win);
|
||||
//mViewManager->GetDeviceContext(dx);
|
||||
//dx->GetDevUnitsToAppUnits(p2t);
|
||||
//offX = offY = 0;
|
||||
//win->ConvertToDeviceCoordinates(offX,offY);
|
||||
//offX = NSIntPixelsToTwips(offX, p2t);
|
||||
//offY = NSIntPixelsToTwips(offY, p2t);
|
||||
|
||||
lx = aEvent->point.x - (trect.x);
|
||||
ly = aEvent->point.y - (trect.y);
|
||||
|
||||
if (!trect.Contains(lx, ly))
|
||||
{
|
||||
nsEventStatus retval;
|
||||
|
||||
if (nsnull != mClientData)
|
||||
{
|
||||
nsIViewObserver *obs;
|
||||
|
||||
if (NS_OK == mViewManager->GetViewObserver(obs))
|
||||
{
|
||||
obs->HandleEvent((nsIView *)this, aEvent, retval);
|
||||
NS_RELEASE(obs);
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return nsView::HandleEvent(aEvent, aEventFlags, aStatus);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsScrollingView :: CreateScrollControls(nsNativeWidget aNative)
|
||||
{
|
||||
nsIDeviceContext *dx;
|
||||
|
|
|
@ -46,7 +46,6 @@ public:
|
|||
// SetVisibility is overriden so that it will set it's components visibility (ClipView,
|
||||
// CornerView, ScrollBarView's),as well as it's own visibility.
|
||||
NS_IMETHOD SetVisibility(nsViewVisibility visibility);
|
||||
NS_IMETHOD HandleEvent(nsGUIEvent *aEvent, PRUint32 aEventFlags, nsEventStatus &aStatus);
|
||||
NS_IMETHOD SetWidget(nsIWidget *aWidget);
|
||||
|
||||
//nsIScrollableView interface
|
||||
|
|
Загрузка…
Ссылка в новой задаче