зеркало из https://github.com/mozilla/pjs.git
Fixes for event going to frames which have changes as a result of other event handlers. (loosely bug 1283)
This commit is contained in:
Родитель
8be07679ad
Коммит
33ed7f5b51
|
@ -44,7 +44,8 @@ public:
|
||||||
NS_IMETHOD PreHandleEvent(nsIPresContext& aPresContext,
|
NS_IMETHOD PreHandleEvent(nsIPresContext& aPresContext,
|
||||||
nsGUIEvent *aEvent,
|
nsGUIEvent *aEvent,
|
||||||
nsIFrame* aTargetFrame,
|
nsIFrame* aTargetFrame,
|
||||||
nsEventStatus& aStatus) = 0;
|
nsEventStatus& aStatus,
|
||||||
|
nsIView* aView) = 0;
|
||||||
|
|
||||||
NS_IMETHOD PostHandleEvent(nsIPresContext& aPresContext,
|
NS_IMETHOD PostHandleEvent(nsIPresContext& aPresContext,
|
||||||
nsGUIEvent *aEvent,
|
nsGUIEvent *aEvent,
|
||||||
|
|
|
@ -337,14 +337,12 @@ NS_METHOD nsDOMEvent::GetButton(PRUint32* aButton)
|
||||||
// nsINSEventInterface
|
// nsINSEventInterface
|
||||||
NS_METHOD nsDOMEvent::GetLayerX(PRInt32* aLayerX)
|
NS_METHOD nsDOMEvent::GetLayerX(PRInt32* aLayerX)
|
||||||
{
|
{
|
||||||
*aLayerX = 0;
|
return GetClientX(aLayerX);
|
||||||
return NS_OK;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_METHOD nsDOMEvent::GetLayerY(PRInt32* aLayerY)
|
NS_METHOD nsDOMEvent::GetLayerY(PRInt32* aLayerY)
|
||||||
{
|
{
|
||||||
*aLayerY = 0;
|
return GetClientY(aLayerY);
|
||||||
return NS_OK;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_METHOD nsDOMEvent::GetPageX(PRInt32* aPageX)
|
NS_METHOD nsDOMEvent::GetPageX(PRInt32* aPageX)
|
||||||
|
|
|
@ -58,6 +58,7 @@ nsEventStateManager::nsEventStateManager() {
|
||||||
mLastMouseOverFrame = nsnull;
|
mLastMouseOverFrame = nsnull;
|
||||||
mLastDragOverFrame = nsnull;
|
mLastDragOverFrame = nsnull;
|
||||||
mCurrentTarget = nsnull;
|
mCurrentTarget = nsnull;
|
||||||
|
mCurrentTargetContent = nsnull;
|
||||||
mLastLeftMouseDownContent = nsnull;
|
mLastLeftMouseDownContent = nsnull;
|
||||||
mLastMiddleMouseDownContent = nsnull;
|
mLastMiddleMouseDownContent = nsnull;
|
||||||
mLastRightMouseDownContent = nsnull;
|
mLastRightMouseDownContent = nsnull;
|
||||||
|
@ -73,6 +74,7 @@ nsEventStateManager::nsEventStateManager() {
|
||||||
}
|
}
|
||||||
|
|
||||||
nsEventStateManager::~nsEventStateManager() {
|
nsEventStateManager::~nsEventStateManager() {
|
||||||
|
NS_IF_RELEASE(mCurrentTargetContent);
|
||||||
NS_IF_RELEASE(mActiveContent);
|
NS_IF_RELEASE(mActiveContent);
|
||||||
NS_IF_RELEASE(mHoverContent);
|
NS_IF_RELEASE(mHoverContent);
|
||||||
NS_IF_RELEASE(mDragOverContent);
|
NS_IF_RELEASE(mDragOverContent);
|
||||||
|
@ -91,9 +93,11 @@ NS_IMETHODIMP
|
||||||
nsEventStateManager::PreHandleEvent(nsIPresContext& aPresContext,
|
nsEventStateManager::PreHandleEvent(nsIPresContext& aPresContext,
|
||||||
nsGUIEvent *aEvent,
|
nsGUIEvent *aEvent,
|
||||||
nsIFrame* aTargetFrame,
|
nsIFrame* aTargetFrame,
|
||||||
nsEventStatus& aStatus)
|
nsEventStatus& aStatus,
|
||||||
|
nsIView* aView)
|
||||||
{
|
{
|
||||||
mCurrentTarget = aTargetFrame;
|
mCurrentTarget = aTargetFrame;
|
||||||
|
NS_IF_RELEASE(mCurrentTargetContent);
|
||||||
|
|
||||||
nsFrameState state;
|
nsFrameState state;
|
||||||
mCurrentTarget->GetFrameState(&state);
|
mCurrentTarget->GetFrameState(&state);
|
||||||
|
@ -111,6 +115,20 @@ nsEventStateManager::PreHandleEvent(nsIPresContext& aPresContext,
|
||||||
GenerateMouseEnterExit(aPresContext, aEvent);
|
GenerateMouseEnterExit(aPresContext, aEvent);
|
||||||
break;
|
break;
|
||||||
case NS_GOTFOCUS:
|
case NS_GOTFOCUS:
|
||||||
|
#if 0
|
||||||
|
nsIViewManager* viewMgr;
|
||||||
|
if (NS_SUCCEEDED(aView->GetViewManager(viewMgr)) && viewMgr) {
|
||||||
|
nsIView* rootView;
|
||||||
|
viewMgr->GetRootView(rootView);
|
||||||
|
if (rootView == aView) {
|
||||||
|
printf("send focus\n");
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
printf("don't send focus\n");
|
||||||
|
}
|
||||||
|
NS_RELEASE(viewMgr);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
//XXX Do we need window related focus change stuff here?
|
//XXX Do we need window related focus change stuff here?
|
||||||
break;
|
break;
|
||||||
case NS_LOSTFOCUS:
|
case NS_LOSTFOCUS:
|
||||||
|
@ -128,6 +146,7 @@ nsEventStateManager::PostHandleEvent(nsIPresContext& aPresContext,
|
||||||
nsIView* aView)
|
nsIView* aView)
|
||||||
{
|
{
|
||||||
mCurrentTarget = aTargetFrame;
|
mCurrentTarget = aTargetFrame;
|
||||||
|
NS_IF_RELEASE(mCurrentTargetContent);
|
||||||
nsresult ret = NS_OK;
|
nsresult ret = NS_OK;
|
||||||
|
|
||||||
nsFrameState state;
|
nsFrameState state;
|
||||||
|
@ -251,6 +270,9 @@ nsEventStateManager::ClearFrameRefs(nsIFrame* aFrame)
|
||||||
mLastMouseOverFrame = nsnull;
|
mLastMouseOverFrame = nsnull;
|
||||||
}
|
}
|
||||||
if (aFrame == mCurrentTarget) {
|
if (aFrame == mCurrentTarget) {
|
||||||
|
if (aFrame) {
|
||||||
|
aFrame->GetContent(&mCurrentTargetContent);
|
||||||
|
}
|
||||||
mCurrentTarget = nsnull;
|
mCurrentTarget = nsnull;
|
||||||
}
|
}
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
|
@ -881,7 +903,18 @@ nsEventStateManager::GetNextTabIndex(nsIContent* aParent, PRBool forward)
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
nsEventStateManager::GetEventTarget(nsIFrame **aFrame)
|
nsEventStateManager::GetEventTarget(nsIFrame **aFrame)
|
||||||
{
|
{
|
||||||
|
if (!mCurrentTarget && mCurrentTargetContent) {
|
||||||
|
nsCOMPtr<nsIPresShell> shell;
|
||||||
|
if (mPresContext) {
|
||||||
|
nsresult rv = mPresContext->GetShell(getter_AddRefs(shell));
|
||||||
|
if (NS_SUCCEEDED(rv) && shell){
|
||||||
|
shell->GetPrimaryFrameFor(mCurrentTargetContent, &mCurrentTarget);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
*aFrame = mCurrentTarget;
|
*aFrame = mCurrentTarget;
|
||||||
|
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -39,7 +39,8 @@ public:
|
||||||
NS_IMETHOD PreHandleEvent(nsIPresContext& aPresContext,
|
NS_IMETHOD PreHandleEvent(nsIPresContext& aPresContext,
|
||||||
nsGUIEvent *aEvent,
|
nsGUIEvent *aEvent,
|
||||||
nsIFrame* aTargetFrame,
|
nsIFrame* aTargetFrame,
|
||||||
nsEventStatus& aStatus);
|
nsEventStatus& aStatus,
|
||||||
|
nsIView* aView);
|
||||||
|
|
||||||
NS_IMETHOD PostHandleEvent(nsIPresContext& aPresContext,
|
NS_IMETHOD PostHandleEvent(nsIPresContext& aPresContext,
|
||||||
nsGUIEvent *aEvent,
|
nsGUIEvent *aEvent,
|
||||||
|
@ -70,6 +71,7 @@ protected:
|
||||||
|
|
||||||
//Any frames here must be checked for validity in ClearFrameRefs
|
//Any frames here must be checked for validity in ClearFrameRefs
|
||||||
nsIFrame* mCurrentTarget;
|
nsIFrame* mCurrentTarget;
|
||||||
|
nsIContent* mCurrentTargetContent;
|
||||||
nsIFrame* mLastMouseOverFrame;
|
nsIFrame* mLastMouseOverFrame;
|
||||||
nsIFrame* mLastDragOverFrame;
|
nsIFrame* mLastDragOverFrame;
|
||||||
|
|
||||||
|
|
|
@ -382,6 +382,7 @@ protected:
|
||||||
PRUint32 mReflowLockCount;
|
PRUint32 mReflowLockCount;
|
||||||
PRBool mIsDestroying;
|
PRBool mIsDestroying;
|
||||||
nsIFrame* mCurrentEventFrame;
|
nsIFrame* mCurrentEventFrame;
|
||||||
|
nsIContent* mCurrentEventContent;
|
||||||
|
|
||||||
nsCOMPtr<nsIFrameSelection> mSelection;
|
nsCOMPtr<nsIFrameSelection> mSelection;
|
||||||
nsCOMPtr<nsICaret> mCaret;
|
nsCOMPtr<nsICaret> mCaret;
|
||||||
|
@ -393,6 +394,7 @@ private:
|
||||||
void DisableScrolling(){mScrollingEnabled = PR_FALSE;}
|
void DisableScrolling(){mScrollingEnabled = PR_FALSE;}
|
||||||
void EnableScrolling(){mScrollingEnabled = PR_TRUE;}
|
void EnableScrolling(){mScrollingEnabled = PR_TRUE;}
|
||||||
PRBool IsScrollingEnabled(){return mScrollingEnabled;}
|
PRBool IsScrollingEnabled(){return mScrollingEnabled;}
|
||||||
|
nsIFrame* GetCurrentEventFrame();
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifdef NS_DEBUG
|
#ifdef NS_DEBUG
|
||||||
|
@ -459,6 +461,7 @@ PresShell::PresShell()
|
||||||
mIsDestroying = PR_FALSE;
|
mIsDestroying = PR_FALSE;
|
||||||
mCaretEnabled = PR_FALSE;
|
mCaretEnabled = PR_FALSE;
|
||||||
mDisplayNonTextSelection = PR_FALSE;
|
mDisplayNonTextSelection = PR_FALSE;
|
||||||
|
mCurrentEventContent = nsnull;
|
||||||
EnableScrolling();
|
EnableScrolling();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -540,6 +543,8 @@ PresShell::~PresShell()
|
||||||
mRefCnt = 99;/* XXX hack! get around re-entrancy bugs */
|
mRefCnt = 99;/* XXX hack! get around re-entrancy bugs */
|
||||||
|
|
||||||
mIsDestroying = PR_TRUE;
|
mIsDestroying = PR_TRUE;
|
||||||
|
|
||||||
|
NS_IF_RELEASE(mCurrentEventContent);
|
||||||
if (mViewManager) {
|
if (mViewManager) {
|
||||||
// Disable paints during tear down of the frame tree
|
// Disable paints during tear down of the frame tree
|
||||||
mViewManager->DisableRefresh();
|
mViewManager->DisableRefresh();
|
||||||
|
@ -1285,6 +1290,7 @@ PresShell::ClearFrameRefs(nsIFrame* aFrame)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (aFrame == mCurrentEventFrame) {
|
if (aFrame == mCurrentEventFrame) {
|
||||||
|
mCurrentEventFrame->GetContent(&mCurrentEventContent);
|
||||||
mCurrentEventFrame = nsnull;
|
mCurrentEventFrame = nsnull;
|
||||||
}
|
}
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
|
@ -1965,6 +1971,16 @@ PresShell::Paint(nsIView *aView,
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
nsIFrame*
|
||||||
|
PresShell::GetCurrentEventFrame()
|
||||||
|
{
|
||||||
|
if (!mCurrentEventFrame && mCurrentEventContent) {
|
||||||
|
GetPrimaryFrameFor(mCurrentEventContent, &mCurrentEventFrame);
|
||||||
|
}
|
||||||
|
|
||||||
|
return mCurrentEventFrame;
|
||||||
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
PresShell::HandleEvent(nsIView *aView,
|
PresShell::HandleEvent(nsIView *aView,
|
||||||
nsGUIEvent* aEvent,
|
nsGUIEvent* aEvent,
|
||||||
|
@ -2003,15 +2019,16 @@ PresShell::HandleEvent(nsIView *aView,
|
||||||
//we are a listener now.
|
//we are a listener now.
|
||||||
}
|
}
|
||||||
frame->GetFrameForPoint(aEvent->point, &mCurrentEventFrame);
|
frame->GetFrameForPoint(aEvent->point, &mCurrentEventFrame);
|
||||||
if (nsnull != mCurrentEventFrame) {
|
NS_IF_RELEASE(mCurrentEventContent);
|
||||||
|
if (nsnull != GetCurrentEventFrame()) {
|
||||||
//Once we have the targetFrame, handle the event in this order
|
//Once we have the targetFrame, handle the event in this order
|
||||||
nsIEventStateManager *manager;
|
nsIEventStateManager *manager;
|
||||||
if (NS_OK == mPresContext->GetEventStateManager(&manager)) {
|
if (NS_OK == mPresContext->GetEventStateManager(&manager)) {
|
||||||
//1. Give event to event manager for pre event state changes and generation of synthetic events.
|
//1. Give event to event manager for pre event state changes and generation of synthetic events.
|
||||||
rv = manager->PreHandleEvent(*mPresContext, aEvent, mCurrentEventFrame, aEventStatus);
|
rv = manager->PreHandleEvent(*mPresContext, aEvent, mCurrentEventFrame, aEventStatus, aView);
|
||||||
|
|
||||||
//2. Give event to the DOM for third party and JS use.
|
//2. Give event to the DOM for third party and JS use.
|
||||||
if (nsnull != mCurrentEventFrame && NS_OK == rv) {
|
if (nsnull != GetCurrentEventFrame() && NS_OK == rv) {
|
||||||
nsIContent* targetContent;
|
nsIContent* targetContent;
|
||||||
if (NS_OK == mCurrentEventFrame->GetContent(&targetContent) && nsnull != targetContent) {
|
if (NS_OK == mCurrentEventFrame->GetContent(&targetContent) && nsnull != targetContent) {
|
||||||
rv = targetContent->HandleDOMEvent(*mPresContext, (nsEvent*)aEvent, nsnull,
|
rv = targetContent->HandleDOMEvent(*mPresContext, (nsEvent*)aEvent, nsnull,
|
||||||
|
@ -2022,11 +2039,11 @@ PresShell::HandleEvent(nsIView *aView,
|
||||||
//3. Give event to the Frames for browser default processing.
|
//3. Give event to the Frames for browser default processing.
|
||||||
// XXX The event isn't translated into the local coordinate space
|
// XXX The event isn't translated into the local coordinate space
|
||||||
// of the frame...
|
// of the frame...
|
||||||
if (nsnull != mCurrentEventFrame && NS_OK == rv) {
|
if (nsnull != GetCurrentEventFrame() && NS_OK == rv) {
|
||||||
rv = mCurrentEventFrame->HandleEvent(*mPresContext, aEvent, aEventStatus);
|
rv = mCurrentEventFrame->HandleEvent(*mPresContext, aEvent, aEventStatus);
|
||||||
|
|
||||||
//4. Give event to event manager for post event state changes and generation of synthetic events.
|
//4. Give event to event manager for post event state changes and generation of synthetic events.
|
||||||
if (nsnull != mCurrentEventFrame && NS_OK == rv) {
|
if (nsnull != GetCurrentEventFrame() && NS_OK == rv) {
|
||||||
rv = manager->PostHandleEvent(*mPresContext, aEvent, mCurrentEventFrame, aEventStatus, aView);
|
rv = manager->PostHandleEvent(*mPresContext, aEvent, mCurrentEventFrame, aEventStatus, aView);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,7 +44,8 @@ public:
|
||||||
NS_IMETHOD PreHandleEvent(nsIPresContext& aPresContext,
|
NS_IMETHOD PreHandleEvent(nsIPresContext& aPresContext,
|
||||||
nsGUIEvent *aEvent,
|
nsGUIEvent *aEvent,
|
||||||
nsIFrame* aTargetFrame,
|
nsIFrame* aTargetFrame,
|
||||||
nsEventStatus& aStatus) = 0;
|
nsEventStatus& aStatus,
|
||||||
|
nsIView* aView) = 0;
|
||||||
|
|
||||||
NS_IMETHOD PostHandleEvent(nsIPresContext& aPresContext,
|
NS_IMETHOD PostHandleEvent(nsIPresContext& aPresContext,
|
||||||
nsGUIEvent *aEvent,
|
nsGUIEvent *aEvent,
|
||||||
|
|
|
@ -337,14 +337,12 @@ NS_METHOD nsDOMEvent::GetButton(PRUint32* aButton)
|
||||||
// nsINSEventInterface
|
// nsINSEventInterface
|
||||||
NS_METHOD nsDOMEvent::GetLayerX(PRInt32* aLayerX)
|
NS_METHOD nsDOMEvent::GetLayerX(PRInt32* aLayerX)
|
||||||
{
|
{
|
||||||
*aLayerX = 0;
|
return GetClientX(aLayerX);
|
||||||
return NS_OK;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_METHOD nsDOMEvent::GetLayerY(PRInt32* aLayerY)
|
NS_METHOD nsDOMEvent::GetLayerY(PRInt32* aLayerY)
|
||||||
{
|
{
|
||||||
*aLayerY = 0;
|
return GetClientY(aLayerY);
|
||||||
return NS_OK;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_METHOD nsDOMEvent::GetPageX(PRInt32* aPageX)
|
NS_METHOD nsDOMEvent::GetPageX(PRInt32* aPageX)
|
||||||
|
|
|
@ -58,6 +58,7 @@ nsEventStateManager::nsEventStateManager() {
|
||||||
mLastMouseOverFrame = nsnull;
|
mLastMouseOverFrame = nsnull;
|
||||||
mLastDragOverFrame = nsnull;
|
mLastDragOverFrame = nsnull;
|
||||||
mCurrentTarget = nsnull;
|
mCurrentTarget = nsnull;
|
||||||
|
mCurrentTargetContent = nsnull;
|
||||||
mLastLeftMouseDownContent = nsnull;
|
mLastLeftMouseDownContent = nsnull;
|
||||||
mLastMiddleMouseDownContent = nsnull;
|
mLastMiddleMouseDownContent = nsnull;
|
||||||
mLastRightMouseDownContent = nsnull;
|
mLastRightMouseDownContent = nsnull;
|
||||||
|
@ -73,6 +74,7 @@ nsEventStateManager::nsEventStateManager() {
|
||||||
}
|
}
|
||||||
|
|
||||||
nsEventStateManager::~nsEventStateManager() {
|
nsEventStateManager::~nsEventStateManager() {
|
||||||
|
NS_IF_RELEASE(mCurrentTargetContent);
|
||||||
NS_IF_RELEASE(mActiveContent);
|
NS_IF_RELEASE(mActiveContent);
|
||||||
NS_IF_RELEASE(mHoverContent);
|
NS_IF_RELEASE(mHoverContent);
|
||||||
NS_IF_RELEASE(mDragOverContent);
|
NS_IF_RELEASE(mDragOverContent);
|
||||||
|
@ -91,9 +93,11 @@ NS_IMETHODIMP
|
||||||
nsEventStateManager::PreHandleEvent(nsIPresContext& aPresContext,
|
nsEventStateManager::PreHandleEvent(nsIPresContext& aPresContext,
|
||||||
nsGUIEvent *aEvent,
|
nsGUIEvent *aEvent,
|
||||||
nsIFrame* aTargetFrame,
|
nsIFrame* aTargetFrame,
|
||||||
nsEventStatus& aStatus)
|
nsEventStatus& aStatus,
|
||||||
|
nsIView* aView)
|
||||||
{
|
{
|
||||||
mCurrentTarget = aTargetFrame;
|
mCurrentTarget = aTargetFrame;
|
||||||
|
NS_IF_RELEASE(mCurrentTargetContent);
|
||||||
|
|
||||||
nsFrameState state;
|
nsFrameState state;
|
||||||
mCurrentTarget->GetFrameState(&state);
|
mCurrentTarget->GetFrameState(&state);
|
||||||
|
@ -111,6 +115,20 @@ nsEventStateManager::PreHandleEvent(nsIPresContext& aPresContext,
|
||||||
GenerateMouseEnterExit(aPresContext, aEvent);
|
GenerateMouseEnterExit(aPresContext, aEvent);
|
||||||
break;
|
break;
|
||||||
case NS_GOTFOCUS:
|
case NS_GOTFOCUS:
|
||||||
|
#if 0
|
||||||
|
nsIViewManager* viewMgr;
|
||||||
|
if (NS_SUCCEEDED(aView->GetViewManager(viewMgr)) && viewMgr) {
|
||||||
|
nsIView* rootView;
|
||||||
|
viewMgr->GetRootView(rootView);
|
||||||
|
if (rootView == aView) {
|
||||||
|
printf("send focus\n");
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
printf("don't send focus\n");
|
||||||
|
}
|
||||||
|
NS_RELEASE(viewMgr);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
//XXX Do we need window related focus change stuff here?
|
//XXX Do we need window related focus change stuff here?
|
||||||
break;
|
break;
|
||||||
case NS_LOSTFOCUS:
|
case NS_LOSTFOCUS:
|
||||||
|
@ -128,6 +146,7 @@ nsEventStateManager::PostHandleEvent(nsIPresContext& aPresContext,
|
||||||
nsIView* aView)
|
nsIView* aView)
|
||||||
{
|
{
|
||||||
mCurrentTarget = aTargetFrame;
|
mCurrentTarget = aTargetFrame;
|
||||||
|
NS_IF_RELEASE(mCurrentTargetContent);
|
||||||
nsresult ret = NS_OK;
|
nsresult ret = NS_OK;
|
||||||
|
|
||||||
nsFrameState state;
|
nsFrameState state;
|
||||||
|
@ -251,6 +270,9 @@ nsEventStateManager::ClearFrameRefs(nsIFrame* aFrame)
|
||||||
mLastMouseOverFrame = nsnull;
|
mLastMouseOverFrame = nsnull;
|
||||||
}
|
}
|
||||||
if (aFrame == mCurrentTarget) {
|
if (aFrame == mCurrentTarget) {
|
||||||
|
if (aFrame) {
|
||||||
|
aFrame->GetContent(&mCurrentTargetContent);
|
||||||
|
}
|
||||||
mCurrentTarget = nsnull;
|
mCurrentTarget = nsnull;
|
||||||
}
|
}
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
|
@ -881,7 +903,18 @@ nsEventStateManager::GetNextTabIndex(nsIContent* aParent, PRBool forward)
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
nsEventStateManager::GetEventTarget(nsIFrame **aFrame)
|
nsEventStateManager::GetEventTarget(nsIFrame **aFrame)
|
||||||
{
|
{
|
||||||
|
if (!mCurrentTarget && mCurrentTargetContent) {
|
||||||
|
nsCOMPtr<nsIPresShell> shell;
|
||||||
|
if (mPresContext) {
|
||||||
|
nsresult rv = mPresContext->GetShell(getter_AddRefs(shell));
|
||||||
|
if (NS_SUCCEEDED(rv) && shell){
|
||||||
|
shell->GetPrimaryFrameFor(mCurrentTargetContent, &mCurrentTarget);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
*aFrame = mCurrentTarget;
|
*aFrame = mCurrentTarget;
|
||||||
|
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -39,7 +39,8 @@ public:
|
||||||
NS_IMETHOD PreHandleEvent(nsIPresContext& aPresContext,
|
NS_IMETHOD PreHandleEvent(nsIPresContext& aPresContext,
|
||||||
nsGUIEvent *aEvent,
|
nsGUIEvent *aEvent,
|
||||||
nsIFrame* aTargetFrame,
|
nsIFrame* aTargetFrame,
|
||||||
nsEventStatus& aStatus);
|
nsEventStatus& aStatus,
|
||||||
|
nsIView* aView);
|
||||||
|
|
||||||
NS_IMETHOD PostHandleEvent(nsIPresContext& aPresContext,
|
NS_IMETHOD PostHandleEvent(nsIPresContext& aPresContext,
|
||||||
nsGUIEvent *aEvent,
|
nsGUIEvent *aEvent,
|
||||||
|
@ -70,6 +71,7 @@ protected:
|
||||||
|
|
||||||
//Any frames here must be checked for validity in ClearFrameRefs
|
//Any frames here must be checked for validity in ClearFrameRefs
|
||||||
nsIFrame* mCurrentTarget;
|
nsIFrame* mCurrentTarget;
|
||||||
|
nsIContent* mCurrentTargetContent;
|
||||||
nsIFrame* mLastMouseOverFrame;
|
nsIFrame* mLastMouseOverFrame;
|
||||||
nsIFrame* mLastDragOverFrame;
|
nsIFrame* mLastDragOverFrame;
|
||||||
|
|
||||||
|
|
|
@ -382,6 +382,7 @@ protected:
|
||||||
PRUint32 mReflowLockCount;
|
PRUint32 mReflowLockCount;
|
||||||
PRBool mIsDestroying;
|
PRBool mIsDestroying;
|
||||||
nsIFrame* mCurrentEventFrame;
|
nsIFrame* mCurrentEventFrame;
|
||||||
|
nsIContent* mCurrentEventContent;
|
||||||
|
|
||||||
nsCOMPtr<nsIFrameSelection> mSelection;
|
nsCOMPtr<nsIFrameSelection> mSelection;
|
||||||
nsCOMPtr<nsICaret> mCaret;
|
nsCOMPtr<nsICaret> mCaret;
|
||||||
|
@ -393,6 +394,7 @@ private:
|
||||||
void DisableScrolling(){mScrollingEnabled = PR_FALSE;}
|
void DisableScrolling(){mScrollingEnabled = PR_FALSE;}
|
||||||
void EnableScrolling(){mScrollingEnabled = PR_TRUE;}
|
void EnableScrolling(){mScrollingEnabled = PR_TRUE;}
|
||||||
PRBool IsScrollingEnabled(){return mScrollingEnabled;}
|
PRBool IsScrollingEnabled(){return mScrollingEnabled;}
|
||||||
|
nsIFrame* GetCurrentEventFrame();
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifdef NS_DEBUG
|
#ifdef NS_DEBUG
|
||||||
|
@ -459,6 +461,7 @@ PresShell::PresShell()
|
||||||
mIsDestroying = PR_FALSE;
|
mIsDestroying = PR_FALSE;
|
||||||
mCaretEnabled = PR_FALSE;
|
mCaretEnabled = PR_FALSE;
|
||||||
mDisplayNonTextSelection = PR_FALSE;
|
mDisplayNonTextSelection = PR_FALSE;
|
||||||
|
mCurrentEventContent = nsnull;
|
||||||
EnableScrolling();
|
EnableScrolling();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -540,6 +543,8 @@ PresShell::~PresShell()
|
||||||
mRefCnt = 99;/* XXX hack! get around re-entrancy bugs */
|
mRefCnt = 99;/* XXX hack! get around re-entrancy bugs */
|
||||||
|
|
||||||
mIsDestroying = PR_TRUE;
|
mIsDestroying = PR_TRUE;
|
||||||
|
|
||||||
|
NS_IF_RELEASE(mCurrentEventContent);
|
||||||
if (mViewManager) {
|
if (mViewManager) {
|
||||||
// Disable paints during tear down of the frame tree
|
// Disable paints during tear down of the frame tree
|
||||||
mViewManager->DisableRefresh();
|
mViewManager->DisableRefresh();
|
||||||
|
@ -1285,6 +1290,7 @@ PresShell::ClearFrameRefs(nsIFrame* aFrame)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (aFrame == mCurrentEventFrame) {
|
if (aFrame == mCurrentEventFrame) {
|
||||||
|
mCurrentEventFrame->GetContent(&mCurrentEventContent);
|
||||||
mCurrentEventFrame = nsnull;
|
mCurrentEventFrame = nsnull;
|
||||||
}
|
}
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
|
@ -1965,6 +1971,16 @@ PresShell::Paint(nsIView *aView,
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
nsIFrame*
|
||||||
|
PresShell::GetCurrentEventFrame()
|
||||||
|
{
|
||||||
|
if (!mCurrentEventFrame && mCurrentEventContent) {
|
||||||
|
GetPrimaryFrameFor(mCurrentEventContent, &mCurrentEventFrame);
|
||||||
|
}
|
||||||
|
|
||||||
|
return mCurrentEventFrame;
|
||||||
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
PresShell::HandleEvent(nsIView *aView,
|
PresShell::HandleEvent(nsIView *aView,
|
||||||
nsGUIEvent* aEvent,
|
nsGUIEvent* aEvent,
|
||||||
|
@ -2003,15 +2019,16 @@ PresShell::HandleEvent(nsIView *aView,
|
||||||
//we are a listener now.
|
//we are a listener now.
|
||||||
}
|
}
|
||||||
frame->GetFrameForPoint(aEvent->point, &mCurrentEventFrame);
|
frame->GetFrameForPoint(aEvent->point, &mCurrentEventFrame);
|
||||||
if (nsnull != mCurrentEventFrame) {
|
NS_IF_RELEASE(mCurrentEventContent);
|
||||||
|
if (nsnull != GetCurrentEventFrame()) {
|
||||||
//Once we have the targetFrame, handle the event in this order
|
//Once we have the targetFrame, handle the event in this order
|
||||||
nsIEventStateManager *manager;
|
nsIEventStateManager *manager;
|
||||||
if (NS_OK == mPresContext->GetEventStateManager(&manager)) {
|
if (NS_OK == mPresContext->GetEventStateManager(&manager)) {
|
||||||
//1. Give event to event manager for pre event state changes and generation of synthetic events.
|
//1. Give event to event manager for pre event state changes and generation of synthetic events.
|
||||||
rv = manager->PreHandleEvent(*mPresContext, aEvent, mCurrentEventFrame, aEventStatus);
|
rv = manager->PreHandleEvent(*mPresContext, aEvent, mCurrentEventFrame, aEventStatus, aView);
|
||||||
|
|
||||||
//2. Give event to the DOM for third party and JS use.
|
//2. Give event to the DOM for third party and JS use.
|
||||||
if (nsnull != mCurrentEventFrame && NS_OK == rv) {
|
if (nsnull != GetCurrentEventFrame() && NS_OK == rv) {
|
||||||
nsIContent* targetContent;
|
nsIContent* targetContent;
|
||||||
if (NS_OK == mCurrentEventFrame->GetContent(&targetContent) && nsnull != targetContent) {
|
if (NS_OK == mCurrentEventFrame->GetContent(&targetContent) && nsnull != targetContent) {
|
||||||
rv = targetContent->HandleDOMEvent(*mPresContext, (nsEvent*)aEvent, nsnull,
|
rv = targetContent->HandleDOMEvent(*mPresContext, (nsEvent*)aEvent, nsnull,
|
||||||
|
@ -2022,11 +2039,11 @@ PresShell::HandleEvent(nsIView *aView,
|
||||||
//3. Give event to the Frames for browser default processing.
|
//3. Give event to the Frames for browser default processing.
|
||||||
// XXX The event isn't translated into the local coordinate space
|
// XXX The event isn't translated into the local coordinate space
|
||||||
// of the frame...
|
// of the frame...
|
||||||
if (nsnull != mCurrentEventFrame && NS_OK == rv) {
|
if (nsnull != GetCurrentEventFrame() && NS_OK == rv) {
|
||||||
rv = mCurrentEventFrame->HandleEvent(*mPresContext, aEvent, aEventStatus);
|
rv = mCurrentEventFrame->HandleEvent(*mPresContext, aEvent, aEventStatus);
|
||||||
|
|
||||||
//4. Give event to event manager for post event state changes and generation of synthetic events.
|
//4. Give event to event manager for post event state changes and generation of synthetic events.
|
||||||
if (nsnull != mCurrentEventFrame && NS_OK == rv) {
|
if (nsnull != GetCurrentEventFrame() && NS_OK == rv) {
|
||||||
rv = manager->PostHandleEvent(*mPresContext, aEvent, mCurrentEventFrame, aEventStatus, aView);
|
rv = manager->PostHandleEvent(*mPresContext, aEvent, mCurrentEventFrame, aEventStatus, aView);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Загрузка…
Ссылка в новой задаче