Commit c7521237 authored by weinig's avatar weinig

Reviewed by Adam.

        Move more functions from kjs_window to DOMWindow and auto-generate
        the bindings for them.

        * bindings/js/kjs_window.cpp:
        (KJS::WindowFunc::callAsFunction):
        * bindings/js/kjs_window.h:
        (KJS::Window::):
        * page/DOMWindow.cpp:
        (WebCore::DOMWindow::print):
        (WebCore::DOMWindow::stop):
        (WebCore::DOMWindow::alert):
        (WebCore::DOMWindow::confirm):
        (WebCore::DOMWindow::prompt):
        (WebCore::DOMWindow::find):
        * page/DOMWindow.h:
        * page/DOMWindow.idl:



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@24350 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 3af21cf7
2007-07-16 Sam Weinig <sam@webkit.org>
Reviewed by Adam.
Move more functions from kjs_window to DOMWindow and auto-generate
the bindings for them.
* bindings/js/kjs_window.cpp:
(KJS::WindowFunc::callAsFunction):
* bindings/js/kjs_window.h:
(KJS::Window::):
* page/DOMWindow.cpp:
(WebCore::DOMWindow::print):
(WebCore::DOMWindow::stop):
(WebCore::DOMWindow::alert):
(WebCore::DOMWindow::confirm):
(WebCore::DOMWindow::prompt):
(WebCore::DOMWindow::find):
* page/DOMWindow.h:
* page/DOMWindow.idl:
2007-07-17 Mark Rowe <mrowe@apple.com>
Gdk build fix.
......@@ -157,11 +157,7 @@ const ClassInfo Window::info = { "Window", 0, &WindowTable, 0 };
moveTo Window::MoveTo DontDelete|Function 2
resizeBy Window::ResizeBy DontDelete|Function 2
resizeTo Window::ResizeTo DontDelete|Function 2
alert Window::Alert DontDelete|Function 1
confirm Window::Confirm DontDelete|Function 1
prompt Window::Prompt DontDelete|Function 2
open Window::Open DontDelete|Function 3
print Window::Print DontDelete|Function 2
setTimeout Window::SetTimeout DontDelete|Function 2
clearTimeout Window::ClearTimeout DontDelete|Function 1
setInterval Window::SetInterval DontDelete|Function 2
......@@ -171,8 +167,6 @@ const ClassInfo Window::info = { "Window", 0, &WindowTable, 0 };
addEventListener Window::AddEventListener DontDelete|Function 3
removeEventListener Window::RemoveEventListener DontDelete|Function 3
showModalDialog Window::ShowModalDialog DontDelete|Function 1
find Window::Find DontDelete|Function 7
stop Window::Stop DontDelete|Function 0
# -- Attributes --
crypto Window::Crypto DontDelete|ReadOnly
frames Window::Frames DontDelete|ReadOnly
......@@ -297,16 +291,6 @@ Location *Window::location() const
return d->loc;
}
bool Window::find(const String& string, bool caseSensitive, bool backwards, bool wrap, bool wholeWord, bool searchInFrames, bool showDialog) const
{
// FIXME (13016): Support wholeWord, searchInFrames and showDialog
Frame* frame = impl()->frame();
if (!frame)
return false;
return frame->findString(string, !backwards, caseSensitive, wrap, false);
}
// reference our special objects during garbage collection
void Window::mark()
{
......@@ -1280,12 +1264,6 @@ JSValue *WindowFunc::callAsFunction(ExecState *exec, JSObject *thisObj, const Li
String str2;
switch (id) {
case Window::Alert:
if (frame && frame->document())
frame->document()->updateRendering();
if (page)
page->chrome()->runJavaScriptAlert(frame, str);
return jsUndefined();
case Window::AToB:
case Window::BToA: {
if (args.size() < 1)
......@@ -1310,24 +1288,6 @@ JSValue *WindowFunc::callAsFunction(ExecState *exec, JSObject *thisObj, const Li
return jsString(String(out.data(), out.size()));
}
case Window::Confirm: {
if (frame && frame->document())
frame->document()->updateRendering();
bool result = false;
if (page)
result = page->chrome()->runJavaScriptConfirm(frame, str);
return jsBoolean(result);
}
case Window::Prompt:
{
if (frame && frame->document())
frame->document()->updateRendering();
String message = args.size() >= 2 ? args[1]->toString(exec) : UString();
if (page && page->chrome()->runJavaScriptPrompt(frame, str, message, str2))
return jsString(str2);
return jsNull();
}
case Window::Open:
{
String urlString = valueToStringWithUndefinedOrNullCheck(exec, args[0]);
......@@ -1374,10 +1334,6 @@ JSValue *WindowFunc::callAsFunction(ExecState *exec, JSObject *thisObj, const Li
return Window::retrieve(frame); // global object
}
case Window::Print:
if (Page* page = frame->page())
page->chrome()->print(frame);
return jsUndefined();
case Window::ScrollBy:
window->updateLayout();
if(args.size() >= 2 && widget)
......@@ -1504,19 +1460,6 @@ JSValue *WindowFunc::callAsFunction(ExecState *exec, JSObject *thisObj, const Li
JSValue* result = showModalDialog(exec, window, args);
return result;
}
case Window::Stop:
frame->loader()->stopForUserCancel();
return jsUndefined();
case Window::Find:
if (!window->isSafeScript(exec))
return jsUndefined();
return jsBoolean(window->find(args[0]->toString(exec),
args[1]->toBoolean(exec),
args[2]->toBoolean(exec),
args[3]->toBoolean(exec),
args[4]->toBoolean(exec),
args[5]->toBoolean(exec),
args[6]->toBoolean(exec)));
}
return jsUndefined();
}
......
......@@ -107,8 +107,8 @@ namespace KJS {
bool isSafeScript(ExecState*) const;
static bool isSafeScript(const ScriptInterpreter *origin, const ScriptInterpreter *target);
Location *location() const;
bool find(const WebCore::String&, bool, bool, bool, bool, bool, bool) const;
Location* location() const;
// Finds a wrapper of a JS EventListener, returns 0 if no existing one.
WebCore::JSEventListener* findJSEventListener(JSValue*, bool html = false);
......@@ -143,13 +143,11 @@ namespace KJS {
enum {
// Functions
AToB, BToA, Alert, Confirm,
Prompt, Open, Print, SetTimeout,
AToB, BToA, Open, SetTimeout,
ClearTimeout, SetInterval, ClearInterval, CaptureEvents,
ReleaseEvents, AddEventListener, RemoveEventListener, Scroll,
ScrollBy, ScrollTo, MoveBy, MoveTo,
ResizeBy, ResizeTo, ShowModalDialog, Find,
Stop,
ResizeBy, ResizeTo, ShowModalDialog,
// Attributes
Crypto, Frames, Event_, Location_,
......
......@@ -171,6 +171,90 @@ void DOMWindow::close()
m_frame->scheduleClose();
}
void DOMWindow::print()
{
if (!m_frame)
return;
Page* page = m_frame->page();
if (!page)
return;
page->chrome()->print(m_frame);
}
void DOMWindow::stop()
{
if (!m_frame)
return;
m_frame->loader()->stopForUserCancel();
}
void DOMWindow::alert(const String& message)
{
if (!m_frame)
return;
Document* doc = m_frame->document();
ASSERT(doc);
if (doc)
doc->updateRendering();
Page* page = m_frame->page();
if (!page)
return;
page->chrome()->runJavaScriptAlert(m_frame, message);
}
bool DOMWindow::confirm(const String& message)
{
if (!m_frame)
return false;
Document* doc = m_frame->document();
ASSERT(doc);
if (doc)
doc->updateRendering();
Page* page = m_frame->page();
if (!page)
return false;
return page->chrome()->runJavaScriptConfirm(m_frame, message);
}
String DOMWindow::prompt(const String& message, const String& defaultValue)
{
if (!m_frame)
return String();
Document* doc = m_frame->document();
ASSERT(doc);
if (doc)
doc->updateRendering();
Page* page = m_frame->page();
if (!page)
return String();
String returnValue;
if (page->chrome()->runJavaScriptPrompt(m_frame, message, defaultValue, returnValue))
return returnValue;
return String();
}
bool DOMWindow::find(const String& string, bool caseSensitive, bool backwards, bool wrap, bool wholeWord, bool searchInFrames, bool showDialog) const
{
if (!m_frame)
return false;
// FIXME (13016): Support wholeWord, searchInFrames and showDialog
return m_frame->findString(string, !backwards, caseSensitive, wrap, false);
}
bool DOMWindow::offscreenBuffering() const
{
return true;
......
......@@ -66,6 +66,14 @@ namespace WebCore {
void focus();
void blur();
void close();
void print();
void stop();
void alert(const String& message);
bool confirm(const String& message);
String prompt(const String& message, const String& defaultValue);
bool find(const String&, bool caseSensitive, bool backwards, bool wrap, bool wholeWord, bool searchInFrames, bool showDialog) const;
bool offscreenBuffering() const;
......
......@@ -42,6 +42,22 @@ module window {
[DoNotCheckDomainSecurity] void blur();
[DoNotCheckDomainSecurity] void close();
void print();
void stop();
void alert(in DOMString message);
boolean confirm(in DOMString message);
[ConvertNullStringTo=Null] DOMString prompt(in [ConvertNullToNullString] DOMString message,
in [ConvertNullToNullString] DOMString defaultValue);
boolean find(in DOMString string,
in boolean caseSensitive,
in boolean backwards,
in boolean wrap,
in boolean wholeWord,
in boolean searchInFrames,
in boolean showDialog);
readonly attribute boolean offscreenBuffering;
readonly attribute long outerHeight;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment