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 "html_image.h" 0025 #include "dom_doc.h" 0026 #include "html_misc.h" 0027 0028 #include <html/html_imageimpl.h> 0029 #include <html/html_miscimpl.h> 0030 #include <xml/dom_docimpl.h> 0031 0032 using namespace DOM; 0033 0034 HTMLAreaElement::HTMLAreaElement() : HTMLElement() 0035 { 0036 } 0037 0038 HTMLAreaElement::HTMLAreaElement(const HTMLAreaElement &other) : HTMLElement(other) 0039 { 0040 } 0041 0042 HTMLAreaElement::HTMLAreaElement(HTMLAreaElementImpl *impl) : HTMLElement(impl) 0043 { 0044 } 0045 0046 HTMLAreaElement &HTMLAreaElement::operator = (const Node &other) 0047 { 0048 assignOther(other, ID_AREA); 0049 return *this; 0050 } 0051 0052 HTMLAreaElement &HTMLAreaElement::operator = (const HTMLAreaElement &other) 0053 { 0054 HTMLElement::operator = (other); 0055 return *this; 0056 } 0057 0058 HTMLAreaElement::~HTMLAreaElement() 0059 { 0060 } 0061 0062 DOMString HTMLAreaElement::accessKey() const 0063 { 0064 if (!impl) { 0065 return DOMString(); 0066 } 0067 return ((ElementImpl *)impl)->getAttribute(ATTR_ACCESSKEY); 0068 } 0069 0070 void HTMLAreaElement::setAccessKey(const DOMString &value) 0071 { 0072 if (impl) { 0073 ((ElementImpl *)impl)->setAttribute(ATTR_ACCESSKEY, value); 0074 } 0075 } 0076 0077 DOMString HTMLAreaElement::alt() const 0078 { 0079 if (!impl) { 0080 return DOMString(); 0081 } 0082 return ((ElementImpl *)impl)->getAttribute(ATTR_ALT); 0083 } 0084 0085 void HTMLAreaElement::setAlt(const DOMString &value) 0086 { 0087 if (impl) { 0088 ((ElementImpl *)impl)->setAttribute(ATTR_ALT, value); 0089 } 0090 } 0091 0092 DOMString HTMLAreaElement::coords() const 0093 { 0094 if (!impl) { 0095 return DOMString(); 0096 } 0097 return ((ElementImpl *)impl)->getAttribute(ATTR_COORDS); 0098 } 0099 0100 void HTMLAreaElement::setCoords(const DOMString &value) 0101 { 0102 if (impl) { 0103 ((ElementImpl *)impl)->setAttribute(ATTR_COORDS, value); 0104 } 0105 } 0106 0107 DOMString HTMLAreaElement::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 HTMLAreaElement::setHref(const DOMString &value) 0117 { 0118 if (impl) { 0119 ((ElementImpl *)impl)->setAttribute(ATTR_HREF, value); 0120 } 0121 } 0122 0123 bool HTMLAreaElement::noHref() const 0124 { 0125 if (!impl) { 0126 return 0; 0127 } 0128 return !((ElementImpl *)impl)->getAttribute(ATTR_NOHREF).isNull(); 0129 } 0130 0131 void HTMLAreaElement::setNoHref(bool _noHref) 0132 { 0133 if (impl) { 0134 DOMString str; 0135 if (_noHref) { 0136 str = ""; 0137 } 0138 ((ElementImpl *)impl)->setAttribute(ATTR_NOHREF, str); 0139 } 0140 } 0141 0142 DOMString HTMLAreaElement::shape() const 0143 { 0144 if (!impl) { 0145 return DOMString(); 0146 } 0147 return ((ElementImpl *)impl)->getAttribute(ATTR_SHAPE); 0148 } 0149 0150 void HTMLAreaElement::setShape(const DOMString &value) 0151 { 0152 if (impl) { 0153 ((ElementImpl *)impl)->setAttribute(ATTR_SHAPE, value); 0154 } 0155 } 0156 0157 long HTMLAreaElement::tabIndex() const 0158 { 0159 if (!impl) { 0160 return 0; 0161 } 0162 return ((ElementImpl *)impl)->getAttribute(ATTR_TABINDEX).toInt(); 0163 } 0164 0165 void HTMLAreaElement::setTabIndex(long _tabIndex) 0166 { 0167 if (impl) { 0168 DOMString value(QString::number(_tabIndex)); 0169 ((ElementImpl *)impl)->setAttribute(ATTR_TABINDEX, value); 0170 } 0171 } 0172 0173 DOMString HTMLAreaElement::target() const 0174 { 0175 if (!impl) { 0176 return DOMString(); 0177 } 0178 return ((ElementImpl *)impl)->getAttribute(ATTR_TARGET); 0179 } 0180 0181 void HTMLAreaElement::setTarget(const DOMString &value) 0182 { 0183 if (impl) { 0184 ((ElementImpl *)impl)->setAttribute(ATTR_TARGET, value); 0185 } 0186 } 0187 0188 // -------------------------------------------------------------------------- 0189 0190 HTMLImageElement::HTMLImageElement() : HTMLElement() 0191 { 0192 } 0193 0194 HTMLImageElement::HTMLImageElement(const HTMLImageElement &other) : HTMLElement(other) 0195 { 0196 } 0197 0198 HTMLImageElement::HTMLImageElement(HTMLImageElementImpl *impl) : HTMLElement(impl) 0199 { 0200 } 0201 0202 HTMLImageElement &HTMLImageElement::operator = (const Node &other) 0203 { 0204 assignOther(other, ID_IMG); 0205 return *this; 0206 } 0207 0208 HTMLImageElement &HTMLImageElement::operator = (const HTMLImageElement &other) 0209 { 0210 HTMLElement::operator = (other); 0211 return *this; 0212 } 0213 0214 HTMLImageElement::~HTMLImageElement() 0215 { 0216 } 0217 0218 DOMString HTMLImageElement::name() const 0219 { 0220 if (!impl) { 0221 return DOMString(); 0222 } 0223 return ((ElementImpl *)impl)->getAttribute(ATTR_NAME); 0224 } 0225 0226 void HTMLImageElement::setName(const DOMString &value) 0227 { 0228 if (impl) { 0229 ((ElementImpl *)impl)->setAttribute(ATTR_NAME, value); 0230 } 0231 } 0232 0233 DOMString HTMLImageElement::align() const 0234 { 0235 if (!impl) { 0236 return DOMString(); 0237 } 0238 return ((ElementImpl *)impl)->getAttribute(ATTR_ALIGN); 0239 } 0240 0241 void HTMLImageElement::setAlign(const DOMString &value) 0242 { 0243 if (impl) { 0244 ((ElementImpl *)impl)->setAttribute(ATTR_ALIGN, value); 0245 } 0246 } 0247 0248 DOMString HTMLImageElement::alt() const 0249 { 0250 if (!impl) { 0251 return DOMString(); 0252 } 0253 return ((ElementImpl *)impl)->getAttribute(ATTR_ALT); 0254 } 0255 0256 void HTMLImageElement::setAlt(const DOMString &value) 0257 { 0258 if (impl) { 0259 ((ElementImpl *)impl)->setAttribute(ATTR_ALT, value); 0260 } 0261 } 0262 0263 #ifndef KHTML_NO_DEPRECATED 0264 long HTMLImageElement::border() const 0265 { 0266 if (!impl) { 0267 return 0; 0268 } 0269 // ### return value in pixels 0270 return static_cast<HTMLImageElementImpl *>(impl)->getAttribute(ATTR_BORDER).toInt(); 0271 } 0272 #endif 0273 0274 #ifndef KHTML_NO_DEPRECATED 0275 void HTMLImageElement::setBorder(long value) 0276 { 0277 if (impl) { 0278 static_cast<HTMLImageElementImpl *>(impl)->setAttribute(ATTR_BORDER, QString::number(value)); 0279 } 0280 } 0281 #endif 0282 0283 DOMString HTMLImageElement::getBorder() const 0284 { 0285 if (!impl) { 0286 return DOMString(); 0287 } 0288 return static_cast<HTMLImageElementImpl *>(impl)->getAttribute(ATTR_BORDER); 0289 } 0290 0291 void HTMLImageElement::setBorder(const DOMString &value) 0292 { 0293 if (impl) { 0294 static_cast<HTMLImageElementImpl *>(impl)->setAttribute(ATTR_BORDER, value); 0295 } 0296 } 0297 0298 long HTMLImageElement::height() const 0299 { 0300 if (!impl) { 0301 return 0; 0302 } 0303 return static_cast<HTMLImageElementImpl *>(impl)->height(); 0304 } 0305 0306 void HTMLImageElement::setHeight(long value) 0307 { 0308 if (impl) { 0309 ((HTMLImageElementImpl *)impl)->setHeight(value); 0310 } 0311 } 0312 0313 long HTMLImageElement::hspace() const 0314 { 0315 if (!impl) { 0316 return 0; 0317 } 0318 // ### return actual value 0319 return ((ElementImpl *)impl)->getAttribute(ATTR_HSPACE).toInt(); 0320 } 0321 0322 void HTMLImageElement::setHspace(long value) 0323 { 0324 if (impl) { 0325 ((ElementImpl *)impl)->setAttribute(ATTR_HSPACE, QString::number(value)); 0326 } 0327 } 0328 0329 bool HTMLImageElement::isMap() const 0330 { 0331 if (!impl) { 0332 return 0; 0333 } 0334 return !((ElementImpl *)impl)->getAttribute(ATTR_ISMAP).isNull(); 0335 } 0336 0337 void HTMLImageElement::setIsMap(bool _isMap) 0338 { 0339 if (impl) { 0340 DOMString str; 0341 if (_isMap) { 0342 str = ""; 0343 } 0344 ((ElementImpl *)impl)->setAttribute(ATTR_ISMAP, str); 0345 } 0346 } 0347 0348 DOMString HTMLImageElement::longDesc() const 0349 { 0350 if (!impl) { 0351 return DOMString(); 0352 } 0353 return ((ElementImpl *)impl)->getAttribute(ATTR_LONGDESC); 0354 } 0355 0356 void HTMLImageElement::setLongDesc(const DOMString &value) 0357 { 0358 if (impl) { 0359 ((ElementImpl *)impl)->setAttribute(ATTR_LONGDESC, value); 0360 } 0361 } 0362 0363 DOMString HTMLImageElement::src() const 0364 { 0365 if (!impl) { 0366 return DOMString(); 0367 } 0368 const DOMString s = ((ElementImpl *)impl)->getAttribute(ATTR_SRC).trimSpaces(); 0369 return !s.isNull() ? impl->document()->completeURL(s.string()) : s; 0370 } 0371 0372 void HTMLImageElement::setSrc(const DOMString &value) 0373 { 0374 if (impl) { 0375 ((ElementImpl *)impl)->setAttribute(ATTR_SRC, value); 0376 } 0377 } 0378 0379 DOMString HTMLImageElement::useMap() const 0380 { 0381 if (!impl) { 0382 return DOMString(); 0383 } 0384 return ((ElementImpl *)impl)->getAttribute(ATTR_USEMAP); 0385 } 0386 0387 void HTMLImageElement::setUseMap(const DOMString &value) 0388 { 0389 if (impl) { 0390 ((ElementImpl *)impl)->setAttribute(ATTR_USEMAP, value); 0391 } 0392 } 0393 0394 long HTMLImageElement::vspace() const 0395 { 0396 if (!impl) { 0397 return 0; 0398 } 0399 // ### return actual vspace 0400 return ((ElementImpl *)impl)->getAttribute(ATTR_VSPACE).toInt(); 0401 } 0402 0403 void HTMLImageElement::setVspace(long value) 0404 { 0405 if (impl) { 0406 static_cast<ElementImpl *>(impl)->setAttribute(ATTR_VSPACE, QString::number(value)); 0407 } 0408 } 0409 0410 long HTMLImageElement::width() const 0411 { 0412 if (!impl) { 0413 return 0; 0414 } 0415 return static_cast<HTMLImageElementImpl *>(impl)->width(); 0416 } 0417 0418 void HTMLImageElement::setWidth(long value) 0419 { 0420 if (impl) { 0421 ((HTMLImageElementImpl *)impl)->setWidth(value); 0422 } 0423 } 0424 0425 long HTMLImageElement::x() const 0426 { 0427 if (impl) { 0428 return static_cast<const HTMLImageElementImpl *>(impl)->x(); 0429 } 0430 return 0; 0431 } 0432 0433 long HTMLImageElement::y() const 0434 { 0435 if (impl) { 0436 return static_cast<const HTMLImageElementImpl *>(impl)->y(); 0437 } 0438 return 0; 0439 } 0440 0441 // -------------------------------------------------------------------------- 0442 0443 HTMLMapElement::HTMLMapElement() : HTMLElement() 0444 { 0445 } 0446 0447 HTMLMapElement::HTMLMapElement(const HTMLMapElement &other) : HTMLElement(other) 0448 { 0449 } 0450 0451 HTMLMapElement::HTMLMapElement(HTMLMapElementImpl *impl) : HTMLElement(impl) 0452 { 0453 } 0454 0455 HTMLMapElement &HTMLMapElement::operator = (const Node &other) 0456 { 0457 assignOther(other, ID_MAP); 0458 return *this; 0459 } 0460 0461 HTMLMapElement &HTMLMapElement::operator = (const HTMLMapElement &other) 0462 { 0463 HTMLElement::operator = (other); 0464 return *this; 0465 } 0466 0467 HTMLMapElement::~HTMLMapElement() 0468 { 0469 } 0470 0471 HTMLCollection HTMLMapElement::areas() const 0472 { 0473 if (!impl) { 0474 return HTMLCollection(); 0475 } 0476 return HTMLCollection(((HTMLMapElementImpl *)impl)->areas()); 0477 } 0478 0479 DOMString HTMLMapElement::name() const 0480 { 0481 if (!impl) { 0482 return DOMString(); 0483 } 0484 return ((ElementImpl *)impl)->getAttribute(ATTR_NAME); 0485 } 0486 0487 void HTMLMapElement::setName(const DOMString &value) 0488 { 0489 if (impl) { 0490 ((ElementImpl *)impl)->setAttribute(ATTR_NAME, value); 0491 } 0492 } 0493