kjs_html.cpp 141 KB
Newer Older
George Staikos's avatar
George Staikos committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
// -*- c-basic-offset: 2 -*-
/*
 *  This file is part of the KDE libraries
 *  Copyright (C) 1999-2002 Harri Porten (porten@kde.org)
 *  Copyright (C) 2001-2003 David Faure (faure@kde.org)
 *  Copyright (C) 2004 Apple Computer, Inc.
 *  Copyright (C) 2005 Maksim Orlovich (maksim@kde.org)
 *
 *  This library is free software; you can redistribute it and/or
 *  modify it under the terms of the GNU Library General Public
 *  License as published by the Free Software Foundation; either
 *  version 2 of the License, or (at your option) any later version.
 *
 *  This library is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 *  Library General Public License for more details.
 *
 *  You should have received a copy of the GNU Library General Public
 *  License along with this library; if not, write to the Free Software
 *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
 */

Alex Merry's avatar
Alex Merry committed
24 25 26 27 28 29 30 31 32 33 34 35 36
#include "kjs_html.h"
#include "kjs_html.lut.h"

#include <misc/loader.h>
#include <html/html_blockimpl.h>
#include <html/html_headimpl.h>
#include <html/html_imageimpl.h>
#include <html/html_inlineimpl.h>
#include <html/html_listimpl.h>
#include <html/html_tableimpl.h>
#include <html/html_objectimpl.h>
#include <html/html_canvasimpl.h>
#include <dom/dom_exception.h>
George Staikos's avatar
George Staikos committed
37

Alex Merry's avatar
Alex Merry committed
38 39 40 41 42
#include <html/html_baseimpl.h>
#include <html/html_documentimpl.h>
#include <html/html_formimpl.h>
#include <html/html_miscimpl.h>
#include <xml/dom2_eventsimpl.h>
George Staikos's avatar
George Staikos committed
43 44 45

#include <kparts/browserextension.h>

Alex Merry's avatar
Alex Merry committed
46 47
#include <khtml_part.h>
#include <khtmlview.h>
George Staikos's avatar
George Staikos committed
48

Alex Merry's avatar
Alex Merry committed
49 50 51 52
#include "kjs_css.h"
#include "kjs_events.h"
#include "kjs_window.h"
#include "kjs_context2d.h"
53
#include <kjs/PropertyNameArray.h>
George Staikos's avatar
George Staikos committed
54

Alex Merry's avatar
Alex Merry committed
55 56 57 58
#include <rendering/render_object.h>
#include <rendering/render_canvas.h>
#include <rendering/render_frames.h>
#include <rendering/render_layer.h>
George Staikos's avatar
George Staikos committed
59

Alex Merry's avatar
Alex Merry committed
60
#include <kmessagebox.h>
George Staikos's avatar
George Staikos committed
61 62 63 64
#include <kstringhandler.h>
#include <klocale.h>

#include <kdebug.h>
Dirk Mueller's avatar
Dirk Mueller committed
65 66
#include <QtCore/QList>
#include <QtCore/QHash>
George Staikos's avatar
George Staikos committed
67

68 69
using namespace DOM;

George Staikos's avatar
George Staikos committed
70 71
namespace KJS {

Maks Orlovich's avatar
Maks Orlovich committed
72
KJS_DEFINE_PROTOTYPE(HTMLDocumentProto)
73
KJS_IMPLEMENT_PROTOFUNC(HTMLDocFunction)
Maks Orlovich's avatar
Maks Orlovich committed
74
KJS_IMPLEMENT_PROTOTYPE("HTMLDocument", HTMLDocumentProto, HTMLDocFunction, DOMDocumentProto)
75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91

IMPLEMENT_PSEUDO_CONSTRUCTOR(HTMLDocumentPseudoCtor, "HTMLDocument", HTMLDocumentProto)

/* Source for HTMLDocumentProtoTable.
@begin HTMLDocumentProtoTable 11
  clear         HTMLDocument::Clear     DontDelete|Function 0
  open          HTMLDocument::Open      DontDelete|Function 0
  close         HTMLDocument::Close     DontDelete|Function 0
  write         HTMLDocument::Write     DontDelete|Function 1
  writeln       HTMLDocument::WriteLn       DontDelete|Function 1
  getElementsByName HTMLDocument::GetElementsByName DontDelete|Function 1
  getSelection  HTMLDocument::GetSelection  DontDelete|Function 1
  captureEvents     HTMLDocument::CaptureEvents DontDelete|Function 0
  releaseEvents     HTMLDocument::ReleaseEvents DontDelete|Function 0
@end
*/

George Staikos's avatar
George Staikos committed
92

Harri Porten's avatar
Harri Porten committed
93
JSValue* KJS::HTMLDocFunction::callAsFunction(ExecState *exec, JSObject *thisObj, const List &args)
George Staikos's avatar
George Staikos committed
94 95 96 97 98 99 100 101
{
  KJS_CHECK_THIS( HTMLDocument, thisObj );

  DOM::HTMLDocumentImpl& doc = *static_cast<KJS::HTMLDocument *>(thisObj)->impl();

  switch (id) {
  case HTMLDocument::Clear: // even IE doesn't support that one...
    //doc.clear(); // TODO
Harri Porten's avatar
Harri Porten committed
102
    return jsUndefined();
George Staikos's avatar
George Staikos committed
103 104 105
  case HTMLDocument::Open:
    if (args.size() >= 3) // IE extension for document.open: it means window.open if it has 3 args or more
    {
106 107 108
      KHTMLPart* part = doc.part();
      if ( part ) {
        Window* win = Window::retrieveWindow(part);
George Staikos's avatar
George Staikos committed
109 110 111 112 113 114 115
        if( win ) {
          win->openWindow(exec, args);
        }
      }
    }

    doc.open();
Harri Porten's avatar
Harri Porten committed
116
    return jsUndefined();
George Staikos's avatar
George Staikos committed
117 118 119
  case HTMLDocument::Close:
    // see khtmltests/ecma/tokenizer-script-recursion.html
    doc.close();
Harri Porten's avatar
Harri Porten committed
120
    return jsUndefined();
George Staikos's avatar
George Staikos committed
121 122 123 124 125 126 127 128
  case HTMLDocument::Write:
  case HTMLDocument::WriteLn: {
    // DOM only specifies single string argument, but NS & IE allow multiple
    // or no arguments
    UString str = "";
    for (int i = 0; i < args.size(); i++)
      str += args[i]->toString(exec);
    if (id == HTMLDocument::WriteLn)
129
      str += "\n";
George Staikos's avatar
George Staikos committed
130
#ifdef KJS_VERBOSE
Laurent Montel's avatar
Laurent Montel committed
131
    kDebug(6070) << "document.write: " << str.qstring();
George Staikos's avatar
George Staikos committed
132 133
#endif
    doc.write(str.qstring());
Harri Porten's avatar
Harri Porten committed
134
    return jsUndefined();
George Staikos's avatar
George Staikos committed
135 136 137 138 139 140
  }
  case HTMLDocument::GetElementsByName:
    return getDOMNodeList(exec,doc.getElementsByName(args[0]->toString(exec).domString()));
  case HTMLDocument::GetSelection: {
    // NS4 and Mozilla specific. IE uses document.selection.createRange()
    // http://docs.sun.com/source/816-6408-10/document.htm#1195981
141 142 143
    KHTMLPart *part = doc.part();
    if ( part )
       return jsString(part->selectedText());
George Staikos's avatar
George Staikos committed
144
    else
Harri Porten's avatar
Harri Porten committed
145
       return jsUndefined();
George Staikos's avatar
George Staikos committed
146 147 148 149 150 151 152
  }
  case HTMLDocument::CaptureEvents:
  case HTMLDocument::ReleaseEvents:
    // Do nothing for now. These are NS-specific legacy calls.
    break;
  }

Harri Porten's avatar
Harri Porten committed
153
  return jsUndefined();
George Staikos's avatar
George Staikos committed
154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182
}

const ClassInfo KJS::HTMLDocument::info =
  { "HTMLDocument", &DOMDocument::info, &HTMLDocumentTable, 0 };
/* Source for HTMLDocumentTable.
@begin HTMLDocumentTable 31
  referrer		HTMLDocument::Referrer		DontDelete|ReadOnly
  domain		HTMLDocument::Domain		DontDelete
  URL			HTMLDocument::URL		DontDelete|ReadOnly
  body			HTMLDocument::Body		DontDelete
  location		HTMLDocument::Location		DontDelete
  cookie		HTMLDocument::Cookie		DontDelete
  images		HTMLDocument::Images		DontDelete|ReadOnly
  applets		HTMLDocument::Applets		DontDelete|ReadOnly
  links			HTMLDocument::Links		DontDelete|ReadOnly
  forms			HTMLDocument::Forms		DontDelete|ReadOnly
  anchors		HTMLDocument::Anchors		DontDelete|ReadOnly
  scripts		HTMLDocument::Scripts		DontDelete|ReadOnly
  all			HTMLDocument::All		DontDelete|ReadOnly
  bgColor		HTMLDocument::BgColor		DontDelete
  fgColor		HTMLDocument::FgColor		DontDelete
  alinkColor		HTMLDocument::AlinkColor	DontDelete
  linkColor		HTMLDocument::LinkColor		DontDelete
  vlinkColor		HTMLDocument::VlinkColor	DontDelete
  lastModified		HTMLDocument::LastModified	DontDelete|ReadOnly
  height		HTMLDocument::Height		DontDelete|ReadOnly
  width			HTMLDocument::Width		DontDelete|ReadOnly
  dir			HTMLDocument::Dir		DontDelete
  compatMode		HTMLDocument::CompatMode	DontDelete|ReadOnly
183
  designMode            HTMLDocument::DesignMode        DontDelete
George Staikos's avatar
George Staikos committed
184 185 186 187
#IE extension
  frames		HTMLDocument::Frames		DontDelete|ReadOnly
#NS4 extension
  layers		HTMLDocument::Layers		DontDelete|ReadOnly
188 189
# HTML5
  activeElement         HTMLDocument::ActiveElement     DontDelete|ReadOnly
George Staikos's avatar
George Staikos committed
190 191 192 193 194 195 196 197 198 199
#potentially obsolete array properties
# plugins
# tags
#potentially obsolete properties
# embeds
# ids
@end
*/

KJS::HTMLDocument::HTMLDocument(ExecState *exec, DOM::HTMLDocumentImpl* d)
200
  : DOMDocument(HTMLDocumentProto::self(exec), d) { }
George Staikos's avatar
George Staikos committed
201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224

/* Should this property be checked after overrides? */
static bool isLateProperty(unsigned token)
{
  switch (token) {
    case HTMLDocument::BgColor:
    case HTMLDocument::FgColor:
    case HTMLDocument::AlinkColor:
    case HTMLDocument::LinkColor:
    case HTMLDocument::VlinkColor:
    case HTMLDocument::LastModified:
    case HTMLDocument::Height: // NS-only, not available in IE
    case HTMLDocument::Width: // NS-only, not available in IE
    case HTMLDocument::Dir:
    case HTMLDocument::Frames:
      return true;
    default:
      return false;
  }
}

bool KJS::HTMLDocument::getOwnPropertySlot(ExecState *exec, const Identifier &propertyName, PropertySlot& slot)
{
#ifdef KJS_VERBOSE
Laurent Montel's avatar
Laurent Montel committed
225
  kDebug(6070) << "KJS::HTMLDocument::getOwnPropertySlot " << propertyName.qstring();
George Staikos's avatar
George Staikos committed
226 227 228
#endif

  DOM::DocumentImpl* docImpl = impl();
229
  KHTMLPart *part = docImpl->part();
George Staikos's avatar
George Staikos committed
230

231
  Window* win = part ? Window::retrieveWindow(part) : 0L;
George Staikos's avatar
George Staikos committed
232 233 234 235 236
  if ( !win || !win->isSafeScript(exec) ) {
    slot.setUndefined(this);
    return true;
  }

Maks Orlovich's avatar
Maks Orlovich committed
237
  DOM::DOMString  propertyDOMString = propertyName.domString();
George Staikos's avatar
George Staikos committed
238 239

  //See whether to return named items under document.
Maks Orlovich's avatar
Maks Orlovich committed
240
  ElementMappingCache::ItemInfo* info = docImpl->underDocNamedCache().get(propertyDOMString);
George Staikos's avatar
George Staikos committed
241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262
  if (info) {
    //May be a false positive, but we can try to avoid doing it the hard way in
    //simpler cases. The trickiness here is that the cache is kept under both
    //name and id, but we sometimes ignore id for IE compat

    bool matched = false;
    if (info->nd && DOM::HTMLMappedNameCollectionImpl::matchesName(info->nd,
                              HTMLCollectionImpl::DOCUMENT_NAMED_ITEMS, propertyDOMString)) {
        matched = true;
    } else {
        //Can't tell it just like that, so better go through collection and count stuff. This is the slow path...
        DOM::HTMLMappedNameCollectionImpl coll(impl(), HTMLCollectionImpl::DOCUMENT_NAMED_ITEMS, propertyDOMString);
        matched = coll.firstItem() != 0;
    }

    if (matched) {
        slot.setCustom(this, nameGetter);
        return true;
    }
  }

  // Check for frames/iframes with name==propertyName
263
  if ( part ) {
Maks Orlovich's avatar
Maks Orlovich committed
264
    if (part->findFrame( propertyName.qstring() )) {
George Staikos's avatar
George Staikos committed
265 266 267 268 269 270 271 272 273 274 275 276 277
      slot.setCustom(this, frameNameGetter);
      return true;
    }
  }

  // Static properties
  const HashEntry* entry = Lookup::findEntry(&HTMLDocumentTable, propertyName);
  if (entry && !isLateProperty(entry->value)) {
    getSlotFromEntry<HTMLDocFunction, HTMLDocument>(entry, this, slot);
    return true;
  }

  // Look for overrides
Harri Porten's avatar
Harri Porten committed
278
  JSValue **val = getDirectLocation(propertyName);
George Staikos's avatar
George Staikos committed
279
  if (val) {
Harri Porten's avatar
Harri Porten committed
280
    fillDirectLocationSlot(slot, val);
George Staikos's avatar
George Staikos committed
281 282 283 284 285 286 287 288 289 290 291 292
    return true;
  }

  // The rest of static properties -- the late ones.
  if (entry) {
    getSlotFromEntry<HTMLDocFunction, HTMLDocument>(entry, this, slot);
    return true;
  }

  return DOMDocument::getOwnPropertySlot(exec, propertyName, slot);
}

Harri Porten's avatar
Harri Porten committed
293
JSValue *HTMLDocument::nameGetter(ExecState *exec, JSObject*, const Identifier& propertyName, const PropertySlot& slot)
George Staikos's avatar
George Staikos committed
294 295 296 297 298
{
  HTMLDocument *thisObj = static_cast<HTMLDocument*>(slot.slotBase());
  DOM::DocumentImpl* docImpl = thisObj->impl();

  //Return named items under document (e.g. images, applets, etc.)
Maks Orlovich's avatar
Maks Orlovich committed
299 300
  DOMString name = propertyName.domString();
  ElementMappingCache::ItemInfo* info = docImpl->underDocNamedCache().get(name);
301
  if (info && info->nd)
George Staikos's avatar
George Staikos committed
302 303 304 305
    return getDOMNode(exec, info->nd);
  else {
    //No cached mapping, do it the hard way..
    DOM::HTMLMappedNameCollectionImpl* coll = new DOM::HTMLMappedNameCollectionImpl(docImpl,
Maks Orlovich's avatar
Maks Orlovich committed
306
                                        HTMLCollectionImpl::DOCUMENT_NAMED_ITEMS, name);
George Staikos's avatar
George Staikos committed
307

308
    if (info && coll->length() == 1) {
George Staikos's avatar
George Staikos committed
309 310 311 312 313 314 315 316 317
        info->nd = static_cast<DOM::ElementImpl*>(coll->firstItem());
        delete coll;
        return getDOMNode(exec, info->nd);
    }

    return getHTMLCollection(exec, coll);
  }

  assert(0);
Harri Porten's avatar
Harri Porten committed
318
  return jsUndefined();
George Staikos's avatar
George Staikos committed
319 320
}

Harri Porten's avatar
Harri Porten committed
321
JSValue *HTMLDocument::frameNameGetter(ExecState*, JSObject*, const Identifier& name, const PropertySlot& slot)
George Staikos's avatar
George Staikos committed
322 323 324
{
  HTMLDocument *thisObj = static_cast<HTMLDocument*>(slot.slotBase());
  // Check for frames/iframes with name==propertyName
325
  return Window::retrieve(thisObj->impl()->part()->findFrame( name.qstring() ));
George Staikos's avatar
George Staikos committed
326 327
}

Harri Porten's avatar
Harri Porten committed
328
JSValue *HTMLDocument::objectNameGetter(ExecState *exec, JSObject*, const Identifier& name, const PropertySlot& slot)
George Staikos's avatar
George Staikos committed
329 330 331 332 333 334
{
  HTMLDocument *thisObj = static_cast<HTMLDocument*>(slot.slotBase());
  DOM::HTMLCollectionImpl objectLike(thisObj->impl(), DOM::HTMLCollectionImpl::DOC_APPLETS);
  return getDOMNode(exec, objectLike.namedItem(name.domString()));
}

Harri Porten's avatar
Harri Porten committed
335
JSValue *HTMLDocument::layerNameGetter(ExecState *exec, JSObject*, const Identifier& name, const PropertySlot& slot)
George Staikos's avatar
George Staikos committed
336 337 338 339 340 341
{
  HTMLDocument *thisObj = static_cast<HTMLDocument*>(slot.slotBase());
  DOM::HTMLCollectionImpl layerLike(thisObj->impl(), DOM::HTMLCollectionImpl::DOC_LAYERS);
  return getDOMNode(exec, layerLike.namedItem(name.domString()));
}

Harri Porten's avatar
Harri Porten committed
342
JSValue* HTMLDocument::getValueProperty(ExecState *exec, int token)
George Staikos's avatar
George Staikos committed
343 344
{
  DOM::HTMLDocumentImpl& doc = *impl();
345 346 347
  KHTMLView* view = doc.view();
  KHTMLPart* part = doc.part();
  Window* win = part ? Window::retrieveWindow(part) : 0L;
George Staikos's avatar
George Staikos committed
348 349 350 351
  DOM::HTMLElementImpl* body = doc.body();

  switch (token) {
    case Referrer:
Harri Porten's avatar
Harri Porten committed
352
      return jsString(doc.referrer());
George Staikos's avatar
George Staikos committed
353
    case Domain:
Harri Porten's avatar
Harri Porten committed
354
      return jsString(doc.domain());
George Staikos's avatar
George Staikos committed
355
    case URL:
Harri Porten's avatar
Harri Porten committed
356
      return jsString(doc.URL().url());
George Staikos's avatar
George Staikos committed
357 358 359 360 361 362
    case Body:
      return getDOMNode(exec,doc.body());
    case Location:
      if (win)
        return win->location();
      else
Harri Porten's avatar
Harri Porten committed
363
        return jsUndefined();
George Staikos's avatar
George Staikos committed
364
    case Cookie:
Harri Porten's avatar
Harri Porten committed
365
      return jsString(doc.cookie());
George Staikos's avatar
George Staikos committed
366 367 368 369 370 371 372 373 374 375 376 377 378
    case Images:
      return getHTMLCollection(exec,doc.images());
    case Applets:
      return getHTMLCollection(exec,doc.applets());
    case Links:
      return getHTMLCollection(exec,doc.links());
    case Forms:
      return getHTMLCollection(exec,doc.forms());
    case Layers:
      // ### Should not be hidden when we emulate Netscape4
      return getHTMLCollection(exec,doc.layers(), true);
    case Anchors:
      return getHTMLCollection(exec,doc.anchors());
379 380
    case Scripts:
      return getHTMLCollection(exec,doc.scripts());
George Staikos's avatar
George Staikos committed
381
    case All:
382
      if ( exec->dynamicInterpreter()->compatMode() == Interpreter::IECompat )
George Staikos's avatar
George Staikos committed
383 384 385 386
        return getHTMLCollection(exec,doc.all());
      else // enabled but hidden
        return getHTMLCollection(exec,doc.all(), true);
    case CompatMode:
Harri Porten's avatar
Harri Porten committed
387
      return jsString(doc.parseMode()
George Staikos's avatar
George Staikos committed
388
              == DocumentImpl::Compat ? "BackCompat" : "CSS1Compat");
389 390
    case DesignMode:
        return jsString((doc.designMode() ? "on":"off"));
391 392
    case ActiveElement:
	return getDOMNode(exec, doc.activeElement());
George Staikos's avatar
George Staikos committed
393
    case BgColor:
Maks Orlovich's avatar
Maks Orlovich committed
394
      return jsString(body ? body->getAttribute(ATTR_BGCOLOR) : DOMString());
George Staikos's avatar
George Staikos committed
395
    case FgColor:
Maks Orlovich's avatar
Maks Orlovich committed
396
      return jsString(body ? body->getAttribute(ATTR_TEXT) : DOMString());
George Staikos's avatar
George Staikos committed
397
    case AlinkColor:
Maks Orlovich's avatar
Maks Orlovich committed
398
      return jsString(body ? body->getAttribute(ATTR_ALINK) : DOMString());
George Staikos's avatar
George Staikos committed
399
    case LinkColor:
Maks Orlovich's avatar
Maks Orlovich committed
400
      return jsString(body ? body->getAttribute(ATTR_LINK) : DOMString());
George Staikos's avatar
George Staikos committed
401
    case VlinkColor:
Maks Orlovich's avatar
Maks Orlovich committed
402
      return jsString(body ? body->getAttribute(ATTR_VLINK) : DOMString());
George Staikos's avatar
George Staikos committed
403
    case LastModified:
Harri Porten's avatar
Harri Porten committed
404
      return jsString(doc.lastModified());
George Staikos's avatar
George Staikos committed
405
    case Height: // NS-only, not available in IE
Harri Porten's avatar
Harri Porten committed
406
      return jsNumber(view ? view->contentsHeight() : 0);
George Staikos's avatar
George Staikos committed
407
    case Width: // NS-only, not available in IE
Harri Porten's avatar
Harri Porten committed
408
      return jsNumber(view ? view->contentsWidth() : 0);
George Staikos's avatar
George Staikos committed
409
    case Dir:
David Faure's avatar
David Faure committed
410
      return body ? jsString(body->getAttribute(ATTR_DIR)) : jsUndefined();
George Staikos's avatar
George Staikos committed
411 412
    case Frames:
      if ( win )
Maks Orlovich's avatar
Maks Orlovich committed
413
        return win;
George Staikos's avatar
George Staikos committed
414
      else
Harri Porten's avatar
Harri Porten committed
415
        return jsUndefined();
George Staikos's avatar
George Staikos committed
416 417
  }
  assert(0);
Jarosław Staniek's avatar
Jarosław Staniek committed
418
  return 0;
George Staikos's avatar
George Staikos committed
419 420
}

Harri Porten's avatar
Harri Porten committed
421
void KJS::HTMLDocument::put(ExecState *exec, const Identifier &propertyName, JSValue *value, int attr)
George Staikos's avatar
George Staikos committed
422 423
{
#ifdef KJS_VERBOSE
Laurent Montel's avatar
Laurent Montel committed
424
  kDebug(6070) << "KJS::HTMLDocument::out " << propertyName.qstring();
George Staikos's avatar
George Staikos committed
425
#endif
426 427
  KHTMLPart* part = impl()->part();
  Window* win = part ? Window::retrieveWindow(part) : 0L;
George Staikos's avatar
George Staikos committed
428 429 430 431 432 433
  if ( !win || !win->isSafeScript(exec) )
    return;

  lookupPut<HTMLDocument, DOMDocument>( exec, propertyName, value, attr, &HTMLDocumentTable, this );
}

Harri Porten's avatar
Harri Porten committed
434
void KJS::HTMLDocument::putValueProperty(ExecState *exec, int token, JSValue *value, int /*attr*/)
George Staikos's avatar
George Staikos committed
435 436 437 438 439 440 441 442
{
  DOM::HTMLDocumentImpl& doc = *impl();
  DOM::DOMString val = value->toString(exec).domString();
  DOMExceptionTranslator exception(exec);

  switch (token) {
    case Body: {
      DOM::NodeImpl* body = toNode(value);
Maks Orlovich's avatar
Maks Orlovich committed
443
      if (body && body->isHTMLElement())
George Staikos's avatar
George Staikos committed
444
        doc.setBody(static_cast<DOM::HTMLElementImpl*>(body), exception);
445
      return;
George Staikos's avatar
George Staikos committed
446 447 448
    }
    case Domain: { // not part of the DOM
      doc.setDomain(val);
449
      return;
George Staikos's avatar
George Staikos committed
450 451 452
    }
    case Cookie:
      doc.setCookie(val);
453
      return;
George Staikos's avatar
George Staikos committed
454 455
    case Location:
    {
456 457 458
      KHTMLPart *part = doc.part();
      if ( part )
        Window::retrieveWindow(part)->goURL(exec, value->toString(exec).qstring(), false /*don't lock history*/);
459
      return;
George Staikos's avatar
George Staikos committed
460
    }
461
    case DesignMode:
Maks Orlovich's avatar
Maks Orlovich committed
462
        doc.setDesignMode((value->toString(exec).qstring().toLower()=="on"));
463
        return;
George Staikos's avatar
George Staikos committed
464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494
  }

  /* The rest of the properties require a body. Note that Doc::body may be the
     frameset(!!) so we have to be a bit careful here. I am not sure this is
     100% right, but it should match previous behavior - M.O. */
  DOM::HTMLElementImpl* bodyCand = doc.body();
  if (!bodyCand || bodyCand->id() != ID_BODY)
    return; //Just ignore.

  DOM::HTMLBodyElementImpl& body = *static_cast<DOM::HTMLBodyElementImpl*>(bodyCand);

  switch (token) {
  case BgColor:
    if (body.bgColor() != val) body.setBgColor(val);
    break;
  case FgColor:
    if (body.text() != val) body.setText(val);
    break;
  case AlinkColor:
    if (body.aLink() != val) body.setALink(val);
    break;
  case LinkColor:
    if (body.link() != val) body.setLink(val);
    break;
  case VlinkColor:
    if (body.vLink() != val) body.setVLink(val);
    break;
  case Dir:
    body.setAttribute(ID_DIR, value->toString(exec).domString());
    break;
  default:
Laurent Montel's avatar
Laurent Montel committed
495
    kDebug(6070) << "WARNING: HTMLDocument::putValueProperty unhandled token " << token;
George Staikos's avatar
George Staikos committed
496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555
  }
}

// -------------------------------------------------------------------------

const ClassInfo KJS::HTMLElement::info = { "HTMLElement", &DOMElement::info, &HTMLElementTable, 0 };
const ClassInfo KJS::HTMLElement::html_info = { "HTMLHtmlElement", &KJS::HTMLElement::info, &HTMLHtmlElementTable, 0 };
const ClassInfo KJS::HTMLElement::head_info = { "HTMLHeadElement", &KJS::HTMLElement::info, &HTMLHeadElementTable, 0 };
const ClassInfo KJS::HTMLElement::link_info = { "HTMLLinkElement", &KJS::HTMLElement::info, &HTMLLinkElementTable, 0 };
const ClassInfo KJS::HTMLElement::title_info = { "HTMLTitleElement", &KJS::HTMLElement::info, &HTMLTitleElementTable, 0 };
const ClassInfo KJS::HTMLElement::meta_info = { "HTMLMetaElement", &KJS::HTMLElement::info, &HTMLMetaElementTable, 0 };
const ClassInfo KJS::HTMLElement::base_info = { "HTMLBaseElement", &KJS::HTMLElement::info, &HTMLBaseElementTable, 0 };
const ClassInfo KJS::HTMLElement::isIndex_info = { "HTMLIsIndexElement", &KJS::HTMLElement::info, &HTMLIsIndexElementTable, 0 };
const ClassInfo KJS::HTMLElement::style_info = { "HTMLStyleElement", &KJS::HTMLElement::info, &HTMLStyleElementTable, 0 };
const ClassInfo KJS::HTMLElement::body_info = { "HTMLBodyElement", &KJS::HTMLElement::info, &HTMLBodyElementTable, 0 };
const ClassInfo KJS::HTMLElement::form_info = { "HTMLFormElement", &KJS::HTMLElement::info, &HTMLFormElementTable, 0 };
const ClassInfo KJS::HTMLElement::select_info = { "HTMLSelectElement", &KJS::HTMLElement::info, &HTMLSelectElementTable, 0 };
const ClassInfo KJS::HTMLElement::optGroup_info = { "HTMLOptGroupElement", &KJS::HTMLElement::info, &HTMLOptGroupElementTable, 0 };
const ClassInfo KJS::HTMLElement::option_info = { "HTMLOptionElement", &KJS::HTMLElement::info, &HTMLOptionElementTable, 0 };
const ClassInfo KJS::HTMLElement::input_info = { "HTMLInputElement", &KJS::HTMLElement::info, &HTMLInputElementTable, 0 };
const ClassInfo KJS::HTMLElement::textArea_info = { "HTMLTextAreaElement", &KJS::HTMLElement::info, &HTMLTextAreaElementTable, 0 };
const ClassInfo KJS::HTMLElement::button_info = { "HTMLButtonElement", &KJS::HTMLElement::info, &HTMLButtonElementTable, 0 };
const ClassInfo KJS::HTMLElement::label_info = { "HTMLLabelElement", &KJS::HTMLElement::info, &HTMLLabelElementTable, 0 };
const ClassInfo KJS::HTMLElement::fieldSet_info = { "HTMLFieldSetElement", &KJS::HTMLElement::info, &HTMLFieldSetElementTable, 0 };
const ClassInfo KJS::HTMLElement::legend_info = { "HTMLLegendElement", &KJS::HTMLElement::info, &HTMLLegendElementTable, 0 };
const ClassInfo KJS::HTMLElement::ul_info = { "HTMLUListElement", &KJS::HTMLElement::info, &HTMLUListElementTable, 0 };
const ClassInfo KJS::HTMLElement::ol_info = { "HTMLOListElement", &KJS::HTMLElement::info, &HTMLOListElementTable, 0 };
const ClassInfo KJS::HTMLElement::dl_info = { "HTMLDListElement", &KJS::HTMLElement::info, &HTMLDListElementTable, 0 };
const ClassInfo KJS::HTMLElement::dir_info = { "HTMLDirectoryElement", &KJS::HTMLElement::info, &HTMLDirectoryElementTable, 0 };
const ClassInfo KJS::HTMLElement::menu_info = { "HTMLMenuElement", &KJS::HTMLElement::info, &HTMLMenuElementTable, 0 };
const ClassInfo KJS::HTMLElement::li_info = { "HTMLLIElement", &KJS::HTMLElement::info, &HTMLLIElementTable, 0 };
const ClassInfo KJS::HTMLElement::div_info = { "HTMLDivElement", &KJS::HTMLElement::info, &HTMLDivElementTable, 0 };
const ClassInfo KJS::HTMLElement::p_info = { "HTMLParagraphElement", &KJS::HTMLElement::info, &HTMLParagraphElementTable, 0 };
const ClassInfo KJS::HTMLElement::heading_info = { "HTMLHeadingElement", &KJS::HTMLElement::info, &HTMLHeadingElementTable, 0 };
const ClassInfo KJS::HTMLElement::blockQuote_info = { "HTMLBlockQuoteElement", &KJS::HTMLElement::info, &HTMLBlockQuoteElementTable, 0 };
const ClassInfo KJS::HTMLElement::q_info = { "HTMLQuoteElement", &KJS::HTMLElement::info, &HTMLQuoteElementTable, 0 };
const ClassInfo KJS::HTMLElement::pre_info = { "HTMLPreElement", &KJS::HTMLElement::info, &HTMLPreElementTable, 0 };
const ClassInfo KJS::HTMLElement::br_info = { "HTMLBRElement", &KJS::HTMLElement::info, &HTMLBRElementTable, 0 };
const ClassInfo KJS::HTMLElement::baseFont_info = { "HTMLBaseFontElement", &KJS::HTMLElement::info, &HTMLBaseFontElementTable, 0 };
const ClassInfo KJS::HTMLElement::font_info = { "HTMLFontElement", &KJS::HTMLElement::info, &HTMLFontElementTable, 0 };
const ClassInfo KJS::HTMLElement::hr_info = { "HTMLHRElement", &KJS::HTMLElement::info, &HTMLHRElementTable, 0 };
const ClassInfo KJS::HTMLElement::mod_info = { "HTMLModElement", &KJS::HTMLElement::info, &HTMLModElementTable, 0 };
const ClassInfo KJS::HTMLElement::a_info = { "HTMLAnchorElement", &KJS::HTMLElement::info, &HTMLAnchorElementTable, 0 };
const ClassInfo KJS::HTMLElement::canvas_info = { "HTMLCanvasElement", &KJS::HTMLElement::info, &HTMLCanvasElementTable, 0 };
const ClassInfo KJS::HTMLElement::img_info = { "HTMLImageElement", &KJS::HTMLElement::info, &HTMLImageElementTable, 0 };
const ClassInfo KJS::HTMLElement::object_info = { "HTMLObjectElement", &KJS::HTMLElement::info, &HTMLObjectElementTable, 0 };
const ClassInfo KJS::HTMLElement::param_info = { "HTMLParamElement", &KJS::HTMLElement::info, &HTMLParamElementTable, 0 };
const ClassInfo KJS::HTMLElement::applet_info = { "HTMLAppletElement", &KJS::HTMLElement::info, &HTMLAppletElementTable, 0 };
const ClassInfo KJS::HTMLElement::map_info = { "HTMLMapElement", &KJS::HTMLElement::info, &HTMLMapElementTable, 0 };
const ClassInfo KJS::HTMLElement::area_info = { "HTMLAreaElement", &KJS::HTMLElement::info, &HTMLAreaElementTable, 0 };
const ClassInfo KJS::HTMLElement::script_info = { "HTMLScriptElement", &KJS::HTMLElement::info, &HTMLScriptElementTable, 0 };
const ClassInfo KJS::HTMLElement::table_info = { "HTMLTableElement", &KJS::HTMLElement::info, &HTMLTableElementTable, 0 };
const ClassInfo KJS::HTMLElement::caption_info = { "HTMLTableCaptionElement", &KJS::HTMLElement::info, &HTMLTableCaptionElementTable, 0 };
const ClassInfo KJS::HTMLElement::col_info = { "HTMLTableColElement", &KJS::HTMLElement::info, &HTMLTableColElementTable, 0 };
const ClassInfo KJS::HTMLElement::tablesection_info = { "HTMLTableSectionElement", &KJS::HTMLElement::info, &HTMLTableSectionElementTable, 0 };
const ClassInfo KJS::HTMLElement::tr_info = { "HTMLTableRowElement", &KJS::HTMLElement::info, &HTMLTableRowElementTable, 0 };
const ClassInfo KJS::HTMLElement::tablecell_info = { "HTMLTableCellElement", &KJS::HTMLElement::info, &HTMLTableCellElementTable, 0 };
const ClassInfo KJS::HTMLElement::frameSet_info = { "HTMLFrameSetElement", &KJS::HTMLElement::info, &HTMLFrameSetElementTable, 0 };
const ClassInfo KJS::HTMLElement::frame_info = { "HTMLFrameElement", &KJS::HTMLElement::info, &HTMLFrameElementTable, 0 };
const ClassInfo KJS::HTMLElement::iFrame_info = { "HTMLIFrameElement", &KJS::HTMLElement::info, &HTMLIFrameElementTable, 0 };
556
const ClassInfo KJS::HTMLElement::marquee_info = { "HTMLMarqueeElement", &KJS::HTMLElement::info, 0, 0 };
George Staikos's avatar
George Staikos committed
557 558
const ClassInfo KJS::HTMLElement::layer_info = { "HTMLLayerElement", &KJS::HTMLElement::info, &HTMLLayerElementTable, 0 };

Harri Porten's avatar
Harri Porten committed
559
static JSObject* prototypeForID(ExecState* exec, DOM::NodeImpl::Id id);
560 561 562 563

KJS::HTMLElement::HTMLElement(ExecState *exec, DOM::HTMLElementImpl* e) :
        DOMElement(prototypeForID(exec, e->id()), e) { }

George Staikos's avatar
George Staikos committed
564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703
const ClassInfo* KJS::HTMLElement::classInfo() const
{
  DOM::HTMLElementImpl& element = *impl();
  switch (element.id()) {
  case ID_HTML:
    return &html_info;
  case ID_HEAD:
    return &head_info;
  case ID_LINK:
    return &link_info;
  case ID_TITLE:
    return &title_info;
  case ID_META:
    return &meta_info;
  case ID_BASE:
    return &base_info;
  case ID_ISINDEX:
    return &isIndex_info;
  case ID_STYLE:
    return &style_info;
  case ID_BODY:
    return &body_info;
  case ID_FORM:
    return &form_info;
  case ID_SELECT:
    return &select_info;
  case ID_OPTGROUP:
    return &optGroup_info;
  case ID_OPTION:
    return &option_info;
  case ID_INPUT:
    return &input_info;
  case ID_TEXTAREA:
    return &textArea_info;
  case ID_BUTTON:
    return &button_info;
  case ID_LABEL:
    return &label_info;
  case ID_FIELDSET:
    return &fieldSet_info;
  case ID_LEGEND:
    return &legend_info;
  case ID_UL:
    return &ul_info;
  case ID_OL:
    return &ol_info;
  case ID_DL:
    return &dl_info;
  case ID_DIR:
    return &dir_info;
  case ID_MENU:
    return &menu_info;
  case ID_LI:
    return &li_info;
  case ID_DIV:
    return &div_info;
  case ID_P:
    return &p_info;
  case ID_H1:
  case ID_H2:
  case ID_H3:
  case ID_H4:
  case ID_H5:
  case ID_H6:
    return &heading_info;
  case ID_BLOCKQUOTE:
    return &blockQuote_info;
  case ID_Q:
    return &q_info;
  case ID_PRE:
    return &pre_info;
  case ID_BR:
    return &br_info;
  case ID_BASEFONT:
    return &baseFont_info;
  case ID_FONT:
    return &font_info;
  case ID_HR:
    return &hr_info;
  case ID_INS:
  case ID_DEL:
    return &mod_info;
  case ID_A:
    return &a_info;
  case ID_IMG:
    return &img_info;
  case ID_CANVAS:
    return &canvas_info;
  case ID_OBJECT:
    return &object_info;
  case ID_PARAM:
    return &param_info;
  case ID_APPLET:
    return &applet_info;
  case ID_MAP:
    return &map_info;
  case ID_AREA:
    return &area_info;
  case ID_SCRIPT:
    return &script_info;
  case ID_TABLE:
    return &table_info;
  case ID_CAPTION:
    return &caption_info;
  case ID_COL:
  case ID_COLGROUP:
    return &col_info;
  case ID_THEAD:
  case ID_TBODY:
  case ID_TFOOT:
    return &tablesection_info;
  case ID_TR:
    return &tr_info;
  case ID_TH:
  case ID_TD:
    return &tablecell_info;
  case ID_FRAMESET:
    return &frameSet_info;
  case ID_FRAME:
    return &frame_info;
  case ID_IFRAME:
    return &iFrame_info;
  case ID_MARQUEE:
    return &marquee_info;
  case ID_LAYER:
    return &layer_info;
  default:
    return &info;
  }
}
/*
@begin HTMLElementTable 11
  id		KJS::HTMLElement::ElementId	DontDelete
  title		KJS::HTMLElement::ElementTitle	DontDelete
  lang		KJS::HTMLElement::ElementLang	DontDelete
  dir		KJS::HTMLElement::ElementDir	DontDelete
  className	KJS::HTMLElement::ElementClassName DontDelete
  innerHTML	KJS::HTMLElement::ElementInnerHTML DontDelete
  innerText	KJS::HTMLElement::ElementInnerText DontDelete
  document	KJS::HTMLElement::ElementDocument  DontDelete|ReadOnly
704
  tabIndex      KJS::HTMLElement::ElementTabIndex  DontDelete
George Staikos's avatar
George Staikos committed
705 706 707
# IE extension
  children	KJS::HTMLElement::ElementChildren  DontDelete|ReadOnly
  all           KJS::HTMLElement::ElementAll       DontDelete|ReadOnly
708 709
  contentEditable   KJS::HTMLElement::ElementContentEditable  DontDelete
  isContentEditable KJS::HTMLElement::ElementIsContentEditable  DontDelete|ReadOnly
710 711
@end
@begin HTMLElementProtoTable 1
Harri Porten's avatar
Harri Porten committed
712
  scrollIntoView KJS::HTMLElement::ElementScrollIntoView DontDelete|Function 0
George Staikos's avatar
George Staikos committed
713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754
@end
@begin HTMLHtmlElementTable 1
  version	KJS::HTMLElement::HtmlVersion	DontDelete
@end
@begin HTMLHeadElementTable 1
  profile	KJS::HTMLElement::HeadProfile	DontDelete
@end
@begin HTMLLinkElementTable 11
  disabled	KJS::HTMLElement::LinkDisabled	DontDelete
  charset	KJS::HTMLElement::LinkCharset	DontDelete
  href		KJS::HTMLElement::LinkHref	DontDelete
  hreflang	KJS::HTMLElement::LinkHrefLang	DontDelete
  media		KJS::HTMLElement::LinkMedia	DontDelete
  rel		KJS::HTMLElement::LinkRel      	DontDelete
  rev		KJS::HTMLElement::LinkRev	DontDelete
  target	KJS::HTMLElement::LinkTarget	DontDelete
  type		KJS::HTMLElement::LinkType	DontDelete
  sheet		KJS::HTMLElement::LinkSheet	DontDelete|ReadOnly
@end
@begin HTMLTitleElementTable 1
  text		KJS::HTMLElement::TitleText	DontDelete
@end
@begin HTMLMetaElementTable 4
  content	KJS::HTMLElement::MetaContent	DontDelete
  httpEquiv	KJS::HTMLElement::MetaHttpEquiv	DontDelete
  name		KJS::HTMLElement::MetaName	DontDelete
  scheme	KJS::HTMLElement::MetaScheme	DontDelete
@end
@begin HTMLBaseElementTable 2
  href		KJS::HTMLElement::BaseHref	DontDelete
  target	KJS::HTMLElement::BaseTarget	DontDelete
@end
@begin HTMLIsIndexElementTable 2
  form		KJS::HTMLElement::IsIndexForm	DontDelete|ReadOnly
  prompt	KJS::HTMLElement::IsIndexPrompt	DontDelete
@end
@begin HTMLStyleElementTable 4
  disabled	KJS::HTMLElement::StyleDisabled	DontDelete
  media		KJS::HTMLElement::StyleMedia	DontDelete
  type		KJS::HTMLElement::StyleType	DontDelete
  sheet		KJS::HTMLElement::StyleSheet	DontDelete|ReadOnly
@end
755
@begin HTMLBodyElementTable 12
George Staikos's avatar
George Staikos committed
756 757 758 759 760 761
  aLink		KJS::HTMLElement::BodyALink	DontDelete
  background	KJS::HTMLElement::BodyBackground	DontDelete
  bgColor	KJS::HTMLElement::BodyBgColor	DontDelete
  link		KJS::HTMLElement::BodyLink	DontDelete
  text		KJS::HTMLElement::BodyText	DontDelete
  vLink		KJS::HTMLElement::BodyVLink	DontDelete
762
# HTML5 specifies these as shadowing normal ones and forwarding to window
763 764 765 766 767 768
  onload        KJS::HTMLElement::BodyOnLoad        DontDelete
  onerror       KJS::HTMLElement::BodyOnError       DontDelete
  onfocus       KJS::HTMLElement::BodyOnFocus       DontDelete
  onblur        KJS::HTMLElement::BodyOnBlur        DontDelete
  onmessage     KJS::HTMLElement::BodyOnMessage     DontDelete
  onhashchange  KJS::HTMLElement::BodyOnHashChange  DontDelete
George Staikos's avatar
George Staikos committed
769
@end
770
@begin HTMLBodyElementProtoTable 2
Maks Orlovich's avatar
Maks Orlovich committed
771 772
# Even though we do blur/focus everywhere, we still handle body.focus()
# specially for now
773 774
  focus         KJS::HTMLElement::BodyFocus      DontDelete|Function 0
@end
George Staikos's avatar
George Staikos committed
775 776 777 778 779 780 781 782 783 784 785
@begin HTMLFormElementTable 11
# Also supported, by name/index
  elements	KJS::HTMLElement::FormElements	DontDelete|ReadOnly
  length	KJS::HTMLElement::FormLength	DontDelete|ReadOnly
  name		KJS::HTMLElement::FormName	DontDelete
  acceptCharset	KJS::HTMLElement::FormAcceptCharset	DontDelete
  action	KJS::HTMLElement::FormAction	DontDelete
  encoding	KJS::HTMLElement::FormEncType	DontDelete
  enctype	KJS::HTMLElement::FormEncType	DontDelete
  method	KJS::HTMLElement::FormMethod	DontDelete
  target	KJS::HTMLElement::FormTarget	DontDelete
786 787
@end
@begin HTMLFormElementProtoTable 2
George Staikos's avatar
George Staikos committed
788 789 790 791 792 793 794 795 796 797 798 799 800 801 802
  submit	KJS::HTMLElement::FormSubmit	DontDelete|Function 0
  reset		KJS::HTMLElement::FormReset	DontDelete|Function 0
@end
@begin HTMLSelectElementTable 11
# Also supported, by index
  type		KJS::HTMLElement::SelectType	DontDelete|ReadOnly
  selectedIndex	KJS::HTMLElement::SelectSelectedIndex	DontDelete
  value		KJS::HTMLElement::SelectValue	DontDelete
  length	KJS::HTMLElement::SelectLength	DontDelete
  form		KJS::HTMLElement::SelectForm	DontDelete|ReadOnly
  options	KJS::HTMLElement::SelectOptions	DontDelete|ReadOnly
  disabled	KJS::HTMLElement::SelectDisabled	DontDelete
  multiple	KJS::HTMLElement::SelectMultiple	DontDelete
  name		KJS::HTMLElement::SelectName	DontDelete
  size		KJS::HTMLElement::SelectSize	DontDelete
803 804
@end
@begin HTMLSelectElementProtoTable 4
George Staikos's avatar
George Staikos committed
805
  add		KJS::HTMLElement::SelectAdd	DontDelete|Function 2
Maks Orlovich's avatar
 
Maks Orlovich committed
806
  item		KJS::HTMLElement::SelectItem	DontDelete|Function 1
George Staikos's avatar
George Staikos committed
807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822
  remove	KJS::HTMLElement::SelectRemove	DontDelete|Function 1
@end
@begin HTMLOptGroupElementTable 2
  disabled	KJS::HTMLElement::OptGroupDisabled	DontDelete
  label		KJS::HTMLElement::OptGroupLabel		DontDelete
@end
@begin HTMLOptionElementTable 8
  form		KJS::HTMLElement::OptionForm		DontDelete|ReadOnly
  defaultSelected KJS::HTMLElement::OptionDefaultSelected	DontDelete
  text		KJS::HTMLElement::OptionText		DontDelete
  index		KJS::HTMLElement::OptionIndex		DontDelete|ReadOnly
  disabled	KJS::HTMLElement::OptionDisabled	DontDelete
  label		KJS::HTMLElement::OptionLabel		DontDelete
  selected	KJS::HTMLElement::OptionSelected	DontDelete
  value		KJS::HTMLElement::OptionValue		DontDelete
@end
823
@begin HTMLInputElementTable 25
George Staikos's avatar
George Staikos committed
824 825 826 827 828 829 830 831
  defaultValue	KJS::HTMLElement::InputDefaultValue	DontDelete
  defaultChecked KJS::HTMLElement::InputDefaultChecked	DontDelete
  form		KJS::HTMLElement::InputForm		DontDelete|ReadOnly
  accept	KJS::HTMLElement::InputAccept		DontDelete
  accessKey	KJS::HTMLElement::InputAccessKey	DontDelete
  align		KJS::HTMLElement::InputAlign		DontDelete
  alt		KJS::HTMLElement::InputAlt		DontDelete
  checked	KJS::HTMLElement::InputChecked		DontDelete
832
  indeterminate	KJS::HTMLElement::InputIndeterminate	DontDelete
George Staikos's avatar
George Staikos committed
833 834 835 836 837 838 839 840 841 842
  status	KJS::HTMLElement::InputChecked		DontDelete
  disabled	KJS::HTMLElement::InputDisabled		DontDelete
  maxLength	KJS::HTMLElement::InputMaxLength	DontDelete
  name		KJS::HTMLElement::InputName		DontDelete
  readOnly	KJS::HTMLElement::InputReadOnly		DontDelete
  size		KJS::HTMLElement::InputSize		DontDelete
  src		KJS::HTMLElement::InputSrc		DontDelete
  type		KJS::HTMLElement::InputType		DontDelete
  useMap	KJS::HTMLElement::InputUseMap		DontDelete
  value		KJS::HTMLElement::InputValue		DontDelete
Maks Orlovich's avatar
Maks Orlovich committed
843 844
  selectionStart KJS::HTMLElement::InputSelectionStart  DontDelete
  selectionEnd   KJS::HTMLElement::InputSelectionEnd    DontDelete
845
  placeholder   KJS::HTMLElement::InputPlaceholder      DontDelete
846 847
@end
@begin HTMLInputElementProtoTable 5
George Staikos's avatar
George Staikos committed
848 849
  select	KJS::HTMLElement::InputSelect		DontDelete|Function 0
  click		KJS::HTMLElement::InputClick		DontDelete|Function 0
Maks Orlovich's avatar
Maks Orlovich committed
850
  setSelectionRange KJS::HTMLElement::InputSetSelectionRange DontDelete|Function 2
George Staikos's avatar
George Staikos committed
851 852 853 854 855 856 857 858 859 860 861 862
@end
@begin HTMLTextAreaElementTable 13
  defaultValue	KJS::HTMLElement::TextAreaDefaultValue	DontDelete
  form		KJS::HTMLElement::TextAreaForm		DontDelete|ReadOnly
  accessKey	KJS::HTMLElement::TextAreaAccessKey	DontDelete
  cols		KJS::HTMLElement::TextAreaCols		DontDelete
  disabled	KJS::HTMLElement::TextAreaDisabled	DontDelete
  name		KJS::HTMLElement::TextAreaName		DontDelete
  readOnly	KJS::HTMLElement::TextAreaReadOnly	DontDelete
  rows		KJS::HTMLElement::TextAreaRows		DontDelete
  type		KJS::HTMLElement::TextAreaType		DontDelete|ReadOnly
  value		KJS::HTMLElement::TextAreaValue		DontDelete
Maks Orlovich's avatar
Maks Orlovich committed
863 864 865
  selectionStart KJS::HTMLElement::TextAreaSelectionStart DontDelete
  selectionEnd   KJS::HTMLElement::TextAreaSelectionEnd   DontDelete
  textLength     KJS::HTMLElement::TextAreaTextLength     DontDelete|ReadOnly
866
  placeholder   KJS::HTMLElement::TextAreaPlaceholder     DontDelete
867 868
@end
@begin HTMLTextAreaElementProtoTable 4
Maks Orlovich's avatar
Maks Orlovich committed
869
  select  KJS::HTMLElement::TextAreaSelect        DontDelete|Function 0
Maks Orlovich's avatar
Maks Orlovich committed
870
  setSelectionRange KJS::HTMLElement::TextAreaSetSelectionRange DontDelete|Function 2
George Staikos's avatar
George Staikos committed
871 872 873 874 875 876 877 878
@end
@begin HTMLButtonElementTable 9
  form		KJS::HTMLElement::ButtonForm		DontDelete|ReadOnly
  accessKey	KJS::HTMLElement::ButtonAccessKey	DontDelete
  disabled	KJS::HTMLElement::ButtonDisabled	DontDelete
  name		KJS::HTMLElement::ButtonName		DontDelete
  type		KJS::HTMLElement::ButtonType		DontDelete|ReadOnly
  value		KJS::HTMLElement::ButtonValue		DontDelete
879
@end
880 881
@begin HTMLButtonElementProtoTable 3
  click		KJS::HTMLElement::ButtonClick           DontDelete|Function 0
George Staikos's avatar
George Staikos committed
882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973
@end
@begin HTMLLabelElementTable 3
  form		KJS::HTMLElement::LabelForm		DontDelete|ReadOnly
  accessKey	KJS::HTMLElement::LabelAccessKey	DontDelete
  htmlFor	KJS::HTMLElement::LabelHtmlFor		DontDelete
@end
@begin HTMLFieldSetElementTable 1
  form		KJS::HTMLElement::FieldSetForm		DontDelete|ReadOnly
@end
@begin HTMLLegendElementTable 3
  form		KJS::HTMLElement::LegendForm		DontDelete|ReadOnly
  accessKey	KJS::HTMLElement::LegendAccessKey	DontDelete
  align		KJS::HTMLElement::LegendAlign		DontDelete
@end
@begin HTMLUListElementTable 2
  compact	KJS::HTMLElement::UListCompact		DontDelete
  type		KJS::HTMLElement::UListType		DontDelete
@end
@begin HTMLOListElementTable 3
  compact	KJS::HTMLElement::OListCompact		DontDelete
  start		KJS::HTMLElement::OListStart		DontDelete
  type		KJS::HTMLElement::OListType		DontDelete
@end
@begin HTMLDListElementTable 1
  compact	KJS::HTMLElement::DListCompact		DontDelete
@end
@begin HTMLDirectoryElementTable 1
  compact	KJS::HTMLElement::DirectoryCompact	DontDelete
@end
@begin HTMLMenuElementTable 1
  compact	KJS::HTMLElement::MenuCompact		DontDelete
@end
@begin HTMLLIElementTable 2
  type		KJS::HTMLElement::LIType		DontDelete
  value		KJS::HTMLElement::LIValue		DontDelete
@end
@begin HTMLDivElementTable 1
  align		KJS::HTMLElement::DivAlign		DontDelete
@end
@begin HTMLParagraphElementTable 1
  align		KJS::HTMLElement::ParagraphAlign	DontDelete
@end
@begin HTMLHeadingElementTable 1
  align		KJS::HTMLElement::HeadingAlign		DontDelete
@end
@begin HTMLBlockQuoteElementTable 1
  cite		KJS::HTMLElement::BlockQuoteCite	DontDelete
@end
@begin HTMLQuoteElementTable 1
  cite		KJS::HTMLElement::QuoteCite		DontDelete
@end
@begin HTMLPreElementTable 1
  width		KJS::HTMLElement::PreWidth		DontDelete
@end
@begin HTMLBRElementTable 1
  clear		KJS::HTMLElement::BRClear		DontDelete
@end
@begin HTMLBaseFontElementTable 3
  color		KJS::HTMLElement::BaseFontColor		DontDelete
  face		KJS::HTMLElement::BaseFontFace		DontDelete
  size		KJS::HTMLElement::BaseFontSize		DontDelete
@end
@begin HTMLFontElementTable 3
  color		KJS::HTMLElement::FontColor		DontDelete
  face		KJS::HTMLElement::FontFace		DontDelete
  size		KJS::HTMLElement::FontSize		DontDelete
@end
@begin HTMLHRElementTable 4
  align		KJS::HTMLElement::HRAlign		DontDelete
  noShade	KJS::HTMLElement::HRNoShade		DontDelete
  size		KJS::HTMLElement::HRSize		DontDelete
  width		KJS::HTMLElement::HRWidth		DontDelete
@end
@begin HTMLModElementTable 2
  cite		KJS::HTMLElement::ModCite		DontDelete
  dateTime	KJS::HTMLElement::ModDateTime		DontDelete
@end
@begin HTMLAnchorElementTable 23
  accessKey	KJS::HTMLElement::AnchorAccessKey	DontDelete
  charset	KJS::HTMLElement::AnchorCharset		DontDelete
  coords	KJS::HTMLElement::AnchorCoords		DontDelete
  href		KJS::HTMLElement::AnchorHref		DontDelete
  hreflang	KJS::HTMLElement::AnchorHrefLang	DontDelete
  hash		KJS::HTMLElement::AnchorHash		DontDelete|ReadOnly
  host		KJS::HTMLElement::AnchorHost		DontDelete|ReadOnly
  hostname	KJS::HTMLElement::AnchorHostname	DontDelete|ReadOnly
  name		KJS::HTMLElement::AnchorName		DontDelete
  pathname	KJS::HTMLElement::AnchorPathName	DontDelete|ReadOnly
  port		KJS::HTMLElement::AnchorPort		DontDelete|ReadOnly
  protocol	KJS::HTMLElement::AnchorProtocol	DontDelete|ReadOnly
  rel		KJS::HTMLElement::AnchorRel		DontDelete
  rev		KJS::HTMLElement::AnchorRev		DontDelete
974
  search	KJS::HTMLElement::AnchorSearch		DontDelete
George Staikos's avatar
George Staikos committed
975 976 977 978
  shape		KJS::HTMLElement::AnchorShape		DontDelete
  target	KJS::HTMLElement::AnchorTarget		DontDelete
  text		KJS::HTMLElement::AnchorText		DontDelete|ReadOnly
  type		KJS::HTMLElement::AnchorType		DontDelete
979 980
@end
@begin HTMLAnchorElementProtoTable 3
Maks Orlovich's avatar
Maks Orlovich committed
981
  click		KJS::HTMLElement::AnchorClick		DontDelete|Function 0
982
  toString      KJS::HTMLElement::AnchorToString        DontDelete|Function 0
George Staikos's avatar
George Staikos committed
983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000
@end
@begin HTMLImageElementTable 15
  name		KJS::HTMLElement::ImageName		DontDelete
  align		KJS::HTMLElement::ImageAlign		DontDelete
  alt		KJS::HTMLElement::ImageAlt		DontDelete
  border	KJS::HTMLElement::ImageBorder		DontDelete
  complete	KJS::HTMLElement::ImageComplete		DontDelete|ReadOnly
  height	KJS::HTMLElement::ImageHeight		DontDelete
  hspace	KJS::HTMLElement::ImageHspace		DontDelete
  isMap		KJS::HTMLElement::ImageIsMap		DontDelete
  longDesc	KJS::HTMLElement::ImageLongDesc		DontDelete
  src		KJS::HTMLElement::ImageSrc		DontDelete
  useMap	KJS::HTMLElement::ImageUseMap		DontDelete
  vspace	KJS::HTMLElement::ImageVspace		DontDelete
  width		KJS::HTMLElement::ImageWidth		DontDelete
  x     	KJS::HTMLElement::ImageX		DontDelete|ReadOnly
  y     	KJS::HTMLElement::ImageY		DontDelete|ReadOnly
@end
1001
@begin HTMLObjectElementTable 23
George Staikos's avatar
George Staikos committed
1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020
  form		  KJS::HTMLElement::ObjectForm		  DontDelete|ReadOnly
  code		  KJS::HTMLElement::ObjectCode		  DontDelete
  align		  KJS::HTMLElement::ObjectAlign		  DontDelete
  archive	  KJS::HTMLElement::ObjectArchive	  DontDelete
  border	  KJS::HTMLElement::ObjectBorder	  DontDelete
  codeBase	  KJS::HTMLElement::ObjectCodeBase	  DontDelete
  codeType	  KJS::HTMLElement::ObjectCodeType	  DontDelete
  contentDocument KJS::HTMLElement::ObjectContentDocument DontDelete|ReadOnly
  data		  KJS::HTMLElement::ObjectData		  DontDelete
  declare	  KJS::HTMLElement::ObjectDeclare	  DontDelete
  height	  KJS::HTMLElement::ObjectHeight	  DontDelete
  hspace	  KJS::HTMLElement::ObjectHspace	  DontDelete
  name		  KJS::HTMLElement::ObjectName		  DontDelete
  standby	  KJS::HTMLElement::ObjectStandby	  DontDelete
  type		  KJS::HTMLElement::ObjectType		  DontDelete
  useMap	  KJS::HTMLElement::ObjectUseMap	  DontDelete
  vspace	  KJS::HTMLElement::ObjectVspace	  DontDelete
  width		  KJS::HTMLElement::ObjectWidth		  DontDelete
@end
1021 1022 1023 1024 1025
@begin HTMLObjectElementProtoTable 1
# half deprecated - cf. http://lists.w3.org/Archives/Public/www-svg/2008Feb/0031.html
# only implemented in ecma, because of acid3 dependency
  getSVGDocument  KJS::HTMLElement::ObjectGetSVGDocument  DontDelete|Function 0
@end
George Staikos's avatar
George Staikos committed
1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088
@begin HTMLParamElementTable 4
  name		KJS::HTMLElement::ParamName		DontDelete
  type		KJS::HTMLElement::ParamType		DontDelete
  value		KJS::HTMLElement::ParamValue		DontDelete
  valueType	KJS::HTMLElement::ParamValueType	DontDelete
@end
@begin HTMLAppletElementTable 11
  align		KJS::HTMLElement::AppletAlign		DontDelete
  alt		KJS::HTMLElement::AppletAlt		DontDelete
  archive	KJS::HTMLElement::AppletArchive		DontDelete
  code		KJS::HTMLElement::AppletCode		DontDelete
  codeBase	KJS::HTMLElement::AppletCodeBase	DontDelete
  height	KJS::HTMLElement::AppletHeight		DontDelete
  hspace	KJS::HTMLElement::AppletHspace		DontDelete
  name		KJS::HTMLElement::AppletName		DontDelete
  object	KJS::HTMLElement::AppletObject		DontDelete
  vspace	KJS::HTMLElement::AppletVspace		DontDelete
  width		KJS::HTMLElement::AppletWidth		DontDelete
@end
@begin HTMLMapElementTable 2
  areas		KJS::HTMLElement::MapAreas		DontDelete|ReadOnly
  name		KJS::HTMLElement::MapName		DontDelete
@end
@begin HTMLAreaElementTable 15
  accessKey	KJS::HTMLElement::AreaAccessKey		DontDelete
  alt		KJS::HTMLElement::AreaAlt		DontDelete
  coords	KJS::HTMLElement::AreaCoords		DontDelete
  href		KJS::HTMLElement::AreaHref		DontDelete
  hash		KJS::HTMLElement::AreaHash		DontDelete|ReadOnly
  host		KJS::HTMLElement::AreaHost		DontDelete|ReadOnly
  hostname	KJS::HTMLElement::AreaHostName		DontDelete|ReadOnly
  pathname	KJS::HTMLElement::AreaPathName		DontDelete|ReadOnly
  port		KJS::HTMLElement::AreaPort		DontDelete|ReadOnly
  protocol	KJS::HTMLElement::AreaProtocol		DontDelete|ReadOnly
  search	KJS::HTMLElement::AreaSearch		DontDelete|ReadOnly
  noHref	KJS::HTMLElement::AreaNoHref		DontDelete
  shape		KJS::HTMLElement::AreaShape		DontDelete
  target	KJS::HTMLElement::AreaTarget		DontDelete
@end
@begin HTMLScriptElementTable 7
  text		KJS::HTMLElement::ScriptText		DontDelete
  htmlFor	KJS::HTMLElement::ScriptHtmlFor		DontDelete
  event		KJS::HTMLElement::ScriptEvent		DontDelete
  charset	KJS::HTMLElement::ScriptCharset		DontDelete
  defer		KJS::HTMLElement::ScriptDefer		DontDelete
  src		KJS::HTMLElement::ScriptSrc		DontDelete
  type		KJS::HTMLElement::ScriptType		DontDelete
@end
@begin HTMLTableElementTable 23
  caption	KJS::HTMLElement::TableCaption		DontDelete
  tHead		KJS::HTMLElement::TableTHead		DontDelete
  tFoot		KJS::HTMLElement::TableTFoot		DontDelete
  rows		KJS::HTMLElement::TableRows		DontDelete|ReadOnly
  tBodies	KJS::HTMLElement::TableTBodies		DontDelete|ReadOnly
  align		KJS::HTMLElement::TableAlign		DontDelete
  bgColor	KJS::HTMLElement::TableBgColor		DontDelete
  border	KJS::HTMLElement::TableBorder		DontDelete
  cellPadding	KJS::HTMLElement::TableCellPadding	DontDelete
  cellSpacing	KJS::HTMLElement::TableCellSpacing	DontDelete
  frame		KJS::HTMLElement::TableFrame		DontDelete
  rules		KJS::HTMLElement::TableRules		DontDelete
  summary	KJS::HTMLElement::TableSummary		DontDelete
  width		KJS::HTMLElement::TableWidth		DontDelete
1089 1090
@end
@begin HTMLTableElementProtoTable 8
George Staikos's avatar
George Staikos committed
1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116
  createTHead	KJS::HTMLElement::TableCreateTHead	DontDelete|Function 0
  deleteTHead	KJS::HTMLElement::TableDeleteTHead	DontDelete|Function 0
  createTFoot	KJS::HTMLElement::TableCreateTFoot	DontDelete|Function 0
  deleteTFoot	KJS::HTMLElement::TableDeleteTFoot	DontDelete|Function 0
  createCaption	KJS::HTMLElement::TableCreateCaption	DontDelete|Function 0
  deleteCaption	KJS::HTMLElement::TableDeleteCaption	DontDelete|Function 0
  insertRow	KJS::HTMLElement::TableInsertRow	DontDelete|Function 1
  deleteRow	KJS::HTMLElement::TableDeleteRow	DontDelete|Function 1
@end
@begin HTMLTableCaptionElementTable 1
  align		KJS::HTMLElement::TableCaptionAlign	DontDelete
@end
@begin HTMLTableColElementTable 7
  align		KJS::HTMLElement::TableColAlign		DontDelete
  ch		KJS::HTMLElement::TableColCh		DontDelete
  chOff		KJS::HTMLElement::TableColChOff		DontDelete
  span		KJS::HTMLElement::TableColSpan		DontDelete
  vAlign	KJS::HTMLElement::TableColVAlign	DontDelete
  width		KJS::HTMLElement::TableColWidth		DontDelete
@end
@begin HTMLTableSectionElementTable 7
  align		KJS::HTMLElement::TableSectionAlign		DontDelete
  ch		KJS::HTMLElement::TableSectionCh		DontDelete
  chOff		KJS::HTMLElement::TableSectionChOff		DontDelete
  vAlign	KJS::HTMLElement::TableSectionVAlign		DontDelete
  rows		KJS::HTMLElement::TableSectionRows		DontDelete|ReadOnly
1117 1118
@end
@begin HTMLTableSectionElementProtoTable 2
George Staikos's avatar
George Staikos committed
1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130
  insertRow	KJS::HTMLElement::TableSectionInsertRow		DontDelete|Function 1
  deleteRow	KJS::HTMLElement::TableSectionDeleteRow		DontDelete|Function 1
@end
@begin HTMLTableRowElementTable 11
  rowIndex	KJS::HTMLElement::TableRowRowIndex		DontDelete|ReadOnly
  sectionRowIndex KJS::HTMLElement::TableRowSectionRowIndex	DontDelete|ReadOnly
  cells		KJS::HTMLElement::TableRowCells			DontDelete|ReadOnly
  align		KJS::HTMLElement::TableRowAlign			DontDelete
  bgColor	KJS::HTMLElement::TableRowBgColor		DontDelete
  ch		KJS::HTMLElement::TableRowCh			DontDelete
  chOff		KJS::HTMLElement::TableRowChOff			DontDelete
  vAlign	KJS::HTMLElement::TableRowVAlign		DontDelete
1131 1132
@end
@begin HTMLTableRowElementProtoTable 2
George Staikos's avatar
George Staikos committed
1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155
  insertCell	KJS::HTMLElement::TableRowInsertCell		DontDelete|Function 1
  deleteCell	KJS::HTMLElement::TableRowDeleteCell		DontDelete|Function 1
@end
@begin HTMLTableCellElementTable 15
  cellIndex	KJS::HTMLElement::TableCellCellIndex		DontDelete|ReadOnly
  abbr		KJS::HTMLElement::TableCellAbbr			DontDelete
  align		KJS::HTMLElement::TableCellAlign		DontDelete
  axis		KJS::HTMLElement::TableCellAxis			DontDelete
  bgColor	KJS::HTMLElement::TableCellBgColor		DontDelete
  ch		KJS::HTMLElement::TableCellCh			DontDelete
  chOff		KJS::HTMLElement::TableCellChOff		DontDelete
  colSpan	KJS::HTMLElement::TableCellColSpan		DontDelete
  headers	KJS::HTMLElement::TableCellHeaders		DontDelete
  height	KJS::HTMLElement::TableCellHeight		DontDelete
  noWrap	KJS::HTMLElement::TableCellNoWrap		DontDelete
  rowSpan	KJS::HTMLElement::TableCellRowSpan		DontDelete
  scope		KJS::HTMLElement::TableCellScope		DontDelete
  vAlign	KJS::HTMLElement::TableCellVAlign		DontDelete
  width		KJS::HTMLElement::TableCellWidth		DontDelete
@end
@begin HTMLFrameSetElementTable 2
  cols		KJS::HTMLElement::FrameSetCols			DontDelete
  rows		KJS::HTMLElement::FrameSetRows			DontDelete
Maks Orlovich's avatar
Maks Orlovich committed
1156
  onmessage     KJS::HTMLElement::FrameSetOnMessage             DontDelete
George Staikos's avatar
George Staikos committed
1157 1158 1159 1160 1161 1162 1163 1164 1165 1166
@end
@begin HTMLLayerElementTable 6
  top		  KJS::HTMLElement::LayerTop			DontDelete
  left		  KJS::HTMLElement::LayerLeft			DontDelete
  visibility	  KJS::HTMLElement::LayerVisibility		DontDelete
  bgColor	  KJS::HTMLElement::LayerBgColor		DontDelete
  document  	  KJS::HTMLElement::LayerDocument		DontDelete|ReadOnly
  clip	  	  KJS::HTMLElement::LayerClip			DontDelete|ReadOnly
  layers	  KJS::HTMLElement::LayerLayers			DontDelete|ReadOnly
@end
1167
@begin HTMLFrameElementTable 13
George Staikos's avatar
George Staikos committed
1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178
  contentDocument KJS::HTMLElement::FrameContentDocument        DontDelete|ReadOnly
  contentWindow KJS::HTMLElement::FrameContentWindow        DontDelete|ReadOnly
  frameBorder     KJS::HTMLElement::FrameFrameBorder		DontDelete
  longDesc	  KJS::HTMLElement::FrameLongDesc		DontDelete
  marginHeight	  KJS::HTMLElement::FrameMarginHeight		DontDelete
  marginWidth	  KJS::HTMLElement::FrameMarginWidth		DontDelete
  name		  KJS::HTMLElement::FrameName			DontDelete
  noResize	  KJS::HTMLElement::FrameNoResize		DontDelete
  scrolling	  KJS::HTMLElement::FrameScrolling		DontDelete
  src		  KJS::HTMLElement::FrameSrc			DontDelete
  location	  KJS::HTMLElement::FrameLocation		DontDelete
1179 1180 1181
# IE extension
  width		  KJS::HTMLElement::FrameWidth			DontDelete|ReadOnly
  height	  KJS::HTMLElement::FrameHeight			DontDelete|ReadOnly
George Staikos's avatar
George Staikos committed
1182
@end
1183
@begin HTMLIFrameElementTable 13
George Staikos's avatar
George Staikos committed
1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196
  align		  KJS::HTMLElement::IFrameAlign			DontDelete
  contentDocument KJS::HTMLElement::IFrameContentDocument       DontDelete|ReadOnly
  contentWindow KJS::HTMLElement::IFrameContentWindow        DontDelete|ReadOnly
  frameBorder	  KJS::HTMLElement::IFrameFrameBorder		DontDelete
  height	  KJS::HTMLElement::IFrameHeight		DontDelete
  longDesc	  KJS::HTMLElement::IFrameLongDesc		DontDelete
  marginHeight	  KJS::HTMLElement::IFrameMarginHeight		DontDelete
  marginWidth	  KJS::HTMLElement::IFrameMarginWidth		DontDelete
  name		  KJS::HTMLElement::IFrameName			DontDelete
  scrolling	  KJS::HTMLElement::IFrameScrolling		DontDelete
  src		  KJS::HTMLElement::IFrameSrc			DontDelete
  width		  KJS::HTMLElement::IFrameWidth			DontDelete
@end
1197 1198 1199 1200 1201
@begin HTMLIFrameElementProtoTable 1
# half deprecated - cf. http://lists.w3.org/Archives/Public/www-svg/2008Feb/0031.html
# only implemented in ecma, because of acid3 dependency
  getSVGDocument  KJS::HTMLElement::IFrameGetSVGDocument        DontDelete|Function 0
@end
George Staikos's avatar
George Staikos committed
1202

1203
@begin HTMLMarqueeElementProtoTable 2
George Staikos's avatar
George Staikos committed
1204 1205 1206 1207
  start           KJS::HTMLElement::MarqueeStart		DontDelete|Function 0
  stop            KJS::HTMLElement::MarqueeStop                 DontDelete|Function 0
@end

1208 1209 1210 1211 1212 1213
@begin HTMLCanvasElementTable 2
  width           KJS::HTMLElement::CanvasWidth                 DontDelete
  height          KJS::HTMLElement::CanvasHeight                DontDelete
@end

@begin HTMLCanvasElementProtoTable 1
1214 1215
  getContext      KJS::HTMLElement::CanvasGetContext            DontDelete|Function 1
  toDataURL       KJS::HTMLElement::CanvasToDataURL             DontDelete|Function 0
George Staikos's avatar
George Staikos committed
1216 1217
@end
*/
1218
KJS_IMPLEMENT_PROTOFUNC(HTMLElementFunction)
George Staikos's avatar
George Staikos committed
1219

1220
KParts::ScriptableExtension *HTMLElement::getScriptableExtension(const DOM::HTMLElementImpl &element)
George Staikos's avatar
George Staikos committed
1221
{
1222
  DOM::DocumentImpl* doc = element.document();
1223
  if (doc->part())
1224
    return doc->part()->scriptableExtension(&element);
George Staikos's avatar
George Staikos committed
1225 1226 1227
  return 0L;
}

Harri Porten's avatar
Harri Porten committed
1228
JSValue *HTMLElement::formNameGetter(ExecState *exec, JSObject*, const Identifier& propertyName, const PropertySlot& slot)
George Staikos's avatar
George Staikos committed
1229
{
1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242
    HTMLElement* thisObj = static_cast<HTMLElement*>(slot.slotBase());
    HTMLFormElementImpl* form = static_cast<HTMLFormElementImpl*>(thisObj->impl());

    KJS::HTMLCollection coll(exec, form->elements());
    JSValue* result = coll.getNamedItems(exec, propertyName);
    
    // In case of simple result, remember in past names map
    // ### our HTMLFormElementsCollection is a bit too IE-compatey rather than HTML5ey
    if (DOM::NodeImpl* node = toNode(result)) {
	if (node->isGenericFormElement())
	    form->bindPastName(static_cast<HTMLGenericFormElementImpl*>(node));
    }
    return result;
George Staikos's avatar
George Staikos committed
1243 1244
}

Harri Porten's avatar
Harri Porten committed
1245
//JSValue* KJS::HTMLElement::tryGet(ExecState *exec, const Identifier &propertyName) const
George Staikos's avatar
George Staikos committed
1246 1247 1248 1249
bool KJS::HTMLElement::getOwnPropertySlot(ExecState *exec, const Identifier &propertyName, PropertySlot& slot)
{
  DOM::HTMLElementImpl& element = *impl();
#ifdef KJS_VERBOSE
Laurent Montel's avatar
Laurent Montel committed
1250
  kDebug(6070) << "KJS::HTMLElement::getOwnPropertySlot " << propertyName.qstring() << " thisTag=" << element.tagName().string();
George Staikos's avatar
George Staikos committed
1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261
#endif
  // First look at dynamic properties
  switch (element.id()) {
    case ID_FORM: {
      DOM::HTMLFormElementImpl& form = static_cast<DOM::HTMLFormElementImpl&>(element);
      // Check if we're retrieving an element (by index or by name)

      if (getIndexSlot(this, propertyName, slot))
        return true;

      KJS::HTMLCollection coll(exec, form.elements());
Harri Porten's avatar
Harri Porten committed
1262
      JSValue *namedItems = coll.getNamedItems(exec, propertyName);
George Staikos's avatar
George Staikos committed
1263
      if (namedItems->type() != UndefinedType) {
1264 1265
          slot.setCustom(this, formNameGetter);
          return true;
George Staikos's avatar
George Staikos committed
1266
      }
1267 1268 1269 1270 1271
      
      // Try with past names map
      if (HTMLGenericFormElementImpl* r = form.lookupByPastName(propertyName.domString())) 
	  return getImmediateValueSlot(this, getDOMNode(exec, r), slot);
      
George Staikos's avatar
George Staikos committed
1272 1273 1274 1275 1276 1277 1278 1279 1280
      break;
    }
    case ID_SELECT:
      if (getIndexSlot(this, propertyName, slot))
        return true;
      break;
    case ID_APPLET:
    case ID_OBJECT:
    case ID_EMBED: {
1281 1282 1283
      KParts::ScriptableExtension* se = getScriptableExtension(*impl());
      if (pluginRootGet(exec, se, propertyName, slot))
        return true;
George Staikos's avatar
George Staikos committed
1284
      break;
1285
    }
George Staikos's avatar
George Staikos committed
1286 1287 1288
  }

  const HashTable* table = classInfo()->propHashTable; // get the right hashtable
1289
  if (table && getStaticOwnPropertySlot<HTMLElementFunction, HTMLElement>(table, this, propertyName, slot))
George Staikos's avatar
George Staikos committed
1290 1291 1292 1293 1294 1295 1296
    return true;

  // Base HTMLElement stuff or parent class forward, as usual
  return getStaticPropertySlot<KJS::HTMLElementFunction, KJS::HTMLElement, DOMElement>(
    exec, &KJS::HTMLElementTable, this, propertyName, slot);
}

Harri Porten's avatar
Harri Porten committed
1297
JSValue* HTMLElement::indexGetter(ExecState *exec, unsigned index)
George Staikos's avatar
George Staikos committed
1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312
{
  switch (impl()->id())
  {
    case ID_FORM: {
      DOM::HTMLFormElementImpl* form = static_cast<DOM::HTMLFormElementImpl*>(impl());
      SharedPtr<DOM::HTMLCollectionImpl> elems = form->elements();
      return getDOMNode(exec, elems->item(index));
    }
  case ID_SELECT: {
      DOM::HTMLSelectElementImpl* select = static_cast<DOM::HTMLSelectElementImpl*>(impl());
      SharedPtr<DOM::HTMLCollectionImpl> opts = select->options();
      return getDOMNode(exec, opts->item(index)); // not specified by DOM(?) but supported in netscape/IE
    }
  default:
    assert(0);
Harri Porten's avatar
Harri Porten committed
1313
    return jsUndefined();
George Staikos's avatar
George Staikos committed
1314 1315 1316 1317 1318 1319 1320 1321 1322 1323
  }
}

#if 0
  // First look at dynamic properties
  switch (element.id()) {
    case ID_FORM: {
      DOM::HTMLFormElementImpl& form = static_cast<DOM::HTMLFormElementImpl&>(element);
      // Check if we're retrieving an element (by index or by name)
      KJS::HTMLCollection coll(exec, form.elements());
Harri Porten's avatar
Harri Porten committed
1324
      JSValue *namedItems = coll.getNamedItems(exec, propertyName);
George Staikos's avatar
George Staikos committed
1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456
      if (namedItems->type() != UndefinedType)
        return namedItems;
    }
  }

#endif

/**
 Table of how to connect JS tokens to attributes
*/
const KJS::HTMLElement::BoundPropInfo KJS::HTMLElement::bpTable[] = {
  {ID_HTML, HtmlVersion, T_String, ATTR_VERSION},
  {ID_HEAD, HeadProfile, T_String, ATTR_PROFILE},
  {ID_LINK, LinkDisabled, T_Bool, ATTR_DISABLED},
  {ID_LINK, LinkCharset,  T_String, ATTR_CHARSET},
  {ID_LINK, LinkHref,     T_URL,    ATTR_HREF},
  {ID_LINK, LinkHrefLang, T_String, ATTR_HREFLANG},
  {ID_LINK, LinkMedia,    T_String, ATTR_MEDIA},
  {ID_LINK, LinkRel,      T_String, ATTR_REL},
  {ID_LINK, LinkRev,      T_String, ATTR_REV},
  {ID_LINK, LinkTarget,   T_String, ATTR_TARGET},
  {ID_LINK, LinkType,     T_String, ATTR_TYPE},
  {ID_BASE, BaseHref,     T_URL,    ATTR_HREF},
  {ID_BASE, BaseTarget,   T_String, ATTR_TARGET},
  {ID_META, MetaContent,  T_String, ATTR_CONTENT},
  {ID_META, MetaHttpEquiv,T_String, ATTR_HTTP_EQUIV},
  {ID_META, MetaName,     T_String, ATTR_NAME},
  {ID_META, MetaScheme,   T_String, ATTR_SCHEME},
  {ID_STYLE, StyleDisabled, T_Bool, ATTR_DISABLED},
  {ID_STYLE, StyleMedia,  T_String, ATTR_MEDIA},
  {ID_STYLE, StyleType,   T_String, ATTR_TYPE},
  {ID_BODY,  BodyALink,   T_String, ATTR_ALINK},
  {ID_BODY,  BodyBackground, T_String, ATTR_BACKGROUND},
  {ID_BODY,  BodyBgColor,    T_String, ATTR_BGCOLOR},
  {ID_BODY,  BodyLink,    T_String, ATTR_LINK},
  {ID_BODY,  BodyText,       T_String, ATTR_TEXT},//### odd?
  {ID_BODY,  BodyVLink,      T_String, ATTR_VLINK},
  {ID_FORM,  FormName,       T_String, ATTR_NAME}, // NOT getString (IE gives empty string)
  {ID_FORM,  FormAcceptCharset, T_String, ATTR_ACCEPT_CHARSET},
  {ID_FORM,  FormAction,     T_String, ATTR_ACTION},
  {ID_FORM,  FormEncType,    T_String, ATTR_ENCTYPE},
  {ID_FORM,  FormMethod,     T_String, ATTR_METHOD},
  {ID_FORM,  FormTarget,     T_String, ATTR_TARGET},
  {ID_SELECT, SelectDisabled, T_Bool,  ATTR_DISABLED},
  {ID_SELECT, SelectMultiple, T_Bool,  ATTR_MULTIPLE},
  {ID_SELECT, SelectSize,     T_Int,   ATTR_SIZE}, //toInt on attr, then number
  {ID_OPTGROUP, OptGroupDisabled, T_Bool, ATTR_DISABLED},
  {ID_OPTGROUP, OptGroupLabel,    T_String, ATTR_LABEL},
  {ID_OPTION, OptionDefaultSelected, T_Bool, ATTR_SELECTED},
  {ID_OPTION, OptionDisabled, T_Bool,   ATTR_DISABLED},
  {ID_OPTION, OptionLabel,    T_String, ATTR_LABEL},
  {ID_INPUT,  InputDefaultValue,   T_String, ATTR_VALUE},
  {ID_INPUT,  InputDefaultChecked, T_Bool,   ATTR_CHECKED},
  {ID_INPUT,  InputAccept,    T_String, ATTR_ACCEPT},
  {ID_INPUT,  InputAccessKey, T_String, ATTR_ACCESSKEY},
  {ID_INPUT,  InputAlign,     T_String, ATTR_ALIGN},
  {ID_INPUT,  InputAlt,       T_String, ATTR_ALT},
  {ID_INPUT,  InputDisabled,  T_Bool,   ATTR_DISABLED},
  {ID_INPUT,  InputMaxLength, T_Int,    ATTR_MAXLENGTH},
  {ID_INPUT,  InputReadOnly,  T_Bool,   ATTR_READONLY},
  {ID_INPUT,  InputSize,      T_Int,    ATTR_SIZE},
  {ID_INPUT,  InputSrc,       T_URL,    ATTR_SRC},
  {ID_INPUT,  InputUseMap,    T_String, ATTR_USEMAP},
  {ID_TEXTAREA, TextAreaAccessKey, T_String, ATTR_ACCESSKEY},
  {ID_TEXTAREA, TextAreaCols, T_Int, ATTR_COLS},
  {ID_TEXTAREA, TextAreaDisabled, T_Bool, ATTR_DISABLED},
  {ID_TEXTAREA, TextAreaReadOnly, T_Bool, ATTR_READONLY},
  {ID_TEXTAREA, TextAreaRows, T_Int,  ATTR_ROWS},
  {ID_BUTTON,   ButtonAccessKey, T_String, ATTR_ACCESSKEY},
  {ID_BUTTON,   ButtonDisabled, T_Bool  , ATTR_DISABLED},
  {ID_BUTTON,   ButtonName,     T_String, ATTR_NAME},
  {ID_BUTTON,   ButtonValue,    T_String, ATTR_VALUE},
  {ID_LABEL,    LabelAccessKey, T_String, ATTR_ACCESSKEY},
  {ID_LABEL,    LabelHtmlFor,   T_String, ATTR_FOR},
  {ID_LEGEND,   LegendAccessKey, T_String, ATTR_ACCESSKEY},
  {ID_LEGEND,   LegendAlign,     T_String, ATTR_ALIGN},
  {ID_UL,       UListCompact,    T_Bool,   ATTR_COMPACT},
  {ID_UL,       UListType,       T_String, ATTR_TYPE},
  {ID_OL,       OListCompact,    T_Bool,   ATTR_COMPACT},
  {ID_OL,       OListStart,      T_Int,    ATTR_START},
  {ID_OL,       OListType,       T_String, ATTR_TYPE},
  {ID_DL,       DListCompact,    T_Bool,   ATTR_COMPACT},
  {ID_DIR,      DirectoryCompact, T_Bool,  ATTR_COMPACT},
  {ID_MENU,     MenuCompact,      T_Bool,  ATTR_COMPACT},
  {ID_LI,       LIType,           T_String, ATTR_TYPE},
  {ID_LI,       LIValue,          T_Int,    ATTR_VALUE},
  {ID_DIV,      DivAlign,         T_String, ATTR_ALIGN},
  {ID_P,        ParagraphAlign,