File indexing completed on 2024-04-21 11:29:42

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_misc.h"
0025 #include "html/html_miscimpl.h"
0026 
0027 using namespace DOM;
0028 
0029 HTMLBaseFontElement::HTMLBaseFontElement() : HTMLElement()
0030 {
0031 }
0032 
0033 HTMLBaseFontElement::HTMLBaseFontElement(const HTMLBaseFontElement &other) : HTMLElement(other)
0034 {
0035 }
0036 
0037 HTMLBaseFontElement::HTMLBaseFontElement(HTMLBaseFontElementImpl *impl) : HTMLElement(impl)
0038 {
0039 }
0040 
0041 HTMLBaseFontElement &HTMLBaseFontElement::operator = (const Node &other)
0042 {
0043     assignOther(other, ID_BASEFONT);
0044     return *this;
0045 }
0046 
0047 HTMLBaseFontElement &HTMLBaseFontElement::operator = (const HTMLBaseFontElement &other)
0048 {
0049     HTMLElement::operator = (other);
0050     return *this;
0051 }
0052 
0053 HTMLBaseFontElement::~HTMLBaseFontElement()
0054 {
0055 }
0056 
0057 DOMString HTMLBaseFontElement::color() const
0058 {
0059     if (!impl) {
0060         return DOMString();
0061     }
0062     return ((ElementImpl *)impl)->getAttribute(ATTR_COLOR);
0063 }
0064 
0065 void HTMLBaseFontElement::setColor(const DOMString &value)
0066 {
0067     if (impl) {
0068         ((ElementImpl *)impl)->setAttribute(ATTR_COLOR, value);
0069     }
0070 }
0071 
0072 DOMString HTMLBaseFontElement::face() const
0073 {
0074     if (!impl) {
0075         return DOMString();
0076     }
0077     return ((ElementImpl *)impl)->getAttribute(ATTR_FACE);
0078 }
0079 
0080 void HTMLBaseFontElement::setFace(const DOMString &value)
0081 {
0082     if (impl) {
0083         ((ElementImpl *)impl)->setAttribute(ATTR_FACE, value);
0084     }
0085 }
0086 
0087 #ifndef KHTML_NO_DEPRECATED
0088 DOMString HTMLBaseFontElement::size() const
0089 {
0090     if (!impl) {
0091         return DOMString();
0092     }
0093     return ((ElementImpl *)impl)->getAttribute(ATTR_SIZE);
0094 }
0095 #endif
0096 
0097 #ifndef KHTML_NO_DEPRECATED
0098 void HTMLBaseFontElement::setSize(const DOMString &value)
0099 {
0100     if (impl) {
0101         ((ElementImpl *)impl)->setAttribute(ATTR_SIZE, value);
0102     }
0103 }
0104 #endif
0105 
0106 long HTMLBaseFontElement::getSize() const
0107 {
0108     if (!impl) {
0109         return 0;
0110     }
0111     return ((ElementImpl *)impl)->getAttribute(ATTR_SIZE).toInt();
0112 }
0113 
0114 void HTMLBaseFontElement::setSize(long _value)
0115 {
0116     if (impl) {
0117         DOMString value(QString::number(_value));
0118         ((ElementImpl *)impl)->setAttribute(ATTR_SIZE, value);
0119     }
0120 }
0121 
0122 // --------------------------------------------------------------------------
0123 
0124 HTMLCollection::HTMLCollection()
0125     : impl(nullptr)
0126 {
0127 }
0128 
0129 HTMLCollection::HTMLCollection(HTMLCollectionImpl *_impl): impl(_impl)
0130 {
0131     if (impl) {
0132         impl->ref();
0133     }
0134 }
0135 
0136 HTMLCollection::HTMLCollection(const HTMLCollection &other)
0137 {
0138     impl = other.impl;
0139     if (impl) {
0140         impl->ref();
0141     }
0142 }
0143 
0144 HTMLCollection::HTMLCollection(NodeImpl *base, int type)
0145 {
0146     impl = new HTMLCollectionImpl(base, type);
0147     impl->ref();
0148 }
0149 
0150 HTMLCollection &HTMLCollection::operator = (const HTMLCollection &other)
0151 {
0152     if (impl != other.impl) {
0153         if (impl) {
0154             impl->deref();
0155         }
0156         impl = other.impl;
0157         if (impl) {
0158             impl->ref();
0159         }
0160     }
0161     return *this;
0162 }
0163 
0164 HTMLCollection::~HTMLCollection()
0165 {
0166     if (impl) {
0167         impl->deref();
0168     }
0169 }
0170 
0171 unsigned long HTMLCollection::length() const
0172 {
0173     if (!impl) {
0174         return 0;
0175     }
0176     return ((HTMLCollectionImpl *)impl)->length();
0177 }
0178 
0179 Node HTMLCollection::item(unsigned long index) const
0180 {
0181     if (!impl) {
0182         return nullptr;
0183     }
0184     return ((HTMLCollectionImpl *)impl)->item(index);
0185 }
0186 
0187 Node HTMLCollection::namedItem(const DOMString &name) const
0188 {
0189     if (!impl) {
0190         return nullptr;
0191     }
0192     return ((HTMLCollectionImpl *)impl)->namedItem(name);
0193 }
0194 
0195 Node HTMLCollection::base() const
0196 {
0197     if (!impl) {
0198         return nullptr;
0199     }
0200 
0201     return static_cast<HTMLCollectionImpl *>(impl)->m_refNode;
0202 }
0203 
0204 Node HTMLCollection::firstItem() const
0205 {
0206     if (!impl) {
0207         return nullptr;
0208     }
0209     return static_cast<HTMLCollectionImpl *>(impl)->firstItem();
0210 }
0211 
0212 Node HTMLCollection::nextItem() const
0213 {
0214     if (!impl) {
0215         return nullptr;
0216     }
0217     return static_cast<HTMLCollectionImpl *>(impl)->nextItem();
0218 }
0219 
0220 Node HTMLCollection::nextNamedItem(const DOMString &name) const
0221 {
0222     if (!impl) {
0223         return nullptr;
0224     }
0225     return static_cast<HTMLCollectionImpl *>(impl)->nextNamedItem(name);
0226 }
0227 
0228 HTMLCollectionImpl *HTMLCollection::handle() const
0229 {
0230     return impl;
0231 }
0232 
0233 bool HTMLCollection::isNull() const
0234 {
0235     return (impl == nullptr);
0236 }
0237 
0238 // -----------------------------------------------------------------------------
0239 
0240 HTMLFormCollection::HTMLFormCollection(NodeImpl *base)
0241     : HTMLCollection()
0242 {
0243     impl = new HTMLFormCollectionImpl(base);
0244     impl->ref();
0245 }
0246