Commit 8f521e29 authored by andersca's avatar andersca

WebCore:

        Reviewed by Adam.

        Move addMessageToConsole to Chrome.
        
        * bindings/js/kjs_events.cpp:
        (KJS::JSAbstractEventListener::handleEvent):
        * bindings/js/kjs_proxy.cpp:
        (WebCore::KJSProxy::evaluate):
        * bindings/js/kjs_window.cpp:
        (KJS::Window::isSafeScript):
        (KJS::ScheduledAction::execute):
        * bridge/mac/FrameMac.h:
        * bridge/mac/FrameMac.mm:
        * bridge/mac/WebCoreFrameBridge.h:
        * page/Chrome.cpp:
        (WebCore::Chrome::addMessageToConsole):
        * page/Chrome.h:
        * page/ChromeClient.h:
        * page/Frame.h:

WebKit:

        Reviewed by Adam.

        Move addMessageToConsole to Chrome.

        * WebCoreSupport/WebChromeClient.h:
        * WebCoreSupport/WebChromeClient.mm:
        (WebChromeClient::addMessageToConsole):
        * WebCoreSupport/WebFrameBridge.mm:



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@17886 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 1a60e775
2006-11-27 Anders Carlsson <acarlsson@apple.com>
Reviewed by Adam.
Move addMessageToConsole to Chrome.
* bindings/js/kjs_events.cpp:
(KJS::JSAbstractEventListener::handleEvent):
* bindings/js/kjs_proxy.cpp:
(WebCore::KJSProxy::evaluate):
* bindings/js/kjs_window.cpp:
(KJS::Window::isSafeScript):
(KJS::ScheduledAction::execute):
* bridge/mac/FrameMac.h:
* bridge/mac/FrameMac.mm:
* bridge/mac/WebCoreFrameBridge.h:
* page/Chrome.cpp:
(WebCore::Chrome::addMessageToConsole):
* page/Chrome.h:
* page/ChromeClient.h:
* page/Frame.h:
2006-11-27 Adele Peterson <adele@apple.com>
Reviewed by Hyatt.
......@@ -21,6 +21,7 @@
#include "config.h"
#include "kjs_events.h"
#include "Chrome.h"
#include "CString.h"
#include "Clipboard.h"
#include "ClipboardEvent.h"
......@@ -42,6 +43,7 @@
#include "MouseEvent.h"
#include "MutationEvent.h"
#include "OverflowEvent.h"
#include "Page.h"
#include "UIEvent.h"
#include "WheelEvent.h"
#include "kjs_proxy.h"
......@@ -130,7 +132,8 @@ void JSAbstractEventListener::handleEvent(Event* ele, bool isWindowEvent)
String sourceURL = exception->get(exec, "sourceURL")->toString(exec);
if (Interpreter::shouldPrintExceptions())
printf("(event handler):%s\n", message.utf8().data());
frame->addMessageToConsole(message, lineNumber, sourceURL);
if (Page* page = frame->page())
page->chrome()->addMessageToConsole(message, lineNumber, sourceURL);
exec->clearException();
} else {
if (!retval->isUndefinedOrNull() && event->storesResultAsString())
......
......@@ -21,11 +21,13 @@
#include "config.h"
#include "kjs_proxy.h"
#include "Chrome.h"
#include "kjs_events.h"
#include "kjs_window.h"
#include "Frame.h"
#include "FrameLoader.h"
#include "JSDOMWindow.h"
#include "Page.h"
#ifdef SVG_SUPPORT
#include "JSSVGLazyEventListener.h"
......@@ -76,7 +78,7 @@ JSValue* KJSProxy::evaluate(const String& filename, int baseLine, const String&
UString errorMessage = comp.value()->toString(m_script->globalExec());
int lineNumber = comp.value()->toObject(m_script->globalExec())->get(m_script->globalExec(), "line")->toInt32(m_script->globalExec());
UString sourceURL = comp.value()->toObject(m_script->globalExec())->get(m_script->globalExec(), "sourceURL")->toString(m_script->globalExec());
m_frame->addMessageToConsole(errorMessage, lineNumber, sourceURL);
m_frame->page()->chrome()->addMessageToConsole(errorMessage, lineNumber, sourceURL);
}
return 0;
......
......@@ -1215,7 +1215,8 @@ bool Window::isSafeScript(const ScriptInterpreter *origin, const ScriptInterpret
}
String message = String::format("Unsafe JavaScript attempt to access frame with URL %s from frame with URL %s. Domains must match.\n",
targetDocument->URL().latin1(), originDocument->URL().latin1());
targetFrame->addMessageToConsole(message, 1, String()); //fixme: provide a real line number and sourceurl
if (Page* page = targetFrame->page())
page->chrome()->addMessageToConsole(message, 1, String()); //fixme: provide a real line number and sourceurl
return false;
}
......@@ -1275,7 +1276,8 @@ bool Window::isSafeScript(ExecState *exec) const
}
String message = String::format("Unsafe JavaScript attempt to access frame with URL %s from frame with URL %s. Domains must match.\n",
thisDocument->URL().latin1(), actDocument->URL().latin1());
m_frame->addMessageToConsole(message, 1, String());
if (Page* page = m_frame->page())
page->chrome()->addMessageToConsole(message, 1, String());
return false;
}
......@@ -1810,7 +1812,8 @@ void ScheduledAction::execute(Window *window)
int lineNumber = exception->get(exec, "line")->toInt32(exec);
if (Interpreter::shouldPrintExceptions())
printf("(timer):%s\n", message.utf8().data());
window->m_frame->addMessageToConsole(message, lineNumber, String());
if (Page* page = window->m_frame->page())
page->chrome()->addMessageToConsole(message, lineNumber, String());
}
}
} else
......
......@@ -142,8 +142,6 @@ public:
virtual void focusWindow();
virtual void unfocusWindow();
virtual void addMessageToConsole(const String& message, unsigned int lineNumber, const String& sourceID);
virtual void runJavaScriptAlert(const String&);
virtual bool runJavaScriptConfirm(const String&);
virtual bool runJavaScriptPrompt(const String& message, const String& defaultValue, String& result);
......
......@@ -730,16 +730,6 @@ bool FrameMac::shouldInterruptJavaScript()
return false;
}
void FrameMac::addMessageToConsole(const String &message, unsigned lineNumber, const String &sourceURL)
{
NSDictionary *dictionary = [NSDictionary dictionaryWithObjectsAndKeys:
(NSString *)message, @"message",
[NSNumber numberWithInt: lineNumber], @"lineNumber",
(NSString *)sourceURL, @"sourceURL",
NULL];
[_bridge addMessageToConsole:dictionary];
}
// Returns whether caller should continue with "the default processing", which is the same as
// the event handler NOT setting the return value to false
bool FrameMac::dispatchCPPEvent(const AtomicString &eventType, ClipboardAccessPolicy policy)
......
......@@ -320,7 +320,6 @@ typedef enum {
- (BOOL)shouldInterruptJavaScript;
- (BOOL)canRunBeforeUnloadConfirmPanel;
- (BOOL)runBeforeUnloadConfirmPanelWithMessage:(NSString *)message;
- (void)addMessageToConsole:(NSDictionary *)message;
- (void)runOpenPanelForFileButtonWithResultListener:(id <WebCoreOpenPanelResultListener>)resultListener;
- (void)formControlIsBecomingFirstResponder:(NSView *)formControl;
......
......@@ -170,5 +170,10 @@ void Chrome::setResizable(bool b) const
m_client->setResizable(b);
}
void Chrome::addMessageToConsole(const String &message, unsigned lineNumber, const String &sourceURL)
{
m_client->addMessageToConsole(message, lineNumber, sourceURL);
}
} // namespace WebCore
......@@ -30,6 +30,7 @@ namespace WebCore {
class ContextMenu;
class FloatRect;
class Page;
class String;
struct FrameLoadRequest;
class Chrome {
......@@ -70,6 +71,8 @@ namespace WebCore {
void setResizable(bool) const;
void addMessageToConsole(const String& message, unsigned int lineNumber, const String& sourceID);
private:
Page* m_page;
RefPtr<ChromeClient> m_client;
......
......@@ -27,7 +27,8 @@ namespace WebCore {
class FloatRect;
class Page;
class String;
struct FrameLoadRequest;
class ChromeClient : public AbstractShared {
......@@ -62,6 +63,8 @@ namespace WebCore {
virtual bool menubarVisible() = 0;
virtual void setResizable(bool) = 0;
virtual void addMessageToConsole(const String& message, unsigned int lineNumber, const String& sourceID) = 0;
};
}
......
......@@ -220,8 +220,6 @@ private:
// === to be moved into Chrome
public:
virtual void addMessageToConsole(const String& message, unsigned int lineNumber, const String& sourceID) = 0;
virtual void runJavaScriptAlert(const String& message) = 0;
virtual bool runJavaScriptConfirm(const String& message) = 0;
virtual bool runJavaScriptPrompt(const String& message, const String& defaultValue, String& result) = 0;
......
2006-11-27 Anders Carlsson <acarlsson@apple.com>
Reviewed by Adam.
Move addMessageToConsole to Chrome.
* WebCoreSupport/WebChromeClient.h:
* WebCoreSupport/WebChromeClient.mm:
(WebChromeClient::addMessageToConsole):
* WebCoreSupport/WebFrameBridge.mm:
2006-11-27 Brady Eidson <beidson@apple.com>
Reviewed by Anders
......
......@@ -72,6 +72,8 @@ public:
virtual void setResizable(bool);
virtual void addMessageToConsole(const WebCore::String& message, unsigned int lineNumber, const WebCore::String& sourceID);
private:
WebChromeClient(WebView *webView);
......
......@@ -33,10 +33,12 @@
#import "WebFrameView.h"
#import "WebNSURLRequestExtras.h"
#import "WebUIDelegate.h"
#import "WebUIDelegatePrivate.h"
#import "WebView.h"
#import "WebViewInternal.h"
#import <WebCore/FloatRect.h>
#import <WebCore/FrameLoadRequest.h>
#import <WebCore/PlatformString.h>
#import <WebCore/ResourceRequestMac.h>
#import <WebCore/Screen.h>
#import <wtf/PassRefPtr.h>
......@@ -202,3 +204,18 @@ void WebChromeClient::setResizable(bool b)
[[m_webView _UIDelegateForwarder] webView:m_webView setResizable:b];
}
void WebChromeClient::addMessageToConsole(const String& message, unsigned int lineNumber, const String& sourceURL)
{
id wd = [m_webView UIDelegate];
if ([wd respondsToSelector:@selector(webView:addMessageToConsole:)]) {
NSDictionary *dictionary = [NSDictionary dictionaryWithObjectsAndKeys:
(NSString *)message, @"message",
[NSNumber numberWithInt: lineNumber], @"lineNumber",
(NSString *)sourceURL, @"sourceURL",
NULL];
[wd webView:m_webView addMessageToConsole:dictionary];
}
}
......@@ -368,14 +368,6 @@ NSString *WebPluginContainerKey = @"WebPluginContainer";
return *result != nil;
}
- (void)addMessageToConsole:(NSDictionary *)message
{
WebView *wv = [self webView];
id wd = [wv UIDelegate];
if ([wd respondsToSelector:@selector(webView:addMessageToConsole:)])
[wd webView:wv addMessageToConsole:message];
}
- (void)runOpenPanelForFileButtonWithResultListener:(id<WebCoreOpenPanelResultListener>)resultListener
{
WebView *wv = [self webView];
......
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