File indexing completed on 2024-05-05 12:14:52
0001 /** 0002 * This file is part of the DOM implementation for KDE. 0003 * 0004 * Copyright 1999 Lars Knoll (knoll@kde.org) 0005 * 0006 * This library is free software; you can redistribute it and/or 0007 * modify it under the terms of the GNU Library General Public 0008 * License as published by the Free Software Foundation; either 0009 * version 2 of the License, or (at your option) any later version. 0010 * 0011 * This library is distributed in the hope that it will be useful, 0012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 0013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 0014 * Library General Public License for more details. 0015 * 0016 * You should have received a copy of the GNU Library General Public License 0017 * along with this library; see the file COPYING.LIB. If not, write to 0018 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 0019 * Boston, MA 02110-1301, USA. 0020 * 0021 */ 0022 // -------------------------------------------------------------------------- 0023 0024 #include "dom/html_form.h" 0025 #include "dom/dom_exception.h" 0026 #include "dom/dom_doc.h" 0027 0028 #include "html/html_formimpl.h" 0029 #include "html/html_miscimpl.h" 0030 0031 #include "xml/dom_docimpl.h" 0032 0033 using namespace DOM; 0034 0035 HTMLButtonElement::HTMLButtonElement() : HTMLElement() 0036 { 0037 } 0038 0039 HTMLButtonElement::HTMLButtonElement(const HTMLButtonElement &other) : HTMLElement(other) 0040 { 0041 } 0042 0043 HTMLButtonElement::HTMLButtonElement(HTMLButtonElementImpl *impl) : HTMLElement(impl) 0044 { 0045 } 0046 0047 HTMLButtonElement &HTMLButtonElement::operator = (const Node &other) 0048 { 0049 assignOther(other, ID_BUTTON); 0050 return *this; 0051 } 0052 0053 HTMLButtonElement &HTMLButtonElement::operator = (const HTMLButtonElement &other) 0054 { 0055 HTMLElement::operator = (other); 0056 return *this; 0057 } 0058 0059 HTMLButtonElement::~HTMLButtonElement() 0060 { 0061 } 0062 0063 HTMLFormElement HTMLButtonElement::form() const 0064 { 0065 return Element::form(); 0066 } 0067 0068 DOMString HTMLButtonElement::accessKey() const 0069 { 0070 if (!impl) { 0071 return DOMString(); 0072 } 0073 return static_cast<ElementImpl *>(impl)->getAttribute(ATTR_ACCESSKEY); 0074 } 0075 0076 void HTMLButtonElement::setAccessKey(const DOMString &value) 0077 { 0078 if (impl) { 0079 static_cast<ElementImpl *>(impl)->setAttribute(ATTR_ACCESSKEY, value); 0080 } 0081 } 0082 0083 bool HTMLButtonElement::disabled() const 0084 { 0085 if (!impl) { 0086 return 0; 0087 } 0088 return !static_cast<ElementImpl *>(impl)->getAttribute(ATTR_DISABLED).isNull(); 0089 } 0090 0091 void HTMLButtonElement::setDisabled(bool _disabled) 0092 { 0093 if (impl) { 0094 static_cast<ElementImpl *>(impl)->setAttribute(ATTR_DISABLED, _disabled ? "" : nullptr); 0095 } 0096 } 0097 0098 DOMString HTMLButtonElement::name() const 0099 { 0100 if (!impl) { 0101 return DOMString(); 0102 } 0103 return static_cast<ElementImpl *>(impl)->getAttribute(ATTR_NAME); 0104 } 0105 0106 void HTMLButtonElement::setName(const DOMString &value) 0107 { 0108 if (impl) { 0109 static_cast<ElementImpl *>(impl)->setAttribute(ATTR_NAME, value); 0110 } 0111 } 0112 0113 void HTMLButtonElement::focus() 0114 { 0115 if (impl) { 0116 static_cast<HTMLButtonElementImpl *>(impl)->focus(); 0117 } 0118 } 0119 0120 void HTMLButtonElement::blur() 0121 { 0122 if (impl) { 0123 static_cast<HTMLButtonElementImpl *>(impl)->blur(); 0124 } 0125 } 0126 0127 long HTMLButtonElement::tabIndex() const 0128 { 0129 if (!impl) { 0130 return 0; 0131 } 0132 return static_cast<ElementImpl *>(impl)->tabIndex(); 0133 } 0134 0135 void HTMLButtonElement::setTabIndex(long _tabIndex) 0136 { 0137 if (!impl) { 0138 return; 0139 } 0140 static_cast<ElementImpl *>(impl)->setTabIndex(_tabIndex); 0141 } 0142 0143 DOMString HTMLButtonElement::type() const 0144 { 0145 if (!impl) { 0146 return DOMString(); 0147 } 0148 return static_cast<HTMLButtonElementImpl *>(impl)->type(); 0149 } 0150 0151 DOMString HTMLButtonElement::value() const 0152 { 0153 if (!impl) { 0154 return DOMString(); 0155 } 0156 DOMString s = static_cast<ElementImpl *>(impl)->getAttribute(ATTR_VALUE); 0157 if (s.isNull()) { 0158 return DOMString(""); 0159 } 0160 return s; 0161 } 0162 0163 void HTMLButtonElement::setValue(const DOMString &value) 0164 { 0165 if (impl) { 0166 static_cast<ElementImpl *>(impl)->setAttribute(ATTR_VALUE, value); 0167 } 0168 } 0169 0170 // -------------------------------------------------------------------------- 0171 0172 HTMLFieldSetElement::HTMLFieldSetElement() : HTMLElement() 0173 { 0174 } 0175 0176 HTMLFieldSetElement::HTMLFieldSetElement(const HTMLFieldSetElement &other) : HTMLElement(other) 0177 { 0178 } 0179 0180 HTMLFieldSetElement::HTMLFieldSetElement(HTMLFieldSetElementImpl *impl) : HTMLElement(impl) 0181 { 0182 } 0183 0184 HTMLFieldSetElement &HTMLFieldSetElement::operator = (const Node &other) 0185 { 0186 assignOther(other, ID_FIELDSET); 0187 return *this; 0188 } 0189 0190 HTMLFieldSetElement &HTMLFieldSetElement::operator = (const HTMLFieldSetElement &other) 0191 { 0192 HTMLElement::operator = (other); 0193 return *this; 0194 } 0195 0196 HTMLFieldSetElement::~HTMLFieldSetElement() 0197 { 0198 } 0199 0200 HTMLFormElement HTMLFieldSetElement::form() const 0201 { 0202 return Element::form(); 0203 } 0204 0205 // -------------------------------------------------------------------------- 0206 0207 HTMLFormElement::HTMLFormElement() : HTMLElement() 0208 { 0209 } 0210 0211 HTMLFormElement::HTMLFormElement(const HTMLFormElement &other) : HTMLElement(other) 0212 { 0213 } 0214 0215 HTMLFormElement::HTMLFormElement(HTMLFormElementImpl *impl) : HTMLElement(impl) 0216 { 0217 } 0218 0219 HTMLFormElement &HTMLFormElement::operator = (const Node &other) 0220 { 0221 assignOther(other, ID_FORM); 0222 return *this; 0223 } 0224 0225 HTMLFormElement &HTMLFormElement::operator = (const HTMLFormElement &other) 0226 { 0227 HTMLElement::operator = (other); 0228 return *this; 0229 } 0230 0231 HTMLFormElement::~HTMLFormElement() 0232 { 0233 } 0234 0235 HTMLCollection HTMLFormElement::elements() const 0236 { 0237 if (!impl) { 0238 return HTMLCollection(); 0239 } 0240 return HTMLFormCollection(impl); 0241 } 0242 0243 long HTMLFormElement::length() const 0244 { 0245 if (!impl) { 0246 return 0; 0247 } 0248 return static_cast<HTMLFormElementImpl *>(impl)->length(); 0249 } 0250 0251 DOMString HTMLFormElement::name() const 0252 { 0253 if (!impl) { 0254 return DOMString(); 0255 } 0256 return static_cast<ElementImpl *>(impl)->getAttribute(ATTR_NAME); 0257 } 0258 0259 void HTMLFormElement::setName(const DOMString &value) 0260 { 0261 if (impl) { 0262 static_cast<ElementImpl *>(impl)->setAttribute(ATTR_NAME, value); 0263 } 0264 } 0265 0266 DOMString HTMLFormElement::acceptCharset() const 0267 { 0268 if (!impl) { 0269 return DOMString(); 0270 } 0271 return static_cast<ElementImpl *>(impl)->getAttribute(ATTR_ACCEPT_CHARSET); 0272 } 0273 0274 void HTMLFormElement::setAcceptCharset(const DOMString &value) 0275 { 0276 if (impl) { 0277 static_cast<ElementImpl *>(impl)->setAttribute(ATTR_ACCEPT_CHARSET, value); 0278 } 0279 } 0280 0281 DOMString HTMLFormElement::action() const 0282 { 0283 if (!impl) { 0284 return DOMString(); 0285 } 0286 return static_cast<HTMLFormElementImpl *>(impl)->action(); 0287 } 0288 0289 void HTMLFormElement::setAction(const DOMString &value) 0290 { 0291 if (impl) { 0292 static_cast<ElementImpl *>(impl)->setAttribute(ATTR_ACTION, value); 0293 } 0294 } 0295 0296 DOMString HTMLFormElement::enctype() const 0297 { 0298 if (!impl) { 0299 return DOMString(); 0300 } 0301 return static_cast<ElementImpl *>(impl)->getAttribute(ATTR_ENCTYPE); 0302 } 0303 0304 void HTMLFormElement::setEnctype(const DOMString &value) 0305 { 0306 if (impl) { 0307 static_cast<ElementImpl *>(impl)->setAttribute(ATTR_ENCTYPE, value); 0308 } 0309 } 0310 0311 DOMString HTMLFormElement::method() const 0312 { 0313 if (!impl) { 0314 return DOMString(); 0315 } 0316 return static_cast<ElementImpl *>(impl)->getAttribute(ATTR_METHOD); 0317 } 0318 0319 void HTMLFormElement::setMethod(const DOMString &value) 0320 { 0321 if (impl) { 0322 static_cast<ElementImpl *>(impl)->setAttribute(ATTR_METHOD, value); 0323 } 0324 } 0325 0326 DOMString HTMLFormElement::target() const 0327 { 0328 if (!impl) { 0329 return DOMString(); 0330 } 0331 return static_cast<HTMLFormElementImpl *>(impl)->target(); 0332 } 0333 0334 void HTMLFormElement::setTarget(const DOMString &value) 0335 { 0336 if (impl) { 0337 static_cast<ElementImpl *>(impl)->setAttribute(ATTR_TARGET, value); 0338 } 0339 } 0340 0341 void HTMLFormElement::submit() 0342 { 0343 if (impl) { 0344 static_cast<HTMLFormElementImpl *>(impl)->submit(); 0345 } 0346 } 0347 0348 void HTMLFormElement::reset() 0349 { 0350 if (impl) { 0351 static_cast<HTMLFormElementImpl *>(impl)->reset(); 0352 } 0353 } 0354 0355 // -------------------------------------------------------------------------- 0356 0357 HTMLInputElement::HTMLInputElement() : HTMLElement() 0358 { 0359 } 0360 0361 HTMLInputElement::HTMLInputElement(const HTMLInputElement &other) : HTMLElement(other) 0362 { 0363 } 0364 0365 HTMLInputElement::HTMLInputElement(HTMLInputElementImpl *impl) : HTMLElement(impl) 0366 { 0367 } 0368 0369 HTMLInputElement &HTMLInputElement::operator = (const Node &other) 0370 { 0371 assignOther(other, ID_INPUT); 0372 return *this; 0373 } 0374 0375 HTMLInputElement &HTMLInputElement::operator = (const HTMLInputElement &other) 0376 { 0377 HTMLElement::operator = (other); 0378 return *this; 0379 } 0380 0381 HTMLInputElement::~HTMLInputElement() 0382 { 0383 } 0384 0385 DOMString HTMLInputElement::defaultValue() const 0386 { 0387 if (!impl) { 0388 return DOMString(); 0389 } 0390 DOMString s = static_cast<ElementImpl *>(impl)->getAttribute(ATTR_VALUE); 0391 if (s.isNull()) { 0392 return DOMString(""); 0393 } 0394 return s; 0395 0396 } 0397 0398 void HTMLInputElement::setDefaultValue(const DOMString &value) 0399 { 0400 if (impl) { 0401 ((ElementImpl *)impl)->setAttribute(ATTR_VALUE, value); 0402 } 0403 } 0404 0405 bool HTMLInputElement::defaultChecked() const 0406 { 0407 if (!impl) { 0408 return 0; 0409 } 0410 return !((ElementImpl *)impl)->getAttribute(ATTR_CHECKED).isNull(); 0411 } 0412 0413 void HTMLInputElement::setDefaultChecked(bool _defaultChecked) 0414 { 0415 if (impl) { 0416 ((ElementImpl *)impl)->setAttribute(ATTR_CHECKED, _defaultChecked ? "" : nullptr); 0417 } 0418 } 0419 0420 HTMLFormElement HTMLInputElement::form() const 0421 { 0422 return Element::form(); 0423 } 0424 0425 DOMString HTMLInputElement::accept() const 0426 { 0427 if (!impl) { 0428 return DOMString(); 0429 } 0430 return ((ElementImpl *)impl)->getAttribute(ATTR_ACCEPT); 0431 } 0432 0433 void HTMLInputElement::setAccept(const DOMString &value) 0434 { 0435 if (impl) { 0436 ((ElementImpl *)impl)->setAttribute(ATTR_ACCEPT, value); 0437 } 0438 } 0439 0440 DOMString HTMLInputElement::accessKey() const 0441 { 0442 if (!impl) { 0443 return DOMString(); 0444 } 0445 return ((ElementImpl *)impl)->getAttribute(ATTR_ACCESSKEY); 0446 } 0447 0448 void HTMLInputElement::setAccessKey(const DOMString &value) 0449 { 0450 if (impl) { 0451 ((ElementImpl *)impl)->setAttribute(ATTR_ACCESSKEY, value); 0452 } 0453 } 0454 0455 DOMString HTMLInputElement::align() const 0456 { 0457 if (!impl) { 0458 return DOMString(); 0459 } 0460 return ((ElementImpl *)impl)->getAttribute(ATTR_ALIGN); 0461 } 0462 0463 void HTMLInputElement::setAlign(const DOMString &value) 0464 { 0465 if (impl) { 0466 ((ElementImpl *)impl)->setAttribute(ATTR_ALIGN, value); 0467 } 0468 } 0469 0470 DOMString HTMLInputElement::alt() const 0471 { 0472 if (!impl) { 0473 return DOMString(); 0474 } 0475 return ((ElementImpl *)impl)->getAttribute(ATTR_ALT); 0476 } 0477 0478 void HTMLInputElement::setAlt(const DOMString &value) 0479 { 0480 if (impl) { 0481 ((ElementImpl *)impl)->setAttribute(ATTR_ALT, value); 0482 } 0483 } 0484 0485 bool HTMLInputElement::checked() const 0486 { 0487 if (!impl) { 0488 return 0; 0489 } 0490 return ((HTMLInputElementImpl *)impl)->checked(); 0491 } 0492 0493 void HTMLInputElement::setChecked(bool _checked) 0494 { 0495 if (impl) { 0496 ((HTMLInputElementImpl *)impl)->setChecked(_checked); 0497 } 0498 } 0499 0500 bool HTMLInputElement::indeterminate() const 0501 { 0502 if (!impl) { 0503 return 0; 0504 } 0505 return ((HTMLInputElementImpl *)impl)->indeterminate(); 0506 } 0507 0508 void HTMLInputElement::setIndeterminate(bool _indeterminate) 0509 { 0510 if (impl) { 0511 ((HTMLInputElementImpl *)impl)->setIndeterminate(_indeterminate); 0512 } 0513 } 0514 0515 bool HTMLInputElement::disabled() const 0516 { 0517 if (!impl) { 0518 return 0; 0519 } 0520 return !((ElementImpl *)impl)->getAttribute(ATTR_DISABLED).isNull(); 0521 } 0522 0523 void HTMLInputElement::setDisabled(bool _disabled) 0524 { 0525 if (impl) { 0526 ((ElementImpl *)impl)->setAttribute(ATTR_DISABLED, _disabled ? "" : nullptr); 0527 } 0528 } 0529 0530 long HTMLInputElement::maxLength() const 0531 { 0532 if (!impl) { 0533 return 0; 0534 } 0535 return ((HTMLInputElementImpl *)impl)->getAttribute(ATTR_MAXLENGTH).toInt(); 0536 } 0537 0538 void HTMLInputElement::setMaxLength(long _maxLength) 0539 { 0540 if (impl) { 0541 DOMString value(QString::number(_maxLength)); 0542 ((ElementImpl *)impl)->setAttribute(ATTR_MAXLENGTH, value); 0543 } 0544 } 0545 0546 DOMString HTMLInputElement::name() const 0547 { 0548 if (!impl) { 0549 return DOMString(); 0550 } 0551 return static_cast<HTMLInputElementImpl *const>(impl)->name(); 0552 } 0553 0554 void HTMLInputElement::setName(const DOMString &value) 0555 { 0556 if (impl) { 0557 static_cast<HTMLInputElementImpl *>(impl)->setName(value); 0558 } 0559 } 0560 0561 bool HTMLInputElement::readOnly() const 0562 { 0563 if (!impl) { 0564 return 0; 0565 } 0566 return !static_cast<ElementImpl *>(impl)->getAttribute(ATTR_READONLY).isNull(); 0567 } 0568 0569 void HTMLInputElement::setReadOnly(bool _readOnly) 0570 { 0571 if (impl) { 0572 static_cast<ElementImpl *>(impl)->setAttribute(ATTR_READONLY, _readOnly ? "" : nullptr); 0573 } 0574 } 0575 0576 /* The next two are provided for backwards compatibility. */ 0577 #ifndef KHTML_NO_DEPRECATED 0578 DOMString HTMLInputElement::size() const 0579 { 0580 if (!impl) { 0581 return DOMString(); 0582 } 0583 return static_cast<ElementImpl *>(impl)->getAttribute(ATTR_SIZE); 0584 } 0585 #endif 0586 0587 #ifndef KHTML_NO_DEPRECATED 0588 void HTMLInputElement::setSize(const DOMString &value) 0589 { 0590 if (impl) { 0591 static_cast<ElementImpl *>(impl)->setAttribute(ATTR_SIZE, value); 0592 } 0593 } 0594 #endif 0595 0596 long HTMLInputElement::getSize() const 0597 { 0598 if (!impl) { 0599 return 0; 0600 } 0601 return static_cast<ElementImpl *>(impl)->getAttribute(ATTR_SIZE).toInt(); 0602 } 0603 0604 void HTMLInputElement::setSize(long value) 0605 { 0606 if (impl) { 0607 static_cast<ElementImpl *>(impl)->setAttribute(ATTR_SIZE, QString::number(value)); 0608 } 0609 } 0610 0611 DOMString HTMLInputElement::src() const 0612 { 0613 if (!impl) { 0614 return DOMString(); 0615 } 0616 const DOMString s = static_cast<ElementImpl *>(impl)->getAttribute(ATTR_SRC).trimSpaces(); 0617 return !s.isNull() ? impl->document()->completeURL(s.string()) : s; 0618 } 0619 0620 void HTMLInputElement::setSrc(const DOMString &value) 0621 { 0622 if (impl) { 0623 static_cast<ElementImpl *>(impl)->setAttribute(ATTR_SRC, value); 0624 } 0625 } 0626 0627 long HTMLInputElement::tabIndex() const 0628 { 0629 if (!impl) { 0630 return 0; 0631 } 0632 return static_cast<ElementImpl *>(impl)->tabIndex(); 0633 } 0634 0635 void HTMLInputElement::setTabIndex(long _tabIndex) 0636 { 0637 if (!impl) { 0638 return; 0639 } 0640 static_cast<ElementImpl *>(impl)->setTabIndex(_tabIndex); 0641 } 0642 0643 DOMString HTMLInputElement::type() const 0644 { 0645 if (!impl) { 0646 return DOMString(); 0647 } 0648 return ((HTMLInputElementImpl *)impl)->type(); 0649 } 0650 0651 void HTMLInputElement::setType(const DOMString &_type) 0652 { 0653 if (!impl) { 0654 return; 0655 } 0656 static_cast<HTMLInputElementImpl *>(impl)->setType(_type); 0657 } 0658 0659 DOMString HTMLInputElement::useMap() const 0660 { 0661 if (!impl) { 0662 return DOMString(); 0663 } 0664 return static_cast<ElementImpl *>(impl)->getAttribute(ATTR_USEMAP); 0665 } 0666 0667 void HTMLInputElement::setUseMap(const DOMString &value) 0668 { 0669 if (impl) { 0670 static_cast<ElementImpl *>(impl)->setAttribute(ATTR_USEMAP, value); 0671 } 0672 } 0673 0674 DOMString HTMLInputElement::value() const 0675 { 0676 if (!impl) { 0677 return DOMString(); 0678 } 0679 return ((HTMLInputElementImpl *)impl)->value(); 0680 } 0681 0682 void HTMLInputElement::setValue(const DOMString &value) 0683 { 0684 if (impl) { 0685 ((HTMLInputElementImpl *)impl)->setValue(value); 0686 } 0687 0688 } 0689 0690 void HTMLInputElement::blur() 0691 { 0692 if (impl) { 0693 ((HTMLInputElementImpl *)impl)->blur(); 0694 } 0695 } 0696 0697 void HTMLInputElement::focus() 0698 { 0699 if (impl) { 0700 ((HTMLInputElementImpl *)impl)->focus(); 0701 } 0702 } 0703 0704 void HTMLInputElement::select() 0705 { 0706 if (impl) { 0707 ((HTMLInputElementImpl *)impl)->select(); 0708 } 0709 } 0710 0711 void HTMLInputElement::click() 0712 { 0713 if (impl) { 0714 ((HTMLInputElementImpl *)impl)->click(); 0715 } 0716 } 0717 0718 long HTMLInputElement::selectionStart() 0719 { 0720 if (impl) { 0721 return ((HTMLInputElementImpl *)impl)->selectionStart(); 0722 } 0723 return -1; 0724 } 0725 0726 long HTMLInputElement::selectionEnd() 0727 { 0728 if (impl) { 0729 return ((HTMLInputElementImpl *)impl)->selectionEnd(); 0730 } 0731 return -1; 0732 } 0733 0734 void HTMLInputElement::setSelectionStart(long pos) 0735 { 0736 if (impl) { 0737 ((HTMLInputElementImpl *)impl)->setSelectionStart(pos); 0738 } 0739 } 0740 0741 void HTMLInputElement::setSelectionEnd(long pos) 0742 { 0743 if (impl) { 0744 ((HTMLInputElementImpl *)impl)->setSelectionEnd(pos); 0745 } 0746 } 0747 0748 void HTMLInputElement::setSelectionRange(long start, long end) 0749 { 0750 if (impl) { 0751 ((HTMLInputElementImpl *)impl)->setSelectionRange(start, end); 0752 } 0753 } 0754 0755 // -------------------------------------------------------------------------- 0756 0757 HTMLLabelElement::HTMLLabelElement() : HTMLElement() 0758 { 0759 } 0760 0761 HTMLLabelElement::HTMLLabelElement(const HTMLLabelElement &other) : HTMLElement(other) 0762 { 0763 } 0764 0765 HTMLLabelElement::HTMLLabelElement(HTMLLabelElementImpl *impl) : HTMLElement(impl) 0766 { 0767 } 0768 0769 HTMLLabelElement &HTMLLabelElement::operator = (const Node &other) 0770 { 0771 assignOther(other, ID_LABEL); 0772 return *this; 0773 } 0774 0775 HTMLLabelElement &HTMLLabelElement::operator = (const HTMLLabelElement &other) 0776 { 0777 HTMLElement::operator = (other); 0778 return *this; 0779 } 0780 0781 HTMLLabelElement::~HTMLLabelElement() 0782 { 0783 } 0784 0785 DOMString HTMLLabelElement::accessKey() const 0786 { 0787 if (!impl) { 0788 return DOMString(); 0789 } 0790 return static_cast<ElementImpl *>(impl)->getAttribute(ATTR_ACCESSKEY); 0791 } 0792 0793 void HTMLLabelElement::setAccessKey(const DOMString &value) 0794 { 0795 if (impl) { 0796 static_cast<ElementImpl *>(impl)->setAttribute(ATTR_ACCESSKEY, value); 0797 } 0798 } 0799 0800 DOMString HTMLLabelElement::htmlFor() const 0801 { 0802 if (!impl) { 0803 return DOMString(); 0804 } 0805 return static_cast<ElementImpl *>(impl)->getAttribute(ATTR_FOR); 0806 } 0807 0808 void HTMLLabelElement::setHtmlFor(const DOMString &value) 0809 { 0810 if (impl) { 0811 static_cast<ElementImpl *>(impl)->setAttribute(ATTR_FOR, value); 0812 } 0813 } 0814 0815 // -------------------------------------------------------------------------- 0816 0817 HTMLLegendElement::HTMLLegendElement() : HTMLElement() 0818 { 0819 } 0820 0821 HTMLLegendElement::HTMLLegendElement(const HTMLLegendElement &other) : HTMLElement(other) 0822 { 0823 } 0824 0825 HTMLLegendElement::HTMLLegendElement(HTMLLegendElementImpl *impl) : HTMLElement(impl) 0826 { 0827 } 0828 0829 HTMLLegendElement &HTMLLegendElement::operator = (const Node &other) 0830 { 0831 assignOther(other, ID_LEGEND); 0832 return *this; 0833 } 0834 0835 HTMLLegendElement &HTMLLegendElement::operator = (const HTMLLegendElement &other) 0836 { 0837 HTMLElement::operator = (other); 0838 return *this; 0839 } 0840 0841 HTMLLegendElement::~HTMLLegendElement() 0842 { 0843 } 0844 0845 HTMLFormElement HTMLLegendElement::form() const 0846 { 0847 return Element::form(); 0848 } 0849 0850 DOMString HTMLLegendElement::accessKey() const 0851 { 0852 if (!impl) { 0853 return DOMString(); 0854 } 0855 return static_cast<ElementImpl *>(impl)->getAttribute(ATTR_ACCESSKEY); 0856 } 0857 0858 void HTMLLegendElement::setAccessKey(const DOMString &value) 0859 { 0860 if (impl) { 0861 static_cast<ElementImpl *>(impl)->setAttribute(ATTR_ACCESSKEY, value); 0862 } 0863 } 0864 0865 DOMString HTMLLegendElement::align() const 0866 { 0867 if (!impl) { 0868 return DOMString(); 0869 } 0870 return static_cast<ElementImpl *>(impl)->getAttribute(ATTR_ALIGN); 0871 } 0872 0873 void HTMLLegendElement::setAlign(const DOMString &value) 0874 { 0875 if (impl) { 0876 static_cast<ElementImpl *>(impl)->setAttribute(ATTR_ALIGN, value); 0877 } 0878 } 0879 0880 // -------------------------------------------------------------------------- 0881 0882 HTMLOptGroupElement::HTMLOptGroupElement() : HTMLElement() 0883 { 0884 } 0885 0886 HTMLOptGroupElement::HTMLOptGroupElement(const HTMLOptGroupElement &other) : HTMLElement(other) 0887 { 0888 } 0889 0890 HTMLOptGroupElement::HTMLOptGroupElement(HTMLOptGroupElementImpl *impl) : HTMLElement(impl) 0891 { 0892 } 0893 0894 HTMLOptGroupElement &HTMLOptGroupElement::operator = (const Node &other) 0895 { 0896 assignOther(other, ID_OPTGROUP); 0897 return *this; 0898 } 0899 0900 HTMLOptGroupElement &HTMLOptGroupElement::operator = (const HTMLOptGroupElement &other) 0901 { 0902 HTMLElement::operator = (other); 0903 return *this; 0904 } 0905 0906 HTMLOptGroupElement::~HTMLOptGroupElement() 0907 { 0908 } 0909 0910 bool HTMLOptGroupElement::disabled() const 0911 { 0912 if (!impl) { 0913 return 0; 0914 } 0915 return !static_cast<ElementImpl *>(impl)->getAttribute(ATTR_DISABLED).isNull(); 0916 } 0917 0918 void HTMLOptGroupElement::setDisabled(bool _disabled) 0919 { 0920 if (impl) { 0921 static_cast<ElementImpl *>(impl)->setAttribute(ATTR_DISABLED, _disabled ? "" : nullptr); 0922 } 0923 } 0924 0925 DOMString HTMLOptGroupElement::label() const 0926 { 0927 if (!impl) { 0928 return DOMString(); 0929 } 0930 return static_cast<ElementImpl *>(impl)->getAttribute(ATTR_LABEL); 0931 } 0932 0933 void HTMLOptGroupElement::setLabel(const DOMString &value) 0934 { 0935 if (impl) { 0936 static_cast<ElementImpl *>(impl)->setAttribute(ATTR_LABEL, value); 0937 } 0938 } 0939 0940 // -------------------------------------------------------------------------- 0941 0942 HTMLSelectElement::HTMLSelectElement() : HTMLElement() 0943 { 0944 } 0945 0946 HTMLSelectElement::HTMLSelectElement(const HTMLSelectElement &other) : HTMLElement(other) 0947 { 0948 } 0949 0950 HTMLSelectElement::HTMLSelectElement(HTMLSelectElementImpl *impl) : HTMLElement(impl) 0951 { 0952 } 0953 0954 HTMLSelectElement &HTMLSelectElement::operator = (const Node &other) 0955 { 0956 assignOther(other, ID_SELECT); 0957 return *this; 0958 } 0959 0960 HTMLSelectElement &HTMLSelectElement::operator = (const HTMLSelectElement &other) 0961 { 0962 HTMLElement::operator = (other); 0963 return *this; 0964 } 0965 0966 HTMLSelectElement::~HTMLSelectElement() 0967 { 0968 } 0969 0970 DOMString HTMLSelectElement::type() const 0971 { 0972 if (!impl) { 0973 return DOMString(); 0974 } 0975 return ((HTMLSelectElementImpl *)impl)->type(); 0976 } 0977 0978 long HTMLSelectElement::selectedIndex() const 0979 { 0980 if (!impl) { 0981 return 0; 0982 } 0983 return ((HTMLSelectElementImpl *)impl)->selectedIndex(); 0984 } 0985 0986 void HTMLSelectElement::setSelectedIndex(long _selectedIndex) 0987 { 0988 if (impl) { 0989 ((HTMLSelectElementImpl *)impl)->setSelectedIndex(_selectedIndex); 0990 } 0991 } 0992 0993 DOMString HTMLSelectElement::value() const 0994 { 0995 if (!impl) { 0996 return DOMString(); 0997 } 0998 return static_cast<HTMLSelectElementImpl *>(impl)->value(); 0999 } 1000 1001 void HTMLSelectElement::setValue(const DOMString &value) 1002 { 1003 if (!impl || value.isNull()) { 1004 return; 1005 } 1006 static_cast<HTMLSelectElementImpl *>(impl)->setValue(value.implementation()); 1007 } 1008 1009 long HTMLSelectElement::length() const 1010 { 1011 if (!impl) { 1012 return 0; 1013 } 1014 return ((HTMLSelectElementImpl *)impl)->length(); 1015 } 1016 1017 HTMLFormElement HTMLSelectElement::form() const 1018 { 1019 return Element::form(); 1020 } 1021 1022 HTMLCollection HTMLSelectElement::options() const 1023 { 1024 if (!impl) { 1025 return HTMLCollection(); 1026 } 1027 return HTMLCollection(((HTMLSelectElementImpl *)impl)->options()); 1028 } 1029 1030 bool HTMLSelectElement::disabled() const 1031 { 1032 if (!impl) { 1033 return 0; 1034 } 1035 return !static_cast<ElementImpl *>(impl)->getAttribute(ATTR_DISABLED).isNull(); 1036 } 1037 1038 void HTMLSelectElement::setDisabled(bool _disabled) 1039 { 1040 if (impl) { 1041 static_cast<ElementImpl *>(impl)->setAttribute(ATTR_DISABLED, _disabled ? "" : nullptr); 1042 } 1043 } 1044 1045 bool HTMLSelectElement::multiple() const 1046 { 1047 if (!impl) { 1048 return 0; 1049 } 1050 return !static_cast<ElementImpl *>(impl)->getAttribute(ATTR_MULTIPLE).isNull(); 1051 } 1052 1053 void HTMLSelectElement::setMultiple(bool _multiple) 1054 { 1055 if (impl) { 1056 static_cast<ElementImpl *>(impl)->setAttribute(ATTR_MULTIPLE, _multiple ? "" : nullptr); 1057 } 1058 } 1059 1060 DOMString HTMLSelectElement::name() const 1061 { 1062 if (!impl) { 1063 return DOMString(); 1064 } 1065 return static_cast<HTMLSelectElementImpl *const>(impl)->name(); 1066 } 1067 1068 void HTMLSelectElement::setName(const DOMString &value) 1069 { 1070 if (impl) { 1071 static_cast<HTMLSelectElementImpl *>(impl)->setName(value); 1072 } 1073 } 1074 1075 long HTMLSelectElement::size() const 1076 { 1077 if (!impl) { 1078 return 0; 1079 } 1080 return ((HTMLSelectElementImpl *)impl)->getAttribute(ATTR_SIZE).toInt(); 1081 } 1082 1083 void HTMLSelectElement::setSize(long _size) 1084 { 1085 1086 if (impl) { 1087 DOMString value(QString::number(_size)); 1088 static_cast<ElementImpl *>(impl)->setAttribute(ATTR_SIZE, value); 1089 } 1090 } 1091 1092 long HTMLSelectElement::tabIndex() const 1093 { 1094 if (!impl) { 1095 return 0; 1096 } 1097 return static_cast<ElementImpl *>(impl)->tabIndex(); 1098 } 1099 1100 void HTMLSelectElement::setTabIndex(long _tabIndex) 1101 { 1102 if (!impl) { 1103 return; 1104 } 1105 static_cast<ElementImpl *>(impl)->setTabIndex(_tabIndex); 1106 } 1107 1108 void HTMLSelectElement::add(const HTMLElement &element, const HTMLElement &before) 1109 { 1110 if (!impl) { 1111 throw DOMException(DOMException::NOT_FOUND_ERR); 1112 } 1113 1114 int exceptioncode = 0; 1115 static_cast<HTMLSelectElementImpl *>(impl)->add( 1116 static_cast<HTMLElementImpl *>(element.handle()), 1117 static_cast<HTMLElementImpl *>(before.handle()), exceptioncode); 1118 if (exceptioncode) { 1119 throw DOMException(exceptioncode); 1120 } 1121 } 1122 1123 void HTMLSelectElement::remove(long index) 1124 { 1125 if (impl) { 1126 static_cast<HTMLSelectElementImpl *>(impl)->remove(index); 1127 } 1128 } 1129 1130 void HTMLSelectElement::blur() 1131 { 1132 if (impl) { 1133 ((HTMLSelectElementImpl *)impl)->blur(); 1134 } 1135 } 1136 1137 void HTMLSelectElement::focus() 1138 { 1139 if (impl) { 1140 ((HTMLSelectElementImpl *)impl)->focus(); 1141 } 1142 } 1143 1144 // -------------------------------------------------------------------------- 1145 1146 HTMLTextAreaElement::HTMLTextAreaElement() : HTMLElement() 1147 { 1148 } 1149 1150 HTMLTextAreaElement::HTMLTextAreaElement(const HTMLTextAreaElement &other) : HTMLElement(other) 1151 { 1152 } 1153 1154 HTMLTextAreaElement::HTMLTextAreaElement(HTMLTextAreaElementImpl *impl) : HTMLElement(impl) 1155 { 1156 } 1157 1158 HTMLTextAreaElement &HTMLTextAreaElement::operator = (const Node &other) 1159 { 1160 assignOther(other, ID_TEXTAREA); 1161 return *this; 1162 } 1163 1164 HTMLTextAreaElement &HTMLTextAreaElement::operator = (const HTMLTextAreaElement &other) 1165 { 1166 HTMLElement::operator = (other); 1167 return *this; 1168 } 1169 1170 HTMLTextAreaElement::~HTMLTextAreaElement() 1171 { 1172 } 1173 1174 DOMString HTMLTextAreaElement::defaultValue() const 1175 { 1176 if (!impl) { 1177 return DOMString(); 1178 } 1179 return ((HTMLTextAreaElementImpl *)impl)->defaultValue(); 1180 } 1181 1182 void HTMLTextAreaElement::setDefaultValue(const DOMString &value) 1183 { 1184 if (impl) { 1185 ((HTMLTextAreaElementImpl *)impl)->setDefaultValue(value); 1186 } 1187 } 1188 1189 HTMLFormElement HTMLTextAreaElement::form() const 1190 { 1191 return Element::form(); 1192 } 1193 1194 DOMString HTMLTextAreaElement::accessKey() const 1195 { 1196 if (!impl) { 1197 return DOMString(); 1198 } 1199 return static_cast<ElementImpl *>(impl)->getAttribute(ATTR_ACCESSKEY); 1200 } 1201 1202 void HTMLTextAreaElement::setAccessKey(const DOMString &value) 1203 { 1204 if (impl) { 1205 static_cast<ElementImpl *>(impl)->setAttribute(ATTR_ACCESSKEY, value); 1206 } 1207 } 1208 1209 long HTMLTextAreaElement::cols() const 1210 { 1211 if (!impl) { 1212 return 0; 1213 } 1214 return ((HTMLTextAreaElementImpl *)impl)->getAttribute(ATTR_COLS).toInt(); 1215 } 1216 1217 void HTMLTextAreaElement::setCols(long _cols) 1218 { 1219 1220 if (impl) { 1221 DOMString value(QString::number(_cols)); 1222 static_cast<ElementImpl *>(impl)->setAttribute(ATTR_COLS, value); 1223 } 1224 } 1225 1226 bool HTMLTextAreaElement::disabled() const 1227 { 1228 if (!impl) { 1229 return 0; 1230 } 1231 return !static_cast<ElementImpl *>(impl)->getAttribute(ATTR_DISABLED).isNull(); 1232 } 1233 1234 void HTMLTextAreaElement::setDisabled(bool _disabled) 1235 { 1236 if (impl) { 1237 static_cast<ElementImpl *>(impl)->setAttribute(ATTR_DISABLED, _disabled ? "" : nullptr); 1238 } 1239 } 1240 1241 DOMString HTMLTextAreaElement::name() const 1242 { 1243 if (!impl) { 1244 return DOMString(); 1245 } 1246 return static_cast<HTMLTextAreaElementImpl *const>(impl)->name(); 1247 } 1248 1249 void HTMLTextAreaElement::setName(const DOMString &value) 1250 { 1251 if (impl) { 1252 static_cast<HTMLTextAreaElementImpl *>(impl)->setName(value); 1253 } 1254 } 1255 1256 bool HTMLTextAreaElement::readOnly() const 1257 { 1258 if (!impl) { 1259 return 0; 1260 } 1261 return !static_cast<ElementImpl *>(impl)->getAttribute(ATTR_READONLY).isNull(); 1262 } 1263 1264 void HTMLTextAreaElement::setReadOnly(bool _readOnly) 1265 { 1266 if (impl) { 1267 static_cast<ElementImpl *>(impl)->setAttribute(ATTR_READONLY, _readOnly ? "" : nullptr); 1268 } 1269 } 1270 1271 long HTMLTextAreaElement::rows() const 1272 { 1273 if (!impl) { 1274 return 0; 1275 } 1276 return ((HTMLTextAreaElementImpl *)impl)->getAttribute(ATTR_ROWS).toInt(); 1277 } 1278 1279 void HTMLTextAreaElement::setRows(long _rows) 1280 { 1281 1282 if (impl) { 1283 DOMString value(QString::number(_rows)); 1284 static_cast<ElementImpl *>(impl)->setAttribute(ATTR_ROWS, value); 1285 } 1286 } 1287 1288 long HTMLTextAreaElement::tabIndex() const 1289 { 1290 if (!impl) { 1291 return 0; 1292 } 1293 return static_cast<ElementImpl *>(impl)->tabIndex(); 1294 } 1295 1296 void HTMLTextAreaElement::setTabIndex(long _tabIndex) 1297 { 1298 if (!impl) { 1299 return; 1300 } 1301 static_cast<ElementImpl *>(impl)->setTabIndex(_tabIndex); 1302 } 1303 1304 DOMString HTMLTextAreaElement::type() const 1305 { 1306 if (!impl) { 1307 return DOMString(); 1308 } 1309 return ((HTMLTextAreaElementImpl *)impl)->type(); 1310 } 1311 1312 DOMString HTMLTextAreaElement::value() const 1313 { 1314 if (!impl) { 1315 return DOMString(); 1316 } 1317 return ((HTMLTextAreaElementImpl *)impl)->value(); 1318 } 1319 1320 void HTMLTextAreaElement::setValue(const DOMString &value) 1321 { 1322 if (impl) { 1323 ((HTMLTextAreaElementImpl *)impl)->setValue(value); 1324 } 1325 } 1326 1327 void HTMLTextAreaElement::blur() 1328 { 1329 if (impl) { 1330 ((HTMLTextAreaElementImpl *)impl)->blur(); 1331 } 1332 } 1333 1334 void HTMLTextAreaElement::focus() 1335 { 1336 if (impl) { 1337 ((HTMLTextAreaElementImpl *)impl)->focus(); 1338 } 1339 } 1340 1341 void HTMLTextAreaElement::select() 1342 { 1343 if (impl) { 1344 ((HTMLTextAreaElementImpl *)impl)->select(); 1345 } 1346 } 1347 1348 long HTMLTextAreaElement::selectionStart() 1349 { 1350 if (impl) { 1351 return ((HTMLTextAreaElementImpl *)impl)->selectionStart(); 1352 } 1353 return 0; 1354 } 1355 1356 long HTMLTextAreaElement::selectionEnd() 1357 { 1358 if (impl) { 1359 return ((HTMLTextAreaElementImpl *)impl)->selectionEnd(); 1360 } 1361 return 0; 1362 } 1363 1364 long HTMLTextAreaElement::textLength() 1365 { 1366 if (impl) { 1367 return ((HTMLTextAreaElementImpl *)impl)->textLength(); 1368 } 1369 return 0; 1370 } 1371 1372 void HTMLTextAreaElement::setSelectionStart(long pos) 1373 { 1374 if (impl) { 1375 ((HTMLTextAreaElementImpl *)impl)->setSelectionStart(pos); 1376 } 1377 } 1378 1379 void HTMLTextAreaElement::setSelectionEnd(long pos) 1380 { 1381 if (impl) { 1382 ((HTMLTextAreaElementImpl *)impl)->setSelectionEnd(pos); 1383 } 1384 } 1385 1386 void HTMLTextAreaElement::setSelectionRange(long start, long end) 1387 { 1388 if (impl) { 1389 ((HTMLTextAreaElementImpl *)impl)->setSelectionRange(start, end); 1390 } 1391 } 1392 1393 // -------------------------------------------------------------------------- 1394 1395 HTMLOptionElement::HTMLOptionElement() : HTMLElement() 1396 { 1397 } 1398 1399 HTMLOptionElement::HTMLOptionElement(const HTMLOptionElement &other) : HTMLElement(other) 1400 { 1401 } 1402 1403 HTMLOptionElement::HTMLOptionElement(HTMLOptionElementImpl *impl) : HTMLElement(impl) 1404 { 1405 } 1406 1407 HTMLOptionElement &HTMLOptionElement::operator = (const Node &other) 1408 { 1409 assignOther(other, ID_OPTION); 1410 return *this; 1411 } 1412 1413 HTMLOptionElement &HTMLOptionElement::operator = (const HTMLOptionElement &other) 1414 { 1415 HTMLElement::operator = (other); 1416 return *this; 1417 } 1418 1419 HTMLOptionElement::~HTMLOptionElement() 1420 { 1421 } 1422 1423 HTMLFormElement HTMLOptionElement::form() const 1424 { 1425 return Element::form(); 1426 } 1427 1428 bool HTMLOptionElement::defaultSelected() const 1429 { 1430 if (!impl) { 1431 return 0; 1432 } 1433 return !static_cast<ElementImpl *>(impl)->getAttribute(ATTR_SELECTED).isNull(); 1434 } 1435 1436 void HTMLOptionElement::setDefaultSelected(bool _defaultSelected) 1437 { 1438 if (impl) { 1439 static_cast<HTMLOptionElementImpl *>(impl)->setDefaultSelected(_defaultSelected); 1440 } 1441 } 1442 1443 DOMString HTMLOptionElement::text() const 1444 { 1445 if (!impl) { 1446 return DOMString(); 1447 } 1448 return ((HTMLOptionElementImpl *)impl)->text(); 1449 } 1450 1451 long HTMLOptionElement::index() const 1452 { 1453 if (!impl) { 1454 return 0; 1455 } 1456 return ((HTMLOptionElementImpl *)impl)->index(); 1457 } 1458 1459 void HTMLOptionElement::setIndex(long /*_index*/) 1460 { 1461 throw DOMException(DOMException::NO_MODIFICATION_ALLOWED_ERR); 1462 } 1463 1464 bool HTMLOptionElement::disabled() const 1465 { 1466 if (!impl) { 1467 return 0; 1468 } 1469 return !static_cast<ElementImpl *>(impl)->getAttribute(ATTR_DISABLED).isNull(); 1470 } 1471 1472 void HTMLOptionElement::setDisabled(bool _disabled) 1473 { 1474 if (impl) { 1475 static_cast<ElementImpl *>(impl)->setAttribute(ATTR_DISABLED, _disabled ? "" : nullptr); 1476 } 1477 } 1478 1479 DOMString HTMLOptionElement::label() const 1480 { 1481 if (!impl) { 1482 return DOMString(); 1483 } 1484 return static_cast<ElementImpl *>(impl)->getAttribute(ATTR_LABEL); 1485 } 1486 1487 void HTMLOptionElement::setLabel(const DOMString &value) 1488 { 1489 if (impl) { 1490 static_cast<ElementImpl *>(impl)->setAttribute(ATTR_LABEL, value); 1491 } 1492 } 1493 1494 bool HTMLOptionElement::selected() const 1495 { 1496 if (!impl) { 1497 return 0; 1498 } 1499 return ((HTMLOptionElementImpl *)impl)->selected(); 1500 } 1501 1502 void HTMLOptionElement::setSelected(bool _selected) 1503 { 1504 if (!impl) { 1505 return; 1506 } 1507 ((HTMLOptionElementImpl *)impl)->setSelected(_selected); 1508 } 1509 1510 DOMString HTMLOptionElement::value() const 1511 { 1512 if (!impl) { 1513 return DOMString(); 1514 } 1515 return static_cast<HTMLOptionElementImpl *>(impl)->value(); 1516 } 1517 1518 void HTMLOptionElement::setValue(const DOMString &value) 1519 { 1520 if (impl) { 1521 static_cast<HTMLOptionElementImpl *>(impl)->setValue(value.implementation()); 1522 } 1523 } 1524 1525 // ----------------------------------------------------------------------------- 1526 1527 HTMLIsIndexElement::HTMLIsIndexElement() : HTMLElement() 1528 { 1529 } 1530 1531 HTMLIsIndexElement::HTMLIsIndexElement(const HTMLIsIndexElement &other) : HTMLElement(other) 1532 { 1533 } 1534 1535 HTMLIsIndexElement::HTMLIsIndexElement(HTMLIsIndexElementImpl *impl) : HTMLElement(impl) 1536 { 1537 } 1538 1539 HTMLIsIndexElement &HTMLIsIndexElement::operator = (const Node &other) 1540 { 1541 assignOther(other, ID_ISINDEX); 1542 return *this; 1543 } 1544 1545 HTMLIsIndexElement &HTMLIsIndexElement::operator = (const HTMLIsIndexElement &other) 1546 { 1547 HTMLElement::operator = (other); 1548 return *this; 1549 } 1550 1551 HTMLIsIndexElement::~HTMLIsIndexElement() 1552 { 1553 } 1554 1555 HTMLFormElement HTMLIsIndexElement::form() const 1556 { 1557 return Element::form(); 1558 } 1559 1560 DOMString HTMLIsIndexElement::prompt() const 1561 { 1562 if (!impl) { 1563 return DOMString(); 1564 } 1565 return static_cast<HTMLIsIndexElementImpl *>(impl)->prompt(); 1566 } 1567 1568 void HTMLIsIndexElement::setPrompt(const DOMString &value) 1569 { 1570 if (impl) { 1571 static_cast<HTMLIsIndexElementImpl *>(impl)->setPrompt(value); 1572 } 1573 }