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

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_head.h"
0025 #include "html/html_headimpl.h"
0026 #include "xml/dom_docimpl.h"
0027 
0028 using namespace DOM;
0029 
0030 HTMLBaseElement::HTMLBaseElement() : HTMLElement()
0031 {
0032 }
0033 
0034 HTMLBaseElement::HTMLBaseElement(const HTMLBaseElement &other) : HTMLElement(other)
0035 {
0036 }
0037 
0038 HTMLBaseElement::HTMLBaseElement(HTMLBaseElementImpl *impl) : HTMLElement(impl)
0039 {
0040 }
0041 
0042 HTMLBaseElement &HTMLBaseElement::operator = (const Node &other)
0043 {
0044     assignOther(other, ID_BASE);
0045     return *this;
0046 }
0047 
0048 HTMLBaseElement &HTMLBaseElement::operator = (const HTMLBaseElement &other)
0049 {
0050     HTMLElement::operator = (other);
0051     return *this;
0052 }
0053 
0054 HTMLBaseElement::~HTMLBaseElement()
0055 {
0056 }
0057 
0058 DOMString HTMLBaseElement::href() const
0059 {
0060     if (!impl) {
0061         return DOMString();
0062     }
0063     const DOMString href = static_cast<ElementImpl *>(impl)->getAttribute(ATTR_HREF).trimSpaces();
0064     return !href.isNull() ? impl->document()->completeURL(href.string()) : href;
0065 }
0066 
0067 void HTMLBaseElement::setHref(const DOMString &value)
0068 {
0069     if (impl) {
0070         ((ElementImpl *)impl)->setAttribute(ATTR_HREF, value);
0071     }
0072 }
0073 
0074 DOMString HTMLBaseElement::target() const
0075 {
0076     if (!impl) {
0077         return DOMString();
0078     }
0079     return ((ElementImpl *)impl)->getAttribute(ATTR_TARGET);
0080 }
0081 
0082 void HTMLBaseElement::setTarget(const DOMString &value)
0083 {
0084     if (impl) {
0085         ((ElementImpl *)impl)->setAttribute(ATTR_TARGET, value);
0086     }
0087 }
0088 
0089 // --------------------------------------------------------------------------
0090 
0091 HTMLLinkElement::HTMLLinkElement() : HTMLElement()
0092 {
0093 }
0094 
0095 HTMLLinkElement::HTMLLinkElement(const HTMLLinkElement &other) : HTMLElement(other)
0096 {
0097 }
0098 
0099 HTMLLinkElement::HTMLLinkElement(HTMLLinkElementImpl *impl) : HTMLElement(impl)
0100 {
0101 }
0102 
0103 HTMLLinkElement &HTMLLinkElement::operator = (const Node &other)
0104 {
0105     assignOther(other, ID_LINK);
0106     return *this;
0107 }
0108 
0109 HTMLLinkElement &HTMLLinkElement::operator = (const HTMLLinkElement &other)
0110 {
0111     HTMLElement::operator = (other);
0112     return *this;
0113 }
0114 
0115 HTMLLinkElement::~HTMLLinkElement()
0116 {
0117 }
0118 
0119 bool HTMLLinkElement::disabled() const
0120 {
0121     if (!impl) {
0122         return 0;
0123     }
0124     return !((ElementImpl *)impl)->getAttribute(ATTR_DISABLED).isNull();
0125 }
0126 
0127 void HTMLLinkElement::setDisabled(bool _disabled)
0128 {
0129     if (impl) {
0130         ((ElementImpl *)impl)->setAttribute(ATTR_DISABLED, _disabled ? "" : nullptr);
0131     }
0132 }
0133 
0134 DOMString HTMLLinkElement::charset() const
0135 {
0136     if (!impl) {
0137         return DOMString();
0138     }
0139     return ((ElementImpl *)impl)->getAttribute(ATTR_CHARSET);
0140 }
0141 
0142 void HTMLLinkElement::setCharset(const DOMString &value)
0143 {
0144     if (impl) {
0145         ((ElementImpl *)impl)->setAttribute(ATTR_CHARSET, value);
0146     }
0147 }
0148 
0149 DOMString HTMLLinkElement::href() const
0150 {
0151     if (!impl) {
0152         return DOMString();
0153     }
0154     const DOMString href = static_cast<ElementImpl *>(impl)->getAttribute(ATTR_HREF).trimSpaces();
0155     return !href.isNull() ? impl->document()->completeURL(href.string()) : href;
0156 }
0157 
0158 void HTMLLinkElement::setHref(const DOMString &value)
0159 {
0160     if (impl) {
0161         ((ElementImpl *)impl)->setAttribute(ATTR_HREF, value);
0162     }
0163 }
0164 
0165 DOMString HTMLLinkElement::hreflang() const
0166 {
0167     if (!impl) {
0168         return DOMString();
0169     }
0170     return ((ElementImpl *)impl)->getAttribute(ATTR_HREFLANG);
0171 }
0172 
0173 void HTMLLinkElement::setHreflang(const DOMString &value)
0174 {
0175     if (impl) {
0176         ((ElementImpl *)impl)->setAttribute(ATTR_HREFLANG, value);
0177     }
0178 }
0179 
0180 DOMString HTMLLinkElement::media() const
0181 {
0182     if (!impl) {
0183         return DOMString();
0184     }
0185     return ((ElementImpl *)impl)->getAttribute(ATTR_MEDIA);
0186 }
0187 
0188 void HTMLLinkElement::setMedia(const DOMString &value)
0189 {
0190     if (impl) {
0191         ((ElementImpl *)impl)->setAttribute(ATTR_MEDIA, value);
0192     }
0193 }
0194 
0195 DOMString HTMLLinkElement::rel() const
0196 {
0197     if (!impl) {
0198         return DOMString();
0199     }
0200     return ((ElementImpl *)impl)->getAttribute(ATTR_REL);
0201 }
0202 
0203 void HTMLLinkElement::setRel(const DOMString &value)
0204 {
0205     if (impl) {
0206         ((ElementImpl *)impl)->setAttribute(ATTR_REL, value);
0207     }
0208 }
0209 
0210 DOMString HTMLLinkElement::rev() const
0211 {
0212     if (!impl) {
0213         return DOMString();
0214     }
0215     return ((ElementImpl *)impl)->getAttribute(ATTR_REV);
0216 }
0217 
0218 void HTMLLinkElement::setRev(const DOMString &value)
0219 {
0220     if (impl) {
0221         ((ElementImpl *)impl)->setAttribute(ATTR_REV, value);
0222     }
0223 }
0224 
0225 DOMString HTMLLinkElement::target() const
0226 {
0227     if (!impl) {
0228         return DOMString();
0229     }
0230     return ((ElementImpl *)impl)->getAttribute(ATTR_TARGET);
0231 }
0232 
0233 void HTMLLinkElement::setTarget(const DOMString &value)
0234 {
0235     if (impl) {
0236         ((ElementImpl *)impl)->setAttribute(ATTR_TARGET, value);
0237     }
0238 }
0239 
0240 DOMString HTMLLinkElement::type() const
0241 {
0242     if (!impl) {
0243         return DOMString();
0244     }
0245     return ((ElementImpl *)impl)->getAttribute(ATTR_TYPE);
0246 }
0247 
0248 void HTMLLinkElement::setType(const DOMString &value)
0249 {
0250     if (impl) {
0251         ((ElementImpl *)impl)->setAttribute(ATTR_TYPE, value);
0252     }
0253 }
0254 
0255 StyleSheet HTMLLinkElement::sheet() const
0256 {
0257     if (!impl) {
0258         return nullptr;
0259     }
0260     return ((HTMLLinkElementImpl *)impl)->sheet();
0261 }
0262 
0263 // --------------------------------------------------------------------------
0264 
0265 HTMLMetaElement::HTMLMetaElement() : HTMLElement()
0266 {
0267 }
0268 
0269 HTMLMetaElement::HTMLMetaElement(const HTMLMetaElement &other) : HTMLElement(other)
0270 {
0271 }
0272 
0273 HTMLMetaElement::HTMLMetaElement(HTMLMetaElementImpl *impl) : HTMLElement(impl)
0274 {
0275 }
0276 
0277 HTMLMetaElement &HTMLMetaElement::operator = (const Node &other)
0278 {
0279     assignOther(other, ID_META);
0280     return *this;
0281 }
0282 
0283 HTMLMetaElement &HTMLMetaElement::operator = (const HTMLMetaElement &other)
0284 {
0285     HTMLElement::operator = (other);
0286     return *this;
0287 }
0288 
0289 HTMLMetaElement::~HTMLMetaElement()
0290 {
0291 }
0292 
0293 DOMString HTMLMetaElement::content() const
0294 {
0295     if (!impl) {
0296         return DOMString();
0297     }
0298     return ((ElementImpl *)impl)->getAttribute(ATTR_CONTENT);
0299 }
0300 
0301 void HTMLMetaElement::setContent(const DOMString &value)
0302 {
0303     if (impl) {
0304         ((ElementImpl *)impl)->setAttribute(ATTR_CONTENT, value);
0305     }
0306 }
0307 
0308 DOMString HTMLMetaElement::httpEquiv() const
0309 {
0310     if (!impl) {
0311         return DOMString();
0312     }
0313     return ((ElementImpl *)impl)->getAttribute(ATTR_HTTP_EQUIV);
0314 }
0315 
0316 void HTMLMetaElement::setHttpEquiv(const DOMString &value)
0317 {
0318     if (impl) {
0319         ((ElementImpl *)impl)->setAttribute(ATTR_HTTP_EQUIV, value);
0320     }
0321 }
0322 
0323 DOMString HTMLMetaElement::name() const
0324 {
0325     if (!impl) {
0326         return DOMString();
0327     }
0328     return ((ElementImpl *)impl)->getAttribute(ATTR_NAME);
0329 }
0330 
0331 void HTMLMetaElement::setName(const DOMString &value)
0332 {
0333     if (impl) {
0334         ((ElementImpl *)impl)->setAttribute(ATTR_NAME, value);
0335     }
0336 }
0337 
0338 DOMString HTMLMetaElement::scheme() const
0339 {
0340     if (!impl) {
0341         return DOMString();
0342     }
0343     return ((ElementImpl *)impl)->getAttribute(ATTR_SCHEME);
0344 }
0345 
0346 void HTMLMetaElement::setScheme(const DOMString &value)
0347 {
0348     if (impl) {
0349         ((ElementImpl *)impl)->setAttribute(ATTR_SCHEME, value);
0350     }
0351 }
0352 
0353 // --------------------------------------------------------------------------
0354 
0355 HTMLScriptElement::HTMLScriptElement() : HTMLElement()
0356 {
0357 }
0358 
0359 HTMLScriptElement::HTMLScriptElement(const HTMLScriptElement &other) : HTMLElement(other)
0360 {
0361 }
0362 
0363 HTMLScriptElement::HTMLScriptElement(HTMLScriptElementImpl *impl) : HTMLElement(impl)
0364 {
0365 }
0366 
0367 HTMLScriptElement &HTMLScriptElement::operator = (const Node &other)
0368 {
0369     assignOther(other, ID_SCRIPT);
0370     return *this;
0371 }
0372 
0373 HTMLScriptElement &HTMLScriptElement::operator = (const HTMLScriptElement &other)
0374 {
0375     HTMLElement::operator = (other);
0376     return *this;
0377 }
0378 
0379 HTMLScriptElement::~HTMLScriptElement()
0380 {
0381 }
0382 
0383 DOMString HTMLScriptElement::text() const
0384 {
0385     if (!impl) {
0386         return DOMString();
0387     }
0388     return ((HTMLScriptElementImpl *)impl)->text();
0389 }
0390 
0391 void HTMLScriptElement::setText(const DOMString &value)
0392 {
0393     if (impl) {
0394         ((HTMLScriptElementImpl *)impl)->setText(value);
0395     }
0396 }
0397 
0398 DOMString HTMLScriptElement::htmlFor() const
0399 {
0400     // DOM Level 1 says: reserved for future use...
0401     return DOMString();
0402 }
0403 
0404 void HTMLScriptElement::setHtmlFor(const DOMString &/*value*/)
0405 {
0406     // DOM Level 1 says: reserved for future use...
0407 }
0408 
0409 DOMString HTMLScriptElement::event() const
0410 {
0411     // DOM Level 1 says: reserved for future use...
0412     return DOMString();
0413 }
0414 
0415 void HTMLScriptElement::setEvent(const DOMString &/*value*/)
0416 {
0417     // DOM Level 1 says: reserved for future use...
0418 }
0419 
0420 DOMString HTMLScriptElement::charset() const
0421 {
0422     if (!impl) {
0423         return DOMString();
0424     }
0425     return ((ElementImpl *)impl)->getAttribute(ATTR_CHARSET);
0426 }
0427 
0428 void HTMLScriptElement::setCharset(const DOMString &value)
0429 {
0430     if (impl) {
0431         ((ElementImpl *)impl)->setAttribute(ATTR_CHARSET, value);
0432     }
0433 }
0434 
0435 bool HTMLScriptElement::defer() const
0436 {
0437     if (!impl) {
0438         return 0;
0439     }
0440     return !((ElementImpl *)impl)->getAttribute(ATTR_DEFER).isNull();
0441 }
0442 
0443 void HTMLScriptElement::setDefer(bool _defer)
0444 {
0445 
0446     if (impl) {
0447         ((ElementImpl *)impl)->setAttribute(ATTR_DEFER, _defer ? "" : nullptr);
0448     }
0449 }
0450 
0451 DOMString HTMLScriptElement::src() const
0452 {
0453     if (!impl) {
0454         return DOMString();
0455     }
0456     const DOMString s = ((ElementImpl *)impl)->getAttribute(ATTR_SRC).trimSpaces();
0457     return !s.isNull() ? impl->document()->completeURL(s.string()) : s;
0458 }
0459 
0460 void HTMLScriptElement::setSrc(const DOMString &value)
0461 {
0462     if (impl) {
0463         ((ElementImpl *)impl)->setAttribute(ATTR_SRC, value);
0464     }
0465 }
0466 
0467 DOMString HTMLScriptElement::type() const
0468 {
0469     if (!impl) {
0470         return DOMString();
0471     }
0472     return ((ElementImpl *)impl)->getAttribute(ATTR_TYPE);
0473 }
0474 
0475 void HTMLScriptElement::setType(const DOMString &value)
0476 {
0477     if (impl) {
0478         ((ElementImpl *)impl)->setAttribute(ATTR_TYPE, value);
0479     }
0480 }
0481 
0482 // --------------------------------------------------------------------------
0483 
0484 HTMLStyleElement::HTMLStyleElement() : HTMLElement()
0485 {
0486 }
0487 
0488 HTMLStyleElement::HTMLStyleElement(const HTMLStyleElement &other) : HTMLElement(other)
0489 {
0490 }
0491 
0492 HTMLStyleElement::HTMLStyleElement(HTMLStyleElementImpl *impl) : HTMLElement(impl)
0493 {
0494 }
0495 
0496 HTMLStyleElement &HTMLStyleElement::operator = (const Node &other)
0497 {
0498     assignOther(other, ID_STYLE);
0499     return *this;
0500 }
0501 
0502 HTMLStyleElement &HTMLStyleElement::operator = (const HTMLStyleElement &other)
0503 {
0504     HTMLElement::operator = (other);
0505     return *this;
0506 }
0507 
0508 HTMLStyleElement::~HTMLStyleElement()
0509 {
0510 }
0511 
0512 bool HTMLStyleElement::disabled() const
0513 {
0514     if (!impl) {
0515         return 0;
0516     }
0517     return !((HTMLStyleElementImpl *)impl)->getAttribute(ATTR_DISABLED).isNull();
0518 }
0519 
0520 void HTMLStyleElement::setDisabled(bool _disabled)
0521 {
0522 
0523     if (impl) {
0524         ((ElementImpl *)impl)->setAttribute(ATTR_DISABLED, _disabled ? "" : nullptr);
0525     }
0526 }
0527 
0528 DOMString HTMLStyleElement::media() const
0529 {
0530     if (!impl) {
0531         return DOMString();
0532     }
0533     return ((ElementImpl *)impl)->getAttribute(ATTR_MEDIA);
0534 }
0535 
0536 void HTMLStyleElement::setMedia(const DOMString &value)
0537 {
0538     if (impl) {
0539         ((ElementImpl *)impl)->setAttribute(ATTR_MEDIA, value);
0540     }
0541 }
0542 
0543 DOMString HTMLStyleElement::type() const
0544 {
0545     if (!impl) {
0546         return DOMString();
0547     }
0548     return ((ElementImpl *)impl)->getAttribute(ATTR_TYPE);
0549 }
0550 
0551 void HTMLStyleElement::setType(const DOMString &value)
0552 {
0553     if (impl) {
0554         ((ElementImpl *)impl)->setAttribute(ATTR_TYPE, value);
0555     }
0556 }
0557 
0558 StyleSheet HTMLStyleElement::sheet() const
0559 {
0560     if (!impl) {
0561         return nullptr;
0562     }
0563     return ((HTMLStyleElementImpl *)impl)->sheet();
0564 }
0565 
0566 // --------------------------------------------------------------------------
0567 
0568 HTMLTitleElement::HTMLTitleElement() : HTMLElement()
0569 {
0570 }
0571 
0572 HTMLTitleElement::HTMLTitleElement(const HTMLTitleElement &other) : HTMLElement(other)
0573 {
0574 }
0575 
0576 HTMLTitleElement::HTMLTitleElement(HTMLTitleElementImpl *impl) : HTMLElement(impl)
0577 {
0578 }
0579 
0580 HTMLTitleElement &HTMLTitleElement::operator = (const Node &other)
0581 {
0582     assignOther(other, ID_TITLE);
0583     return *this;
0584 }
0585 
0586 HTMLTitleElement &HTMLTitleElement::operator = (const HTMLTitleElement &other)
0587 {
0588     HTMLElement::operator = (other);
0589     return *this;
0590 }
0591 
0592 HTMLTitleElement::~HTMLTitleElement()
0593 {
0594 }
0595 
0596 DOMString HTMLTitleElement::text() const
0597 {
0598     if (!impl) {
0599         return DOMString();
0600     }
0601     return ((HTMLTitleElementImpl *)impl)->text();
0602 }
0603 
0604 void HTMLTitleElement::setText(const DOMString &value)
0605 {
0606     if (impl) {
0607         ((HTMLTitleElementImpl *)impl)->setText(value);
0608     }
0609 }
0610