зеркало из https://github.com/mozilla/pjs.git
Fixing a submit/reset event bug, frame destruction reentrancy bug, and an imagemap bug.
This commit is contained in:
Родитель
0b569910d9
Коммит
ecbb1182ec
|
@ -305,7 +305,7 @@ nsHTMLInputElement::GetValue(nsString& aValue)
|
|||
{
|
||||
PRInt32 type;
|
||||
GetType(&type);
|
||||
if (NS_FORM_INPUT_TEXT == type) {
|
||||
if (NS_FORM_INPUT_TEXT == type || NS_FORM_INPUT_PASSWORD == type) {
|
||||
if (nsnull != mWidget) {
|
||||
nsITextWidget* text = nsnull;
|
||||
if (NS_OK == mWidget->QueryInterface(kITextWidgetIID,(void**)&text)) {
|
||||
|
|
|
@ -245,6 +245,7 @@ protected:
|
|||
nsVoidArray mReflowCommands;
|
||||
PRUint32 mReflowLockCount;
|
||||
PRBool mIsDestroying;
|
||||
nsIFrame* mCurrentEventFrame;
|
||||
};
|
||||
|
||||
#ifdef NS_DEBUG
|
||||
|
@ -748,6 +749,9 @@ PresShell::ClearFrameRefs(nsIFrame* aFrame)
|
|||
manager->ClearFrameRefs(aFrame);
|
||||
NS_RELEASE(manager);
|
||||
}
|
||||
if (aFrame == mCurrentEventFrame) {
|
||||
mCurrentEventFrame = nsnull;
|
||||
}
|
||||
}
|
||||
|
||||
NS_IMETHODIMP PresShell :: CreateRenderingContext(nsIFrame *aFrame,
|
||||
|
@ -1020,7 +1024,7 @@ NS_IMETHODIMP PresShell :: HandleEvent(nsIView *aView,
|
|||
{
|
||||
void* clientData;
|
||||
nsIFrame* frame;
|
||||
nsresult rv;
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
NS_ASSERTION(!(nsnull == aView), "null view");
|
||||
|
||||
|
@ -1032,34 +1036,37 @@ NS_IMETHODIMP PresShell :: HandleEvent(nsIView *aView,
|
|||
frame = (nsIFrame *)clientData;
|
||||
|
||||
if (nsnull != frame) {
|
||||
nsIFrame* targetFrame;
|
||||
frame->GetFrameForPoint(aEvent->point, &targetFrame);
|
||||
if (nsnull != frame) {
|
||||
frame->GetFrameForPoint(aEvent->point, &mCurrentEventFrame);
|
||||
if (nsnull != mCurrentEventFrame) {
|
||||
//Once we have the targetFrame, handle the event in this order
|
||||
nsIEventStateManager *manager;
|
||||
if (NS_OK == mPresContext->GetEventStateManager(&manager)) {
|
||||
//1. Give event to event manager for state changes and generation of synthetic events.
|
||||
manager->HandleEvent(*mPresContext, aEvent, targetFrame, aEventStatus);
|
||||
rv = manager->HandleEvent(*mPresContext, aEvent, mCurrentEventFrame, aEventStatus);
|
||||
|
||||
//2. Give event to the DOM for third party and JS use.
|
||||
nsIContent* targetContent;
|
||||
if (NS_OK == targetFrame->GetContent(targetContent) && nsnull != targetContent) {
|
||||
rv = targetContent->HandleDOMEvent(*mPresContext, (nsEvent*)aEvent, nsnull,
|
||||
DOM_EVENT_INIT, aEventStatus);
|
||||
NS_RELEASE(targetContent);
|
||||
if (nsnull != mCurrentEventFrame && NS_OK == rv) {
|
||||
nsIContent* targetContent;
|
||||
if (NS_OK == mCurrentEventFrame->GetContent(targetContent) && nsnull != targetContent) {
|
||||
rv = targetContent->HandleDOMEvent(*mPresContext, (nsEvent*)aEvent, nsnull,
|
||||
DOM_EVENT_INIT, aEventStatus);
|
||||
NS_RELEASE(targetContent);
|
||||
}
|
||||
}
|
||||
|
||||
//3. Give event to the Frames for browser default processing.
|
||||
// XXX The event isn't translated into the local coordinate space
|
||||
// of the frame...
|
||||
if (NS_OK == rv) {
|
||||
rv = targetFrame->HandleEvent(*mPresContext, aEvent, aEventStatus);
|
||||
if (nsnull != mCurrentEventFrame && NS_OK == rv) {
|
||||
rv = mCurrentEventFrame->HandleEvent(*mPresContext, aEvent, aEventStatus);
|
||||
}
|
||||
NS_RELEASE(manager);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
else {
|
||||
rv = NS_OK;
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
|
|
@ -348,11 +348,17 @@ nsImageControlFrame::MouseClicked(nsIPresContext* aPresContext)
|
|||
GetType(&type);
|
||||
|
||||
if ((nsnull != mFormFrame) && !nsFormFrame::GetDisabled(this)) {
|
||||
nsIContent *formContent = nsnull;
|
||||
mFormFrame->GetContent(formContent);
|
||||
|
||||
nsEventStatus status;
|
||||
nsEvent event;
|
||||
event.eventStructType = NS_EVENT;
|
||||
event.message = NS_FORM_SUBMIT;
|
||||
mContent->HandleDOMEvent(*aPresContext, &event, nsnull, DOM_EVENT_INIT, status);
|
||||
if (nsnull != formContent) {
|
||||
formContent->HandleDOMEvent(*aPresContext, &event, nsnull, DOM_EVENT_INIT, status);
|
||||
NS_RELEASE(formContent);
|
||||
}
|
||||
if (nsEventStatus_eConsumeNoDefault != status) {
|
||||
mFormFrame->OnSubmit(aPresContext, this);
|
||||
}
|
||||
|
|
|
@ -770,7 +770,9 @@ NS_IMETHODIMP ImageMapImpl::IsInside(nscoord aX, nscoord aY)
|
|||
for (i = 0; i < n; i++) {
|
||||
Area* area = (Area*) mAreas.ElementAt(i);
|
||||
if (area->IsInside(aX, aY)) {
|
||||
return NS_OK;
|
||||
if ((area->mHREF).Length() > 0) {
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
}
|
||||
return NS_NOT_INSIDE;
|
||||
|
|
|
@ -770,7 +770,9 @@ NS_IMETHODIMP ImageMapImpl::IsInside(nscoord aX, nscoord aY)
|
|||
for (i = 0; i < n; i++) {
|
||||
Area* area = (Area*) mAreas.ElementAt(i);
|
||||
if (area->IsInside(aX, aY)) {
|
||||
return NS_OK;
|
||||
if ((area->mHREF).Length() > 0) {
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
}
|
||||
return NS_NOT_INSIDE;
|
||||
|
|
|
@ -245,6 +245,7 @@ protected:
|
|||
nsVoidArray mReflowCommands;
|
||||
PRUint32 mReflowLockCount;
|
||||
PRBool mIsDestroying;
|
||||
nsIFrame* mCurrentEventFrame;
|
||||
};
|
||||
|
||||
#ifdef NS_DEBUG
|
||||
|
@ -748,6 +749,9 @@ PresShell::ClearFrameRefs(nsIFrame* aFrame)
|
|||
manager->ClearFrameRefs(aFrame);
|
||||
NS_RELEASE(manager);
|
||||
}
|
||||
if (aFrame == mCurrentEventFrame) {
|
||||
mCurrentEventFrame = nsnull;
|
||||
}
|
||||
}
|
||||
|
||||
NS_IMETHODIMP PresShell :: CreateRenderingContext(nsIFrame *aFrame,
|
||||
|
@ -1020,7 +1024,7 @@ NS_IMETHODIMP PresShell :: HandleEvent(nsIView *aView,
|
|||
{
|
||||
void* clientData;
|
||||
nsIFrame* frame;
|
||||
nsresult rv;
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
NS_ASSERTION(!(nsnull == aView), "null view");
|
||||
|
||||
|
@ -1032,34 +1036,37 @@ NS_IMETHODIMP PresShell :: HandleEvent(nsIView *aView,
|
|||
frame = (nsIFrame *)clientData;
|
||||
|
||||
if (nsnull != frame) {
|
||||
nsIFrame* targetFrame;
|
||||
frame->GetFrameForPoint(aEvent->point, &targetFrame);
|
||||
if (nsnull != frame) {
|
||||
frame->GetFrameForPoint(aEvent->point, &mCurrentEventFrame);
|
||||
if (nsnull != mCurrentEventFrame) {
|
||||
//Once we have the targetFrame, handle the event in this order
|
||||
nsIEventStateManager *manager;
|
||||
if (NS_OK == mPresContext->GetEventStateManager(&manager)) {
|
||||
//1. Give event to event manager for state changes and generation of synthetic events.
|
||||
manager->HandleEvent(*mPresContext, aEvent, targetFrame, aEventStatus);
|
||||
rv = manager->HandleEvent(*mPresContext, aEvent, mCurrentEventFrame, aEventStatus);
|
||||
|
||||
//2. Give event to the DOM for third party and JS use.
|
||||
nsIContent* targetContent;
|
||||
if (NS_OK == targetFrame->GetContent(targetContent) && nsnull != targetContent) {
|
||||
rv = targetContent->HandleDOMEvent(*mPresContext, (nsEvent*)aEvent, nsnull,
|
||||
DOM_EVENT_INIT, aEventStatus);
|
||||
NS_RELEASE(targetContent);
|
||||
if (nsnull != mCurrentEventFrame && NS_OK == rv) {
|
||||
nsIContent* targetContent;
|
||||
if (NS_OK == mCurrentEventFrame->GetContent(targetContent) && nsnull != targetContent) {
|
||||
rv = targetContent->HandleDOMEvent(*mPresContext, (nsEvent*)aEvent, nsnull,
|
||||
DOM_EVENT_INIT, aEventStatus);
|
||||
NS_RELEASE(targetContent);
|
||||
}
|
||||
}
|
||||
|
||||
//3. Give event to the Frames for browser default processing.
|
||||
// XXX The event isn't translated into the local coordinate space
|
||||
// of the frame...
|
||||
if (NS_OK == rv) {
|
||||
rv = targetFrame->HandleEvent(*mPresContext, aEvent, aEventStatus);
|
||||
if (nsnull != mCurrentEventFrame && NS_OK == rv) {
|
||||
rv = mCurrentEventFrame->HandleEvent(*mPresContext, aEvent, aEventStatus);
|
||||
}
|
||||
NS_RELEASE(manager);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
else {
|
||||
rv = NS_OK;
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
|
|
@ -305,7 +305,7 @@ nsHTMLInputElement::GetValue(nsString& aValue)
|
|||
{
|
||||
PRInt32 type;
|
||||
GetType(&type);
|
||||
if (NS_FORM_INPUT_TEXT == type) {
|
||||
if (NS_FORM_INPUT_TEXT == type || NS_FORM_INPUT_PASSWORD == type) {
|
||||
if (nsnull != mWidget) {
|
||||
nsITextWidget* text = nsnull;
|
||||
if (NS_OK == mWidget->QueryInterface(kITextWidgetIID,(void**)&text)) {
|
||||
|
|
|
@ -243,26 +243,34 @@ nsButtonControlFrame::MouseClicked(nsIPresContext* aPresContext)
|
|||
GetType(&type);
|
||||
|
||||
if ((nsnull != mFormFrame) && !nsFormFrame::GetDisabled(this)) {
|
||||
nsEventStatus status;
|
||||
nsEventStatus status = nsEventStatus_eIgnore;
|
||||
nsEvent event;
|
||||
event.eventStructType = NS_EVENT;
|
||||
nsIContent *formContent = nsnull;
|
||||
mFormFrame->GetContent(formContent);
|
||||
|
||||
switch(type) {
|
||||
case NS_FORM_INPUT_RESET:
|
||||
event.message = NS_FORM_RESET;
|
||||
mContent->HandleDOMEvent(*aPresContext, &event, nsnull, DOM_EVENT_INIT, status);
|
||||
if (nsnull != formContent) {
|
||||
formContent->HandleDOMEvent(*aPresContext, &event, nsnull, DOM_EVENT_INIT, status);
|
||||
}
|
||||
if (nsEventStatus_eConsumeNoDefault != status) {
|
||||
mFormFrame->OnReset();
|
||||
}
|
||||
break;
|
||||
case NS_FORM_INPUT_SUBMIT:
|
||||
event.message = NS_FORM_SUBMIT;
|
||||
mContent->HandleDOMEvent(*aPresContext, &event, nsnull, DOM_EVENT_INIT, status);
|
||||
if (nsnull != formContent) {
|
||||
formContent->HandleDOMEvent(*aPresContext, &event, nsnull, DOM_EVENT_INIT, status);
|
||||
}
|
||||
if (nsEventStatus_eConsumeNoDefault != status) {
|
||||
mFormFrame->OnSubmit(aPresContext, this);
|
||||
}
|
||||
}
|
||||
} else if ((NS_FORM_BROWSE == type) && mFileControlFrame) {
|
||||
NS_IF_RELEASE(formContent);
|
||||
}
|
||||
else if ((NS_FORM_BROWSE == type) && mFileControlFrame) {
|
||||
mFileControlFrame->MouseClicked(aPresContext);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -348,11 +348,17 @@ nsImageControlFrame::MouseClicked(nsIPresContext* aPresContext)
|
|||
GetType(&type);
|
||||
|
||||
if ((nsnull != mFormFrame) && !nsFormFrame::GetDisabled(this)) {
|
||||
nsIContent *formContent = nsnull;
|
||||
mFormFrame->GetContent(formContent);
|
||||
|
||||
nsEventStatus status;
|
||||
nsEvent event;
|
||||
event.eventStructType = NS_EVENT;
|
||||
event.message = NS_FORM_SUBMIT;
|
||||
mContent->HandleDOMEvent(*aPresContext, &event, nsnull, DOM_EVENT_INIT, status);
|
||||
if (nsnull != formContent) {
|
||||
formContent->HandleDOMEvent(*aPresContext, &event, nsnull, DOM_EVENT_INIT, status);
|
||||
NS_RELEASE(formContent);
|
||||
}
|
||||
if (nsEventStatus_eConsumeNoDefault != status) {
|
||||
mFormFrame->OnSubmit(aPresContext, this);
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче