# khtml Library API Documentation

Overview | Class Hierarchy | Classes | Classes (annotated) | Members | Source Files

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

This file is part of the documentation for kdelibs Version 3.1.5.
Documentation copyright © 1996-2002 the KDE developers.
Generated on Wed Jan 28 13:34:20 2004 by doxygen 1.3.4 written by Dimitri van Heesch, © 1997-2001