Add focus, blur and close functions to DOMWindow implementation class
and move bindings from Window to JSDOMWindow.
* bindings/js/JSDOMWindowCustom.cpp:
(WebCore::JSDOMWindow::customGetOwnPropertySlot):
* bindings/js/kjs_window.cpp:
(KJS::Window::getOwnPropertySlot):
(KJS::WindowFunc::callAsFunction):
* bindings/js/kjs_window.h:
(KJS::Window::):
* bindings/scripts/CodeGeneratorJS.pm: Move prototype function declaration from
the implementation to the header.
* page/DOMWindow.cpp:
(WebCore::DOMWindow::focus):
(WebCore::DOMWindow::blur):
(WebCore::DOMWindow::close):
* page/DOMWindow.h:
* page/DOMWindow.idl:
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@24028
268f45cc-cd09-0410-ab3c-
d52691b4dbfc
+2007-07-05 Sam Weinig <sam@webkit.org>
+
+ Reviewed by Geoff.
+
+ Add focus, blur and close functions to DOMWindow implementation class
+ and move bindings from Window to JSDOMWindow.
+
+ * bindings/js/JSDOMWindowCustom.cpp:
+ (WebCore::JSDOMWindow::customGetOwnPropertySlot):
+ * bindings/js/kjs_window.cpp:
+ (KJS::Window::getOwnPropertySlot):
+ (KJS::WindowFunc::callAsFunction):
+ * bindings/js/kjs_window.h:
+ (KJS::Window::):
+ * bindings/scripts/CodeGeneratorJS.pm: Move prototype function declaration from
+ the implementation to the header.
+ * page/DOMWindow.cpp:
+ (WebCore::DOMWindow::focus):
+ (WebCore::DOMWindow::blur):
+ (WebCore::DOMWindow::close):
+ * page/DOMWindow.h:
+ * page/DOMWindow.idl:
+
2007-07-05 Justin Garcia <justin.garcia@apple.com>
Reviewed by Harrison.
// we don't want any properties other than "closed" on a closed window
if (!frame()) {
if (propertyName == "closed") {
- slot.setStaticEntry(this, KJS::Lookup::findEntry(KJS::Window::classInfo()->propHashTable, "closed"), KJS::staticValueGetter<KJS::Window>);
- return true;
+ const KJS::HashEntry* entry = KJS::Lookup::findEntry(KJS::Window::classInfo()->propHashTable, propertyName);
+ ASSERT(entry);
+ if (entry) {
+ slot.setStaticEntry(this, entry, KJS::staticValueGetter<KJS::Window>);
+ return true;
+ }
}
if (propertyName == "close") {
- const KJS::HashEntry* entry = KJS::Lookup::findEntry(KJS::Window::classInfo()->propHashTable, propertyName);
- slot.setStaticEntry(this, entry, KJS::staticFunctionGetter<KJS::WindowFunc>);
- return true;
+ KJS::JSValue* proto = prototype();
+ if (proto->isObject()) {
+ const KJS::HashEntry* entry = KJS::Lookup::findEntry(static_cast<KJS::JSObject*>(proto)->classInfo()->propHashTable, propertyName);
+ ASSERT(entry);
+ if (entry) {
+ slot.setStaticEntry(this, entry, KJS::staticFunctionGetter<JSDOMWindowPrototypeFunction>);
+ return true;
+ }
+ }
}
slot.setUndefined(this);
return true;
}
+ // FIXME: We need this to work around the blanket isSafeScript check in KJS::Window. Once we remove that, we
+ // can move this to JSDOMWindowPrototype.
+ KJS::JSValue* proto = prototype();
+ if (proto->isObject()) {
+ const KJS::HashEntry* entry = KJS::Lookup::findEntry(static_cast<KJS::JSObject*>(proto)->classInfo()->propHashTable, propertyName);
+ if (entry) {
+ if (entry->attr & KJS::Function) {
+ switch (entry->value) {
+ case FocusFuncNum:
+ case BlurFuncNum:
+ case CloseFuncNum:
+ slot.setStaticEntry(this, entry, KJS::staticFunctionGetter<JSDOMWindowPrototypeFunction>);
+ return true;
+ }
+ }
+ }
+ }
+
return false;
}
print Window::Print DontDelete|Function 2
setTimeout Window::SetTimeout DontDelete|Function 2
clearTimeout Window::ClearTimeout DontDelete|Function 1
- focus Window::Focus DontDelete|Function 0
- blur Window::Blur DontDelete|Function 0
- close Window::Close DontDelete|Function 0
setInterval Window::SetInterval DontDelete|Function 2
clearInterval Window::ClearInterval DontDelete|Function 1
captureEvents Window::CaptureEvents DontDelete|Function 0
if (entry) {
if (entry->attr & Function) {
switch (entry->value) {
- case Focus:
- case Blur:
- case Close:
- slot.setStaticEntry(this, entry, staticFunctionGetter<WindowFunc>);
- break;
case ShowModalDialog:
if (!canShowModalDialog(this))
return false;
return jsUndefined();
(const_cast<Window*>(window))->clearTimeout(v->toInt32(exec));
return jsUndefined();
- case Window::Focus:
- frame->focusWindow();
- return jsUndefined();
- case Window::Blur:
- frame->unfocusWindow();
- return jsUndefined();
- case Window::Close:
- // Do not close windows that have history unless they were opened by JavaScript.
- if (frame->loader()->openedByDOM() || frame->loader()->getHistoryLength() <= 1)
- const_cast<Window*>(window)->scheduleClose();
- return jsUndefined();
case Window::CaptureEvents:
case Window::ReleaseEvents:
// If anyone implements these, they need the safe script security check.
ScreenTop, ScreenLeft,
ScrollTo, ScrollX, ScrollY, MoveBy, MoveTo, ResizeBy, ResizeTo, Self, Window_, Top,
Image, Option, Alert, Confirm, Prompt, Open, Print, SetTimeout, ClearTimeout,
- Focus, Blur, Close, SetInterval, ClearInterval, CaptureEvents,
+ SetInterval, ClearInterval, CaptureEvents,
ReleaseEvents, AddEventListener, RemoveEventListener,
XMLHttpRequest, XSLTProcessor_,
Onabort, Onblur, Onchange, Onclick, Ondblclick, Onerror,
}
push(@headerContent, "};\n\n");
- push(@headerContent, "}\n\n");
+
+ if ($numFunctions > 0) {
+ push(@headerContent, prototypeFunctionFor($className));
+ }
+
+ push(@headerContent, "} // namespace WebCore\n\n");
push(@headerContent, "#endif // ${conditionalString}\n\n") if $conditional;
push(@headerContent, "#endif\n");
}
\@hashKeys, \@hashValues,
\@hashSpecials, \@hashParameters);
- if ($numFunctions > 0) {
- push(@implContent, prototypeFunctionFor($className));
- }
-
push(@implContent, "const ClassInfo ${className}Prototype::info = { \"${interfaceName}Prototype\", 0, &${className}PrototypeTable, 0 };\n\n");
if ($dataNode->extendedAttributes->{"DoNotCache"}) {
push(@implContent, "JSObject* ${className}Prototype::self()\n");
$implIncludes{"EventTargetNode.h"} = 1;
$implIncludes{"JSEventTargetNode.h"} = 1;
$implIncludes{"kjs_dom.h"} = 1;
- } elsif ($type eq "HTMLCanvasElement") {
- $implIncludes{"kjs_dom.h"} = 1;
- $implIncludes{"HTMLCanvasElement.h"} = 1;
} elsif ($type eq "DOMWindow") {
$implIncludes{"kjs_window.h"} = 1;
} elsif ($type eq "DOMObject") {
my $className = shift;
my $implContent = << "EOF";
-class ${className}PrototypeFunction : public InternalFunctionImp {
+class ${className}PrototypeFunction : public KJS::InternalFunctionImp {
public:
- ${className}PrototypeFunction(ExecState* exec, int i, int len, const Identifier& name)
- : InternalFunctionImp(static_cast<FunctionPrototype*>(exec->lexicalInterpreter()->builtinFunctionPrototype()), name)
+ ${className}PrototypeFunction(KJS::ExecState* exec, int i, int len, const KJS::Identifier& name)
+ : KJS::InternalFunctionImp(static_cast<KJS::FunctionPrototype*>(exec->lexicalInterpreter()->builtinFunctionPrototype()), name)
, id(i)
{
- put(exec, exec->propertyNames().length, jsNumber(len), DontDelete|ReadOnly|DontEnum);
+ put(exec, exec->propertyNames().length, KJS::jsNumber(len), KJS::DontDelete|KJS::ReadOnly|KJS::DontEnum);
}
- virtual JSValue* callAsFunction(ExecState*, JSObject*, const List&);
+ virtual KJS::JSValue* callAsFunction(KJS::ExecState*, KJS::JSObject*, const KJS::List&);
+
private:
int id;
};
return m_selection.get();
}
+void DOMWindow::focus()
+{
+ if (!m_frame)
+ return;
+ m_frame->focusWindow();
+}
+
+void DOMWindow::blur()
+{
+ if (!m_frame)
+ return;
+ m_frame->unfocusWindow();
+}
+
+void DOMWindow::close()
+{
+ if (!m_frame)
+ return;
+
+ if (m_frame->loader()->openedByDOM() || m_frame->loader()->getHistoryLength() <= 1)
+ m_frame->scheduleClose();
+}
+
Document* DOMWindow::document() const
{
if (!m_frame)
DOMSelection* getSelection();
+ void focus();
+ void blur();
+ void close();
+
// DOM Level 2 AbstractView Interface
Document* document() const;
DOMSelection getSelection();
+ [DoNotCheckDomainSecurity] void focus();
+ [DoNotCheckDomainSecurity] void blur();
+ [DoNotCheckDomainSecurity] void close();
+
// DOM Level 2 AbstractView Interface
readonly attribute Document document;