File indexing completed on 2024-04-28 15:23:02

0001 /**
0002  * This file is part of the DOM implementation for KDE.
0003  *
0004  * Copyright 1999 Lars Knoll (knoll@kde.org)
0005  * Copyright 2001 Dirk mueller (mueller@kde.org)
0006  *
0007  * This library is free software; you can redistribute it and/or
0008  * modify it under the terms of the GNU Library General Public
0009  * License as published by the Free Software Foundation; either
0010  * version 2 of the License, or (at your option) any later version.
0011  *
0012  * This library is distributed in the hope that it will be useful,
0013  * but WITHOUT ANY WARRANTY; without even the implied warranty of
0014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0015  * Library General Public License for more details.
0016  *
0017  * You should have received a copy of the GNU Library General Public License
0018  * along with this library; see the file COPYING.LIB.  If not, write to
0019  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
0020  * Boston, MA 02110-1301, USA.
0021  *
0022  */
0023 // --------------------------------------------------------------------------
0024 
0025 #include "html_inline.h"
0026 #include "dom_doc.h"
0027 
0028 #include <html/html_inlineimpl.h>
0029 #include <html/html_baseimpl.h>
0030 #include <xml/dom_docimpl.h>
0031 
0032 using namespace DOM;
0033 
0034 HTMLAnchorElement::HTMLAnchorElement() : HTMLElement()
0035 {
0036 }
0037 
0038 HTMLAnchorElement::HTMLAnchorElement(const HTMLAnchorElement &other) : HTMLElement(other)
0039 {
0040 }
0041 
0042 HTMLAnchorElement::HTMLAnchorElement(HTMLAnchorElementImpl *impl) : HTMLElement(impl)
0043 {
0044 }
0045 
0046 HTMLAnchorElement &HTMLAnchorElement::operator = (const Node &other)
0047 {
0048     assignOther(other, ID_A);
0049     return *this;
0050 }
0051 
0052 HTMLAnchorElement &HTMLAnchorElement::operator = (const HTMLAnchorElement &other)
0053 {
0054     HTMLElement::operator = (other);
0055     return *this;
0056 }
0057 
0058 HTMLAnchorElement::~HTMLAnchorElement()
0059 {
0060 }
0061 
0062 DOMString HTMLAnchorElement::accessKey() const
0063 {
0064     if (!impl) {
0065         return DOMString();
0066     }
0067     return ((ElementImpl *)impl)->getAttribute(ATTR_ACCESSKEY);
0068 }
0069 
0070 void HTMLAnchorElement::setAccessKey(const DOMString &value)
0071 {
0072     if (impl) {
0073         ((ElementImpl *)impl)->setAttribute(ATTR_ACCESSKEY, value);
0074     }
0075 }
0076 
0077 DOMString HTMLAnchorElement::charset() const
0078 {
0079     if (!impl) {
0080         return DOMString();
0081     }
0082     return ((ElementImpl *)impl)->getAttribute(ATTR_CHARSET);
0083 }
0084 
0085 void HTMLAnchorElement::setCharset(const DOMString &value)
0086 {
0087     if (impl) {
0088         ((ElementImpl *)impl)->setAttribute(ATTR_CHARSET, value);
0089     }
0090 }
0091 
0092 DOMString HTMLAnchorElement::coords() const
0093 {
0094     if (!impl) {
0095         return DOMString();
0096     }
0097     return ((ElementImpl *)impl)->getAttribute(ATTR_COORDS);
0098 }
0099 
0100 void HTMLAnchorElement::setCoords(const DOMString &value)
0101 {
0102     if (impl) {
0103         ((ElementImpl *)impl)->setAttribute(ATTR_COORDS, value);
0104     }
0105 }
0106 
0107 DOMString HTMLAnchorElement::href() const
0108 {
0109     if (!impl) {
0110         return DOMString();
0111     }
0112     const DOMString href = static_cast<ElementImpl *>(impl)->getAttribute(ATTR_HREF).trimSpaces();
0113     return !href.isNull() ? impl->document()->completeURL(href.string()) : href;
0114 }
0115 
0116 void HTMLAnchorElement::setHref(const DOMString &value)
0117 {
0118     if (impl) {
0119         ((ElementImpl *)impl)->setAttribute(ATTR_HREF, value);
0120     }
0121 }
0122 
0123 DOMString HTMLAnchorElement::hreflang() const
0124 {
0125     if (!impl) {
0126         return DOMString();
0127     }
0128     return ((ElementImpl *)impl)->getAttribute(ATTR_HREFLANG);
0129 }
0130 
0131 void HTMLAnchorElement::setHreflang(const DOMString &value)
0132 {
0133     if (impl) {
0134         ((ElementImpl *)impl)->setAttribute(ATTR_HREFLANG, value);
0135     }
0136 }
0137 
0138 DOMString HTMLAnchorElement::name() const
0139 {
0140     if (!impl) {
0141         return DOMString();
0142     }
0143     return ((ElementImpl *)impl)->getAttribute(ATTR_NAME);
0144 }
0145 
0146 void HTMLAnchorElement::setName(const DOMString &value)
0147 {
0148     if (impl) {
0149         ((ElementImpl *)impl)->setAttribute(ATTR_NAME, value);
0150     }
0151 }
0152 
0153 DOMString HTMLAnchorElement::rel() const
0154 {
0155     if (!impl) {
0156         return DOMString();
0157     }
0158     return ((ElementImpl *)impl)->getAttribute(ATTR_REL);
0159 }
0160 
0161 void HTMLAnchorElement::setRel(const DOMString &value)
0162 {
0163     if (impl) {
0164         ((ElementImpl *)impl)->setAttribute(ATTR_REL, value);
0165     }
0166 }
0167 
0168 DOMString HTMLAnchorElement::rev() const
0169 {
0170     if (!impl) {
0171         return DOMString();
0172     }
0173     return ((ElementImpl *)impl)->getAttribute(ATTR_REV);
0174 }
0175 
0176 void HTMLAnchorElement::setRev(const DOMString &value)
0177 {
0178     if (impl) {
0179         ((ElementImpl *)impl)->setAttribute(ATTR_REV, value);
0180     }
0181 }
0182 
0183 DOMString HTMLAnchorElement::shape() const
0184 {
0185     if (!impl) {
0186         return DOMString();
0187     }
0188     return ((ElementImpl *)impl)->getAttribute(ATTR_SHAPE);
0189 }
0190 
0191 void HTMLAnchorElement::setShape(const DOMString &value)
0192 {
0193     if (impl) {
0194         ((ElementImpl *)impl)->setAttribute(ATTR_SHAPE, value);
0195     }
0196 }
0197 
0198 long HTMLAnchorElement::tabIndex() const
0199 {
0200     if (!impl) {
0201         return 0;
0202     }
0203     return ((ElementImpl *)impl)->getAttribute(ATTR_TABINDEX).toInt();
0204 }
0205 
0206 void HTMLAnchorElement::setTabIndex(long _tabIndex)
0207 {
0208     if (impl) {
0209         DOMString value(QString::number(_tabIndex));
0210         ((ElementImpl *)impl)->setAttribute(ATTR_TABINDEX, value);
0211     }
0212 }
0213 
0214 DOMString HTMLAnchorElement::target() const
0215 {
0216     if (!impl) {
0217         return DOMString();
0218     }
0219     return ((ElementImpl *)impl)->getAttribute(ATTR_TARGET);
0220 }
0221 
0222 void HTMLAnchorElement::setTarget(const DOMString &value)
0223 {
0224     if (impl) {
0225         ((ElementImpl *)impl)->setAttribute(ATTR_TARGET, value);
0226     }
0227 }
0228 
0229 DOMString HTMLAnchorElement::type() const
0230 {
0231     if (!impl) {
0232         return DOMString();
0233     }
0234     return ((ElementImpl *)impl)->getAttribute(ATTR_TYPE);
0235 }
0236 
0237 void HTMLAnchorElement::setType(const DOMString &value)
0238 {
0239     if (impl) {
0240         ((ElementImpl *)impl)->setAttribute(ATTR_TYPE, value);
0241     }
0242 }
0243 
0244 void HTMLAnchorElement::blur()
0245 {
0246     if (impl) {
0247         ((HTMLAnchorElementImpl *)impl)->blur();
0248     }
0249 }
0250 
0251 void HTMLAnchorElement::focus()
0252 {
0253     if (impl) {
0254         ((HTMLAnchorElementImpl *)impl)->focus();
0255     }
0256 }
0257 
0258 // --------------------------------------------------------------------------
0259 
0260 HTMLBRElement::HTMLBRElement() : HTMLElement()
0261 {
0262 }
0263 
0264 HTMLBRElement::HTMLBRElement(const HTMLBRElement &other) : HTMLElement(other)
0265 {
0266 }
0267 
0268 HTMLBRElement::HTMLBRElement(HTMLBRElementImpl *impl) : HTMLElement(impl)
0269 {
0270 }
0271 
0272 HTMLBRElement &HTMLBRElement::operator = (const Node &other)
0273 {
0274     assignOther(other, ID_BR);
0275     return *this;
0276 }
0277 
0278 HTMLBRElement &HTMLBRElement::operator = (const HTMLBRElement &other)
0279 {
0280     HTMLElement::operator = (other);
0281     return *this;
0282 }
0283 
0284 HTMLBRElement::~HTMLBRElement()
0285 {
0286 }
0287 
0288 DOMString HTMLBRElement::clear() const
0289 {
0290     if (!impl) {
0291         return DOMString();
0292     }
0293     return ((ElementImpl *)impl)->getAttribute(ATTR_CLEAR);
0294 }
0295 
0296 void HTMLBRElement::setClear(const DOMString &value)
0297 {
0298     if (impl) {
0299         ((ElementImpl *)impl)->setAttribute(ATTR_CLEAR, value);
0300     }
0301 }
0302 
0303 // --------------------------------------------------------------------------
0304 
0305 HTMLFontElement::HTMLFontElement() : HTMLElement()
0306 {
0307 }
0308 
0309 HTMLFontElement::HTMLFontElement(const HTMLFontElement &other) : HTMLElement(other)
0310 {
0311 }
0312 
0313 HTMLFontElement::HTMLFontElement(HTMLFontElementImpl *impl) : HTMLElement(impl)
0314 {
0315 }
0316 
0317 HTMLFontElement &HTMLFontElement::operator = (const Node &other)
0318 {
0319     assignOther(other, ID_FONT);
0320     return *this;
0321 }
0322 
0323 HTMLFontElement &HTMLFontElement::operator = (const HTMLFontElement &other)
0324 {
0325     HTMLElement::operator = (other);
0326     return *this;
0327 }
0328 
0329 HTMLFontElement::~HTMLFontElement()
0330 {
0331 }
0332 
0333 DOMString HTMLFontElement::color() const
0334 {
0335     if (!impl) {
0336         return DOMString();
0337     }
0338     return ((ElementImpl *)impl)->getAttribute(ATTR_COLOR);
0339 }
0340 
0341 void HTMLFontElement::setColor(const DOMString &value)
0342 {
0343     if (impl) {
0344         ((ElementImpl *)impl)->setAttribute(ATTR_COLOR, value);
0345     }
0346 }
0347 
0348 DOMString HTMLFontElement::face() const
0349 {
0350     if (!impl) {
0351         return DOMString();
0352     }
0353     return ((ElementImpl *)impl)->getAttribute(ATTR_FACE);
0354 }
0355 
0356 void HTMLFontElement::setFace(const DOMString &value)
0357 {
0358     if (impl) {
0359         ((ElementImpl *)impl)->setAttribute(ATTR_FACE, value);
0360     }
0361 }
0362 
0363 DOMString HTMLFontElement::size() const
0364 {
0365     if (!impl) {
0366         return DOMString();
0367     }
0368     return ((ElementImpl *)impl)->getAttribute(ATTR_SIZE);
0369 }
0370 
0371 void HTMLFontElement::setSize(const DOMString &value)
0372 {
0373     if (impl) {
0374         ((ElementImpl *)impl)->setAttribute(ATTR_SIZE, value);
0375     }
0376 }
0377 
0378 // --------------------------------------------------------------------------
0379 
0380 HTMLModElement::HTMLModElement() : HTMLElement()
0381 {
0382 }
0383 
0384 HTMLModElement::HTMLModElement(const HTMLModElement &other) : HTMLElement(other)
0385 {
0386 }
0387 
0388 HTMLModElement::HTMLModElement(HTMLElementImpl *_impl)
0389     : HTMLElement()
0390 {
0391     if (_impl && (_impl->id() == ID_INS || _impl->id() == ID_DEL)) {
0392         impl = _impl;
0393     } else {
0394         impl = nullptr;
0395     }
0396     if (impl) {
0397         impl->ref();
0398     }
0399 }
0400 
0401 HTMLModElement &HTMLModElement::operator = (const Node &other)
0402 {
0403     if (other.handle() != handle()) {
0404         if (other.elementId() != ID_INS &&
0405                 other.elementId() != ID_DEL) {
0406             if (impl) {
0407                 impl->deref();
0408             }
0409             impl = nullptr;
0410         } else {
0411             Node::operator = (other);
0412         }
0413     }
0414     return *this;
0415 }
0416 
0417 HTMLModElement &HTMLModElement::operator = (const HTMLModElement &other)
0418 {
0419     HTMLElement::operator = (other);
0420     return *this;
0421 }
0422 
0423 HTMLModElement::~HTMLModElement()
0424 {
0425 }
0426 
0427 DOMString HTMLModElement::cite() const
0428 {
0429     if (!impl) {
0430         return DOMString();
0431     }
0432     return ((ElementImpl *)impl)->getAttribute(ATTR_CITE);
0433 }
0434 
0435 void HTMLModElement::setCite(const DOMString &value)
0436 {
0437     if (impl) {
0438         ((ElementImpl *)impl)->setAttribute(ATTR_CITE, value);
0439     }
0440 }
0441 
0442 DOMString HTMLModElement::dateTime() const
0443 {
0444     if (!impl) {
0445         return DOMString();
0446     }
0447     return ((ElementImpl *)impl)->getAttribute(ATTR_DATETIME);
0448 }
0449 
0450 void HTMLModElement::setDateTime(const DOMString &value)
0451 {
0452     if (impl) {
0453         ((ElementImpl *)impl)->setAttribute(ATTR_DATETIME, value);
0454     }
0455 }
0456 
0457 // --------------------------------------------------------------------------
0458 
0459 HTMLQuoteElement::HTMLQuoteElement() : HTMLElement()
0460 {
0461 }
0462 
0463 HTMLQuoteElement::HTMLQuoteElement(const HTMLQuoteElement &other) : HTMLElement(other)
0464 {
0465 }
0466 
0467 HTMLQuoteElement::HTMLQuoteElement(HTMLGenericElementImpl *_impl)
0468     : HTMLElement()
0469 {
0470     if (_impl && _impl->id() == ID_Q) {
0471         impl = _impl;
0472     } else {
0473         impl = nullptr;
0474     }
0475     if (impl) {
0476         impl->ref();
0477     }
0478 }
0479 
0480 HTMLQuoteElement &HTMLQuoteElement::operator = (const Node &other)
0481 {
0482     assignOther(other, ID_Q);
0483     return *this;
0484 }
0485 
0486 HTMLQuoteElement &HTMLQuoteElement::operator = (const HTMLQuoteElement &other)
0487 {
0488     HTMLElement::operator = (other);
0489     return *this;
0490 }
0491 
0492 HTMLQuoteElement::~HTMLQuoteElement()
0493 {
0494 }
0495 
0496 DOMString HTMLQuoteElement::cite() const
0497 {
0498     if (!impl) {
0499         return DOMString();
0500     }
0501     return ((ElementImpl *)impl)->getAttribute(ATTR_CITE);
0502 }
0503 
0504 void HTMLQuoteElement::setCite(const DOMString &value)
0505 {
0506     if (impl) {
0507         ((ElementImpl *)impl)->setAttribute(ATTR_CITE, value);
0508     }
0509 }
0510