Removing nsILinkHandler enum types from dependencies, fixing event handler bugs

This commit is contained in:
joki%netscape.com 1999-01-28 23:14:36 +00:00
Родитель 93bb8ce0eb
Коммит 76111374a3
16 изменённых файлов: 194 добавлений и 106 удалений

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

@ -28,6 +28,12 @@ class nsIPresContext;
class nsIDOMEvent;
class nsIFrame;
enum nsLinkEventState {
eLinkState_Unspecified = 0,
eLinkState_Active = 1, // mouse is down on link
eLinkState_Hover = 2 // mouse is hovering over link
};
/*
* Event listener manager interface.
*/
@ -55,8 +61,9 @@ public:
NS_IMETHOD GetEventTarget(nsIFrame **aFrame) = 0;
NS_IMETHOD GetActiveLink(nsIContent **aLink) = 0;
NS_IMETHOD GetLinkState(nsIContent *aLink, nsLinkEventState& aState) = 0;
NS_IMETHOD SetActiveLink(nsIContent *aLink) = 0;
NS_IMETHOD SetHoverLink(nsIContent *aLink) = 0;
};
#endif // nsIEventStateManager_h__

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

@ -48,6 +48,7 @@ nsEventStateManager::nsEventStateManager() {
mLastRightMouseDownFrame = nsnull;
mActiveLink = nsnull;
mHoverLink = nsnull;
mCurrentFocus = nsnull;
mDocument = nsnull;
mPresContext = nsnull;
@ -56,6 +57,7 @@ nsEventStateManager::nsEventStateManager() {
nsEventStateManager::~nsEventStateManager() {
NS_IF_RELEASE(mActiveLink);
NS_IF_RELEASE(mHoverLink);
NS_IF_RELEASE(mCurrentFocus);
NS_IF_RELEASE(mDocument);
}
@ -89,7 +91,9 @@ nsEventStateManager::PreHandleEvent(nsIPresContext& aPresContext,
break;
case NS_GOTFOCUS:
NS_IF_RELEASE(mCurrentFocus);
aTargetFrame->GetContent(mCurrentFocus);
if (nsnull != mCurrentTarget) {
mCurrentTarget->GetContent(mCurrentFocus);
}
break;
}
return NS_OK;
@ -112,9 +116,11 @@ nsEventStateManager::PostHandleEvent(nsIPresContext& aPresContext,
switch (aEvent->message) {
case NS_MOUSE_LEFT_BUTTON_DOWN:
case NS_MOUSE_MIDDLE_BUTTON_DOWN:
case NS_MOUSE_RIGHT_BUTTON_DOWN:
if (nsnull != aEvent->widget) {
aEvent->widget->SetFocus();
case NS_MOUSE_RIGHT_BUTTON_DOWN:
{
if (nsnull != aEvent->widget) {
aEvent->widget->SetFocus();
}
}
//Break left out on purpose
case NS_MOUSE_LEFT_BUTTON_UP:
@ -256,7 +262,10 @@ nsEventStateManager::GenerateMouseEnterExit(nsIPresContext& aPresContext, nsGUIE
}
//Now dispatch to the frame
mLastMouseOverFrame->HandleEvent(aPresContext, &event, status);
if (nsnull != mLastMouseOverFrame) {
//XXX Get the new frame
mLastMouseOverFrame->HandleEvent(aPresContext, &event, status);
}
}
//fire mouseover
@ -276,6 +285,7 @@ nsEventStateManager::GenerateMouseEnterExit(nsIPresContext& aPresContext, nsGUIE
//Now dispatch to the frame
if (nsnull != mCurrentTarget) {
//XXX Get the new frame
mCurrentTarget->HandleEvent(aPresContext, &event, status);
}
@ -307,7 +317,10 @@ nsEventStateManager::GenerateMouseEnterExit(nsIPresContext& aPresContext, nsGUIE
}
//Now dispatch to the frame
mLastMouseOverFrame->HandleEvent(aPresContext, &event, status);
if (nsnull != mLastMouseOverFrame) {
//XXX Get the new frame
mLastMouseOverFrame->HandleEvent(aPresContext, &event, status);
}
}
}
break;
@ -490,12 +503,19 @@ nsEventStateManager::GetNextTabbableContent(nsIContent* aParent, nsIContent* aCh
if (nsnull != child) {
nsIAtom* tag;
PRBool disabled = PR_TRUE;
PRBool hidden = PR_FALSE;
child->GetTag(tag);
if (nsHTMLAtoms::input==tag) {
nsIDOMHTMLInputElement *nextInput;
if (NS_OK == child->QueryInterface(kIDOMHTMLInputElementIID,(void **)&nextInput)) {
nextInput->GetDisabled(&disabled);
nsAutoString type;
nextInput->GetType(type);
if (type.EqualsIgnoreCase("hidden")) {
hidden = PR_TRUE;
}
NS_RELEASE(nextInput);
}
}
@ -523,7 +543,7 @@ nsEventStateManager::GetNextTabbableContent(nsIContent* aParent, nsIContent* aCh
disabled = PR_FALSE;
}
if (!disabled) {
if (!disabled && !hidden) {
return child;
}
NS_RELEASE(child);
@ -551,59 +571,69 @@ nsEventStateManager::GetEventTarget(nsIFrame **aFrame)
}
NS_IMETHODIMP
nsEventStateManager::GetActiveLink(nsIContent **aLink)
nsEventStateManager::GetLinkState(nsIContent *aLink, nsLinkEventState& aState)
{
NS_PRECONDITION(nsnull != aLink, "null ptr");
if (nsnull == aLink) {
return NS_ERROR_NULL_POINTER;
if (aLink == mActiveLink) {
aState = eLinkState_Active;
}
else if (aLink == mHoverLink) {
aState = eLinkState_Hover;
}
else {
aState = eLinkState_Unspecified;
}
*aLink = mActiveLink;
NS_IF_ADDREF(mActiveLink);
return NS_OK;
}
NS_IMETHODIMP
nsEventStateManager::SetActiveLink(nsIContent *aLink)
{
#if 0
nsIDocument *mDocument;
//XXX this should just be able to call ContentChanged for the link once
//either nsFrame::ContentChanged does something or we have a separate
//link class
if (nsnull != mActiveLink) {
if (NS_OK == mActiveLink->GetDocument(mDocument)) {
nsIContent *mKid;
PRInt32 numKids;
mActiveLink->ChildCount(numKids);
for (int i = 0; i < numKids; i++) {
mActiveLink->ChildAt(i, mKid);
mDocument->ContentChanged(mKid, nsnull);
NS_RELEASE(mKid);
}
mDocument->ContentChanged(mActiveLink, nsnull);
NS_RELEASE(mDocument);
}
NS_RELEASE(mDocument);
}
#endif
NS_IF_RELEASE(mActiveLink);
mActiveLink = aLink;
NS_IF_ADDREF(mActiveLink);
#if 0
if (nsnull != mActiveLink) {
if (NS_OK == mActiveLink->GetDocument(mDocument)) {
nsIContent *mKid;
PRInt32 numKids;
mActiveLink->ChildCount(numKids);
for (int i = 0; i < numKids; i++) {
mActiveLink->ChildAt(i, mKid);
mDocument->ContentChanged(mKid, nsnull);
NS_RELEASE(mKid);
}
mDocument->ContentChanged(mActiveLink, nsnull);
NS_RELEASE(mDocument);
}
NS_RELEASE(mDocument);
}
#endif
return NS_OK;
}
NS_IMETHODIMP
nsEventStateManager::SetHoverLink(nsIContent *aLink)
{
nsIDocument *mDocument;
if (nsnull != mHoverLink) {
if (NS_OK == mHoverLink->GetDocument(mDocument)) {
mDocument->ContentChanged(mHoverLink, nsnull);
NS_RELEASE(mDocument);
}
}
NS_IF_RELEASE(mHoverLink);
mHoverLink = aLink;
NS_IF_ADDREF(mHoverLink);
if (nsnull != mHoverLink) {
if (NS_OK == mHoverLink->GetDocument(mDocument)) {
mDocument->ContentChanged(mHoverLink, nsnull);
NS_RELEASE(mDocument);
}
}
return NS_OK;
}

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

@ -50,9 +50,9 @@ public:
NS_IMETHOD GetEventTarget(nsIFrame **aFrame);
NS_IMETHOD GetActiveLink(nsIContent **aLink);
NS_IMETHOD GetLinkState(nsIContent *aLink, nsLinkEventState& aState);
NS_IMETHOD SetActiveLink(nsIContent *aLink);
NS_IMETHOD SetHoverLink(nsIContent *aLink);
protected:
void UpdateCursor(nsIPresContext& aPresContext, nsPoint& aPoint, nsIFrame* aTargetFrame, nsEventStatus& aStatus);
@ -70,6 +70,7 @@ protected:
nsIFrame* mLastRightMouseDownFrame;
nsIContent* mActiveLink;
nsIContent* mHoverLink;
nsIContent* mCurrentFocus;
//Not refcnted

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

@ -264,13 +264,13 @@ nsHTMLAnchorElement::HandleDOMEvent(nsIPresContext& aPresContext,
case NS_MOUSE_LEFT_BUTTON_UP:
{
nsIEventStateManager *stateManager;
nsIContent *activeLink;
nsLinkEventState linkState;
if (NS_OK == aPresContext.GetEventStateManager(&stateManager)) {
stateManager->GetActiveLink(&activeLink);
stateManager->GetLinkState(this, linkState);
NS_RELEASE(stateManager);
}
if (activeLink == this) {
if (eLinkState_Active == linkState) {
if (nsEventStatus_eConsumeNoDefault != aEventStatus) {
nsAutoString target;
nsIURL* baseURL = nsnull;

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

@ -1062,12 +1062,14 @@ static PRBool SelectorMatches(nsIPresContext* aPresContext,
case eLinkState_OutOfDate:
result = PRBool (pseudo == nsCSSAtoms::outOfDatePseudo);
break;
case eLinkState_Active:
//These cases have been moved from nsILinkHandler to to nsIEventStateManager.
//Code needs to be adjusted to get these state items from their new location.
/*case eLinkState_Active:
result = PRBool (pseudo == nsCSSAtoms::activePseudo);
break;
case eLinkState_Hover:
result = PRBool (pseudo == nsCSSAtoms::hoverPseudo);
break;
break;*/
}
}
}

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

@ -702,12 +702,14 @@ PRInt32 HTMLStyleSheetImpl::RulesMatching(nsIPresContext* aPresContext,
matchCount++;
}
break;
case eLinkState_Active:
//This case have been moved from nsILinkHandler to to nsIEventStateManager.
//Code needs to be adjusted to get this state item from new location.
/*case eLinkState_Active:
if (nsnull != mActiveRule) {
aResults->AppendElement(mActiveRule);
matchCount++;
}
break;
break;*/
}
}
}

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

@ -138,13 +138,13 @@ nsXMLElement::HandleDOMEvent(nsIPresContext& aPresContext,
case NS_MOUSE_LEFT_BUTTON_UP:
{
nsIEventStateManager *stateManager;
nsIContent *activeLink;
nsLinkEventState linkState;
if (NS_OK == aPresContext.GetEventStateManager(&stateManager)) {
stateManager->GetActiveLink(&activeLink);
stateManager->GetLinkState(this, linkState);
NS_RELEASE(stateManager);
}
if (activeLink == this) {
if (eLinkState_Active == linkState) {
if (nsEventStatus_eConsumeNoDefault != aEventStatus) {
nsAutoString show, href, target;
nsIURL* baseURL = nsnull;

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

@ -28,6 +28,12 @@ class nsIPresContext;
class nsIDOMEvent;
class nsIFrame;
enum nsLinkEventState {
eLinkState_Unspecified = 0,
eLinkState_Active = 1, // mouse is down on link
eLinkState_Hover = 2 // mouse is hovering over link
};
/*
* Event listener manager interface.
*/
@ -55,8 +61,9 @@ public:
NS_IMETHOD GetEventTarget(nsIFrame **aFrame) = 0;
NS_IMETHOD GetActiveLink(nsIContent **aLink) = 0;
NS_IMETHOD GetLinkState(nsIContent *aLink, nsLinkEventState& aState) = 0;
NS_IMETHOD SetActiveLink(nsIContent *aLink) = 0;
NS_IMETHOD SetHoverLink(nsIContent *aLink) = 0;
};
#endif // nsIEventStateManager_h__

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

@ -48,6 +48,7 @@ nsEventStateManager::nsEventStateManager() {
mLastRightMouseDownFrame = nsnull;
mActiveLink = nsnull;
mHoverLink = nsnull;
mCurrentFocus = nsnull;
mDocument = nsnull;
mPresContext = nsnull;
@ -56,6 +57,7 @@ nsEventStateManager::nsEventStateManager() {
nsEventStateManager::~nsEventStateManager() {
NS_IF_RELEASE(mActiveLink);
NS_IF_RELEASE(mHoverLink);
NS_IF_RELEASE(mCurrentFocus);
NS_IF_RELEASE(mDocument);
}
@ -89,7 +91,9 @@ nsEventStateManager::PreHandleEvent(nsIPresContext& aPresContext,
break;
case NS_GOTFOCUS:
NS_IF_RELEASE(mCurrentFocus);
aTargetFrame->GetContent(mCurrentFocus);
if (nsnull != mCurrentTarget) {
mCurrentTarget->GetContent(mCurrentFocus);
}
break;
}
return NS_OK;
@ -112,9 +116,11 @@ nsEventStateManager::PostHandleEvent(nsIPresContext& aPresContext,
switch (aEvent->message) {
case NS_MOUSE_LEFT_BUTTON_DOWN:
case NS_MOUSE_MIDDLE_BUTTON_DOWN:
case NS_MOUSE_RIGHT_BUTTON_DOWN:
if (nsnull != aEvent->widget) {
aEvent->widget->SetFocus();
case NS_MOUSE_RIGHT_BUTTON_DOWN:
{
if (nsnull != aEvent->widget) {
aEvent->widget->SetFocus();
}
}
//Break left out on purpose
case NS_MOUSE_LEFT_BUTTON_UP:
@ -256,7 +262,10 @@ nsEventStateManager::GenerateMouseEnterExit(nsIPresContext& aPresContext, nsGUIE
}
//Now dispatch to the frame
mLastMouseOverFrame->HandleEvent(aPresContext, &event, status);
if (nsnull != mLastMouseOverFrame) {
//XXX Get the new frame
mLastMouseOverFrame->HandleEvent(aPresContext, &event, status);
}
}
//fire mouseover
@ -276,6 +285,7 @@ nsEventStateManager::GenerateMouseEnterExit(nsIPresContext& aPresContext, nsGUIE
//Now dispatch to the frame
if (nsnull != mCurrentTarget) {
//XXX Get the new frame
mCurrentTarget->HandleEvent(aPresContext, &event, status);
}
@ -307,7 +317,10 @@ nsEventStateManager::GenerateMouseEnterExit(nsIPresContext& aPresContext, nsGUIE
}
//Now dispatch to the frame
mLastMouseOverFrame->HandleEvent(aPresContext, &event, status);
if (nsnull != mLastMouseOverFrame) {
//XXX Get the new frame
mLastMouseOverFrame->HandleEvent(aPresContext, &event, status);
}
}
}
break;
@ -490,12 +503,19 @@ nsEventStateManager::GetNextTabbableContent(nsIContent* aParent, nsIContent* aCh
if (nsnull != child) {
nsIAtom* tag;
PRBool disabled = PR_TRUE;
PRBool hidden = PR_FALSE;
child->GetTag(tag);
if (nsHTMLAtoms::input==tag) {
nsIDOMHTMLInputElement *nextInput;
if (NS_OK == child->QueryInterface(kIDOMHTMLInputElementIID,(void **)&nextInput)) {
nextInput->GetDisabled(&disabled);
nsAutoString type;
nextInput->GetType(type);
if (type.EqualsIgnoreCase("hidden")) {
hidden = PR_TRUE;
}
NS_RELEASE(nextInput);
}
}
@ -523,7 +543,7 @@ nsEventStateManager::GetNextTabbableContent(nsIContent* aParent, nsIContent* aCh
disabled = PR_FALSE;
}
if (!disabled) {
if (!disabled && !hidden) {
return child;
}
NS_RELEASE(child);
@ -551,59 +571,69 @@ nsEventStateManager::GetEventTarget(nsIFrame **aFrame)
}
NS_IMETHODIMP
nsEventStateManager::GetActiveLink(nsIContent **aLink)
nsEventStateManager::GetLinkState(nsIContent *aLink, nsLinkEventState& aState)
{
NS_PRECONDITION(nsnull != aLink, "null ptr");
if (nsnull == aLink) {
return NS_ERROR_NULL_POINTER;
if (aLink == mActiveLink) {
aState = eLinkState_Active;
}
else if (aLink == mHoverLink) {
aState = eLinkState_Hover;
}
else {
aState = eLinkState_Unspecified;
}
*aLink = mActiveLink;
NS_IF_ADDREF(mActiveLink);
return NS_OK;
}
NS_IMETHODIMP
nsEventStateManager::SetActiveLink(nsIContent *aLink)
{
#if 0
nsIDocument *mDocument;
//XXX this should just be able to call ContentChanged for the link once
//either nsFrame::ContentChanged does something or we have a separate
//link class
if (nsnull != mActiveLink) {
if (NS_OK == mActiveLink->GetDocument(mDocument)) {
nsIContent *mKid;
PRInt32 numKids;
mActiveLink->ChildCount(numKids);
for (int i = 0; i < numKids; i++) {
mActiveLink->ChildAt(i, mKid);
mDocument->ContentChanged(mKid, nsnull);
NS_RELEASE(mKid);
}
mDocument->ContentChanged(mActiveLink, nsnull);
NS_RELEASE(mDocument);
}
NS_RELEASE(mDocument);
}
#endif
NS_IF_RELEASE(mActiveLink);
mActiveLink = aLink;
NS_IF_ADDREF(mActiveLink);
#if 0
if (nsnull != mActiveLink) {
if (NS_OK == mActiveLink->GetDocument(mDocument)) {
nsIContent *mKid;
PRInt32 numKids;
mActiveLink->ChildCount(numKids);
for (int i = 0; i < numKids; i++) {
mActiveLink->ChildAt(i, mKid);
mDocument->ContentChanged(mKid, nsnull);
NS_RELEASE(mKid);
}
mDocument->ContentChanged(mActiveLink, nsnull);
NS_RELEASE(mDocument);
}
NS_RELEASE(mDocument);
}
#endif
return NS_OK;
}
NS_IMETHODIMP
nsEventStateManager::SetHoverLink(nsIContent *aLink)
{
nsIDocument *mDocument;
if (nsnull != mHoverLink) {
if (NS_OK == mHoverLink->GetDocument(mDocument)) {
mDocument->ContentChanged(mHoverLink, nsnull);
NS_RELEASE(mDocument);
}
}
NS_IF_RELEASE(mHoverLink);
mHoverLink = aLink;
NS_IF_ADDREF(mHoverLink);
if (nsnull != mHoverLink) {
if (NS_OK == mHoverLink->GetDocument(mDocument)) {
mDocument->ContentChanged(mHoverLink, nsnull);
NS_RELEASE(mDocument);
}
}
return NS_OK;
}

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

@ -50,9 +50,9 @@ public:
NS_IMETHOD GetEventTarget(nsIFrame **aFrame);
NS_IMETHOD GetActiveLink(nsIContent **aLink);
NS_IMETHOD GetLinkState(nsIContent *aLink, nsLinkEventState& aState);
NS_IMETHOD SetActiveLink(nsIContent *aLink);
NS_IMETHOD SetHoverLink(nsIContent *aLink);
protected:
void UpdateCursor(nsIPresContext& aPresContext, nsPoint& aPoint, nsIFrame* aTargetFrame, nsEventStatus& aStatus);
@ -70,6 +70,7 @@ protected:
nsIFrame* mLastRightMouseDownFrame;
nsIContent* mActiveLink;
nsIContent* mHoverLink;
nsIContent* mCurrentFocus;
//Not refcnted

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

@ -264,13 +264,13 @@ nsHTMLAnchorElement::HandleDOMEvent(nsIPresContext& aPresContext,
case NS_MOUSE_LEFT_BUTTON_UP:
{
nsIEventStateManager *stateManager;
nsIContent *activeLink;
nsLinkEventState linkState;
if (NS_OK == aPresContext.GetEventStateManager(&stateManager)) {
stateManager->GetActiveLink(&activeLink);
stateManager->GetLinkState(this, linkState);
NS_RELEASE(stateManager);
}
if (activeLink == this) {
if (eLinkState_Active == linkState) {
if (nsEventStatus_eConsumeNoDefault != aEventStatus) {
nsAutoString target;
nsIURL* baseURL = nsnull;

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

@ -1062,12 +1062,14 @@ static PRBool SelectorMatches(nsIPresContext* aPresContext,
case eLinkState_OutOfDate:
result = PRBool (pseudo == nsCSSAtoms::outOfDatePseudo);
break;
case eLinkState_Active:
//These cases have been moved from nsILinkHandler to to nsIEventStateManager.
//Code needs to be adjusted to get these state items from their new location.
/*case eLinkState_Active:
result = PRBool (pseudo == nsCSSAtoms::activePseudo);
break;
case eLinkState_Hover:
result = PRBool (pseudo == nsCSSAtoms::hoverPseudo);
break;
break;*/
}
}
}

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

@ -702,12 +702,14 @@ PRInt32 HTMLStyleSheetImpl::RulesMatching(nsIPresContext* aPresContext,
matchCount++;
}
break;
case eLinkState_Active:
//This case have been moved from nsILinkHandler to to nsIEventStateManager.
//Code needs to be adjusted to get this state item from new location.
/*case eLinkState_Active:
if (nsnull != mActiveRule) {
aResults->AppendElement(mActiveRule);
matchCount++;
}
break;
break;*/
}
}
}

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

@ -1062,12 +1062,14 @@ static PRBool SelectorMatches(nsIPresContext* aPresContext,
case eLinkState_OutOfDate:
result = PRBool (pseudo == nsCSSAtoms::outOfDatePseudo);
break;
case eLinkState_Active:
//These cases have been moved from nsILinkHandler to to nsIEventStateManager.
//Code needs to be adjusted to get these state items from their new location.
/*case eLinkState_Active:
result = PRBool (pseudo == nsCSSAtoms::activePseudo);
break;
case eLinkState_Hover:
result = PRBool (pseudo == nsCSSAtoms::hoverPseudo);
break;
break;*/
}
}
}

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

@ -702,12 +702,14 @@ PRInt32 HTMLStyleSheetImpl::RulesMatching(nsIPresContext* aPresContext,
matchCount++;
}
break;
case eLinkState_Active:
//This case have been moved from nsILinkHandler to to nsIEventStateManager.
//Code needs to be adjusted to get this state item from new location.
/*case eLinkState_Active:
if (nsnull != mActiveRule) {
aResults->AppendElement(mActiveRule);
matchCount++;
}
break;
break;*/
}
}
}

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

@ -138,13 +138,13 @@ nsXMLElement::HandleDOMEvent(nsIPresContext& aPresContext,
case NS_MOUSE_LEFT_BUTTON_UP:
{
nsIEventStateManager *stateManager;
nsIContent *activeLink;
nsLinkEventState linkState;
if (NS_OK == aPresContext.GetEventStateManager(&stateManager)) {
stateManager->GetActiveLink(&activeLink);
stateManager->GetLinkState(this, linkState);
NS_RELEASE(stateManager);
}
if (activeLink == this) {
if (eLinkState_Active == linkState) {
if (nsEventStatus_eConsumeNoDefault != aEventStatus) {
nsAutoString show, href, target;
nsIURL* baseURL = nsnull;