24 #include "dom/html_form.h" 25 #include "dom/dom_exception.h" 26 #include "dom/dom_doc.h" 28 #include "html/html_formimpl.h" 29 #include "html/html_miscimpl.h" 31 #include "xml/dom_docimpl.h" 32 #include "misc/htmlhashes.h" 36 HTMLButtonElement::HTMLButtonElement() :
HTMLElement()
44 HTMLButtonElement::HTMLButtonElement(HTMLButtonElementImpl *impl) :
HTMLElement(impl)
50 assignOther( other, ID_BUTTON );
56 HTMLElement::operator = (other);
60 HTMLButtonElement::~HTMLButtonElement()
72 return static_cast<ElementImpl*
>(impl)->
getAttribute(ATTR_ACCESSKEY);
77 if(impl)
static_cast<ElementImpl*
>(impl)->
setAttribute(ATTR_ACCESSKEY, value);
83 return !
static_cast<ElementImpl*
>(impl)->
getAttribute(ATTR_DISABLED).isNull();
88 if (impl)
static_cast<ElementImpl*
>(impl)->
setAttribute(ATTR_DISABLED, _disabled ?
"" : 0);
94 return static_cast<ElementImpl*
>(impl)->
getAttribute(ATTR_NAME);
99 if(impl)
static_cast<ElementImpl*
>(impl)->
setAttribute(ATTR_NAME, value);
105 static_cast<HTMLButtonElementImpl*
>(impl)->focus();
111 static_cast<HTMLButtonElementImpl*
>(impl)->blur();
117 return static_cast<ElementImpl*
>(impl)->tabIndex();
123 static_cast<ElementImpl*
>(impl)->setTabIndex(_tabIndex);
129 return static_cast<HTMLButtonElementImpl*
>(impl)->type();
142 if(impl)
static_cast<ElementImpl*
>(impl)->
setAttribute(ATTR_VALUE, value);
147 HTMLFieldSetElement::HTMLFieldSetElement() :
HTMLElement()
155 HTMLFieldSetElement::HTMLFieldSetElement(HTMLFieldSetElementImpl *impl) :
HTMLElement(impl)
161 assignOther( other, ID_FIELDSET );
167 HTMLElement::operator = (other);
171 HTMLFieldSetElement::~HTMLFieldSetElement()
190 HTMLFormElement::HTMLFormElement(HTMLFormElementImpl *impl) :
HTMLElement(impl)
196 assignOther( other, ID_FORM );
202 HTMLElement::operator = (other);
206 HTMLFormElement::~HTMLFormElement()
213 return HTMLFormCollection(impl);
219 return static_cast<HTMLFormElementImpl*
>(impl)->length();
225 return static_cast<ElementImpl*
>(impl)->
getAttribute(ATTR_NAME);
230 if(impl)
static_cast<ElementImpl*
>(impl)->
setAttribute(ATTR_NAME, value);
236 return static_cast<ElementImpl*
>(impl)->
getAttribute(ATTR_ACCEPT_CHARSET);
241 if(impl)
static_cast<ElementImpl*
>(impl)->
setAttribute(ATTR_ACCEPT_CHARSET, value);
247 return static_cast<ElementImpl*
>(impl)->
getAttribute(ATTR_ACTION);
252 if(impl)
static_cast<ElementImpl*
>(impl)->
setAttribute(ATTR_ACTION, value);
258 return static_cast<ElementImpl*
>(impl)->
getAttribute(ATTR_ENCTYPE);
263 if(impl)
static_cast<ElementImpl*
>(impl)->
setAttribute(ATTR_ENCTYPE, value);
269 return static_cast<ElementImpl*
>(impl)->
getAttribute(ATTR_METHOD);
274 if(impl)
static_cast<ElementImpl*
>(impl)->
setAttribute(ATTR_METHOD, value);
280 return static_cast<ElementImpl*
>(impl)->
getAttribute(ATTR_TARGET);
285 if(impl)
static_cast<ElementImpl*
>(impl)->
setAttribute(ATTR_TARGET, value);
290 if(impl)
static_cast<HTMLFormElementImpl*
>(impl)->submit( );
295 if(impl)
static_cast<HTMLFormElementImpl*
>(impl)->reset( );
300 HTMLInputElement::HTMLInputElement() :
HTMLElement()
308 HTMLInputElement::HTMLInputElement(HTMLInputElementImpl *impl) :
HTMLElement(impl)
314 assignOther( other, ID_INPUT );
320 HTMLElement::operator = (other);
324 HTMLInputElement::~HTMLInputElement()
339 if(impl) ((ElementImpl *)impl)->setAttribute(ATTR_VALUE, value);
345 return !((ElementImpl *)impl)->getAttribute(ATTR_CHECKED).isNull();
351 ((ElementImpl *)impl)->setAttribute(ATTR_CHECKED, _defaultChecked ?
"" : 0);
362 return ((ElementImpl *)impl)->getAttribute(ATTR_ACCEPT);
367 if(impl) ((ElementImpl *)impl)->setAttribute(ATTR_ACCEPT, value);
373 return ((ElementImpl *)impl)->getAttribute(ATTR_ACCESSKEY);
378 if(impl) ((ElementImpl *)impl)->setAttribute(ATTR_ACCESSKEY, value);
384 return ((ElementImpl *)impl)->getAttribute(ATTR_ALIGN);
389 if(impl) ((ElementImpl *)impl)->setAttribute(ATTR_ALIGN, value);
395 return ((ElementImpl *)impl)->getAttribute(ATTR_ALT);
400 if(impl) ((ElementImpl *)impl)->setAttribute(ATTR_ALT, value);
406 return ((HTMLInputElementImpl*)impl)->checked();
412 ((HTMLInputElementImpl*)impl)->setChecked(_checked);
418 return ((HTMLInputElementImpl*)impl)->indeterminate();
424 ((HTMLInputElementImpl*)impl)->setIndeterminate(_indeterminate);
430 return !((ElementImpl *)impl)->getAttribute(ATTR_DISABLED).isNull();
437 ((ElementImpl *)impl)->setAttribute(ATTR_DISABLED, _disabled ?
"" : 0);
444 return ((HTMLInputElementImpl *)impl)->getAttribute(ATTR_MAXLENGTH).toInt();
450 DOMString value(TQString::number(_maxLength));
451 ((ElementImpl *)impl)->setAttribute(ATTR_MAXLENGTH,value);
458 return static_cast<HTMLInputElementImpl* const
>(impl)->name();
463 if(impl)
static_cast<HTMLInputElementImpl*
>(impl)->setName(value);
469 return !
static_cast<ElementImpl*
>(impl)->
getAttribute(ATTR_READONLY).isNull();
475 static_cast<ElementImpl*
>(impl)->
setAttribute(ATTR_READONLY, _readOnly ?
"" : 0);
482 return static_cast<ElementImpl*
>(impl)->
getAttribute(ATTR_SIZE);
487 if(impl)
static_cast<ElementImpl*
>(impl)->
setAttribute(ATTR_SIZE, value);
493 return static_cast<ElementImpl*
>(impl)->
getAttribute(ATTR_SIZE).toInt();
498 if(impl)
static_cast<ElementImpl*
>(impl)->
setAttribute(ATTR_SIZE, TQString::number(value));
505 return !s.isNull() ? impl->getDocument()->completeURL( s.string() ) : s;
510 if(impl)
static_cast<ElementImpl*
>(impl)->
setAttribute(ATTR_SRC, value);
516 return static_cast<ElementImpl*
>(impl)->tabIndex();
522 static_cast<ElementImpl*
>(impl)->setTabIndex(_tabIndex);
528 return ((HTMLInputElementImpl *)impl)->type();
534 static_cast<HTMLInputElementImpl*
>(impl)->setType(_type);
540 return static_cast<ElementImpl*
>(impl)->
getAttribute(ATTR_USEMAP);
545 if(impl)
static_cast<ElementImpl*
>(impl)->
setAttribute(ATTR_USEMAP, value);
551 return ((HTMLInputElementImpl*)impl)->value();
557 ((HTMLInputElementImpl*)impl)->setValue(value);
564 ((HTMLInputElementImpl*)impl)->blur();
570 ((HTMLInputElementImpl*)impl)->focus();
576 ((HTMLInputElementImpl *)impl)->select( );
582 ((HTMLInputElementImpl *)impl)->click( );
588 return ((HTMLInputElementImpl *)impl)->selectionStart( );
595 return ((HTMLInputElementImpl *)impl)->selectionEnd( );
602 ((HTMLInputElementImpl *)impl)->setSelectionStart( pos );
608 ((HTMLInputElementImpl *)impl)->setSelectionEnd( pos );
614 ((HTMLInputElementImpl *)impl)->setSelectionRange( start, end );
619 HTMLLabelElement::HTMLLabelElement() :
HTMLElement()
627 HTMLLabelElement::HTMLLabelElement(HTMLLabelElementImpl *impl) :
HTMLElement(impl)
633 assignOther( other, ID_LABEL );
639 HTMLElement::operator = (other);
643 HTMLLabelElement::~HTMLLabelElement()
650 return static_cast<ElementImpl*
>(impl)->
getAttribute(ATTR_ACCESSKEY);
655 if(impl)
static_cast<ElementImpl*
>(impl)->
setAttribute(ATTR_ACCESSKEY, value);
661 return static_cast<ElementImpl*
>(impl)->
getAttribute(ATTR_FOR);
666 if(impl)
static_cast<ElementImpl*
>(impl)->
setAttribute(ATTR_FOR, value);
671 HTMLLegendElement::HTMLLegendElement() :
HTMLElement()
679 HTMLLegendElement::HTMLLegendElement(HTMLLegendElementImpl *impl) :
HTMLElement(impl)
685 assignOther( other, ID_LEGEND );
691 HTMLElement::operator = (other);
695 HTMLLegendElement::~HTMLLegendElement()
707 return static_cast<ElementImpl*
>(impl)->
getAttribute(ATTR_ACCESSKEY);
712 if(impl)
static_cast<ElementImpl*
>(impl)->
setAttribute(ATTR_ACCESSKEY, value);
718 return static_cast<ElementImpl*
>(impl)->
getAttribute(ATTR_ALIGN);
723 if(impl)
static_cast<ElementImpl*
>(impl)->
setAttribute(ATTR_ALIGN, value);
728 HTMLOptGroupElement::HTMLOptGroupElement() :
HTMLElement()
736 HTMLOptGroupElement::HTMLOptGroupElement(HTMLOptGroupElementImpl *impl) :
HTMLElement(impl)
742 assignOther( other, ID_OPTGROUP );
748 HTMLElement::operator = (other);
752 HTMLOptGroupElement::~HTMLOptGroupElement()
759 return !
static_cast<ElementImpl*
>(impl)->
getAttribute(ATTR_DISABLED).isNull();
765 static_cast<ElementImpl*
>(impl)->
setAttribute(ATTR_DISABLED, _disabled ?
"" : 0);
771 return static_cast<ElementImpl*
>(impl)->
getAttribute(ATTR_LABEL);
776 if(impl)
static_cast<ElementImpl*
>(impl)->
setAttribute(ATTR_LABEL, value);
781 HTMLSelectElement::HTMLSelectElement() :
HTMLElement()
789 HTMLSelectElement::HTMLSelectElement(HTMLSelectElementImpl *impl) :
HTMLElement(impl)
795 assignOther( other, ID_SELECT );
801 HTMLElement::operator = (other);
805 HTMLSelectElement::~HTMLSelectElement()
812 return ((HTMLSelectElementImpl *)impl)->type();
818 return ((HTMLSelectElementImpl *)impl)->selectedIndex();
824 ((HTMLSelectElementImpl *)impl)->setSelectedIndex(_selectedIndex);
830 return static_cast<HTMLSelectElementImpl*
>(impl)->value();
835 if(!impl || value.isNull())
return;
836 static_cast<HTMLSelectElementImpl*
>(impl)->setValue(value.implementation());
842 return ((HTMLSelectElementImpl *)impl)->length();
859 return !
static_cast<ElementImpl*
>(impl)->
getAttribute(ATTR_DISABLED).isNull();
864 if(impl)
static_cast<ElementImpl*
>(impl)->
setAttribute(ATTR_DISABLED, _disabled ?
"" : 0);
871 return !
static_cast<ElementImpl*
>(impl)->
getAttribute(ATTR_MULTIPLE).isNull();
876 if(impl)
static_cast<ElementImpl*
>(impl)->
setAttribute(ATTR_MULTIPLE, _multiple ?
"" : 0);
882 return static_cast<HTMLSelectElementImpl* const
>(impl)->name();
887 if(impl)
static_cast<HTMLSelectElementImpl*
>(impl)->setName(value);
893 return ((HTMLSelectElementImpl *)impl)->getAttribute(ATTR_SIZE).toInt();
900 DOMString value(TQString::number(_size));
901 static_cast<ElementImpl*
>(impl)->
setAttribute(ATTR_SIZE,value);
908 return static_cast<ElementImpl*
>(impl)->tabIndex();
914 static_cast<ElementImpl*
>(impl)->setTabIndex(_tabIndex);
922 int exceptioncode = 0;
923 static_cast<HTMLSelectElementImpl*
>(impl)->add( element, before, exceptioncode );
930 if(impl)
static_cast<HTMLSelectElementImpl*
>(impl)->
remove( index );
936 ((HTMLSelectElementImpl*)impl)->blur();
942 ((HTMLSelectElementImpl*)impl)->focus();
947 HTMLTextAreaElement::HTMLTextAreaElement() :
HTMLElement()
955 HTMLTextAreaElement::HTMLTextAreaElement(HTMLTextAreaElementImpl *impl) :
HTMLElement(impl)
961 assignOther( other, ID_TEXTAREA );
967 HTMLElement::operator = (other);
971 HTMLTextAreaElement::~HTMLTextAreaElement()
978 return ((HTMLTextAreaElementImpl *)impl)->defaultValue();
983 if (impl) ((HTMLTextAreaElementImpl *)impl)->setDefaultValue(value);
994 return static_cast<ElementImpl*
>(impl)->
getAttribute(ATTR_ACCESSKEY);
999 if(impl)
static_cast<ElementImpl*
>(impl)->
setAttribute(ATTR_ACCESSKEY, value);
1005 return ((HTMLTextAreaElementImpl *)impl)->getAttribute(ATTR_COLS).toInt();
1012 DOMString value(TQString::number(_cols));
1013 static_cast<ElementImpl*
>(impl)->
setAttribute(ATTR_COLS,value);
1020 return !
static_cast<ElementImpl*
>(impl)->
getAttribute(ATTR_DISABLED).isNull();
1025 if(impl)
static_cast<ElementImpl*
>(impl)->
setAttribute(ATTR_DISABLED, _disabled ?
"" : 0);
1031 return static_cast<HTMLTextAreaElementImpl* const
>(impl)->name();
1036 if(impl)
static_cast<HTMLTextAreaElementImpl*
>(impl)->setName(value);
1042 return !
static_cast<ElementImpl*
>(impl)->
getAttribute(ATTR_READONLY).isNull();
1047 if(impl)
static_cast<ElementImpl*
>(impl)->
setAttribute(ATTR_READONLY, _readOnly ?
"" : 0);
1053 return ((HTMLTextAreaElementImpl *)impl)->getAttribute(ATTR_ROWS).toInt();
1060 DOMString value(TQString::number(_rows));
1061 static_cast<ElementImpl*
>(impl)->
setAttribute(ATTR_ROWS,value);
1068 return static_cast<ElementImpl*
>(impl)->tabIndex();
1074 static_cast<ElementImpl*
>(impl)->setTabIndex(_tabIndex);
1080 return ((HTMLTextAreaElementImpl *)impl)->type();
1086 return ((HTMLTextAreaElementImpl *)impl)->value();
1091 if(impl) ((HTMLTextAreaElementImpl *)impl)->setValue(value);
1097 ((HTMLTextAreaElementImpl*)impl)->blur();
1103 ((HTMLTextAreaElementImpl*)impl)->focus();
1109 ((HTMLTextAreaElementImpl *)impl)->select( );
1115 return ((HTMLTextAreaElementImpl *)impl)->selectionStart( );
1122 return ((HTMLTextAreaElementImpl *)impl)->selectionEnd( );
1129 return ((HTMLTextAreaElementImpl *)impl)->textLength( );
1136 ((HTMLTextAreaElementImpl *)impl)->setSelectionStart( pos );
1142 ((HTMLTextAreaElementImpl *)impl)->setSelectionEnd( pos );
1148 ((HTMLTextAreaElementImpl *)impl)->setSelectionRange( start, end );
1153 HTMLOptionElement::HTMLOptionElement() :
HTMLElement()
1161 HTMLOptionElement::HTMLOptionElement(HTMLOptionElementImpl *impl) :
HTMLElement(impl)
1167 assignOther( other, ID_OPTION );
1173 HTMLElement::operator = (other);
1177 HTMLOptionElement::~HTMLOptionElement()
1189 return !
static_cast<ElementImpl*
>(impl)->
getAttribute(ATTR_SELECTED).isNull();
1194 if(impl)
static_cast<ElementImpl*
>(impl)->
setAttribute(ATTR_SELECTED, _defaultSelected ?
"" : 0);
1200 return ((HTMLOptionElementImpl *)impl)->text();
1206 return ((HTMLOptionElementImpl *)impl)->index();
1211 throw DOMException(DOMException::NO_MODIFICATION_ALLOWED_ERR);
1217 return !
static_cast<ElementImpl*
>(impl)->
getAttribute(ATTR_DISABLED).isNull();
1222 if(impl)
static_cast<ElementImpl*
>(impl)->
setAttribute(ATTR_DISABLED, _disabled ?
"" : 0);
1228 return static_cast<ElementImpl*
>(impl)->
getAttribute(ATTR_LABEL);
1233 if(impl)
static_cast<ElementImpl*
>(impl)->
setAttribute(ATTR_LABEL, value);
1239 return ((HTMLOptionElementImpl *)impl)->selected();
1244 ((HTMLOptionElementImpl *)impl)->setSelected(_selected);
1250 return static_cast<HTMLOptionElementImpl*
>(impl)->value();
1255 if(impl)
static_cast<HTMLOptionElementImpl*
>(impl)->setValue(value.implementation());
1260 HTMLIsIndexElement::HTMLIsIndexElement() :
HTMLElement()
1268 HTMLIsIndexElement::HTMLIsIndexElement(HTMLIsIndexElementImpl *impl) :
HTMLElement(impl)
1274 assignOther( other, ID_ISINDEX );
1280 HTMLElement::operator = (other);
1284 HTMLIsIndexElement::~HTMLIsIndexElement()
1296 return static_cast<HTMLIsIndexElementImpl*
>(impl)->prompt();
1301 if(impl)
static_cast<HTMLIsIndexElementImpl*
>(impl)->setPrompt(value);
DOMString defaultValue() const
Stores the initial control value (i.e., the initial value of value ).
void remove(long index)
Remove an element from the collection of OPTION elements for this SELECT .
void setReadOnly(bool)
see readOnly
void setSelectionRange(long start, long end)
Selects the text from start to end, and positions the cursor after the selection. ...
void setPrompt(const DOMString &)
see prompt
The Node interface is the primary datatype for the entire Document Object Model.
bool multiple() const
If true, multiple OPTION elements may be selected in this SELECT .
HTMLFormElement form() const
KDE 4.0: remove
The select element allows the selection of an option.
long textLength()
Returns the length of the text.
This element is used for single-line text input.
HTMLFormElement form() const
KDE 4.0: remove.
void setTabIndex(long)
see tabIndex
void setValue(const DOMString &)
see value
HTMLCollection options() const
The collection of OPTION elements contained by this element.
void setAccessKey(const DOMString &)
see accessKey
DOMString value() const
The current form control value.
Element form() const
KHTML extension to DOM This method returns the associated form element.
void focus()
Gives keyboard focus to this element.
long tabIndex() const
Index that represents the element's position in the tabbing order.
void setMultiple(bool)
see multiple
DOMString label() const
Option label for use in hierarchical menus.
void setCols(long)
see cols
long tabIndex() const
Index that represents the element's position in the tabbing order.
DOMString type() const
The type of control created.
DOM operations only raise exceptions in "exceptional" circumstances, i.e., when an operation is impos...
bool readOnly() const
This control is read-only.
void setAttribute(const DOMString &name, const DOMString &value)
Adds a new attribute.
DOMString accessKey() const
A single character access key to give access to the form control.
An HTMLCollection is a list of nodes.
void setAccessKey(const DOMString &)
see accessKey
HTMLFormElement form() const
KDE 4.0: remove
void setDefaultValue(const DOMString &)
see defaultValue
void setRows(long)
see rows
DOMString accessKey() const
A single character access key to give access to the form control.
HTMLFormElement form() const
KDE 4.0: remove
void setTabIndex(long)
see tabIndex
void focus()
Gives keyboard focus to this element.
bool disabled() const
The control is unavailable in this context.
Group options together in logical subdivisions.
Provides a caption for a FIELDSET grouping.
DOMString label() const
Assigns a label to this option group.
void setSelectionEnd(long offset)
Move the end of the selection (and the cursor) to the given offset in text NOTE: this method is not p...
This class implements the basic string we use in the DOM.
DOMString value() const
The current form control value.
long selectionEnd()
Returns the character offset of end of selection, or if none, the cursor position.
DOMString align() const
Text alignment relative to FIELDSET .
DOMString text() const
The text contained within the option element.
void blur()
Removes keyboard focus from this element.
void setDisabled(bool)
see disabled
void setDisabled(bool)
see disabled
long selectedIndex() const
The ordinal index of the selected option.
void setSelectionStart(long offset)
Move the beginning of the selection to the given offset in text NOTE: this method is not part of the ...
HTMLFormElement form() const
KDE 4.0: remove.
DOMString htmlFor() const
This attribute links this label with another form control by id attribute.
void blur()
Removes keyboard focus from this element.
void setName(const DOMString &)
see name
DOMString name() const
Form control or object name when submitted with a form.
The Document Object Model (DOM) is divided into two parts, the COREDOM core DOM, specifying some core...
long length() const
The number of options in this SELECT .
DOMString value() const
The current textual content of the multi-line text field.
void setSize(long)
see size
void setValue(const DOMString &)
see value
DOMString type() const
The type of this form control.
void setLabel(const DOMString &)
see label
void setAccessKey(const DOMString &)
see accessKey
DOMString getAttribute(const DOMString &name)
Retrieves an attribute value by name.
Organizes form controls into logical groups.
void setDisabled(bool)
see disabled
void setLabel(const DOMString &)
see label
bool disabled() const
The control is unavailable in this context.
long size() const
Number of visible rows.
long index() const
The index of this OPTION in its parent SELECT .
bool disabled() const
The control is unavailable in this context.
DOMString accessKey() const
A single character access key to give access to the form control.
void setHtmlFor(const DOMString &)
see htmlFor
void setName(const DOMString &)
see name
void setIndex(long)
see index
void setValue(const DOMString &)
see value
bool defaultSelected() const
Stores the initial value of the selected attribute.
HTMLFormElement form() const
KDE 4.0: remove.
long selectionStart()
Returns the character offset of beginning of selection, or if none, the cursor position.
void setDisabled(bool)
see disabled
void setSelectedIndex(long)
see selectedIndex
long rows() const
Number of text rows.
bool selected() const
Means that this option is initially selected.
void setSelected(bool)
see selected
void setDefaultSelected(bool)
see defaultSelected
long cols() const
Width of control (in characters).
All HTML element interfaces derive from this class.
void select()
Select the contents of the TEXTAREA .
DOMString name() const
Form control or object name when submitted with a form.
DOMString prompt() const
The prompt message.
void setAlign(const DOMString &)
see align
bool disabled() const
The control is unavailable in this context.
void add(const HTMLElement &element, const HTMLElement &before)
Add a new element to the collection of OPTION elements for this SELECT .