зеркало из https://github.com/mozilla/gecko-dev.git
New api's into nsEventStateManager for content state change (hover,focus,active)
This commit is contained in:
Родитель
6af1a991d4
Коммит
b6f2484b5b
|
@ -56,15 +56,12 @@ public:
|
|||
NS_IMETHOD GetEventTarget(nsIFrame **aFrame) = 0;
|
||||
|
||||
NS_IMETHOD GetContentState(nsIContent *aContent, PRInt32& aState) = 0;
|
||||
|
||||
NS_IMETHOD SetActiveContent(nsIContent *aActive) = 0;
|
||||
NS_IMETHOD SetHoverContent(nsIContent *aHover) = 0;
|
||||
NS_IMETHOD SetFocusedContent(nsIContent *aContent) = 0;
|
||||
NS_IMETHOD SetContentState(nsIContent *aContent, PRInt32 aState) = 0;
|
||||
};
|
||||
|
||||
#define NS_EVENT_STATE_UNSPECIFIED 0000
|
||||
#define NS_EVENT_STATE_ACTIVE 0001 // mouse is down on content
|
||||
#define NS_EVENT_STATE_FOCUS 0002 // content has focus
|
||||
#define NS_EVENT_STATE_HOVER 0003 // mouse is hovering over content
|
||||
#define NS_EVENT_STATE_UNSPECIFIED 0x0000
|
||||
#define NS_EVENT_STATE_ACTIVE 0x0001 // mouse is down on content
|
||||
#define NS_EVENT_STATE_FOCUS 0x0002 // content has focus
|
||||
#define NS_EVENT_STATE_HOVER 0x0004 // mouse is hovering over content
|
||||
|
||||
#endif // nsIEventStateManager_h__
|
||||
|
|
|
@ -130,24 +130,30 @@ nsEventStateManager::PostHandleEvent(nsIPresContext& aPresContext,
|
|||
case NS_MOUSE_RIGHT_BUTTON_DOWN:
|
||||
{
|
||||
ret = CheckForAndDispatchClick(aPresContext, (nsMouseEvent*)aEvent, aStatus);
|
||||
|
||||
nsIContent* newFocus;
|
||||
mCurrentTarget->GetContent(&newFocus);
|
||||
if (newFocus) {
|
||||
if (!ChangeFocus(newFocus, PR_TRUE)) {
|
||||
if (nsnull != aEvent->widget) {
|
||||
aEvent->widget->SetFocus();
|
||||
|
||||
if (nsEventStatus_eConsumeNoDefault != aStatus) {
|
||||
nsIContent* newFocus;
|
||||
mCurrentTarget->GetContent(&newFocus);
|
||||
if (newFocus) {
|
||||
if (!ChangeFocus(newFocus, PR_TRUE)) {
|
||||
if (nsnull != aEvent->widget) {
|
||||
aEvent->widget->SetFocus();
|
||||
}
|
||||
}
|
||||
}
|
||||
NS_RELEASE(newFocus);
|
||||
|
||||
SetContentState(newFocus, NS_EVENT_STATE_ACTIVE);
|
||||
|
||||
NS_IF_RELEASE(newFocus);
|
||||
}
|
||||
|
||||
}
|
||||
break;
|
||||
case NS_MOUSE_LEFT_BUTTON_UP:
|
||||
case NS_MOUSE_MIDDLE_BUTTON_UP:
|
||||
case NS_MOUSE_RIGHT_BUTTON_UP:
|
||||
ret = CheckForAndDispatchClick(aPresContext, (nsMouseEvent*)aEvent, aStatus);
|
||||
SetActiveContent(nsnull);
|
||||
SetContentState(nsnull, NS_EVENT_STATE_ACTIVE);
|
||||
break;
|
||||
case NS_KEY_DOWN:
|
||||
ret = DispatchKeyPressEvent(aPresContext, (nsKeyEvent*)aEvent, aStatus);
|
||||
|
@ -274,6 +280,10 @@ nsEventStateManager::GenerateMouseEnterExit(nsIPresContext& aPresContext, nsGUIE
|
|||
}
|
||||
}
|
||||
|
||||
if (nsEventStatus_eConsumeNoDefault != status) {
|
||||
SetContentState(nsnull, NS_EVENT_STATE_HOVER);
|
||||
}
|
||||
|
||||
//Now dispatch to the frame
|
||||
if (nsnull != mLastMouseOverFrame) {
|
||||
//XXX Get the new frame
|
||||
|
@ -294,6 +304,10 @@ nsEventStateManager::GenerateMouseEnterExit(nsIPresContext& aPresContext, nsGUIE
|
|||
if (nsnull != targetContent) {
|
||||
targetContent->HandleDOMEvent(aPresContext, &event, nsnull, NS_EVENT_FLAG_INIT, status);
|
||||
}
|
||||
|
||||
if (nsEventStatus_eConsumeNoDefault != status) {
|
||||
SetContentState(targetContent, NS_EVENT_STATE_HOVER);
|
||||
}
|
||||
}
|
||||
|
||||
//Now dispatch to the frame
|
||||
|
@ -455,6 +469,8 @@ nsEventStateManager::ChangeFocus(nsIContent* aFocus, PRBool aSetFocus)
|
|||
void
|
||||
nsEventStateManager::ShiftFocus(PRBool forward)
|
||||
{
|
||||
PRBool topOfDoc = PR_FALSE;
|
||||
|
||||
if (nsnull == mPresContext) {
|
||||
return;
|
||||
}
|
||||
|
@ -475,11 +491,14 @@ nsEventStateManager::ShiftFocus(PRBool forward)
|
|||
return;
|
||||
}
|
||||
mCurrentTabIndex = forward ? 1 : 0;
|
||||
topOfDoc = PR_TRUE;
|
||||
}
|
||||
|
||||
nsIContent* next = GetNextTabbableContent(mCurrentFocus, nsnull, mCurrentFocus, forward);
|
||||
|
||||
if (nsnull == next) {
|
||||
PRBool focusTaken = PR_FALSE;
|
||||
|
||||
NS_IF_RELEASE(mCurrentFocus);
|
||||
|
||||
//Pass focus up to nsIWebShellContainer FocusAvailable
|
||||
|
@ -491,13 +510,16 @@ nsEventStateManager::ShiftFocus(PRBool forward)
|
|||
nsIWebShellContainer* webShellContainer;
|
||||
webShell->GetContainer(webShellContainer);
|
||||
if (nsnull != webShellContainer) {
|
||||
webShellContainer->FocusAvailable(webShell);
|
||||
webShellContainer->FocusAvailable(webShell, focusTaken);
|
||||
NS_RELEASE(webShellContainer);
|
||||
}
|
||||
NS_RELEASE(webShell);
|
||||
}
|
||||
NS_RELEASE(container);
|
||||
}
|
||||
if (!focusTaken && !topOfDoc) {
|
||||
ShiftFocus(forward);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -693,59 +715,70 @@ nsEventStateManager::GetContentState(nsIContent *aContent, PRInt32& aState)
|
|||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsEventStateManager::SetActiveContent(nsIContent *aActive)
|
||||
nsEventStateManager::SetContentState(nsIContent *aContent, PRInt32 aState)
|
||||
{
|
||||
nsIDocument *mDocument;
|
||||
nsIDocument *document;
|
||||
|
||||
if (nsnull != mActiveContent) {
|
||||
if (aState & NS_EVENT_STATE_ACTIVE && nsnull != mActiveContent) {
|
||||
//transferring ref to lastActive from mActiveContent
|
||||
nsIContent *lastActive = mActiveContent;
|
||||
mActiveContent = nsnull;
|
||||
|
||||
if (NS_OK == mActiveContent->GetDocument(mDocument)) {
|
||||
mActiveContent = nsnull;
|
||||
mDocument->ContentStateChanged(lastActive);
|
||||
NS_RELEASE(mDocument);
|
||||
lastActive->GetDocument(document);
|
||||
if (document) {
|
||||
document->ContentStateChanged(lastActive);
|
||||
NS_RELEASE(document);
|
||||
}
|
||||
NS_RELEASE(lastActive);
|
||||
}
|
||||
|
||||
mActiveContent = aActive;
|
||||
NS_IF_ADDREF(mActiveContent);
|
||||
|
||||
if (nsnull != mActiveContent) {
|
||||
if (NS_OK == mActiveContent->GetDocument(mDocument)) {
|
||||
mDocument->ContentStateChanged(mActiveContent);
|
||||
NS_RELEASE(mDocument);
|
||||
}
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsEventStateManager::SetHoverContent(nsIContent *aHover)
|
||||
{
|
||||
nsIDocument *mDocument;
|
||||
|
||||
if (nsnull != mHoverContent) {
|
||||
//transferring ref to lastHover from mActiveContent
|
||||
if (aState & NS_EVENT_STATE_HOVER && nsnull != mHoverContent) {
|
||||
//transferring ref to lastHover from mHoverContent
|
||||
nsIContent *lastHover = mHoverContent;
|
||||
mHoverContent = nsnull;
|
||||
|
||||
if (NS_OK == mHoverContent->GetDocument(mDocument)) {
|
||||
mHoverContent = nsnull;
|
||||
mDocument->ContentStateChanged(lastHover);
|
||||
NS_RELEASE(mDocument);
|
||||
lastHover->GetDocument(document);
|
||||
if (document) {
|
||||
document->ContentStateChanged(lastHover);
|
||||
NS_RELEASE(document);
|
||||
}
|
||||
NS_RELEASE(lastHover);
|
||||
}
|
||||
|
||||
mHoverContent = aHover;
|
||||
if (aState & NS_EVENT_STATE_FOCUS) {
|
||||
SendFocusBlur(aContent);
|
||||
|
||||
NS_IF_ADDREF(mHoverContent);
|
||||
if (nsnull != mHoverContent) {
|
||||
if (NS_OK == mHoverContent->GetDocument(mDocument)) {
|
||||
mDocument->ContentStateChanged(mHoverContent);
|
||||
NS_RELEASE(mDocument);
|
||||
if (nsnull != mCurrentFocus) {
|
||||
//transferring ref to lastFocus from mCurrentFocus
|
||||
nsIContent *lastFocus = mCurrentFocus;
|
||||
mCurrentFocus = nsnull;
|
||||
|
||||
lastFocus->GetDocument(document);
|
||||
if (document) {
|
||||
document->ContentStateChanged(lastFocus);
|
||||
NS_RELEASE(document);
|
||||
}
|
||||
NS_RELEASE(lastFocus);
|
||||
}
|
||||
}
|
||||
|
||||
if (nsnull != aContent) {
|
||||
if (aState & NS_EVENT_STATE_ACTIVE) {
|
||||
mActiveContent = aContent;
|
||||
NS_IF_ADDREF(mActiveContent);
|
||||
}
|
||||
if (aState & NS_EVENT_STATE_HOVER) {
|
||||
mHoverContent = aContent;
|
||||
NS_IF_ADDREF(mHoverContent);
|
||||
}
|
||||
if (aState & NS_EVENT_STATE_FOCUS) {
|
||||
mCurrentFocus = aContent;
|
||||
NS_IF_ADDREF(mCurrentFocus);
|
||||
}
|
||||
aContent->GetDocument(document);
|
||||
if (document) {
|
||||
document->ContentStateChanged(aContent);
|
||||
NS_RELEASE(document);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -753,12 +786,14 @@ nsEventStateManager::SetHoverContent(nsIContent *aHover)
|
|||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsEventStateManager::SetFocusedContent(nsIContent *aContent)
|
||||
nsEventStateManager::SendFocusBlur(nsIContent *aContent)
|
||||
{
|
||||
if (mCurrentFocus == aContent) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsIDocument *document;
|
||||
|
||||
if (mCurrentFocus) {
|
||||
ChangeFocus(mCurrentFocus, PR_FALSE);
|
||||
|
||||
|
@ -771,29 +806,27 @@ nsEventStateManager::SetFocusedContent(nsIContent *aContent)
|
|||
if (nsnull != mPresContext) {
|
||||
mCurrentFocus->HandleDOMEvent(*mPresContext, &event, nsnull, NS_EVENT_FLAG_INIT, status);
|
||||
}
|
||||
NS_RELEASE(mCurrentFocus);
|
||||
}
|
||||
|
||||
//fire focus
|
||||
nsEventStatus status = nsEventStatus_eIgnore;
|
||||
nsEvent event;
|
||||
event.eventStructType = NS_EVENT;
|
||||
event.message = NS_FOCUS_CONTENT;
|
||||
if (nsnull != aContent) {
|
||||
//fire focus
|
||||
nsEventStatus status = nsEventStatus_eIgnore;
|
||||
nsEvent event;
|
||||
event.eventStructType = NS_EVENT;
|
||||
event.message = NS_FOCUS_CONTENT;
|
||||
|
||||
if (nsnull != mPresContext) {
|
||||
aContent->HandleDOMEvent(*mPresContext, &event, nsnull, NS_EVENT_FLAG_INIT, status);
|
||||
if (nsnull != mPresContext) {
|
||||
aContent->HandleDOMEvent(*mPresContext, &event, nsnull, NS_EVENT_FLAG_INIT, status);
|
||||
}
|
||||
|
||||
nsAutoString tabIndex;
|
||||
aContent->GetAttribute(kNameSpaceID_HTML, nsHTMLAtoms::tabindex, tabIndex);
|
||||
PRInt32 ec, val = tabIndex.ToInteger(&ec);
|
||||
if (NS_OK == ec) {
|
||||
mCurrentTabIndex = val;
|
||||
}
|
||||
}
|
||||
|
||||
nsAutoString tabIndex;
|
||||
aContent->GetAttribute(kNameSpaceID_HTML, nsHTMLAtoms::tabindex, tabIndex);
|
||||
PRInt32 ec, val = tabIndex.ToInteger(&ec);
|
||||
if (NS_OK == ec) {
|
||||
mCurrentTabIndex = val;
|
||||
}
|
||||
|
||||
mCurrentFocus = aContent;
|
||||
NS_IF_ADDREF(mCurrentFocus);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
|
|
@ -51,9 +51,7 @@ public:
|
|||
NS_IMETHOD GetEventTarget(nsIFrame **aFrame);
|
||||
|
||||
NS_IMETHOD GetContentState(nsIContent *aContent, PRInt32& aState);
|
||||
NS_IMETHOD SetActiveContent(nsIContent *aActive);
|
||||
NS_IMETHOD SetHoverContent(nsIContent *aHover);
|
||||
NS_IMETHOD SetFocusedContent(nsIContent *aContent);
|
||||
NS_IMETHOD SetContentState(nsIContent *aContent, PRInt32 aState);
|
||||
|
||||
protected:
|
||||
void UpdateCursor(nsIPresContext& aPresContext, nsPoint& aPoint, nsIFrame* aTargetFrame, nsEventStatus& aStatus);
|
||||
|
@ -64,6 +62,7 @@ protected:
|
|||
void ShiftFocus(PRBool foward);
|
||||
nsIContent* GetNextTabbableContent(nsIContent* aParent, nsIContent* aChild, nsIContent* aTop, PRBool foward);
|
||||
PRInt32 GetNextTabIndex(nsIContent* aParent, PRBool foward);
|
||||
NS_IMETHOD SendFocusBlur(nsIContent *aContent);
|
||||
|
||||
//Any frames here must be checked for validity in ClearFrameRefs
|
||||
nsIFrame* mCurrentTarget;
|
||||
|
|
|
@ -200,7 +200,7 @@ nsHTMLAnchorElement::SetFocus(nsIPresContext* aPresContext)
|
|||
{
|
||||
nsIEventStateManager* esm;
|
||||
if (NS_OK == aPresContext->GetEventStateManager(&esm)) {
|
||||
esm->SetFocusedContent(this);
|
||||
esm->SetContentState(this, NS_EVENT_STATE_FOCUS);
|
||||
NS_RELEASE(esm);
|
||||
}
|
||||
|
||||
|
@ -286,7 +286,7 @@ nsHTMLAnchorElement::HandleDOMEvent(nsIPresContext& aPresContext,
|
|||
{
|
||||
nsIEventStateManager *stateManager;
|
||||
if (NS_OK == aPresContext.GetEventStateManager(&stateManager)) {
|
||||
stateManager->SetActiveContent(this);
|
||||
stateManager->SetContentState(this, NS_EVENT_STATE_ACTIVE | NS_EVENT_STATE_FOCUS);
|
||||
NS_RELEASE(stateManager);
|
||||
}
|
||||
aEventStatus = nsEventStatus_eConsumeNoDefault;
|
||||
|
@ -306,7 +306,7 @@ nsHTMLAnchorElement::HandleDOMEvent(nsIPresContext& aPresContext,
|
|||
mInner.TriggerLink(aPresContext, eLinkVerb_Replace,
|
||||
baseURL, href, target, PR_TRUE);
|
||||
NS_IF_RELEASE(baseURL);
|
||||
aEventStatus = nsEventStatus_eConsumeNoDefault;
|
||||
aEventStatus = nsEventStatus_eConsumeDoDefault;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
@ -317,6 +317,12 @@ nsHTMLAnchorElement::HandleDOMEvent(nsIPresContext& aPresContext,
|
|||
|
||||
case NS_MOUSE_ENTER:
|
||||
{
|
||||
nsIEventStateManager *stateManager;
|
||||
if (NS_OK == aPresContext.GetEventStateManager(&stateManager)) {
|
||||
stateManager->SetContentState(this, NS_EVENT_STATE_HOVER);
|
||||
NS_RELEASE(stateManager);
|
||||
}
|
||||
|
||||
nsAutoString target;
|
||||
nsIURL* baseURL = nsnull;
|
||||
GetBaseURL(baseURL);
|
||||
|
@ -327,15 +333,21 @@ nsHTMLAnchorElement::HandleDOMEvent(nsIPresContext& aPresContext,
|
|||
mInner.TriggerLink(aPresContext, eLinkVerb_Replace,
|
||||
baseURL, href, target, PR_FALSE);
|
||||
NS_IF_RELEASE(baseURL);
|
||||
aEventStatus = nsEventStatus_eConsumeDoDefault;
|
||||
aEventStatus = nsEventStatus_eConsumeNoDefault;
|
||||
}
|
||||
break;
|
||||
|
||||
case NS_MOUSE_EXIT:
|
||||
{
|
||||
nsIEventStateManager *stateManager;
|
||||
if (NS_OK == aPresContext.GetEventStateManager(&stateManager)) {
|
||||
stateManager->SetContentState(nsnull, NS_EVENT_STATE_HOVER);
|
||||
NS_RELEASE(stateManager);
|
||||
}
|
||||
|
||||
nsAutoString empty;
|
||||
mInner.TriggerLink(aPresContext, eLinkVerb_Replace, nsnull, empty, empty, PR_FALSE);
|
||||
aEventStatus = nsEventStatus_eConsumeDoDefault;
|
||||
aEventStatus = nsEventStatus_eConsumeNoDefault;
|
||||
}
|
||||
break;
|
||||
|
||||
|
|
|
@ -231,7 +231,7 @@ nsHTMLAreaElement::SetFocus(nsIPresContext* aPresContext)
|
|||
{
|
||||
nsIEventStateManager* esm;
|
||||
if (NS_OK == aPresContext->GetEventStateManager(&esm)) {
|
||||
esm->SetFocusedContent(this);
|
||||
esm->SetContentState(this, NS_EVENT_STATE_FOCUS);
|
||||
NS_RELEASE(esm);
|
||||
}
|
||||
|
||||
|
|
|
@ -276,7 +276,7 @@ nsHTMLButtonElement::SetFocus(nsIPresContext* aPresContext)
|
|||
{
|
||||
nsIEventStateManager* esm;
|
||||
if (NS_OK == aPresContext->GetEventStateManager(&esm)) {
|
||||
esm->SetFocusedContent(this);
|
||||
esm->SetContentState(this, NS_EVENT_STATE_FOCUS);
|
||||
NS_RELEASE(esm);
|
||||
}
|
||||
|
||||
|
@ -372,7 +372,7 @@ nsHTMLButtonElement::HandleDOMEvent(nsIPresContext& aPresContext,
|
|||
{
|
||||
nsIEventStateManager *stateManager;
|
||||
if (NS_OK == aPresContext.GetEventStateManager(&stateManager)) {
|
||||
//stateManager->SetActiveLink(this);
|
||||
stateManager->SetContentState(this, NS_EVENT_STATE_ACTIVE | NS_EVENT_STATE_FOCUS);
|
||||
NS_RELEASE(stateManager);
|
||||
}
|
||||
aEventStatus = nsEventStatus_eConsumeNoDefault;
|
||||
|
@ -413,28 +413,25 @@ nsHTMLButtonElement::HandleDOMEvent(nsIPresContext& aPresContext,
|
|||
break;
|
||||
|
||||
case NS_MOUSE_ENTER:
|
||||
//mouse enter doesn't work yet. Use move until then.
|
||||
{
|
||||
nsAutoString href, target;
|
||||
nsIURL* baseURL = nsnull;
|
||||
GetBaseURL(baseURL);
|
||||
GetAttribute(kNameSpaceID_HTML, nsHTMLAtoms::href, href);
|
||||
GetAttribute(kNameSpaceID_HTML, nsHTMLAtoms::target, target);
|
||||
if (target.Length() == 0) {
|
||||
GetBaseTarget(target);
|
||||
nsIEventStateManager *stateManager;
|
||||
if (NS_OK == aPresContext.GetEventStateManager(&stateManager)) {
|
||||
stateManager->SetContentState(this, NS_EVENT_STATE_HOVER);
|
||||
NS_RELEASE(stateManager);
|
||||
}
|
||||
mInner.TriggerLink(aPresContext, eLinkVerb_Replace, baseURL, href, target, PR_FALSE);
|
||||
NS_IF_RELEASE(baseURL);
|
||||
aEventStatus = nsEventStatus_eConsumeDoDefault;
|
||||
aEventStatus = nsEventStatus_eConsumeNoDefault;
|
||||
}
|
||||
break;
|
||||
|
||||
// XXX this doesn't seem to do anything yet
|
||||
case NS_MOUSE_EXIT:
|
||||
{
|
||||
nsAutoString empty;
|
||||
mInner.TriggerLink(aPresContext, eLinkVerb_Replace, nsnull, empty, empty, PR_FALSE);
|
||||
aEventStatus = nsEventStatus_eConsumeDoDefault;
|
||||
nsIEventStateManager *stateManager;
|
||||
if (NS_OK == aPresContext.GetEventStateManager(&stateManager)) {
|
||||
stateManager->SetContentState(nsnull, NS_EVENT_STATE_HOVER);
|
||||
NS_RELEASE(stateManager);
|
||||
}
|
||||
aEventStatus = nsEventStatus_eConsumeNoDefault;
|
||||
}
|
||||
break;
|
||||
|
||||
|
|
|
@ -425,7 +425,7 @@ nsHTMLInputElement::SetFocus(nsIPresContext* aPresContext)
|
|||
{
|
||||
nsIEventStateManager* esm;
|
||||
if (NS_OK == aPresContext->GetEventStateManager(&esm)) {
|
||||
esm->SetFocusedContent(this);
|
||||
esm->SetContentState(this, NS_EVENT_STATE_FOCUS);
|
||||
NS_RELEASE(esm);
|
||||
}
|
||||
|
||||
|
|
|
@ -415,7 +415,7 @@ nsHTMLSelectElement::SetFocus(nsIPresContext* aPresContext)
|
|||
{
|
||||
nsIEventStateManager* esm;
|
||||
if (NS_OK == aPresContext->GetEventStateManager(&esm)) {
|
||||
esm->SetFocusedContent(this);
|
||||
esm->SetContentState(this, NS_EVENT_STATE_FOCUS);
|
||||
NS_RELEASE(esm);
|
||||
}
|
||||
|
||||
|
|
|
@ -252,7 +252,7 @@ nsHTMLTextAreaElement::SetFocus(nsIPresContext* aPresContext)
|
|||
{
|
||||
nsIEventStateManager* esm;
|
||||
if (NS_OK == aPresContext->GetEventStateManager(&esm)) {
|
||||
esm->SetFocusedContent(this);
|
||||
esm->SetContentState(this, NS_EVENT_STATE_FOCUS);
|
||||
NS_RELEASE(esm);
|
||||
}
|
||||
|
||||
|
|
|
@ -136,10 +136,10 @@ nsXMLElement::HandleDOMEvent(nsIPresContext& aPresContext,
|
|||
{
|
||||
nsIEventStateManager *stateManager;
|
||||
if (NS_OK == aPresContext.GetEventStateManager(&stateManager)) {
|
||||
stateManager->SetActiveContent(this);
|
||||
stateManager->SetContentState(this, NS_EVENT_STATE_ACTIVE | NS_EVENT_STATE_FOCUS);
|
||||
NS_RELEASE(stateManager);
|
||||
}
|
||||
aEventStatus = nsEventStatus_eConsumeNoDefault;
|
||||
aEventStatus = nsEventStatus_eConsumeDoDefault;
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -165,7 +165,7 @@ nsXMLElement::HandleDOMEvent(nsIPresContext& aPresContext,
|
|||
}
|
||||
mInner.TriggerLink(aPresContext, verb, baseURL, href, target, PR_TRUE);
|
||||
NS_IF_RELEASE(baseURL);
|
||||
aEventStatus = nsEventStatus_eConsumeNoDefault;
|
||||
aEventStatus = nsEventStatus_eConsumeDoDefault;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
|
|
@ -56,15 +56,12 @@ public:
|
|||
NS_IMETHOD GetEventTarget(nsIFrame **aFrame) = 0;
|
||||
|
||||
NS_IMETHOD GetContentState(nsIContent *aContent, PRInt32& aState) = 0;
|
||||
|
||||
NS_IMETHOD SetActiveContent(nsIContent *aActive) = 0;
|
||||
NS_IMETHOD SetHoverContent(nsIContent *aHover) = 0;
|
||||
NS_IMETHOD SetFocusedContent(nsIContent *aContent) = 0;
|
||||
NS_IMETHOD SetContentState(nsIContent *aContent, PRInt32 aState) = 0;
|
||||
};
|
||||
|
||||
#define NS_EVENT_STATE_UNSPECIFIED 0000
|
||||
#define NS_EVENT_STATE_ACTIVE 0001 // mouse is down on content
|
||||
#define NS_EVENT_STATE_FOCUS 0002 // content has focus
|
||||
#define NS_EVENT_STATE_HOVER 0003 // mouse is hovering over content
|
||||
#define NS_EVENT_STATE_UNSPECIFIED 0x0000
|
||||
#define NS_EVENT_STATE_ACTIVE 0x0001 // mouse is down on content
|
||||
#define NS_EVENT_STATE_FOCUS 0x0002 // content has focus
|
||||
#define NS_EVENT_STATE_HOVER 0x0004 // mouse is hovering over content
|
||||
|
||||
#endif // nsIEventStateManager_h__
|
||||
|
|
|
@ -130,24 +130,30 @@ nsEventStateManager::PostHandleEvent(nsIPresContext& aPresContext,
|
|||
case NS_MOUSE_RIGHT_BUTTON_DOWN:
|
||||
{
|
||||
ret = CheckForAndDispatchClick(aPresContext, (nsMouseEvent*)aEvent, aStatus);
|
||||
|
||||
nsIContent* newFocus;
|
||||
mCurrentTarget->GetContent(&newFocus);
|
||||
if (newFocus) {
|
||||
if (!ChangeFocus(newFocus, PR_TRUE)) {
|
||||
if (nsnull != aEvent->widget) {
|
||||
aEvent->widget->SetFocus();
|
||||
|
||||
if (nsEventStatus_eConsumeNoDefault != aStatus) {
|
||||
nsIContent* newFocus;
|
||||
mCurrentTarget->GetContent(&newFocus);
|
||||
if (newFocus) {
|
||||
if (!ChangeFocus(newFocus, PR_TRUE)) {
|
||||
if (nsnull != aEvent->widget) {
|
||||
aEvent->widget->SetFocus();
|
||||
}
|
||||
}
|
||||
}
|
||||
NS_RELEASE(newFocus);
|
||||
|
||||
SetContentState(newFocus, NS_EVENT_STATE_ACTIVE);
|
||||
|
||||
NS_IF_RELEASE(newFocus);
|
||||
}
|
||||
|
||||
}
|
||||
break;
|
||||
case NS_MOUSE_LEFT_BUTTON_UP:
|
||||
case NS_MOUSE_MIDDLE_BUTTON_UP:
|
||||
case NS_MOUSE_RIGHT_BUTTON_UP:
|
||||
ret = CheckForAndDispatchClick(aPresContext, (nsMouseEvent*)aEvent, aStatus);
|
||||
SetActiveContent(nsnull);
|
||||
SetContentState(nsnull, NS_EVENT_STATE_ACTIVE);
|
||||
break;
|
||||
case NS_KEY_DOWN:
|
||||
ret = DispatchKeyPressEvent(aPresContext, (nsKeyEvent*)aEvent, aStatus);
|
||||
|
@ -274,6 +280,10 @@ nsEventStateManager::GenerateMouseEnterExit(nsIPresContext& aPresContext, nsGUIE
|
|||
}
|
||||
}
|
||||
|
||||
if (nsEventStatus_eConsumeNoDefault != status) {
|
||||
SetContentState(nsnull, NS_EVENT_STATE_HOVER);
|
||||
}
|
||||
|
||||
//Now dispatch to the frame
|
||||
if (nsnull != mLastMouseOverFrame) {
|
||||
//XXX Get the new frame
|
||||
|
@ -294,6 +304,10 @@ nsEventStateManager::GenerateMouseEnterExit(nsIPresContext& aPresContext, nsGUIE
|
|||
if (nsnull != targetContent) {
|
||||
targetContent->HandleDOMEvent(aPresContext, &event, nsnull, NS_EVENT_FLAG_INIT, status);
|
||||
}
|
||||
|
||||
if (nsEventStatus_eConsumeNoDefault != status) {
|
||||
SetContentState(targetContent, NS_EVENT_STATE_HOVER);
|
||||
}
|
||||
}
|
||||
|
||||
//Now dispatch to the frame
|
||||
|
@ -455,6 +469,8 @@ nsEventStateManager::ChangeFocus(nsIContent* aFocus, PRBool aSetFocus)
|
|||
void
|
||||
nsEventStateManager::ShiftFocus(PRBool forward)
|
||||
{
|
||||
PRBool topOfDoc = PR_FALSE;
|
||||
|
||||
if (nsnull == mPresContext) {
|
||||
return;
|
||||
}
|
||||
|
@ -475,11 +491,14 @@ nsEventStateManager::ShiftFocus(PRBool forward)
|
|||
return;
|
||||
}
|
||||
mCurrentTabIndex = forward ? 1 : 0;
|
||||
topOfDoc = PR_TRUE;
|
||||
}
|
||||
|
||||
nsIContent* next = GetNextTabbableContent(mCurrentFocus, nsnull, mCurrentFocus, forward);
|
||||
|
||||
if (nsnull == next) {
|
||||
PRBool focusTaken = PR_FALSE;
|
||||
|
||||
NS_IF_RELEASE(mCurrentFocus);
|
||||
|
||||
//Pass focus up to nsIWebShellContainer FocusAvailable
|
||||
|
@ -491,13 +510,16 @@ nsEventStateManager::ShiftFocus(PRBool forward)
|
|||
nsIWebShellContainer* webShellContainer;
|
||||
webShell->GetContainer(webShellContainer);
|
||||
if (nsnull != webShellContainer) {
|
||||
webShellContainer->FocusAvailable(webShell);
|
||||
webShellContainer->FocusAvailable(webShell, focusTaken);
|
||||
NS_RELEASE(webShellContainer);
|
||||
}
|
||||
NS_RELEASE(webShell);
|
||||
}
|
||||
NS_RELEASE(container);
|
||||
}
|
||||
if (!focusTaken && !topOfDoc) {
|
||||
ShiftFocus(forward);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -693,59 +715,70 @@ nsEventStateManager::GetContentState(nsIContent *aContent, PRInt32& aState)
|
|||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsEventStateManager::SetActiveContent(nsIContent *aActive)
|
||||
nsEventStateManager::SetContentState(nsIContent *aContent, PRInt32 aState)
|
||||
{
|
||||
nsIDocument *mDocument;
|
||||
nsIDocument *document;
|
||||
|
||||
if (nsnull != mActiveContent) {
|
||||
if (aState & NS_EVENT_STATE_ACTIVE && nsnull != mActiveContent) {
|
||||
//transferring ref to lastActive from mActiveContent
|
||||
nsIContent *lastActive = mActiveContent;
|
||||
mActiveContent = nsnull;
|
||||
|
||||
if (NS_OK == mActiveContent->GetDocument(mDocument)) {
|
||||
mActiveContent = nsnull;
|
||||
mDocument->ContentStateChanged(lastActive);
|
||||
NS_RELEASE(mDocument);
|
||||
lastActive->GetDocument(document);
|
||||
if (document) {
|
||||
document->ContentStateChanged(lastActive);
|
||||
NS_RELEASE(document);
|
||||
}
|
||||
NS_RELEASE(lastActive);
|
||||
}
|
||||
|
||||
mActiveContent = aActive;
|
||||
NS_IF_ADDREF(mActiveContent);
|
||||
|
||||
if (nsnull != mActiveContent) {
|
||||
if (NS_OK == mActiveContent->GetDocument(mDocument)) {
|
||||
mDocument->ContentStateChanged(mActiveContent);
|
||||
NS_RELEASE(mDocument);
|
||||
}
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsEventStateManager::SetHoverContent(nsIContent *aHover)
|
||||
{
|
||||
nsIDocument *mDocument;
|
||||
|
||||
if (nsnull != mHoverContent) {
|
||||
//transferring ref to lastHover from mActiveContent
|
||||
if (aState & NS_EVENT_STATE_HOVER && nsnull != mHoverContent) {
|
||||
//transferring ref to lastHover from mHoverContent
|
||||
nsIContent *lastHover = mHoverContent;
|
||||
mHoverContent = nsnull;
|
||||
|
||||
if (NS_OK == mHoverContent->GetDocument(mDocument)) {
|
||||
mHoverContent = nsnull;
|
||||
mDocument->ContentStateChanged(lastHover);
|
||||
NS_RELEASE(mDocument);
|
||||
lastHover->GetDocument(document);
|
||||
if (document) {
|
||||
document->ContentStateChanged(lastHover);
|
||||
NS_RELEASE(document);
|
||||
}
|
||||
NS_RELEASE(lastHover);
|
||||
}
|
||||
|
||||
mHoverContent = aHover;
|
||||
if (aState & NS_EVENT_STATE_FOCUS) {
|
||||
SendFocusBlur(aContent);
|
||||
|
||||
NS_IF_ADDREF(mHoverContent);
|
||||
if (nsnull != mHoverContent) {
|
||||
if (NS_OK == mHoverContent->GetDocument(mDocument)) {
|
||||
mDocument->ContentStateChanged(mHoverContent);
|
||||
NS_RELEASE(mDocument);
|
||||
if (nsnull != mCurrentFocus) {
|
||||
//transferring ref to lastFocus from mCurrentFocus
|
||||
nsIContent *lastFocus = mCurrentFocus;
|
||||
mCurrentFocus = nsnull;
|
||||
|
||||
lastFocus->GetDocument(document);
|
||||
if (document) {
|
||||
document->ContentStateChanged(lastFocus);
|
||||
NS_RELEASE(document);
|
||||
}
|
||||
NS_RELEASE(lastFocus);
|
||||
}
|
||||
}
|
||||
|
||||
if (nsnull != aContent) {
|
||||
if (aState & NS_EVENT_STATE_ACTIVE) {
|
||||
mActiveContent = aContent;
|
||||
NS_IF_ADDREF(mActiveContent);
|
||||
}
|
||||
if (aState & NS_EVENT_STATE_HOVER) {
|
||||
mHoverContent = aContent;
|
||||
NS_IF_ADDREF(mHoverContent);
|
||||
}
|
||||
if (aState & NS_EVENT_STATE_FOCUS) {
|
||||
mCurrentFocus = aContent;
|
||||
NS_IF_ADDREF(mCurrentFocus);
|
||||
}
|
||||
aContent->GetDocument(document);
|
||||
if (document) {
|
||||
document->ContentStateChanged(aContent);
|
||||
NS_RELEASE(document);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -753,12 +786,14 @@ nsEventStateManager::SetHoverContent(nsIContent *aHover)
|
|||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsEventStateManager::SetFocusedContent(nsIContent *aContent)
|
||||
nsEventStateManager::SendFocusBlur(nsIContent *aContent)
|
||||
{
|
||||
if (mCurrentFocus == aContent) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsIDocument *document;
|
||||
|
||||
if (mCurrentFocus) {
|
||||
ChangeFocus(mCurrentFocus, PR_FALSE);
|
||||
|
||||
|
@ -771,29 +806,27 @@ nsEventStateManager::SetFocusedContent(nsIContent *aContent)
|
|||
if (nsnull != mPresContext) {
|
||||
mCurrentFocus->HandleDOMEvent(*mPresContext, &event, nsnull, NS_EVENT_FLAG_INIT, status);
|
||||
}
|
||||
NS_RELEASE(mCurrentFocus);
|
||||
}
|
||||
|
||||
//fire focus
|
||||
nsEventStatus status = nsEventStatus_eIgnore;
|
||||
nsEvent event;
|
||||
event.eventStructType = NS_EVENT;
|
||||
event.message = NS_FOCUS_CONTENT;
|
||||
if (nsnull != aContent) {
|
||||
//fire focus
|
||||
nsEventStatus status = nsEventStatus_eIgnore;
|
||||
nsEvent event;
|
||||
event.eventStructType = NS_EVENT;
|
||||
event.message = NS_FOCUS_CONTENT;
|
||||
|
||||
if (nsnull != mPresContext) {
|
||||
aContent->HandleDOMEvent(*mPresContext, &event, nsnull, NS_EVENT_FLAG_INIT, status);
|
||||
if (nsnull != mPresContext) {
|
||||
aContent->HandleDOMEvent(*mPresContext, &event, nsnull, NS_EVENT_FLAG_INIT, status);
|
||||
}
|
||||
|
||||
nsAutoString tabIndex;
|
||||
aContent->GetAttribute(kNameSpaceID_HTML, nsHTMLAtoms::tabindex, tabIndex);
|
||||
PRInt32 ec, val = tabIndex.ToInteger(&ec);
|
||||
if (NS_OK == ec) {
|
||||
mCurrentTabIndex = val;
|
||||
}
|
||||
}
|
||||
|
||||
nsAutoString tabIndex;
|
||||
aContent->GetAttribute(kNameSpaceID_HTML, nsHTMLAtoms::tabindex, tabIndex);
|
||||
PRInt32 ec, val = tabIndex.ToInteger(&ec);
|
||||
if (NS_OK == ec) {
|
||||
mCurrentTabIndex = val;
|
||||
}
|
||||
|
||||
mCurrentFocus = aContent;
|
||||
NS_IF_ADDREF(mCurrentFocus);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
|
|
@ -51,9 +51,7 @@ public:
|
|||
NS_IMETHOD GetEventTarget(nsIFrame **aFrame);
|
||||
|
||||
NS_IMETHOD GetContentState(nsIContent *aContent, PRInt32& aState);
|
||||
NS_IMETHOD SetActiveContent(nsIContent *aActive);
|
||||
NS_IMETHOD SetHoverContent(nsIContent *aHover);
|
||||
NS_IMETHOD SetFocusedContent(nsIContent *aContent);
|
||||
NS_IMETHOD SetContentState(nsIContent *aContent, PRInt32 aState);
|
||||
|
||||
protected:
|
||||
void UpdateCursor(nsIPresContext& aPresContext, nsPoint& aPoint, nsIFrame* aTargetFrame, nsEventStatus& aStatus);
|
||||
|
@ -64,6 +62,7 @@ protected:
|
|||
void ShiftFocus(PRBool foward);
|
||||
nsIContent* GetNextTabbableContent(nsIContent* aParent, nsIContent* aChild, nsIContent* aTop, PRBool foward);
|
||||
PRInt32 GetNextTabIndex(nsIContent* aParent, PRBool foward);
|
||||
NS_IMETHOD SendFocusBlur(nsIContent *aContent);
|
||||
|
||||
//Any frames here must be checked for validity in ClearFrameRefs
|
||||
nsIFrame* mCurrentTarget;
|
||||
|
|
|
@ -731,10 +731,12 @@ nsFrame::HandleEvent(nsIPresContext& aPresContext,
|
|||
|
||||
if(nsEventStatus_eConsumeNoDefault != aEventStatus) {
|
||||
if (aEvent->message == NS_MOUSE_LEFT_BUTTON_DOWN) {
|
||||
} else if (aEvent->message == NS_MOUSE_MOVE && mDoingSelection ||
|
||||
}
|
||||
else if (aEvent->message == NS_MOUSE_MOVE && mDoingSelection ||
|
||||
aEvent->message == NS_MOUSE_LEFT_BUTTON_UP) {
|
||||
// no-op
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
return NS_OK;
|
||||
}
|
||||
if (SELECTION_DEBUG) printf("Message: %d-------------------------------------------------------------\n",aEvent->message);
|
||||
|
@ -765,7 +767,6 @@ nsFrame::HandlePress(nsIPresContext& aPresContext,
|
|||
nsEventStatus& aEventStatus)
|
||||
{
|
||||
if (!DisplaySelection(aPresContext, PR_TRUE)) {
|
||||
aEventStatus = nsEventStatus_eIgnore;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -810,7 +811,6 @@ NS_IMETHODIMP nsFrame::HandleDrag(nsIPresContext& aPresContext,
|
|||
nsEventStatus& aEventStatus)
|
||||
{
|
||||
if (!DisplaySelection(aPresContext, PR_TRUE)) {
|
||||
aEventStatus = nsEventStatus_eIgnore;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -852,7 +852,6 @@ NS_IMETHODIMP nsFrame::HandleRelease(nsIPresContext& aPresContext,
|
|||
nsEventStatus& aEventStatus)
|
||||
{
|
||||
mDoingSelection = PR_FALSE;
|
||||
aEventStatus = nsEventStatus_eIgnore;
|
||||
NS_IF_RELEASE(gDoc);
|
||||
return NS_OK;
|
||||
}
|
||||
|
|
|
@ -895,7 +895,6 @@ nsImageFrame::HandleEvent(nsIPresContext& aPresContext,
|
|||
nsEventStatus& aEventStatus)
|
||||
{
|
||||
nsImageMap* map;
|
||||
aEventStatus = nsEventStatus_eIgnore;
|
||||
|
||||
switch (aEvent->message) {
|
||||
case NS_MOUSE_LEFT_BUTTON_UP:
|
||||
|
@ -947,7 +946,7 @@ nsImageFrame::HandleEvent(nsIPresContext& aPresContext,
|
|||
// We hit a clickable area. Time to go somewhere...
|
||||
PRBool clicked = PR_FALSE;
|
||||
if (aEvent->message == NS_MOUSE_LEFT_BUTTON_UP) {
|
||||
aEventStatus = nsEventStatus_eConsumeNoDefault;
|
||||
aEventStatus = nsEventStatus_eConsumeDoDefault;
|
||||
clicked = PR_TRUE;
|
||||
}
|
||||
TriggerLink(aPresContext, absURL, target, clicked);
|
||||
|
@ -983,20 +982,18 @@ nsImageFrame::HandleEvent(nsIPresContext& aPresContext,
|
|||
absURL.Append(cbuf);
|
||||
PRBool clicked = PR_FALSE;
|
||||
if (aEvent->message == NS_MOUSE_LEFT_BUTTON_UP) {
|
||||
aEventStatus = nsEventStatus_eConsumeNoDefault;
|
||||
aEventStatus = nsEventStatus_eConsumeDoDefault;
|
||||
clicked = PR_TRUE;
|
||||
}
|
||||
TriggerLink(aPresContext, absURL, target, clicked);
|
||||
}
|
||||
break;
|
||||
}
|
||||
// FALL THROUGH
|
||||
|
||||
default:
|
||||
// Let default event handler deal with it
|
||||
return nsLeafFrame::HandleEvent(aPresContext, aEvent, aEventStatus);
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return NS_OK;
|
||||
|
||||
return nsLeafFrame::HandleEvent(aPresContext, aEvent, aEventStatus);
|
||||
}
|
||||
|
||||
NS_METHOD
|
||||
|
|
|
@ -731,10 +731,12 @@ nsFrame::HandleEvent(nsIPresContext& aPresContext,
|
|||
|
||||
if(nsEventStatus_eConsumeNoDefault != aEventStatus) {
|
||||
if (aEvent->message == NS_MOUSE_LEFT_BUTTON_DOWN) {
|
||||
} else if (aEvent->message == NS_MOUSE_MOVE && mDoingSelection ||
|
||||
}
|
||||
else if (aEvent->message == NS_MOUSE_MOVE && mDoingSelection ||
|
||||
aEvent->message == NS_MOUSE_LEFT_BUTTON_UP) {
|
||||
// no-op
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
return NS_OK;
|
||||
}
|
||||
if (SELECTION_DEBUG) printf("Message: %d-------------------------------------------------------------\n",aEvent->message);
|
||||
|
@ -765,7 +767,6 @@ nsFrame::HandlePress(nsIPresContext& aPresContext,
|
|||
nsEventStatus& aEventStatus)
|
||||
{
|
||||
if (!DisplaySelection(aPresContext, PR_TRUE)) {
|
||||
aEventStatus = nsEventStatus_eIgnore;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -810,7 +811,6 @@ NS_IMETHODIMP nsFrame::HandleDrag(nsIPresContext& aPresContext,
|
|||
nsEventStatus& aEventStatus)
|
||||
{
|
||||
if (!DisplaySelection(aPresContext, PR_TRUE)) {
|
||||
aEventStatus = nsEventStatus_eIgnore;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -852,7 +852,6 @@ NS_IMETHODIMP nsFrame::HandleRelease(nsIPresContext& aPresContext,
|
|||
nsEventStatus& aEventStatus)
|
||||
{
|
||||
mDoingSelection = PR_FALSE;
|
||||
aEventStatus = nsEventStatus_eIgnore;
|
||||
NS_IF_RELEASE(gDoc);
|
||||
return NS_OK;
|
||||
}
|
||||
|
|
|
@ -895,7 +895,6 @@ nsImageFrame::HandleEvent(nsIPresContext& aPresContext,
|
|||
nsEventStatus& aEventStatus)
|
||||
{
|
||||
nsImageMap* map;
|
||||
aEventStatus = nsEventStatus_eIgnore;
|
||||
|
||||
switch (aEvent->message) {
|
||||
case NS_MOUSE_LEFT_BUTTON_UP:
|
||||
|
@ -947,7 +946,7 @@ nsImageFrame::HandleEvent(nsIPresContext& aPresContext,
|
|||
// We hit a clickable area. Time to go somewhere...
|
||||
PRBool clicked = PR_FALSE;
|
||||
if (aEvent->message == NS_MOUSE_LEFT_BUTTON_UP) {
|
||||
aEventStatus = nsEventStatus_eConsumeNoDefault;
|
||||
aEventStatus = nsEventStatus_eConsumeDoDefault;
|
||||
clicked = PR_TRUE;
|
||||
}
|
||||
TriggerLink(aPresContext, absURL, target, clicked);
|
||||
|
@ -983,20 +982,18 @@ nsImageFrame::HandleEvent(nsIPresContext& aPresContext,
|
|||
absURL.Append(cbuf);
|
||||
PRBool clicked = PR_FALSE;
|
||||
if (aEvent->message == NS_MOUSE_LEFT_BUTTON_UP) {
|
||||
aEventStatus = nsEventStatus_eConsumeNoDefault;
|
||||
aEventStatus = nsEventStatus_eConsumeDoDefault;
|
||||
clicked = PR_TRUE;
|
||||
}
|
||||
TriggerLink(aPresContext, absURL, target, clicked);
|
||||
}
|
||||
break;
|
||||
}
|
||||
// FALL THROUGH
|
||||
|
||||
default:
|
||||
// Let default event handler deal with it
|
||||
return nsLeafFrame::HandleEvent(aPresContext, aEvent, aEventStatus);
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return NS_OK;
|
||||
|
||||
return nsLeafFrame::HandleEvent(aPresContext, aEvent, aEventStatus);
|
||||
}
|
||||
|
||||
NS_METHOD
|
||||
|
|
|
@ -200,7 +200,7 @@ nsHTMLAnchorElement::SetFocus(nsIPresContext* aPresContext)
|
|||
{
|
||||
nsIEventStateManager* esm;
|
||||
if (NS_OK == aPresContext->GetEventStateManager(&esm)) {
|
||||
esm->SetFocusedContent(this);
|
||||
esm->SetContentState(this, NS_EVENT_STATE_FOCUS);
|
||||
NS_RELEASE(esm);
|
||||
}
|
||||
|
||||
|
@ -286,7 +286,7 @@ nsHTMLAnchorElement::HandleDOMEvent(nsIPresContext& aPresContext,
|
|||
{
|
||||
nsIEventStateManager *stateManager;
|
||||
if (NS_OK == aPresContext.GetEventStateManager(&stateManager)) {
|
||||
stateManager->SetActiveContent(this);
|
||||
stateManager->SetContentState(this, NS_EVENT_STATE_ACTIVE | NS_EVENT_STATE_FOCUS);
|
||||
NS_RELEASE(stateManager);
|
||||
}
|
||||
aEventStatus = nsEventStatus_eConsumeNoDefault;
|
||||
|
@ -306,7 +306,7 @@ nsHTMLAnchorElement::HandleDOMEvent(nsIPresContext& aPresContext,
|
|||
mInner.TriggerLink(aPresContext, eLinkVerb_Replace,
|
||||
baseURL, href, target, PR_TRUE);
|
||||
NS_IF_RELEASE(baseURL);
|
||||
aEventStatus = nsEventStatus_eConsumeNoDefault;
|
||||
aEventStatus = nsEventStatus_eConsumeDoDefault;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
@ -317,6 +317,12 @@ nsHTMLAnchorElement::HandleDOMEvent(nsIPresContext& aPresContext,
|
|||
|
||||
case NS_MOUSE_ENTER:
|
||||
{
|
||||
nsIEventStateManager *stateManager;
|
||||
if (NS_OK == aPresContext.GetEventStateManager(&stateManager)) {
|
||||
stateManager->SetContentState(this, NS_EVENT_STATE_HOVER);
|
||||
NS_RELEASE(stateManager);
|
||||
}
|
||||
|
||||
nsAutoString target;
|
||||
nsIURL* baseURL = nsnull;
|
||||
GetBaseURL(baseURL);
|
||||
|
@ -327,15 +333,21 @@ nsHTMLAnchorElement::HandleDOMEvent(nsIPresContext& aPresContext,
|
|||
mInner.TriggerLink(aPresContext, eLinkVerb_Replace,
|
||||
baseURL, href, target, PR_FALSE);
|
||||
NS_IF_RELEASE(baseURL);
|
||||
aEventStatus = nsEventStatus_eConsumeDoDefault;
|
||||
aEventStatus = nsEventStatus_eConsumeNoDefault;
|
||||
}
|
||||
break;
|
||||
|
||||
case NS_MOUSE_EXIT:
|
||||
{
|
||||
nsIEventStateManager *stateManager;
|
||||
if (NS_OK == aPresContext.GetEventStateManager(&stateManager)) {
|
||||
stateManager->SetContentState(nsnull, NS_EVENT_STATE_HOVER);
|
||||
NS_RELEASE(stateManager);
|
||||
}
|
||||
|
||||
nsAutoString empty;
|
||||
mInner.TriggerLink(aPresContext, eLinkVerb_Replace, nsnull, empty, empty, PR_FALSE);
|
||||
aEventStatus = nsEventStatus_eConsumeDoDefault;
|
||||
aEventStatus = nsEventStatus_eConsumeNoDefault;
|
||||
}
|
||||
break;
|
||||
|
||||
|
|
|
@ -231,7 +231,7 @@ nsHTMLAreaElement::SetFocus(nsIPresContext* aPresContext)
|
|||
{
|
||||
nsIEventStateManager* esm;
|
||||
if (NS_OK == aPresContext->GetEventStateManager(&esm)) {
|
||||
esm->SetFocusedContent(this);
|
||||
esm->SetContentState(this, NS_EVENT_STATE_FOCUS);
|
||||
NS_RELEASE(esm);
|
||||
}
|
||||
|
||||
|
|
|
@ -276,7 +276,7 @@ nsHTMLButtonElement::SetFocus(nsIPresContext* aPresContext)
|
|||
{
|
||||
nsIEventStateManager* esm;
|
||||
if (NS_OK == aPresContext->GetEventStateManager(&esm)) {
|
||||
esm->SetFocusedContent(this);
|
||||
esm->SetContentState(this, NS_EVENT_STATE_FOCUS);
|
||||
NS_RELEASE(esm);
|
||||
}
|
||||
|
||||
|
@ -372,7 +372,7 @@ nsHTMLButtonElement::HandleDOMEvent(nsIPresContext& aPresContext,
|
|||
{
|
||||
nsIEventStateManager *stateManager;
|
||||
if (NS_OK == aPresContext.GetEventStateManager(&stateManager)) {
|
||||
//stateManager->SetActiveLink(this);
|
||||
stateManager->SetContentState(this, NS_EVENT_STATE_ACTIVE | NS_EVENT_STATE_FOCUS);
|
||||
NS_RELEASE(stateManager);
|
||||
}
|
||||
aEventStatus = nsEventStatus_eConsumeNoDefault;
|
||||
|
@ -413,28 +413,25 @@ nsHTMLButtonElement::HandleDOMEvent(nsIPresContext& aPresContext,
|
|||
break;
|
||||
|
||||
case NS_MOUSE_ENTER:
|
||||
//mouse enter doesn't work yet. Use move until then.
|
||||
{
|
||||
nsAutoString href, target;
|
||||
nsIURL* baseURL = nsnull;
|
||||
GetBaseURL(baseURL);
|
||||
GetAttribute(kNameSpaceID_HTML, nsHTMLAtoms::href, href);
|
||||
GetAttribute(kNameSpaceID_HTML, nsHTMLAtoms::target, target);
|
||||
if (target.Length() == 0) {
|
||||
GetBaseTarget(target);
|
||||
nsIEventStateManager *stateManager;
|
||||
if (NS_OK == aPresContext.GetEventStateManager(&stateManager)) {
|
||||
stateManager->SetContentState(this, NS_EVENT_STATE_HOVER);
|
||||
NS_RELEASE(stateManager);
|
||||
}
|
||||
mInner.TriggerLink(aPresContext, eLinkVerb_Replace, baseURL, href, target, PR_FALSE);
|
||||
NS_IF_RELEASE(baseURL);
|
||||
aEventStatus = nsEventStatus_eConsumeDoDefault;
|
||||
aEventStatus = nsEventStatus_eConsumeNoDefault;
|
||||
}
|
||||
break;
|
||||
|
||||
// XXX this doesn't seem to do anything yet
|
||||
case NS_MOUSE_EXIT:
|
||||
{
|
||||
nsAutoString empty;
|
||||
mInner.TriggerLink(aPresContext, eLinkVerb_Replace, nsnull, empty, empty, PR_FALSE);
|
||||
aEventStatus = nsEventStatus_eConsumeDoDefault;
|
||||
nsIEventStateManager *stateManager;
|
||||
if (NS_OK == aPresContext.GetEventStateManager(&stateManager)) {
|
||||
stateManager->SetContentState(nsnull, NS_EVENT_STATE_HOVER);
|
||||
NS_RELEASE(stateManager);
|
||||
}
|
||||
aEventStatus = nsEventStatus_eConsumeNoDefault;
|
||||
}
|
||||
break;
|
||||
|
||||
|
|
|
@ -425,7 +425,7 @@ nsHTMLInputElement::SetFocus(nsIPresContext* aPresContext)
|
|||
{
|
||||
nsIEventStateManager* esm;
|
||||
if (NS_OK == aPresContext->GetEventStateManager(&esm)) {
|
||||
esm->SetFocusedContent(this);
|
||||
esm->SetContentState(this, NS_EVENT_STATE_FOCUS);
|
||||
NS_RELEASE(esm);
|
||||
}
|
||||
|
||||
|
|
|
@ -415,7 +415,7 @@ nsHTMLSelectElement::SetFocus(nsIPresContext* aPresContext)
|
|||
{
|
||||
nsIEventStateManager* esm;
|
||||
if (NS_OK == aPresContext->GetEventStateManager(&esm)) {
|
||||
esm->SetFocusedContent(this);
|
||||
esm->SetContentState(this, NS_EVENT_STATE_FOCUS);
|
||||
NS_RELEASE(esm);
|
||||
}
|
||||
|
||||
|
|
|
@ -252,7 +252,7 @@ nsHTMLTextAreaElement::SetFocus(nsIPresContext* aPresContext)
|
|||
{
|
||||
nsIEventStateManager* esm;
|
||||
if (NS_OK == aPresContext->GetEventStateManager(&esm)) {
|
||||
esm->SetFocusedContent(this);
|
||||
esm->SetContentState(this, NS_EVENT_STATE_FOCUS);
|
||||
NS_RELEASE(esm);
|
||||
}
|
||||
|
||||
|
|
|
@ -136,10 +136,10 @@ nsXMLElement::HandleDOMEvent(nsIPresContext& aPresContext,
|
|||
{
|
||||
nsIEventStateManager *stateManager;
|
||||
if (NS_OK == aPresContext.GetEventStateManager(&stateManager)) {
|
||||
stateManager->SetActiveContent(this);
|
||||
stateManager->SetContentState(this, NS_EVENT_STATE_ACTIVE | NS_EVENT_STATE_FOCUS);
|
||||
NS_RELEASE(stateManager);
|
||||
}
|
||||
aEventStatus = nsEventStatus_eConsumeNoDefault;
|
||||
aEventStatus = nsEventStatus_eConsumeDoDefault;
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -165,7 +165,7 @@ nsXMLElement::HandleDOMEvent(nsIPresContext& aPresContext,
|
|||
}
|
||||
mInner.TriggerLink(aPresContext, verb, baseURL, href, target, PR_TRUE);
|
||||
NS_IF_RELEASE(baseURL);
|
||||
aEventStatus = nsEventStatus_eConsumeNoDefault;
|
||||
aEventStatus = nsEventStatus_eConsumeDoDefault;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
|
Загрузка…
Ссылка в новой задаче