khtml Library API Documentation

kjs_html.cpp

00001 // -*- c-basic-offset: 2 -*-
00002 /*
00003  *  This file is part of the KDE libraries
00004  *  Copyright (C) 1999-2002 Harri Porten (porten@kde.org)
00005  *  Copyright (C) 2001-2003 David Faure (faure@kde.org)
00006  *  Copyright (C) 2003 Apple Computer, Inc.
00007  *
00008  *  This library is free software; you can redistribute it and/or
00009  *  modify it under the terms of the GNU Library General Public
00010  *  License as published by the Free Software Foundation; either
00011  *  version 2 of the License, or (at your option) any later version.
00012  *
00013  *  This library is distributed in the hope that it will be useful,
00014  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00015  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00016  *  Library General Public License for more details.
00017  *
00018  *  You should have received a copy of the GNU Library General Public
00019  *  License along with this library; if not, write to the Free Software
00020  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00021  */
00022 
00023 #include "misc/loader.h"
00024 #include "dom/html_block.h"
00025 #include "dom/html_head.h"
00026 #include "dom/html_image.h"
00027 #include "dom/html_inline.h"
00028 #include "dom/html_list.h"
00029 #include "dom/html_table.h"
00030 #include "dom/html_object.h"
00031 #include "dom/dom_exception.h"
00032 
00033 // ### HACK
00034 #include "html/html_baseimpl.h"
00035 #include "html/html_documentimpl.h"
00036 #include "html/html_imageimpl.h"
00037 #include "html/html_miscimpl.h"
00038 #include "xml/dom2_eventsimpl.h"
00039 
00040 #include <kparts/browserextension.h>
00041 
00042 #include "khtml_part.h"
00043 #include "khtmlview.h"
00044 
00045 #include "ecma/kjs_css.h"
00046 #include "ecma/kjs_events.h"
00047 #include "ecma/kjs_html.h"
00048 #include "ecma/kjs_window.h"
00049 #include "kjs_html.lut.h"
00050 
00051 #include "misc/htmltags.h"
00052 #include "misc/htmlattrs.h"
00053 #include "rendering/render_object.h"
00054 #include "rendering/render_canvas.h"
00055 #include "rendering/render_frames.h"
00056 #include "rendering/render_layer.h"
00057 
00058 #include "kmessagebox.h"
00059 #include <kstringhandler.h>
00060 #include <klocale.h>
00061 
00062 #include <kdebug.h>
00063 
00064 using namespace KJS;
00065 
00066 IMPLEMENT_PROTOFUNC_DOM(HTMLDocFunction)
00067 
00068 Value KJS::HTMLDocFunction::tryCall(ExecState *exec, Object &thisObj, const List &args)
00069 {
00070   KJS_CHECK_THIS( HTMLDocument, thisObj );
00071 
00072   DOM::HTMLDocument doc = static_cast<KJS::HTMLDocument *>(thisObj.imp())->toDocument();
00073 
00074   switch (id) {
00075   case HTMLDocument::Clear: // even IE doesn't support that one...
00076     //doc.clear(); // TODO
00077     return Undefined();
00078   case HTMLDocument::Open:
00079     if (args.size() >= 3) // IE extension for document.open: it means window.open if it has 3 args or more
00080     {
00081       KHTMLView *view = static_cast<DOM::DocumentImpl*>(doc.handle())->view();
00082       if ( view && view->part() ) {
00083         Window* win = Window::retrieveWindow(view->part());
00084         if( win ) {
00085           win->openWindow(exec, args);
00086         }
00087       }
00088     }
00089 
00090     doc.open();
00091     return Undefined();
00092   case HTMLDocument::Close:
00093     // see khtmltests/ecma/tokenizer-script-recursion.html
00094     doc.close();
00095     return Undefined();
00096   case HTMLDocument::Write:
00097   case HTMLDocument::WriteLn: {
00098     // DOM only specifies single string argument, but NS & IE allow multiple
00099     // or no arguments
00100     UString str = "";
00101     for (int i = 0; i < args.size(); i++)
00102       str += args[i].toString(exec);
00103     if (id == HTMLDocument::WriteLn)
00104       str += "\n";
00105 #ifdef KJS_VERBOSE
00106     kdDebug(6070) << "document.write: " << str.string().string() << endl;
00107 #endif
00108     doc.write(str.string());
00109     return Undefined();
00110   }
00111   case HTMLDocument::GetElementsByName:
00112     return getDOMNodeList(exec,doc.getElementsByName(args[0].toString(exec).string()));
00113   case HTMLDocument::GetSelection: {
00114     // NS4 and Mozilla specific. IE uses document.selection.createRange()
00115     // http://docs.sun.com/source/816-6408-10/document.htm#1195981
00116     KHTMLView *view = static_cast<DOM::DocumentImpl*>(doc.handle())->view();
00117     if ( view && view->part() )
00118        return String(view->part()->selectedText());
00119     else
00120        return Undefined();
00121   }
00122   case HTMLDocument::CaptureEvents:
00123   case HTMLDocument::ReleaseEvents:
00124     // Do nothing for now. These are NS-specific legacy calls.
00125     break;
00126   }
00127 
00128   return Undefined();
00129 }
00130 
00131 const ClassInfo KJS::HTMLDocument::info =
00132   { "HTMLDocument", &DOMDocument::info, &HTMLDocumentTable, 0 };
00133 /* Source for HTMLDocumentTable.
00134 @begin HTMLDocumentTable 31
00135   title         HTMLDocument::Title     DontDelete
00136   referrer      HTMLDocument::Referrer      DontDelete|ReadOnly
00137   domain        HTMLDocument::Domain        DontDelete
00138   URL           HTMLDocument::URL       DontDelete|ReadOnly
00139   body          HTMLDocument::Body      DontDelete
00140   location      HTMLDocument::Location      DontDelete
00141   cookie        HTMLDocument::Cookie        DontDelete
00142   images        HTMLDocument::Images        DontDelete|ReadOnly
00143   applets       HTMLDocument::Applets       DontDelete|ReadOnly
00144   links         HTMLDocument::Links     DontDelete|ReadOnly
00145   forms         HTMLDocument::Forms     DontDelete|ReadOnly
00146   anchors       HTMLDocument::Anchors       DontDelete|ReadOnly
00147   scripts       HTMLDocument::Scripts       DontDelete|ReadOnly
00148   all           HTMLDocument::All       DontDelete|ReadOnly
00149   clear         HTMLDocument::Clear     DontDelete|Function 0
00150   open          HTMLDocument::Open      DontDelete|Function 0
00151   close         HTMLDocument::Close     DontDelete|Function 0
00152   write         HTMLDocument::Write     DontDelete|Function 1
00153   writeln       HTMLDocument::WriteLn       DontDelete|Function 1
00154   getElementsByName HTMLDocument::GetElementsByName DontDelete|Function 1
00155   getSelection  HTMLDocument::GetSelection  DontDelete|Function 1
00156   captureEvents     HTMLDocument::CaptureEvents DontDelete|Function 0
00157   releaseEvents     HTMLDocument::ReleaseEvents DontDelete|Function 0
00158   bgColor       HTMLDocument::BgColor       DontDelete
00159   fgColor       HTMLDocument::FgColor       DontDelete
00160   alinkColor        HTMLDocument::AlinkColor    DontDelete
00161   linkColor     HTMLDocument::LinkColor     DontDelete
00162   vlinkColor        HTMLDocument::VlinkColor    DontDelete
00163   lastModified      HTMLDocument::LastModified  DontDelete|ReadOnly
00164   height        HTMLDocument::Height        DontDelete|ReadOnly
00165   width         HTMLDocument::Width     DontDelete|ReadOnly
00166   dir           HTMLDocument::Dir       DontDelete
00167   compatMode        HTMLDocument::CompatMode    DontDelete|ReadOnly
00168 #IE extension
00169   frames        HTMLDocument::Frames        DontDelete|ReadOnly
00170 #NS4 extension
00171 #  layers       HTMLDocument::Layers        DontDelete|ReadOnly
00172 #potentially obsolete array properties
00173 # plugins
00174 # tags
00175 #potentially obsolete properties
00176 # embeds
00177 # ids
00178 @end
00179 */
00180 
00181 void NamedTagLengthDeterminer::operator () (NodeImpl *start) {
00182   for(NodeImpl *n = start->firstChild(); n != 0; n = n->nextSibling())
00183     if ( n->nodeType() == Node::ELEMENT_NODE ) {
00184       for (int i = 0; i < nrTags; i++)
00185         if (n->id() == tags[i].id &&
00186             static_cast<ElementImpl *>(n)->getAttribute(ATTR_NAME) == name) {
00187           tags[i].length++;
00188           tags[i].last = n;   // cache this NodeImpl*
00189           nrTags = i+1;       // forget about Tags with lower preference
00190           break;
00191         }
00192       (*this)(n);
00193     }
00194 }
00195 
00196 KJS::HTMLDocument::HTMLDocument(ExecState *exec, const DOM::HTMLDocument& d)
00197   /*TODO pass HTMLDocumentProto::self(exec), but it needs to access DOMDocumentProto...*/
00198   : DOMDocument(exec, d) { }
00199 
00200 bool KJS::HTMLDocument::hasProperty(ExecState *exec, const Identifier &p) const
00201 {
00202 #ifdef KJS_VERBOSE
00203   //kdDebug(6070) << "KJS::HTMLDocument::hasProperty " << p.qstring() << endl;
00204 #endif
00205   DOM::HTMLDocument doc = static_cast<DOM::HTMLDocument>(node);
00206   KHTMLView *view = static_cast<DOM::DocumentImpl*>(doc.handle())->view();
00207   Window* win = view && view->part() ? Window::retrieveWindow(view->part()) : 0L;
00208   if ( !win || !win->isSafeScript(exec) )
00209     return false;
00210 
00211   // Keep in sync with tryGet
00212   NamedTagLengthDeterminer::TagLength tags[4] = {
00213       {ID_IMG, 0, 0L}, {ID_FORM, 0, 0L}, {ID_APPLET, 0, 0L}, {ID_LAYER, 0, 0L}
00214   };
00215   NamedTagLengthDeterminer(p.string(), tags, 4)(doc.handle());
00216   for (int i = 0; i < 4; i++)
00217     if (tags[i].length > 0)
00218         return true;
00219 
00220   if ( view && view->part() )
00221   {
00222     KHTMLPart *kp = view->part()->findFrame( p.qstring() );
00223     if (kp)
00224       return true;
00225   }
00226 
00227   return DOMDocument::hasProperty(exec, p);
00228 }
00229 
00230 Value KJS::HTMLDocument::tryGet(ExecState *exec, const Identifier &propertyName) const
00231 {
00232 #ifdef KJS_VERBOSE
00233   kdDebug(6070) << "KJS::HTMLDocument::tryGet " << propertyName.qstring() << endl;
00234 #endif
00235 
00236   DOM::HTMLDocument doc = static_cast<DOM::HTMLDocument>(node);
00237   KHTMLView *view = static_cast<DOM::DocumentImpl*>(doc.handle())->view();
00238 
00239   Window* win = view && view->part() ? Window::retrieveWindow(view->part()) : 0L;
00240   if ( !win || !win->isSafeScript(exec) )
00241     return Undefined();
00242 
00243   // Check for images with name==propertyName, return item or list if found
00244   // We don't use the images collection because it looks for id=p and name=p, we only want name=p
00245   // Check for forms with name==propertyName, return item or list if found
00246   // Note that document.myform should only look at forms
00247   // Check for applets with name==propertyName, return item or list if found
00248 
00249   NamedTagLengthDeterminer::TagLength tags[4] = {
00250     {ID_IMG, 0, 0L}, {ID_FORM, 0, 0L}, {ID_APPLET, 0, 0L}, {ID_LAYER, 0, 0L}
00251   };
00252   NamedTagLengthDeterminer(propertyName.string(), tags, 4)(doc.handle());
00253   for (int i = 0; i < 4; i++)
00254     if (tags[i].length > 0) {
00255       if (tags[i].length == 1)
00256         return getDOMNode(exec, tags[i].last);
00257       // Get all the items with the same name
00258       return getDOMNodeList(exec, DOM::NodeList(new DOM::NamedTagNodeListImpl(doc.handle(), tags[i].id, propertyName.string())));
00259     }
00260 
00261   // Check for frames/iframes with name==propertyName
00262   if ( view && view->part() )
00263   {
00264     // ###### TODO return a collection in case several frames have the same name
00265     // (IE does that). Hard to do with findFrame :}
00266     KHTMLPart *kp = view->part()->findFrame( propertyName.qstring() );
00267     if (kp)
00268       return Window::retrieve(kp);
00269   }
00270 
00271   const HashEntry* entry = Lookup::findEntry(&HTMLDocumentTable, propertyName);
00272   if (entry) {
00273     switch (entry->value) {
00274     case Title:
00275       return String(doc.title());
00276     case Referrer:
00277       return String(doc.referrer());
00278     case Domain:
00279       return String(doc.domain());
00280     case URL:
00281       return String(doc.URL());
00282     case Body:
00283       return getDOMNode(exec,doc.body());
00284     case Location:
00285       if (win)
00286         return Value(win->location());
00287       else
00288         return Undefined();
00289     case Cookie:
00290       return String(doc.cookie());
00291     case Images:
00292       return getHTMLCollection(exec,doc.images());
00293     case Applets:
00294       return getHTMLCollection(exec,doc.applets());
00295     case Links:
00296       return getHTMLCollection(exec,doc.links());
00297     case Forms:
00298       return getHTMLCollection(exec,doc.forms());
00299     case Layers:
00300       return Undefined();
00301       // ### Should not be hidden when we emulate Netscape4
00302       //return getHTMLCollection(exec,doc.layers(), true);
00303     case Anchors:
00304       return getHTMLCollection(exec,doc.anchors());
00305     case Scripts: // TODO (IE-specific)
00306     {
00307       // Disable document.scripts unless we try to be IE-compatible
00308       // Especially since it's not implemented, so
00309       // if (document.scripts) shouldn't return true.
00310       if ( exec->interpreter()->compatMode() != Interpreter::IECompat )
00311         return Undefined();
00312       // To be implemented. Meanwhile, return an object with a length property set to 0
00313       // This gets some code going on IE-specific pages.
00314       // The script object isn't really simple to implement though
00315       // (http://msdn.microsoft.com/workshop/author/dhtml/reference/objects/script.asp)
00316       kdDebug(6070) << "WARNING: KJS::HTMLDocument document.scripts called - not implemented" << endl;
00317       Object obj( new ObjectImp() );
00318       obj.put( exec, lengthPropertyName, Number(0) );
00319       return obj;
00320     }
00321     case All:
00322       // Disable document.all when we try to be Netscape-compatible
00323       if ( exec->interpreter()->compatMode() == Interpreter::NetscapeCompat )
00324         return Undefined();
00325       return getHTMLCollection(exec,doc.all());
00326     case Clear:
00327     case Open:
00328     case Close:
00329     case Write:
00330     case WriteLn:
00331     case GetElementsByName:
00332     case GetSelection:
00333     case CaptureEvents:
00334     case ReleaseEvents:
00335       return lookupOrCreateFunction<HTMLDocFunction>( exec, propertyName, this, entry->value, entry->params, entry->attr );
00336     case CompatMode:
00337       return String(static_cast<HTMLDocumentImpl *>(doc.handle())->parseMode()
00338               == DocumentImpl::Compat ? "BackCompat" : "CSS1Compat");
00339     }
00340   }
00341   // Look for overrides
00342   ValueImp * val = ObjectImp::getDirect(propertyName);
00343   if (val)
00344     return Value(val);
00345 
00346   DOM::HTMLBodyElement body = doc.body();
00347   if (entry) {
00348     switch (entry->value) {
00349     case BgColor:
00350       return String(body.bgColor());
00351     case FgColor:
00352       return String(body.text());
00353     case AlinkColor:
00354       return String(body.aLink());
00355     case LinkColor:
00356       return String(body.link());
00357     case VlinkColor:
00358       return String(body.vLink());
00359     case LastModified:
00360       return String(doc.lastModified());
00361     case Height: // NS-only, not available in IE
00362       return Number(view ? view->contentsHeight() : 0);
00363     case Width: // NS-only, not available in IE
00364       return Number(view ? view->contentsWidth() : 0);
00365     case Dir:
00366       return String(body.dir());
00367     case Frames:
00368       if ( win )
00369         return Value(win->frames(exec));
00370       else
00371         return Undefined();
00372     }
00373   }
00374   if (DOMDocument::hasProperty(exec, propertyName))
00375     return DOMDocument::tryGet(exec, propertyName);
00376 
00377   // allow shortcuts like 'document.Applet1' instead of document.applets.Applet1
00378   if (doc.isHTMLDocument()) { // might be XML
00379     DOM::HTMLCollection coll = doc.applets();
00380     DOM::HTMLElement element = coll.namedItem(propertyName.string());
00381     if (!element.isNull()) {
00382       return getDOMNode(exec,element);
00383     }
00384 
00385     DOM::HTMLCollection coll2 = doc.layers();
00386     DOM::HTMLElement element2 = coll2.namedItem(propertyName.string());
00387     if (!element2.isNull()) {
00388       return getDOMNode(exec,element2);
00389     }
00390   }
00391 #ifdef KJS_VERBOSE
00392   kdDebug(6070) << "KJS::HTMLDocument::tryGet " << propertyName.qstring() << " not found" << endl;
00393 #endif
00394   return Undefined();
00395 }
00396 
00397 void KJS::HTMLDocument::tryPut(ExecState *exec, const Identifier &propertyName, const Value& value, int attr)
00398 {
00399 #ifdef KJS_VERBOSE
00400   kdDebug(6070) << "KJS::HTMLDocument::tryPut " << propertyName.qstring() << endl;
00401 #endif
00402   KHTMLView *view = static_cast<DOM::DocumentImpl*>(node.handle())->view();
00403 
00404   Window* win = view && view->part() ? Window::retrieveWindow(view->part()) : 0L;
00405   if ( !win || !win->isSafeScript(exec) )
00406     return;
00407 
00408   DOMObjectLookupPut<HTMLDocument, DOMDocument>( exec, propertyName, value, attr, &HTMLDocumentTable, this );
00409 }
00410 
00411 void KJS::HTMLDocument::putValueProperty(ExecState *exec, int token, const Value& value, int /*attr*/)
00412 {
00413   DOM::HTMLDocument doc = static_cast<DOM::HTMLDocument>(node);
00414 
00415   DOM::HTMLBodyElement body = doc.body();
00416   DOM::DOMString val = value.toString(exec).string();
00417 
00418   switch (token) {
00419   case Title:
00420     if (doc.title() != val) doc.setTitle(val);
00421     break;
00422   case Body: {
00423     DOMNode *node = new DOMNode(exec, KJS::toNode(value));
00424     // This is required to avoid leaking the node.
00425     Value nodeValue(node);
00426     doc.setBody(node->toNode());
00427     break;
00428   }
00429   case Domain: { // not part of the DOM
00430     DOM::HTMLDocumentImpl* docimpl = static_cast<DOM::HTMLDocumentImpl*>(doc.handle());
00431     if (docimpl)
00432       docimpl->setDomain(val);
00433     break;
00434   }
00435   case Cookie:
00436     doc.setCookie(val);
00437     break;
00438   case Location:
00439   {
00440     KHTMLView *view = static_cast<DOM::DocumentImpl*>(doc.handle())->view();
00441     if ( view )
00442       Window::retrieveWindow(view->part())->goURL(exec, value.toString(exec).qstring(), false /*don't lock history*/);
00443     break;
00444   }
00445   case BgColor:
00446     if (body.bgColor() != val) body.setBgColor(val);
00447     break;
00448   case FgColor:
00449     if (body.text() != val) body.setText(val);
00450     break;
00451   case AlinkColor:
00452     if (body.aLink() != val) body.setALink(val);
00453     break;
00454   case LinkColor:
00455     if (body.link() != val) body.setLink(val);
00456     break;
00457   case VlinkColor:
00458     if (body.vLink() != val) body.setVLink(val);
00459     break;
00460   case Dir:
00461     body.setDir(val);
00462     break;
00463   default:
00464     kdDebug(6070) << "WARNING: HTMLDocument::putValueProperty unhandled token " << token << endl;
00465   }
00466 }
00467 
00468 // -------------------------------------------------------------------------
00469 
00470 const ClassInfo KJS::HTMLElement::info = { "HTMLElement", &DOMElement::info, &HTMLElementTable, 0 };
00471 const ClassInfo KJS::HTMLElement::html_info = { "HTMLHtmlElement", &KJS::HTMLElement::info, &HTMLHtmlElementTable, 0 };
00472 const ClassInfo KJS::HTMLElement::head_info = { "HTMLHeadElement", &KJS::HTMLElement::info, &HTMLHeadElementTable, 0 };
00473 const ClassInfo KJS::HTMLElement::link_info = { "HTMLLinkElement", &KJS::HTMLElement::info, &HTMLLinkElementTable, 0 };
00474 const ClassInfo KJS::HTMLElement::title_info = { "HTMLTitleElement", &KJS::HTMLElement::info, &HTMLTitleElementTable, 0 };
00475 const ClassInfo KJS::HTMLElement::meta_info = { "HTMLMetaElement", &KJS::HTMLElement::info, &HTMLMetaElementTable, 0 };
00476 const ClassInfo KJS::HTMLElement::base_info = { "HTMLBaseElement", &KJS::HTMLElement::info, &HTMLBaseElementTable, 0 };
00477 const ClassInfo KJS::HTMLElement::isIndex_info = { "HTMLIsIndexElement", &KJS::HTMLElement::info, &HTMLIsIndexElementTable, 0 };
00478 const ClassInfo KJS::HTMLElement::style_info = { "HTMLStyleElement", &KJS::HTMLElement::info, &HTMLStyleElementTable, 0 };
00479 const ClassInfo KJS::HTMLElement::body_info = { "HTMLBodyElement", &KJS::HTMLElement::info, &HTMLBodyElementTable, 0 };
00480 const ClassInfo KJS::HTMLElement::form_info = { "HTMLFormElement", &KJS::HTMLElement::info, &HTMLFormElementTable, 0 };
00481 const ClassInfo KJS::HTMLElement::select_info = { "HTMLSelectElement", &KJS::HTMLElement::info, &HTMLSelectElementTable, 0 };
00482 const ClassInfo KJS::HTMLElement::optGroup_info = { "HTMLOptGroupElement", &KJS::HTMLElement::info, &HTMLOptGroupElementTable, 0 };
00483 const ClassInfo KJS::HTMLElement::option_info = { "HTMLOptionElement", &KJS::HTMLElement::info, &HTMLOptionElementTable, 0 };
00484 const ClassInfo KJS::HTMLElement::input_info = { "HTMLInputElement", &KJS::HTMLElement::info, &HTMLInputElementTable, 0 };
00485 const ClassInfo KJS::HTMLElement::textArea_info = { "HTMLTextAreaElement", &KJS::HTMLElement::info, &HTMLTextAreaElementTable, 0 };
00486 const ClassInfo KJS::HTMLElement::button_info = { "HTMLButtonElement", &KJS::HTMLElement::info, &HTMLButtonElementTable, 0 };
00487 const ClassInfo KJS::HTMLElement::label_info = { "HTMLLabelElement", &KJS::HTMLElement::info, &HTMLLabelElementTable, 0 };
00488 const ClassInfo KJS::HTMLElement::fieldSet_info = { "HTMLFieldSetElement", &KJS::HTMLElement::info, &HTMLFieldSetElementTable, 0 };
00489 const ClassInfo KJS::HTMLElement::legend_info = { "HTMLLegendElement", &KJS::HTMLElement::info, &HTMLLegendElementTable, 0 };
00490 const ClassInfo KJS::HTMLElement::ul_info = { "HTMLUListElement", &KJS::HTMLElement::info, &HTMLUListElementTable, 0 };
00491 const ClassInfo KJS::HTMLElement::ol_info = { "HTMLOListElement", &KJS::HTMLElement::info, &HTMLOListElementTable, 0 };
00492 const ClassInfo KJS::HTMLElement::dl_info = { "HTMLDListElement", &KJS::HTMLElement::info, &HTMLDListElementTable, 0 };
00493 const ClassInfo KJS::HTMLElement::dir_info = { "HTMLDirectoryElement", &KJS::HTMLElement::info, &HTMLDirectoryElementTable, 0 };
00494 const ClassInfo KJS::HTMLElement::menu_info = { "HTMLMenuElement", &KJS::HTMLElement::info, &HTMLMenuElementTable, 0 };
00495 const ClassInfo KJS::HTMLElement::li_info = { "HTMLLIElement", &KJS::HTMLElement::info, &HTMLLIElementTable, 0 };
00496 const ClassInfo KJS::HTMLElement::div_info = { "HTMLDivElement", &KJS::HTMLElement::info, &HTMLDivElementTable, 0 };
00497 const ClassInfo KJS::HTMLElement::p_info = { "HTMLParagraphElement", &KJS::HTMLElement::info, &HTMLParagraphElementTable, 0 };
00498 const ClassInfo KJS::HTMLElement::heading_info = { "HTMLHeadingElement", &KJS::HTMLElement::info, &HTMLHeadingElementTable, 0 };
00499 const ClassInfo KJS::HTMLElement::blockQuote_info = { "HTMLBlockQuoteElement", &KJS::HTMLElement::info, &HTMLBlockQuoteElementTable, 0 };
00500 const ClassInfo KJS::HTMLElement::q_info = { "HTMLQuoteElement", &KJS::HTMLElement::info, &HTMLQuoteElementTable, 0 };
00501 const ClassInfo KJS::HTMLElement::pre_info = { "HTMLPreElement", &KJS::HTMLElement::info, &HTMLPreElementTable, 0 };
00502 const ClassInfo KJS::HTMLElement::br_info = { "HTMLBRElement", &KJS::HTMLElement::info, &HTMLBRElementTable, 0 };
00503 const ClassInfo KJS::HTMLElement::baseFont_info = { "HTMLBaseFontElement", &KJS::HTMLElement::info, &HTMLBaseFontElementTable, 0 };
00504 const ClassInfo KJS::HTMLElement::font_info = { "HTMLFontElement", &KJS::HTMLElement::info, &HTMLFontElementTable, 0 };
00505 const ClassInfo KJS::HTMLElement::hr_info = { "HTMLHRElement", &KJS::HTMLElement::info, &HTMLHRElementTable, 0 };
00506 const ClassInfo KJS::HTMLElement::mod_info = { "HTMLModElement", &KJS::HTMLElement::info, &HTMLModElementTable, 0 };
00507 const ClassInfo KJS::HTMLElement::a_info = { "HTMLAnchorElement", &KJS::HTMLElement::info, &HTMLAnchorElementTable, 0 };
00508 const ClassInfo KJS::HTMLElement::img_info = { "HTMLImageElement", &KJS::HTMLElement::info, &HTMLImageElementTable, 0 };
00509 const ClassInfo KJS::HTMLElement::object_info = { "HTMLObjectElement", &KJS::HTMLElement::info, &HTMLObjectElementTable, 0 };
00510 const ClassInfo KJS::HTMLElement::param_info = { "HTMLParamElement", &KJS::HTMLElement::info, &HTMLParamElementTable, 0 };
00511 const ClassInfo KJS::HTMLElement::applet_info = { "HTMLAppletElement", &KJS::HTMLElement::info, &HTMLAppletElementTable, 0 };
00512 const ClassInfo KJS::HTMLElement::map_info = { "HTMLMapElement", &KJS::HTMLElement::info, &HTMLMapElementTable, 0 };
00513 const ClassInfo KJS::HTMLElement::area_info = { "HTMLAreaElement", &KJS::HTMLElement::info, &HTMLAreaElementTable, 0 };
00514 const ClassInfo KJS::HTMLElement::script_info = { "HTMLScriptElement", &KJS::HTMLElement::info, &HTMLScriptElementTable, 0 };
00515 const ClassInfo KJS::HTMLElement::table_info = { "HTMLTableElement", &KJS::HTMLElement::info, &HTMLTableElementTable, 0 };
00516 const ClassInfo KJS::HTMLElement::caption_info = { "HTMLTableCaptionElement", &KJS::HTMLElement::info, &HTMLTableCaptionElementTable, 0 };
00517 const ClassInfo KJS::HTMLElement::col_info = { "HTMLTableColElement", &KJS::HTMLElement::info, &HTMLTableColElementTable, 0 };
00518 const ClassInfo KJS::HTMLElement::tablesection_info = { "HTMLTableSectionElement", &KJS::HTMLElement::info, &HTMLTableSectionElementTable, 0 };
00519 const ClassInfo KJS::HTMLElement::tr_info = { "HTMLTableRowElement", &KJS::HTMLElement::info, &HTMLTableRowElementTable, 0 };
00520 const ClassInfo KJS::HTMLElement::tablecell_info = { "HTMLTableCellElement", &KJS::HTMLElement::info, &HTMLTableCellElementTable, 0 };
00521 const ClassInfo KJS::HTMLElement::frameSet_info = { "HTMLFrameSetElement", &KJS::HTMLElement::info, &HTMLFrameSetElementTable, 0 };
00522 const ClassInfo KJS::HTMLElement::frame_info = { "HTMLFrameElement", &KJS::HTMLElement::info, &HTMLFrameElementTable, 0 };
00523 const ClassInfo KJS::HTMLElement::iFrame_info = { "HTMLIFrameElement", &KJS::HTMLElement::info, &HTMLIFrameElementTable, 0 };
00524 const ClassInfo KJS::HTMLElement::marquee_info = { "HTMLMarqueeElement", &KJS::HTMLElement::info, &HTMLMarqueeElementTable, 0 };
00525 const ClassInfo KJS::HTMLElement::layer_info = { "HTMLLayerElement", &KJS::HTMLElement::info, &HTMLLayerElementTable, 0 };
00526 
00527 const ClassInfo* KJS::HTMLElement::classInfo() const
00528 {
00529   DOM::HTMLElement element = static_cast<DOM::HTMLElement>(node);
00530   switch (element.elementId()) {
00531   case ID_HTML:
00532     return &html_info;
00533   case ID_HEAD:
00534     return &head_info;
00535   case ID_LINK:
00536     return &link_info;
00537   case ID_TITLE:
00538     return &title_info;
00539   case ID_META:
00540     return &meta_info;
00541   case ID_BASE:
00542     return &base_info;
00543   case ID_ISINDEX:
00544     return &isIndex_info;
00545   case ID_STYLE:
00546     return &style_info;
00547   case ID_BODY:
00548     return &body_info;
00549   case ID_FORM:
00550     return &form_info;
00551   case ID_SELECT:
00552     return &select_info;
00553   case ID_OPTGROUP:
00554     return &optGroup_info;
00555   case ID_OPTION:
00556     return &option_info;
00557   case ID_INPUT:
00558     return &input_info;
00559   case ID_TEXTAREA:
00560     return &textArea_info;
00561   case ID_BUTTON:
00562     return &button_info;
00563   case ID_LABEL:
00564     return &label_info;
00565   case ID_FIELDSET:
00566     return &fieldSet_info;
00567   case ID_LEGEND:
00568     return &legend_info;
00569   case ID_UL:
00570     return &ul_info;
00571   case ID_OL:
00572     return &ol_info;
00573   case ID_DL:
00574     return &dl_info;
00575   case ID_DIR:
00576     return &dir_info;
00577   case ID_MENU:
00578     return &menu_info;
00579   case ID_LI:
00580     return &li_info;
00581   case ID_DIV:
00582     return &div_info;
00583   case ID_P:
00584     return &p_info;
00585   case ID_H1:
00586   case ID_H2:
00587   case ID_H3:
00588   case ID_H4:
00589   case ID_H5:
00590   case ID_H6:
00591     return &heading_info;
00592   case ID_BLOCKQUOTE:
00593     return &blockQuote_info;
00594   case ID_Q:
00595     return &q_info;
00596   case ID_PRE:
00597     return &pre_info;
00598   case ID_BR:
00599     return &br_info;
00600   case ID_BASEFONT:
00601     return &baseFont_info;
00602   case ID_FONT:
00603     return &font_info;
00604   case ID_HR:
00605     return &hr_info;
00606   case ID_INS:
00607   case ID_DEL:
00608     return &mod_info;
00609   case ID_A:
00610     return &a_info;
00611   case ID_IMG:
00612     return &img_info;
00613   case ID_OBJECT:
00614     return &object_info;
00615   case ID_PARAM:
00616     return &param_info;
00617   case ID_APPLET:
00618     return &applet_info;
00619   case ID_MAP:
00620     return &map_info;
00621   case ID_AREA:
00622     return &area_info;
00623   case ID_SCRIPT:
00624     return &script_info;
00625   case ID_TABLE:
00626     return &table_info;
00627   case ID_CAPTION:
00628     return &caption_info;
00629   case ID_COL:
00630   case ID_COLGROUP:
00631     return &col_info;
00632   case ID_THEAD:
00633     return &tablesection_info;
00634   case ID_TBODY:
00635     return &tablesection_info;
00636   case ID_TFOOT:
00637     return &tablesection_info;
00638   case ID_TR:
00639     return &tr_info;
00640   case ID_TH:
00641     return &tablecell_info;
00642   case ID_TD:
00643     return &tablecell_info;
00644   case ID_FRAMESET:
00645     return &frameSet_info;
00646   case ID_FRAME:
00647     return &frame_info;
00648   case ID_IFRAME:
00649     return &iFrame_info;
00650   case ID_MARQUEE:
00651     return &marquee_info;
00652   case ID_LAYER:
00653     return &layer_info;
00654   default:
00655     return &info;
00656   }
00657 }
00658 /*
00659 @begin HTMLElementTable 11
00660   id        KJS::HTMLElement::ElementId DontDelete
00661   title     KJS::HTMLElement::ElementTitle  DontDelete
00662   lang      KJS::HTMLElement::ElementLang   DontDelete
00663   dir       KJS::HTMLElement::ElementDir    DontDelete
00664 ### isn't this "class" in the HTML spec?
00665   className KJS::HTMLElement::ElementClassName DontDelete
00666   innerHTML KJS::HTMLElement::ElementInnerHTML DontDelete
00667   innerText KJS::HTMLElement::ElementInnerText DontDelete
00668   document  KJS::HTMLElement::ElementDocument  DontDelete|ReadOnly
00669 # IE extension
00670   children  KJS::HTMLElement::ElementChildren  DontDelete|ReadOnly
00671   all           KJS::HTMLElement::ElementAll       DontDelete|ReadOnly
00672 @end
00673 @begin HTMLHtmlElementTable 1
00674   version   KJS::HTMLElement::HtmlVersion   DontDelete
00675 @end
00676 @begin HTMLHeadElementTable 1
00677   profile   KJS::HTMLElement::HeadProfile   DontDelete
00678 @end
00679 @begin HTMLLinkElementTable 11
00680   disabled  KJS::HTMLElement::LinkDisabled  DontDelete
00681   charset   KJS::HTMLElement::LinkCharset   DontDelete
00682   href      KJS::HTMLElement::LinkHref  DontDelete
00683   hreflang  KJS::HTMLElement::LinkHrefLang  DontDelete
00684   media     KJS::HTMLElement::LinkMedia DontDelete
00685   rel       KJS::HTMLElement::LinkRel       DontDelete
00686   rev       KJS::HTMLElement::LinkRev   DontDelete
00687   target    KJS::HTMLElement::LinkTarget    DontDelete
00688   type      KJS::HTMLElement::LinkType  DontDelete
00689   sheet     KJS::HTMLElement::LinkSheet DontDelete|ReadOnly
00690 @end
00691 @begin HTMLTitleElementTable 1
00692   text      KJS::HTMLElement::TitleText DontDelete
00693 @end
00694 @begin HTMLMetaElementTable 4
00695   content   KJS::HTMLElement::MetaContent   DontDelete
00696   httpEquiv KJS::HTMLElement::MetaHttpEquiv DontDelete
00697   name      KJS::HTMLElement::MetaName  DontDelete
00698   scheme    KJS::HTMLElement::MetaScheme    DontDelete
00699 @end
00700 @begin HTMLBaseElementTable 2
00701   href      KJS::HTMLElement::BaseHref  DontDelete
00702   target    KJS::HTMLElement::BaseTarget    DontDelete
00703 @end
00704 @begin HTMLIsIndexElementTable 2
00705   form      KJS::HTMLElement::IsIndexForm   DontDelete|ReadOnly
00706   prompt    KJS::HTMLElement::IsIndexPrompt DontDelete
00707 @end
00708 @begin HTMLStyleElementTable 4
00709   disabled  KJS::HTMLElement::StyleDisabled DontDelete
00710   media     KJS::HTMLElement::StyleMedia    DontDelete
00711   type      KJS::HTMLElement::StyleType DontDelete
00712   sheet     KJS::HTMLElement::StyleSheet    DontDelete|ReadOnly
00713 @end
00714 @begin HTMLBodyElementTable 8
00715   aLink     KJS::HTMLElement::BodyALink DontDelete
00716   background    KJS::HTMLElement::BodyBackground    DontDelete
00717   bgColor   KJS::HTMLElement::BodyBgColor   DontDelete
00718   link      KJS::HTMLElement::BodyLink  DontDelete
00719   text      KJS::HTMLElement::BodyText  DontDelete
00720   vLink     KJS::HTMLElement::BodyVLink DontDelete
00721 # IE extension
00722   scrollLeft    KJS::HTMLElement::BodyScrollLeft DontDelete
00723   scrollTop KJS::HTMLElement::BodyScrollTop  DontDelete
00724   scrollWidth   KJS::HTMLElement::BodyScrollWidth DontDelete|ReadOnly
00725   scrollHeight  KJS::HTMLElement::BodyScrollHeight DontDelete|ReadOnly
00726 @end
00727 @begin HTMLFormElementTable 11
00728 # Also supported, by name/index
00729   elements  KJS::HTMLElement::FormElements  DontDelete|ReadOnly
00730   length    KJS::HTMLElement::FormLength    DontDelete|ReadOnly
00731   name      KJS::HTMLElement::FormName  DontDelete
00732   acceptCharset KJS::HTMLElement::FormAcceptCharset DontDelete
00733   action    KJS::HTMLElement::FormAction    DontDelete
00734   encoding  KJS::HTMLElement::FormEncType   DontDelete
00735   enctype   KJS::HTMLElement::FormEncType   DontDelete
00736   method    KJS::HTMLElement::FormMethod    DontDelete
00737   target    KJS::HTMLElement::FormTarget    DontDelete
00738   submit    KJS::HTMLElement::FormSubmit    DontDelete|Function 0
00739   reset     KJS::HTMLElement::FormReset DontDelete|Function 0
00740 @end
00741 @begin HTMLSelectElementTable 11
00742 # Also supported, by index
00743   type      KJS::HTMLElement::SelectType    DontDelete|ReadOnly
00744   selectedIndex KJS::HTMLElement::SelectSelectedIndex   DontDelete
00745   value     KJS::HTMLElement::SelectValue   DontDelete
00746   length    KJS::HTMLElement::SelectLength  DontDelete
00747   form      KJS::HTMLElement::SelectForm    DontDelete|ReadOnly
00748   options   KJS::HTMLElement::SelectOptions DontDelete|ReadOnly
00749   disabled  KJS::HTMLElement::SelectDisabled    DontDelete
00750   multiple  KJS::HTMLElement::SelectMultiple    DontDelete
00751   name      KJS::HTMLElement::SelectName    DontDelete
00752   size      KJS::HTMLElement::SelectSize    DontDelete
00753   tabIndex  KJS::HTMLElement::SelectTabIndex    DontDelete
00754   add       KJS::HTMLElement::SelectAdd DontDelete|Function 2
00755   remove    KJS::HTMLElement::SelectRemove  DontDelete|Function 1
00756   blur      KJS::HTMLElement::SelectBlur    DontDelete|Function 0
00757   focus     KJS::HTMLElement::SelectFocus   DontDelete|Function 0
00758 @end
00759 @begin HTMLOptGroupElementTable 2
00760   disabled  KJS::HTMLElement::OptGroupDisabled  DontDelete
00761   label     KJS::HTMLElement::OptGroupLabel     DontDelete
00762 @end
00763 @begin HTMLOptionElementTable 8
00764   form      KJS::HTMLElement::OptionForm        DontDelete|ReadOnly
00765   defaultSelected KJS::HTMLElement::OptionDefaultSelected   DontDelete
00766   text      KJS::HTMLElement::OptionText        DontDelete
00767   index     KJS::HTMLElement::OptionIndex       DontDelete|ReadOnly
00768   disabled  KJS::HTMLElement::OptionDisabled    DontDelete
00769   label     KJS::HTMLElement::OptionLabel       DontDelete
00770   selected  KJS::HTMLElement::OptionSelected    DontDelete
00771   value     KJS::HTMLElement::OptionValue       DontDelete
00772 @end
00773 @begin HTMLInputElementTable 24
00774   defaultValue  KJS::HTMLElement::InputDefaultValue DontDelete
00775   defaultChecked KJS::HTMLElement::InputDefaultChecked  DontDelete
00776   form      KJS::HTMLElement::InputForm     DontDelete|ReadOnly
00777   accept    KJS::HTMLElement::InputAccept       DontDelete
00778   accessKey KJS::HTMLElement::InputAccessKey    DontDelete
00779   align     KJS::HTMLElement::InputAlign        DontDelete
00780   alt       KJS::HTMLElement::InputAlt      DontDelete
00781   checked   KJS::HTMLElement::InputChecked      DontDelete
00782   status    KJS::HTMLElement::InputChecked      DontDelete
00783   disabled  KJS::HTMLElement::InputDisabled     DontDelete
00784   maxLength KJS::HTMLElement::InputMaxLength    DontDelete
00785   name      KJS::HTMLElement::InputName     DontDelete
00786   readOnly  KJS::HTMLElement::InputReadOnly     DontDelete
00787   size      KJS::HTMLElement::InputSize     DontDelete
00788   src       KJS::HTMLElement::InputSrc      DontDelete
00789   tabIndex  KJS::HTMLElement::InputTabIndex     DontDelete
00790   type      KJS::HTMLElement::InputType     DontDelete
00791   useMap    KJS::HTMLElement::InputUseMap       DontDelete
00792   value     KJS::HTMLElement::InputValue        DontDelete
00793   blur      KJS::HTMLElement::InputBlur     DontDelete|Function 0
00794   focus     KJS::HTMLElement::InputFocus        DontDelete|Function 0
00795   select    KJS::HTMLElement::InputSelect       DontDelete|Function 0
00796   click     KJS::HTMLElement::InputClick        DontDelete|Function 0
00797 @end
00798 @begin HTMLTextAreaElementTable 13
00799   defaultValue  KJS::HTMLElement::TextAreaDefaultValue  DontDelete
00800   form      KJS::HTMLElement::TextAreaForm      DontDelete|ReadOnly
00801   accessKey KJS::HTMLElement::TextAreaAccessKey DontDelete
00802   cols      KJS::HTMLElement::TextAreaCols      DontDelete
00803   disabled  KJS::HTMLElement::TextAreaDisabled  DontDelete
00804   name      KJS::HTMLElement::TextAreaName      DontDelete
00805   readOnly  KJS::HTMLElement::TextAreaReadOnly  DontDelete
00806   rows      KJS::HTMLElement::TextAreaRows      DontDelete
00807   tabIndex  KJS::HTMLElement::TextAreaTabIndex  DontDelete
00808   type      KJS::HTMLElement::TextAreaType      DontDelete|ReadOnly
00809   value     KJS::HTMLElement::TextAreaValue     DontDelete
00810   blur      KJS::HTMLElement::TextAreaBlur      DontDelete|Function 0
00811   focus     KJS::HTMLElement::TextAreaFocus     DontDelete|Function 0
00812   select    KJS::HTMLElement::TextAreaSelect    DontDelete|Function 0
00813 @end
00814 @begin HTMLButtonElementTable 7
00815   form      KJS::HTMLElement::ButtonForm        DontDelete|ReadOnly
00816   accessKey KJS::HTMLElement::ButtonAccessKey   DontDelete
00817   disabled  KJS::HTMLElement::ButtonDisabled    DontDelete
00818   name      KJS::HTMLElement::ButtonName        DontDelete
00819   tabIndex  KJS::HTMLElement::ButtonTabIndex    DontDelete
00820   type      KJS::HTMLElement::ButtonType        DontDelete|ReadOnly
00821   value     KJS::HTMLElement::ButtonValue       DontDelete
00822 @end
00823 @begin HTMLLabelElementTable 3
00824   form      KJS::HTMLElement::LabelForm     DontDelete|ReadOnly
00825   accessKey KJS::HTMLElement::LabelAccessKey    DontDelete
00826   htmlFor   KJS::HTMLElement::LabelHtmlFor      DontDelete
00827 @end
00828 @begin HTMLFieldSetElementTable 1
00829   form      KJS::HTMLElement::FieldSetForm      DontDelete|ReadOnly
00830 @end
00831 @begin HTMLLegendElementTable 3
00832   form      KJS::HTMLElement::LegendForm        DontDelete|ReadOnly
00833   accessKey KJS::HTMLElement::LegendAccessKey   DontDelete
00834   align     KJS::HTMLElement::LegendAlign       DontDelete
00835 @end
00836 @begin HTMLUListElementTable 2
00837   compact   KJS::HTMLElement::UListCompact      DontDelete
00838   type      KJS::HTMLElement::UListType     DontDelete
00839 @end
00840 @begin HTMLOListElementTable 3
00841   compact   KJS::HTMLElement::OListCompact      DontDelete
00842   start     KJS::HTMLElement::OListStart        DontDelete
00843   type      KJS::HTMLElement::OListType     DontDelete
00844 @end
00845 @begin HTMLDListElementTable 1
00846   compact   KJS::HTMLElement::DListCompact      DontDelete
00847 @end
00848 @begin HTMLDirectoryElementTable 1
00849   compact   KJS::HTMLElement::DirectoryCompact  DontDelete
00850 @end
00851 @begin HTMLMenuElementTable 1
00852   compact   KJS::HTMLElement::MenuCompact       DontDelete
00853 @end
00854 @begin HTMLLIElementTable 2
00855   type      KJS::HTMLElement::LIType        DontDelete
00856   value     KJS::HTMLElement::LIValue       DontDelete
00857 @end
00858 @begin HTMLDivElementTable 1
00859   align     KJS::HTMLElement::DivAlign      DontDelete
00860 @end
00861 @begin HTMLParagraphElementTable 1
00862   align     KJS::HTMLElement::ParagraphAlign    DontDelete
00863 @end
00864 @begin HTMLHeadingElementTable 1
00865   align     KJS::HTMLElement::HeadingAlign      DontDelete
00866 @end
00867 @begin HTMLBlockQuoteElementTable 1
00868   cite      KJS::HTMLElement::BlockQuoteCite    DontDelete
00869 @end
00870 @begin HTMLQuoteElementTable 1
00871   cite      KJS::HTMLElement::QuoteCite     DontDelete
00872 @end
00873 @begin HTMLPreElementTable 1
00874   width     KJS::HTMLElement::PreWidth      DontDelete
00875 @end
00876 @begin HTMLBRElementTable 1
00877   clear     KJS::HTMLElement::BRClear       DontDelete
00878 @end
00879 @begin HTMLBaseFontElementTable 3
00880   color     KJS::HTMLElement::BaseFontColor     DontDelete
00881   face      KJS::HTMLElement::BaseFontFace      DontDelete
00882   size      KJS::HTMLElement::BaseFontSize      DontDelete
00883 @end
00884 @begin HTMLFontElementTable 3
00885   color     KJS::HTMLElement::FontColor     DontDelete
00886   face      KJS::HTMLElement::FontFace      DontDelete
00887   size      KJS::HTMLElement::FontSize      DontDelete
00888 @end
00889 @begin HTMLHRElementTable 4
00890   align     KJS::HTMLElement::HRAlign       DontDelete
00891   noShade   KJS::HTMLElement::HRNoShade     DontDelete
00892   size      KJS::HTMLElement::HRSize        DontDelete
00893   width     KJS::HTMLElement::HRWidth       DontDelete
00894 @end
00895 @begin HTMLModElementTable 2
00896   cite      KJS::HTMLElement::ModCite       DontDelete
00897   dateTime  KJS::HTMLElement::ModDateTime       DontDelete
00898 @end
00899 @begin HTMLAnchorElementTable 23
00900   accessKey KJS::HTMLElement::AnchorAccessKey   DontDelete
00901   charset   KJS::HTMLElement::AnchorCharset     DontDelete
00902   coords    KJS::HTMLElement::AnchorCoords      DontDelete
00903   href      KJS::HTMLElement::AnchorHref        DontDelete
00904   hreflang  KJS::HTMLElement::AnchorHrefLang    DontDelete
00905   hash      KJS::HTMLElement::AnchorHash        DontDelete|ReadOnly
00906   host      KJS::HTMLElement::AnchorHost        DontDelete|ReadOnly
00907   hostname  KJS::HTMLElement::AnchorHostname    DontDelete|ReadOnly
00908   name      KJS::HTMLElement::AnchorName        DontDelete
00909   pathname  KJS::HTMLElement::AnchorPathName    DontDelete|ReadOnly
00910   port      KJS::HTMLElement::AnchorPort        DontDelete|ReadOnly
00911   protocol  KJS::HTMLElement::AnchorProtocol    DontDelete|ReadOnly
00912   rel       KJS::HTMLElement::AnchorRel     DontDelete
00913   rev       KJS::HTMLElement::AnchorRev     DontDelete
00914   search    KJS::HTMLElement::AnchorSearch      DontDelete|ReadOnly
00915   shape     KJS::HTMLElement::AnchorShape       DontDelete
00916   tabIndex  KJS::HTMLElement::AnchorTabIndex    DontDelete
00917   target    KJS::HTMLElement::AnchorTarget      DontDelete
00918   text      KJS::HTMLElement::AnchorText        DontDelete|ReadOnly
00919   type      KJS::HTMLElement::AnchorType        DontDelete
00920   blur      KJS::HTMLElement::AnchorBlur        DontDelete|Function 0
00921   focus     KJS::HTMLElement::AnchorFocus       DontDelete|Function 0
00922 @end
00923 @begin HTMLImageElementTable 14
00924   name      KJS::HTMLElement::ImageName     DontDelete
00925   align     KJS::HTMLElement::ImageAlign        DontDelete
00926   alt       KJS::HTMLElement::ImageAlt      DontDelete
00927   border    KJS::HTMLElement::ImageBorder       DontDelete
00928   complete  KJS::HTMLElement::ImageComplete     DontDelete|ReadOnly
00929   height    KJS::HTMLElement::ImageHeight       DontDelete
00930   hspace    KJS::HTMLElement::ImageHspace       DontDelete
00931   isMap     KJS::HTMLElement::ImageIsMap        DontDelete
00932   longDesc  KJS::HTMLElement::ImageLongDesc     DontDelete
00933   src       KJS::HTMLElement::ImageSrc      DontDelete
00934   useMap    KJS::HTMLElement::ImageUseMap       DontDelete
00935   vspace    KJS::HTMLElement::ImageVspace       DontDelete
00936   width     KJS::HTMLElement::ImageWidth        DontDelete
00937   x         KJS::HTMLElement::ImageX        DontDelete|ReadOnly
00938   y         KJS::HTMLElement::ImageY        DontDelete|ReadOnly
00939 @end
00940 @begin HTMLObjectElementTable 20
00941   form        KJS::HTMLElement::ObjectForm        DontDelete|ReadOnly
00942   code        KJS::HTMLElement::ObjectCode        DontDelete
00943   align       KJS::HTMLElement::ObjectAlign       DontDelete
00944   archive     KJS::HTMLElement::ObjectArchive     DontDelete
00945   border      KJS::HTMLElement::ObjectBorder      DontDelete
00946   codeBase    KJS::HTMLElement::ObjectCodeBase    DontDelete
00947   codeType    KJS::HTMLElement::ObjectCodeType    DontDelete
00948   contentDocument KJS::HTMLElement::ObjectContentDocument DontDelete|ReadOnly
00949   data        KJS::HTMLElement::ObjectData        DontDelete
00950   declare     KJS::HTMLElement::ObjectDeclare     DontDelete
00951   height      KJS::HTMLElement::ObjectHeight      DontDelete
00952   hspace      KJS::HTMLElement::ObjectHspace      DontDelete
00953   name        KJS::HTMLElement::ObjectName        DontDelete
00954   standby     KJS::HTMLElement::ObjectStandby     DontDelete
00955   tabIndex    KJS::HTMLElement::ObjectTabIndex    DontDelete
00956   type        KJS::HTMLElement::ObjectType        DontDelete
00957   useMap      KJS::HTMLElement::ObjectUseMap      DontDelete
00958   vspace      KJS::HTMLElement::ObjectVspace      DontDelete
00959   width       KJS::HTMLElement::ObjectWidth       DontDelete
00960 @end
00961 @begin HTMLParamElementTable 4
00962   name      KJS::HTMLElement::ParamName     DontDelete
00963   type      KJS::HTMLElement::ParamType     DontDelete
00964   value     KJS::HTMLElement::ParamValue        DontDelete
00965   valueType KJS::HTMLElement::ParamValueType    DontDelete
00966 @end
00967 @begin HTMLAppletElementTable 11
00968   align     KJS::HTMLElement::AppletAlign       DontDelete
00969   alt       KJS::HTMLElement::AppletAlt     DontDelete
00970   archive   KJS::HTMLElement::AppletArchive     DontDelete
00971   code      KJS::HTMLElement::AppletCode        DontDelete
00972   codeBase  KJS::HTMLElement::AppletCodeBase    DontDelete
00973   height    KJS::HTMLElement::AppletHeight      DontDelete
00974   hspace    KJS::HTMLElement::AppletHspace      DontDelete
00975   name      KJS::HTMLElement::AppletName        DontDelete
00976   object    KJS::HTMLElement::AppletObject      DontDelete
00977   vspace    KJS::HTMLElement::AppletVspace      DontDelete
00978   width     KJS::HTMLElement::AppletWidth       DontDelete
00979 @end
00980 @begin HTMLMapElementTable 2
00981   areas     KJS::HTMLElement::MapAreas      DontDelete|ReadOnly
00982   name      KJS::HTMLElement::MapName       DontDelete
00983 @end
00984 @begin HTMLAreaElementTable 15
00985   accessKey KJS::HTMLElement::AreaAccessKey     DontDelete
00986   alt       KJS::HTMLElement::AreaAlt       DontDelete
00987   coords    KJS::HTMLElement::AreaCoords        DontDelete
00988   href      KJS::HTMLElement::AreaHref      DontDelete
00989   hash      KJS::HTMLElement::AreaHash      DontDelete|ReadOnly
00990   host      KJS::HTMLElement::AreaHost      DontDelete|ReadOnly
00991   hostname  KJS::HTMLElement::AreaHostName      DontDelete|ReadOnly
00992   pathname  KJS::HTMLElement::AreaPathName      DontDelete|ReadOnly
00993   port      KJS::HTMLElement::AreaPort      DontDelete|ReadOnly
00994   protocol  KJS::HTMLElement::AreaProtocol      DontDelete|ReadOnly
00995   search    KJS::HTMLElement::AreaSearch        DontDelete|ReadOnly
00996   noHref    KJS::HTMLElement::AreaNoHref        DontDelete
00997   shape     KJS::HTMLElement::AreaShape     DontDelete
00998   tabIndex  KJS::HTMLElement::AreaTabIndex      DontDelete
00999   target    KJS::HTMLElement::AreaTarget        DontDelete
01000 @end
01001 @begin HTMLScriptElementTable 7
01002   text      KJS::HTMLElement::ScriptText        DontDelete
01003   htmlFor   KJS::HTMLElement::ScriptHtmlFor     DontDelete
01004   event     KJS::HTMLElement::ScriptEvent       DontDelete
01005   charset   KJS::HTMLElement::ScriptCharset     DontDelete
01006   defer     KJS::HTMLElement::ScriptDefer       DontDelete
01007   src       KJS::HTMLElement::ScriptSrc     DontDelete
01008   type      KJS::HTMLElement::ScriptType        DontDelete
01009 @end
01010 @begin HTMLTableElementTable 23
01011   caption   KJS::HTMLElement::TableCaption      DontDelete
01012   tHead     KJS::HTMLElement::TableTHead        DontDelete
01013   tFoot     KJS::HTMLElement::TableTFoot        DontDelete
01014   rows      KJS::HTMLElement::TableRows     DontDelete|ReadOnly
01015   tBodies   KJS::HTMLElement::TableTBodies      DontDelete|ReadOnly
01016   align     KJS::HTMLElement::TableAlign        DontDelete
01017   bgColor   KJS::HTMLElement::TableBgColor      DontDelete
01018   border    KJS::HTMLElement::TableBorder       DontDelete
01019   cellPadding   KJS::HTMLElement::TableCellPadding  DontDelete
01020   cellSpacing   KJS::HTMLElement::TableCellSpacing  DontDelete
01021   frame     KJS::HTMLElement::TableFrame        DontDelete
01022   rules     KJS::HTMLElement::TableRules        DontDelete
01023   summary   KJS::HTMLElement::TableSummary      DontDelete
01024   width     KJS::HTMLElement::TableWidth        DontDelete
01025   createTHead   KJS::HTMLElement::TableCreateTHead  DontDelete|Function 0
01026   deleteTHead   KJS::HTMLElement::TableDeleteTHead  DontDelete|Function 0
01027   createTFoot   KJS::HTMLElement::TableCreateTFoot  DontDelete|Function 0
01028   deleteTFoot   KJS::HTMLElement::TableDeleteTFoot  DontDelete|Function 0
01029   createCaption KJS::HTMLElement::TableCreateCaption    DontDelete|Function 0
01030   deleteCaption KJS::HTMLElement::TableDeleteCaption    DontDelete|Function 0
01031   insertRow KJS::HTMLElement::TableInsertRow    DontDelete|Function 1
01032   deleteRow KJS::HTMLElement::TableDeleteRow    DontDelete|Function 1
01033 @end
01034 @begin HTMLTableCaptionElementTable 1
01035   align     KJS::HTMLElement::TableCaptionAlign DontDelete
01036 @end
01037 @begin HTMLTableColElementTable 7
01038   align     KJS::HTMLElement::TableColAlign     DontDelete
01039   ch        KJS::HTMLElement::TableColCh        DontDelete
01040   chOff     KJS::HTMLElement::TableColChOff     DontDelete
01041   span      KJS::HTMLElement::TableColSpan      DontDelete
01042   vAlign    KJS::HTMLElement::TableColVAlign    DontDelete
01043   width     KJS::HTMLElement::TableColWidth     DontDelete
01044 @end
01045 @begin HTMLTableSectionElementTable 7
01046   align     KJS::HTMLElement::TableSectionAlign     DontDelete
01047   ch        KJS::HTMLElement::TableSectionCh        DontDelete
01048   chOff     KJS::HTMLElement::TableSectionChOff     DontDelete
01049   vAlign    KJS::HTMLElement::TableSectionVAlign        DontDelete
01050   rows      KJS::HTMLElement::TableSectionRows      DontDelete|ReadOnly
01051   insertRow KJS::HTMLElement::TableSectionInsertRow     DontDelete|Function 1
01052   deleteRow KJS::HTMLElement::TableSectionDeleteRow     DontDelete|Function 1
01053 @end
01054 @begin HTMLTableRowElementTable 11
01055   rowIndex  KJS::HTMLElement::TableRowRowIndex      DontDelete|ReadOnly
01056   sectionRowIndex KJS::HTMLElement::TableRowSectionRowIndex DontDelete|ReadOnly
01057   cells     KJS::HTMLElement::TableRowCells         DontDelete|ReadOnly
01058   align     KJS::HTMLElement::TableRowAlign         DontDelete
01059   bgColor   KJS::HTMLElement::TableRowBgColor       DontDelete
01060   ch        KJS::HTMLElement::TableRowCh            DontDelete
01061   chOff     KJS::HTMLElement::TableRowChOff         DontDelete
01062   vAlign    KJS::HTMLElement::TableRowVAlign        DontDelete
01063   insertCell    KJS::HTMLElement::TableRowInsertCell        DontDelete|Function 1
01064   deleteCell    KJS::HTMLElement::TableRowDeleteCell        DontDelete|Function 1
01065 @end
01066 @begin HTMLTableCellElementTable 15
01067   cellIndex KJS::HTMLElement::TableCellCellIndex        DontDelete|ReadOnly
01068   abbr      KJS::HTMLElement::TableCellAbbr         DontDelete
01069   align     KJS::HTMLElement::TableCellAlign        DontDelete
01070   axis      KJS::HTMLElement::TableCellAxis         DontDelete
01071   bgColor   KJS::HTMLElement::TableCellBgColor      DontDelete
01072   ch        KJS::HTMLElement::TableCellCh           DontDelete
01073   chOff     KJS::HTMLElement::TableCellChOff        DontDelete
01074   colSpan   KJS::HTMLElement::TableCellColSpan      DontDelete
01075   headers   KJS::HTMLElement::TableCellHeaders      DontDelete
01076   height    KJS::HTMLElement::TableCellHeight       DontDelete
01077   noWrap    KJS::HTMLElement::TableCellNoWrap       DontDelete
01078   rowSpan   KJS::HTMLElement::TableCellRowSpan      DontDelete
01079   scope     KJS::HTMLElement::TableCellScope        DontDelete
01080   vAlign    KJS::HTMLElement::TableCellVAlign       DontDelete
01081   width     KJS::HTMLElement::TableCellWidth        DontDelete
01082 @end
01083 @begin HTMLFrameSetElementTable 2
01084   cols      KJS::HTMLElement::FrameSetCols          DontDelete
01085   rows      KJS::HTMLElement::FrameSetRows          DontDelete
01086 @end
01087 @begin HTMLLayerElementTable 6
01088   top         KJS::HTMLElement::LayerTop            DontDelete
01089   left        KJS::HTMLElement::LayerLeft           DontDelete
01090   visibility      KJS::HTMLElement::LayerVisibility     DontDelete
01091   bgColor     KJS::HTMLElement::LayerBgColor        DontDelete
01092   document        KJS::HTMLElement::LayerDocument       DontDelete|ReadOnly
01093   clip        KJS::HTMLElement::LayerClip           DontDelete|ReadOnly
01094   layers      KJS::HTMLElement::LayerLayers         DontDelete|ReadOnly
01095 @end
01096 @begin HTMLFrameElementTable 9
01097   contentDocument KJS::HTMLElement::FrameContentDocument        DontDelete|ReadOnly
01098   frameBorder     KJS::HTMLElement::FrameFrameBorder        DontDelete
01099   longDesc    KJS::HTMLElement::FrameLongDesc       DontDelete
01100   marginHeight    KJS::HTMLElement::FrameMarginHeight       DontDelete
01101   marginWidth     KJS::HTMLElement::FrameMarginWidth        DontDelete
01102   name        KJS::HTMLElement::FrameName           DontDelete
01103   noResize    KJS::HTMLElement::FrameNoResize       DontDelete
01104   scrolling   KJS::HTMLElement::FrameScrolling      DontDelete
01105   src         KJS::HTMLElement::FrameSrc            DontDelete
01106   location    KJS::HTMLElement::FrameLocation       DontDelete
01107 @end
01108 @begin HTMLIFrameElementTable 12
01109   align       KJS::HTMLElement::IFrameAlign         DontDelete
01110   contentDocument KJS::HTMLElement::IFrameContentDocument       DontDelete|ReadOnly
01111   frameBorder     KJS::HTMLElement::IFrameFrameBorder       DontDelete
01112   height      KJS::HTMLElement::IFrameHeight        DontDelete
01113   longDesc    KJS::HTMLElement::IFrameLongDesc      DontDelete
01114   marginHeight    KJS::HTMLElement::IFrameMarginHeight      DontDelete
01115   marginWidth     KJS::HTMLElement::IFrameMarginWidth       DontDelete
01116   name        KJS::HTMLElement::IFrameName          DontDelete
01117   scrolling   KJS::HTMLElement::IFrameScrolling     DontDelete
01118   src         KJS::HTMLElement::IFrameSrc           DontDelete
01119   width       KJS::HTMLElement::IFrameWidth         DontDelete
01120 @end
01121 
01122 @begin HTMLMarqueeElementTable 2
01123   start           KJS::HTMLElement::MarqueeStart        DontDelete|Function 0
01124   stop            KJS::HTMLElement::MarqueeStop                 DontDelete|Function 0
01125 @end
01126 
01127 */
01128 
01129 static KParts::LiveConnectExtension *getLiveConnectExtension(const DOM::HTMLElement & element)
01130 {
01131   DOM::HTMLDocument doc = element.ownerDocument();
01132   KHTMLView *view = static_cast<DOM::DocumentImpl*>(doc.handle())->view();
01133   if (view && element.handle())
01134     return view->part()->liveConnectExtension(static_cast<khtml::RenderPart*>(element.handle()->renderer()));
01135   return 0L;
01136 }
01137 
01138 Value KJS::HTMLElement::tryGet(ExecState *exec, const Identifier &propertyName) const
01139 {
01140   DOM::HTMLElement element = static_cast<DOM::HTMLElement>(node);
01141 #ifdef KJS_VERBOSE
01142   kdDebug(6070) << "KJS::HTMLElement::tryGet " << propertyName.qstring() << " thisTag=" << element.tagName().string() << endl;
01143 #endif
01144   // First look at dynamic properties
01145   switch (element.elementId()) {
01146     case ID_FORM: {
01147       DOM::HTMLFormElement form = element;
01148       // Check if we're retrieving an element (by index or by name)
01149       bool ok;
01150       uint u = propertyName.toULong(&ok);
01151 
01152       if (ok)
01153         return getDOMNode(exec,form.elements().item(u));
01154       KJS::HTMLCollection coll(exec, form.elements());
01155       Value namedItems = coll.getNamedItems(exec, propertyName);
01156       if (namedItems.type() != UndefinedType)
01157         return namedItems;
01158     }
01159       break;
01160     case ID_SELECT: {
01161       DOM::HTMLSelectElement select = element;
01162       bool ok;
01163       uint u = propertyName.toULong(&ok);
01164       if (ok)
01165         return getDOMNode(exec,select.options().item(u)); // not specified by DOM(?) but supported in netscape/IE
01166     }
01167       break;
01168     case ID_APPLET:
01169     case ID_OBJECT:
01170     case ID_EMBED: {
01171       KParts::LiveConnectExtension *lc = getLiveConnectExtension(element);
01172       QString rvalue;
01173       KParts::LiveConnectExtension::Type rtype;
01174       unsigned long robjid;
01175       if (lc && lc->get(0, propertyName.qstring(), rtype, robjid, rvalue))
01176         return getLiveConnectValue(lc, propertyName.qstring(), rtype, rvalue, robjid);
01177     }
01178       break;
01179   default:
01180     break;
01181   }
01182 
01183   const HashTable* table = classInfo()->propHashTable; // get the right hashtable
01184   const HashEntry* entry = Lookup::findEntry(table, propertyName);
01185   if (entry) {
01186     if (entry->attr & Function)
01187       return lookupOrCreateFunction<KJS::HTMLElementFunction>(exec, propertyName, this, entry->value, entry->params, entry->attr);
01188     return getValueProperty(exec, entry->value);
01189   }
01190 
01191   // Base HTMLElement stuff or parent class forward, as usual
01192   return DOMObjectLookupGet<KJS::HTMLElementFunction, KJS::HTMLElement, DOMElement>(exec, propertyName, &KJS::HTMLElementTable, this);
01193 }
01194 
01195 Value KJS::HTMLElement::getValueProperty(ExecState *exec, int token) const
01196 {
01197   DOM::HTMLElement element = static_cast<DOM::HTMLElement>(node);
01198   switch (element.elementId()) {
01199   case ID_HTML: {
01200     DOM::HTMLHtmlElement html = element;
01201     if      (token == HtmlVersion)         return String(html.version());
01202   }
01203   break;
01204   case ID_HEAD: {
01205     DOM::HTMLHeadElement head = element;
01206     if      (token == HeadProfile)         return String(head.profile());
01207   }
01208   break;
01209   case ID_LINK: {
01210     DOM::HTMLLinkElement link = element;
01211     switch (token) {
01212     case LinkDisabled:        return Boolean(link.disabled());
01213     case LinkCharset:         return String(link.charset());
01214     case LinkHref:            return String(link.href());
01215     case LinkHrefLang:        return String(link.hreflang());
01216     case LinkMedia:           return String(link.media());
01217     case LinkRel:             return String(link.rel());
01218     case LinkRev:             return String(link.rev());
01219     case LinkTarget:          return String(link.target());
01220     case LinkType:            return String(link.type());
01221     case LinkSheet:           return getDOMStyleSheet(exec,static_cast<DOM::ProcessingInstruction>(node).sheet());
01222     }
01223   }
01224   break;
01225   case ID_TITLE: {
01226     DOM::HTMLTitleElement title = element;
01227     switch (token) {
01228     case TitleText:                 return String(title.text());
01229     }
01230   }
01231   break;
01232   case ID_META: {
01233     DOM::HTMLMetaElement meta = element;
01234     switch (token) {
01235     case MetaContent:         return String(meta.content());
01236     case MetaHttpEquiv:       return String(meta.httpEquiv());
01237     case MetaName:            return String(meta.name());
01238     case MetaScheme:          return String(meta.scheme());
01239     }
01240   }
01241   break;
01242   case ID_BASE: {
01243     DOM::HTMLBaseElement base = element;
01244     switch (token) {
01245     case BaseHref:            return String(base.href());
01246     case BaseTarget:          return String(base.target());
01247     }
01248   }
01249   break;
01250   case ID_ISINDEX: {
01251     DOM::HTMLIsIndexElement isindex = element;
01252     switch (token) {
01253     case IsIndexForm:            return getDOMNode(exec,isindex.form()); // type HTMLFormElement
01254     case IsIndexPrompt:          return String(isindex.prompt());
01255     }
01256   }
01257   break;
01258   case ID_STYLE: {
01259     DOM::HTMLStyleElement style = element;
01260     switch (token) {
01261     case StyleDisabled:        return Boolean(style.disabled());
01262     case StyleMedia:           return String(style.media());
01263     case StyleType:            return String(style.type());
01264     case StyleSheet:           return getDOMStyleSheet(exec,style.sheet());
01265     }
01266   }
01267   break;
01268   case ID_BODY: {
01269     DOM::HTMLBodyElement body = element;
01270     switch (token) {
01271     case BodyALink:           return String(body.aLink());
01272     case BodyBackground:      return String(body.background());
01273     case BodyBgColor:         return String(body.bgColor());
01274     case BodyLink:            return String(body.link());
01275     case BodyText:            return String(body.text());
01276     case BodyVLink:           return String(body.vLink());
01277     default:
01278       // Update the document's layout before we compute these attributes.
01279       DOM::DocumentImpl* docimpl = node.handle()->getDocument();
01280       if (docimpl)
01281         docimpl->updateLayout();
01282 
01283       switch( token ) {
01284       case BodyScrollLeft:
01285         return Number(body.ownerDocument().view() ? body.ownerDocument().view()->contentsX() : 0);
01286       case BodyScrollTop:
01287         return Number(body.ownerDocument().view() ? body.ownerDocument().view()->contentsY() : 0);
01288       case BodyScrollHeight:   return Number(body.ownerDocument().view() ? body.ownerDocument().view()->contentsHeight() : 0);
01289       case BodyScrollWidth:    return Number(body.ownerDocument().view() ? body.ownerDocument().view()->contentsWidth() : 0);
01290       }
01291     }
01292   }
01293   break;
01294 
01295   case ID_FORM: {
01296     DOM::HTMLFormElement form = element;
01297     switch (token) {
01298     case FormElements:        return getHTMLCollection(exec,form.elements());
01299     case FormLength:          return Number(form.length());
01300     case FormName:            return String(form.name()); // NOT getString (IE gives empty string)
01301     case FormAcceptCharset:   return String(form.acceptCharset());
01302     case FormAction:          return String(form.action());
01303     case FormEncType:         return String(form.enctype());
01304     case FormMethod:          return String(form.method());
01305     case FormTarget:          return String(form.target());
01306     }
01307   }
01308   break;
01309   case ID_SELECT: {
01310     DOM::HTMLSelectElement select = element;
01311     switch (token) {
01312     case SelectType:            return String(select.type());
01313     case SelectSelectedIndex:   return Number(select.selectedIndex());
01314     case SelectValue:           return String(select.value());
01315     case SelectLength:          return Number(select.length());
01316     case SelectForm:            return getDOMNode(exec,select.form()); // type HTMLFormElement
01317     case SelectOptions:         return getSelectHTMLCollection(exec, select.options(), select); // type HTMLCollection
01318     case SelectDisabled:        return Boolean(select.disabled());
01319     case SelectMultiple:        return Boolean(select.multiple());
01320     case SelectName:            return String(select.name());
01321     case SelectSize:            return Number(select.size());
01322     case SelectTabIndex:        return Number(select.tabIndex());
01323     }
01324   }
01325   break;
01326   case ID_OPTGROUP: {
01327     DOM::HTMLOptGroupElement optgroup = element;
01328     switch (token) {
01329     case OptGroupDisabled:        return Boolean(optgroup.disabled());
01330     case OptGroupLabel:           return String(optgroup.label());
01331     }
01332   }
01333   break;
01334   case ID_OPTION: {
01335     DOM::HTMLOptionElement option = element;
01336     switch (token) {
01337     case OptionForm:            return getDOMNode(exec,option.form()); // type HTMLFormElement
01338     case OptionDefaultSelected: return Boolean(option.defaultSelected());
01339     case OptionText:            return String(option.text());
01340     case OptionIndex:           return Number(option.index());
01341     case OptionDisabled:        return Boolean(option.disabled());
01342     case OptionLabel:           return String(option.label());
01343     case OptionSelected:        return Boolean(option.selected());
01344     case OptionValue:           return String(option.value());
01345     }
01346   }
01347   break;
01348   case ID_INPUT: {
01349     DOM::HTMLInputElement input = element;
01350     switch (token) {
01351     case InputDefaultValue:    return String(input.defaultValue());
01352     case InputDefaultChecked:  return Boolean(input.defaultChecked());
01353     case InputForm:            return getDOMNode(exec,input.form()); // type HTMLFormElement
01354     case InputAccept:          return String(input.accept());
01355     case InputAccessKey:       return String(input.accessKey());
01356     case InputAlign:           return String(input.align());
01357     case InputAlt:             return String(input.alt());
01358     case InputChecked:         return Boolean(input.checked());
01359     case InputDisabled:        return Boolean(input.disabled());
01360     case InputMaxLength:       return Number(input.maxLength());
01361     case InputName:            return String(input.name()); // NOT getString (IE gives empty string)
01362     case InputReadOnly:        return Boolean(input.readOnly());
01363     case InputSize:            return Number(input.getSize());
01364     case InputSrc:             return String(input.src());
01365     case InputTabIndex:        return Number(input.tabIndex());
01366     case InputType:            return String(input.type());
01367     case InputUseMap:          return String(input.useMap());
01368     case InputValue:           return String(input.value());
01369     }
01370   }
01371   break;
01372   case ID_TEXTAREA: {
01373     DOM::HTMLTextAreaElement textarea = element;
01374     switch (token) {
01375     case TextAreaDefaultValue:    return String(textarea.defaultValue());
01376     case TextAreaForm:            return getDOMNode(exec,textarea.form()); // type HTMLFormElement
01377     case TextAreaAccessKey:       return String(textarea.accessKey());
01378     case TextAreaCols:            return Number(textarea.cols());
01379     case TextAreaDisabled:        return Boolean(textarea.disabled());
01380     case TextAreaName:            return String(textarea.name());
01381     case TextAreaReadOnly:        return Boolean(textarea.readOnly());
01382     case TextAreaRows:            return Number(textarea.rows());
01383     case TextAreaTabIndex:        return Number(textarea.tabIndex());
01384     case TextAreaType:            return String(textarea.type());
01385     case TextAreaValue:           return String(textarea.value());
01386     }
01387   }
01388   break;
01389   case ID_BUTTON: {
01390     DOM::HTMLButtonElement button = element;
01391     switch (token) {
01392     case ButtonForm:            return getDOMNode(exec,button.form()); // type HTMLFormElement
01393     case ButtonAccessKey:       return String(button.accessKey());
01394     case ButtonDisabled:        return Boolean(button.disabled());
01395     case ButtonName:            return String(button.name());
01396     case ButtonTabIndex:        return Number(button.tabIndex());
01397     case ButtonType:            return String(button.type());
01398     case ButtonValue:           return String(button.value());
01399     }
01400   }
01401   break;
01402   case ID_LABEL: {
01403     DOM::HTMLLabelElement label = element;
01404     switch (token) {
01405     case LabelForm:            return getDOMNode(exec,label.form()); // type HTMLFormElement
01406     case LabelAccessKey:       return String(label.accessKey());
01407     case LabelHtmlFor:         return String(label.htmlFor());
01408     }
01409   }
01410   break;
01411   case ID_FIELDSET: {
01412     DOM::HTMLFieldSetElement fieldSet = element;
01413     switch (token) {
01414     case FieldSetForm:            return getDOMNode(exec,fieldSet.form()); // type HTMLFormElement
01415     }
01416   }
01417   break;
01418   case ID_LEGEND: {
01419     DOM::HTMLLegendElement legend = element;
01420     switch (token) {
01421     case LegendForm:            return getDOMNode(exec,legend.form()); // type HTMLFormElement
01422     case LegendAccessKey:       return String(legend.accessKey());
01423     case LegendAlign:           return String(legend.align());
01424     }
01425   }
01426   break;
01427   case ID_UL: {
01428     DOM::HTMLUListElement uList = element;
01429     switch (token) {
01430     case UListCompact:         return Boolean(uList.compact());
01431     case UListType:            return String(uList.type());
01432     }
01433   }
01434   break;
01435   case ID_OL: {
01436     DOM::HTMLOListElement oList = element;
01437     switch (token) {
01438     case OListCompact:         return Boolean(oList.compact());
01439     case OListStart:           return Number(oList.start());
01440     case OListType:            return String(oList.type());
01441     }
01442   }
01443   break;
01444   case ID_DL: {
01445     DOM::HTMLDListElement dList = element;
01446     switch (token) {
01447     case DListCompact:         return Boolean(dList.compact());
01448     }
01449   }
01450   break;
01451   case ID_DIR: {
01452     DOM::HTMLDirectoryElement directory = element;
01453     switch (token) {
01454     case DirectoryCompact:         return Boolean(directory.compact());
01455     }
01456   }
01457   break;
01458   case ID_MENU: {
01459     DOM::HTMLMenuElement menu = element;
01460     switch (token) {
01461     case MenuCompact:         return Boolean(menu.compact());
01462     }
01463   }
01464   break;
01465   case ID_LI: {
01466     DOM::HTMLLIElement li = element;
01467     switch (token) {
01468     case LIType:            return String(li.type());
01469     case LIValue:           return Number(li.value());
01470     }
01471   }
01472   break;
01473   case ID_DIV: {
01474     DOM::HTMLDivElement div = element;
01475     switch (token) {
01476     case DivAlign:           return String(div.align());
01477     }
01478   }
01479   break;
01480   case ID_P: {
01481     DOM::HTMLParagraphElement paragraph = element;
01482     switch (token) {
01483     case ParagraphAlign:           return String(paragraph.align());
01484     }
01485   }
01486   break;
01487   case ID_H1:
01488   case ID_H2:
01489   case ID_H3:
01490   case ID_H4:
01491   case ID_H5:
01492   case ID_H6: {
01493     DOM::HTMLHeadingElement heading = element;
01494     switch (token) {
01495     case HeadingAlign:           return String(heading.align());
01496     }
01497   }
01498   break;
01499   case ID_BLOCKQUOTE: {
01500     DOM::HTMLBlockquoteElement blockquote = element;
01501     switch (token) {
01502     case BlockQuoteCite:            return String(blockquote.cite());
01503     }
01504   }
01505   case ID_Q: {
01506     DOM::HTMLQuoteElement quote = element;
01507     switch (token) {
01508     case QuoteCite:            return String(quote.cite());
01509     }
01510   }
01511   case ID_PRE: {
01512     DOM::HTMLPreElement pre = element;
01513     switch (token) {
01514     case PreWidth:           return Number(pre.width());
01515     }
01516   }
01517   break;
01518   case ID_BR: {
01519     DOM::HTMLBRElement br = element;
01520     switch (token) {
01521     case BRClear:           return String(br.clear());
01522     }
01523   }
01524   break;
01525   case ID_BASEFONT: {
01526     DOM::HTMLBaseFontElement baseFont = element;
01527     switch (token) {
01528     case BaseFontColor:           return String(baseFont.color());
01529     case BaseFontFace:            return String(baseFont.face());
01530     case BaseFontSize:            return Number(baseFont.getSize());
01531     }
01532   }
01533   break;
01534   case ID_FONT: {
01535     DOM::HTMLFontElement font = element;
01536     switch (token) {
01537     case FontColor:           return String(font.color());
01538     case FontFace:            return String(font.face());
01539     case FontSize:            return String(font.size());
01540     }
01541   }
01542   break;
01543   case ID_HR: {
01544     DOM::HTMLHRElement hr = element;
01545     switch (token) {
01546     case HRAlign:           return String(hr.align());
01547     case HRNoShade:         return Boolean(hr.noShade());
01548     case HRSize:            return String(hr.size());
01549     case HRWidth:           return String(hr.width());
01550     }
01551   }
01552   break;
01553   case ID_INS:
01554   case ID_DEL: {
01555     DOM::HTMLModElement mod = element;
01556     switch (token) {
01557     case ModCite:            return String(mod.cite());
01558     case ModDateTime:        return String(mod.dateTime());
01559     }
01560   }
01561   break;
01562   case ID_A: {
01563     DOM::HTMLAnchorElement anchor = element;
01564     switch (token) {
01565     case AnchorAccessKey:       return String(anchor.accessKey());
01566     case AnchorCharset:         return String(anchor.charset());
01567     case AnchorCoords:          return String(anchor.coords());
01568     case AnchorHref:            return String(anchor.href());
01569     case AnchorHrefLang:        return String(anchor.hreflang());
01570     case AnchorHash:            return String('#'+KURL(anchor.href().string()).ref());
01571     case AnchorHost:            return String(KURL(anchor.href().string()).host());
01572     case AnchorHostname: {
01573       KURL url(anchor.href().string());
01574       kdDebug(6070) << "anchor::hostname uses:" <<url.url()<<endl;
01575       if (url.port()==0)
01576         return String(url.host());
01577       else
01578         return String(url.host() + ":" + QString::number(url.port()));
01579     }
01580     case AnchorPathName:        return String(KURL(anchor.href().string()).path());
01581     case AnchorPort:            return String(QString::number(KURL(anchor.href().string()).port()));
01582     case AnchorProtocol:        return String(KURL(anchor.href().string()).protocol()+":");
01583     case AnchorSearch:          return String(KURL(anchor.href().string()).query());
01584     case AnchorName:            return String(anchor.name());
01585     case AnchorRel:             return String(anchor.rel());
01586     case AnchorRev:             return String(anchor.rev());
01587     case AnchorShape:           return String(anchor.shape());
01588     case AnchorTabIndex:        return Number(anchor.tabIndex());
01589     case AnchorTarget:          return String(anchor.target());
01590     // Not specified in http://msdn.microsoft.com/workshop/author/dhtml/reference/objects/a.asp
01591     // Mozilla returns the inner text.
01592     case AnchorText:            return String(anchor.innerText());
01593     case AnchorType:            return String(anchor.type());
01594     }
01595   }
01596   break;
01597   case ID_IMG: {
01598     DOM::HTMLImageElement image = element;
01599     switch (token) {
01600     case ImageName:            return String(image.name()); // NOT getString (IE gives empty string)
01601     case ImageAlign:           return String(image.align());
01602     case ImageAlt:             return String(image.alt());
01603     case ImageBorder:          return String(image.getBorder());
01604     case ImageComplete:        return Boolean(static_cast<DOM::HTMLImageElementImpl*>( image.handle() )->complete());
01605     case ImageHeight:          return Number(image.height());
01606     case ImageHspace:          return Number(image.hspace());
01607     case ImageIsMap:           return Boolean(image.isMap());
01608     case ImageLongDesc:        return String(image.longDesc());
01609     case ImageSrc:             return String(image.src());
01610     case ImageUseMap:          return String(image.useMap());
01611     case ImageVspace:          return Number(image.vspace());
01612     case ImageWidth:           return Number(image.width());
01613     case ImageX:               return Number(image.x());
01614     case ImageY:               return Number(image.y());
01615     }
01616   }
01617   break;
01618   case ID_OBJECT: {
01619     DOM::HTMLObjectElement object = element;
01620     switch (token) {
01621     case ObjectForm:            return getDOMNode(exec,object.form()); // type HTMLFormElement
01622     case ObjectCode:            return String(object.code());
01623     case ObjectAlign:           return String(object.align());
01624     case ObjectArchive:         return String(object.archive());
01625     case ObjectBorder:          return String(object.border());
01626     case ObjectCodeBase:        return String(object.codeBase());
01627     case ObjectCodeType:        return String(object.codeType());
01628     case ObjectContentDocument: return checkNodeSecurity(exec,object.contentDocument()) ?
01629                        getDOMNode(exec, object.contentDocument()) : Undefined();
01630     case ObjectData:            return String(object.data());
01631     case ObjectDeclare:         return Boolean(object.declare());
01632     case ObjectHeight:          return String(object.height());
01633     case ObjectHspace:          return Number(object.getHspace());
01634     case ObjectName:            return String(object.name());
01635     case ObjectStandby:         return String(object.standby());
01636     case ObjectTabIndex:        return Number(object.tabIndex());
01637     case ObjectType:            return String(object.type());
01638     case ObjectUseMap:          return String(object.useMap());
01639     case ObjectVspace:          return Number(object.getVspace());
01640     case ObjectWidth:           return String(object.width());
01641     }
01642   }
01643   break;
01644   case ID_PARAM: {
01645     DOM::HTMLParamElement param = element;
01646     switch (token) {
01647     case ParamName:            return String(param.name());
01648     case ParamType:            return String(param.type());
01649     case ParamValue:           return String(param.value());
01650     case ParamValueType:       return String(param.valueType());
01651     }
01652   }
01653   break;
01654   case ID_APPLET: {
01655     DOM::HTMLAppletElement applet = element;
01656     switch (token) {
01657     case AppletAlign:           return String(applet.align());
01658     case AppletAlt:             return String(applet.alt());
01659     case AppletArchive:         return String(applet.archive());
01660     case AppletCode:            return String(applet.code());
01661     case AppletCodeBase:        return String(applet.codeBase());
01662     case AppletHeight:          return String(applet.height());
01663     case AppletHspace:          return Number(applet.getHspace());
01664     case AppletName:            return String(applet.name());
01665     case AppletObject:          return String(applet.object());
01666     case AppletVspace:          return Number(applet.getVspace());
01667     case AppletWidth:           return String(applet.width());
01668     }
01669   }
01670   break;
01671   case ID_MAP: {
01672     DOM::HTMLMapElement map = element;
01673     switch (token) {
01674     case MapAreas:           return getHTMLCollection(exec, map.areas()); // type HTMLCollection
01675     case MapName:            return String(map.name());
01676     }
01677   }
01678   break;
01679   case ID_AREA: {
01680     DOM::HTMLAreaElement area = element;
01681     switch (token) {
01682     case AreaAccessKey:       return String(area.accessKey());
01683     case AreaAlt:             return String(area.alt());
01684     case AreaCoords:          return String(area.coords());
01685     // Group everything that needs href
01686     case AreaHref:
01687     case AreaHash:
01688     case AreaHost:
01689     case AreaHostName:
01690     case AreaPathName:
01691     case AreaPort:
01692     case AreaProtocol:
01693     case AreaSearch:
01694     {
01695       DOM::Document doc = area.ownerDocument();
01696       DOM::DOMString href = area.href();
01697       KURL url;
01698       if ( !href.isNull() ) {
01699         url = doc.completeURL( href ).string();
01700         if ( href.isEmpty() )
01701           url.setFileName( QString::null ); // href="" clears the filename (in IE)
01702       }
01703       switch(token) {
01704       case AreaHref:
01705         return String(url.url());
01706       case AreaHash:            return String(url.isEmpty() ? "" : '#'+url.ref());
01707       case AreaHost:            return String(url.host());
01708       case AreaHostName: {
01709         if (url.port()==0)
01710           return String(url.host());
01711         else
01712           return String(url.host() + ":" + QString::number(url.port()));
01713       }
01714       case AreaPathName:        {
01715         return String(url.path());
01716       }
01717       case AreaPort:            return String(QString::number(url.port()));
01718       case AreaProtocol:        return String(url.isEmpty() ? "" : url.protocol()+":");
01719       case AreaSearch:          return String(url.query());
01720       }
01721     }
01722     case AreaNoHref:          return Boolean(area.noHref());
01723     case AreaShape:           return String(area.shape());
01724     case AreaTabIndex:        return Number(area.tabIndex());
01725     case AreaTarget:          return String(area.target());
01726     }
01727   }
01728   break;
01729   case ID_SCRIPT: {
01730     DOM::HTMLScriptElement script = element;
01731     switch (token) {
01732     case ScriptText:            return String(script.text());
01733     case ScriptHtmlFor:         return String(script.htmlFor());
01734     case ScriptEvent:           return String(script.event());
01735     case ScriptCharset:         return String(script.charset());
01736     case ScriptDefer:           return Boolean(script.defer());
01737     case ScriptSrc:             return String(script.src());
01738     case ScriptType:            return String(script.type());
01739     }
01740   }
01741   break;
01742   case ID_TABLE: {
01743     DOM::HTMLTableElement table = element;
01744     switch (token) {
01745     case TableCaption:         return getDOMNode(exec,table.caption()); // type HTMLTableCaptionElement
01746     case TableTHead:           return getDOMNode(exec,table.tHead()); // type HTMLTableSectionElement
01747     case TableTFoot:           return getDOMNode(exec,table.tFoot()); // type HTMLTableSectionElement
01748     case TableRows:            return getHTMLCollection(exec,table.rows()); // type HTMLCollection
01749     case TableTBodies:         return getHTMLCollection(exec,table.tBodies()); // type HTMLCollection
01750     case TableAlign:           return String(table.align());
01751     case TableBgColor:         return String(table.bgColor());
01752     case TableBorder:          return String(table.border());
01753     case TableCellPadding:     return String(table.cellPadding());
01754     case TableCellSpacing:     return String(table.cellSpacing());
01755     case TableFrame:           return String(table.frame());
01756     case TableRules:           return String(table.rules());
01757     case TableSummary:         return String(table.summary());
01758     case TableWidth:           return String(table.width());
01759     }
01760   }
01761   break;
01762   case ID_CAPTION: {
01763     DOM::HTMLTableCaptionElement tableCaption = element;
01764     switch (token) {
01765     case TableCaptionAlign:       return String(tableCaption.align());
01766     }
01767   }
01768   break;
01769   case ID_COL:
01770   case ID_COLGROUP: {
01771     DOM::HTMLTableColElement tableCol = element;
01772     switch (token) {
01773     case TableColAlign:           return String(tableCol.align());
01774     case TableColCh:              return String(tableCol.ch());
01775     case TableColChOff:           return String(tableCol.chOff());
01776     case TableColSpan:            return Number(tableCol.span());
01777     case TableColVAlign:          return String(tableCol.vAlign());
01778     case TableColWidth:           return String(tableCol.width());
01779     }
01780   }
01781   break;
01782   case ID_THEAD:
01783   case ID_TBODY:
01784   case ID_TFOOT: {
01785     DOM::HTMLTableSectionElement tableSection = element;
01786     switch (token) {
01787     case TableSectionAlign:           return String(tableSection.align());
01788     case TableSectionCh:              return String(tableSection.ch());
01789     case TableSectionChOff:           return String(tableSection.chOff());
01790     case TableSectionVAlign:          return String(tableSection.vAlign());
01791     case TableSectionRows:            return getHTMLCollection(exec,tableSection.rows()); // type HTMLCollection
01792     }
01793   }
01794   break;
01795   case ID_TR: {
01796    DOM::HTMLTableRowElement tableRow = element;
01797    switch (token) {
01798    case TableRowRowIndex:        return Number(tableRow.rowIndex());
01799    case TableRowSectionRowIndex: return Number(tableRow.sectionRowIndex());
01800    case TableRowCells:           return getHTMLCollection(exec,tableRow.cells()); // type HTMLCollection
01801    case TableRowAlign:           return String(tableRow.align());
01802    case TableRowBgColor:         return String(tableRow.bgColor());
01803    case TableRowCh:              return String(tableRow.ch());
01804    case TableRowChOff:           return String(tableRow.chOff());
01805    case TableRowVAlign:          return String(tableRow.vAlign());
01806    }
01807   }
01808   break;
01809   case ID_TH:
01810   case ID_TD: {
01811     DOM::HTMLTableCellElement tableCell = element;
01812     switch (token) {
01813     case TableCellCellIndex:       return Number(tableCell.cellIndex());
01814     case TableCellAbbr:            return String(tableCell.abbr());
01815     case TableCellAlign:           return String(tableCell.align());
01816     case TableCellAxis:            return String(tableCell.axis());
01817     case TableCellBgColor:         return String(tableCell.bgColor());
01818     case TableCellCh:              return String(tableCell.ch());
01819     case TableCellChOff:           return String(tableCell.chOff());
01820     case TableCellColSpan:         return Number(tableCell.colSpan());
01821     case TableCellHeaders:         return String(tableCell.headers());
01822     case TableCellHeight:          return String(tableCell.height());
01823     case TableCellNoWrap:          return Boolean(tableCell.noWrap());
01824     case TableCellRowSpan:         return Number(tableCell.rowSpan());
01825     case TableCellScope:           return String(tableCell.scope());
01826     case TableCellVAlign:          return String(tableCell.vAlign());
01827     case TableCellWidth:           return String(tableCell.width());
01828     }
01829   }
01830   break;
01831   case ID_FRAMESET: {
01832     DOM::HTMLFrameSetElement frameSet = element;
01833     switch (token) {
01834     case FrameSetCols:            return String(frameSet.cols());
01835     case FrameSetRows:            return String(frameSet.rows());
01836     }
01837   }
01838   break;
01839   case ID_LAYER: {
01840     DOM::HTMLLayerElement layerElement = element;
01841     switch (token) {
01842     case LayerTop:            return Number(layerElement.top());
01843     case LayerLeft:           return Number(layerElement.left());
01844     case LayerVisibility:     return getString(layerElement.visibility());
01845     case LayerBgColor:        return getString(layerElement.bgColor());
01846     /*case LayerClip:           return getLayerClip(exec, layerElement); */
01847     case LayerDocument:       return Undefined();
01848     case LayerLayers:         return getHTMLCollection(exec,layerElement.layers());
01849     }
01850   }
01851   break;
01852   case ID_FRAME: {
01853     DOM::HTMLFrameElement frameElement = element;
01854     switch (token) {
01855     case FrameContentDocument: return checkNodeSecurity(exec,frameElement.contentDocument()) ?
01856                       getDOMNode(exec, frameElement.contentDocument()) : Undefined();
01857     case FrameFrameBorder:     return String(frameElement.frameBorder());
01858     case FrameLongDesc:        return String(frameElement.longDesc());
01859     case FrameMarginHeight:    return String(frameElement.marginHeight());
01860     case FrameMarginWidth:     return String(frameElement.marginWidth());
01861     case FrameName:            return String(frameElement.name());
01862     case FrameNoResize:        return Boolean(frameElement.noResize());
01863     case FrameScrolling:       return String(frameElement.scrolling());
01864     case FrameSrc:
01865     case FrameLocation:        return String(frameElement.src());
01866     }
01867   }
01868   break;
01869   case ID_IFRAME: {
01870     DOM::HTMLIFrameElement iFrame = element;
01871     switch (token) {
01872     case IFrameAlign:           return String(iFrame.align());
01873     case IFrameContentDocument: return checkNodeSecurity(exec,iFrame.contentDocument()) ?
01874                        getDOMNode(exec, iFrame.contentDocument()) : Undefined();
01875     case IFrameFrameBorder:     return String(iFrame.frameBorder());
01876     case IFrameHeight:          return String(iFrame.height());
01877     case IFrameLongDesc:        return String(iFrame.longDesc());
01878     case IFrameMarginHeight:    return String(iFrame.marginHeight());
01879     case IFrameMarginWidth:     return String(iFrame.marginWidth());
01880     case IFrameName:            return String(iFrame.name());
01881     case IFrameScrolling:       return String(iFrame.scrolling());
01882     case IFrameSrc:             return String(iFrame.src());
01883     case IFrameWidth:           return String(iFrame.width());
01884     }
01885     break;
01886   }
01887   } // xemacs (or arnt) could be a bit smarter when it comes to indenting switch()es ;)
01888   // its not arnt to blame - its the original Stroustrup style we like :) (Dirk)
01889 
01890   // generic properties
01891   switch (token) {
01892   case ElementId:
01893     return String(element.id()); // String is wrong here. Other browsers return empty string if no id specified.
01894   case ElementTitle:
01895     return String(element.title());
01896   case ElementLang:
01897     return String(element.lang());
01898   case ElementDir:
01899     return String(element.dir());
01900   case ElementClassName:
01901     return String(element.className());
01902   case ElementInnerHTML:
01903     return String(element.innerHTML());
01904   case ElementInnerText:
01905     return String(element.innerText());
01906   case ElementDocument:
01907     return getDOMNode(exec,element.ownerDocument());
01908   case ElementChildren:
01909     return getHTMLCollection(exec,element.children());
01910   case ElementAll:
01911     // Disable element.all when we try to be Netscape-compatible
01912     if ( exec->interpreter()->compatMode() == Interpreter::NetscapeCompat )
01913       return Undefined();
01914     return getHTMLCollection(exec,element.all());
01915   // ### what about style? or is this used instead for DOM2 stylesheets?
01916   }
01917   kdError() << "HTMLElement::getValueProperty unhandled token " << token << endl;
01918   return Undefined();
01919 }
01920 
01921 bool KJS::HTMLElement::hasProperty(ExecState *exec, const Identifier &propertyName) const
01922 {
01923 #ifdef KJS_VERBOSE
01924   //kdDebug(6070) << "HTMLElement::hasProperty " << propertyName.qstring() << endl;
01925 #endif
01926   DOM::HTMLElement element = static_cast<DOM::HTMLElement>(node);
01927   // First look at dynamic properties - keep this in sync with tryGet
01928   switch (element.elementId()) {
01929     case ID_FORM: {
01930       DOM::HTMLFormElement form = element;
01931       // Check if we're retrieving an element (by index or by name)
01932       bool ok;
01933       uint u = propertyName.toULong(&ok);
01934       if (ok && !(form.elements().item(u).isNull()))
01935         return true;
01936       DOM::Node testnode = form.elements().namedItem(propertyName.string());
01937       if (!testnode.isNull())
01938         return true;
01939     }
01940     case ID_SELECT: {
01941       DOM::HTMLSelectElement select = element;
01942       bool ok;
01943       uint u = propertyName.toULong(&ok);
01944       if (ok && !(select.options().item(u).isNull()))
01945         return true;
01946     }
01947     default:
01948       break;
01949   }
01950 
01951   return DOMElement::hasProperty(exec, propertyName);
01952 }
01953 
01954 UString KJS::HTMLElement::toString(ExecState *exec) const
01955 {
01956   if (node.elementId() == ID_A)
01957     return UString(static_cast<const DOM::HTMLAnchorElement&>(node).href());
01958   else if (node.elementId() == ID_APPLET) {
01959     KParts::LiveConnectExtension *lc = getLiveConnectExtension(node);
01960     QStringList qargs;
01961     QString retvalue;
01962     KParts::LiveConnectExtension::Type rettype;
01963     unsigned long retobjid;
01964     if (lc && lc->call(0, "hashCode", qargs, rettype, retobjid, retvalue)) {
01965       QString str("[object APPLET ref=");
01966       return UString(str + retvalue + QString("]"));
01967     }
01968   } else if (node.elementId() == ID_IMG) {
01969     DOM::HTMLImageElement image(node);
01970     if (!image.alt().isEmpty())
01971       return UString(image.alt()) + " " + DOMElement::toString(exec);
01972   }
01973   return DOMElement::toString(exec);
01974 }
01975 
01976 static void getForm(DOM::HTMLFormElement* form, const DOM::HTMLElement& element)
01977 {
01978     switch (element.elementId()) {
01979         case ID_ISINDEX: {
01980             DOM::HTMLIsIndexElement isindex = element;
01981             *form = isindex.form();
01982             break;
01983         }
01984         case ID_SELECT: {
01985             DOM::HTMLSelectElement select = element;
01986             *form = select.form();
01987             break;
01988         }
01989         case ID_OPTION: {
01990             DOM::HTMLOptionElement option = element;
01991             *form = option.form();
01992             break;
01993         }
01994         case ID_INPUT: {
01995             DOM::HTMLInputElement input = element;
01996             *form = input.form();
01997             break;
01998         }
01999         case ID_TEXTAREA: {
02000             DOM::HTMLTextAreaElement textarea = element;
02001             *form = textarea.form();
02002             break;
02003         }
02004         case ID_LABEL: {
02005             DOM::HTMLLabelElement label = element;
02006             *form = label.form();
02007             break;
02008         }
02009         case ID_FIELDSET: {
02010             DOM::HTMLFieldSetElement fieldset = element;
02011             *form = fieldset.form();
02012             break;
02013         }
02014         case ID_LEGEND: {
02015             DOM::HTMLLegendElement legend = element;
02016             *form = legend.form();
02017             break;
02018         }
02019         case ID_OBJECT: {
02020             DOM::HTMLObjectElement object = element;
02021             *form = object.form();
02022             break;
02023         }
02024         default:
02025             break;
02026     }
02027 }
02028 
02029 void KJS::HTMLElement::pushEventHandlerScope(ExecState *exec, ScopeChain &scope) const
02030 {
02031   DOM::HTMLElement element = static_cast<DOM::HTMLElement>(node);
02032 
02033   // The document is put on first, fall back to searching it only after the element and form.
02034   scope.push(static_cast<ObjectImp *>(getDOMNode(exec, element.ownerDocument()).imp()));
02035 
02036   // The form is next, searched before the document, but after the element itself.
02037   DOM::HTMLFormElement formElt;
02038 
02039   // First try to obtain the form from the element itself.  We do this to deal with
02040   // the malformed case where <form>s aren't in our parent chain (e.g., when they were inside
02041   // <table> or <tbody>.
02042   getForm(&formElt, element);
02043   if (!formElt.isNull())
02044     scope.push(static_cast<ObjectImp *>(getDOMNode(exec, formElt).imp()));
02045   else {
02046     DOM::Node form = element.parentNode();
02047     while (!form.isNull() && form.elementId() != ID_FORM)
02048         form = form.parentNode();
02049 
02050     if (!form.isNull())
02051         scope.push(static_cast<ObjectImp *>(getDOMNode(exec, form).imp()));
02052   }
02053 
02054   // The element is on top, searched first.
02055   scope.push(static_cast<ObjectImp *>(getDOMNode(exec, element).imp()));
02056 }
02057 
02058 HTMLElementFunction::HTMLElementFunction(ExecState *exec, int i, int len)
02059   : DOMFunction(exec), id(i)
02060 {
02061   Value protect(this);
02062   put(exec,lengthPropertyName,Number(len),DontDelete|ReadOnly|DontEnum);
02063 }
02064 
02065 Value KJS::HTMLElementFunction::tryCall(ExecState *exec, Object &thisObj, const List &args)
02066 {
02067   KJS_CHECK_THIS( HTMLElement, thisObj );
02068 
02069 #ifdef KJS_VERBOSE
02070   kdDebug(6070) << "KJS::HTMLElementFunction::tryCall " << endl;
02071 #endif
02072   DOM::HTMLElement element = static_cast<KJS::HTMLElement *>(thisObj.imp())->toElement();
02073 
02074   switch (element.elementId()) {
02075     case ID_FORM: {
02076       DOM::HTMLFormElement form = element;
02077       if (id == KJS::HTMLElement::FormSubmit) {
02078 
02079 
02080         DOM::HTMLDocument doc = element.ownerDocument();
02081         KHTMLView *view = static_cast<DOM::DocumentImpl*>(doc.handle())->view();
02082         KHTMLSettings::KJSWindowOpenPolicy policy = KHTMLSettings::KJSWindowOpenAllow;
02083     if (view)
02084         policy = view->part()->settings()->windowOpenPolicy(view->part()->url().host());
02085 
02086         bool block = false;
02087 
02088         if ( policy != KHTMLSettings::KJSWindowOpenAllow ) {
02089           block = true;
02090 
02091          // if this is a form without a target, or a special target, don't block
02092           QString trg = form.target().lower().string();
02093           if( trg.isEmpty() || trg == "_top" || trg == "_self" ||
02094               trg == "_parent")
02095             block = false;
02096 
02097           QString caption;
02098 
02099           // if there is a frame with the target name, don't block
02100           if ( view && view->part() )  {
02101             if (!view->part()->url().host().isEmpty())
02102               caption = view->part()->url().host() + " - ";
02103             // search all (possibly nested) framesets
02104             KHTMLPart *currentPart = view->part()->parentPart();
02105             while( currentPart != 0L ) {
02106               if( currentPart->frameExists( form.target().string() ) )
02107                 block = false;
02108               currentPart = currentPart->parentPart();
02109             }
02110           }
02111 
02112           if ( block && policy == KHTMLSettings::KJSWindowOpenAsk && view ) {
02113             if (view && view->part())
02114             emit view->part()->browserExtension()->requestFocus(view->part());
02115             caption += i18n( "Confirmation: JavaScript Popup" );
02116             if ( KMessageBox::questionYesNo(view, form.action().isEmpty() ?
02117                    i18n( "This site is submitting a form which will open up a new browser "
02118                          "window via JavaScript.\n"
02119                          "Do you want to allow the form to be submitted?" ) :
02120                    i18n( "<qt>This site is submitting a form which will open <p>%1</p> in a new browser window via JavaScript.<br />"
02121                          "Do you want to allow the form to be submitted?</qt>").arg(KStringHandler::csqueeze(form.action().string(),  100)),
02122                    caption ) == KMessageBox::Yes )
02123               block = false;
02124 
02125           } else if ( block && policy == KHTMLSettings::KJSWindowOpenSmart ) {
02126             if( static_cast<KJS::ScriptInterpreter *>(exec->interpreter())->isWindowOpenAllowed() ) {
02127               // This submission has been triggered by the user
02128               block = false;
02129             }
02130           }
02131         }
02132 
02133         if( !block )
02134           form.submit();
02135 
02136         return Undefined();
02137       }
02138       else if (id == KJS::HTMLElement::FormReset) {
02139         form.reset();
02140         return Undefined();
02141       }
02142     }
02143     break;
02144     case ID_SELECT: {
02145       DOM::HTMLSelectElement select = element;
02146       if (id == KJS::HTMLElement::SelectAdd) {
02147         select.add(KJS::toNode(args[0]),KJS::toNode(args[1]));
02148         return Undefined();
02149       }
02150       else if (id == KJS::HTMLElement::SelectRemove) {
02151         select.remove(int(args[0].toNumber(exec)));
02152         return Undefined();
02153       }
02154       else if (id == KJS::HTMLElement::SelectBlur) {
02155         select.blur();
02156         return Undefined();
02157       }
02158       else if (id == KJS::HTMLElement::SelectFocus) {
02159         select.focus();
02160         return Undefined();
02161       }
02162     }
02163     break;
02164     case ID_INPUT: {
02165       DOM::HTMLInputElement input = element;
02166       if (id == KJS::HTMLElement::InputBlur) {
02167         input.blur();
02168         return Undefined();
02169       }
02170       else if (id == KJS::HTMLElement::InputFocus) {
02171         input.focus();
02172         return Undefined();
02173       }
02174       else if (id == KJS::HTMLElement::InputSelect) {
02175         input.select();
02176         return Undefined();
02177       }
02178       else if (id == KJS::HTMLElement::InputClick) {
02179         input.click();
02180         return Undefined();
02181       }
02182     }
02183     break;
02184     case ID_TEXTAREA: {
02185       DOM::HTMLTextAreaElement textarea = element;
02186       if (id == KJS::HTMLElement::TextAreaBlur) {
02187         textarea.blur();
02188         return Undefined();
02189       }
02190       else if (id == KJS::HTMLElement::TextAreaFocus) {
02191         textarea.focus();
02192         return Undefined();
02193       }
02194       else if (id == KJS::HTMLElement::TextAreaSelect) {
02195         textarea.select();
02196         return Undefined();
02197       }
02198     }
02199     break;
02200     case ID_A: {
02201       DOM::HTMLAnchorElement anchor = element;
02202       if (id == KJS::HTMLElement::AnchorBlur) {
02203         anchor.blur();
02204         return Undefined();
02205       }
02206       else if (id == KJS::HTMLElement::AnchorFocus) {
02207         anchor.focus();
02208         return Undefined();
02209       }
02210     }
02211     break;
02212     case ID_TABLE: {
02213       DOM::HTMLTableElement table = element;
02214       if (id == KJS::HTMLElement::TableCreateTHead)
02215         return getDOMNode(exec,table.createTHead());
02216       else if (id == KJS::HTMLElement::TableDeleteTHead) {
02217         table.deleteTHead();
02218         return Undefined();
02219       }
02220       else if (id == KJS::HTMLElement::TableCreateTFoot)
02221         return getDOMNode(exec,table.createTFoot());
02222       else if (id == KJS::HTMLElement::TableDeleteTFoot) {
02223         table.deleteTFoot();
02224         return Undefined();
02225       }
02226       else if (id == KJS::HTMLElement::TableCreateCaption)
02227         return getDOMNode(exec,table.createCaption());
02228       else if (id == KJS::HTMLElement::TableDeleteCaption) {
02229         table.deleteCaption();
02230         return Undefined();
02231       }
02232       else if (id == KJS::HTMLElement::TableInsertRow)
02233         return getDOMNode(exec,table.insertRow(args[0].toInteger(exec)));
02234       else if (id == KJS::HTMLElement::TableDeleteRow) {
02235         table.deleteRow(args[0].toInteger(exec));
02236         return Undefined();
02237       }
02238     }
02239     break;
02240     case ID_THEAD:
02241     case ID_TBODY:
02242     case ID_TFOOT: {
02243       DOM::HTMLTableSectionElement tableSection = element;
02244       if (id == KJS::HTMLElement::TableSectionInsertRow)
02245         return getDOMNode(exec,tableSection.insertRow(args[0].toInteger(exec)));
02246       else if (id == KJS::HTMLElement::TableSectionDeleteRow) {
02247         tableSection.deleteRow(args[0].toInteger(exec));
02248         return Undefined();
02249       }
02250     }
02251     break;
02252     case ID_TR: {
02253       DOM::HTMLTableRowElement tableRow = element;
02254       if (id == KJS::HTMLElement::TableRowInsertCell)
02255         return getDOMNode(exec,tableRow.insertCell(args[0].toInteger(exec)));
02256       else if (id == KJS::HTMLElement::TableRowDeleteCell) {
02257         tableRow.deleteCell(args[0].toInteger(exec));
02258         return Undefined();
02259       }
02260       break;
02261     }
02262     case ID_MARQUEE: {
02263       if (id == KJS::HTMLElement::MarqueeStart && element.handle()->renderer() &&
02264         element.handle()->renderer()->layer() &&
02265         element.handle()->renderer()->layer()->marquee()) {
02266         element.handle()->renderer()->layer()->marquee()->start();
02267         return Undefined();
02268       }
02269       else if (id == KJS::HTMLElement::MarqueeStop && element.handle()->renderer() &&
02270               element.handle()->renderer()->layer() &&
02271               element.handle()->renderer()->layer()->marquee()) {
02272         element.handle()->renderer()->layer()->marquee()->stop();
02273         return Undefined();
02274       }
02275       break;
02276     }
02277   }
02278 
02279   return Undefined();
02280 }
02281 
02282 void KJS::HTMLElement::tryPut(ExecState *exec, const Identifier &propertyName, const Value& value, int attr)
02283 {
02284 #ifdef KJS_VERBOSE
02285   DOM::DOMString str = value.isA(NullType) ? DOM::DOMString() : value.toString(exec).string();
02286 #endif
02287   DOM::HTMLElement element = static_cast<DOM::HTMLElement>(node);
02288 #ifdef KJS_VERBOSE
02289   kdDebug(6070) << "KJS::HTMLElement::tryPut " << propertyName.qstring()
02290                 << " thisTag=" << element.tagName().string()
02291                 << " str=" << str.string() << endl;
02292 #endif
02293   // First look at dynamic properties
02294   switch (element.elementId()) {
02295     case ID_SELECT: {
02296       DOM::HTMLSelectElement select = element;
02297       bool ok;
02298       /*uint u =*/ propertyName.toULong(&ok);
02299       if (ok) {
02300         Object coll = Object::dynamicCast( getSelectHTMLCollection(exec, select.options(), select) );
02301         if ( !coll.isNull() )
02302           coll.put(exec,propertyName,value);
02303         return;
02304       }
02305       break;
02306     }
02307     case ID_APPLET:
02308     case ID_OBJECT:
02309     case ID_EMBED: {
02310       KParts::LiveConnectExtension *lc = getLiveConnectExtension(element);
02311       if (lc && lc->put(0, propertyName.qstring(), value.toString(exec).qstring()))
02312         return;
02313       break;
02314     }
02315     default:
02316       break;
02317   }
02318 
02319   const HashTable* table = classInfo()->propHashTable; // get the right hashtable
02320   const HashEntry* entry = Lookup::findEntry(table, propertyName);
02321   if (entry) {
02322     if (entry->attr & Function) // function: put as override property
02323     {
02324       ObjectImp::put(exec, propertyName, value, attr);
02325       return;
02326     }
02327     else if ((entry->attr & ReadOnly) == 0) // let DOMObjectLookupPut print the warning if not
02328     {
02329       putValueProperty(exec, entry->value, value, attr);
02330       return;
02331     }
02332   }
02333   DOMObjectLookupPut<KJS::HTMLElement, DOMElement>(exec, propertyName, value, attr, &KJS::HTMLElementTable, this);
02334 }
02335 
02336 void KJS::HTMLElement::putValueProperty(ExecState *exec, int token, const Value& value, int)
02337 {
02338   DOM::DOMString str = value.isA(NullType) ? DOM::DOMString() : value.toString(exec).string();
02339   DOMNode *kjsNode = new DOMNode(exec, KJS::toNode(value));
02340   // Need to create a Value wrapper to avoid leaking the KJS::DOMNode
02341   Value nodeValue(kjsNode);
02342   DOM::Node n = kjsNode->toNode();
02343   DOM::HTMLElement element = static_cast<DOM::HTMLElement>(node);
02344 #ifdef KJS_VERBOSE
02345   kdDebug(6070) << "KJS::HTMLElement::putValueProperty "
02346                 << " thisTag=" << element.tagName().string()
02347                 << " token=" << token << endl;
02348 #endif
02349 
02350   switch (element.elementId()) {
02351   case ID_HTML: {
02352       DOM::HTMLHtmlElement html = element;
02353       switch (token) {
02354       case HtmlVersion:         { html.setVersion(str); return; }
02355       }
02356   }
02357   break;
02358   case ID_HEAD: {
02359     DOM::HTMLHeadElement head = element;
02360     switch (token) {
02361     case HeadProfile:         { head.setProfile(str); return; }
02362     }
02363   }
02364   break;
02365   case ID_LINK: {
02366     DOM::HTMLLinkElement link = element;
02367     switch (token) {
02368       case LinkDisabled:        { link.setDisabled(value.toBoolean(exec)); return; }
02369       case LinkCharset:         { link.setCharset(str); return; }
02370       case LinkHref:            { link.setHref(str); return; }
02371       case LinkHrefLang:        { link.setHreflang(str); return; }
02372       case LinkMedia:           { link.setMedia(str); return; }
02373       case LinkRel:             { link.setRel(str); return; }
02374       case LinkRev:             { link.setRev(str); return; }
02375       case LinkTarget:          { link.setTarget(str); return; }
02376       case LinkType:            { link.setType(str); return; }
02377       }
02378     }
02379     break;
02380     case ID_TITLE: {
02381       DOM::HTMLTitleElement title = element;
02382       switch (token) {
02383       case TitleText:                 { title.setText(str); return; }
02384       }
02385     }
02386     break;
02387     case ID_META: {
02388       DOM::HTMLMetaElement meta = element;
02389       switch (token) {
02390       case MetaContent:         { meta.setContent(str); return; }
02391       case MetaHttpEquiv:       { meta.setHttpEquiv(str); return; }
02392       case MetaName:            { meta.setName(str); return; }
02393       case MetaScheme:          { meta.setScheme(str); return; }
02394       }
02395     }
02396     break;
02397     case ID_BASE: {
02398       DOM::HTMLBaseElement base = element;
02399       switch (token) {
02400       case BaseHref:            { base.setHref(str); return; }
02401       case BaseTarget:          { base.setTarget(str); return; }
02402       }
02403     }
02404     break;
02405     case ID_ISINDEX: {
02406       DOM::HTMLIsIndexElement isindex = element;
02407       switch (token) {
02408       // read-only: form
02409       case IsIndexPrompt:               { isindex.setPrompt(str); return; }
02410       }
02411     }
02412     break;
02413     case ID_STYLE: {
02414       DOM::HTMLStyleElement style = element;
02415       switch (token) {
02416       case StyleDisabled:        { style.setDisabled(value.toBoolean(exec)); return; }
02417       case StyleMedia:           { style.setMedia(str); return; }
02418       case StyleType:            { style.setType(str); return; }
02419       }
02420     }
02421     break;
02422     case ID_BODY: {
02423       DOM::HTMLBodyElement body = element;
02424       switch (token) {
02425       case BodyALink:           { body.setALink(str); return; }
02426       case BodyBackground:      { body.setBackground(str); return; }
02427       case BodyBgColor:         { body.setBgColor(str); return; }
02428       case BodyLink:            { body.setLink(str); return; }
02429       case BodyText:            { body.setText(str); return; }
02430       case BodyVLink:           { body.setVLink(str); return; }
02431       case BodyScrollLeft:
02432       case BodyScrollTop: {
02433         QScrollView* sview = body.ownerDocument().view();
02434         if (sview) {
02435           // Update the document's layout before we compute these attributes.
02436           DOM::DocumentImpl* docimpl = body.handle()->getDocument();
02437           if (docimpl)
02438             docimpl->updateLayout();
02439           if (token == BodyScrollLeft)
02440             sview->setContentsPos(value.toInteger(exec), sview->contentsY());
02441           else
02442             sview->setContentsPos(sview->contentsX(), value.toInteger(exec));
02443           }
02444         return;
02445         }
02446       }
02447     }
02448     break;
02449     case ID_FORM: {
02450       DOM::HTMLFormElement form = element;
02451       switch (token) {
02452       // read-only: elements
02453       // read-only: length
02454       case FormName:            { form.setName(str); return; }
02455       case FormAcceptCharset:   { form.setAcceptCharset(str); return; }
02456       case FormAction:          { form.setAction(str.string()); return; }
02457       case FormEncType:         { form.setEnctype(str); return; }
02458       case FormMethod:          { form.setMethod(str); return; }
02459       case FormTarget:          { form.setTarget(str); return; }
02460       }
02461     }
02462     break;
02463     case ID_SELECT: {
02464       DOM::HTMLSelectElement select = element;
02465       switch (token) {
02466       // read-only: type
02467       case SelectSelectedIndex:   { select.setSelectedIndex(value.toInteger(exec)); return; }
02468       case SelectValue:           { select.setValue(str); return; }
02469       case SelectLength:          { // read-only according to the NS spec, but webpages need it writeable
02470                                          Object coll = Object::dynamicCast( getSelectHTMLCollection(exec, select.options(), select) );
02471                                          if ( !coll.isNull() )
02472                                            coll.put(exec,"length",value);
02473                                          return;
02474                                        }
02475       // read-only: form
02476       // read-only: options
02477       case SelectDisabled:        { select.setDisabled(value.toBoolean(exec)); return; }
02478       case SelectMultiple:        { select.setMultiple(value.toBoolean(exec)); return; }
02479       case SelectName:            { select.setName(str); return; }
02480       case SelectSize:            { select.setSize(value.toInteger(exec)); return; }
02481       case SelectTabIndex:        { select.setTabIndex(value.toInteger(exec)); return; }
02482       }
02483     }
02484     break;
02485     case ID_OPTGROUP: {
02486       DOM::HTMLOptGroupElement optgroup = element;
02487       switch (token) {
02488       case OptGroupDisabled:        { optgroup.setDisabled(value.toBoolean(exec)); return; }
02489       case OptGroupLabel:           { optgroup.setLabel(str); return; }
02490       }
02491     }
02492     break;
02493     case ID_OPTION: {
02494       DOM::HTMLOptionElement option = element;
02495       switch (token) {
02496       // read-only: form
02497       case OptionDefaultSelected: { option.setDefaultSelected(value.toBoolean(exec)); return; }
02498       // read-only: text  <--- According to the DOM, but JavaScript and JScript both allow changes.
02499       // So, we'll do it here and not add it to our DOM headers.
02500       case OptionText:            { DOM::NodeList nl(option.childNodes());
02501                                     for (unsigned int i = 0; i < nl.length(); i++) {
02502                                         if (nl.item(i).nodeType() == DOM::Node::TEXT_NODE) {
02503                                             static_cast<DOM::Text>(nl.item(i)).setData(str);
02504                                             return;
02505                                         }
02506                                   }
02507                                   // No child text node found, creating one
02508                                   DOM::Text t = option.ownerDocument().createTextNode(str);
02509                                   try { option.appendChild(t); }
02510                                   catch(DOM::DOMException& e) {
02511                                     // #### exec->setException ?
02512                                   }
02513 
02514                                   return;
02515       }
02516       // read-only: index
02517       case OptionDisabled:        { option.setDisabled(value.toBoolean(exec)); return; }
02518       case OptionLabel:           { option.setLabel(str); return; }
02519       case OptionSelected:        { option.setSelected(value.toBoolean(exec)); return; }
02520       case OptionValue:           { option.setValue(str); return; }
02521       }
02522     }
02523     break;
02524     case ID_INPUT: {
02525       DOM::HTMLInputElement input = element;
02526       switch (token) {
02527       case InputDefaultValue:    { input.setDefaultValue(str); return; }
02528       case InputDefaultChecked:  { input.setDefaultChecked(value.toBoolean(exec)); return; }
02529       // read-only: form
02530       case InputAccept:          { input.setAccept(str); return; }
02531       case InputAccessKey:       { input.setAccessKey(str); return; }
02532       case InputAlign:           { input.setAlign(str); return; }
02533       case InputAlt:             { input.setAlt(str); return; }
02534       case InputChecked:         { input.setChecked(value.toBoolean(exec)); return; }
02535       case InputDisabled:        { input.setDisabled(value.toBoolean(exec)); return; }
02536       case InputMaxLength:       { input.setMaxLength(value.toInteger(exec)); return; }
02537       case InputName:            { input.setName(str); return; }
02538       case InputReadOnly:        { input.setReadOnly(value.toBoolean(exec)); return; }
02539       case InputSize:            { input.setSize(value.toInteger(exec)); return; }
02540       case InputSrc:             { input.setSrc(str); return; }
02541       case InputTabIndex:        { input.setTabIndex(value.toInteger(exec)); return; }
02542       case InputType:            { input.setType(str); return; }
02543       case InputUseMap:          { input.setUseMap(str); return; }
02544       case InputValue:           { input.setValue(str); return; }
02545       }
02546     }
02547     break;
02548     case ID_TEXTAREA: {
02549       DOM::HTMLTextAreaElement textarea = element;
02550       switch (token) {
02551       case TextAreaDefaultValue:    { textarea.setDefaultValue(str); return; }
02552       // read-only: form
02553       case TextAreaAccessKey:       { textarea.setAccessKey(str); return; }
02554       case TextAreaCols:            { textarea.setCols(value.toInteger(exec)); return; }
02555       case TextAreaDisabled:        { textarea.setDisabled(value.toBoolean(exec)); return; }
02556       case TextAreaName:            { textarea.setName(str); return; }
02557       case TextAreaReadOnly:        { textarea.setReadOnly(value.toBoolean(exec)); return; }
02558       case TextAreaRows:            { textarea.setRows(value.toInteger(exec)); return; }
02559       case TextAreaTabIndex:        { textarea.setTabIndex(value.toInteger(exec)); return; }
02560       // read-only: type
02561       case TextAreaValue:           { textarea.setValue(str); return; }
02562       }
02563     }
02564     break;
02565     case ID_BUTTON: {
02566       DOM::HTMLButtonElement button = element;
02567       switch (token) {
02568       // read-only: form
02569       case ButtonAccessKey:       { button.setAccessKey(str); return; }
02570       case ButtonDisabled:        { button.setDisabled(value.toBoolean(exec)); return; }
02571       case ButtonName:            { button.setName(str); return; }
02572       case ButtonTabIndex:        { button.setTabIndex(value.toInteger(exec)); return; }
02573       // read-only: type
02574       case ButtonValue:           { button.setValue(str); return; }
02575       }
02576     }
02577     break;
02578     case ID_LABEL: {
02579       DOM::HTMLLabelElement label = element;
02580       switch (token) {
02581       // read-only: form
02582       case LabelAccessKey:       { label.setAccessKey(str); return; }
02583       case LabelHtmlFor:         { label.setHtmlFor(str); return; }
02584       }
02585     }
02586     break;
02587 //    case ID_FIELDSET: {
02588 //      DOM::HTMLFieldSetElement fieldSet = element;
02589 //      // read-only: form
02590 //    }
02591 //    break;
02592     case ID_LEGEND: {
02593       DOM::HTMLLegendElement legend = element;
02594       switch (token) {
02595       // read-only: form
02596       case LegendAccessKey:       { legend.setAccessKey(str); return; }
02597       case LegendAlign:           { legend.setAlign(str); return; }
02598       }
02599     }
02600     break;
02601     case ID_UL: {
02602       DOM::HTMLUListElement uList = element;
02603       switch (token) {
02604       case UListCompact:         { uList.setCompact(value.toBoolean(exec)); return; }
02605       case UListType:            { uList.setType(str); return; }
02606       }
02607     }
02608     break;
02609     case ID_OL: {
02610       DOM::HTMLOListElement oList = element;
02611       switch (token) {
02612       case OListCompact:         { oList.setCompact(value.toBoolean(exec)); return; }
02613       case OListStart:           { oList.setStart(value.toInteger(exec)); return; }
02614       case OListType:            { oList.setType(str); return; }
02615       }
02616     }
02617     break;
02618     case ID_DL: {
02619       DOM::HTMLDListElement dList = element;
02620       switch (token) {
02621       case DListCompact:         { dList.setCompact(value.toBoolean(exec)); return; }
02622       }
02623     }
02624     break;
02625     case ID_DIR: {
02626       DOM::HTMLDirectoryElement directory = element;
02627       switch (token) {
02628       case DirectoryCompact:     { directory.setCompact(value.toBoolean(exec)); return; }
02629       }
02630     }
02631     break;
02632     case ID_MENU: {
02633       DOM::HTMLMenuElement menu = element;
02634       switch (token) {
02635       case MenuCompact:         { menu.setCompact(value.toBoolean(exec)); return; }
02636       }
02637     }
02638     break;
02639     case ID_LI: {
02640       DOM::HTMLLIElement li = element;
02641       switch (token) {
02642       case LIType:            { li.setType(str); return; }
02643       case LIValue:           { li.setValue(value.toInteger(exec)); return; }
02644       }
02645     }
02646     break;
02647     case ID_DIV: {
02648       DOM::HTMLDivElement div = element;
02649       switch (token) {
02650       case DivAlign:           { div.setAlign(str); return; }
02651       }
02652     }
02653     break;
02654     case ID_P: {
02655       DOM::HTMLParagraphElement paragraph = element;
02656       switch (token) {
02657       case ParagraphAlign:     { paragraph.setAlign(str); return; }
02658       }
02659     }
02660     break;
02661     case ID_H1:
02662     case ID_H2:
02663     case ID_H3:
02664     case ID_H4:
02665     case ID_H5:
02666     case ID_H6: {
02667       DOM::HTMLHeadingElement heading = element;
02668       switch (token) {
02669       case HeadingAlign:         { heading.setAlign(str); return; }
02670       }
02671     }
02672     break;
02673     case ID_BLOCKQUOTE: {
02674       DOM::HTMLBlockquoteElement blockquote = element;
02675       switch (token) {
02676       case BlockQuoteCite:       { blockquote.setCite(str); return; }
02677       }
02678     }
02679     break;
02680     case ID_Q: {
02681       DOM::HTMLQuoteElement quote = element;
02682       switch (token) {
02683       case QuoteCite:            { quote.setCite(str); return; }
02684       }
02685     }
02686     break;
02687     case ID_PRE: {
02688       DOM::HTMLPreElement pre = element;
02689       switch (token) {
02690       case PreWidth:           { pre.setWidth(value.toInteger(exec)); return; }
02691       }
02692     }
02693     break;
02694     case ID_BR: {
02695       DOM::HTMLBRElement br = element;
02696       switch (token) {
02697       case BRClear:           { br.setClear(str); return; }
02698       }
02699     }
02700     break;
02701     case ID_BASEFONT: {
02702       DOM::HTMLBaseFontElement baseFont = element;
02703       switch (token) {
02704       case BaseFontColor:           { baseFont.setColor(str); return; }
02705       case BaseFontFace:            { baseFont.setFace(str); return; }
02706       case BaseFontSize:            { baseFont.setSize(value.toInteger(exec)); return; }
02707       }
02708     }
02709     break;
02710     case ID_FONT: {
02711       DOM::HTMLFontElement font = element;
02712       switch (token) {
02713       case FontColor:           { font.setColor(str); return; }
02714       case FontFace:            { font.setFace(str); return; }
02715       case FontSize:            { font.setSize(str); return; }
02716       }
02717     }
02718     break;
02719     case ID_HR: {
02720       DOM::HTMLHRElement hr = element;
02721       switch (token) {
02722       case HRAlign:           { hr.setAlign(str); return; }
02723       case HRNoShade:         { hr.setNoShade(value.toBoolean(exec)); return; }
02724       case HRSize:            { hr.setSize(str); return; }
02725       case HRWidth:           { hr.setWidth(str); return; }
02726       }
02727     }
02728     break;
02729     case ID_INS:
02730     case ID_DEL: {
02731       DOM::HTMLModElement mod = element;
02732       switch (token) {
02733       case ModCite:            { mod.setCite(str); return; }
02734       case ModDateTime:        { mod.setDateTime(str); return; }
02735       }
02736     }
02737     break;
02738     case ID_A: {
02739       DOM::HTMLAnchorElement anchor = element;
02740       switch (token) {
02741       case AnchorAccessKey:       { anchor.setAccessKey(str); return; }
02742       case AnchorCharset:         { anchor.setCharset(str); return; }
02743       case AnchorCoords:          { anchor.setCoords(str); return; }
02744       case AnchorHref:            { anchor.setHref(str); return; }
02745       case AnchorHrefLang:        { anchor.setHreflang(str); return; }
02746       case AnchorName:            { anchor.setName(str); return; }
02747       case AnchorRel:             { anchor.setRel(str); return; }
02748       case AnchorRev:             { anchor.setRev(str); return; }
02749       case AnchorShape:           { anchor.setShape(str); return; }
02750       case AnchorTabIndex:        { anchor.setTabIndex(value.toInteger(exec)); return; }
02751       case AnchorTarget:          { anchor.setTarget(str); return; }
02752       case AnchorType:            { anchor.setType(str); return; }
02753       }
02754     }
02755     break;
02756     case ID_IMG: {
02757       DOM::HTMLImageElement image = element;
02758       switch (token) {
02759       case ImageName:            { image.setName(str); return; }
02760       case ImageAlign:           { image.setAlign(str); return; }
02761       case ImageAlt:             { image.setAlt(str); return; }
02762       case ImageBorder:          { image.setBorder(str); return; }
02763       case ImageHeight:          { image.setHeight(value.toInteger(exec)); return; }
02764       case ImageHspace:          { image.setHspace(value.toInteger(exec)); return; }
02765       case ImageIsMap:           { image.setIsMap(value.toBoolean(exec)); return; }
02766       case ImageLongDesc:        { image.setLongDesc(str); return; }
02767       case ImageSrc:             { image.setSrc(str); return; }
02768       case ImageUseMap:          { image.setUseMap(str); return; }
02769       case ImageVspace:          { image.setVspace(value.toInteger(exec)); return; }
02770       case ImageWidth:           { image.setWidth(value.toInteger(exec)); return; }
02771       }
02772     }
02773     break;
02774     case ID_OBJECT: {
02775       DOM::HTMLObjectElement object = element;
02776       switch (token) {
02777       // read-only: form
02778       case ObjectCode:                 { object.setCode(str); return; }
02779       case ObjectAlign:           { object.setAlign(str); return; }
02780       case ObjectArchive:         { object.setArchive(str); return; }
02781       case ObjectBorder:          { object.setBorder(str); return; }
02782       case ObjectCodeBase:        { object.setCodeBase(str); return; }
02783       case ObjectCodeType:        { object.setCodeType(str); return; }
02784       // read-only: ObjectContentDocument
02785       case ObjectData:            { object.setData(str); return; }
02786       case ObjectDeclare:         { object.setDeclare(value.toBoolean(exec)); return; }
02787       case ObjectHeight:          { object.setHeight(str); return; }
02788       case ObjectHspace:          { object.setHspace(value.toInteger(exec)); return; }
02789       case ObjectName:            { object.setName(str); return; }
02790       case ObjectStandby:         { object.setStandby(str); return; }
02791       case ObjectTabIndex:        { object.setTabIndex(value.toInteger(exec)); return; }
02792       case ObjectType:            { object.setType(str); return; }
02793       case ObjectUseMap:          { object.setUseMap(str); return; }
02794       case ObjectVspace:          { object.setVspace(value.toInteger(exec)); return; }
02795       case ObjectWidth:           { object.setWidth(str); return; }
02796       }
02797     }
02798     break;
02799     case ID_PARAM: {
02800       DOM::HTMLParamElement param = element;
02801       switch (token) {
02802       case ParamName:            { param.setName(str); return; }
02803       case ParamType:            { param.setType(str); return; }
02804       case ParamValue:           { param.setValue(str); return; }
02805       case ParamValueType:       { param.setValueType(str); return; }
02806       }
02807     }
02808     break;
02809     case ID_APPLET: {
02810       DOM::HTMLAppletElement applet = element;
02811       switch (token) {
02812       case AppletAlign:           { applet.setAlign(str); return; }
02813       case AppletAlt:             { applet.setAlt(str); return; }
02814       case AppletArchive:         { applet.setArchive(str); return; }
02815       case AppletCode:            { applet.setCode(str); return; }
02816       case AppletCodeBase:        { applet.setCodeBase(str); return; }
02817       case AppletHeight:          { applet.setHeight(str); return; }
02818       case AppletHspace:          { applet.setHspace(value.toInteger(exec)); return; }
02819       case AppletName:            { applet.setName(str); return; }
02820       case AppletObject:          { applet.setObject(str); return; }
02821       case AppletVspace:          { applet.setVspace(value.toInteger(exec)); return; }
02822       case AppletWidth:           { applet.setWidth(str); return; }
02823       }
02824     }
02825     break;
02826     case ID_MAP: {
02827       DOM::HTMLMapElement map = element;
02828       switch (token) {
02829       // read-only: areas
02830       case MapName:                 { map.setName(str); return; }
02831      }
02832     }
02833     break;
02834     case ID_AREA: {
02835       DOM::HTMLAreaElement area = element;
02836       switch (token) {
02837       case AreaAccessKey:       { area.setAccessKey(str); return; }
02838       case AreaAlt:             { area.setAlt(str); return; }
02839       case AreaCoords:          { area.setCoords(str); return; }
02840       case AreaHref:            { area.setHref(str); return; }
02841       case AreaNoHref:          { area.setNoHref(value.toBoolean(exec)); return; }
02842       case AreaShape:           { area.setShape(str); return; }
02843       case AreaTabIndex:        { area.setTabIndex(value.toInteger(exec)); return; }
02844       case AreaTarget:          { area.setTarget(str); return; }
02845       }
02846     }
02847     break;
02848     case ID_SCRIPT: {
02849       DOM::HTMLScriptElement script = element;
02850       switch (token) {
02851       case ScriptText:            { script.setText(str); return; }
02852       case ScriptHtmlFor:         { script.setHtmlFor(str); return; }
02853       case ScriptEvent:           { script.setEvent(str); return; }
02854       case ScriptCharset:         { script.setCharset(str); return; }
02855       case ScriptDefer:           { script.setDefer(value.toBoolean(exec)); return; }
02856       case ScriptSrc:             { script.setSrc(str); return; }
02857       case ScriptType:            { script.setType(str); return; }
02858       }
02859     }
02860     break;
02861     case ID_TABLE: {
02862       DOM::HTMLTableElement table = element;
02863       switch (token) {
02864       case TableCaption:         { table.setCaption(n); return; } // type HTMLTableCaptionElement
02865       case TableTHead:           { table.setTHead(n); return; } // type HTMLTableSectionElement
02866       case TableTFoot:           { table.setTFoot(n); return; } // type HTMLTableSectionElement
02867       // read-only: rows
02868       // read-only: tbodies
02869       case TableAlign:           { table.setAlign(str); return; }
02870       case TableBgColor:         { table.setBgColor(str); return; }
02871       case TableBorder:          { table.setBorder(str); return; }
02872       case TableCellPadding:     { table.setCellPadding(str); return; }
02873       case TableCellSpacing:     { table.setCellSpacing(str); return; }
02874       case TableFrame:           { table.setFrame(str); return; }
02875       case TableRules:           { table.setRules(str); return; }
02876       case TableSummary:         { table.setSummary(str); return; }
02877       case TableWidth:           { table.setWidth(str); return; }
02878       }
02879     }
02880     break;
02881     case ID_CAPTION: {
02882       DOM::HTMLTableCaptionElement tableCaption = element;
02883       switch (token) {
02884       case TableAlign:           { tableCaption.setAlign(str); return; }
02885       }
02886     }
02887     break;
02888     case ID_COL:
02889     case ID_COLGROUP: {
02890       DOM::HTMLTableColElement tableCol = element;
02891       switch (token) {
02892       case TableColAlign:           { tableCol.setAlign(str); return; }
02893       case TableColCh:              { tableCol.setCh(str); return; }
02894       case TableColChOff:           { tableCol.setChOff(str); return; }
02895       case TableColSpan:            { tableCol.setSpan(value.toInteger(exec)); return; }
02896       case TableColVAlign:          { tableCol.setVAlign(str); return; }
02897       case TableColWidth:           { tableCol.setWidth(str); return; }
02898       }
02899     }
02900     break;
02901     case ID_THEAD:
02902     case ID_TBODY:
02903     case ID_TFOOT: {
02904       DOM::HTMLTableSectionElement tableSection = element;
02905       switch (token) {
02906       case TableSectionAlign:           { tableSection.setAlign(str); return; }
02907       case TableSectionCh:              { tableSection.setCh(str); return; }
02908       case TableSectionChOff:           { tableSection.setChOff(str); return; }
02909       case TableSectionVAlign:          { tableSection.setVAlign(str); return; }
02910       // read-only: rows
02911       }
02912     }
02913     break;
02914     case ID_TR: {
02915       DOM::HTMLTableRowElement tableRow = element;
02916       switch (token) {
02917       // read-only: rowIndex
02918       // read-only: sectionRowIndex
02919       // read-only: cells
02920       case TableRowAlign:           { tableRow.setAlign(str); return; }
02921       case TableRowBgColor:         { tableRow.setBgColor(str); return; }
02922       case TableRowCh:              { tableRow.setCh(str); return; }
02923       case TableRowChOff:           { tableRow.setChOff(str); return; }
02924       case TableRowVAlign:          { tableRow.setVAlign(str); return; }
02925       }
02926     }
02927     break;
02928     case ID_TH:
02929     case ID_TD: {
02930       DOM::HTMLTableCellElement tableCell = element;
02931       switch (token) {
02932       // read-only: cellIndex
02933       case TableCellAbbr:            { tableCell.setAbbr(str); return; }
02934       case TableCellAlign:           { tableCell.setAlign(str); return; }
02935       case TableCellAxis:            { tableCell.setAxis(str); return; }
02936       case TableCellBgColor:         { tableCell.setBgColor(str); return; }
02937       case TableCellCh:              { tableCell.setCh(str); return; }
02938       case TableCellChOff:           { tableCell.setChOff(str); return; }
02939       case TableCellColSpan:         { tableCell.setColSpan(value.toInteger(exec)); return; }
02940       case TableCellHeaders:         { tableCell.setHeaders(str); return; }
02941       case TableCellHeight:          { tableCell.setHeight(str); return; }
02942       case TableCellNoWrap:          { tableCell.setNoWrap(value.toBoolean(exec)); return; }
02943       case TableCellRowSpan:         { tableCell.setRowSpan(value.toInteger(exec)); return; }
02944       case TableCellScope:           { tableCell.setScope(str); return; }
02945       case TableCellVAlign:          { tableCell.setVAlign(str); return; }
02946       case TableCellWidth:           { tableCell.setWidth(str); return; }
02947       }
02948     }
02949     break;
02950     case ID_FRAMESET: {
02951       DOM::HTMLFrameSetElement frameSet = element;
02952       switch (token) {
02953       case FrameSetCols:            { frameSet.setCols(str); return; }
02954       case FrameSetRows:            { frameSet.setRows(str); return; }
02955       }
02956     }
02957     break;
02958     case ID_LAYER: {
02959       DOM::HTMLLayerElement layerElement = element;
02960       switch (token) {
02961       case LayerTop:                   { layerElement.setTop(value.toInteger(exec)); return; }
02962       case LayerLeft:                  { layerElement.setLeft(value.toInteger(exec)); return; }
02963       case LayerVisibility:            { layerElement.setVisibility(str); return; }
02964       case LayerBgColor:               { layerElement.setBgColor(str); return; }
02965       // read-only: layers, clip
02966       }
02967     }
02968     break;
02969     case ID_FRAME: {
02970       DOM::HTMLFrameElement frameElement = element;
02971       switch (token) {
02972        // read-only: FrameContentDocument:
02973       case FrameFrameBorder:     { frameElement.setFrameBorder(str); return; }
02974       case FrameLongDesc:        { frameElement.setLongDesc(str); return; }
02975       case FrameMarginHeight:    { frameElement.setMarginHeight(str); return; }
02976       case FrameMarginWidth:     { frameElement.setMarginWidth(str); return; }
02977       case FrameName:            { frameElement.setName(str); return; }
02978       case FrameNoResize:        { frameElement.setNoResize(value.toBoolean(exec)); return; }
02979       case FrameScrolling:       { frameElement.setScrolling(str); return; }
02980       case FrameSrc:             { frameElement.setSrc(str); return; }
02981       case FrameLocation:        {
02982                                    static_cast<DOM::HTMLFrameElementImpl *>(frameElement.handle())->setLocation(str);
02983                                    return;
02984                                  }
02985       }
02986     }
02987     break;
02988     case ID_IFRAME: {
02989       DOM::HTMLIFrameElement iFrame = element;
02990       switch (token) {
02991       case IFrameAlign:           { iFrame.setAlign(str); return; }
02992       // read-only: IFrameContentDocument
02993       case IFrameFrameBorder:     { iFrame.setFrameBorder(str); return; }
02994       case IFrameHeight:          { iFrame.setHeight(str); return; }
02995       case IFrameLongDesc:        { iFrame.setLongDesc(str); return; }
02996       case IFrameMarginHeight:    { iFrame.setMarginHeight(str); return; }
02997       case IFrameMarginWidth:     { iFrame.setMarginWidth(str); return; }
02998       case IFrameName:            { iFrame.setName(str); return; }
02999       case IFrameScrolling:       { iFrame.setScrolling(str); return; }
03000       case IFrameSrc:             { iFrame.setSrc(str); return; }
03001       case IFrameWidth:           { iFrame.setWidth(str); return; }
03002       }
03003       break;
03004     }
03005   }
03006 
03007   // generic properties
03008   switch (token) {
03009   case ElementId:
03010     element.setId(str);
03011     return;
03012   case ElementTitle:
03013     element.setTitle(str);
03014     return;
03015   case ElementLang:
03016     element.setLang(str);
03017     return;
03018   case ElementDir:
03019     element.setDir(str);
03020     return;
03021   case ElementClassName:
03022     element.setClassName(str);
03023     return;
03024   case ElementInnerHTML:
03025     element.setInnerHTML(str);
03026     return;
03027   case ElementInnerText:
03028     element.setInnerText(str);
03029     return;
03030   default:
03031     kdDebug(6070) << "WARNING: KJS::HTMLElement::putValueProperty unhandled token " << token << " thisTag=" << element.tagName().string() << " str=" << str.string() << endl;
03032   }
03033 }
03034 
03035 // -------------------------------------------------------------------------
03036 /* Source for HTMLCollectionProtoTable.
03037 @begin HTMLCollectionProtoTable 3
03038   item      HTMLCollection::Item        DontDelete|Function 1
03039   namedItem HTMLCollection::NamedItem   DontDelete|Function 1
03040   tags      HTMLCollection::Tags        DontDelete|Function 1
03041 @end
03042 */
03043 DEFINE_PROTOTYPE("HTMLCollection", HTMLCollectionProto)
03044 IMPLEMENT_PROTOFUNC_DOM(HTMLCollectionProtoFunc)
03045 IMPLEMENT_PROTOTYPE(HTMLCollectionProto,HTMLCollectionProtoFunc)
03046 
03047 const ClassInfo KJS::HTMLCollection::info = { "HTMLCollection", 0, 0, 0 };
03048 
03049 KJS::HTMLCollection::HTMLCollection(ExecState *exec, const DOM::HTMLCollection& c)
03050   : DOMObject(HTMLCollectionProto::self(exec)), collection(c), hidden(false) {}
03051 
03052 KJS::HTMLCollection::~HTMLCollection()
03053 {
03054   ScriptInterpreter::forgetDOMObject(collection.handle());
03055 }
03056 
03057 bool KJS::HTMLCollection::toBoolean(ExecState *) const {
03058     return !hidden;
03059 }
03060 
03061 Type KJS::HTMLCollection::type() const {
03062     if (hidden) // what, me? No, I do not exist..
03063         return UndefinedType;
03064     else
03065         return ObjectImp::type();
03066 }
03067 
03068 // We have to implement hasProperty since we don't use a hashtable for 'selectedIndex' and 'length'
03069 // ## this breaks "for (..in..)" though.
03070 bool KJS::HTMLCollection::hasProperty(ExecState *exec, const Identifier &p) const
03071 {
03072   if (p == lengthPropertyName)
03073     return true;
03074   if ( collection.item(0).elementId() == ID_OPTION &&
03075        ( p == "selectedIndex" || p == "value" ) )
03076     return true;
03077   return DOMObject::hasProperty(exec, p);
03078 }
03079 
03080 Value KJS::HTMLCollection::tryGet(ExecState *exec, const Identifier &propertyName) const
03081 {
03082 #ifdef KJS_VERBOSE
03083   kdDebug(6070) << "KJS::HTMLCollection::tryGet " << propertyName.ascii() << endl;
03084 #endif
03085   if (propertyName == lengthPropertyName)
03086   {
03087 #ifdef KJS_VERBOSE
03088     kdDebug(6070) << "  collection length is " << collection.length() << endl;
03089 #endif
03090     return Number(collection.length());
03091   }
03092 
03093   if (collection.item(0).elementId() == ID_OPTION) {
03094     DOM::HTMLSelectElement parentSelect;
03095     DOM::Node node = collection.item(0).parentNode();
03096     while(!node.isNull() && parentSelect.isNull()) {
03097       if(node.elementId() == ID_SELECT)
03098         parentSelect = static_cast<DOM::HTMLSelectElement>(node);
03099       node = node.parentNode();
03100     }
03101     if ( parentSelect.isNull() )
03102       return Undefined();
03103     if (propertyName == "selectedIndex") {
03104       // NON-STANDARD options.selectedIndex
03105       return Number(parentSelect.selectedIndex());
03106     } else if ( propertyName == "value" ) {
03107       // NON-STANDARD options.value
03108       return String(parentSelect.value());
03109     }
03110   }
03111 
03112   // Look in the prototype (for functions) before assuming it's an item's name
03113   Object proto = Object::dynamicCast(prototype());
03114   if (!proto.isNull() && proto.hasProperty(exec,propertyName))
03115     return proto.get(exec,propertyName);
03116 
03117   // name or index ?
03118   bool ok;
03119   unsigned int u = propertyName.toULong(&ok);
03120   if (ok) {
03121     if ( u < collection.length() ) {
03122       DOM::Node node = collection.item(u);
03123       return getDOMNode(exec,node);
03124     } else
03125       return Undefined();
03126   }
03127   else
03128     return getNamedItems(exec,propertyName);
03129 }
03130 
03131 // HTMLCollections are strange objects, they support both get and call,
03132 // so that document.forms.item(0) and document.forms(0) both work.
03133 Value KJS::HTMLCollection::call(ExecState *exec, Object &thisObj, const List &args)
03134 {
03135   // This code duplication is necessary, HTMLCollection isn't a DOMFunction
03136   Value val;
03137   try {
03138     val = tryCall(exec, thisObj, args);
03139   }
03140   // pity there's no way to distinguish between these in JS code
03141   catch (...) {
03142     Object err = Error::create(exec, GeneralError, "Exception from HTMLCollection");
03143     exec->setException(err);
03144   }
03145   return val;
03146 }
03147 
03148 Value KJS::HTMLCollection::tryCall(ExecState *exec, Object &, const List &args)
03149 {
03150   // Do not use thisObj here. It can be the HTMLDocument, in the document.forms(i) case.
03151   /*if( thisObj.imp() != this )
03152   {
03153     kdDebug(6070) << "WARNING: thisObj.imp() != this in HTMLCollection::tryCall" << endl;
03154     KJS::printInfo(exec,"KJS::HTMLCollection::tryCall thisObj",thisObj,-1);
03155     KJS::printInfo(exec,"KJS::HTMLCollection::tryCall this",Value(this),-1);
03156   }*/
03157   // Also, do we need the TypeError test here ?
03158 
03159   if (args.size() == 1) {
03160     // support for document.all(<index>) etc.
03161     bool ok;
03162     UString s = args[0].toString(exec);
03163     unsigned int u = s.toULong(&ok);
03164     if (ok) {
03165       DOM::Element element = collection.item(u);
03166       return getDOMNode(exec,element);
03167     }
03168     // support for document.images('<name>') etc.
03169     return getNamedItems(exec,Identifier(s));
03170   }
03171   else if (args.size() >= 1) // the second arg, if set, is the index of the item we want
03172   {
03173     bool ok;
03174     UString s = args[0].toString(exec);
03175     unsigned int u = args[1].toString(exec).toULong(&ok);
03176     if (ok)
03177     {
03178       DOM::DOMString pstr = s.string();
03179       DOM::Node node = collection.namedItem(pstr);
03180       while (!node.isNull()) {
03181         if (!u)
03182           return getDOMNode(exec,node);
03183         node = collection.nextNamedItem(pstr);
03184         --u;
03185       }
03186     }
03187   }
03188   return Undefined();
03189 }
03190 
03191 Value KJS::HTMLCollection::getNamedItems(ExecState *exec, const Identifier &propertyName) const
03192 {
03193 #ifdef KJS_VERBOSE
03194   kdDebug(6070) << "KJS::HTMLCollection::getNamedItems " << propertyName.ascii() << endl;
03195 #endif
03196   DOM::DOMString pstr = propertyName.string();
03197   DOM::Node node = collection.namedItem(pstr);
03198   if(!node.isNull())
03199   {
03200     DOM::Node next = collection.nextNamedItem(pstr);
03201     if (next.isNull()) // single item
03202     {
03203 #ifdef KJS_VERBOSE
03204       kdDebug(6070) << "returning single node" << endl;
03205 #endif
03206       return getDOMNode(exec,node);
03207     }
03208     else // multiple items, return a collection
03209     {
03210       QValueList<DOM::Node> nodes;
03211       nodes.append(node);
03212       do {
03213         nodes.append(next);
03214         next = collection.nextNamedItem(pstr);
03215       } while (!next.isNull());
03216 #ifdef KJS_VERBOSE
03217       kdDebug(6070) << "returning list of " << nodes.count() << " nodes" << endl;
03218 #endif
03219       return Value(new DOMNamedNodesCollection(exec, nodes));
03220     }
03221   }
03222 #ifdef KJS_VERBOSE
03223   kdDebug(6070) << "not found" << endl;
03224 #endif
03225   return Undefined();
03226 }
03227 
03228 Value KJS::HTMLCollectionProtoFunc::tryCall(ExecState *exec, Object &thisObj, const List &args)
03229 {
03230   KJS_CHECK_THIS( KJS::HTMLCollection, thisObj );
03231   DOM::HTMLCollection coll = static_cast<KJS::HTMLCollection *>(thisObj.imp())->toCollection();
03232 
03233   switch (id) {
03234   case KJS::HTMLCollection::Item:
03235     return getDOMNode(exec,coll.item(args[0].toUInt32(exec)));
03236   case KJS::HTMLCollection::Tags:
03237   {
03238     DOM::DOMString tagName = args[0].toString(exec).string();
03239     DOM::NodeList list;
03240     // getElementsByTagName exists in Document and in Element, pick up the right one
03241     if ( coll.base().nodeType() == DOM::Node::DOCUMENT_NODE )
03242     {
03243       DOM::Document doc = coll.base();
03244       list = doc.getElementsByTagName(tagName);
03245 #ifdef KJS_VERBOSE
03246       kdDebug(6070) << "KJS::HTMLCollectionProtoFunc::tryCall document.tags(" << tagName.string() << ") -> " << list.length() << " items in node list" << endl;
03247 #endif
03248     } else
03249     {
03250       DOM::Element e = coll.base();
03251       list = e.getElementsByTagName(tagName);
03252 #ifdef KJS_VERBOSE
03253       kdDebug(6070) << "KJS::HTMLCollectionProtoFunc::tryCall element.tags(" << tagName.string() << ") -> " << list.length() << " items in node list" << endl;
03254 #endif
03255     }
03256     return getDOMNodeList(exec, list);
03257   }
03258   case KJS::HTMLCollection::NamedItem:
03259   {
03260     Value val = static_cast<HTMLCollection *>(thisObj.imp())->getNamedItems(exec, Identifier(args[0].toString(exec)));
03261     // Must return null when asking for a named item that isn't in the collection
03262     // (DOM2 testsuite, HTMLCollection12 test)
03263     if ( val.type() == KJS::UndefinedType )
03264       return Null();
03265     else
03266       return val;
03267   }
03268   default:
03269     return Undefined();
03270   }
03271 }
03272 
03273 Value KJS::HTMLSelectCollection::tryGet(ExecState *exec, const Identifier &p) const
03274 {
03275   if (p == "selectedIndex")
03276     return Number(element.selectedIndex());
03277 
03278   return  HTMLCollection::tryGet(exec, p);
03279 }
03280 
03281 void KJS::HTMLSelectCollection::tryPut(ExecState *exec, const Identifier &propertyName, const Value& value, int)
03282 {
03283 #ifdef KJS_VERBOSE
03284   kdDebug(6070) << "KJS::HTMLSelectCollection::tryPut " << propertyName.qstring() << endl;
03285 #endif
03286   if ( propertyName == "selectedIndex" ) {
03287     element.setSelectedIndex( value.toInteger( exec ) );
03288     return;
03289   }
03290   // resize ?
03291   else if (propertyName == lengthPropertyName) {
03292     unsigned newLen;
03293     bool converted = value.toUInt32(newLen);
03294 
03295     if (!converted) {
03296       return;
03297     }
03298 
03299     long diff = element.length() - newLen;
03300 
03301     if (diff < 0) { // add dummy elements
03302       do {
03303         element.add(element.ownerDocument().createElement("OPTION"), DOM::HTMLElement());
03304       } while (++diff);
03305     }
03306     else // remove elements
03307       while (diff-- > 0)
03308         element.remove(newLen);
03309 
03310     return;
03311   }
03312   // an index ?
03313   bool ok;
03314   unsigned int u = propertyName.toULong(&ok);
03315   if (!ok)
03316     return;
03317 
03318   if (value.isA(NullType) || value.isA(UndefinedType)) {
03319     // null and undefined delete. others, too ?
03320     element.remove(u);
03321     return;
03322   }
03323 
03324   // is v an option element ?
03325   DOM::Node node = KJS::toNode(value);
03326   if (node.isNull() || node.elementId() != ID_OPTION)
03327     return;
03328 
03329   DOM::HTMLOptionElement option = static_cast<DOM::HTMLOptionElement>(node);
03330   if ( option.ownerDocument() != element.ownerDocument() )
03331     option = static_cast<DOM::HTMLOptionElement>(element.ownerDocument().importNode(option, true));
03332   long diff = long(u) - element.length();
03333   DOM::HTMLElement before;
03334   // out of array bounds ? first insert empty dummies
03335   if (diff > 0) {
03336     while (diff--) {
03337       element.add(element.ownerDocument().createElement("OPTION"), before);
03338     }
03339     // replace an existing entry ?
03340   } else if (diff < 0) {
03341     before = element.options().item(u+1);
03342     element.remove(u);
03343   }
03344   // finally add the new element
03345   element.add(option, before);
03346 }
03347 
03349 
03350 OptionConstructorImp::OptionConstructorImp(ExecState *exec, const DOM::Document &d)
03351     : ObjectImp(), doc(d)
03352 {
03353   // ## isn't there some redundancy between ObjectImp::_proto and the "prototype" property ?
03354   //put(exec,"prototype", ...,DontEnum|DontDelete|ReadOnly);
03355 
03356   // no. of arguments for constructor
03357   // ## is 4 correct ? 0 to 4, it seems to be
03358   put(exec,lengthPropertyName, Number(4), ReadOnly|DontDelete|DontEnum);
03359 }
03360 
03361 bool OptionConstructorImp::implementsConstruct() const
03362 {
03363   return true;
03364 }
03365 
03366 Object OptionConstructorImp::construct(ExecState *exec, const List &args)
03367 {
03368   DOM::Element el = doc.createElement("OPTION");
03369   DOM::HTMLOptionElement opt = static_cast<DOM::HTMLOptionElement>(el);
03370   int sz = args.size();
03371   DOM::Text t = doc.createTextNode("");
03372   try { opt.appendChild(t); }
03373   catch(DOM::DOMException& e) {
03374     // #### exec->setException ?
03375   }
03376   if (sz > 0)
03377     t.setData(args[0].toString(exec).string()); // set the text
03378   if (sz > 1)
03379     opt.setValue(args[1].toString(exec).string());
03380   if (sz > 2)
03381     opt.setDefaultSelected(args[2].toBoolean(exec));
03382   if (sz > 3)
03383     opt.setSelected(args[3].toBoolean(exec));
03384 
03385   return Object::dynamicCast(getDOMNode(exec,opt));
03386 }
03387 
03389 
03390 ImageConstructorImp::ImageConstructorImp(ExecState *, const DOM::Document &d)
03391     : ObjectImp(), doc(d)
03392 {
03393 }
03394 
03395 bool ImageConstructorImp::implementsConstruct() const
03396 {
03397   return true;
03398 }
03399 
03400 Object ImageConstructorImp::construct(ExecState *exec, const List &)
03401 {
03402   /* TODO: fetch optional height & width from arguments */
03403 
03404   Object result(new Image(exec, doc));
03405   /* TODO: do we need a prototype ? */
03406 
03407   return result;
03408 }
03409 
03410 const ClassInfo KJS::Image::info = { "Image", 0, &ImageTable, 0 };
03411 
03412 /* Source for ImageTable.
03413 @begin ImageTable 5
03414   src       Image::Src      DontDelete
03415   width     Image::Width        DontDelete|ReadOnly
03416   height    Image::Height       DontDelete|ReadOnly
03417   complete  Image::Complete     DontDelete|ReadOnly
03418   onload    Image::OnLoad       DontDelete
03419 @end
03420 */
03421 Image::Image(ExecState* exec, const DOM::Document &d)
03422   : DOMObject(exec->interpreter()->builtinObjectPrototype()), doc(d), img(0),
03423   m_onLoadListener(0L)
03424 {
03425 }
03426 
03427 Value Image::tryGet(ExecState *exec, const Identifier &propertyName) const
03428 {
03429   return DOMObjectLookupGetValue<Image,DOMObject>(exec, propertyName, &ImageTable, this);
03430 }
03431 
03432 Value Image::getValueProperty(ExecState *, int token) const
03433 {
03434   switch (token) {
03435   case Src:
03436     return String(src);
03437   case Complete:
03438     return Boolean(!img || img->status() >= khtml::CachedObject::Persistent);
03439   case Width:
03440     if ( !img )
03441       return Undefined();
03442     return Number(img->pixmap_size().width());
03443   case Height:
03444     if ( !img )
03445       return Undefined();
03446     return Number(img->pixmap_size().height());
03447   case OnLoad:
03448     if ( m_onLoadListener && m_onLoadListener->listenerObjImp())
03449       return m_onLoadListener->listenerObj();
03450     return Undefined();
03451   default:
03452     kdDebug(6070) << "WARNING: Image::getValueProperty unhandled token " << token << endl;
03453     return Value();
03454   }
03455 }
03456 
03457 void Image::tryPut(ExecState *exec, const Identifier &propertyName, const Value& value, int attr)
03458 {
03459   DOMObjectLookupPut<Image, DOMObject>( exec, propertyName, value, attr, &ImageTable, this );
03460 }
03461 
03462 void Image::putValueProperty(ExecState *exec, int token, const Value& value, int)
03463 {
03464   switch (token) {
03465   case Src:
03466     src = value.toString(exec);
03467     if ( img ) img->deref(this);
03468     img = static_cast<DOM::DocumentImpl*>( doc.handle() )->docLoader()->requestImage( src.string() );
03469 // ### img = doc ? doc->docLoader()->requestImage( src.string() ) : 0;
03470     if ( img ) {
03471       img->ref(this);
03472       src = img->url();
03473     }
03474     break;
03475   case OnLoad:
03476     if ( m_onLoadListener )
03477         m_onLoadListener->deref();
03478     m_onLoadListener = Window::retrieveActive(exec)->getJSEventListener(value,true);
03479     if ( m_onLoadListener )
03480         m_onLoadListener->ref();
03481     break;
03482   default:
03483     kdDebug(6070) << "WARNING: Image::putValueProperty unhandled token " << token << endl;
03484   }
03485 }
03486 
03487 void Image::notifyFinished(khtml::CachedObject * finishedObj)
03488 {
03489   if (img == finishedObj /*&& !loadEventSent*/ && m_onLoadListener ) {
03490     //loadEventSent = true;
03491     DOM::EventImpl *evt = new DOM::EventImpl( (DOM::EventImpl::EventId)ATTR_ONLOAD, false, false );
03492     evt->setTarget( 0 );
03493     evt->ref();
03494     DOM::Event e(evt);
03495     Object thisObj( this );
03496     m_onLoadListener->hackSetThisObj( thisObj );
03497     m_onLoadListener->handleEvent( e );
03498     if ( m_onLoadListener ) // #57195
03499         m_onLoadListener->hackUnsetThisObj();
03500     evt->deref();
03501   }
03502 }
03503 
03504 Image::~Image()
03505 {
03506   if ( img ) img->deref(this);
03507   if ( m_onLoadListener )
03508       m_onLoadListener->deref();
03509 }
03510 
03511 Value KJS::getHTMLCollection(ExecState *exec, const DOM::HTMLCollection& c, bool hide)
03512 {
03513   Value coll = cacheDOMObject<DOM::HTMLCollection, KJS::HTMLCollection>(exec, c);
03514   if (hide) {
03515     KJS::HTMLCollection *impl = static_cast<KJS::HTMLCollection*>(coll.imp());
03516     impl->hide();
03517   }
03518   return coll;
03519 }
03520 
03521 Value KJS::getSelectHTMLCollection(ExecState *exec, const DOM::HTMLCollection& c, const DOM::HTMLSelectElement& e)
03522 {
03523   DOMObject *ret;
03524   if (c.isNull())
03525     return Null();
03526   ScriptInterpreter* interp = static_cast<ScriptInterpreter *>(exec->interpreter());
03527   if ((ret = interp->getDOMObject(c.handle())))
03528     return Value(ret);
03529   else {
03530     ret = new HTMLSelectCollection(exec, c, e);
03531     interp->putDOMObject(c.handle(),ret);
03532     return Value(ret);
03533   }
03534 }
KDE Logo
This file is part of the documentation for khtml Library Version 3.3.2.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Sun Jan 15 13:34:49 2006 by doxygen 1.4.2 written by Dimitri van Heesch, © 1997-2003