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             return Value(Window::retrieveWindow(part));
01872         else
01873             return Undefined();
01874     }
01875     case FrameFrameBorder:     return String(frameElement.frameBorder());
01876     case FrameLongDesc:        return String(frameElement.longDesc());
01877     case FrameMarginHeight:    return String(frameElement.marginHeight());
01878     case FrameMarginWidth:     return String(frameElement.marginWidth());
01879     case FrameName:            return String(frameElement.name());
01880     case FrameNoResize:        return Boolean(frameElement.noResize());
01881     case FrameScrolling:       return String(frameElement.scrolling());
01882     case FrameSrc:
01883     case FrameLocation:        return String(frameElement.src());
01884     }
01885   }
01886   break;
01887   case ID_IFRAME: {
01888     DOM::HTMLIFrameElement iFrame = element;
01889     switch (token) {
01890     case IFrameAlign:           return String(iFrame.align());
01891     case IFrameContentDocument: return checkNodeSecurity(exec,iFrame.contentDocument()) ?
01892                        getDOMNode(exec, iFrame.contentDocument()) : Undefined();
01893     case IFrameContentWindow:       {
01894         KHTMLPart* part = static_cast<DOM::HTMLIFrameElementImpl*>(iFrame.handle())->contentPart();
01895         if (part)
01896             return Value(Window::retrieveWindow(part));
01897         else
01898             return Undefined();
01899     }
01900     case IFrameFrameBorder:     return String(iFrame.frameBorder());
01901     case IFrameHeight:          return String(iFrame.height());
01902     case IFrameLongDesc:        return String(iFrame.longDesc());
01903     case IFrameMarginHeight:    return String(iFrame.marginHeight());
01904     case IFrameMarginWidth:     return String(iFrame.marginWidth());
01905     case IFrameName:            return String(iFrame.name());
01906     case IFrameScrolling:       return String(iFrame.scrolling());
01907     case IFrameSrc:             return String(iFrame.src());
01908     case IFrameWidth:           return String(iFrame.width());
01909     }
01910     break;
01911   }
01912   } // xemacs (or arnt) could be a bit smarter when it comes to indenting switch()es ;)
01913   // its not arnt to blame - its the original Stroustrup style we like :) (Dirk)
01914 
01915   // generic properties
01916   switch (token) {
01917   case ElementId:
01918     return String(element.id()); // String is wrong here. Other browsers return empty string if no id specified.
01919   case ElementTitle:
01920     return String(element.title());
01921   case ElementLang:
01922     return String(element.lang());
01923   case ElementDir:
01924     return String(element.dir());
01925   case ElementClassName:
01926     return String(element.className());
01927   case ElementInnerHTML:
01928     return String(element.innerHTML());
01929   case ElementInnerText:
01930     return String(element.innerText());
01931   case ElementDocument:
01932     return getDOMNode(exec,element.ownerDocument());
01933   case ElementChildren:
01934     return getHTMLCollection(exec,element.children());
01935   case ElementAll:
01936     // Disable element.all when we try to be Netscape-compatible
01937     if ( exec->interpreter()->compatMode() == Interpreter::NetscapeCompat )
01938       return Undefined();
01939     else
01940     if ( exec->interpreter()->compatMode() == Interpreter::IECompat )
01941       return getHTMLCollection(exec,element.all());
01942     else // Enabled but hidden by default
01943       return getHTMLCollection(exec,element.all(), true);
01944   // ### what about style? or is this used instead for DOM2 stylesheets?
01945   }
01946   kdError() << "HTMLElement::getValueProperty unhandled token " << token << endl;
01947   return Undefined();
01948 }
01949 
01950 bool KJS::HTMLElement::hasProperty(ExecState *exec, const Identifier &propertyName) const
01951 {
01952 #ifdef KJS_VERBOSE
01953   //kdDebug(6070) << "HTMLElement::hasProperty " << propertyName.qstring() << endl;
01954 #endif
01955   DOM::HTMLElement element = static_cast<DOM::HTMLElement>(node);
01956   // First look at dynamic properties - keep this in sync with tryGet
01957   switch (element.elementId()) {
01958     case ID_FORM: {
01959       DOM::HTMLFormElement form = element;
01960       // Check if we're retrieving an element (by index or by name)
01961       bool ok;
01962       uint u = propertyName.toULong(&ok);
01963       if (ok && !(form.elements().item(u).isNull()))
01964         return true;
01965       DOM::Node testnode = form.elements().namedItem(propertyName.string());
01966       if (!testnode.isNull())
01967         return true;
01968     }
01969     case ID_SELECT: {
01970       DOM::HTMLSelectElement select = element;
01971       bool ok;
01972       uint u = propertyName.toULong(&ok);
01973       if (ok && !(select.options().item(u).isNull()))
01974         return true;
01975     }
01976     default:
01977       break;
01978   }
01979 
01980   return DOMElement::hasProperty(exec, propertyName);
01981 }
01982 
01983 UString KJS::HTMLElement::toString(ExecState *exec) const
01984 {
01985   if (node.elementId() == ID_A)
01986     return UString(static_cast<const DOM::HTMLAnchorElement&>(node).href());
01987   else if (node.elementId() == ID_APPLET) {
01988     KParts::LiveConnectExtension *lc = getLiveConnectExtension(node);
01989     QStringList qargs;
01990     QString retvalue;
01991     KParts::LiveConnectExtension::Type rettype;
01992     unsigned long retobjid;
01993     if (lc && lc->call(0, "hashCode", qargs, rettype, retobjid, retvalue)) {
01994       QString str("[object APPLET ref=");
01995       return UString(str + retvalue + QString("]"));
01996     }
01997   } else if (node.elementId() == ID_IMG) {
01998     DOM::HTMLImageElement image(node);
01999     if (!image.alt().isEmpty())
02000       return UString(image.alt()) + " " + DOMElement::toString(exec);
02001   }
02002   return DOMElement::toString(exec);
02003 }
02004 
02005 static void getForm(DOM::HTMLFormElement* form, const DOM::HTMLElement& element)
02006 {
02007     switch (element.elementId()) {
02008         case ID_ISINDEX: {
02009             DOM::HTMLIsIndexElement isindex = element;
02010             *form = isindex.form();
02011             break;
02012         }
02013         case ID_SELECT: {
02014             DOM::HTMLSelectElement select = element;
02015             *form = select.form();
02016             break;
02017         }
02018         case ID_OPTION: {
02019             DOM::HTMLOptionElement option = element;
02020             *form = option.form();
02021             break;
02022         }
02023         case ID_INPUT: {
02024             DOM::HTMLInputElement input = element;
02025             *form = input.form();
02026             break;
02027         }
02028         case ID_TEXTAREA: {
02029             DOM::HTMLTextAreaElement textarea = element;
02030             *form = textarea.form();
02031             break;
02032         }
02033         case ID_LABEL: {
02034             DOM::HTMLLabelElement label = element;
02035             *form = label.form();
02036             break;
02037         }
02038         case ID_FIELDSET: {
02039             DOM::HTMLFieldSetElement fieldset = element;
02040             *form = fieldset.form();
02041             break;
02042         }
02043         case ID_LEGEND: {
02044             DOM::HTMLLegendElement legend = element;
02045             *form = legend.form();
02046             break;
02047         }
02048         case ID_OBJECT: {
02049             DOM::HTMLObjectElement object = element;
02050             *form = object.form();
02051             break;
02052         }
02053         default:
02054             break;
02055     }
02056 }
02057 
02058 void KJS::HTMLElement::pushEventHandlerScope(ExecState *exec, ScopeChain &scope) const
02059 {
02060   DOM::HTMLElement element = static_cast<DOM::HTMLElement>(node);
02061 
02062   // The document is put on first, fall back to searching it only after the element and form.
02063   scope.push(static_cast<ObjectImp *>(getDOMNode(exec, element.ownerDocument()).imp()));
02064 
02065   // The form is next, searched before the document, but after the element itself.
02066   DOM::HTMLFormElement formElt;
02067 
02068   // First try to obtain the form from the element itself.  We do this to deal with
02069   // the malformed case where <form>s aren't in our parent chain (e.g., when they were inside
02070   // <table> or <tbody>.
02071   getForm(&formElt, element);
02072   if (!formElt.isNull())
02073     scope.push(static_cast<ObjectImp *>(getDOMNode(exec, formElt).imp()));
02074   else {
02075     DOM::Node form = element.parentNode();
02076     while (!form.isNull() && form.elementId() != ID_FORM)
02077         form = form.parentNode();
02078 
02079     if (!form.isNull())
02080         scope.push(static_cast<ObjectImp *>(getDOMNode(exec, form).imp()));
02081   }
02082 
02083   // The element is on top, searched first.
02084   scope.push(static_cast<ObjectImp *>(getDOMNode(exec, element).imp()));
02085 }
02086 
02087 HTMLElementFunction::HTMLElementFunction(ExecState *exec, int i, int len)
02088   : DOMFunction(exec), id(i)
02089 {
02090   Value protect(this);
02091   put(exec,lengthPropertyName,Number(len),DontDelete|ReadOnly|DontEnum);
02092 }
02093 
02094 Value KJS::HTMLElementFunction::tryCall(ExecState *exec, Object &thisObj, const List &args)
02095 {
02096   KJS_CHECK_THIS( HTMLElement, thisObj );
02097 
02098 #ifdef KJS_VERBOSE
02099   kdDebug(6070) << "KJS::HTMLElementFunction::tryCall " << endl;
02100 #endif
02101   DOM::HTMLElement element = static_cast<KJS::HTMLElement *>(thisObj.imp())->toElement();
02102 
02103   switch (element.elementId()) {
02104     case ID_FORM: {
02105       DOM::HTMLFormElement form = element;
02106       if (id == KJS::HTMLElement::FormSubmit) {
02107 
02108 
02109         DOM::HTMLDocument doc = element.ownerDocument();
02110         KHTMLView *view = static_cast<DOM::DocumentImpl*>(doc.handle())->view();
02111         KHTMLSettings::KJSWindowOpenPolicy policy = KHTMLSettings::KJSWindowOpenAllow;
02112     if (view)
02113         policy = view->part()->settings()->windowOpenPolicy(view->part()->url().host());
02114 
02115         bool block = false;
02116 
02117         if ( policy != KHTMLSettings::KJSWindowOpenAllow ) {
02118           block = true;
02119 
02120          // if this is a form without a target, or a special target, don't block
02121           QString trg = form.target().lower().string();
02122           if( trg.isEmpty() || trg == "_top" || trg == "_self" ||
02123               trg == "_parent")
02124             block = false;
02125 
02126           QString caption;
02127 
02128           // if there is a frame with the target name, don't block
02129           if ( view && view->part() )  {
02130             if (!view->part()->url().host().isEmpty())
02131               caption = view->part()->url().host() + " - ";
02132             // search all (possibly nested) framesets
02133             KHTMLPart *currentPart = view->part()->parentPart();
02134             while( currentPart != 0L ) {
02135               if( currentPart->frameExists( form.target().string() ) )
02136                 block = false;
02137               currentPart = currentPart->parentPart();
02138             }
02139           }
02140 
02141           if ( block && policy == KHTMLSettings::KJSWindowOpenAsk && view ) {
02142             if (view && view->part())
02143             emit view->part()->browserExtension()->requestFocus(view->part());
02144             caption += i18n( "Confirmation: JavaScript Popup" );
02145             if ( KMessageBox::questionYesNo(view, form.action().isEmpty() ?
02146                    i18n( "This site is submitting a form which will open up a new browser "
02147                          "window via JavaScript.\n"
02148                          "Do you want to allow the form to be submitted?" ) :
02149                    i18n( "<qt>This site is submitting a form which will open <p>%1</p> in a new browser window via JavaScript.<br />"
02150                          "Do you want to allow the form to be submitted?</qt>").arg(KStringHandler::csqueeze(form.action().string(),  100)),
02151                    caption, i18n("Allow"), i18n("Do Not Allow") ) == KMessageBox::Yes )
02152               block = false;
02153 
02154           } else if ( block && policy == KHTMLSettings::KJSWindowOpenSmart ) {
02155             if( static_cast<KJS::ScriptInterpreter *>(exec->interpreter())->isWindowOpenAllowed() ) {
02156               // This submission has been triggered by the user
02157               block = false;
02158             }
02159           }
02160         }
02161 
02162         if( !block )
02163           form.submit();
02164 
02165         return Undefined();
02166       }
02167       else if (id == KJS::HTMLElement::FormReset) {
02168         form.reset();
02169         return Undefined();
02170       }
02171     }
02172     break;
02173     case ID_SELECT: {
02174       DOM::HTMLSelectElement select = element;
02175       if (id == KJS::HTMLElement::SelectAdd) {
02176         select.add(KJS::toNode(args[0]),KJS::toNode(args[1]));
02177         return Undefined();
02178       }
02179       else if (id == KJS::HTMLElement::SelectRemove) {
02180         select.remove(int(args[0].toNumber(exec)));
02181         return Undefined();
02182       }
02183       else if (id == KJS::HTMLElement::SelectBlur) {
02184         select.blur();
02185         return Undefined();
02186       }
02187       else if (id == KJS::HTMLElement::SelectFocus) {
02188         select.focus();
02189         return Undefined();
02190       }
02191     }
02192     break;
02193     case ID_INPUT: {
02194       DOM::HTMLInputElement input = element;
02195       if (id == KJS::HTMLElement::InputBlur) {
02196         input.blur();
02197         return Undefined();
02198       }
02199       else if (id == KJS::HTMLElement::InputFocus) {
02200         input.focus();
02201         return Undefined();
02202       }
02203       else if (id == KJS::HTMLElement::InputSelect) {
02204         input.select();
02205         return Undefined();
02206       }
02207       else if (id == KJS::HTMLElement::InputClick) {
02208         input.click();
02209         return Undefined();
02210       }
02211       else if (id == KJS::HTMLElement::InputSetSelectionRange) {
02212         input.setSelectionRange(args[0].toNumber(exec), args[1].toNumber(exec));
02213         return Undefined();
02214       }
02215     }
02216     break;
02217     case ID_BUTTON: {
02218       DOM::HTMLButtonElement button = element;
02219       if (id == KJS::HTMLElement::ButtonBlur) {
02220         button.blur();
02221         return Undefined();
02222       }
02223       else if (id == KJS::HTMLElement::ButtonFocus) {
02224         button.focus();
02225         return Undefined();
02226       }
02227     }
02228     break;
02229     case ID_TEXTAREA: {
02230       DOM::HTMLTextAreaElement textarea = element;
02231       if (id == KJS::HTMLElement::TextAreaBlur) {
02232         textarea.blur();
02233         return Undefined();
02234       }
02235       else if (id == KJS::HTMLElement::TextAreaFocus) {
02236         textarea.focus();
02237         return Undefined();
02238       }
02239       else if (id == KJS::HTMLElement::TextAreaSelect) {
02240         textarea.select();
02241         return Undefined();
02242       }
02243       else if (id == KJS::HTMLElement::TextAreaSetSelectionRange) {
02244         textarea.setSelectionRange(args[0].toNumber(exec), args[1].toNumber(exec));
02245         return Undefined();
02246       }
02247 
02248     }
02249     break;
02250     case ID_A: {
02251       DOM::HTMLAnchorElement anchor = element;
02252       if (id == KJS::HTMLElement::AnchorBlur) {
02253         anchor.blur();
02254         return Undefined();
02255       }
02256       else if (id == KJS::HTMLElement::AnchorFocus) {
02257         anchor.focus();
02258         return Undefined();
02259       }
02260       else if (id == KJS::HTMLElement::AnchorClick) {
02261         static_cast<DOM::HTMLAnchorElementImpl*>(anchor.handle())->click();
02262         return Undefined();
02263       }
02264     }
02265     break;
02266     case ID_TABLE: {
02267       DOM::HTMLTableElement table = element;
02268       if (id == KJS::HTMLElement::TableCreateTHead)
02269         return getDOMNode(exec,table.createTHead());
02270       else if (id == KJS::HTMLElement::TableDeleteTHead) {
02271         table.deleteTHead();
02272         return Undefined();
02273       }
02274       else if (id == KJS::HTMLElement::TableCreateTFoot)
02275         return getDOMNode(exec,table.createTFoot());
02276       else if (id == KJS::HTMLElement::TableDeleteTFoot) {
02277         table.deleteTFoot();
02278         return Undefined();
02279       }
02280       else if (id == KJS::HTMLElement::TableCreateCaption)
02281         return getDOMNode(exec,table.createCaption());
02282       else if (id == KJS::HTMLElement::TableDeleteCaption) {
02283         table.deleteCaption();
02284         return Undefined();
02285       }
02286       else if (id == KJS::HTMLElement::TableInsertRow)
02287         return getDOMNode(exec,table.insertRow(args[0].toInteger(exec)));
02288       else if (id == KJS::HTMLElement::TableDeleteRow) {
02289         table.deleteRow(args[0].toInteger(exec));
02290         return Undefined();
02291       }
02292     }
02293     break;
02294     case ID_THEAD:
02295     case ID_TBODY:
02296     case ID_TFOOT: {
02297       DOM::HTMLTableSectionElement tableSection = element;
02298       if (id == KJS::HTMLElement::TableSectionInsertRow)
02299         return getDOMNode(exec,tableSection.insertRow(args[0].toInteger(exec)));
02300       else if (id == KJS::HTMLElement::TableSectionDeleteRow) {
02301         tableSection.deleteRow(args[0].toInteger(exec));
02302         return Undefined();
02303       }
02304     }
02305     break;
02306     case ID_TR: {
02307       DOM::HTMLTableRowElement tableRow = element;
02308       if (id == KJS::HTMLElement::TableRowInsertCell)
02309         return getDOMNode(exec,tableRow.insertCell(args[0].toInteger(exec)));
02310       else if (id == KJS::HTMLElement::TableRowDeleteCell) {
02311         tableRow.deleteCell(args[0].toInteger(exec));
02312         return Undefined();
02313       }
02314       break;
02315     }
02316     case ID_MARQUEE: {
02317       if (id == KJS::HTMLElement::MarqueeStart && element.handle()->renderer() &&
02318         element.handle()->renderer()->layer() &&
02319         element.handle()->renderer()->layer()->marquee()) {
02320         element.handle()->renderer()->layer()->marquee()->start();
02321         return Undefined();
02322       }
02323       else if (id == KJS::HTMLElement::MarqueeStop && element.handle()->renderer() &&
02324               element.handle()->renderer()->layer() &&
02325               element.handle()->renderer()->layer()->marquee()) {
02326         element.handle()->renderer()->layer()->marquee()->stop();
02327         return Undefined();
02328       }
02329       break;
02330     }
02331   }
02332 
02333   if (id == HTMLElement::ElementScrollIntoView) {
02334     // ### implement
02335     kdWarning() << "non-standard HTMLElement::scrollIntoView() not implemented"
02336         << endl;
02337     return Undefined();
02338   }
02339 
02340   return Undefined();
02341 }
02342 
02343 void KJS::HTMLElement::tryPut(ExecState *exec, const Identifier &propertyName, const Value& value, int attr)
02344 {
02345 #ifdef KJS_VERBOSE
02346   DOM::DOMString str = value.isA(NullType) ? DOM::DOMString() : value.toString(exec).string();
02347 #endif
02348   DOM::HTMLElement element = static_cast<DOM::HTMLElement>(node);
02349 #ifdef KJS_VERBOSE
02350   kdDebug(6070) << "KJS::HTMLElement::tryPut " << propertyName.qstring()
02351                 << " thisTag=" << element.tagName().string()
02352                 << " str=" << str.string() << endl;
02353 #endif
02354   // First look at dynamic properties
02355   switch (element.elementId()) {
02356     case ID_SELECT: {
02357       DOM::HTMLSelectElement select = element;
02358       bool ok;
02359       /*uint u =*/ propertyName.toULong(&ok);
02360       if (ok) {
02361         Object coll = Object::dynamicCast( getSelectHTMLCollection(exec, select.options(), select) );
02362         if ( coll.isValid() )
02363           coll.put(exec,propertyName,value);
02364         return;
02365       }
02366       break;
02367     }
02368     case ID_APPLET:
02369     case ID_OBJECT:
02370     case ID_EMBED: {
02371       KParts::LiveConnectExtension *lc = getLiveConnectExtension(element);
02372       if (lc && lc->put(0, propertyName.qstring(), value.toString(exec).qstring()))
02373         return;
02374       break;
02375     }
02376     default:
02377       break;
02378   }
02379 
02380   const HashTable* table = classInfo()->propHashTable; // get the right hashtable
02381   const HashEntry* entry = Lookup::findEntry(table, propertyName);
02382   if (entry) {
02383     if (entry->attr & Function) // function: put as override property
02384     {
02385       ObjectImp::put(exec, propertyName, value, attr);
02386       return;
02387     }
02388     else if ((entry->attr & ReadOnly) == 0) // let DOMObjectLookupPut print the warning if not
02389     {
02390       putValueProperty(exec, entry->value, value, attr);
02391       return;
02392     }
02393   }
02394   DOMObjectLookupPut<KJS::HTMLElement, DOMElement>(exec, propertyName, value, attr, &KJS::HTMLElementTable, this);
02395 }
02396 
02397 void KJS::HTMLElement::putValueProperty(ExecState *exec, int token, const Value& value, int)
02398 {
02399   DOM::DOMString str = value.isA(NullType) ? DOM::DOMString() : value.toString(exec).string();
02400   DOMNode *kjsNode = new DOMNode(exec, KJS::toNode(value));
02401   // Need to create a Value wrapper to avoid leaking the KJS::DOMNode
02402   Value nodeValue(kjsNode);
02403   DOM::Node n = kjsNode->toNode();
02404   DOM::HTMLElement element = static_cast<DOM::HTMLElement>(node);
02405 #ifdef KJS_VERBOSE
02406   kdDebug(6070) << "KJS::HTMLElement::putValueProperty "
02407                 << " thisTag=" << element.tagName().string()
02408                 << " token=" << token << endl;
02409 #endif
02410 
02411   switch (element.elementId()) {
02412   case ID_HTML: {
02413       DOM::HTMLHtmlElement html = element;
02414       switch (token) {
02415       case HtmlVersion:         { html.setVersion(str); return; }
02416       }
02417   }
02418   break;
02419   case ID_HEAD: {
02420     DOM::HTMLHeadElement head = element;
02421     switch (token) {
02422     case HeadProfile:         { head.setProfile(str); return; }
02423     }
02424   }
02425   break;
02426   case ID_LINK: {
02427     DOM::HTMLLinkElement link = element;
02428     switch (token) {
02429       case LinkDisabled:        { link.setDisabled(value.toBoolean(exec)); return; }
02430       case LinkCharset:         { link.setCharset(str); return; }
02431       case LinkHref:            { link.setHref(str); return; }
02432       case LinkHrefLang:        { link.setHreflang(str); return; }
02433       case LinkMedia:           { link.setMedia(str); return; }
02434       case LinkRel:             { link.setRel(str); return; }
02435       case LinkRev:             { link.setRev(str); return; }
02436       case LinkTarget:          { link.setTarget(str); return; }
02437       case LinkType:            { link.setType(str); return; }
02438       }
02439     }
02440     break;
02441     case ID_TITLE: {
02442       DOM::HTMLTitleElement title = element;
02443       switch (token) {
02444       case TitleText:                 { title.setText(str); return; }
02445       }
02446     }
02447     break;
02448     case ID_META: {
02449       DOM::HTMLMetaElement meta = element;
02450       switch (token) {
02451       case MetaContent:         { meta.setContent(str); return; }
02452       case MetaHttpEquiv:       { meta.setHttpEquiv(str); return; }
02453       case MetaName:            { meta.setName(str); return; }
02454       case MetaScheme:          { meta.setScheme(str); return; }
02455       }
02456     }
02457     break;
02458     case ID_BASE: {
02459       DOM::HTMLBaseElement base = element;
02460       switch (token) {
02461       case BaseHref:            { base.setHref(str); return; }
02462       case BaseTarget:          { base.setTarget(str); return; }
02463       }
02464     }
02465     break;
02466     case ID_ISINDEX: {
02467       DOM::HTMLIsIndexElement isindex = element;
02468       switch (token) {
02469       // read-only: form
02470       case IsIndexPrompt:               { isindex.setPrompt(str); return; }
02471       }
02472     }
02473     break;
02474     case ID_STYLE: {
02475       DOM::HTMLStyleElement style = element;
02476       switch (token) {
02477       case StyleDisabled:        { style.setDisabled(value.toBoolean(exec)); return; }
02478       case StyleMedia:           { style.setMedia(str); return; }
02479       case StyleType:            { style.setType(str); return; }
02480       }
02481     }
02482     break;
02483     case ID_BODY: {
02484       DOM::HTMLBodyElement body = element;
02485       switch (token) {
02486       case BodyALink:           { body.setALink(str); return; }
02487       case BodyBackground:      { body.setBackground(str); return; }
02488       case BodyBgColor:         { body.setBgColor(str); return; }
02489       case BodyLink:            { body.setLink(str); return; }
02490       case BodyText:            { body.setText(str); return; }
02491       case BodyVLink:           { body.setVLink(str); return; }
02492       case BodyScrollLeft:
02493       case BodyScrollTop: {
02494         QScrollView* sview = body.ownerDocument().view();
02495         if (sview) {
02496           // Update the document's layout before we compute these attributes.
02497           DOM::DocumentImpl* docimpl = body.handle()->getDocument();
02498           if (docimpl)
02499             docimpl->updateLayout();
02500           if (token == BodyScrollLeft)
02501             sview->setContentsPos(value.toInteger(exec), sview->contentsY());
02502           else
02503             sview->setContentsPos(sview->contentsX(), value.toInteger(exec));
02504           }
02505         return;
02506       }
02507       case BodyOnLoad:
02508         DOM::DocumentImpl *doc = static_cast<DOM::DocumentImpl *>(node.ownerDocument().handle());
02509         if (doc && checkNodeSecurity(exec, node))
02510         {
02511           DOMNode* kjsDocNode = new DOMNode(exec, doc);
02512           // Need to create a Value wrapper to avoid leaking the KJS::DOMNode
02513           Value nodeValue(kjsDocNode);
02514           kjsDocNode->setListener(exec,DOM::EventImpl::LOAD_EVENT,value);
02515         }
02516         return;
02517       }
02518     }
02519     break;
02520     case ID_FORM: {
02521       DOM::HTMLFormElement form = element;
02522       switch (token) {
02523       // read-only: elements
02524       // read-only: length
02525       case FormName:            { form.setName(str); return; }
02526       case FormAcceptCharset:   { form.setAcceptCharset(str); return; }
02527       case FormAction:          { form.setAction(str.string()); return; }
02528       case FormEncType:         { form.setEnctype(str); return; }
02529       case FormMethod:          { form.setMethod(str); return; }
02530       case FormTarget:          { form.setTarget(str); return; }
02531       }
02532     }
02533     break;
02534     case ID_SELECT: {
02535       DOM::HTMLSelectElement select = element;
02536       switch (token) {
02537       // read-only: type
02538       case SelectSelectedIndex:   { select.setSelectedIndex(value.toInteger(exec)); return; }
02539       case SelectValue:           { select.setValue(str); return; }
02540       case SelectLength:          { // read-only according to the NS spec, but webpages need it writeable
02541                                          Object coll = Object::dynamicCast( getSelectHTMLCollection(exec, select.options(), select) );
02542                                          if ( coll.isValid() )
02543                                            coll.put(exec,"length",value);
02544                                          return;
02545                                        }
02546       // read-only: form
02547       // read-only: options
02548       case SelectDisabled:        { select.setDisabled(value.toBoolean(exec)); return; }
02549       case SelectMultiple:        { select.setMultiple(value.toBoolean(exec)); return; }
02550       case SelectName:            { select.setName(str); return; }
02551       case SelectSize:            { select.setSize(value.toInteger(exec)); return; }
02552       case SelectTabIndex:        { select.setTabIndex(value.toInteger(exec)); return; }
02553       }
02554     }
02555     break;
02556     case ID_OPTGROUP: {
02557       DOM::HTMLOptGroupElement optgroup = element;
02558       switch (token) {
02559       case OptGroupDisabled:        { optgroup.setDisabled(value.toBoolean(exec)); return; }
02560       case OptGroupLabel:           { optgroup.setLabel(str); return; }
02561       }
02562     }
02563     break;
02564     case ID_OPTION: {
02565       DOM::HTMLOptionElement option = element;
02566       switch (token) {
02567       // read-only: form
02568       case OptionDefaultSelected: { option.setDefaultSelected(value.toBoolean(exec)); return; }
02569       // read-only: text  <--- According to the DOM, but JavaScript and JScript both allow changes.
02570       // So, we'll do it here and not add it to our DOM headers.
02571       case OptionText:            { DOM::NodeList nl(option.childNodes());
02572                                     for (unsigned int i = 0; i < nl.length(); i++) {
02573                                         if (nl.item(i).nodeType() == DOM::Node::TEXT_NODE) {
02574                                             static_cast<DOM::Text>(nl.item(i)).setData(str);
02575                                             return;
02576                                         }
02577                                   }
02578                                   // No child text node found, creating one
02579                                   DOM::Text t = option.ownerDocument().createTextNode(str);
02580                                   try { option.appendChild(t); }
02581                                   catch(DOM::DOMException& e) {
02582                                     // #### exec->setException ?
02583                                   }
02584 
02585                                   return;
02586       }
02587       // read-only: index
02588       case OptionDisabled:        { option.setDisabled(value.toBoolean(exec)); return; }
02589       case OptionLabel:           { option.setLabel(str); return; }
02590       case OptionSelected:        { option.setSelected(value.toBoolean(exec)); return; }
02591       case OptionValue:           { option.setValue(str); return; }
02592       }
02593     }
02594     break;
02595     case ID_INPUT: {
02596       DOM::HTMLInputElement input = element;
02597       switch (token) {
02598       case InputDefaultValue:    { input.setDefaultValue(str); return; }
02599       case InputDefaultChecked:  { input.setDefaultChecked(value.toBoolean(exec)); return; }
02600       // read-only: form
02601       case InputAccept:          { input.setAccept(str); return; }
02602       case InputAccessKey:       { input.setAccessKey(str); return; }
02603       case InputAlign:           { input.setAlign(str); return; }
02604       case InputAlt:             { input.setAlt(str); return; }
02605       case InputChecked:         { input.setChecked(value.toBoolean(exec)); return; }
02606       case InputDisabled:        { input.setDisabled(value.toBoolean(exec)); return; }
02607       case InputMaxLength:       { input.setMaxLength(value.toInteger(exec)); return; }
02608       case InputName:            { input.setName(str); return; }
02609       case InputReadOnly:        { input.setReadOnly(value.toBoolean(exec)); return; }
02610       case InputSize:            { input.setSize(value.toInteger(exec)); return; }
02611       case InputSrc:             { input.setSrc(str); return; }
02612       case InputTabIndex:        { input.setTabIndex(value.toInteger(exec)); return; }
02613       case InputType:            { input.setType(str); return; }
02614       case InputUseMap:          { input.setUseMap(str); return; }
02615       case InputValue:           { input.setValue(str); return; }
02616       case InputSelectionStart:  { input.setSelectionStart(value.toInteger(exec)); return; }
02617       case InputSelectionEnd:    { input.setSelectionEnd  (value.toInteger(exec)); return; }
02618       }
02619     }
02620     break;
02621     case ID_TEXTAREA: {
02622       DOM::HTMLTextAreaElement textarea = element;
02623       switch (token) {
02624       case TextAreaDefaultValue:    { textarea.setDefaultValue(str); return; }
02625       // read-only: form
02626       case TextAreaAccessKey:       { textarea.setAccessKey(str); return; }
02627       case TextAreaCols:            { textarea.setCols(value.toInteger(exec)); return; }
02628       case TextAreaDisabled:        { textarea.setDisabled(value.toBoolean(exec)); return; }
02629       case TextAreaName:            { textarea.setName(str); return; }
02630       case TextAreaReadOnly:        { textarea.setReadOnly(value.toBoolean(exec)); return; }
02631       case TextAreaRows:            { textarea.setRows(value.toInteger(exec)); return; }
02632       case TextAreaTabIndex:        { textarea.setTabIndex(value.toInteger(exec)); return; }
02633       // read-only: type
02634       case TextAreaValue:           { textarea.setValue(str); return; }
02635       case TextAreaSelectionStart:  { textarea.setSelectionStart(value.toInteger(exec)); return; }
02636       case TextAreaSelectionEnd:    { textarea.setSelectionEnd  (value.toInteger(exec)); return; }
02637       }
02638     }
02639     break;
02640     case ID_BUTTON: {
02641       DOM::HTMLButtonElement button = element;
02642       switch (token) {
02643       // read-only: form
02644       case ButtonAccessKey:       { button.setAccessKey(str); return; }
02645       case ButtonDisabled:        { button.setDisabled(value.toBoolean(exec)); return; }
02646       case ButtonName:            { button.setName(str); return; }
02647       case ButtonTabIndex:        { button.setTabIndex(value.toInteger(exec)); return; }
02648       // read-only: type
02649       case ButtonValue:           { button.setValue(str); return; }
02650       }
02651     }
02652     break;
02653     case ID_LABEL: {
02654       DOM::HTMLLabelElement label = element;
02655       switch (token) {
02656       // read-only: form
02657       case LabelAccessKey:       { label.setAccessKey(str); return; }
02658       case LabelHtmlFor:         { label.setHtmlFor(str); return; }
02659       }
02660     }
02661     break;
02662 //    case ID_FIELDSET: {
02663 //      DOM::HTMLFieldSetElement fieldSet = element;
02664 //      // read-only: form
02665 //    }
02666 //    break;
02667     case ID_LEGEND: {
02668       DOM::HTMLLegendElement legend = element;
02669       switch (token) {
02670       // read-only: form
02671       case LegendAccessKey:       { legend.setAccessKey(str); return; }
02672       case LegendAlign:           { legend.setAlign(str); return; }
02673       }
02674     }
02675     break;
02676     case ID_UL: {
02677       DOM::HTMLUListElement uList = element;
02678       switch (token) {
02679       case UListCompact:         { uList.setCompact(value.toBoolean(exec)); return; }
02680       case UListType:            { uList.setType(str); return; }
02681       }
02682     }
02683     break;
02684     case ID_OL: {
02685       DOM::HTMLOListElement oList = element;
02686       switch (token) {
02687       case OListCompact:         { oList.setCompact(value.toBoolean(exec)); return; }
02688       case OListStart:           { oList.setStart(value.toInteger(exec)); return; }
02689       case OListType:            { oList.setType(str); return; }
02690       }
02691     }
02692     break;
02693     case ID_DL: {
02694       DOM::HTMLDListElement dList = element;
02695       switch (token) {
02696       case DListCompact:         { dList.setCompact(value.toBoolean(exec)); return; }
02697       }
02698     }
02699     break;
02700     case ID_DIR: {
02701       DOM::HTMLDirectoryElement directory = element;
02702       switch (token) {
02703       case DirectoryCompact:     { directory.setCompact(value.toBoolean(exec)); return; }
02704       }
02705     }
02706     break;
02707     case ID_MENU: {
02708       DOM::HTMLMenuElement menu = element;
02709       switch (token) {
02710       case MenuCompact:         { menu.setCompact(value.toBoolean(exec)); return; }
02711       }
02712     }
02713     break;
02714     case ID_LI: {
02715       DOM::HTMLLIElement li = element;
02716       switch (token) {
02717       case LIType:            { li.setType(str); return; }
02718       case LIValue:           { li.setValue(value.toInteger(exec)); return; }
02719       }
02720     }
02721     break;
02722     case ID_DIV: {
02723       DOM::HTMLDivElement div = element;
02724       switch (token) {
02725       case DivAlign:           { div.setAlign(str); return; }
02726       }
02727     }
02728     break;
02729     case ID_P: {
02730       DOM::HTMLParagraphElement paragraph = element;
02731       switch (token) {
02732       case ParagraphAlign:     { paragraph.setAlign(str); return; }
02733       }
02734     }
02735     break;
02736     case ID_H1:
02737     case ID_H2:
02738     case ID_H3:
02739     case ID_H4:
02740     case ID_H5:
02741     case ID_H6: {
02742       DOM::HTMLHeadingElement heading = element;
02743       switch (token) {
02744       case HeadingAlign:         { heading.setAlign(str); return; }
02745       }
02746     }
02747     break;
02748     case ID_BLOCKQUOTE: {
02749       DOM::HTMLBlockquoteElement blockquote = element;
02750       switch (token) {
02751       case BlockQuoteCite:       { blockquote.setCite(str); return; }
02752       }
02753     }
02754     break;
02755     case ID_Q: {
02756       DOM::HTMLQuoteElement quote = element;
02757       switch (token) {
02758       case QuoteCite:            { quote.setCite(str); return; }
02759       }
02760     }
02761     break;
02762     case ID_PRE: {
02763       DOM::HTMLPreElement pre = element;
02764       switch (token) {
02765       case PreWidth:           { pre.setWidth(value.toInteger(exec)); return; }
02766       }
02767     }
02768     break;
02769     case ID_BR: {
02770       DOM::HTMLBRElement br = element;
02771       switch (token) {
02772       case BRClear:           { br.setClear(str); return; }
02773       }
02774     }
02775     break;
02776     case ID_BASEFONT: {
02777       DOM::HTMLBaseFontElement baseFont = element;
02778       switch (token) {
02779       case BaseFontColor:           { baseFont.setColor(str); return; }
02780       case BaseFontFace:            { baseFont.setFace(str); return; }
02781       case BaseFontSize:            { baseFont.setSize(value.toInteger(exec)); return; }
02782       }
02783     }
02784     break;
02785     case ID_FONT: {
02786       DOM::HTMLFontElement font = element;
02787       switch (token) {
02788       case FontColor:           { font.setColor(str); return; }
02789       case FontFace:            { font.setFace(str); return; }
02790       case FontSize:            { font.setSize(str); return; }
02791       }
02792     }
02793     break;
02794     case ID_HR: {
02795       DOM::HTMLHRElement hr = element;
02796       switch (token) {
02797       case HRAlign:           { hr.setAlign(str); return; }
02798       case HRNoShade:         { hr.setNoShade(value.toBoolean(exec)); return; }
02799       case HRSize:            { hr.setSize(str); return; }
02800       case HRWidth:           { hr.setWidth(str); return; }
02801       }
02802     }
02803     break;
02804     case ID_INS:
02805     case ID_DEL: {
02806       DOM::HTMLModElement mod = element;
02807       switch (token) {
02808       case ModCite:            { mod.setCite(str); return; }
02809       case ModDateTime:        { mod.setDateTime(str); return; }
02810       }
02811     }
02812     break;
02813     case ID_A: {
02814       DOM::HTMLAnchorElement anchor = element;
02815       switch (token) {
02816       case AnchorAccessKey:       { anchor.setAccessKey(str); return; }
02817       case AnchorCharset:         { anchor.setCharset(str); return; }
02818       case AnchorCoords:          { anchor.setCoords(str); return; }
02819       case AnchorHref:            { anchor.setHref(str); return; }
02820       case AnchorHrefLang:        { anchor.setHreflang(str); return; }
02821       case AnchorName:            { anchor.setName(str); return; }
02822       case AnchorRel:             { anchor.setRel(str); return; }
02823       case AnchorRev:             { anchor.setRev(str); return; }
02824       case AnchorShape:           { anchor.setShape(str); return; }
02825       case AnchorTabIndex:        { anchor.setTabIndex(value.toInteger(exec)); return; }
02826       case AnchorTarget:          { anchor.setTarget(str); return; }
02827       case AnchorType:            { anchor.setType(str); return; }
02828       }
02829     }
02830     break;
02831     case ID_IMG: {
02832       DOM::HTMLImageElement image = element;
02833       switch (token) {
02834       case ImageName:            { image.setName(str); return; }
02835       case ImageAlign:           { image.setAlign(str); return; }
02836       case ImageAlt:             { image.setAlt(str); return; }
02837       case ImageBorder:          { image.setBorder(str); return; }
02838       case ImageHeight:          { image.setHeight(value.toInteger(exec)); return; }
02839       case ImageHspace:          { image.setHspace(value.toInteger(exec)); return; }
02840       case ImageIsMap:           { image.setIsMap(value.toBoolean(exec)); return; }
02841       case ImageLongDesc:        { image.setLongDesc(str); return; }
02842       case ImageSrc:             { image.setSrc(str); return; }
02843       case ImageUseMap:          { image.setUseMap(str); return; }
02844       case ImageVspace:          { image.setVspace(value.toInteger(exec)); return; }
02845       case ImageWidth:           { image.setWidth(value.toInteger(exec)); return; }
02846       }
02847     }
02848     break;
02849     case ID_OBJECT: {
02850       DOM::HTMLObjectElement object = element;
02851       switch (token) {
02852       // read-only: form
02853       case ObjectCode:                 { object.setCode(str); return; }
02854       case ObjectAlign:           { object.setAlign(str); return; }
02855       case ObjectArchive:         { object.setArchive(str); return; }
02856       case ObjectBorder:          { object.setBorder(str); return; }
02857       case ObjectCodeBase:        { object.setCodeBase(str); return; }
02858       case ObjectCodeType:        { object.setCodeType(str); return; }
02859       // read-only: ObjectContentDocument
02860       case ObjectData:            { object.setData(str); return; }
02861       case ObjectDeclare:         { object.setDeclare(value.toBoolean(exec)); return; }
02862       case ObjectHeight:          { object.setHeight(str); return; }
02863       case ObjectHspace:          { object.setHspace(value.toInteger(exec)); return; }
02864       case ObjectName:            { object.setName(str); return; }
02865       case ObjectStandby:         { object.setStandby(str); return; }
02866       case ObjectTabIndex:        { object.setTabIndex(value.toInteger(exec)); return; }
02867       case ObjectType:            { object.setType(str); return; }
02868       case ObjectUseMap:          { object.setUseMap(str); return; }
02869       case ObjectVspace:          { object.setVspace(value.toInteger(exec)); return; }
02870       case ObjectWidth:           { object.setWidth(str); return; }
02871       }
02872     }
02873     break;
02874     case ID_PARAM: {
02875       DOM::HTMLParamElement param = element;
02876       switch (token) {
02877       case ParamName:            { param.setName(str); return; }
02878       case ParamType:            { param.setType(str); return; }
02879       case ParamValue:           { param.setValue(str); return; }
02880       case ParamValueType:       { param.setValueType(str); return; }
02881       }
02882     }
02883     break;
02884     case ID_APPLET: {
02885       DOM::HTMLAppletElement applet = element;
02886       switch (token) {
02887       case AppletAlign:           { applet.setAlign(str); return; }
02888       case AppletAlt:             { applet.setAlt(str); return; }
02889       case AppletArchive:         { applet.setArchive(str); return; }
02890       case AppletCode:            { applet.setCode(str); return; }
02891       case AppletCodeBase:        { applet.setCodeBase(str); return; }
02892       case AppletHeight:          { applet.setHeight(str); return; }
02893       case AppletHspace:          { applet.setHspace(value.toInteger(exec)); return; }
02894       case AppletName:            { applet.setName(str); return; }
02895       case AppletObject:          { applet.setObject(str); return; }
02896       case AppletVspace:          { applet.setVspace(value.toInteger(exec)); return; }
02897       case AppletWidth:           { applet.setWidth(str); return; }
02898       }
02899     }
02900     break;
02901     case ID_MAP: {
02902       DOM::HTMLMapElement map = element;
02903       switch (token) {
02904       // read-only: areas
02905       case MapName:                 { map.setName(str); return; }
02906      }
02907     }
02908     break;
02909     case ID_AREA: {
02910       DOM::HTMLAreaElement area = element;
02911       switch (token) {
02912       case AreaAccessKey:       { area.setAccessKey(str); return; }
02913       case AreaAlt:             { area.setAlt(str); return; }
02914       case AreaCoords:          { area.setCoords(str); return; }
02915       case AreaHref:            { area.setHref(str); return; }
02916       case AreaNoHref:          { area.setNoHref(value.toBoolean(exec)); return; }
02917       case AreaShape:           { area.setShape(str); return; }
02918       case AreaTabIndex:        { area.setTabIndex(value.toInteger(exec)); return; }
02919       case AreaTarget:          { area.setTarget(str); return; }
02920       }
02921     }
02922     break;
02923     case ID_SCRIPT: {
02924       DOM::HTMLScriptElement script = element;
02925       switch (token) {
02926       case ScriptText:            { script.setText(str); return; }
02927       case ScriptHtmlFor:         { script.setHtmlFor(str); return; }
02928       case ScriptEvent:           { script.setEvent(str); return; }
02929       case ScriptCharset:         { script.setCharset(str); return; }
02930       case ScriptDefer:           { script.setDefer(value.toBoolean(exec)); return; }
02931       case ScriptSrc:             { script.setSrc(str); return; }
02932       case ScriptType:            { script.setType(str); return; }
02933       }
02934     }
02935     break;
02936     case ID_TABLE: {
02937       DOM::HTMLTableElement table = element;
02938       switch (token) {
02939       case TableCaption:         { table.setCaption(n); return; } // type HTMLTableCaptionElement
02940       case TableTHead:           { table.setTHead(n); return; } // type HTMLTableSectionElement
02941       case TableTFoot:           { table.setTFoot(n); return; } // type HTMLTableSectionElement
02942       // read-only: rows
02943       // read-only: tbodies
02944       case TableAlign:           { table.setAlign(str); return; }
02945       case TableBgColor:         { table.setBgColor(str); return; }
02946       case TableBorder:          { table.setBorder(str); return; }
02947       case TableCellPadding:     { table.setCellPadding(str); return; }
02948       case TableCellSpacing:     { table.setCellSpacing(str); return; }
02949       case TableFrame:           { table.setFrame(str); return; }
02950       case TableRules:           { table.setRules(str); return; }
02951       case TableSummary:         { table.setSummary(str); return; }
02952       case TableWidth:           { table.setWidth(str); return; }
02953       }
02954     }
02955     break;
02956     case ID_CAPTION: {
02957       DOM::HTMLTableCaptionElement tableCaption = element;
02958       switch (token) {
02959       case TableCaptionAlign:           { tableCaption.setAlign(str); return; }
02960       }
02961     }
02962     break;
02963     case ID_COL:
02964     case ID_COLGROUP: {
02965       DOM::HTMLTableColElement tableCol = element;
02966       switch (token) {
02967       case TableColAlign:           { tableCol.setAlign(str); return; }
02968       case TableColCh:              { tableCol.setCh(str); return; }
02969       case TableColChOff:           { tableCol.setChOff(str); return; }
02970       case TableColSpan:            { tableCol.setSpan(value.toInteger(exec)); return; }
02971       case TableColVAlign:          { tableCol.setVAlign(str); return; }
02972       case TableColWidth:           { tableCol.setWidth(str); return; }
02973       }
02974     }
02975     break;
02976     case ID_THEAD:
02977     case ID_TBODY:
02978     case ID_TFOOT: {
02979       DOM::HTMLTableSectionElement tableSection = element;
02980       switch (token) {
02981       case TableSectionAlign:           { tableSection.setAlign(str); return; }
02982       case TableSectionCh:              { tableSection.setCh(str); return; }
02983       case TableSectionChOff:           { tableSection.setChOff(str); return; }
02984       case TableSectionVAlign:          { tableSection.setVAlign(str); return; }
02985       // read-only: rows
02986       }
02987     }
02988     break;
02989     case ID_TR: {
02990       DOM::HTMLTableRowElement tableRow = element;
02991       switch (token) {
02992       // read-only: rowIndex
02993       // read-only: sectionRowIndex
02994       // read-only: cells
02995       case TableRowAlign:           { tableRow.setAlign(str); return; }
02996       case TableRowBgColor:         { tableRow.setBgColor(str); return; }
02997       case TableRowCh:              { tableRow.setCh(str); return; }
02998       case TableRowChOff:           { tableRow.setChOff(str); return; }
02999       case TableRowVAlign:          { tableRow.setVAlign(str); return; }
03000       }
03001     }
03002     break;
03003     case ID_TH:
03004     case ID_TD: {
03005       DOM::HTMLTableCellElement tableCell = element;
03006       switch (token) {
03007       // read-only: cellIndex
03008       case TableCellAbbr:            { tableCell.setAbbr(str); return; }
03009       case TableCellAlign:           { tableCell.setAlign(str); return; }
03010       case TableCellAxis:            { tableCell.setAxis(str); return; }
03011       case TableCellBgColor:         { tableCell.setBgColor(str); return; }
03012       case TableCellCh:              { tableCell.setCh(str); return; }
03013       case TableCellChOff:           { tableCell.setChOff(str); return; }
03014       case TableCellColSpan:         { tableCell.setColSpan(value.toInteger(exec)); return; }
03015       case TableCellHeaders:         { tableCell.setHeaders(str); return; }
03016       case TableCellHeight:          { tableCell.setHeight(str); return; }
03017       case TableCellNoWrap:          { tableCell.setNoWrap(value.toBoolean(exec)); return; }
03018       case TableCellRowSpan:         { tableCell.setRowSpan(value.toInteger(exec)); return; }
03019       case TableCellScope:           { tableCell.setScope(str); return; }
03020       case TableCellVAlign:          { tableCell.setVAlign(str); return; }
03021       case TableCellWidth:           { tableCell.setWidth(str); return; }
03022       }
03023     }
03024     break;
03025     case ID_FRAMESET: {
03026       DOM::HTMLFrameSetElement frameSet = element;
03027       switch (token) {
03028       case FrameSetCols:            { frameSet.setCols(str); return; }
03029       case FrameSetRows:            { frameSet.setRows(str); return; }
03030       }
03031     }
03032     break;
03033     case ID_LAYER: {
03034       DOM::HTMLLayerElement layerElement = element;
03035       switch (token) {
03036       case LayerTop:                   { layerElement.setTop(value.toInteger(exec)); return; }
03037       case LayerLeft:                  { layerElement.setLeft(value.toInteger(exec)); return; }
03038       case LayerVisibility:            { layerElement.setVisibility(str); return; }
03039       case LayerBgColor:               { layerElement.setBgColor(str); return; }
03040       // read-only: layers, clip
03041       }
03042     }
03043     break;
03044     case ID_FRAME: {
03045       DOM::HTMLFrameElement frameElement = element;
03046       switch (token) {
03047        // read-only: FrameContentDocument:
03048       case FrameFrameBorder:     { frameElement.setFrameBorder(str); return; }
03049       case FrameLongDesc:        { frameElement.setLongDesc(str); return; }
03050       case FrameMarginHeight:    { frameElement.setMarginHeight(str); return; }
03051       case FrameMarginWidth:     { frameElement.setMarginWidth(str); return; }
03052       case FrameName:            { frameElement.setName(str); return; }
03053       case FrameNoResize:        { frameElement.setNoResize(value.toBoolean(exec)); return; }
03054       case FrameScrolling:       { frameElement.setScrolling(str); return; }
03055       case FrameSrc:             { frameElement.setSrc(str); return; }
03056       case FrameLocation:        {
03057                                    static_cast<DOM::HTMLFrameElementImpl *>(frameElement.handle())->setLocation(str);
03058                                    return;
03059                                  }
03060       }
03061     }
03062     break;
03063     case ID_IFRAME: {
03064       DOM::HTMLIFrameElement iFrame = element;
03065       switch (token) {
03066       case IFrameAlign:           { iFrame.setAlign(str); return; }
03067       // read-only: IFrameContentDocument
03068       case IFrameFrameBorder:     { iFrame.setFrameBorder(str); return; }
03069       case IFrameHeight:          { iFrame.setHeight(str); return; }
03070       case IFrameLongDesc:        { iFrame.setLongDesc(str); return; }
03071       case IFrameMarginHeight:    { iFrame.setMarginHeight(str); return; }
03072       case IFrameMarginWidth:     { iFrame.setMarginWidth(str); return; }
03073       case IFrameName:            { iFrame.setName(str); return; }
03074       case IFrameScrolling:       { iFrame.setScrolling(str); return; }
03075       case IFrameSrc:             { iFrame.setSrc(str); return; }
03076       case IFrameWidth:           { iFrame.setWidth(str); return; }
03077       }
03078       break;
03079     }
03080   }
03081 
03082   // generic properties
03083   switch (token) {
03084   case ElementId:
03085     element.setId(str);
03086     return;
03087   case ElementTitle:
03088     element.setTitle(str);
03089     return;
03090   case ElementLang:
03091     element.setLang(str);
03092     return;
03093   case ElementDir:
03094     element.setDir(str);
03095     return;
03096   case ElementClassName:
03097     element.setClassName(str);
03098     return;
03099   case ElementInnerHTML:
03100     element.setInnerHTML(str);
03101     return;
03102   case ElementInnerText:
03103     element.setInnerText(str);
03104     return;
03105   default:
03106     kdDebug(6070) << "WARNING: KJS::HTMLElement::putValueProperty unhandled token " << token << " thisTag=" << element.tagName().string() << " str=" << str.string() << endl;
03107   }
03108 }
03109 
03110 // -------------------------------------------------------------------------
03111 /* Source for HTMLCollectionProtoTable.
03112 @begin HTMLCollectionProtoTable 3
03113   item      HTMLCollection::Item        DontDelete|Function 1
03114   namedItem HTMLCollection::NamedItem   DontDelete|Function 1
03115   tags      HTMLCollection::Tags        DontDelete|Function 1
03116 @end
03117 */
03118 DEFINE_PROTOTYPE("HTMLCollection", HTMLCollectionProto)
03119 IMPLEMENT_PROTOFUNC_DOM(HTMLCollectionProtoFunc)
03120 IMPLEMENT_PROTOTYPE(HTMLCollectionProto,HTMLCollectionProtoFunc)
03121 
03122 const ClassInfo KJS::HTMLCollection::info = { "HTMLCollection", 0, 0, 0 };
03123 
03124 KJS::HTMLCollection::HTMLCollection(ExecState *exec, const DOM::HTMLCollection& c)
03125   : DOMObject(HTMLCollectionProto::self(exec)), collection(c), hidden(false) {}
03126 
03127 KJS::HTMLCollection::~HTMLCollection()
03128 {
03129   ScriptInterpreter::forgetDOMObject(collection.handle());
03130 }
03131 
03132 bool KJS::HTMLCollection::toBoolean(ExecState *) const {
03133     return !hidden;
03134 }
03135 
03136 // We have to implement hasProperty since we don't use a hashtable for 'selectedIndex' and 'length',
03137 // and for indices in "for (..in..)"
03138 bool KJS::HTMLCollection::hasProperty(ExecState *exec, const Identifier &p) const
03139 {
03140   if (p == lengthPropertyName)
03141     return true;
03142   if ( collection.handle()->getType() == HTMLCollectionImpl::SELECT_OPTIONS &&
03143        ( p == "selectedIndex" || p == "value" ) )
03144     return true;
03145 
03146   bool ok;
03147   unsigned long pos = p.toULong(&ok);
03148   if (ok && pos < collection.length())
03149     return true;
03150 
03151   return DOMObject::hasProperty(exec, p);
03152 }
03153 
03154 ReferenceList KJS::HTMLCollection::propList(ExecState *exec, bool recursive)
03155 {
03156   ReferenceList properties = ObjectImp::propList(exec,recursive);
03157 
03158   for (unsigned i = 0; i < collection.length(); ++i) {
03159     if (!ObjectImp::hasProperty(exec,Identifier::from(i))) {
03160       properties.append(Reference(this, i));
03161     }
03162   }
03163 
03164   if (!ObjectImp::hasProperty(exec, lengthPropertyName))
03165     properties.append(Reference(this, lengthPropertyName));
03166 
03167   return properties;
03168 }
03169 
03170 Value KJS::HTMLCollection::tryGet(ExecState *exec, const Identifier &propertyName) const
03171 {
03172 #ifdef KJS_VERBOSE
03173   kdDebug(6070) << "KJS::HTMLCollection::tryGet " << propertyName.ascii() << endl;
03174 #endif
03175   if (propertyName == lengthPropertyName)
03176   {
03177 #ifdef KJS_VERBOSE
03178     kdDebug(6070) << "  collection length is " << collection.length() << endl;
03179 #endif
03180     return Number(collection.length());
03181   }
03182 
03183   if (collection.handle()->getType() == HTMLCollectionImpl::SELECT_OPTIONS) {
03184     DOM::HTMLSelectElement parentSelect = collection.base();
03185     if ( parentSelect.isNull() )
03186       return Undefined();
03187     if (propertyName == "selectedIndex") {
03188       // NON-STANDARD options.selectedIndex
03189       return Number(parentSelect.selectedIndex());
03190     } else if ( propertyName == "value" ) {
03191       // NON-STANDARD options.value
03192       return String(parentSelect.value());
03193     }
03194   }
03195 
03196   // Look in the prototype (for functions) before assuming it's an item's name
03197   Object proto = Object::dynamicCast(prototype());
03198   if (proto.isValid() && proto.hasProperty(exec,propertyName))
03199     return proto.get(exec,propertyName);
03200 
03201   // name or index ?
03202   bool ok;
03203   unsigned int u = propertyName.toULong(&ok);
03204   if (ok) {
03205     if ( u < collection.length() ) {
03206       DOM::Node node = collection.item(u);
03207       return getDOMNode(exec,node);
03208     } else
03209       return Undefined();
03210   }
03211   else
03212     return getNamedItems(exec,propertyName);
03213 }
03214 
03215 // HTMLCollections are strange objects, they support both get and call,
03216 // so that document.forms.item(0) and document.forms(0) both work.
03217 Value KJS::HTMLCollection::call(ExecState *exec, Object &thisObj, const List &args)
03218 {
03219   // This code duplication is necessary, HTMLCollection isn't a DOMFunction
03220   Value val;
03221   try {
03222     val = tryCall(exec, thisObj, args);
03223   }
03224   // pity there's no way to distinguish between these in JS code
03225   catch (...) {
03226     Object err = Error::create(exec, GeneralError, "Exception from HTMLCollection");
03227     exec->setException(err);
03228   }
03229   return val;
03230 }
03231 
03232 Value KJS::HTMLCollection::tryCall(ExecState *exec, Object &, const List &args)
03233 {
03234   // Do not use thisObj here. It can be the HTMLDocument, in the document.forms(i) case.
03235   /*if( thisObj.imp() != this )
03236   {
03237     kdDebug(6070) << "WARNING: thisObj.imp() != this in HTMLCollection::tryCall" << endl;
03238     KJS::printInfo(exec,"KJS::HTMLCollection::tryCall thisObj",thisObj,-1);
03239     KJS::printInfo(exec,"KJS::HTMLCollection::tryCall this",Value(this),-1);
03240   }*/
03241   // Also, do we need the TypeError test here ?
03242 
03243   if (args.size() == 1) {
03244     // support for document.all(<index>) etc.
03245     bool ok;
03246     UString s = args[0].toString(exec);
03247     unsigned int u = s.toULong(&ok);
03248     if (ok) {
03249       DOM::Element element = collection.item(u);
03250       return getDOMNode(exec,element);
03251     }
03252     // support for document.images('<name>') etc.
03253     return getNamedItems(exec,Identifier(s));
03254   }
03255   else if (args.size() >= 1) // the second arg, if set, is the index of the item we want
03256   {
03257     bool ok;
03258     UString s = args[0].toString(exec);
03259     unsigned int u = args[1].toString(exec).toULong(&ok);
03260     if (ok)
03261     {
03262       DOM::DOMString pstr = s.string();
03263       DOM::Node node = collection.namedItem(pstr);
03264       while (!node.isNull()) {
03265         if (!u)
03266           return getDOMNode(exec,node);
03267         node = collection.nextNamedItem(pstr);
03268         --u;
03269       }
03270     }
03271   }
03272   return Undefined();
03273 }
03274 
03275 Value KJS::HTMLCollection::getNamedItems(ExecState *exec, const Identifier &propertyName) const
03276 {
03277 #ifdef KJS_VERBOSE
03278   kdDebug(6070) << "KJS::HTMLCollection::getNamedItems " << propertyName.ascii() << endl;
03279 #endif
03280 
03281   DOM::DOMString pstr = propertyName.string();
03282 
03283   QValueList<DOM::NodeImpl*> matches = collection.handle()->namedItems(pstr);
03284 
03285   if (!matches.isEmpty()) {
03286     if (matches.size() == 1) {
03287       DOM::Node node(matches[0]);
03288 #ifdef KJS_VERBOSE
03289       kdDebug(6070) << "returning single node" << endl;
03290 #endif
03291       return getDOMNode(exec,node);
03292     }
03293     else  {
03294       // multiple items, return a collection
03295       QValueList<DOM::Node> nodes;
03296       for (QValueList<DOM::NodeImpl*>::const_iterator i =  matches.begin();
03297                                                       i != matches.end(); ++i)
03298            nodes.append(DOM::Node(*i));
03299 #ifdef KJS_VERBOSE
03300       kdDebug(6070) << "returning list of " << nodes.count() << " nodes" << endl;
03301 #endif
03302       return Value(new DOMNamedNodesCollection(exec, nodes));
03303     }
03304   }
03305 #ifdef KJS_VERBOSE
03306   kdDebug(6070) << "not found" << endl;
03307 #endif
03308   return Undefined();
03309 }
03310 
03311 Value KJS::HTMLCollectionProtoFunc::tryCall(ExecState *exec, Object &thisObj, const List &args)
03312 {
03313   KJS_CHECK_THIS( KJS::HTMLCollection, thisObj );
03314   DOM::HTMLCollection coll = static_cast<KJS::HTMLCollection *>(thisObj.imp())->toCollection();
03315 
03316   switch (id) {
03317   case KJS::HTMLCollection::Item:
03318   {
03319     // support for item(<index>) (DOM)
03320     bool ok;
03321     UString s = args[0].toString(exec);
03322     unsigned int u = s.toULong(&ok);
03323     if (ok) {
03324       return getDOMNode(exec,coll.item(u));
03325     }
03326     // support for item('<name>') (IE only)
03327     kdWarning() << "non-standard HTMLCollection.item('" << s.ascii() << "') called, use namedItem instead" << endl;
03328     return getDOMNode(exec,coll.namedItem(s.string()));
03329   }
03330   case KJS::HTMLCollection::Tags:
03331   {
03332     DOM::DOMString tagName = args[0].toString(exec).string();
03333     DOM::NodeList list;
03334     // getElementsByTagName exists in Document and in Element, pick up the right one
03335     if ( coll.base().nodeType() == DOM::Node::DOCUMENT_NODE )
03336     {
03337       DOM::Document doc = coll.base();
03338       list = doc.getElementsByTagName(tagName);
03339 #ifdef KJS_VERBOSE
03340       kdDebug(6070) << "KJS::HTMLCollectionProtoFunc::tryCall document.tags(" << tagName.string() << ") -> " << list.length() << " items in node list" << endl;
03341 #endif
03342     } else
03343     {
03344       DOM::Element e = coll.base();
03345       list = e.getElementsByTagName(tagName);
03346 #ifdef KJS_VERBOSE
03347       kdDebug(6070) << "KJS::HTMLCollectionProtoFunc::tryCall element.tags(" << tagName.string() << ") -> " << list.length() << " items in node list" << endl;
03348 #endif
03349     }
03350     return getDOMNodeList(exec, list);
03351   }
03352   case KJS::HTMLCollection::NamedItem:
03353   {
03354     Value val = static_cast<HTMLCollection *>(thisObj.imp())->getNamedItems(exec, Identifier(args[0].toString(exec)));
03355     // Must return null when asking for a named item that isn't in the collection
03356     // (DOM2 testsuite, HTMLCollection12 test)
03357     if ( val.type() == KJS::UndefinedType )
03358       return Null();
03359     else
03360       return val;
03361   }
03362   default:
03363     return Undefined();
03364   }
03365 }
03366 
03367 Value KJS::HTMLSelectCollection::tryGet(ExecState *exec, const Identifier &p) const
03368 {
03369   if (p == "selectedIndex")
03370     return Number(element.selectedIndex());
03371 
03372   return  HTMLCollection::tryGet(exec, p);
03373 }
03374 
03375 void KJS::HTMLSelectCollection::tryPut(ExecState *exec, const Identifier &propertyName, const Value& value, int)
03376 {
03377 #ifdef KJS_VERBOSE
03378   kdDebug(6070) << "KJS::HTMLSelectCollection::tryPut " << propertyName.qstring() << endl;
03379 #endif
03380   if ( propertyName == "selectedIndex" ) {
03381     element.setSelectedIndex( value.toInteger( exec ) );
03382     return;
03383   }
03384   // resize ?
03385   else if (propertyName == lengthPropertyName) {
03386     unsigned newLen;
03387     bool converted = value.toUInt32(newLen);
03388 
03389     if (!converted) {
03390       return;
03391     }
03392 
03393     long diff = element.length() - newLen;
03394 
03395     if (diff < 0) { // add dummy elements
03396       do {
03397         element.add(element.ownerDocument().createElement("OPTION"), DOM::HTMLElement());
03398       } while (++diff);
03399     }
03400     else // remove elements
03401       while (diff-- > 0)
03402         element.remove(newLen + diff);
03403 
03404     return;
03405   }
03406   // an index ?
03407   bool ok;
03408   unsigned int u = propertyName.toULong(&ok);
03409   if (!ok)
03410     return;
03411 
03412   if (value.isA(NullType) || value.isA(UndefinedType)) {
03413     // null and undefined delete. others, too ?
03414     element.remove(u);
03415     return;
03416   }
03417 
03418   // is v an option element ?
03419   DOM::Node node = KJS::toNode(value);
03420   if (node.isNull() || node.elementId() != ID_OPTION)
03421     return;
03422 
03423   DOM::HTMLOptionElement option = static_cast<DOM::HTMLOptionElement>(node);
03424   if ( option.ownerDocument() != element.ownerDocument() )
03425     option = static_cast<DOM::HTMLOptionElement>(element.ownerDocument().importNode(option, true));
03426   long diff = long(u) - element.length();
03427   DOM::HTMLElement before;
03428   // out of array bounds ? first insert empty dummies
03429   if (diff > 0) {
03430     while (diff--) {
03431       element.add(element.ownerDocument().createElement("OPTION"), before);
03432     }
03433     // replace an existing entry ?
03434   } else if (diff < 0) {
03435     before = element.options().item(u+1);
03436     element.remove(u);
03437   }
03438   // finally add the new element
03439   element.add(option, before);
03440 }
03441 
03443 
03444 OptionConstructorImp::OptionConstructorImp(ExecState *exec, const DOM::Document &d)
03445     : ObjectImp(), doc(d)
03446 {
03447   // ## isn't there some redundancy between ObjectImp::_proto and the "prototype" property ?
03448   //put(exec,"prototype", ...,DontEnum|DontDelete|ReadOnly);
03449 
03450   // no. of arguments for constructor
03451   // ## is 4 correct ? 0 to 4, it seems to be
03452   put(exec,lengthPropertyName, Number(4), ReadOnly|DontDelete|DontEnum);
03453 }
03454 
03455 bool OptionConstructorImp::implementsConstruct() const
03456 {
03457   return true;
03458 }
03459 
03460 Object OptionConstructorImp::construct(ExecState *exec, const List &args)
03461 {
03462   DOM::Element el = doc.createElement("OPTION");
03463   DOM::HTMLOptionElement opt = static_cast<DOM::HTMLOptionElement>(el);
03464   int sz = args.size();
03465   DOM::Text t = doc.createTextNode("");
03466   try { opt.appendChild(t); }
03467   catch(DOM::DOMException& e) {
03468     // #### exec->setException ?
03469   }
03470   if (sz > 0)
03471     t.setData(args[0].toString(exec).string()); // set the text
03472   if (sz > 1)
03473     opt.setValue(args[1].toString(exec).string());
03474   if (sz > 2)
03475     opt.setDefaultSelected(args[2].toBoolean(exec));
03476   if (sz > 3)
03477     opt.setSelected(args[3].toBoolean(exec));
03478 
03479   return Object::dynamicCast(getDOMNode(exec,opt));
03480 }
03481 
03483 
03484 //Like in other browsers, we merely make a new HTMLImageElement
03485 //not in tree for this.
03486 ImageConstructorImp::ImageConstructorImp(ExecState *, const DOM::Document &d)
03487     : ObjectImp(), doc(d)
03488 {
03489 }
03490 
03491 bool ImageConstructorImp::implementsConstruct() const
03492 {
03493   return true;
03494 }
03495 
03496 Object ImageConstructorImp::construct(ExecState *exec, const List &list)
03497 {
03498   bool widthSet = false, heightSet = false;
03499   int width = 0, height = 0;
03500   if (list.size() > 0) {
03501     widthSet = true;
03502     Value w = list.at(0);
03503     width = w.toInt32(exec);
03504   }
03505   if (list.size() > 1) {
03506     heightSet = true;
03507     Value h = list.at(1);
03508     height = h.toInt32(exec);
03509   }
03510 
03511   HTMLImageElement image(doc.createElement("image"));
03512 
03513   if (widthSet)
03514     image.setWidth(width);
03515 
03516   if (heightSet)
03517     image.setHeight(height);
03518 
03519   return Object::dynamicCast(getDOMNode(exec,image));
03520 }
03521 
03522 Value KJS::getHTMLCollection(ExecState *exec, const DOM::HTMLCollection& c, bool hide)
03523 {
03524   Value coll = cacheDOMObject<DOM::HTMLCollection, KJS::HTMLCollection>(exec, c);
03525   if (hide) {
03526     KJS::HTMLCollection *impl = static_cast<KJS::HTMLCollection*>(coll.imp());
03527     impl->hide();
03528   }
03529   return coll;
03530 }
03531 
03532 Value KJS::getSelectHTMLCollection(ExecState *exec, const DOM::HTMLCollection& c, const DOM::HTMLSelectElement& e)
03533 {
03534   DOMObject *ret;
03535   if (c.isNull())
03536     return Null();
03537   ScriptInterpreter* interp = static_cast<ScriptInterpreter *>(exec->interpreter());
03538   if ((ret = interp->getDOMObject(c.handle())))
03539     return Value(ret);
03540   else {
03541     ret = new HTMLSelectCollection(exec, c, e);
03542     interp->putDOMObject(c.handle(),ret);
03543     return Value(ret);
03544   }
03545 }
KDE Home | KDE Accessibility Home | Description of Access Keys