kjs_html.cpp

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