Backed out 1.54, this is 1.53

This commit is contained in:
rods%netscape.com 1999-09-30 16:43:11 +00:00
parent b0b9f1a791
commit 441488d899
2 changed files with 30 additions and 134 deletions

View File

@ -138,8 +138,6 @@ protected:
nsIForm* mForm;
PRInt32 mType;
NS_IMETHOD GetPresContext(nsIPresContext ** aPresContext);
PRBool IsImage() const {
nsAutoString tmp;
mInner.GetAttribute(kNameSpaceID_HTML, nsHTMLAtoms::type, tmp);
@ -439,51 +437,15 @@ nsHTMLInputElement::SetChecked(PRBool aValue)
return NS_OK;
}
NS_IMETHODIMP
nsHTMLInputElement::GetPresContext(nsIPresContext ** aPresContext)
{
if (nsnull == aPresContext) {
return NS_ERROR_FAILURE;
}
*aPresContext = nsnull;
nsIDocument* doc;
nsresult rv = GetDocument(doc);
if (nsnull != doc) {
nsIPresShell* presShell = doc->GetShellAt(0);
if (nsnull != presShell) {
rv = presShell->GetPresContext(aPresContext);
NS_RELEASE(presShell);
}
NS_RELEASE(doc);
}
return rv;
}
NS_IMETHODIMP
nsHTMLInputElement::Blur()
{
nsIPresContext * context;
nsresult rv = GetPresContext(&context);
if (NS_SUCCEEDED(rv) && nsnull != context) {
nsIEventStateManager* esm;
if (NS_OK == context->GetEventStateManager(&esm)) {
nsIContent * focusedContent;
nsIContent * content;
rv = QueryInterface(nsIContent::GetIID(), (void **)&content);
if (NS_SUCCEEDED(rv) && nsnull != content) {
esm->GetFocusedContent(&focusedContent);
if (nsnull != focusedContent && content == focusedContent) {
rv = esm->SetContentState(nsnull, NS_EVENT_STATE_FOCUS);
NS_RELEASE(focusedContent);
}
NS_RELEASE(content);
}
NS_RELEASE(esm);
}
NS_RELEASE(context);
nsIFormControlFrame* formControlFrame = nsnull;
nsresult rv = nsGenericHTMLElement::GetPrimaryFrame(this, formControlFrame);
if (NS_SUCCEEDED(rv)) {
// Ask the frame to Deselect focus (i.e Blur).
formControlFrame->SetFocus(PR_FALSE, PR_TRUE);
return NS_OK;
}
return rv;
}
@ -491,13 +453,12 @@ nsHTMLInputElement::Blur()
NS_IMETHODIMP
nsHTMLInputElement::Focus()
{
nsIPresContext * context;
nsresult rv = GetPresContext(&context);
if (NS_SUCCEEDED(rv) && nsnull != context) {
SetFocus(context);
NS_RELEASE(context);
nsIFormControlFrame* formControlFrame = nsnull;
nsresult rv = nsGenericHTMLElement::GetPrimaryFrame(this, formControlFrame);
if (NS_SUCCEEDED(rv)) {
formControlFrame->SetFocus(PR_TRUE, PR_TRUE);
return NS_OK;
}
return rv;
}
@ -516,14 +477,14 @@ nsHTMLInputElement::SetFocus(nsIPresContext* aPresContext)
NS_RELEASE(esm);
}
// XXX Should focus only this presContext
Focus();
nsIFormControlFrame* formControlFrame = nsnull;
nsresult rv = nsGenericHTMLElement::GetPrimaryFrame(this, formControlFrame);
if (NS_SUCCEEDED(rv)) {
formControlFrame->SetFocus(PR_TRUE, PR_TRUE);
formControlFrame->ScrollIntoView(aPresContext);
return NS_OK;
}
return rv;
}
@ -531,7 +492,7 @@ NS_IMETHODIMP
nsHTMLInputElement::RemoveFocus(nsIPresContext* aPresContext)
{
// XXX Should focus only this presContext
//Blur();
Blur();
return NS_OK;
}
@ -590,19 +551,6 @@ nsHTMLInputElement::HandleDOMEvent(nsIPresContext& aPresContext,
if ((NS_OK == ret) && (nsEventStatus_eIgnore == aEventStatus)) {
switch (aEvent->message) {
case NS_FOCUS_CONTENT:
{
nsIFormControlFrame* formControlFrame = nsnull;
nsresult rv = nsGenericHTMLElement::GetPrimaryFrame(this, formControlFrame);
if (NS_SUCCEEDED(rv)) {
formControlFrame->SetFocus(PR_TRUE, PR_TRUE);
return NS_OK;
}
//SetFocus(&aPresContext);
}
break;
case NS_KEY_PRESS:
{
nsKeyEvent * keyEvent = (nsKeyEvent *)aEvent;

View File

@ -138,8 +138,6 @@ protected:
nsIForm* mForm;
PRInt32 mType;
NS_IMETHOD GetPresContext(nsIPresContext ** aPresContext);
PRBool IsImage() const {
nsAutoString tmp;
mInner.GetAttribute(kNameSpaceID_HTML, nsHTMLAtoms::type, tmp);
@ -439,51 +437,15 @@ nsHTMLInputElement::SetChecked(PRBool aValue)
return NS_OK;
}
NS_IMETHODIMP
nsHTMLInputElement::GetPresContext(nsIPresContext ** aPresContext)
{
if (nsnull == aPresContext) {
return NS_ERROR_FAILURE;
}
*aPresContext = nsnull;
nsIDocument* doc;
nsresult rv = GetDocument(doc);
if (nsnull != doc) {
nsIPresShell* presShell = doc->GetShellAt(0);
if (nsnull != presShell) {
rv = presShell->GetPresContext(aPresContext);
NS_RELEASE(presShell);
}
NS_RELEASE(doc);
}
return rv;
}
NS_IMETHODIMP
nsHTMLInputElement::Blur()
{
nsIPresContext * context;
nsresult rv = GetPresContext(&context);
if (NS_SUCCEEDED(rv) && nsnull != context) {
nsIEventStateManager* esm;
if (NS_OK == context->GetEventStateManager(&esm)) {
nsIContent * focusedContent;
nsIContent * content;
rv = QueryInterface(nsIContent::GetIID(), (void **)&content);
if (NS_SUCCEEDED(rv) && nsnull != content) {
esm->GetFocusedContent(&focusedContent);
if (nsnull != focusedContent && content == focusedContent) {
rv = esm->SetContentState(nsnull, NS_EVENT_STATE_FOCUS);
NS_RELEASE(focusedContent);
}
NS_RELEASE(content);
}
NS_RELEASE(esm);
}
NS_RELEASE(context);
nsIFormControlFrame* formControlFrame = nsnull;
nsresult rv = nsGenericHTMLElement::GetPrimaryFrame(this, formControlFrame);
if (NS_SUCCEEDED(rv)) {
// Ask the frame to Deselect focus (i.e Blur).
formControlFrame->SetFocus(PR_FALSE, PR_TRUE);
return NS_OK;
}
return rv;
}
@ -491,13 +453,12 @@ nsHTMLInputElement::Blur()
NS_IMETHODIMP
nsHTMLInputElement::Focus()
{
nsIPresContext * context;
nsresult rv = GetPresContext(&context);
if (NS_SUCCEEDED(rv) && nsnull != context) {
SetFocus(context);
NS_RELEASE(context);
nsIFormControlFrame* formControlFrame = nsnull;
nsresult rv = nsGenericHTMLElement::GetPrimaryFrame(this, formControlFrame);
if (NS_SUCCEEDED(rv)) {
formControlFrame->SetFocus(PR_TRUE, PR_TRUE);
return NS_OK;
}
return rv;
}
@ -516,14 +477,14 @@ nsHTMLInputElement::SetFocus(nsIPresContext* aPresContext)
NS_RELEASE(esm);
}
// XXX Should focus only this presContext
Focus();
nsIFormControlFrame* formControlFrame = nsnull;
nsresult rv = nsGenericHTMLElement::GetPrimaryFrame(this, formControlFrame);
if (NS_SUCCEEDED(rv)) {
formControlFrame->SetFocus(PR_TRUE, PR_TRUE);
formControlFrame->ScrollIntoView(aPresContext);
return NS_OK;
}
return rv;
}
@ -531,7 +492,7 @@ NS_IMETHODIMP
nsHTMLInputElement::RemoveFocus(nsIPresContext* aPresContext)
{
// XXX Should focus only this presContext
//Blur();
Blur();
return NS_OK;
}
@ -590,19 +551,6 @@ nsHTMLInputElement::HandleDOMEvent(nsIPresContext& aPresContext,
if ((NS_OK == ret) && (nsEventStatus_eIgnore == aEventStatus)) {
switch (aEvent->message) {
case NS_FOCUS_CONTENT:
{
nsIFormControlFrame* formControlFrame = nsnull;
nsresult rv = nsGenericHTMLElement::GetPrimaryFrame(this, formControlFrame);
if (NS_SUCCEEDED(rv)) {
formControlFrame->SetFocus(PR_TRUE, PR_TRUE);
return NS_OK;
}
//SetFocus(&aPresContext);
}
break;
case NS_KEY_PRESS:
{
nsKeyEvent * keyEvent = (nsKeyEvent *)aEvent;