1
// -*- c-basic-offset: 4 -*-
3
* This file is part of the KDE libraries
4
* Copyright (C) 1999-2000 Harri Porten (porten@kde.org)
5
* Copyright (C) 2004, 2005, 2006, 2007 Apple Inc. All rights reserved.
7
* This library is free software; you can redistribute it and/or
8
* modify it under the terms of the GNU Lesser General Public
9
* License as published by the Free Software Foundation; either
10
* version 2 of the License, or (at your option) any later version.
12
* This library is distributed in the hope that it will be useful,
13
* but WITHOUT ANY WARRANTY; without even the implied warranty of
14
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15
* Lesser General Public License for more details.
17
* You should have received a copy of the GNU Lesser General Public
18
* License along with this library; if not, write to the Free Software
19
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
26
#include "FrameLoader.h"
27
#include "JSHTMLElement.h"
28
#include "HTMLDocument.h"
29
#include "HTMLImageElement.h"
30
#include "kjs_proxy.h"
36
ImageConstructorImp::ImageConstructorImp(ExecState* exec, Document* doc)
39
setPrototype(exec->lexicalInterpreter()->builtinObjectPrototype());
42
JSObject* ImageConstructorImp::construct(ExecState* exec, const List& list)
44
bool widthSet = false;
45
bool heightSet = false;
49
if (list.size() > 0) {
51
JSValue* w = list.at(0);
52
width = w->toInt32(exec);
55
if (list.size() > 1) {
57
JSValue* h = list.at(1);
58
height = h->toInt32(exec);
61
HTMLImageElement* image = new HTMLImageElement(m_doc.get());
62
JSObject* result = static_cast<JSObject*>(toJS(exec, image));
65
image->setWidth(width);
67
image->setHeight(height);
72
// -------------------------------------------------------------------------
74
// Runtime object support code for JSHTMLAppletElement, JSHTMLEmbedElement and JSHTMLObjectElement.
76
JSValue* runtimeObjectGetter(ExecState* exec, JSObject* originalObject, const Identifier& propertyName, const PropertySlot& slot)
78
JSHTMLElement* thisObj = static_cast<JSHTMLElement*>(slot.slotBase());
79
HTMLElement* element = static_cast<HTMLElement*>(thisObj->impl());
81
return getRuntimeObject(exec, element);
84
JSValue* runtimeObjectPropertyGetter(ExecState* exec, JSObject* originalObject, const Identifier& propertyName, const PropertySlot& slot)
86
JSHTMLElement* thisObj = static_cast<JSHTMLElement*>(slot.slotBase());
87
HTMLElement* element = static_cast<HTMLElement*>(thisObj->impl());
89
if (JSValue* runtimeObject = getRuntimeObject(exec, element))
90
return static_cast<JSObject*>(runtimeObject)->get(exec, propertyName);
94
bool runtimeObjectCustomGetOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot, WebCore::JSHTMLElement* originalObj, HTMLElement* thisImp)
96
JSValue* runtimeObject = getRuntimeObject(exec, thisImp);
98
JSObject* imp = static_cast<JSObject*>(runtimeObject);
99
if (imp->hasProperty(exec, propertyName)) {
100
slot.setCustom(originalObj, runtimeObjectPropertyGetter);
108
bool runtimeObjectCustomPut(ExecState* exec, const Identifier& propertyName, JSValue* value, int /*attr*/, HTMLElement* thisImp)
110
if (JSValue* runtimeObject = getRuntimeObject(exec, thisImp)) {
111
JSObject* imp = static_cast<JSObject*>(runtimeObject);
112
if (imp->canPut(exec, propertyName)) {
113
imp->put(exec, propertyName, value);
121
bool runtimeObjectImplementsCall(HTMLElement* thisImp)
123
Frame* frame = thisImp->document()->frame();
126
KJSProxy* proxy = frame->scriptProxy();
127
ExecState* exec = proxy->interpreter()->globalExec();
128
if (JSValue* runtimeObject = getRuntimeObject(exec, thisImp))
129
return static_cast<JSObject*>(runtimeObject)->implementsCall();
134
JSValue* runtimeObjectCallAsFunction(ExecState* exec, JSObject* thisObj, const List& args, HTMLElement* thisImp)
136
if (JSValue* runtimeObject = getRuntimeObject(exec, thisImp))
137
return static_cast<JSObject*>(runtimeObject)->call(exec, thisObj, args);
138
return jsUndefined();
141
} // namespace WebCore