From 73330eac5e5d57826e61274ad3a84da6bd6a5b11 Mon Sep 17 00:00:00 2001 From: "karnaze%netscape.com" Date: Sat, 8 May 1999 19:30:57 +0000 Subject: [PATCH] added vcard_name html attribute. Added GetVcardName in nsFormFrame. --- content/html/content/src/nsHTMLAtoms.cpp | 3 ++ content/html/content/src/nsHTMLAtoms.h | 1 + content/shared/public/nsHTMLAtoms.h | 1 + content/shared/src/nsHTMLAtoms.cpp | 3 ++ layout/html/base/src/nsHTMLAtoms.cpp | 3 ++ layout/html/base/src/nsHTMLAtoms.h | 1 + layout/html/forms/src/nsFormFrame.cpp | 54 ++++++++++++++++++------ 7 files changed, 53 insertions(+), 13 deletions(-) diff --git a/content/html/content/src/nsHTMLAtoms.cpp b/content/html/content/src/nsHTMLAtoms.cpp index eeaf48ff993..64de63c6f0e 100644 --- a/content/html/content/src/nsHTMLAtoms.cpp +++ b/content/html/content/src/nsHTMLAtoms.cpp @@ -263,6 +263,7 @@ nsIAtom* nsHTMLAtoms::valign; nsIAtom* nsHTMLAtoms::value; nsIAtom* nsHTMLAtoms::valuetype; nsIAtom* nsHTMLAtoms::variable; +nsIAtom* nsHTMLAtoms::vcard_name; nsIAtom* nsHTMLAtoms::version; nsIAtom* nsHTMLAtoms::verticalFramesetBorderPseudo; nsIAtom* nsHTMLAtoms::visibility; @@ -525,6 +526,7 @@ void nsHTMLAtoms::AddrefAtoms() value = NS_NewAtom("value"); valuetype = NS_NewAtom("valuetype"); variable = NS_NewAtom("variable"); + vcard_name = NS_NewAtom("vcard_name"); version = NS_NewAtom("version"); verticalFramesetBorderPseudo = NS_NewAtom(":vframeset-border"); visibility = NS_NewAtom("visibility"); @@ -773,6 +775,7 @@ void nsHTMLAtoms::ReleaseAtoms() NS_RELEASE(value); NS_RELEASE(valuetype); NS_RELEASE(variable); + NS_RELEASE(vcard_name); NS_RELEASE(version); NS_RELEASE(verticalFramesetBorderPseudo); NS_RELEASE(visibility); diff --git a/content/html/content/src/nsHTMLAtoms.h b/content/html/content/src/nsHTMLAtoms.h index bca53d6dec4..3fb2f97a00b 100644 --- a/content/html/content/src/nsHTMLAtoms.h +++ b/content/html/content/src/nsHTMLAtoms.h @@ -300,6 +300,7 @@ public: static nsIAtom* value; static nsIAtom* valuetype; static nsIAtom* variable; + static nsIAtom* vcard_name; static nsIAtom* version; static nsIAtom* verticalFramesetBorderPseudo; static nsIAtom* visibility; diff --git a/content/shared/public/nsHTMLAtoms.h b/content/shared/public/nsHTMLAtoms.h index bca53d6dec4..3fb2f97a00b 100644 --- a/content/shared/public/nsHTMLAtoms.h +++ b/content/shared/public/nsHTMLAtoms.h @@ -300,6 +300,7 @@ public: static nsIAtom* value; static nsIAtom* valuetype; static nsIAtom* variable; + static nsIAtom* vcard_name; static nsIAtom* version; static nsIAtom* verticalFramesetBorderPseudo; static nsIAtom* visibility; diff --git a/content/shared/src/nsHTMLAtoms.cpp b/content/shared/src/nsHTMLAtoms.cpp index eeaf48ff993..64de63c6f0e 100644 --- a/content/shared/src/nsHTMLAtoms.cpp +++ b/content/shared/src/nsHTMLAtoms.cpp @@ -263,6 +263,7 @@ nsIAtom* nsHTMLAtoms::valign; nsIAtom* nsHTMLAtoms::value; nsIAtom* nsHTMLAtoms::valuetype; nsIAtom* nsHTMLAtoms::variable; +nsIAtom* nsHTMLAtoms::vcard_name; nsIAtom* nsHTMLAtoms::version; nsIAtom* nsHTMLAtoms::verticalFramesetBorderPseudo; nsIAtom* nsHTMLAtoms::visibility; @@ -525,6 +526,7 @@ void nsHTMLAtoms::AddrefAtoms() value = NS_NewAtom("value"); valuetype = NS_NewAtom("valuetype"); variable = NS_NewAtom("variable"); + vcard_name = NS_NewAtom("vcard_name"); version = NS_NewAtom("version"); verticalFramesetBorderPseudo = NS_NewAtom(":vframeset-border"); visibility = NS_NewAtom("visibility"); @@ -773,6 +775,7 @@ void nsHTMLAtoms::ReleaseAtoms() NS_RELEASE(value); NS_RELEASE(valuetype); NS_RELEASE(variable); + NS_RELEASE(vcard_name); NS_RELEASE(version); NS_RELEASE(verticalFramesetBorderPseudo); NS_RELEASE(visibility); diff --git a/layout/html/base/src/nsHTMLAtoms.cpp b/layout/html/base/src/nsHTMLAtoms.cpp index eeaf48ff993..64de63c6f0e 100644 --- a/layout/html/base/src/nsHTMLAtoms.cpp +++ b/layout/html/base/src/nsHTMLAtoms.cpp @@ -263,6 +263,7 @@ nsIAtom* nsHTMLAtoms::valign; nsIAtom* nsHTMLAtoms::value; nsIAtom* nsHTMLAtoms::valuetype; nsIAtom* nsHTMLAtoms::variable; +nsIAtom* nsHTMLAtoms::vcard_name; nsIAtom* nsHTMLAtoms::version; nsIAtom* nsHTMLAtoms::verticalFramesetBorderPseudo; nsIAtom* nsHTMLAtoms::visibility; @@ -525,6 +526,7 @@ void nsHTMLAtoms::AddrefAtoms() value = NS_NewAtom("value"); valuetype = NS_NewAtom("valuetype"); variable = NS_NewAtom("variable"); + vcard_name = NS_NewAtom("vcard_name"); version = NS_NewAtom("version"); verticalFramesetBorderPseudo = NS_NewAtom(":vframeset-border"); visibility = NS_NewAtom("visibility"); @@ -773,6 +775,7 @@ void nsHTMLAtoms::ReleaseAtoms() NS_RELEASE(value); NS_RELEASE(valuetype); NS_RELEASE(variable); + NS_RELEASE(vcard_name); NS_RELEASE(version); NS_RELEASE(verticalFramesetBorderPseudo); NS_RELEASE(visibility); diff --git a/layout/html/base/src/nsHTMLAtoms.h b/layout/html/base/src/nsHTMLAtoms.h index bca53d6dec4..3fb2f97a00b 100644 --- a/layout/html/base/src/nsHTMLAtoms.h +++ b/layout/html/base/src/nsHTMLAtoms.h @@ -300,6 +300,7 @@ public: static nsIAtom* value; static nsIAtom* valuetype; static nsIAtom* variable; + static nsIAtom* vcard_name; static nsIAtom* version; static nsIAtom* verticalFramesetBorderPseudo; static nsIAtom* visibility; diff --git a/layout/html/forms/src/nsFormFrame.cpp b/layout/html/forms/src/nsFormFrame.cpp index 24afe823224..0780943c10e 100644 --- a/layout/html/forms/src/nsFormFrame.cpp +++ b/layout/html/forms/src/nsFormFrame.cpp @@ -726,6 +726,35 @@ NS_IMETHODIMP nsFormFrame::GetEncoder(nsIUnicodeEncoder** encoder) } return NS_OK; } + +#ifdef ClientWallet +void +GetVcardName(nsIFormControlFrame& aFormControlFrame, nsString& aVCardName) +{ + aVCardName = ""; + nsIFrame* frame = nsnull; + nsresult rv = aFormControlFrame.QueryInterface(kIFrameIID, (void**)&frame); + if (NS_SUCCEEDED(rv) && frame) { + nsIContent* content = nsnull; + rv = frame->GetContent(&content); + if (NS_SUCCEEDED(rv) && content) { + nsIHTMLContent* htmlContent = nsnull; + rv = content->QueryInterface(kIHTMLContentIID, (void**)&htmlContent); + if (NS_SUCCEEDED(rv) && htmlContent) { + nsHTMLValue value; + if (NS_CONTENT_ATTR_HAS_VALUE == htmlContent->GetHTMLAttribute(nsHTMLAtoms::vcard_name, value)) { + if (eHTMLUnit_String == value.GetUnit()) { + value.GetStringValue(aVCardName); + } + } + NS_RELEASE(htmlContent); + } + NS_RELEASE(content); + } + } +} +#endif + #define CRLF "\015\012" void nsFormFrame::ProcessAsURLEncoded(PRBool isPost, nsString& aData, nsIFormControlFrame* aFrame) { @@ -811,19 +840,18 @@ void nsFormFrame::ProcessAsURLEncoded(PRBool isPost, nsString& aData, nsIFormCon child->GetType(&type); #endif #ifdef ClientWallet - if (OKToCapture && (NS_FORM_INPUT_TEXT == type)) { - nsString vcard(""); -/* following line is awaiting karneze to implement GetAttrib */ -// child->GetAttrib(NS_NewAtom("VCARD_NAME"), &vcard); - nsIWalletService *service; - nsresult res = nsServiceManager::GetService(kWalletServiceCID, - kIWalletServiceIID, - (nsISupports **)&service); - if ((NS_OK == res) && (nsnull != service)) { - res = service->WALLET_Capture(doc, *names, *values, vcard); - NS_RELEASE(service); - } - } + if (OKToCapture && (NS_FORM_INPUT_TEXT == type)) { + nsString vcard(""); + GetVcardName(*child, vcard); + nsIWalletService *service; + nsresult res = nsServiceManager::GetService(kWalletServiceCID, + kIWalletServiceIID, + (nsISupports **)&service); + if ((NS_OK == res) && (nsnull != service)) { + res = service->WALLET_Capture(doc, *names, *values, vcard); + NS_RELEASE(service); + } + } #endif #ifdef SingleSignon if ((type == NS_FORM_INPUT_PASSWORD) || (type == NS_FORM_INPUT_TEXT)) {