This commit is contained in:
karnaze%netscape.com 1998-10-19 20:37:40 +00:00
Родитель d59bbe2d87
Коммит 98eb658b89
9 изменённых файлов: 107 добавлений и 12 удалений

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

@ -266,7 +266,7 @@ nsHTMLTextAreaElement::Select() // XXX not tested
return NS_OK;
}
NS_IMPL_STRING_ATTR(nsHTMLTextAreaElement, DefaultValue, defaultvalue, eSetAttrNotify_None)
//NS_IMPL_STRING_ATTR(nsHTMLTextAreaElement, DefaultValue, defaultvalue, eSetAttrNotify_None)
NS_IMPL_STRING_ATTR(nsHTMLTextAreaElement, AccessKey, accesskey, eSetAttrNotify_None)
NS_IMPL_INT_ATTR(nsHTMLTextAreaElement, Cols, cols, eSetAttrNotify_Reflow)
NS_IMPL_BOOL_ATTR(nsHTMLTextAreaElement, Disabled, disabled, eSetAttrNotify_Render)
@ -275,6 +275,23 @@ NS_IMPL_BOOL_ATTR(nsHTMLTextAreaElement, ReadOnly, readonly, eSetAttrNotify_Rend
NS_IMPL_INT_ATTR(nsHTMLTextAreaElement, Rows, rows, eSetAttrNotify_Reflow)
NS_IMPL_INT_ATTR(nsHTMLTextAreaElement, TabIndex, tabindex, eSetAttrNotify_None)
NS_IMETHODIMP
nsHTMLTextAreaElement::GetDefaultValue(nsString& aDefaultValue)
{
mInner.GetAttribute(nsHTMLAtoms::defaultvalue, aDefaultValue);
return NS_OK;
}
NS_IMETHODIMP
nsHTMLTextAreaElement::SetDefaultValue(const nsString& aDefaultValue)
{
// trim leading whitespace
static char whitespace[] = " \r\n\t";
nsString value(aDefaultValue);
value.Trim(whitespace, PR_TRUE, PR_FALSE);
return mInner.SetAttribute(nsHTMLAtoms::defaultvalue, value, PR_TRUE);
}
NS_IMETHODIMP
nsHTMLTextAreaElement::StringToAttribute(nsIAtom* aAttribute,
const nsString& aValue,

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

@ -236,10 +236,19 @@ nsTextControlFrame::GetWidgetInitData(nsIPresContext& aPresContext)
nsTextWidgetInitData* data = nsnull;
if (NS_FORM_INPUT_PASSWORD == type) {
PRBool readOnly = nsFormFrame::GetReadonly(this);
if ((NS_FORM_INPUT_PASSWORD == type) || readOnly) {
data = new nsTextWidgetInitData();
data->clipChildren = PR_TRUE;
data->mIsPassword = PR_TRUE;
data->mIsPassword = PR_FALSE;
data->mIsReadOnly = PR_FALSE;
if (NS_FORM_INPUT_PASSWORD == type) {
data->clipChildren = PR_TRUE;
data->mIsPassword = PR_TRUE;
}
if (readOnly) {
data->mIsReadOnly = PR_TRUE;
}
}
return data;
@ -251,7 +260,7 @@ nsTextControlFrame::GetText(nsString* aText)
nsresult result = NS_CONTENT_ATTR_NOT_THERE;
PRInt32 type;
GetType(&type);
if (NS_FORM_INPUT_TEXT == type) {
if ((NS_FORM_INPUT_TEXT == type) || (NS_FORM_INPUT_PASSWORD == type)) {
nsIDOMHTMLInputElement* textElem = nsnull;
result = mContent->QueryInterface(kIDOMHTMLInputElementIID, (void**)&textElem);
if ((NS_OK == result) && textElem) {
@ -305,7 +314,9 @@ nsTextControlFrame::PostCreateWidget(nsIPresContext* aPresContext,
textArea->SetText(value, ignore);
NS_RELEASE(textArea);
}
mWidget->Enable(!nsFormFrame::GetDisabled(this));
if (nsFormFrame::GetDisabled(this)) {
mWidget->Enable(PR_FALSE);
}
}
PRInt32

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

@ -266,7 +266,7 @@ nsHTMLTextAreaElement::Select() // XXX not tested
return NS_OK;
}
NS_IMPL_STRING_ATTR(nsHTMLTextAreaElement, DefaultValue, defaultvalue, eSetAttrNotify_None)
//NS_IMPL_STRING_ATTR(nsHTMLTextAreaElement, DefaultValue, defaultvalue, eSetAttrNotify_None)
NS_IMPL_STRING_ATTR(nsHTMLTextAreaElement, AccessKey, accesskey, eSetAttrNotify_None)
NS_IMPL_INT_ATTR(nsHTMLTextAreaElement, Cols, cols, eSetAttrNotify_Reflow)
NS_IMPL_BOOL_ATTR(nsHTMLTextAreaElement, Disabled, disabled, eSetAttrNotify_Render)
@ -275,6 +275,23 @@ NS_IMPL_BOOL_ATTR(nsHTMLTextAreaElement, ReadOnly, readonly, eSetAttrNotify_Rend
NS_IMPL_INT_ATTR(nsHTMLTextAreaElement, Rows, rows, eSetAttrNotify_Reflow)
NS_IMPL_INT_ATTR(nsHTMLTextAreaElement, TabIndex, tabindex, eSetAttrNotify_None)
NS_IMETHODIMP
nsHTMLTextAreaElement::GetDefaultValue(nsString& aDefaultValue)
{
mInner.GetAttribute(nsHTMLAtoms::defaultvalue, aDefaultValue);
return NS_OK;
}
NS_IMETHODIMP
nsHTMLTextAreaElement::SetDefaultValue(const nsString& aDefaultValue)
{
// trim leading whitespace
static char whitespace[] = " \r\n\t";
nsString value(aDefaultValue);
value.Trim(whitespace, PR_TRUE, PR_FALSE);
return mInner.SetAttribute(nsHTMLAtoms::defaultvalue, value, PR_TRUE);
}
NS_IMETHODIMP
nsHTMLTextAreaElement::StringToAttribute(nsIAtom* aAttribute,
const nsString& aValue,

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

@ -1044,3 +1044,29 @@ nsFormFrame::GetDisabled(nsIFrame* aChildFrame, nsIContent* aContent)
}
return result;
}
PRBool
nsFormFrame::GetReadonly(nsIFrame* aChildFrame, nsIContent* aContent)
{
PRBool result = PR_FALSE;
nsIContent* content = aContent;
if (nsnull == content) {
aChildFrame->GetContent(content);
}
if (nsnull != content) {
nsIHTMLContent* htmlContent = nsnull;
content->QueryInterface(kIHTMLContentIID, (void**)&htmlContent);
if (nsnull != htmlContent) {
nsHTMLValue value;
if (NS_CONTENT_ATTR_HAS_VALUE == htmlContent->GetAttribute(nsHTMLAtoms::readonly, value)) {
result = PR_TRUE;
}
NS_RELEASE(htmlContent);
}
if (nsnull == aContent) {
NS_RELEASE(content);
}
}
return result;
}

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

@ -67,6 +67,7 @@ public:
// static helper functions for nsIFormControls
static PRBool GetDisabled(nsIFrame* aChildFrame, nsIContent* aContent = 0);
static PRBool GetReadonly(nsIFrame* aChildFrame, nsIContent* aContent = 0);
protected:
NS_IMETHOD_(nsrefcnt) AddRef(void);

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

@ -236,10 +236,19 @@ nsTextControlFrame::GetWidgetInitData(nsIPresContext& aPresContext)
nsTextWidgetInitData* data = nsnull;
if (NS_FORM_INPUT_PASSWORD == type) {
PRBool readOnly = nsFormFrame::GetReadonly(this);
if ((NS_FORM_INPUT_PASSWORD == type) || readOnly) {
data = new nsTextWidgetInitData();
data->clipChildren = PR_TRUE;
data->mIsPassword = PR_TRUE;
data->mIsPassword = PR_FALSE;
data->mIsReadOnly = PR_FALSE;
if (NS_FORM_INPUT_PASSWORD == type) {
data->clipChildren = PR_TRUE;
data->mIsPassword = PR_TRUE;
}
if (readOnly) {
data->mIsReadOnly = PR_TRUE;
}
}
return data;
@ -251,7 +260,7 @@ nsTextControlFrame::GetText(nsString* aText)
nsresult result = NS_CONTENT_ATTR_NOT_THERE;
PRInt32 type;
GetType(&type);
if (NS_FORM_INPUT_TEXT == type) {
if ((NS_FORM_INPUT_TEXT == type) || (NS_FORM_INPUT_PASSWORD == type)) {
nsIDOMHTMLInputElement* textElem = nsnull;
result = mContent->QueryInterface(kIDOMHTMLInputElementIID, (void**)&textElem);
if ((NS_OK == result) && textElem) {
@ -305,7 +314,9 @@ nsTextControlFrame::PostCreateWidget(nsIPresContext* aPresContext,
textArea->SetText(value, ignore);
NS_RELEASE(textArea);
}
mWidget->Enable(!nsFormFrame::GetDisabled(this));
if (nsFormFrame::GetDisabled(this)) {
mWidget->Enable(PR_FALSE);
}
}
PRInt32

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

@ -102,6 +102,16 @@ Disabled controls, the image submit should not submit the form.
</form>
<BR>
<BR>
<HR>
Readonly controls
<BR>
<FORM>
<input type=text readonly size=5 value=hello readonly> &nbsp; <input type=password value=foo disabled> &nbsp;
<textarea readonly>bar</textarea>
</form>
<BR>
<HR>
Additional tests -&nbsp;
<A href=test8siz.html>sizing</A>,

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

@ -28,6 +28,7 @@
struct nsTextWidgetInitData : public nsWidgetInitData {
PRBool mIsPassword;
PRBool mIsReadOnly;
};

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

@ -30,6 +30,7 @@ NS_METHOD nsTextHelper::PreCreateWidget(nsWidgetInitData *aInitData)
if (nsnull != aInitData) {
nsTextWidgetInitData* data = (nsTextWidgetInitData *) aInitData;
mIsPassword = data->mIsPassword;
mIsReadOnly = data->mIsReadOnly;
}
return NS_OK;
}