fix logic
[personal-kdelibs.git] / khtml / dom / html_misc.cpp
blob2e041f5868c96e8113dd7b2ec80a7ee30a67b308
1 /**
2 * This file is part of the DOM implementation for KDE.
4 * Copyright 1999 Lars Knoll (knoll@kde.org)
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Library General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Library General Public License for more details.
16 * You should have received a copy of the GNU Library General Public License
17 * along with this library; see the file COPYING.LIB. If not, write to
18 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19 * Boston, MA 02110-1301, USA.
22 // --------------------------------------------------------------------------
24 #include "dom/html_misc.h"
25 #include "html/html_miscimpl.h"
26 #include "misc/htmlhashes.h"
28 using namespace DOM;
30 HTMLBaseFontElement::HTMLBaseFontElement() : HTMLElement()
34 HTMLBaseFontElement::HTMLBaseFontElement(const HTMLBaseFontElement &other) : HTMLElement(other)
38 HTMLBaseFontElement::HTMLBaseFontElement(HTMLBaseFontElementImpl *impl) : HTMLElement(impl)
42 HTMLBaseFontElement &HTMLBaseFontElement::operator = (const Node &other)
44 assignOther( other, ID_BASEFONT );
45 return *this;
48 HTMLBaseFontElement &HTMLBaseFontElement::operator = (const HTMLBaseFontElement &other)
50 HTMLElement::operator = (other);
51 return *this;
54 HTMLBaseFontElement::~HTMLBaseFontElement()
58 DOMString HTMLBaseFontElement::color() const
60 if(!impl) return DOMString();
61 return ((ElementImpl *)impl)->getAttribute(ATTR_COLOR);
64 void HTMLBaseFontElement::setColor( const DOMString &value )
66 if(impl) ((ElementImpl *)impl)->setAttribute(ATTR_COLOR, value);
69 DOMString HTMLBaseFontElement::face() const
71 if(!impl) return DOMString();
72 return ((ElementImpl *)impl)->getAttribute(ATTR_FACE);
75 void HTMLBaseFontElement::setFace( const DOMString &value )
77 if(impl) ((ElementImpl *)impl)->setAttribute(ATTR_FACE, value);
80 DOMString HTMLBaseFontElement::size() const
82 if(!impl) return DOMString();
83 return ((ElementImpl *)impl)->getAttribute(ATTR_SIZE);
86 void HTMLBaseFontElement::setSize( const DOMString &value )
88 if(impl) ((ElementImpl *)impl)->setAttribute(ATTR_SIZE, value);
91 long HTMLBaseFontElement::getSize() const
93 if(!impl) return 0;
94 return ((ElementImpl *)impl)->getAttribute(ATTR_SIZE).toInt();
97 void HTMLBaseFontElement::setSize( long _value )
99 if ( impl )
101 DOMString value( QString::number( _value ) );
102 ((ElementImpl *)impl)->setAttribute(ATTR_SIZE, value);
107 // --------------------------------------------------------------------------
109 HTMLCollection::HTMLCollection()
110 : impl(0)
114 HTMLCollection::HTMLCollection(HTMLCollectionImpl* _impl): impl(_impl)
116 if (impl) impl->ref();
119 HTMLCollection::HTMLCollection(const HTMLCollection &other)
121 impl = other.impl;
122 if(impl) impl->ref();
125 HTMLCollection::HTMLCollection(NodeImpl *base, int type)
127 impl = new HTMLCollectionImpl(base, type);
128 impl->ref();
131 HTMLCollection &HTMLCollection::operator = (const HTMLCollection &other)
133 if(impl != other.impl) {
134 if(impl) impl->deref();
135 impl = other.impl;
136 if(impl) impl->ref();
138 return *this;
141 HTMLCollection::~HTMLCollection()
143 if(impl) impl->deref();
146 unsigned long HTMLCollection::length() const
148 if(!impl) return 0;
149 return ((HTMLCollectionImpl *)impl)->length();
152 Node HTMLCollection::item( unsigned long index ) const
154 if(!impl) return 0;
155 return ((HTMLCollectionImpl *)impl)->item( index );
158 Node HTMLCollection::namedItem( const DOMString &name ) const
160 if(!impl) return 0;
161 return ((HTMLCollectionImpl *)impl)->namedItem( name );
164 Node HTMLCollection::base() const
166 if ( !impl )
167 return 0;
169 return static_cast<HTMLCollectionImpl*>( impl )->m_refNode;
172 Node HTMLCollection::firstItem() const
174 if ( !impl )
175 return 0;
176 return static_cast<HTMLCollectionImpl*>( impl )->firstItem();
179 Node HTMLCollection::nextItem() const
181 if ( !impl )
182 return 0;
183 return static_cast<HTMLCollectionImpl*>( impl )->nextItem();
186 Node HTMLCollection::nextNamedItem( const DOMString &name ) const
188 if ( !impl )
189 return 0;
190 return static_cast<HTMLCollectionImpl*>( impl )->nextNamedItem( name );
193 HTMLCollectionImpl *HTMLCollection::handle() const
195 return impl;
198 bool HTMLCollection::isNull() const
200 return (impl == 0);
204 // -----------------------------------------------------------------------------
206 HTMLFormCollection::HTMLFormCollection(NodeImpl *base)
207 : HTMLCollection()
209 impl = new HTMLFormCollectionImpl(base);
210 impl->ref();