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 24
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   status    KJS::HTMLElement::InputChecked      DontDelete
00756   disabled  KJS::HTMLElement::InputDisabled     DontDelete
00757   maxLength KJS::HTMLElement::InputMaxLength    DontDelete
00758   name      KJS::HTMLElement::InputName     DontDelete
00759   readOnly  KJS::HTMLElement::InputReadOnly     DontDelete
00760   size      KJS::HTMLElement::InputSize     DontDelete
00761   src       KJS::HTMLElement::InputSrc      DontDelete
00762   tabIndex  KJS::HTMLElement::InputTabIndex     DontDelete
00763   type      KJS::HTMLElement::InputType     DontDelete
00764   useMap    KJS::HTMLElement::InputUseMap       DontDelete
00765   value     KJS::HTMLElement::InputValue        DontDelete
00766   selectionStart KJS::HTMLElement::InputSelectionStart  DontDelete
00767   selectionEnd   KJS::HTMLElement::InputSelectionEnd    DontDelete
00768   blur      KJS::HTMLElement::InputBlur     DontDelete|Function 0
00769   focus     KJS::HTMLElement::InputFocus        DontDelete|Function 0
00770   select    KJS::HTMLElement::InputSelect       DontDelete|Function 0
00771   click     KJS::HTMLElement::InputClick        DontDelete|Function 0
00772   setSelectionRange KJS::HTMLElement::InputSetSelectionRange DontDelete|Function 2
00773 @end
00774 @begin HTMLTextAreaElementTable 13
00775   defaultValue  KJS::HTMLElement::TextAreaDefaultValue  DontDelete
00776   form      KJS::HTMLElement::TextAreaForm      DontDelete|ReadOnly
00777   accessKey KJS::HTMLElement::TextAreaAccessKey DontDelete
00778   cols      KJS::HTMLElement::TextAreaCols      DontDelete
00779   disabled  KJS::HTMLElement::TextAreaDisabled  DontDelete
00780   name      KJS::HTMLElement::TextAreaName      DontDelete
00781   readOnly  KJS::HTMLElement::TextAreaReadOnly  DontDelete
00782   rows      KJS::HTMLElement::TextAreaRows      DontDelete
00783   tabIndex  KJS::HTMLElement::TextAreaTabIndex  DontDelete
00784   type      KJS::HTMLElement::TextAreaType      DontDelete|ReadOnly
00785   value     KJS::HTMLElement::TextAreaValue     DontDelete
00786   selectionStart KJS::HTMLElement::TextAreaSelectionStart DontDelete
00787   selectionEnd   KJS::HTMLElement::TextAreaSelectionEnd   DontDelete
00788   textLength     KJS::HTMLElement::TextAreaTextLength     DontDelete|ReadOnly
00789   blur      KJS::HTMLElement::TextAreaBlur      DontDelete|Function 0
00790   focus     KJS::HTMLElement::TextAreaFocus     DontDelete|Function 0
00791   select    KJS::HTMLElement::TextAreaSelect    DontDelete|Function 0
00792   setSelectionRange KJS::HTMLElement::TextAreaSetSelectionRange DontDelete|Function 2
00793 @end
00794 @begin HTMLButtonElementTable 9
00795   form      KJS::HTMLElement::ButtonForm        DontDelete|ReadOnly
00796   accessKey KJS::HTMLElement::ButtonAccessKey   DontDelete
00797   disabled  KJS::HTMLElement::ButtonDisabled    DontDelete
00798   name      KJS::HTMLElement::ButtonName        DontDelete
00799   tabIndex  KJS::HTMLElement::ButtonTabIndex    DontDelete
00800   type      KJS::HTMLElement::ButtonType        DontDelete|ReadOnly
00801   value     KJS::HTMLElement::ButtonValue       DontDelete
00802   blur      KJS::HTMLElement::ButtonBlur            DontDelete|Function 0
00803   focus     KJS::HTMLElement::ButtonFocus           DontDelete|Function 0
00804 @end
00805 @begin HTMLLabelElementTable 3
00806   form      KJS::HTMLElement::LabelForm     DontDelete|ReadOnly
00807   accessKey KJS::HTMLElement::LabelAccessKey    DontDelete
00808   htmlFor   KJS::HTMLElement::LabelHtmlFor      DontDelete
00809 @end
00810 @begin HTMLFieldSetElementTable 1
00811   form      KJS::HTMLElement::FieldSetForm      DontDelete|ReadOnly
00812 @end
00813 @begin HTMLLegendElementTable 3
00814   form      KJS::HTMLElement::LegendForm        DontDelete|ReadOnly
00815   accessKey KJS::HTMLElement::LegendAccessKey   DontDelete
00816   align     KJS::HTMLElement::LegendAlign       DontDelete
00817 @end
00818 @begin HTMLUListElementTable 2
00819   compact   KJS::HTMLElement::UListCompact      DontDelete
00820   type      KJS::HTMLElement::UListType     DontDelete
00821 @end
00822 @begin HTMLOListElementTable 3
00823   compact   KJS::HTMLElement::OListCompact      DontDelete
00824   start     KJS::HTMLElement::OListStart        DontDelete
00825   type      KJS::HTMLElement::OListType     DontDelete
00826 @end
00827 @begin HTMLDListElementTable 1
00828   compact   KJS::HTMLElement::DListCompact      DontDelete
00829 @end
00830 @begin HTMLDirectoryElementTable 1
00831   compact   KJS::HTMLElement::DirectoryCompact  DontDelete
00832 @end
00833 @begin HTMLMenuElementTable 1
00834   compact   KJS::HTMLElement::MenuCompact       DontDelete
00835 @end
00836 @begin HTMLLIElementTable 2
00837   type      KJS::HTMLElement::LIType        DontDelete
00838   value     KJS::HTMLElement::LIValue       DontDelete
00839 @end
00840 @begin HTMLDivElementTable 1
00841   align     KJS::HTMLElement::DivAlign      DontDelete
00842 @end
00843 @begin HTMLParagraphElementTable 1
00844   align     KJS::HTMLElement::ParagraphAlign    DontDelete
00845 @end
00846 @begin HTMLHeadingElementTable 1
00847   align     KJS::HTMLElement::HeadingAlign      DontDelete
00848 @end
00849 @begin HTMLBlockQuoteElementTable 1
00850   cite      KJS::HTMLElement::BlockQuoteCite    DontDelete
00851 @end
00852 @begin HTMLQuoteElementTable 1
00853   cite      KJS::HTMLElement::QuoteCite     DontDelete
00854 @end
00855 @begin HTMLPreElementTable 1
00856   width     KJS::HTMLElement::PreWidth      DontDelete
00857 @end
00858 @begin HTMLBRElementTable 1
00859   clear     KJS::HTMLElement::BRClear       DontDelete
00860 @end
00861 @begin HTMLBaseFontElementTable 3
00862   color     KJS::HTMLElement::BaseFontColor     DontDelete
00863   face      KJS::HTMLElement::BaseFontFace      DontDelete
00864   size      KJS::HTMLElement::BaseFontSize      DontDelete
00865 @end
00866 @begin HTMLFontElementTable 3
00867   color     KJS::HTMLElement::FontColor     DontDelete
00868   face      KJS::HTMLElement::FontFace      DontDelete
00869   size      KJS::HTMLElement::FontSize      DontDelete
00870 @end
00871 @begin HTMLHRElementTable 4
00872   align     KJS::HTMLElement::HRAlign       DontDelete
00873   noShade   KJS::HTMLElement::HRNoShade     DontDelete
00874   size      KJS::HTMLElement::HRSize        DontDelete
00875   width     KJS::HTMLElement::HRWidth       DontDelete
00876 @end
00877 @begin HTMLModElementTable 2
00878   cite      KJS::HTMLElement::ModCite       DontDelete
00879   dateTime  KJS::HTMLElement::ModDateTime       DontDelete
00880 @end
00881 @begin HTMLAnchorElementTable 23
00882   accessKey KJS::HTMLElement::AnchorAccessKey   DontDelete
00883   charset   KJS::HTMLElement::AnchorCharset     DontDelete
00884   coords    KJS::HTMLElement::AnchorCoords      DontDelete
00885   href      KJS::HTMLElement::AnchorHref        DontDelete
00886   hreflang  KJS::HTMLElement::AnchorHrefLang    DontDelete
00887   hash      KJS::HTMLElement::AnchorHash        DontDelete|ReadOnly
00888   host      KJS::HTMLElement::AnchorHost        DontDelete|ReadOnly
00889   hostname  KJS::HTMLElement::AnchorHostname    DontDelete|ReadOnly
00890   name      KJS::HTMLElement::AnchorName        DontDelete
00891   pathname  KJS::HTMLElement::AnchorPathName    DontDelete|ReadOnly
00892   port      KJS::HTMLElement::AnchorPort        DontDelete|ReadOnly
00893   protocol  KJS::HTMLElement::AnchorProtocol    DontDelete|ReadOnly
00894   rel       KJS::HTMLElement::AnchorRel     DontDelete
00895   rev       KJS::HTMLElement::AnchorRev     DontDelete
00896   search    KJS::HTMLElement::AnchorSearch      DontDelete|ReadOnly
00897   shape     KJS::HTMLElement::AnchorShape       DontDelete
00898   tabIndex  KJS::HTMLElement::AnchorTabIndex    DontDelete
00899   target    KJS::HTMLElement::AnchorTarget      DontDelete
00900   text      KJS::HTMLElement::AnchorText        DontDelete|ReadOnly
00901   type      KJS::HTMLElement::AnchorType        DontDelete
00902   blur      KJS::HTMLElement::AnchorBlur        DontDelete|Function 0
00903   focus     KJS::HTMLElement::AnchorFocus       DontDelete|Function 0
00904   click     KJS::HTMLElement::AnchorClick       DontDelete|Function 0
00905 @end
00906 @begin HTMLImageElementTable 15
00907   name      KJS::HTMLElement::ImageName     DontDelete
00908   align     KJS::HTMLElement::ImageAlign        DontDelete
00909   alt       KJS::HTMLElement::ImageAlt      DontDelete
00910   border    KJS::HTMLElement::ImageBorder       DontDelete
00911   complete  KJS::HTMLElement::ImageComplete     DontDelete|ReadOnly
00912   height    KJS::HTMLElement::ImageHeight       DontDelete
00913   hspace    KJS::HTMLElement::ImageHspace       DontDelete
00914   isMap     KJS::HTMLElement::ImageIsMap        DontDelete
00915   longDesc  KJS::HTMLElement::ImageLongDesc     DontDelete
00916   src       KJS::HTMLElement::ImageSrc      DontDelete
00917   useMap    KJS::HTMLElement::ImageUseMap       DontDelete
00918   vspace    KJS::HTMLElement::ImageVspace       DontDelete
00919   width     KJS::HTMLElement::ImageWidth        DontDelete
00920   x         KJS::HTMLElement::ImageX        DontDelete|ReadOnly
00921   y         KJS::HTMLElement::ImageY        DontDelete|ReadOnly
00922 @end
00923 @begin HTMLObjectElementTable 20
00924   form        KJS::HTMLElement::ObjectForm        DontDelete|ReadOnly
00925   code        KJS::HTMLElement::ObjectCode        DontDelete
00926   align       KJS::HTMLElement::ObjectAlign       DontDelete
00927   archive     KJS::HTMLElement::ObjectArchive     DontDelete
00928   border      KJS::HTMLElement::ObjectBorder      DontDelete
00929   codeBase    KJS::HTMLElement::ObjectCodeBase    DontDelete
00930   codeType    KJS::HTMLElement::ObjectCodeType    DontDelete
00931   contentDocument KJS::HTMLElement::ObjectContentDocument DontDelete|ReadOnly
00932   data        KJS::HTMLElement::ObjectData        DontDelete
00933   declare     KJS::HTMLElement::ObjectDeclare     DontDelete
00934   height      KJS::HTMLElement::ObjectHeight      DontDelete
00935   hspace      KJS::HTMLElement::ObjectHspace      DontDelete
00936   name        KJS::HTMLElement::ObjectName        DontDelete
00937   standby     KJS::HTMLElement::ObjectStandby     DontDelete
00938   tabIndex    KJS::HTMLElement::ObjectTabIndex    DontDelete
00939   type        KJS::HTMLElement::ObjectType        DontDelete
00940   useMap      KJS::HTMLElement::ObjectUseMap      DontDelete
00941   vspace      KJS::HTMLElement::ObjectVspace      DontDelete
00942   width       KJS::HTMLElement::ObjectWidth       DontDelete
00943 @end
00944 @begin HTMLParamElementTable 4
00945   name      KJS::HTMLElement::ParamName     DontDelete
00946   type      KJS::HTMLElement::ParamType     DontDelete
00947   value     KJS::HTMLElement::ParamValue        DontDelete
00948   valueType KJS::HTMLElement::ParamValueType    DontDelete
00949 @end
00950 @begin HTMLAppletElementTable 11
00951   align     KJS::HTMLElement::AppletAlign       DontDelete
00952   alt       KJS::HTMLElement::AppletAlt     DontDelete
00953   archive   KJS::HTMLElement::AppletArchive     DontDelete
00954   code      KJS::HTMLElement::AppletCode        DontDelete
00955   codeBase  KJS::HTMLElement::AppletCodeBase    DontDelete
00956   height    KJS::HTMLElement::AppletHeight      DontDelete
00957   hspace    KJS::HTMLElement::AppletHspace      DontDelete
00958   name      KJS::HTMLElement::AppletName        DontDelete
00959   object    KJS::HTMLElement::AppletObject      DontDelete
00960   vspace    KJS::HTMLElement::AppletVspace      DontDelete
00961   width     KJS::HTMLElement::AppletWidth       DontDelete
00962 @end
00963 @begin HTMLMapElementTable 2
00964   areas     KJS::HTMLElement::MapAreas      DontDelete|ReadOnly
00965   name      KJS::HTMLElement::MapName       DontDelete
00966 @end
00967 @begin HTMLAreaElementTable 15
00968   accessKey KJS::HTMLElement::AreaAccessKey     DontDelete
00969   alt       KJS::HTMLElement::AreaAlt       DontDelete
00970   coords    KJS::HTMLElement::AreaCoords        DontDelete
00971   href      KJS::HTMLElement::AreaHref      DontDelete
00972   hash      KJS::HTMLElement::AreaHash      DontDelete|ReadOnly
00973   host      KJS::HTMLElement::AreaHost      DontDelete|ReadOnly
00974   hostname  KJS::HTMLElement::AreaHostName      DontDelete|ReadOnly
00975   pathname  KJS::HTMLElement::AreaPathName      DontDelete|ReadOnly
00976   port      KJS::HTMLElement::AreaPort      DontDelete|ReadOnly
00977   protocol  KJS::HTMLElement::AreaProtocol      DontDelete|ReadOnly
00978   search    KJS::HTMLElement::AreaSearch        DontDelete|ReadOnly
00979   noHref    KJS::HTMLElement::AreaNoHref        DontDelete
00980   shape     KJS::HTMLElement::AreaShape     DontDelete
00981   tabIndex  KJS::HTMLElement::AreaTabIndex      DontDelete
00982   target    KJS::HTMLElement::AreaTarget        DontDelete
00983 @end
00984 @begin HTMLScriptElementTable 7
00985   text      KJS::HTMLElement::ScriptText        DontDelete
00986   htmlFor   KJS::HTMLElement::ScriptHtmlFor     DontDelete
00987   event     KJS::HTMLElement::ScriptEvent       DontDelete
00988   charset   KJS::HTMLElement::ScriptCharset     DontDelete
00989   defer     KJS::HTMLElement::ScriptDefer       DontDelete
00990   src       KJS::HTMLElement::ScriptSrc     DontDelete
00991   type      KJS::HTMLElement::ScriptType        DontDelete
00992 @end
00993 @begin HTMLTableElementTable 23
00994   caption   KJS::HTMLElement::TableCaption      DontDelete
00995   tHead     KJS::HTMLElement::TableTHead        DontDelete
00996   tFoot     KJS::HTMLElement::TableTFoot        DontDelete
00997   rows      KJS::HTMLElement::TableRows     DontDelete|ReadOnly
00998   tBodies   KJS::HTMLElement::TableTBodies      DontDelete|ReadOnly
00999   align     KJS::HTMLElement::TableAlign        DontDelete
01000   bgColor   KJS::HTMLElement::TableBgColor      DontDelete
01001   border    KJS::HTMLElement::TableBorder       DontDelete
01002   cellPadding   KJS::HTMLElement::TableCellPadding  DontDelete
01003   cellSpacing   KJS::HTMLElement::TableCellSpacing  DontDelete
01004   frame     KJS::HTMLElement::TableFrame        DontDelete
01005   rules     KJS::HTMLElement::TableRules        DontDelete
01006   summary   KJS::HTMLElement::TableSummary      DontDelete
01007   width     KJS::HTMLElement::TableWidth        DontDelete
01008   createTHead   KJS::HTMLElement::TableCreateTHead  DontDelete|Function 0
01009   deleteTHead   KJS::HTMLElement::TableDeleteTHead  DontDelete|Function 0
01010   createTFoot   KJS::HTMLElement::TableCreateTFoot  DontDelete|Function 0
01011   deleteTFoot   KJS::HTMLElement::TableDeleteTFoot  DontDelete|Function 0
01012   createCaption KJS::HTMLElement::TableCreateCaption    DontDelete|Function 0
01013   deleteCaption KJS::HTMLElement::TableDeleteCaption    DontDelete|Function 0
01014   insertRow KJS::HTMLElement::TableInsertRow    DontDelete|Function 1
01015   deleteRow KJS::HTMLElement::TableDeleteRow    DontDelete|Function 1
01016 @end
01017 @begin HTMLTableCaptionElementTable 1
01018   align     KJS::HTMLElement::TableCaptionAlign DontDelete
01019 @end
01020 @begin HTMLTableColElementTable 7
01021   align     KJS::HTMLElement::TableColAlign     DontDelete
01022   ch        KJS::HTMLElement::TableColCh        DontDelete
01023   chOff     KJS::HTMLElement::TableColChOff     DontDelete
01024   span      KJS::HTMLElement::TableColSpan      DontDelete
01025   vAlign    KJS::HTMLElement::TableColVAlign    DontDelete
01026   width     KJS::HTMLElement::TableColWidth     DontDelete
01027 @end
01028 @begin HTMLTableSectionElementTable 7
01029   align     KJS::HTMLElement::TableSectionAlign     DontDelete
01030   ch        KJS::HTMLElement::TableSectionCh        DontDelete
01031   chOff     KJS::HTMLElement::TableSectionChOff     DontDelete
01032   vAlign    KJS::HTMLElement::TableSectionVAlign        DontDelete
01033   rows      KJS::HTMLElement::TableSectionRows      DontDelete|ReadOnly
01034   insertRow KJS::HTMLElement::TableSectionInsertRow     DontDelete|Function 1
01035   deleteRow KJS::HTMLElement::TableSectionDeleteRow     DontDelete|Function 1
01036 @end
01037 @begin HTMLTableRowElementTable 11
01038   rowIndex  KJS::HTMLElement::TableRowRowIndex      DontDelete|ReadOnly
01039   sectionRowIndex KJS::HTMLElement::TableRowSectionRowIndex DontDelete|ReadOnly
01040   cells     KJS::HTMLElement::TableRowCells         DontDelete|ReadOnly
01041   align     KJS::HTMLElement::TableRowAlign         DontDelete
01042   bgColor   KJS::HTMLElement::TableRowBgColor       DontDelete
01043   ch        KJS::HTMLElement::TableRowCh            DontDelete
01044   chOff     KJS::HTMLElement::TableRowChOff         DontDelete
01045   vAlign    KJS::HTMLElement::TableRowVAlign        DontDelete
01046   insertCell    KJS::HTMLElement::TableRowInsertCell        DontDelete|Function 1
01047   deleteCell    KJS::HTMLElement::TableRowDeleteCell        DontDelete|Function 1
01048 @end
01049 @begin HTMLTableCellElementTable 15
01050   cellIndex KJS::HTMLElement::TableCellCellIndex        DontDelete|ReadOnly
01051   abbr      KJS::HTMLElement::TableCellAbbr         DontDelete
01052   align     KJS::HTMLElement::TableCellAlign        DontDelete
01053   axis      KJS::HTMLElement::TableCellAxis         DontDelete
01054   bgColor   KJS::HTMLElement::TableCellBgColor      DontDelete
01055   ch        KJS::HTMLElement::TableCellCh           DontDelete
01056   chOff     KJS::HTMLElement::TableCellChOff        DontDelete
01057   colSpan   KJS::HTMLElement::TableCellColSpan      DontDelete
01058   headers   KJS::HTMLElement::TableCellHeaders      DontDelete
01059   height    KJS::HTMLElement::TableCellHeight       DontDelete
01060   noWrap    KJS::HTMLElement::TableCellNoWrap       DontDelete
01061   rowSpan   KJS::HTMLElement::TableCellRowSpan      DontDelete
01062   scope     KJS::HTMLElement::TableCellScope        DontDelete
01063   vAlign    KJS::HTMLElement::TableCellVAlign       DontDelete
01064   width     KJS::HTMLElement::TableCellWidth        DontDelete
01065 @end
01066 @begin HTMLFrameSetElementTable 2
01067   cols      KJS::HTMLElement::FrameSetCols          DontDelete
01068   rows      KJS::HTMLElement::FrameSetRows          DontDelete
01069 @end
01070 @begin HTMLLayerElementTable 6
01071   top         KJS::HTMLElement::LayerTop            DontDelete
01072   left        KJS::HTMLElement::LayerLeft           DontDelete
01073   visibility      KJS::HTMLElement::LayerVisibility     DontDelete
01074   bgColor     KJS::HTMLElement::LayerBgColor        DontDelete
01075   document        KJS::HTMLElement::LayerDocument       DontDelete|ReadOnly
01076   clip        KJS::HTMLElement::LayerClip           DontDelete|ReadOnly
01077   layers      KJS::HTMLElement::LayerLayers         DontDelete|ReadOnly
01078 @end
01079 @begin HTMLFrameElementTable 9
01080   contentDocument KJS::HTMLElement::FrameContentDocument        DontDelete|ReadOnly
01081   contentWindow KJS::HTMLElement::FrameContentWindow        DontDelete|ReadOnly
01082   frameBorder     KJS::HTMLElement::FrameFrameBorder        DontDelete
01083   longDesc    KJS::HTMLElement::FrameLongDesc       DontDelete
01084   marginHeight    KJS::HTMLElement::FrameMarginHeight       DontDelete
01085   marginWidth     KJS::HTMLElement::FrameMarginWidth        DontDelete
01086   name        KJS::HTMLElement::FrameName           DontDelete
01087   noResize    KJS::HTMLElement::FrameNoResize       DontDelete
01088   scrolling   KJS::HTMLElement::FrameScrolling      DontDelete
01089   src         KJS::HTMLElement::FrameSrc            DontDelete
01090   location    KJS::HTMLElement::FrameLocation       DontDelete
01091 @end
01092 @begin HTMLIFrameElementTable 12
01093   align       KJS::HTMLElement::IFrameAlign         DontDelete
01094   contentDocument KJS::HTMLElement::IFrameContentDocument       DontDelete|ReadOnly
01095   contentWindow KJS::HTMLElement::IFrameContentWindow        DontDelete|ReadOnly
01096   frameBorder     KJS::HTMLElement::IFrameFrameBorder       DontDelete
01097   height      KJS::HTMLElement::IFrameHeight        DontDelete
01098   longDesc    KJS::HTMLElement::IFrameLongDesc      DontDelete
01099   marginHeight    KJS::HTMLElement::IFrameMarginHeight      DontDelete
01100   marginWidth     KJS::HTMLElement::IFrameMarginWidth       DontDelete
01101   name        KJS::HTMLElement::IFrameName          DontDelete
01102   scrolling   KJS::HTMLElement::IFrameScrolling     DontDelete
01103   src         KJS::HTMLElement::IFrameSrc           DontDelete
01104   width       KJS::HTMLElement::IFrameWidth         DontDelete
01105 @end
01106 
01107 @begin HTMLMarqueeElementTable 2
01108   start           KJS::HTMLElement::MarqueeStart        DontDelete|Function 0
01109   stop            KJS::HTMLElement::MarqueeStop                 DontDelete|Function 0
01110 @end
01111 
01112 */
01113 
01114 static KParts::LiveConnectExtension *getLiveConnectExtension(const DOM::HTMLElement & element)
01115 {
01116   DOM::HTMLDocument doc = element.ownerDocument();
01117   KHTMLView *view = static_cast<DOM::DocumentImpl*>(doc.handle())->view();
01118   if (view && element.handle())
01119     return view->part()->liveConnectExtension(static_cast<khtml::RenderPart*>(element.handle()->renderer()));
01120   return 0L;
01121 }
01122 
01123 Value KJS::HTMLElement::tryGet(ExecState *exec, const Identifier &propertyName) const
01124 {
01125   DOM::HTMLElement element = static_cast<DOM::HTMLElement>(node);
01126 #ifdef KJS_VERBOSE
01127   kdDebug(6070) << "KJS::HTMLElement::tryGet " << propertyName.qstring() << " thisTag=" << element.tagName().string() << endl;
01128 #endif
01129   // First look at dynamic properties
01130   switch (element.elementId()) {
01131     case ID_FORM: {
01132       DOM::HTMLFormElement form = element;
01133       // Check if we're retrieving an element (by index or by name)
01134       bool ok;
01135       uint u = propertyName.toULong(&ok);
01136 
01137       if (ok)
01138         return getDOMNode(exec,form.elements().item(u));
01139       KJS::HTMLCollection coll(exec, form.elements());
01140       Value namedItems = coll.getNamedItems(exec, propertyName);
01141       if (namedItems.type() != UndefinedType)
01142         return namedItems;
01143     }
01144       break;
01145     case ID_SELECT: {
01146       DOM::HTMLSelectElement select = element;
01147       bool ok;
01148       uint u = propertyName.toULong(&ok);
01149       if (ok)
01150         return getDOMNode(exec,select.options().item(u)); // not specified by DOM(?) but supported in netscape/IE
01151     }
01152       break;
01153     case ID_APPLET:
01154     case ID_OBJECT:
01155     case ID_EMBED: {
01156       KParts::LiveConnectExtension *lc = getLiveConnectExtension(element);
01157       QString rvalue;
01158       KParts::LiveConnectExtension::Type rtype;
01159       unsigned long robjid;
01160       if (lc && lc->get(0, propertyName.qstring(), rtype, robjid, rvalue))
01161         return getLiveConnectValue(lc, propertyName.qstring(), rtype, rvalue, robjid);
01162     }
01163       break;
01164   default:
01165     break;
01166   }
01167 
01168   const HashTable* table = classInfo()->propHashTable; // get the right hashtable
01169   const HashEntry* entry = Lookup::findEntry(table, propertyName);
01170   if (entry) {
01171     if (entry->attr & Function)
01172       return lookupOrCreateFunction<KJS::HTMLElementFunction>(exec, propertyName, this, entry->value, entry->params, entry->attr);
01173     return getValueProperty(exec, entry->value);
01174   }
01175 
01176   // Base HTMLElement stuff or parent class forward, as usual
01177   return DOMObjectLookupGet<KJS::HTMLElementFunction, KJS::HTMLElement, DOMElement>(exec, propertyName, &KJS::HTMLElementTable, this);
01178 }
01179 
01180 Value KJS::HTMLElement::getValueProperty(ExecState *exec, int token) const
01181 {
01182   DOM::HTMLElement element = static_cast<DOM::HTMLElement>(node);
01183   switch (element.elementId()) {
01184   case ID_HTML: {
01185     DOM::HTMLHtmlElement html = element;
01186     if      (token == HtmlVersion)         return String(html.version());
01187   }
01188   break;
01189   case ID_HEAD: {
01190     DOM::HTMLHeadElement head = element;
01191     if      (token == HeadProfile)         return String(head.profile());
01192   }
01193   break;
01194   case ID_LINK: {
01195     DOM::HTMLLinkElement link = element;
01196     switch (token) {
01197     case LinkDisabled:        return Boolean(link.disabled());
01198     case LinkCharset:         return String(link.charset());
01199     case LinkHref:            return String(link.href());
01200     case LinkHrefLang:        return String(link.hreflang());
01201     case LinkMedia:           return String(link.media());
01202     case LinkRel:             return String(link.rel());
01203     case LinkRev:             return String(link.rev());
01204     case LinkTarget:          return String(link.target());
01205     case LinkType:            return String(link.type());
01206     case LinkSheet:           return getDOMStyleSheet(exec,static_cast<DOM::ProcessingInstruction>(node).sheet());
01207     }
01208   }
01209   break;
01210   case ID_TITLE: {
01211     DOM::HTMLTitleElement title = element;
01212     switch (token) {
01213     case TitleText:                 return String(title.text());
01214     }
01215   }
01216   break;
01217   case ID_META: {
01218     DOM::HTMLMetaElement meta = element;
01219     switch (token) {
01220     case MetaContent:         return String(meta.content());
01221     case MetaHttpEquiv:       return String(meta.httpEquiv());
01222     case MetaName:            return String(meta.name());
01223     case MetaScheme:          return String(meta.scheme());
01224     }
01225   }
01226   break;
01227   case ID_BASE: {
01228     DOM::HTMLBaseElement base = element;
01229     switch (token) {
01230     case BaseHref:            return String(base.href());
01231     case BaseTarget:          return String(base.target());
01232     }
01233   }
01234   break;
01235   case ID_ISINDEX: {
01236     DOM::HTMLIsIndexElement isindex = element;
01237     switch (token) {
01238     case IsIndexForm:            return getDOMNode(exec,isindex.form()); // type HTMLFormElement
01239     case IsIndexPrompt:          return String(isindex.prompt());
01240     }
01241   }
01242   break;
01243   case ID_STYLE: {
01244     DOM::HTMLStyleElement style = element;
01245     switch (token) {
01246     case StyleDisabled:        return Boolean(style.disabled());
01247     case StyleMedia:           return String(style.media());
01248     case StyleType:            return String(style.type());
01249     case StyleSheet:           return getDOMStyleSheet(exec,style.sheet());
01250     }
01251   }
01252   break;
01253   case ID_BODY: {
01254     DOM::HTMLBodyElement body = element;
01255     switch (token) {
01256     case BodyALink:           return String(body.aLink());
01257     case BodyBackground:      return String(body.background());
01258     case BodyBgColor:         return String(body.bgColor());
01259     case BodyLink:            return String(body.link());
01260     case BodyText:            return String(body.text());
01261     case BodyVLink:           return String(body.vLink());
01262     case BodyOnLoad: {
01263         DOM::DocumentImpl *doc = static_cast<DOM::DocumentImpl *>(node.ownerDocument().handle());
01264         if (!doc || !checkNodeSecurity(exec, node))
01265           return Undefined();
01266         DOMNode* kjsDocNode = new DOMNode(exec, doc);
01267         // Need to create a Value wrapper to avoid leaking the KJS::DOMNode
01268         Value nodeValue(kjsDocNode);
01269         return kjsDocNode->getListener( DOM::EventImpl::LOAD_EVENT );
01270     }
01271     default:
01272       // Update the document's layout before we compute these attributes.
01273       DOM::DocumentImpl* docimpl = node.handle()->getDocument();
01274       if (docimpl)
01275         docimpl->updateLayout();
01276 
01277       switch( token ) {
01278       case BodyScrollLeft:
01279         return Number(body.ownerDocument().view() ? body.ownerDocument().view()->contentsX() : 0);
01280       case BodyScrollTop:
01281         return Number(body.ownerDocument().view() ? body.ownerDocument().view()->contentsY() : 0);
01282       case BodyScrollHeight:   return Number(body.ownerDocument().view() ? body.ownerDocument().view()->contentsHeight() : 0);
01283       case BodyScrollWidth:    return Number(body.ownerDocument().view() ? body.ownerDocument().view()->contentsWidth() : 0);
01284       }
01285     }
01286   }
01287   break;
01288 
01289   case ID_FORM: {
01290     DOM::HTMLFormElement form = element;
01291     switch (token) {
01292     case FormElements:        return getHTMLCollection(exec,form.elements());
01293     case FormLength:          return Number(form.length());
01294     case FormName:            return String(form.name()); // NOT getString (IE gives empty string)
01295     case FormAcceptCharset:   return String(form.acceptCharset());
01296     case FormAction:          return String(form.action());
01297     case FormEncType:         return String(form.enctype());
01298     case FormMethod:          return String(form.method());
01299     case FormTarget:          return String(form.target());
01300     }
01301   }
01302   break;
01303   case ID_SELECT: {
01304     DOM::HTMLSelectElement select = element;
01305     switch (token) {
01306     case SelectType:            return String(select.type());
01307     case SelectSelectedIndex:   return Number(select.selectedIndex());
01308     case SelectValue:           return String(select.value());
01309     case SelectLength:          return Number(select.length());
01310     case SelectForm:            return getDOMNode(exec,select.form()); // type HTMLFormElement
01311     case SelectOptions:         return getSelectHTMLCollection(exec, select.options(), select); // type HTMLCollection
01312     case SelectDisabled:        return Boolean(select.disabled());
01313     case SelectMultiple:        return Boolean(select.multiple());
01314     case SelectName:            return String(select.name());
01315     case SelectSize:            return Number(select.size());
01316     case SelectTabIndex:        return Number(select.tabIndex());
01317     }
01318   }
01319   break;
01320   case ID_OPTGROUP: {
01321     DOM::HTMLOptGroupElement optgroup = element;
01322     switch (token) {
01323     case OptGroupDisabled:        return Boolean(optgroup.disabled());
01324     case OptGroupLabel:           return String(optgroup.label());
01325     }
01326   }
01327   break;
01328   case ID_OPTION: {
01329     DOM::HTMLOptionElement option = element;
01330     switch (token) {
01331     case OptionForm:            return getDOMNode(exec,option.form()); // type HTMLFormElement
01332     case OptionDefaultSelected: return Boolean(option.defaultSelected());
01333     case OptionText:            return String(option.text());
01334     case OptionIndex:           return Number(option.index());
01335     case OptionDisabled:        return Boolean(option.disabled());
01336     case OptionLabel:           return String(option.label());
01337     case OptionSelected:        return Boolean(option.selected());
01338     case OptionValue:           return String(option.value());
01339     }
01340   }
01341   break;
01342   case ID_INPUT: {
01343     DOM::HTMLInputElement input = element;
01344     switch (token) {
01345     case InputDefaultValue:    return String(input.defaultValue());
01346     case InputDefaultChecked:  return Boolean(input.defaultChecked());
01347     case InputForm:            return getDOMNode(exec,input.form()); // type HTMLFormElement
01348     case InputAccept:          return String(input.accept());
01349     case InputAccessKey:       return String(input.accessKey());
01350     case InputAlign:           return String(input.align());
01351     case InputAlt:             return String(input.alt());
01352     case InputChecked:         return Boolean(input.checked());
01353     case InputDisabled:        return Boolean(input.disabled());
01354     case InputMaxLength:       return Number(input.maxLength());
01355     case InputName:            return String(input.name()); // NOT getString (IE gives empty string)
01356     case InputReadOnly:        return Boolean(input.readOnly());
01357     case InputSize:            return Number(input.getSize());
01358     case InputSrc:             return String(input.src());
01359     case InputTabIndex:        return Number(input.tabIndex());
01360     case InputType:            return String(input.type());
01361     case InputUseMap:          return String(input.useMap());
01362     case InputValue:           return String(input.value());
01363     case InputSelectionStart:  {
01364         long val = input.selectionStart();
01365         if (val != -1)
01366           return Number(val);
01367         else
01368           return Undefined();
01369       }
01370     case InputSelectionEnd:  {
01371         long val = input.selectionEnd();
01372         if (val != -1)
01373           return Number(val);
01374         else
01375           return Undefined();
01376       }
01377     }
01378   }
01379   break;
01380   case ID_TEXTAREA: {
01381     DOM::HTMLTextAreaElement textarea = element;
01382     switch (token) {
01383     case TextAreaDefaultValue:    return String(textarea.defaultValue());
01384     case TextAreaForm:            return getDOMNode(exec,textarea.form()); // type HTMLFormElement
01385     case TextAreaAccessKey:       return String(textarea.accessKey());
01386     case TextAreaCols:            return Number(textarea.cols());
01387     case TextAreaDisabled:        return Boolean(textarea.disabled());
01388     case TextAreaName:            return String(textarea.name());
01389     case TextAreaReadOnly:        return Boolean(textarea.readOnly());
01390     case TextAreaRows:            return Number(textarea.rows());
01391     case TextAreaTabIndex:        return Number(textarea.tabIndex());
01392     case TextAreaType:            return String(textarea.type());
01393     case TextAreaValue:           return String(textarea.value());
01394     case TextAreaSelectionStart:  return Number(textarea.selectionStart());
01395     case TextAreaSelectionEnd:    return Number(textarea.selectionEnd());
01396     case TextAreaTextLength:      return Number(textarea.textLength());
01397     }
01398   }
01399   break;
01400   case ID_BUTTON: {
01401     DOM::HTMLButtonElement button = element;
01402     switch (token) {
01403     case ButtonForm:            return getDOMNode(exec,button.form()); // type HTMLFormElement
01404     case ButtonAccessKey:       return String(button.accessKey());
01405     case ButtonDisabled:        return Boolean(button.disabled());
01406     case ButtonName:            return String(button.name());
01407     case ButtonTabIndex:        return Number(button.tabIndex());
01408     case ButtonType:            return String(button.type());
01409     case ButtonValue:           return String(button.value());
01410     }
01411   }
01412   break;
01413   case ID_LABEL: {
01414     DOM::HTMLLabelElement label = element;
01415     switch (token) {
01416     case LabelForm:            return getDOMNode(exec,label.form()); // type HTMLFormElement
01417     case LabelAccessKey:       return String(label.accessKey());
01418     case LabelHtmlFor:         return String(label.htmlFor());
01419     }
01420   }
01421   break;
01422   case ID_FIELDSET: {
01423     DOM::HTMLFieldSetElement fieldSet = element;
01424     switch (token) {
01425     case FieldSetForm:            return getDOMNode(exec,fieldSet.form()); // type HTMLFormElement
01426     }
01427   }
01428   break;
01429   case ID_LEGEND: {
01430     DOM::HTMLLegendElement legend = element;
01431     switch (token) {
01432     case LegendForm:            return getDOMNode(exec,legend.form()); // type HTMLFormElement
01433     case LegendAccessKey:       return String(legend.accessKey());
01434     case LegendAlign:           return String(legend.align());
01435     }
01436   }
01437   break;
01438   case ID_UL: {
01439     DOM::HTMLUListElement uList = element;
01440     switch (token) {
01441     case UListCompact:         return Boolean(uList.compact());
01442     case UListType:            return String(uList.type());
01443     }
01444   }
01445   break;
01446   case ID_OL: {
01447     DOM::HTMLOListElement oList = element;
01448     switch (token) {
01449     case OListCompact:         return Boolean(oList.compact());
01450     case OListStart:           return Number(oList.start());
01451     case OListType:            return String(oList.type());
01452     }
01453   }
01454   break;
01455   case ID_DL: {
01456     DOM::HTMLDListElement dList = element;
01457     switch (token) {
01458     case DListCompact:         return Boolean(dList.compact());
01459     }
01460   }
01461   break;
01462   case ID_DIR: {
01463     DOM::HTMLDirectoryElement directory = element;
01464     switch (token) {
01465     case DirectoryCompact:         return Boolean(directory.compact());
01466     }
01467   }
01468   break;
01469   case ID_MENU: {
01470     DOM::HTMLMenuElement menu = element;
01471     switch (token) {
01472     case MenuCompact:         return Boolean(menu.compact());
01473     }
01474   }
01475   break;
01476   case ID_LI: {
01477     DOM::HTMLLIElement li = element;
01478     switch (token) {
01479     case LIType:            return String(li.type());
01480     case LIValue:           return Number(li.value());
01481     }
01482   }
01483   break;
01484   case ID_DIV: {
01485     DOM::HTMLDivElement div = element;
01486     switch (token) {
01487     case DivAlign:           return String(div.align());
01488     }
01489   }
01490   break;
01491   case ID_P: {
01492     DOM::HTMLParagraphElement paragraph = element;
01493     switch (token) {
01494     case ParagraphAlign:           return String(paragraph.align());
01495     }
01496   }
01497   break;
01498   case ID_H1:
01499   case ID_H2:
01500   case ID_H3:
01501   case ID_H4:
01502   case ID_H5:
01503   case ID_H6: {
01504     DOM::HTMLHeadingElement heading = element;
01505     switch (token) {
01506     case HeadingAlign:           return String(heading.align());
01507     }
01508   }
01509   break;
01510   case ID_BLOCKQUOTE: {
01511     DOM::HTMLBlockquoteElement blockquote = element;
01512     switch (token) {
01513     case BlockQuoteCite:            return String(blockquote.cite());
01514     }
01515   }
01516   case ID_Q: {
01517     DOM::HTMLQuoteElement quote = element;
01518     switch (token) {
01519     case QuoteCite:            return String(quote.cite());
01520     }
01521   }
01522   case ID_PRE: {
01523     DOM::HTMLPreElement pre = element;
01524     switch (token) {
01525     case PreWidth:           return Number(pre.width());
01526     }
01527   }
01528   break;
01529   case ID_BR: {
01530     DOM::HTMLBRElement br = element;
01531     switch (token) {
01532     case BRClear:           return String(br.clear());
01533     }
01534   }
01535   break;
01536   case ID_BASEFONT: {
01537     DOM::HTMLBaseFontElement baseFont = element;
01538     switch (token) {
01539     case BaseFontColor:           return String(baseFont.color());
01540     case BaseFontFace:            return String(baseFont.face());
01541     case BaseFontSize:            return Number(baseFont.getSize());
01542     }
01543   }
01544   break;
01545   case ID_FONT: {
01546     DOM::HTMLFontElement font = element;
01547     switch (token) {
01548     case FontColor:           return String(font.color());
01549     case FontFace:            return String(font.face());
01550     case FontSize:            return String(font.size());
01551     }
01552   }
01553   break;
01554   case ID_HR: {
01555     DOM::HTMLHRElement hr = element;
01556     switch (token) {
01557     case HRAlign:           return String(hr.align());
01558     case HRNoShade:         return Boolean(hr.noShade());
01559     case HRSize:            return String(hr.size());
01560     case HRWidth:           return String(hr.width());
01561     }
01562   }
01563   break;
01564   case ID_INS:
01565   case ID_DEL: {
01566     DOM::HTMLModElement mod = element;
01567     switch (token) {
01568     case ModCite:            return String(mod.cite());
01569     case ModDateTime:        return String(mod.dateTime());
01570     }
01571   }
01572   break;
01573   case ID_A: {
01574     DOM::HTMLAnchorElement anchor = element;
01575     switch (token) {
01576     case AnchorAccessKey:       return String(anchor.accessKey());
01577     case AnchorCharset:         return String(anchor.charset());
01578     case AnchorCoords:          return String(anchor.coords());
01579     case AnchorHref:            return String(anchor.href());
01580     case AnchorHrefLang:        return String(anchor.hreflang());
01581     case AnchorHash:            return String('#'+KURL(anchor.href().string()).ref());
01582     case AnchorHost:            return String(KURL(anchor.href().string()).host());
01583     case AnchorHostname: {
01584       KURL url(anchor.href().string());
01585       kdDebug(6070) << "anchor::hostname uses:" <<url.url()<<endl;
01586       if (url.port()==0)
01587         return String(url.host());
01588       else
01589         return String(url.host() + ":" + QString::number(url.port()));
01590     }
01591     case AnchorPathName:        return String(KURL(anchor.href().string()).path());
01592     case AnchorPort:            return String(QString::number(KURL(anchor.href().string()).port()));
01593     case AnchorProtocol:        return String(KURL(anchor.href().string()).protocol()+":");
01594     case AnchorSearch:          return String(KURL(anchor.href().string()).query());
01595     case AnchorName:            return String(anchor.name());
01596     case AnchorRel:             return String(anchor.rel());
01597     case AnchorRev:             return String(anchor.rev());
01598     case AnchorShape:           return String(anchor.shape());
01599     case AnchorTabIndex:        return Number(anchor.tabIndex());
01600     case AnchorTarget:          return String(anchor.target());
01601     // Not specified in http://msdn.microsoft.com/workshop/author/dhtml/reference/objects/a.asp
01602     // Mozilla returns the inner text.
01603     case AnchorText:            return String(anchor.innerText());
01604     case AnchorType:            return String(anchor.type());
01605     }
01606   }
01607   break;
01608   case ID_IMG: {
01609     DOM::HTMLImageElement image = element;
01610     switch (token) {
01611     case ImageName:            return String(image.name()); // NOT getString (IE gives empty string)
01612     case ImageAlign:           return String(image.align());
01613     case ImageAlt:             return String(image.alt());
01614     case ImageBorder:          return String(image.getBorder());
01615     case ImageComplete:        return Boolean(static_cast<DOM::HTMLImageElementImpl*>( image.handle() )->complete());
01616     case ImageHeight:          return Number(image.height());
01617     case ImageHspace:          return Number(image.hspace());
01618     case ImageIsMap:           return Boolean(image.isMap());
01619     case ImageLongDesc:        return String(image.longDesc());
01620     case ImageSrc:             return String(image.src());
01621     case ImageUseMap:          return String(image.useMap());
01622     case ImageVspace:          return Number(image.vspace());
01623     case ImageWidth:           return Number(image.width());
01624     case ImageX:               return Number(image.x());
01625     case ImageY:               return Number(image.y());
01626     }
01627   }
01628   break;
01629   case ID_OBJECT: {
01630     DOM::HTMLObjectElement object = element;
01631     switch (token) {
01632     case ObjectForm:            return getDOMNode(exec,object.form()); // type HTMLFormElement
01633     case ObjectCode:            return String(object.code());
01634     case ObjectAlign:           return String(object.align());
01635     case ObjectArchive:         return String(object.archive());
01636     case ObjectBorder:          return String(object.border());
01637     case ObjectCodeBase:        return String(object.codeBase());
01638     case ObjectCodeType:        return String(object.codeType());
01639     case ObjectContentDocument: return checkNodeSecurity(exec,object.contentDocument()) ?
01640                        getDOMNode(exec, object.contentDocument()) : Undefined();
01641     case ObjectData:            return String(object.data());
01642     case ObjectDeclare:         return Boolean(object.declare());
01643     case ObjectHeight:          return String(object.height());
01644     case ObjectHspace:          return Number(object.getHspace());
01645     case ObjectName:            return String(object.name());
01646     case ObjectStandby:         return String(object.standby());
01647     case ObjectTabIndex:        return Number(object.tabIndex());
01648     case ObjectType:            return String(object.type());
01649     case ObjectUseMap:          return String(object.useMap());
01650     case ObjectVspace:          return Number(object.getVspace());
01651     case ObjectWidth:           return String(object.width());
01652     }
01653   }
01654   break;
01655   case ID_PARAM: {
01656     DOM::HTMLParamElement param = element;
01657     switch (token) {
01658     case ParamName:            return String(param.name());
01659     case ParamType:            return String(param.type());
01660     case ParamValue:           return String(param.value());
01661     case ParamValueType:       return String(param.valueType());
01662     }
01663   }
01664   break;
01665   case ID_APPLET: {
01666     DOM::HTMLAppletElement applet = element;
01667     switch (token) {
01668     case AppletAlign:           return String(applet.align());
01669     case AppletAlt:             return String(applet.alt());
01670     case AppletArchive:         return String(applet.archive());
01671     case AppletCode:            return String(applet.code());
01672     case AppletCodeBase:        return String(applet.codeBase());
01673     case AppletHeight:          return String(applet.height());
01674     case AppletHspace:          return Number(applet.getHspace());
01675     case AppletName:            return String(applet.name());
01676     case AppletObject:          return String(applet.object());
01677     case AppletVspace:          return Number(applet.getVspace());
01678     case AppletWidth:           return String(applet.width());
01679     }
01680   }
01681   break;
01682   case ID_MAP: {
01683     DOM::HTMLMapElement map = element;
01684     switch (token) {
01685     case MapAreas:           return getHTMLCollection(exec, map.areas()); // type HTMLCollection
01686     case MapName:            return String(map.name());
01687     }
01688   }
01689   break;
01690   case ID_AREA: {
01691     DOM::HTMLAreaElement area = element;
01692     switch (token) {
01693     case AreaAccessKey:       return String(area.accessKey());
01694     case AreaAlt:             return String(area.alt());
01695     case AreaCoords:          return String(area.coords());
01696     // Group everything that needs href
01697     case AreaHref:
01698     case AreaHash:
01699     case AreaHost:
01700     case AreaHostName:
01701     case AreaPathName:
01702     case AreaPort:
01703     case AreaProtocol:
01704     case AreaSearch:
01705     {
01706       DOM::Document doc = area.ownerDocument();
01707       DOM::DOMString href = area.href();
01708       KURL url;
01709       if ( !href.isNull() ) {
01710         url = doc.completeURL( href ).string();
01711         if ( href.isEmpty() )
01712           url.setFileName( QString::null ); // href="" clears the filename (in IE)
01713       }
01714       switch(token) {
01715       case AreaHref:
01716         return String(url.url());
01717       case AreaHash:            return String(url.isEmpty() ? "" : '#'+url.ref());
01718       case AreaHost:            return String(url.host());
01719       case AreaHostName: {
01720         if (url.port()==0)
01721           return String(url.host());
01722         else
01723           return String(url.host() + ":" + QString::number(url.port()));
01724       }
01725       case AreaPathName:        {
01726         return String(url.path());
01727       }
01728       case AreaPort:            return String(QString::number(url.port()));
01729       case AreaProtocol:        return String(url.isEmpty() ? "" : url.protocol()+":");
01730       case AreaSearch:          return String(url.query());
01731       }
01732     }
01733     case AreaNoHref:          return Boolean(area.noHref());
01734     case AreaShape:           return String(area.shape());
01735     case AreaTabIndex:        return Number(area.tabIndex());
01736     case AreaTarget:          return String(area.target());
01737     }
01738   }
01739   break;
01740   case ID_SCRIPT: {
01741     DOM::HTMLScriptElement script = element;
01742     switch (token) {
01743     case ScriptText:            return String(script.text());
01744     case ScriptHtmlFor:         return String(script.htmlFor());
01745     case ScriptEvent:           return String(script.event());
01746     case ScriptCharset:         return String(script.charset());
01747     case ScriptDefer:           return Boolean(script.defer());
01748     case ScriptSrc:             return String(script.src());
01749     case ScriptType:            return String(script.type());
01750     }
01751   }
01752   break;
01753   case ID_TABLE: {
01754     DOM::HTMLTableElement table = element;
01755     switch (token) {
01756     case TableCaption:         return getDOMNode(exec,table.caption()); // type HTMLTableCaptionElement
01757     case TableTHead:           return getDOMNode(exec,table.tHead()); // type HTMLTableSectionElement
01758     case TableTFoot:           return getDOMNode(exec,table.tFoot()); // type HTMLTableSectionElement
01759     case TableRows:            return getHTMLCollection(exec,table.rows()); // type HTMLCollection
01760     case TableTBodies:         return getHTMLCollection(exec,table.tBodies()); // type HTMLCollection
01761     case TableAlign:           return String(table.align());
01762     case TableBgColor:         return String(table.bgColor());
01763     case TableBorder:          return String(table.border());
01764     case TableCellPadding:     return String(table.cellPadding());
01765     case TableCellSpacing:     return String(table.cellSpacing());
01766     case TableFrame:           return String(table.frame());
01767     case TableRules:           return String(table.rules());
01768     case TableSummary:         return String(table.summary());
01769     case TableWidth:           return String(table.width());
01770     }
01771   }
01772   break;
01773   case ID_CAPTION: {
01774     DOM::HTMLTableCaptionElement tableCaption = element;
01775     switch (token) {
01776     case TableCaptionAlign:       return String(tableCaption.align());
01777     }
01778   }
01779   break;
01780   case ID_COL:
01781   case ID_COLGROUP: {
01782     DOM::HTMLTableColElement tableCol = element;
01783     switch (token) {
01784     case TableColAlign:           return String(tableCol.align());
01785     case TableColCh:              return String(tableCol.ch());
01786     case TableColChOff:           return String(tableCol.chOff());
01787     case TableColSpan:            return Number(tableCol.span());
01788     case TableColVAlign:          return String(tableCol.vAlign());
01789     case TableColWidth:           return String(tableCol.width());
01790     }
01791   }
01792   break;
01793   case ID_THEAD:
01794   case ID_TBODY:
01795   case ID_TFOOT: {
01796     DOM::HTMLTableSectionElement tableSection = element;
01797     switch (token) {
01798     case TableSectionAlign:           return String(tableSection.align());
01799     case TableSectionCh:              return String(tableSection.ch());
01800     case TableSectionChOff:           return String(tableSection.chOff());
01801     case TableSectionVAlign:          return String(tableSection.vAlign());
01802     case TableSectionRows:            return getHTMLCollection(exec,tableSection.rows()); // type HTMLCollection
01803     }
01804   }
01805   break;
01806   case ID_TR: {
01807    DOM::HTMLTableRowElement tableRow = element;
01808    switch (token) {
01809    case TableRowRowIndex:        return Number(tableRow.rowIndex());
01810    case TableRowSectionRowIndex: return Number(tableRow.sectionRowIndex());
01811    case TableRowCells:           return getHTMLCollection(exec,tableRow.cells()); // type HTMLCollection
01812    case TableRowAlign:           return String(tableRow.align());
01813    case TableRowBgColor:         return String(tableRow.bgColor());
01814    case TableRowCh:              return String(tableRow.ch());
01815    case TableRowChOff:           return String(tableRow.chOff());
01816    case TableRowVAlign:          return String(tableRow.vAlign());
01817    }
01818   }
01819   break;
01820   case ID_TH:
01821   case ID_TD: {
01822     DOM::HTMLTableCellElement tableCell = element;
01823     switch (token) {
01824     case TableCellCellIndex:       return Number(tableCell.cellIndex());
01825     case TableCellAbbr:            return String(tableCell.abbr());
01826     case TableCellAlign:           return String(tableCell.align());
01827     case TableCellAxis:            return String(tableCell.axis());
01828     case TableCellBgColor:         return String(tableCell.bgColor());
01829     case TableCellCh:              return String(tableCell.ch());
01830     case TableCellChOff:           return String(tableCell.chOff());
01831     case TableCellColSpan:         return Number(tableCell.colSpan());
01832     case TableCellHeaders:         return String(tableCell.headers());
01833     case TableCellHeight:          return String(tableCell.height());
01834     case TableCellNoWrap:          return Boolean(tableCell.noWrap());
01835     case TableCellRowSpan:         return Number(tableCell.rowSpan());
01836     case TableCellScope:           return String(tableCell.scope());
01837     case TableCellVAlign:          return String(tableCell.vAlign());
01838     case TableCellWidth:           return String(tableCell.width());
01839     }
01840   }
01841   break;
01842   case ID_FRAMESET: {
01843     DOM::HTMLFrameSetElement frameSet = element;
01844     switch (token) {
01845     case FrameSetCols:            return String(frameSet.cols());
01846     case FrameSetRows:            return String(frameSet.rows());
01847     }
01848   }
01849   break;
01850   case ID_LAYER: {
01851     DOM::HTMLLayerElement layerElement = element;
01852     switch (token) {
01853     case LayerTop:            return Number(layerElement.top());
01854     case LayerLeft:           return Number(layerElement.left());
01855     case LayerVisibility:     return getString(layerElement.visibility());
01856     case LayerBgColor:        return getString(layerElement.bgColor());
01857     /*case LayerClip:           return getLayerClip(exec, layerElement); */
01858     case LayerDocument:       return Undefined();
01859     case LayerLayers:         return getHTMLCollection(exec,layerElement.layers());
01860     }
01861   }
01862   break;
01863   case ID_FRAME: {
01864     DOM::HTMLFrameElement frameElement = element;
01865     switch (token) {
01866     case FrameContentDocument: return checkNodeSecurity(exec,frameElement.contentDocument()) ?
01867                       getDOMNode(exec, frameElement.contentDocument()) : Undefined();
01868     case FrameContentWindow:   {
01869         KHTMLPart* part = static_cast<DOM::HTMLFrameElementImpl*>(frameElement.handle())->contentPart();
01870         if (part) {
01871           Window *w = Window::retrieveWindow(part);
01872           if (w)
01873             return Value(w);
01874         }
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           Window *w = Window::retrieveWindow(part);
01899           if (w)
01900             return Value(w);
01901         }
01902             return Undefined();
01903     }
01904     case IFrameFrameBorder:     return String(iFrame.frameBorder());
01905     case IFrameHeight:          return String(iFrame.height());
01906     case IFrameLongDesc:        return String(iFrame.longDesc());
01907     case IFrameMarginHeight:    return String(iFrame.marginHeight());
01908     case IFrameMarginWidth:     return String(iFrame.marginWidth());
01909     case IFrameName:            return String(iFrame.name());
01910     case IFrameScrolling:       return String(iFrame.scrolling());
01911     case IFrameSrc:             return String(iFrame.src());
01912     case IFrameWidth:           return String(iFrame.width());
01913     }
01914     break;
01915   }
01916   } // xemacs (or arnt) could be a bit smarter when it comes to indenting switch()es ;)
01917   // its not arnt to blame - its the original Stroustrup style we like :) (Dirk)
01918 
01919   // generic properties
01920   switch (token) {
01921   case ElementId:
01922     return String(element.id()); // String is wrong here. Other browsers return empty string if no id specified.
01923   case ElementTitle:
01924     return String(element.title());
01925   case ElementLang:
01926     return String(element.lang());
01927   case ElementDir:
01928     return String(element.dir());
01929   case ElementClassName:
01930     return String(element.className());
01931   case ElementInnerHTML:
01932     return String(element.innerHTML());
01933   case ElementInnerText:
01934     return String(element.innerText());
01935   case ElementDocument:
01936     return getDOMNode(exec,element.ownerDocument());
01937   case ElementChildren:
01938     return getHTMLCollection(exec,element.children());
01939   case ElementAll:
01940     // Disable element.all when we try to be Netscape-compatible
01941     if ( exec->interpreter()->compatMode() == Interpreter::NetscapeCompat )
01942       return Undefined();
01943     else
01944     if ( exec->interpreter()->compatMode() == Interpreter::IECompat )
01945       return getHTMLCollection(exec,element.all());
01946     else // Enabled but hidden by default
01947       return getHTMLCollection(exec,element.all(), true);
01948   // ### what about style? or is this used instead for DOM2 stylesheets?
01949   }
01950   kdError() << "HTMLElement::getValueProperty unhandled token " << token << endl;
01951   return Undefined();
01952 }
01953 
01954 bool KJS::HTMLElement::hasProperty(ExecState *exec, const Identifier &propertyName) const
01955 {
01956 #ifdef KJS_VERBOSE
01957   //kdDebug(6070) << "HTMLElement::hasProperty " << propertyName.qstring() << endl;
01958 #endif
01959   DOM::HTMLElement element = static_cast<DOM::HTMLElement>(node);
01960   // First look at dynamic properties - keep this in sync with tryGet
01961   switch (element.elementId()) {
01962     case ID_FORM: {
01963       DOM::HTMLFormElement form = element;
01964       // Check if we're retrieving an element (by index or by name)
01965       bool ok;
01966       uint u = propertyName.toULong(&ok);
01967       if (ok && !(form.elements().item(u).isNull()))
01968         return true;
01969       DOM::Node testnode = form.elements().namedItem(propertyName.string());
01970       if (!testnode.isNull())
01971         return true;
01972     }
01973     case ID_SELECT: {
01974       DOM::HTMLSelectElement select = element;
01975       bool ok;
01976       uint u = propertyName.toULong(&ok);
01977       if (ok && !(select.options().item(u).isNull()))
01978         return true;
01979     }
01980     default:
01981       break;
01982   }
01983 
01984   return DOMElement::hasProperty(exec, propertyName);
01985 }
01986 
01987 UString KJS::HTMLElement::toString(ExecState *exec) const
01988 {
01989   if (node.elementId() == ID_A)
01990     return UString(static_cast<const DOM::HTMLAnchorElement&>(node).href());
01991   else if (node.elementId() == ID_APPLET) {
01992     KParts::LiveConnectExtension *lc = getLiveConnectExtension(node);
01993     QStringList qargs;
01994     QString retvalue;
01995     KParts::LiveConnectExtension::Type rettype;
01996     unsigned long retobjid;
01997     if (lc && lc->call(0, "hashCode", qargs, rettype, retobjid, retvalue)) {
01998       QString str("[object APPLET ref=");
01999       return UString(str + retvalue + QString("]"));
02000     }
02001   } else if (node.elementId() == ID_IMG) {
02002     DOM::HTMLImageElement image(node);
02003     if (!image.alt().isEmpty())
02004       return UString(image.alt()) + " " + DOMElement::toString(exec);
02005   }
02006   return DOMElement::toString(exec);
02007 }
02008 
02009 static void getForm(DOM::HTMLFormElement* form, const DOM::HTMLElement& element)
02010 {
02011     switch (element.elementId()) {
02012         case ID_ISINDEX: {
02013             DOM::HTMLIsIndexElement isindex = element;
02014             *form = isindex.form();
02015             break;
02016         }
02017         case ID_SELECT: {
02018             DOM::HTMLSelectElement select = element;
02019             *form = select.form();
02020             break;
02021         }
02022         case ID_OPTION: {
02023             DOM::HTMLOptionElement option = element;
02024             *form = option.form();
02025             break;
02026         }
02027         case ID_INPUT: {
02028             DOM::HTMLInputElement input = element;
02029             *form = input.form();
02030             break;
02031         }
02032         case ID_TEXTAREA: {
02033             DOM::HTMLTextAreaElement textarea = element;
02034             *form = textarea.form();
02035             break;
02036         }
02037         case ID_LABEL: {
02038             DOM::HTMLLabelElement label = element;
02039             *form = label.form();
02040             break;
02041         }
02042         case ID_FIELDSET: {
02043             DOM::HTMLFieldSetElement fieldset = element;
02044             *form = fieldset.form();
02045             break;
02046         }
02047         case ID_LEGEND: {
02048             DOM::HTMLLegendElement legend = element;
02049             *form = legend.form();
02050             break;
02051         }
02052         case ID_OBJECT: {
02053             DOM::HTMLObjectElement object = element;
02054             *form = object.form();
02055             break;
02056         }
02057         default:
02058             break;
02059     }
02060 }
02061 
02062 void KJS::HTMLElement::pushEventHandlerScope(ExecState *exec, ScopeChain &scope) const
02063 {
02064   DOM::HTMLElement element = static_cast<DOM::HTMLElement>(node);
02065 
02066   // The document is put on first, fall back to searching it only after the element and form.
02067   scope.push(static_cast<ObjectImp *>(getDOMNode(exec, element.ownerDocument()).imp()));
02068 
02069   // The form is next, searched before the document, but after the element itself.
02070   DOM::HTMLFormElement formElt;
02071 
02072   // First try to obtain the form from the element itself.  We do this to deal with
02073   // the malformed case where <form>s aren't in our parent chain (e.g., when they were inside
02074   // <table> or <tbody>.
02075   getForm(&formElt, element);
02076   if (!formElt.isNull())
02077     scope.push(static_cast<ObjectImp *>(getDOMNode(exec, formElt).imp()));
02078   else {
02079     DOM::Node form = element.parentNode();
02080     while (!form.isNull() && form.elementId() != ID_FORM)
02081         form = form.parentNode();
02082 
02083     if (!form.isNull())
02084         scope.push(static_cast<ObjectImp *>(getDOMNode(exec, form).imp()));
02085   }
02086 
02087   // The element is on top, searched first.
02088   scope.push(static_cast<ObjectImp *>(getDOMNode(exec, element).imp()));
02089 }
02090 
02091 HTMLElementFunction::HTMLElementFunction(ExecState *exec, int i, int len)
02092   : DOMFunction(exec), id(i)
02093 {
02094   Value protect(this);
02095   put(exec,lengthPropertyName,Number(len),DontDelete|ReadOnly|DontEnum);
02096 }
02097 
02098 Value KJS::HTMLElementFunction::tryCall(ExecState *exec, Object &thisObj, const List &args)
02099 {
02100   KJS_CHECK_THIS( HTMLElement, thisObj );
02101 
02102 #ifdef KJS_VERBOSE
02103   kdDebug(6070) << "KJS::HTMLElementFunction::tryCall " << endl;
02104 #endif
02105   DOM::HTMLElement element = static_cast<KJS::HTMLElement *>(thisObj.imp())->toElement();
02106 
02107   switch (element.elementId()) {
02108     case ID_FORM: {
02109       DOM::HTMLFormElement form = element;
02110       if (id == KJS::HTMLElement::FormSubmit) {
02111 
02112 
02113         DOM::HTMLDocument doc = element.ownerDocument();
02114         KHTMLView *view = static_cast<DOM::DocumentImpl*>(doc.handle())->view();
02115         KHTMLSettings::KJSWindowOpenPolicy policy = KHTMLSettings::KJSWindowOpenAllow;
02116     if (view)
02117         policy = view->part()->settings()->windowOpenPolicy(view->part()->url().host());
02118 
02119         bool block = false;
02120 
02121         if ( policy != KHTMLSettings::KJSWindowOpenAllow ) {
02122           block = true;
02123 
02124          // if this is a form without a target, or a special target, don't block
02125           QString trg = form.target().lower().string();
02126           if( trg.isEmpty() || trg == "_top" || trg == "_self" ||
02127               trg == "_parent")
02128             block = false;
02129 
02130           QString caption;
02131 
02132           // if there is a frame with the target name, don't block
02133           if ( view && view->part() )  {
02134             if (!view->part()->url().host().isEmpty())
02135               caption = view->part()->url().host() + " - ";
02136             // search all (possibly nested) framesets
02137             KHTMLPart *currentPart = view->part()->parentPart();
02138             while( currentPart != 0L ) {
02139               if( currentPart->frameExists( form.target().string() ) )
02140                 block = false;
02141               currentPart = currentPart->parentPart();
02142             }
02143           }
02144 
02145           if ( block && policy == KHTMLSettings::KJSWindowOpenAsk && view ) {
02146             if (view && view->part())
02147             emit view->part()->browserExtension()->requestFocus(view->part());
02148             caption += i18n( "Confirmation: JavaScript Popup" );
02149             if ( KMessageBox::questionYesNo(view, form.action().isEmpty() ?
02150                    i18n( "This site is submitting a form which will open up a new browser "
02151                          "window via JavaScript.\n"
02152                          "Do you want to allow the form to be submitted?" ) :
02153                    i18n( "<qt>This site is submitting a form which will open <p>%1</p> in a new browser window via JavaScript.<br />"
02154                          "Do you want to allow the form to be submitted?</qt>").arg(KStringHandler::csqueeze(form.action().string(),  100)),
02155                    caption, i18n("Allow"), i18n("Do Not Allow") ) == KMessageBox::Yes )
02156               block = false;
02157 
02158           } else if ( block && policy == KHTMLSettings::KJSWindowOpenSmart ) {
02159             if( static_cast<KJS::ScriptInterpreter *>(exec->interpreter())->isWindowOpenAllowed() ) {
02160               // This submission has been triggered by the user
02161               block = false;
02162             }
02163           }
02164         }
02165 
02166         if( !block )
02167           form.submit();
02168 
02169         return Undefined();
02170       }
02171       else if (id == KJS::HTMLElement::FormReset) {
02172         form.reset();
02173         return Undefined();
02174       }
02175     }
02176     break;
02177     case ID_SELECT: {
02178       DOM::HTMLSelectElement select = element;
02179       if (id == KJS::HTMLElement::SelectAdd) {
02180         select.add(KJS::toNode(args[0]),KJS::toNode(args[1]));
02181         return Undefined();
02182       }
02183       else if (id == KJS::HTMLElement::SelectRemove) {
02184         select.remove(int(args[0].toNumber(exec)));
02185         return Undefined();
02186       }
02187       else if (id == KJS::HTMLElement::SelectBlur) {
02188         select.blur();
02189         return Undefined();
02190       }
02191       else if (id == KJS::HTMLElement::SelectFocus) {
02192         select.focus();
02193         return Undefined();
02194       }
02195     }
02196     break;
02197     case ID_INPUT: {
02198       DOM::HTMLInputElement input = element;
02199       if (id == KJS::HTMLElement::InputBlur) {
02200         input.blur();
02201         return Undefined();
02202       }
02203       else if (id == KJS::HTMLElement::InputFocus) {
02204         input.focus();
02205         return Undefined();
02206       }
02207       else if (id == KJS::HTMLElement::InputSelect) {
02208         input.select();
02209         return Undefined();
02210       }
02211       else if (id == KJS::HTMLElement::InputClick) {
02212         input.click();
02213         return Undefined();
02214       }
02215       else if (id == KJS::HTMLElement::InputSetSelectionRange) {
02216         input.setSelectionRange(args[0].toNumber(exec), args[1].toNumber(exec));
02217         return Undefined();
02218       }
02219     }
02220     break;
02221     case ID_BUTTON: {
02222       DOM::HTMLButtonElement button = element;
02223       if (id == KJS::HTMLElement::ButtonBlur) {
02224         button.blur();
02225         return Undefined();
02226       }
02227       else if (id == KJS::HTMLElement::ButtonFocus) {
02228         button.focus();
02229         return Undefined();
02230       }
02231     }
02232     break;
02233     case ID_TEXTAREA: {
02234       DOM::HTMLTextAreaElement textarea = element;
02235       if (id == KJS::HTMLElement::TextAreaBlur) {
02236         textarea.blur();
02237         return Undefined();
02238       }
02239       else if (id == KJS::HTMLElement::TextAreaFocus) {
02240         textarea.focus();
02241         return Undefined();
02242       }
02243       else if (id == KJS::HTMLElement::TextAreaSelect) {
02244         textarea.select();
02245         return Undefined();
02246       }
02247       else if (id == KJS::HTMLElement::TextAreaSetSelectionRange) {
02248         textarea.setSelectionRange(args[0].toNumber(exec), args[1].toNumber(exec));
02249         return Undefined();
02250       }
02251 
02252     }
02253     break;
02254     case ID_A: {
02255       DOM::HTMLAnchorElement anchor = element;
02256       if (id == KJS::HTMLElement::AnchorBlur) {
02257         anchor.blur();
02258         return Undefined();
02259       }
02260       else if (id == KJS::HTMLElement::AnchorFocus) {
02261         anchor.focus();
02262         return Undefined();
02263       }
02264       else if (id == KJS::HTMLElement::AnchorClick) {
02265         static_cast<DOM::HTMLAnchorElementImpl*>(anchor.handle())->click();
02266         return Undefined();
02267       }
02268     }
02269     break;
02270     case ID_TABLE: {
02271       DOM::HTMLTableElement table = element;
02272       if (id == KJS::HTMLElement::TableCreateTHead)
02273         return getDOMNode(exec,table.createTHead());
02274       else if (id == KJS::HTMLElement::TableDeleteTHead) {
02275         table.deleteTHead();
02276         return Undefined();
02277       }
02278       else if (id == KJS::HTMLElement::TableCreateTFoot)
02279         return getDOMNode(exec,table.createTFoot());
02280       else if (id == KJS::HTMLElement::TableDeleteTFoot) {
02281         table.deleteTFoot();
02282         return Undefined();
02283       }
02284       else if (id == KJS::HTMLElement::TableCreateCaption)
02285         return getDOMNode(exec,table.createCaption());
02286       else if (id == KJS::HTMLElement::TableDeleteCaption) {
02287         table.deleteCaption();
02288         return Undefined();
02289       }
02290       else if (id == KJS::HTMLElement::TableInsertRow)
02291         return getDOMNode(exec,table.insertRow(args[0].toInteger(exec)));
02292       else if (id == KJS::HTMLElement::TableDeleteRow) {
02293         table.deleteRow(args[0].toInteger(exec));
02294         return Undefined();
02295       }
02296     }
02297     break;
02298     case ID_THEAD:
02299     case ID_TBODY:
02300     case ID_TFOOT: {
02301       DOM::HTMLTableSectionElement tableSection = element;
02302       if (id == KJS::HTMLElement::TableSectionInsertRow)
02303         return getDOMNode(exec,tableSection.insertRow(args[0].toInteger(exec)));
02304       else if (id == KJS::HTMLElement::TableSectionDeleteRow) {
02305         tableSection.deleteRow(args[0].toInteger(exec));
02306         return Undefined();
02307       }
02308     }
02309     break;
02310     case ID_TR: {
02311       DOM::HTMLTableRowElement tableRow = element;
02312       if (id == KJS::HTMLElement::TableRowInsertCell)
02313         return getDOMNode(exec,tableRow.insertCell(args[0].toInteger(exec)));
02314       else if (id == KJS::HTMLElement::TableRowDeleteCell) {
02315         tableRow.deleteCell(args[0].toInteger(exec));
02316         return Undefined();
02317       }
02318       break;
02319     }
02320     case ID_MARQUEE: {
02321       if (id == KJS::HTMLElement::MarqueeStart && element.handle()->renderer() &&
02322         element.handle()->renderer()->layer() &&
02323         element.handle()->renderer()->layer()->marquee()) {
02324         element.handle()->renderer()->layer()->marquee()->start();
02325         return Undefined();
02326       }
02327       else if (id == KJS::HTMLElement::MarqueeStop && element.handle()->renderer() &&
02328               element.handle()->renderer()->layer() &&
02329               element.handle()->renderer()->layer()->marquee()) {
02330         element.handle()->renderer()->layer()->marquee()->stop();
02331         return Undefined();
02332       }
02333       break;
02334     }
02335   }
02336 
02337   if (id == HTMLElement::ElementScrollIntoView) {
02338     // ### implement
02339     kdWarning() << "non-standard HTMLElement::scrollIntoView() not implemented"
02340         << endl;
02341     return Undefined();
02342   }
02343 
02344   return Undefined();
02345 }
02346 
02347 void KJS::HTMLElement::tryPut(ExecState *exec, const Identifier &propertyName, const Value& value, int attr)
02348 {
02349 #ifdef KJS_VERBOSE
02350   DOM::DOMString str = value.isA(NullType) ? DOM::DOMString() : value.toString(exec).string();
02351 #endif
02352   DOM::HTMLElement element = static_cast<DOM::HTMLElement>(node);
02353 #ifdef KJS_VERBOSE
02354   kdDebug(6070) << "KJS::HTMLElement::tryPut " << propertyName.qstring()
02355                 << " thisTag=" << element.tagName().string()
02356                 << " str=" << str.string() << endl;
02357 #endif
02358   // First look at dynamic properties
02359   switch (element.elementId()) {
02360     case ID_SELECT: {
02361       DOM::HTMLSelectElement select = element;
02362       bool ok;
02363       /*uint u =*/ propertyName.toULong(&ok);
02364       if (ok) {
02365         Object coll = Object::dynamicCast( getSelectHTMLCollection(exec, select.options(), select) );
02366         if ( coll.isValid() )
02367           coll.put(exec,propertyName,value);
02368         return;
02369       }
02370       break;
02371     }
02372     case ID_APPLET:
02373     case ID_OBJECT:
02374     case ID_EMBED: {
02375       KParts::LiveConnectExtension *lc = getLiveConnectExtension(element);
02376       if (lc && lc->put(0, propertyName.qstring(), value.toString(exec).qstring()))
02377         return;
02378       break;
02379     }
02380     default:
02381       break;
02382   }
02383 
02384   const HashTable* table = classInfo()->propHashTable; // get the right hashtable
02385   const HashEntry* entry = Lookup::findEntry(table, propertyName);
02386   if (entry) {
02387     if (entry->attr & Function) // function: put as override property
02388     {
02389       ObjectImp::put(exec, propertyName, value, attr);
02390       return;
02391     }
02392     else if ((entry->attr & ReadOnly) == 0) // let DOMObjectLookupPut print the warning if not
02393     {
02394       putValueProperty(exec, entry->value, value, attr);
02395       return;
02396     }
02397   }
02398   DOMObjectLookupPut<KJS::HTMLElement, DOMElement>(exec, propertyName, value, attr, &KJS::HTMLElementTable, this);
02399 }
02400 
02401 void KJS::HTMLElement::putValueProperty(ExecState *exec, int token, const Value& value, int)
02402 {
02403   DOM::DOMString str = value.isA(NullType) ? DOM::DOMString() : value.toString(exec).string();
02404   DOMNode *kjsNode = new DOMNode(exec, KJS::toNode(value));
02405   // Need to create a Value wrapper to avoid leaking the KJS::DOMNode
02406   Value nodeValue(kjsNode);
02407   DOM::Node n = kjsNode->toNode();
02408   DOM::HTMLElement element = static_cast<DOM::HTMLElement>(node);
02409 #ifdef KJS_VERBOSE
02410   kdDebug(6070) << "KJS::HTMLElement::putValueProperty "
02411                 << " thisTag=" << element.tagName().string()
02412                 << " token=" << token << endl;
02413 #endif
02414 
02415   switch (element.elementId()) {
02416   case ID_HTML: {
02417       DOM::HTMLHtmlElement html = element;
02418       switch (token) {
02419       case HtmlVersion:         { html.setVersion(str); return; }
02420       }
02421   }
02422   break;
02423   case ID_HEAD: {
02424     DOM::HTMLHeadElement head = element;
02425     switch (token) {
02426     case HeadProfile:         { head.setProfile(str); return; }
02427     }
02428   }
02429   break;
02430   case ID_LINK: {
02431     DOM::HTMLLinkElement link = element;
02432     switch (token) {
02433       case LinkDisabled:        { link.setDisabled(value.toBoolean(exec)); return; }
02434       case LinkCharset:         { link.setCharset(str); return; }
02435       case LinkHref:            { link.setHref(str); return; }
02436       case LinkHrefLang:        { link.setHreflang(str); return; }
02437       case LinkMedia:           { link.setMedia(str); return; }
02438       case LinkRel:             { link.setRel(str); return; }
02439       case LinkRev:             { link.setRev(str); return; }
02440       case LinkTarget:          { link.setTarget(str); return; }
02441       case LinkType:            { link.setType(str); return; }
02442       }
02443     }
02444     break;
02445     case ID_TITLE: {
02446       DOM::HTMLTitleElement title = element;
02447       switch (token) {
02448       case TitleText:                 { title.setText(str); return; }
02449       }
02450     }
02451     break;
02452     case ID_META: {
02453       DOM::HTMLMetaElement meta = element;
02454       switch (token) {
02455       case MetaContent:         { meta.setContent(str); return; }
02456       case MetaHttpEquiv:       { meta.setHttpEquiv(str); return; }
02457       case MetaName:            { meta.setName(str); return; }
02458       case MetaScheme:          { meta.setScheme(str); return; }
02459       }
02460     }
02461     break;
02462     case ID_BASE: {
02463       DOM::HTMLBaseElement base = element;
02464       switch (token) {
02465       case BaseHref:            { base.setHref(str); return; }
02466       case BaseTarget:          { base.setTarget(str); return; }
02467       }
02468     }
02469     break;
02470     case ID_ISINDEX: {
02471       DOM::HTMLIsIndexElement isindex = element;
02472       switch (token) {
02473       // read-only: form
02474       case IsIndexPrompt:               { isindex.setPrompt(str); return; }
02475       }
02476     }
02477     break;
02478     case ID_STYLE: {
02479       DOM::HTMLStyleElement style = element;
02480       switch (token) {
02481       case StyleDisabled:        { style.setDisabled(value.toBoolean(exec)); return; }
02482       case StyleMedia:           { style.setMedia(str); return; }
02483       case StyleType:            { style.setType(str); return; }
02484       }
02485     }
02486     break;
02487     case ID_BODY: {
02488       DOM::HTMLBodyElement body = element;
02489       switch (token) {
02490       case BodyALink:           { body.setALink(str); return; }
02491       case BodyBackground:      { body.setBackground(str); return; }
02492       case BodyBgColor:         { body.setBgColor(str); return; }
02493       case BodyLink:            { body.setLink(str); return; }
02494       case BodyText:            { body.setText(str); return; }
02495       case BodyVLink:           { body.setVLink(str); return; }
02496       case BodyScrollLeft:
02497       case BodyScrollTop: {
02498         QScrollView* sview = body.ownerDocument().view();
02499         if (sview) {
02500           // Update the document's layout before we compute these attributes.
02501           DOM::DocumentImpl* docimpl = body.handle()->getDocument();
02502           if (docimpl)
02503             docimpl->updateLayout();
02504           if (token == BodyScrollLeft)
02505             sview->setContentsPos(value.toInteger(exec), sview->contentsY());
02506           else
02507             sview->setContentsPos(sview->contentsX(), value.toInteger(exec));
02508           }
02509         return;
02510       }
02511       case BodyOnLoad:
02512         DOM::DocumentImpl *doc = static_cast<DOM::DocumentImpl *>(node.ownerDocument().handle());
02513         if (doc && checkNodeSecurity(exec, node))
02514         {
02515           DOMNode* kjsDocNode = new DOMNode(exec, doc);
02516           // Need to create a Value wrapper to avoid leaking the KJS::DOMNode
02517           Value nodeValue(kjsDocNode);
02518           kjsDocNode->setListener(exec,DOM::EventImpl::LOAD_EVENT,value);
02519         }
02520         return;
02521       }
02522     }
02523     break;
02524     case ID_FORM: {
02525       DOM::HTMLFormElement form = element;
02526       switch (token) {
02527       // read-only: elements
02528       // read-only: length
02529       case FormName:            { form.setName(str); return; }
02530       case FormAcceptCharset:   { form.setAcceptCharset(str); return; }
02531       case FormAction:          { form.setAction(str.string()); return; }
02532       case FormEncType:         { form.setEnctype(str); return; }
02533       case FormMethod:          { form.setMethod(str); return; }
02534       case FormTarget:          { form.setTarget(str); return; }
02535       }
02536     }
02537     break;
02538     case ID_SELECT: {
02539       DOM::HTMLSelectElement select = element;
02540       switch (token) {
02541       // read-only: type
02542       case SelectSelectedIndex:   { select.setSelectedIndex(value.toInteger(exec)); return; }
02543       case SelectValue:           { select.setValue(str); return; }
02544       case SelectLength:          { // read-only according to the NS spec, but webpages need it writeable
02545                                          Object coll = Object::dynamicCast( getSelectHTMLCollection(exec, select.options(), select) );
02546                                          if ( coll.isValid() )
02547                                            coll.put(exec,"length",value);
02548                                          return;
02549                                        }
02550       // read-only: form
02551       // read-only: options
02552       case SelectDisabled:        { select.setDisabled(value.toBoolean(exec)); return; }
02553       case SelectMultiple:        { select.setMultiple(value.toBoolean(exec)); return; }
02554       case SelectName:            { select.setName(str); return; }
02555       case SelectSize:            { select.setSize(value.toInteger(exec)); return; }
02556       case SelectTabIndex:        { select.setTabIndex(value.toInteger(exec)); return; }
02557       }
02558     }
02559     break;
02560     case ID_OPTGROUP: {
02561       DOM::HTMLOptGroupElement optgroup = element;
02562       switch (token) {
02563       case OptGroupDisabled:        { optgroup.setDisabled(value.toBoolean(exec)); return; }
02564       case OptGroupLabel:           { optgroup.setLabel(str); return; }
02565       }
02566     }
02567     break;
02568     case ID_OPTION: {
02569       DOM::HTMLOptionElement option = element;
02570       switch (token) {
02571       // read-only: form
02572       case OptionDefaultSelected: { option.setDefaultSelected(value.toBoolean(exec)); return; }
02573       // read-only: text  <--- According to the DOM, but JavaScript and JScript both allow changes.
02574       // So, we'll do it here and not add it to our DOM headers.
02575       case OptionText:            { DOM::NodeList nl(option.childNodes());
02576                                     for (unsigned int i = 0; i < nl.length(); i++) {
02577                                         if (nl.item(i).nodeType() == DOM::Node::TEXT_NODE) {
02578                                             static_cast<DOM::Text>(nl.item(i)).setData(str);
02579                                             return;
02580                                         }
02581                                   }
02582                                   // No child text node found, creating one
02583                                   DOM::Text t = option.ownerDocument().createTextNode(str);
02584                                   try { option.appendChild(t); }
02585                                   catch(DOM::DOMException& e) {
02586                                     // #### exec->setException ?
02587                                   }
02588 
02589                                   return;
02590       }
02591       // read-only: index
02592       case OptionDisabled:        { option.setDisabled(value.toBoolean(exec)); return; }
02593       case OptionLabel:           { option.setLabel(str); return; }
02594       case OptionSelected:        { option.setSelected(value.toBoolean(exec)); return; }
02595       case OptionValue:           { option.setValue(str); return; }
02596       }
02597     }
02598     break;
02599     case ID_INPUT: {
02600       DOM::HTMLInputElement input = element;
02601       switch (token) {
02602       case InputDefaultValue:    { input.setDefaultValue(str); return; }
02603       case InputDefaultChecked:  { input.setDefaultChecked(value.toBoolean(exec)); return; }
02604       // read-only: form
02605       case InputAccept:          { input.setAccept(str); return; }
02606       case InputAccessKey:       { input.setAccessKey(str); return; }
02607       case InputAlign:           { input.setAlign(str); return; }
02608       case InputAlt:             { input.setAlt(str); return; }
02609       case InputChecked:         { input.setChecked(value.toBoolean(exec)); return; }
02610       case InputDisabled:        { input.setDisabled(value.toBoolean(exec)); return; }
02611       case InputMaxLength:       { input.setMaxLength(value.toInteger(exec)); return; }
02612       case InputName:            { input.setName(str); return; }
02613       case InputReadOnly:        { input.setReadOnly(value.toBoolean(exec)); return; }
02614       case InputSize:            { input.setSize(value.toInteger(exec)); return; }
02615       case InputSrc:             { input.setSrc(str); return; }
02616       case InputTabIndex:        { input.setTabIndex(value.toInteger(exec)); return; }
02617       case InputType:            { input.setType(str); return; }
02618       case InputUseMap:          { input.setUseMap(str); return; }
02619       case InputValue:           { input.setValue(str); return; }
02620       case InputSelectionStart:  { input.setSelectionStart(value.toInteger(exec)); return; }
02621       case InputSelectionEnd:    { input.setSelectionEnd  (value.toInteger(exec)); return; }
02622       }
02623     }
02624     break;
02625     case ID_TEXTAREA: {
02626       DOM::HTMLTextAreaElement textarea = element;
02627       switch (token) {
02628       case TextAreaDefaultValue:    { textarea.setDefaultValue(str); return; }
02629       // read-only: form
02630       case TextAreaAccessKey:       { textarea.setAccessKey(str); return; }
02631       case TextAreaCols:            { textarea.setCols(value.toInteger(exec)); return; }
02632       case TextAreaDisabled:        { textarea.setDisabled(value.toBoolean(exec)); return; }
02633       case TextAreaName:            { textarea.setName(str); return; }
02634       case TextAreaReadOnly:        { textarea.setReadOnly(value.toBoolean(exec)); return; }
02635       case TextAreaRows:            { textarea.setRows(value.toInteger(exec)); return; }
02636       case TextAreaTabIndex:        { textarea.setTabIndex(value.toInteger(exec)); return; }
02637       // read-only: type
02638       case TextAreaValue:           { textarea.setValue(str); return; }
02639       case TextAreaSelectionStart:  { textarea.setSelectionStart(value.toInteger(exec)); return; }
02640       case TextAreaSelectionEnd:    { textarea.setSelectionEnd  (value.toInteger(exec)); return; }
02641       }
02642     }
02643     break;
02644     case ID_BUTTON: {
02645       DOM::HTMLButtonElement button = element;
02646       switch (token) {
02647       // read-only: form
02648       case ButtonAccessKey:       { button.setAccessKey(str); return; }
02649       case ButtonDisabled:        { button.setDisabled(value.toBoolean(exec)); return; }
02650       case ButtonName:            { button.setName(str); return; }
02651       case ButtonTabIndex:        { button.setTabIndex(value.toInteger(exec)); return; }
02652       // read-only: type
02653       case ButtonValue:           { button.setValue(str); return; }
02654       }
02655     }
02656     break;
02657     case ID_LABEL: {
02658       DOM::HTMLLabelElement label = element;
02659       switch (token) {
02660       // read-only: form
02661       case LabelAccessKey:       { label.setAccessKey(str); return; }
02662       case LabelHtmlFor:         { label.setHtmlFor(str); return; }
02663       }
02664     }
02665     break;
02666 //    case ID_FIELDSET: {
02667 //      DOM::HTMLFieldSetElement fieldSet = element;
02668 //      // read-only: form
02669 //    }
02670 //    break;
02671     case ID_LEGEND: {
02672       DOM::HTMLLegendElement legend = element;
02673       switch (token) {
02674       // read-only: form
02675       case LegendAccessKey:       { legend.setAccessKey(str); return; }
02676       case LegendAlign:           { legend.setAlign(str); return; }
02677       }
02678     }
02679     break;
02680     case ID_UL: {
02681       DOM::HTMLUListElement uList = element;
02682       switch (token) {
02683       case UListCompact:         { uList.setCompact(value.toBoolean(exec)); return; }
02684       case UListType:            { uList.setType(str); return; }
02685       }
02686     }
02687     break;
02688     case ID_OL: {
02689       DOM::HTMLOListElement oList = element;
02690       switch (token) {
02691       case OListCompact:         { oList.setCompact(value.toBoolean(exec)); return; }
02692       case OListStart:           { oList.setStart(value.toInteger(exec)); return; }
02693       case OListType:            { oList.setType(str); return; }
02694       }
02695     }
02696     break;
02697     case ID_DL: {
02698       DOM::HTMLDListElement dList = element;
02699       switch (token) {
02700       case DListCompact:         { dList.setCompact(value.toBoolean(exec)); return; }
02701       }
02702     }
02703     break;
02704     case ID_DIR: {
02705       DOM::HTMLDirectoryElement directory = element;
02706       switch (token) {
02707       case DirectoryCompact:     { directory.setCompact(value.toBoolean(exec)); return; }
02708       }
02709     }
02710     break;
02711     case ID_MENU: {
02712       DOM::HTMLMenuElement menu = element;
02713       switch (token) {
02714       case MenuCompact:         { menu.setCompact(value.toBoolean(exec)); return; }
02715       }
02716     }
02717     break;
02718     case ID_LI: {
02719       DOM::HTMLLIElement li = element;
02720       switch (token) {
02721       case LIType:            { li.setType(str); return; }
02722       case LIValue:           { li.setValue(value.toInteger(exec)); return; }
02723       }
02724     }
02725     break;
02726     case ID_DIV: {
02727       DOM::HTMLDivElement div = element;
02728       switch (token) {
02729       case DivAlign:           { div.setAlign(str); return; }
02730       }
02731     }
02732     break;
02733     case ID_P: {
02734       DOM::HTMLParagraphElement paragraph = element;
02735       switch (token) {
02736       case ParagraphAlign:     { paragraph.setAlign(str); return; }
02737       }
02738     }
02739     break;
02740     case ID_H1:
02741     case ID_H2:
02742     case ID_H3:
02743     case ID_H4:
02744     case ID_H5:
02745     case ID_H6: {
02746       DOM::HTMLHeadingElement heading = element;
02747       switch (token) {
02748       case HeadingAlign:         { heading.setAlign(str); return; }
02749       }
02750     }
02751     break;
02752     case ID_BLOCKQUOTE: {
02753       DOM::HTMLBlockquoteElement blockquote = element;
02754       switch (token) {
02755       case BlockQuoteCite:       { blockquote.setCite(str); return; }
02756       }
02757     }
02758     break;
02759     case ID_Q: {
02760       DOM::HTMLQuoteElement quote = element;
02761       switch (token) {
02762       case QuoteCite:            { quote.setCite(str); return; }
02763       }
02764     }
02765     break;
02766     case ID_PRE: {
02767       DOM::HTMLPreElement pre = element;
02768       switch (token) {
02769       case PreWidth:           { pre.setWidth(value.toInteger(exec)); return; }
02770       }
02771     }
02772     break;
02773     case ID_BR: {
02774       DOM::HTMLBRElement br = element;
02775       switch (token) {
02776       case BRClear:           { br.setClear(str); return; }
02777       }
02778     }
02779     break;
02780     case ID_BASEFONT: {
02781       DOM::HTMLBaseFontElement baseFont = element;
02782       switch (token) {
02783       case BaseFontColor:           { baseFont.setColor(str); return; }
02784       case BaseFontFace:            { baseFont.setFace(str); return; }
02785       case BaseFontSize:            { baseFont.setSize(value.toInteger(exec)); return; }
02786       }
02787     }
02788     break;
02789     case ID_FONT: {
02790       DOM::HTMLFontElement font = element;
02791       switch (token) {
02792       case FontColor:           { font.setColor(str); return; }
02793       case FontFace:            { font.setFace(str); return; }
02794       case FontSize:            { font.setSize(str); return; }
02795       }
02796     }
02797     break;
02798     case ID_HR: {
02799       DOM::HTMLHRElement hr = element;
02800       switch (token) {
02801       case HRAlign:           { hr.setAlign(str); return; }
02802       case HRNoShade:         { hr.setNoShade(value.toBoolean(exec)); return; }
02803       case HRSize:            { hr.setSize(str); return; }
02804       case HRWidth:           { hr.setWidth(str); return; }
02805       }
02806     }
02807     break;
02808     case ID_INS:
02809     case ID_DEL: {
02810       DOM::HTMLModElement mod = element;
02811       switch (token) {
02812       case ModCite:            { mod.setCite(str); return; }
02813       case ModDateTime:        { mod.setDateTime(str); return; }
02814       }
02815     }
02816     break;
02817     case ID_A: {
02818       DOM::HTMLAnchorElement anchor = element;
02819       switch (token) {
02820       case AnchorAccessKey:       { anchor.setAccessKey(str); return; }
02821       case AnchorCharset:         { anchor.setCharset(str); return; }
02822       case AnchorCoords:          { anchor.setCoords(str); return; }
02823       case AnchorHref:            { anchor.setHref(str); return; }
02824       case AnchorHrefLang:        { anchor.setHreflang(str); return; }
02825       case AnchorName:            { anchor.setName(str); return; }
02826       case AnchorRel:             { anchor.setRel(str); return; }
02827       case AnchorRev:             { anchor.setRev(str); return; }
02828       case AnchorShape:           { anchor.setShape(str); return; }
02829       case AnchorTabIndex:        { anchor.setTabIndex(value.toInteger(exec)); return; }
02830       case AnchorTarget:          { anchor.setTarget(str); return; }
02831       case AnchorType:            { anchor.setType(str); return; }
02832       }
02833     }
02834     break;
02835     case ID_IMG: {
02836       DOM::HTMLImageElement image = element;
02837       switch (token) {
02838       case ImageName:            { image.setName(str); return; }
02839       case ImageAlign:           { image.setAlign(str); return; }
02840       case ImageAlt:             { image.setAlt(str); return; }
02841       case ImageBorder:          { image.setBorder(str); return; }
02842       case ImageHeight:          { image.setHeight(value.toInteger(exec)); return; }
02843       case ImageHspace:          { image.setHspace(value.toInteger(exec)); return; }
02844       case ImageIsMap:           { image.setIsMap(value.toBoolean(exec)); return; }
02845       case ImageLongDesc:        { image.setLongDesc(str); return; }
02846       case ImageSrc:             { image.setSrc(str); return; }
02847       case ImageUseMap:          { image.setUseMap(str); return; }
02848       case ImageVspace:          { image.setVspace(value.toInteger(exec)); return; }
02849       case ImageWidth:           { image.setWidth(value.toInteger(exec)); return; }
02850       }
02851     }
02852     break;
02853     case ID_OBJECT: {
02854       DOM::HTMLObjectElement object = element;
02855       switch (token) {
02856       // read-only: form
02857       case ObjectCode:                 { object.setCode(str); return; }
02858       case ObjectAlign:           { object.setAlign(str); return; }
02859       case ObjectArchive:         { object.setArchive(str); return; }
02860       case ObjectBorder:          { object.setBorder(str); return; }
02861       case ObjectCodeBase:        { object.setCodeBase(str); return; }
02862       case ObjectCodeType:        { object.setCodeType(str); return; }
02863       // read-only: ObjectContentDocument
02864       case ObjectData:            { object.setData(str); return; }
02865       case ObjectDeclare:         { object.setDeclare(value.toBoolean(exec)); return; }
02866       case ObjectHeight:          { object.setHeight(str); return; }
02867       case ObjectHspace:          { object.setHspace(value.toInteger(exec)); return; }
02868       case ObjectName:            { object.setName(str); return; }
02869       case ObjectStandby:         { object.setStandby(str); return; }
02870       case ObjectTabIndex:        { object.setTabIndex(value.toInteger(exec)); return; }
02871       case ObjectType:            { object.setType(str); return; }
02872       case ObjectUseMap:          { object.setUseMap(str); return; }
02873       case ObjectVspace:          { object.setVspace(value.toInteger(exec)); return; }
02874       case ObjectWidth:           { object.setWidth(str); return; }
02875       }
02876     }
02877     break;
02878     case ID_PARAM: {
02879       DOM::HTMLParamElement param = element;
02880       switch (token) {
02881       case ParamName:            { param.setName(str); return; }
02882       case ParamType:            { param.setType(str); return; }
02883       case ParamValue:           { param.setValue(str); return; }
02884       case ParamValueType:       { param.setValueType(str); return; }
02885       }
02886     }
02887     break;
02888     case ID_APPLET: {
02889       DOM::HTMLAppletElement applet = element;
02890       switch (token) {
02891       case AppletAlign:           { applet.setAlign(str); return; }
02892       case AppletAlt:             { applet.setAlt(str); return; }
02893       case AppletArchive:         { applet.setArchive(str); return; }
02894       case AppletCode:            { applet.setCode(str); return; }
02895       case AppletCodeBase:        { applet.setCodeBase(str); return; }
02896       case AppletHeight:          { applet.setHeight(str); return; }
02897       case AppletHspace:          { applet.setHspace(value.toInteger(exec)); return; }
02898       case AppletName:            { applet.setName(str); return; }
02899       case AppletObject:          { applet.setObject(str); return; }
02900       case AppletVspace:          { applet.setVspace(value.toInteger(exec)); return; }
02901       case AppletWidth:           { applet.setWidth(str); return; }
02902       }
02903     }
02904     break;
02905     case ID_MAP: {
02906       DOM::HTMLMapElement map = element;
02907       switch (token) {
02908       // read-only: areas
02909       case MapName:                 { map.setName(str); return; }
02910      }
02911     }
02912     break;
02913     case ID_AREA: {
02914       DOM::HTMLAreaElement area = element;
02915       switch (token) {
02916       case AreaAccessKey:       { area.setAccessKey(str); return; }
02917       case AreaAlt:             { area.setAlt(str); return; }
02918       case AreaCoords:          { area.setCoords(str); return; }
02919       case AreaHref:            { area.setHref(str); return; }
02920       case AreaNoHref:          { area.setNoHref(value.toBoolean(exec)); return; }
02921       case AreaShape:           { area.setShape(str); return; }
02922       case AreaTabIndex:        { area.setTabIndex(value.toInteger(exec)); return; }
02923       case AreaTarget:          { area.setTarget(str); return; }
02924       }
02925     }
02926     break;
02927     case ID_SCRIPT: {
02928       DOM::HTMLScriptElement script = element;
02929       switch (token) {
02930       case ScriptText:            { script.setText(str); return; }
02931       case ScriptHtmlFor:         { script.setHtmlFor(str); return; }
02932       case ScriptEvent:           { script.setEvent(str); return; }
02933       case ScriptCharset:         { script.setCharset(str); return; }
02934       case ScriptDefer:           { script.setDefer(value.toBoolean(exec)); return; }
02935       case ScriptSrc:             { script.setSrc(str); return; }
02936       case ScriptType:            { script.setType(str); return; }
02937       }
02938     }
02939     break;
02940     case ID_TABLE: {
02941       DOM::HTMLTableElement table = element;
02942       switch (token) {
02943       case TableCaption:         { table.setCaption(n); return; } // type HTMLTableCaptionElement
02944       case TableTHead:           { table.setTHead(n); return; } // type HTMLTableSectionElement
02945       case TableTFoot:           { table.setTFoot(n); return; } // type HTMLTableSectionElement
02946       // read-only: rows
02947       // read-only: tbodies
02948       case TableAlign:           { table.setAlign(str); return; }
02949       case TableBgColor:         { table.setBgColor(str); return; }
02950       case TableBorder:          { table.setBorder(str); return; }
02951       case TableCellPadding:     { table.setCellPadding(str); return; }
02952       case TableCellSpacing:     { table.setCellSpacing(str); return; }
02953       case TableFrame:           { table.setFrame(str); return; }
02954       case TableRules:           { table.setRules(str); return; }
02955       case TableSummary:         { table.setSummary(str); return; }
02956       case TableWidth:           { table.setWidth(str); return; }
02957       }
02958     }
02959     break;
02960     case ID_CAPTION: {
02961       DOM::HTMLTableCaptionElement tableCaption = element;
02962       switch (token) {
02963       case TableCaptionAlign:           { tableCaption.setAlign(str); return; }
02964       }
02965     }
02966     break;
02967     case ID_COL:
02968     case ID_COLGROUP: {
02969       DOM::HTMLTableColElement tableCol = element;
02970       switch (token) {
02971       case TableColAlign:           { tableCol.setAlign(str); return; }
02972       case TableColCh:              { tableCol.setCh(str); return; }
02973       case TableColChOff:           { tableCol.setChOff(str); return; }
02974       case TableColSpan:            { tableCol.setSpan(value.toInteger(exec)); return; }
02975       case TableColVAlign:          { tableCol.setVAlign(str); return; }
02976       case TableColWidth:           { tableCol.setWidth(str); return; }
02977       }
02978     }
02979     break;
02980     case ID_THEAD:
02981     case ID_TBODY:
02982     case ID_TFOOT: {
02983       DOM::HTMLTableSectionElement tableSection = element;
02984       switch (token) {
02985       case TableSectionAlign:           { tableSection.setAlign(str); return; }
02986       case TableSectionCh:              { tableSection.setCh(str); return; }
02987       case TableSectionChOff:           { tableSection.setChOff(str); return; }
02988       case TableSectionVAlign:          { tableSection.setVAlign(str); return; }
02989       // read-only: rows
02990       }
02991     }
02992     break;
02993     case ID_TR: {
02994       DOM::HTMLTableRowElement tableRow = element;
02995       switch (token) {
02996       // read-only: rowIndex
02997       // read-only: sectionRowIndex
02998       // read-only: cells
02999       case TableRowAlign:           { tableRow.setAlign(str); return; }
03000       case TableRowBgColor:         { tableRow.setBgColor(str); return; }
03001       case TableRowCh:              { tableRow.setCh(str); return; }
03002       case TableRowChOff:           { tableRow.setChOff(str); return; }
03003       case TableRowVAlign:          { tableRow.setVAlign(str); return; }
03004       }
03005     }
03006     break;
03007     case ID_TH:
03008     case ID_TD: {
03009       DOM::HTMLTableCellElement tableCell = element;
03010       switch (token) {
03011       // read-only: cellIndex
03012       case TableCellAbbr:            { tableCell.setAbbr(str); return; }
03013       case TableCellAlign:           { tableCell.setAlign(str); return; }
03014       case TableCellAxis:            { tableCell.setAxis(str); return; }
03015       case TableCellBgColor:         { tableCell.setBgColor(str); return; }
03016       case TableCellCh:              { tableCell.setCh(str); return; }
03017       case TableCellChOff:           { tableCell.setChOff(str); return; }
03018       case TableCellColSpan:         { tableCell.setColSpan(value.toInteger(exec)); return; }
03019       case TableCellHeaders:         { tableCell.setHeaders(str); return; }
03020       case TableCellHeight:          { tableCell.setHeight(str); return; }
03021       case TableCellNoWrap:          { tableCell.setNoWrap(value.toBoolean(exec)); return; }
03022       case TableCellRowSpan:         { tableCell.setRowSpan(value.toInteger(exec)); return; }
03023       case TableCellScope:           { tableCell.setScope(str); return; }
03024       case TableCellVAlign:          { tableCell.setVAlign(str); return; }
03025       case TableCellWidth:           { tableCell.setWidth(str); return; }
03026       }
03027     }
03028     break;
03029     case ID_FRAMESET: {
03030       DOM::HTMLFrameSetElement frameSet = element;
03031       switch (token) {
03032       case FrameSetCols:            { frameSet.setCols(str); return; }
03033       case FrameSetRows:            { frameSet.setRows(str); return; }
03034       }
03035     }
03036     break;
03037     case ID_LAYER: {
03038       DOM::HTMLLayerElement layerElement = element;
03039       switch (token) {
03040       case LayerTop:                   { layerElement.setTop(value.toInteger(exec)); return; }
03041       case LayerLeft:                  { layerElement.setLeft(value.toInteger(exec)); return; }
03042       case LayerVisibility:            { layerElement.setVisibility(str); return; }
03043       case LayerBgColor:               { layerElement.setBgColor(str); return; }
03044       // read-only: layers, clip
03045       }
03046     }
03047     break;
03048     case ID_FRAME: {
03049       DOM::HTMLFrameElement frameElement = element;
03050       switch (token) {
03051        // read-only: FrameContentDocument:
03052       case FrameFrameBorder:     { frameElement.setFrameBorder(str); return; }
03053       case FrameLongDesc:        { frameElement.setLongDesc(str); return; }
03054       case FrameMarginHeight:    { frameElement.setMarginHeight(str); return; }
03055       case FrameMarginWidth:     { frameElement.setMarginWidth(str); return; }
03056       case FrameName:            { frameElement.setName(str); return; }
03057       case FrameNoResize:        { frameElement.setNoResize(value.toBoolean(exec)); return; }
03058       case FrameScrolling:       { frameElement.setScrolling(str); return; }
03059       case FrameSrc:             { frameElement.setSrc(str); return; }
03060       case FrameLocation:        {
03061                                    static_cast<DOM::HTMLFrameElementImpl *>(frameElement.handle())->setLocation(str);
03062                                    return;
03063                                  }
03064       }
03065     }
03066     break;
03067     case ID_IFRAME: {
03068       DOM::HTMLIFrameElement iFrame = element;
03069       switch (token) {
03070       case IFrameAlign:           { iFrame.setAlign(str); return; }
03071       // read-only: IFrameContentDocument
03072       case IFrameFrameBorder:     { iFrame.setFrameBorder(str); return; }
03073       case IFrameHeight:          { iFrame.setHeight(str); return; }
03074       case IFrameLongDesc:        { iFrame.setLongDesc(str); return; }
03075       case IFrameMarginHeight:    { iFrame.setMarginHeight(str); return; }
03076       case IFrameMarginWidth:     { iFrame.setMarginWidth(str); return; }
03077       case IFrameName:            { iFrame.setName(str); return; }
03078       case IFrameScrolling:       { iFrame.setScrolling(str); return; }
03079       case IFrameSrc:             { iFrame.setSrc(str); return; }
03080       case IFrameWidth:           { iFrame.setWidth(str); return; }
03081       }
03082       break;
03083     }
03084   }
03085 
03086   // generic properties
03087   switch (token) {
03088   case ElementId:
03089     element.setId(str);
03090     return;
03091   case ElementTitle:
03092     element.setTitle(str);
03093     return;
03094   case ElementLang:
03095     element.setLang(str);
03096     return;
03097   case ElementDir:
03098     element.setDir(str);
03099     return;
03100   case ElementClassName:
03101     element.setClassName(str);
03102     return;
03103   case ElementInnerHTML:
03104     element.setInnerHTML(str);
03105     return;
03106   case ElementInnerText:
03107     element.setInnerText(str);
03108     return;
03109   default:
03110     kdDebug(6070) << "WARNING: KJS::HTMLElement::putValueProperty unhandled token " << token << " thisTag=" << element.tagName().string() << " str=" << str.string() << endl;
03111   }
03112 }
03113 
03114 // -------------------------------------------------------------------------
03115 /* Source for HTMLCollectionProtoTable.
03116 @begin HTMLCollectionProtoTable 3
03117   item      HTMLCollection::Item        DontDelete|Function 1
03118   namedItem HTMLCollection::NamedItem   DontDelete|Function 1
03119   tags      HTMLCollection::Tags        DontDelete|Function 1
03120 @end
03121 */
03122 DEFINE_PROTOTYPE("HTMLCollection", HTMLCollectionProto)
03123 IMPLEMENT_PROTOFUNC_DOM(HTMLCollectionProtoFunc)
03124 IMPLEMENT_PROTOTYPE(HTMLCollectionProto,HTMLCollectionProtoFunc)
03125 
03126 const ClassInfo KJS::HTMLCollection::info = { "HTMLCollection", 0, 0, 0 };
03127 
03128 KJS::HTMLCollection::HTMLCollection(ExecState *exec, const DOM::HTMLCollection& c)
03129   : DOMObject(HTMLCollectionProto::self(exec)), collection(c), hidden(false) {}
03130 
03131 KJS::HTMLCollection::~HTMLCollection()
03132 {
03133   ScriptInterpreter::forgetDOMObject(collection.handle());
03134 }
03135 
03136 bool KJS::HTMLCollection::toBoolean(ExecState *) const {
03137     return !hidden;
03138 }
03139 
03140 // We have to implement hasProperty since we don't use a hashtable for 'selectedIndex' and 'length',
03141 // and for indices in "for (..in..)"
03142 bool KJS::HTMLCollection::hasProperty(ExecState *exec, const Identifier &p) const
03143 {
03144   if (p == lengthPropertyName)
03145     return true;
03146   if ( collection.handle()->getType() == HTMLCollectionImpl::SELECT_OPTIONS &&
03147        ( p == "selectedIndex" || p == "value" ) )
03148     return true;
03149 
03150   bool ok;
03151   unsigned long pos = p.toULong(&ok);
03152   if (ok && pos < collection.length())
03153     return true;
03154 
03155   return DOMObject::hasProperty(exec, p);
03156 }
03157 
03158 ReferenceList KJS::HTMLCollection::propList(ExecState *exec, bool recursive)
03159 {
03160   ReferenceList properties = ObjectImp::propList(exec,recursive);
03161 
03162   for (unsigned i = 0; i < collection.length(); ++i) {
03163     if (!ObjectImp::hasProperty(exec,Identifier::from(i))) {
03164       properties.append(Reference(this, i));
03165     }
03166   }
03167 
03168   if (!ObjectImp::hasProperty(exec, lengthPropertyName))
03169     properties.append(Reference(this, lengthPropertyName));
03170 
03171   return properties;
03172 }
03173 
03174 Value KJS::HTMLCollection::tryGet(ExecState *exec, const Identifier &propertyName) const
03175 {
03176 #ifdef KJS_VERBOSE
03177   kdDebug(6070) << "KJS::HTMLCollection::tryGet " << propertyName.ascii() << endl;
03178 #endif
03179   if (propertyName == lengthPropertyName)
03180   {
03181 #ifdef KJS_VERBOSE
03182     kdDebug(6070) << "  collection length is " << collection.length() << endl;
03183 #endif
03184     return Number(collection.length());
03185   }
03186 
03187   if (collection.handle()->getType() == HTMLCollectionImpl::SELECT_OPTIONS) {
03188     DOM::HTMLSelectElement parentSelect = collection.base();
03189     if ( parentSelect.isNull() )
03190       return Undefined();
03191     if (propertyName == "selectedIndex") {
03192       // NON-STANDARD options.selectedIndex
03193       return Number(parentSelect.selectedIndex());
03194     } else if ( propertyName == "value" ) {
03195       // NON-STANDARD options.value
03196       return String(parentSelect.value());
03197     }
03198   }
03199 
03200   // Look in the prototype (for functions) before assuming it's an item's name
03201   Object proto = Object::dynamicCast(prototype());
03202   if (proto.isValid() && proto.hasProperty(exec,propertyName))
03203     return proto.get(exec,propertyName);
03204 
03205   // name or index ?
03206   bool ok;
03207   unsigned int u = propertyName.toULong(&ok);
03208   if (ok) {
03209     if ( u < collection.length() ) {
03210       DOM::Node node = collection.item(u);
03211       return getDOMNode(exec,node);
03212     } else
03213       return Undefined();
03214   }
03215   else
03216     return getNamedItems(exec,propertyName);
03217 }
03218 
03219 // HTMLCollections are strange objects, they support both get and call,
03220 // so that document.forms.item(0) and document.forms(0) both work.
03221 Value KJS::HTMLCollection::call(ExecState *exec, Object &thisObj, const List &args)
03222 {
03223   // This code duplication is necessary, HTMLCollection isn't a DOMFunction
03224   Value val;
03225   try {
03226     val = tryCall(exec, thisObj, args);
03227   }
03228   // pity there's no way to distinguish between these in JS code
03229   catch (...) {
03230     Object err = Error::create(exec, GeneralError, "Exception from HTMLCollection");
03231     exec->setException(err);
03232   }
03233   return val;
03234 }
03235 
03236 Value KJS::HTMLCollection::tryCall(ExecState *exec, Object &, const List &args)
03237 {
03238   // Do not use thisObj here. It can be the HTMLDocument, in the document.forms(i) case.
03239   /*if( thisObj.imp() != this )
03240   {
03241     kdDebug(6070) << "WARNING: thisObj.imp() != this in HTMLCollection::tryCall" << endl;
03242     KJS::printInfo(exec,"KJS::HTMLCollection::tryCall thisObj",thisObj,-1);
03243     KJS::printInfo(exec,"KJS::HTMLCollection::tryCall this",Value(this),-1);
03244   }*/
03245   // Also, do we need the TypeError test here ?
03246 
03247   if (args.size() == 1) {
03248     // support for document.all(<index>) etc.
03249     bool ok;
03250     UString s = args[0].toString(exec);
03251     unsigned int u = s.toULong(&ok);
03252     if (ok) {
03253       DOM::Element element = collection.item(u);
03254       return getDOMNode(exec,element);
03255     }
03256     // support for document.images('<name>') etc.
03257     return getNamedItems(exec,Identifier(s));
03258   }
03259   else if (args.size() >= 1) // the second arg, if set, is the index of the item we want
03260   {
03261     bool ok;
03262     UString s = args[0].toString(exec);
03263     unsigned int u = args[1].toString(exec).toULong(&ok);
03264     if (ok)
03265     {
03266       DOM::DOMString pstr = s.string();
03267       DOM::Node node = collection.namedItem(pstr);
03268       while (!node.isNull()) {
03269         if (!u)
03270           return getDOMNode(exec,node);
03271         node = collection.nextNamedItem(pstr);
03272         --u;
03273       }
03274     }
03275   }
03276   return Undefined();
03277 }
03278 
03279 Value KJS::HTMLCollection::getNamedItems(ExecState *exec, const Identifier &propertyName) const
03280 {
03281 #ifdef KJS_VERBOSE
03282   kdDebug(6070) << "KJS::HTMLCollection::getNamedItems " << propertyName.ascii() << endl;
03283 #endif
03284 
03285   DOM::DOMString pstr = propertyName.string();
03286 
03287   QValueList<DOM::NodeImpl*> matches = collection.handle()->namedItems(pstr);
03288 
03289   if (!matches.isEmpty()) {
03290     if (matches.size() == 1) {
03291       DOM::Node node(matches[0]);
03292 #ifdef KJS_VERBOSE
03293       kdDebug(6070) << "returning single node" << endl;
03294 #endif
03295       return getDOMNode(exec,node);
03296     }
03297     else  {
03298       // multiple items, return a collection
03299       QValueList<DOM::Node> nodes;
03300       for (QValueList<DOM::NodeImpl*>::const_iterator i =  matches.begin();
03301                                                       i != matches.end(); ++i)
03302            nodes.append(DOM::Node(*i));
03303 #ifdef KJS_VERBOSE
03304       kdDebug(6070) << "returning list of " << nodes.count() << " nodes" << endl;
03305 #endif
03306       return Value(new DOMNamedNodesCollection(exec, nodes));
03307     }
03308   }
03309 #ifdef KJS_VERBOSE
03310   kdDebug(6070) << "not found" << endl;
03311 #endif
03312   return Undefined();
03313 }
03314 
03315 Value KJS::HTMLCollectionProtoFunc::tryCall(ExecState *exec, Object &thisObj, const List &args)
03316 {
03317   KJS_CHECK_THIS( KJS::HTMLCollection, thisObj );
03318   DOM::HTMLCollection coll = static_cast<KJS::HTMLCollection *>(thisObj.imp())->toCollection();
03319 
03320   switch (id) {
03321   case KJS::HTMLCollection::Item:
03322   {
03323     // support for item(<index>) (DOM)
03324     bool ok;
03325     UString s = args[0].toString(exec);
03326     unsigned int u = s.toULong(&ok);
03327     if (ok) {
03328       return getDOMNode(exec,coll.item(u));
03329     }
03330     // support for item('<name>') (IE only)
03331     kdWarning() << "non-standard HTMLCollection.item('" << s.ascii() << "') called, use namedItem instead" << endl;
03332     return getDOMNode(exec,coll.namedItem(s.string()));
03333   }
03334   case KJS::HTMLCollection::Tags:
03335   {
03336     DOM::DOMString tagName = args[0].toString(exec).string();
03337     DOM::NodeList list;
03338     // getElementsByTagName exists in Document and in Element, pick up the right one
03339     if ( coll.base().nodeType() == DOM::Node::DOCUMENT_NODE )
03340     {
03341       DOM::Document doc = coll.base();
03342       list = doc.getElementsByTagName(tagName);
03343 #ifdef KJS_VERBOSE
03344       kdDebug(6070) << "KJS::HTMLCollectionProtoFunc::tryCall document.tags(" << tagName.string() << ") -> " << list.length() << " items in node list" << endl;
03345 #endif
03346     } else
03347     {
03348       DOM::Element e = coll.base();
03349       list = e.getElementsByTagName(tagName);
03350 #ifdef KJS_VERBOSE
03351       kdDebug(6070) << "KJS::HTMLCollectionProtoFunc::tryCall element.tags(" << tagName.string() << ") -> " << list.length() << " items in node list" << endl;
03352 #endif
03353     }
03354     return getDOMNodeList(exec, list);
03355   }
03356   case KJS::HTMLCollection::NamedItem:
03357   {
03358     Value val = static_cast<HTMLCollection *>(thisObj.imp())->getNamedItems(exec, Identifier(args[0].toString(exec)));
03359     // Must return null when asking for a named item that isn't in the collection
03360     // (DOM2 testsuite, HTMLCollection12 test)
03361     if ( val.type() == KJS::UndefinedType )
03362       return Null();
03363     else
03364       return val;
03365   }
03366   default:
03367     return Undefined();
03368   }
03369 }
03370 
03371 Value KJS::HTMLSelectCollection::tryGet(ExecState *exec, const Identifier &p) const
03372 {
03373   if (p == "selectedIndex")
03374     return Number(element.selectedIndex());
03375 
03376   return  HTMLCollection::tryGet(exec, p);
03377 }
03378 
03379 void KJS::HTMLSelectCollection::tryPut(ExecState *exec, const Identifier &propertyName, const Value& value, int)
03380 {
03381 #ifdef KJS_VERBOSE
03382   kdDebug(6070) << "KJS::HTMLSelectCollection::tryPut " << propertyName.qstring() << endl;
03383 #endif
03384   if ( propertyName == "selectedIndex" ) {
03385     element.setSelectedIndex( value.toInteger( exec ) );
03386     return;
03387   }
03388   // resize ?
03389   else if (propertyName == lengthPropertyName) {
03390     unsigned newLen;
03391     bool converted = value.toUInt32(newLen);
03392 
03393     if (!converted) {
03394       return;
03395     }
03396 
03397     long diff = element.length() - newLen;
03398 
03399     if (diff < 0) { // add dummy elements
03400       do {
03401         element.add(element.ownerDocument().createElement("OPTION"), DOM::HTMLElement());
03402       } while (++diff);
03403     }
03404     else // remove elements
03405       while (diff-- > 0)
03406         element.remove(newLen + diff);
03407 
03408     return;
03409   }
03410   // an index ?
03411   bool ok;
03412   unsigned int u = propertyName.toULong(&ok);
03413   if (!ok)
03414     return;
03415 
03416   if (value.isA(NullType) || value.isA(UndefinedType)) {
03417     // null and undefined delete. others, too ?
03418     element.remove(u);
03419     return;
03420   }
03421 
03422   // is v an option element ?
03423   DOM::Node node = KJS::toNode(value);
03424   if (node.isNull() || node.elementId() != ID_OPTION)
03425     return;
03426 
03427   DOM::HTMLOptionElement option = static_cast<DOM::HTMLOptionElement>(node);
03428   if ( option.ownerDocument() != element.ownerDocument() )
03429     option = static_cast<DOM::HTMLOptionElement>(element.ownerDocument().importNode(option, true));
03430   long diff = long(u) - element.length();
03431   DOM::HTMLElement before;
03432   // out of array bounds ? first insert empty dummies
03433   if (diff > 0) {
03434     while (diff--) {
03435       element.add(element.ownerDocument().createElement("OPTION"), before);
03436     }
03437     // replace an existing entry ?
03438   } else if (diff < 0) {
03439     before = element.options().item(u+1);
03440     element.remove(u);
03441   }
03442   // finally add the new element
03443   element.add(option, before);
03444 }
03445 
03447 
03448 OptionConstructorImp::OptionConstructorImp(ExecState *exec, const DOM::Document &d)
03449     : ObjectImp(), doc(d)
03450 {
03451   // ## isn't there some redundancy between ObjectImp::_proto and the "prototype" property ?
03452   //put(exec,"prototype", ...,DontEnum|DontDelete|ReadOnly);
03453 
03454   // no. of arguments for constructor
03455   // ## is 4 correct ? 0 to 4, it seems to be
03456   put(exec,lengthPropertyName, Number(4), ReadOnly|DontDelete|DontEnum);
03457 }
03458 
03459 bool OptionConstructorImp::implementsConstruct() const
03460 {
03461   return true;
03462 }
03463 
03464 Object OptionConstructorImp::construct(ExecState *exec, const List &args)
03465 {
03466   DOM::Element el = doc.createElement("OPTION");
03467   DOM::HTMLOptionElement opt = static_cast<DOM::HTMLOptionElement>(el);
03468   int sz = args.size();
03469   DOM::Text t = doc.createTextNode("");
03470   try { opt.appendChild(t); }
03471   catch(DOM::DOMException& e) {
03472     // #### exec->setException ?
03473   }
03474   if (sz > 0)
03475     t.setData(args[0].toString(exec).string()); // set the text
03476   if (sz > 1)
03477     opt.setValue(args[1].toString(exec).string());
03478   if (sz > 2)
03479     opt.setDefaultSelected(args[2].toBoolean(exec));
03480   if (sz > 3)
03481     opt.setSelected(args[3].toBoolean(exec));
03482 
03483   return Object::dynamicCast(getDOMNode(exec,opt));
03484 }
03485 
03487 
03488 //Like in other browsers, we merely make a new HTMLImageElement
03489 //not in tree for this.
03490 ImageConstructorImp::ImageConstructorImp(ExecState *, const DOM::Document &d)
03491     : ObjectImp(), doc(d)
03492 {
03493 }
03494 
03495 bool ImageConstructorImp::implementsConstruct() const
03496 {
03497   return true;
03498 }
03499 
03500 Object ImageConstructorImp::construct(ExecState *exec, const List &list)
03501 {
03502   bool widthSet = false, heightSet = false;
03503   int width = 0, height = 0;
03504   if (list.size() > 0) {
03505     widthSet = true;
03506     Value w = list.at(0);
03507     width = w.toInt32(exec);
03508   }
03509   if (list.size() > 1) {
03510     heightSet = true;
03511     Value h = list.at(1);
03512     height = h.toInt32(exec);
03513   }
03514 
03515   HTMLImageElement image(doc.createElement("image"));
03516 
03517   if (widthSet)
03518     image.setWidth(width);
03519 
03520   if (heightSet)
03521     image.setHeight(height);
03522 
03523   return Object::dynamicCast(getDOMNode(exec,image));
03524 }
03525 
03526 Value KJS::getHTMLCollection(ExecState *exec, const DOM::HTMLCollection& c, bool hide)
03527 {
03528   Value coll = cacheDOMObject<DOM::HTMLCollection, KJS::HTMLCollection>(exec, c);
03529   if (hide) {
03530     KJS::HTMLCollection *impl = static_cast<KJS::HTMLCollection*>(coll.imp());
03531     impl->hide();
03532   }
03533   return coll;
03534 }
03535 
03536 Value KJS::getSelectHTMLCollection(ExecState *exec, const DOM::HTMLCollection& c, const DOM::HTMLSelectElement& e)
03537 {
03538   DOMObject *ret;
03539   if (c.isNull())
03540     return Null();
03541   ScriptInterpreter* interp = static_cast<ScriptInterpreter *>(exec->interpreter());
03542   if ((ret = interp->getDOMObject(c.handle())))
03543     return Value(ret);
03544   else {
03545     ret = new HTMLSelectCollection(exec, c, e);
03546     interp->putDOMObject(c.handle(),ret);
03547     return Value(ret);
03548   }
03549 }
KDE Home | KDE Accessibility Home | Description of Access Keys