Commit ccd79ac2 authored by alp@webkit.org's avatar alp@webkit.org

2007-12-08 Luca Bruno <lethalman88@gmail.com>

        Reviewed by Alp Toker.

        http://bugs.webkit.org/show_bug.cgi?id=16346
        [GTK] Some webview parts must use the focused frame.

        Also update some old code.

        * WebView/webkitprivate.cpp:
        (getFrameFromView): removed

        * WebView/webkitprivate.h:
        (getFrameFromView): removed
        
        * WebView/webkitwebview.cpp:
        (webkit_web_view_expose_event):
        (webkit_web_view_key_press_event): use focused frame
        (webkit_web_view_key_release_event): use focused frame
        (webkit_web_view_button_press_event):
        (webkit_web_view_button_release_event):
        (webkit_web_view_motion_event):
        (webkit_web_view_scroll_event):
        (webkit_web_view_size_allocate):
        (webkit_web_view_set_scroll_adjustments):
        (webkit_web_view_execute_script):
        (webkit_web_view_stop_loading):
        (webkit_web_view_load_string):
        (webkit_web_view_reload):
        (webkit_web_view_open):
        (webkit_web_view_can_go_forward):
        (webkit_web_view_can_go_backward):
        (webkit_web_view_go_forward):
        (webkit_web_view_go_backward):

        * WebCoreSupport/EditorClientGtk.cpp:
        (WebKit::EditorClient::handleKeypress): fix for page up and page down keys for editable contents


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@28564 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent f35b90a7
2007-12-08 Luca Bruno <lethalman88@gmail.com>
Reviewed by Alp Toker.
http://bugs.webkit.org/show_bug.cgi?id=16346
[GTK] Some webview parts must use the focused frame.
Also update some old code.
* WebView/webkitprivate.cpp:
(getFrameFromView): removed
* WebView/webkitprivate.h:
(getFrameFromView): removed
* WebView/webkitwebview.cpp:
(webkit_web_view_expose_event):
(webkit_web_view_key_press_event): use focused frame
(webkit_web_view_key_release_event): use focused frame
(webkit_web_view_button_press_event):
(webkit_web_view_button_release_event):
(webkit_web_view_motion_event):
(webkit_web_view_scroll_event):
(webkit_web_view_size_allocate):
(webkit_web_view_set_scroll_adjustments):
(webkit_web_view_execute_script):
(webkit_web_view_stop_loading):
(webkit_web_view_load_string):
(webkit_web_view_reload):
(webkit_web_view_open):
(webkit_web_view_can_go_forward):
(webkit_web_view_can_go_backward):
(webkit_web_view_go_forward):
(webkit_web_view_go_backward):
* WebCoreSupport/EditorClientGtk.cpp:
(WebKit::EditorClient::handleKeypress): fix for page up and page down keys for editable contents
2007-12-07 Luca Bruno <lethalman88@gmail.com>
Reviewed by Alp Toker.
......
......@@ -270,7 +270,9 @@ void EditorClient::handleKeypress(KeyboardEvent* event)
frame->editor()->execCommand("MoveDownByPageAndModifyCaret");
break;
case VK_HOME:
if (kevent->ctrlKey())
if (kevent->ctrlKey() && kevent->shiftKey())
frame->editor()->execCommand("MoveToBeginningOfDocumentAndModifySelection");
else if (kevent->ctrlKey())
frame->editor()->execCommand("MoveToBeginningOfDocument");
else if (kevent->shiftKey())
frame->editor()->execCommand("MoveToBeginningOfLineAndModifySelection");
......@@ -278,7 +280,9 @@ void EditorClient::handleKeypress(KeyboardEvent* event)
frame->editor()->execCommand("MoveToBeginningOfLine");
break;
case VK_END:
if (kevent->ctrlKey())
if (kevent->ctrlKey() && kevent->shiftKey())
frame->editor()->execCommand("MoveToEndOfDocumentAndModifySelection");
else if (kevent->ctrlKey())
frame->editor()->execCommand("MoveToEndOfDocument");
else if (kevent->shiftKey())
frame->editor()->execCommand("MoveToEndOfLineAndModifySelection");
......
......@@ -39,11 +39,6 @@ WebKitSettings* create(WebCore::Settings*)
return 0;
}
WebKitWebFrame* getFrameFromView(WebKitWebView* webView)
{
return webkit_web_view_get_main_frame(webView);
}
WebKitWebView* getViewFromFrame(WebKitWebFrame* frame)
{
return webkit_web_frame_get_web_view(frame);
......
......@@ -40,7 +40,6 @@
namespace WebKit {
void apply(WebKitSettings*,WebCore::Settings*);
WebKitSettings* create(WebCore::Settings*);
WebKitWebFrame* getFrameFromView(WebKitWebView*);
WebKitWebView* getViewFromFrame(WebKitWebFrame*);
WebCore::Frame* core(WebKitWebFrame*);
......
......@@ -89,7 +89,7 @@ G_DEFINE_TYPE(WebKitWebView, webkit_web_view, GTK_TYPE_CONTAINER)
static gboolean webkit_web_view_expose_event(GtkWidget* widget, GdkEventExpose* event)
{
Frame* frame = core(getFrameFromView(WEBKIT_WEB_VIEW(widget)));
Frame* frame = core(webkit_web_view_get_main_frame(WEBKIT_WEB_VIEW(widget)));
GdkRectangle clip;
gdk_region_get_clipbox(event->region, &clip);
cairo_t* cr = gdk_cairo_create(event->window);
......@@ -106,7 +106,7 @@ static gboolean webkit_web_view_expose_event(GtkWidget* widget, GdkEventExpose*
static gboolean webkit_web_view_key_press_event(GtkWidget* widget, GdkEventKey* event)
{
Frame* frame = core(getFrameFromView(WEBKIT_WEB_VIEW(widget)));
Frame* frame = core(WEBKIT_WEB_VIEW(widget))->focusController()->focusedOrMainFrame();
PlatformKeyboardEvent keyboardEvent(event);
if (frame->eventHandler()->keyEvent(keyboardEvent))
......@@ -148,7 +148,7 @@ static gboolean webkit_web_view_key_press_event(GtkWidget* widget, GdkEventKey*
static gboolean webkit_web_view_key_release_event(GtkWidget* widget, GdkEventKey* event)
{
Frame* frame = core(getFrameFromView(WEBKIT_WEB_VIEW(widget)));
Frame* frame = core(WEBKIT_WEB_VIEW(widget))->focusController()->focusedOrMainFrame();
PlatformKeyboardEvent keyboardEvent(event);
if (frame->eventHandler()->keyEvent(keyboardEvent))
......@@ -160,7 +160,7 @@ static gboolean webkit_web_view_key_release_event(GtkWidget* widget, GdkEventKey
static gboolean webkit_web_view_button_press_event(GtkWidget* widget, GdkEventButton* event)
{
Frame* frame = core(getFrameFromView(WEBKIT_WEB_VIEW(widget)));
Frame* frame = core(webkit_web_view_get_main_frame(WEBKIT_WEB_VIEW(widget)));
// FIXME: need to keep track of subframe focus for key events
gtk_widget_grab_focus(GTK_WIDGET(widget));
......@@ -169,20 +169,20 @@ static gboolean webkit_web_view_button_press_event(GtkWidget* widget, GdkEventBu
static gboolean webkit_web_view_button_release_event(GtkWidget* widget, GdkEventButton* event)
{
Frame* frame = core(getFrameFromView(WEBKIT_WEB_VIEW(widget)));
Frame* frame = core(webkit_web_view_get_main_frame(WEBKIT_WEB_VIEW(widget)));
return frame->eventHandler()->handleMouseReleaseEvent(PlatformMouseEvent(event));
}
static gboolean webkit_web_view_motion_event(GtkWidget* widget, GdkEventMotion* event)
{
Frame* frame = core(getFrameFromView(WEBKIT_WEB_VIEW(widget)));
Frame* frame = core(webkit_web_view_get_main_frame(WEBKIT_WEB_VIEW(widget)));
return frame->eventHandler()->mouseMoved(PlatformMouseEvent(event));
}
static gboolean webkit_web_view_scroll_event(GtkWidget* widget, GdkEventScroll* event)
{
Frame* frame = core(getFrameFromView(WEBKIT_WEB_VIEW(widget)));
Frame* frame = core(webkit_web_view_get_main_frame(WEBKIT_WEB_VIEW(widget)));
PlatformWheelEvent wheelEvent(event);
return frame->eventHandler()->handleWheelEvent(wheelEvent);
}
......@@ -191,7 +191,7 @@ static void webkit_web_view_size_allocate(GtkWidget* widget, GtkAllocation* allo
{
GTK_WIDGET_CLASS(webkit_web_view_parent_class)->size_allocate(widget,allocation);
Frame* frame = core(getFrameFromView(WEBKIT_WEB_VIEW(widget)));
Frame* frame = core(webkit_web_view_get_main_frame(WEBKIT_WEB_VIEW(widget)));
frame->view()->resize(allocation->width, allocation->height);
frame->forceLayout();
frame->view()->adjustViewSize();
......@@ -229,7 +229,7 @@ static void webkit_web_view_realize(GtkWidget* widget)
static void webkit_web_view_set_scroll_adjustments(WebKitWebView* webView, GtkAdjustment* hadj, GtkAdjustment* vadj)
{
FrameView* view = core(getFrameFromView(webView))->view();
FrameView* view = core(webkit_web_view_get_main_frame(webView))->view();
view->setGtkAdjustments(hadj, vadj);
}
......@@ -835,70 +835,62 @@ void webkit_web_view_go_backward(WebKitWebView* webView)
{
g_return_if_fail(WEBKIT_IS_WEB_VIEW(webView));
WebKitWebViewPrivate* webViewData = WEBKIT_WEB_VIEW_GET_PRIVATE(webView);
WebKitWebFramePrivate* frameData = WEBKIT_WEB_FRAME_GET_PRIVATE(webViewData->mainFrame);
frameData->frame->loader()->goBackOrForward(-1);
Frame* frame = core(webkit_web_view_get_main_frame(webView));
frame->loader()->goBackOrForward(-1);
}
void webkit_web_view_go_forward(WebKitWebView* webView)
{
g_return_if_fail(WEBKIT_IS_WEB_VIEW(webView));
WebKitWebViewPrivate* webViewData = WEBKIT_WEB_VIEW_GET_PRIVATE(webView);
WebKitWebFramePrivate* frameData = WEBKIT_WEB_FRAME_GET_PRIVATE(webViewData->mainFrame);
frameData->frame->loader()->goBackOrForward(1);
Frame* frame = core(webkit_web_view_get_main_frame(webView));
frame->loader()->goBackOrForward(1);
}
gboolean webkit_web_view_can_go_backward(WebKitWebView* webView)
{
g_return_val_if_fail(WEBKIT_IS_WEB_VIEW(webView), FALSE);
WebKitWebViewPrivate* webViewData = WEBKIT_WEB_VIEW_GET_PRIVATE(webView);
WebKitWebFramePrivate* frameData = WEBKIT_WEB_FRAME_GET_PRIVATE(webViewData->mainFrame);
return frameData->frame->loader()->canGoBackOrForward(-1);
Frame* frame = core(webkit_web_view_get_main_frame(webView));
return frame->loader()->canGoBackOrForward(-1);
}
gboolean webkit_web_view_can_go_forward(WebKitWebView* webView)
{
g_return_val_if_fail(WEBKIT_IS_WEB_VIEW(webView), FALSE);
WebKitWebViewPrivate* webViewData = WEBKIT_WEB_VIEW_GET_PRIVATE(webView);
WebKitWebFramePrivate* frameData = WEBKIT_WEB_FRAME_GET_PRIVATE(webViewData->mainFrame);
return frameData->frame->loader()->canGoBackOrForward(1);
Frame* frame = core(webkit_web_view_get_main_frame(webView));
return frame->loader()->canGoBackOrForward(1);
}
void webkit_web_view_open(WebKitWebView* webView, const gchar* uri)
{
g_return_if_fail(WEBKIT_IS_WEB_VIEW(webView));
WebKitWebViewPrivate* webViewData = WEBKIT_WEB_VIEW_GET_PRIVATE(webView);
WebKitWebFramePrivate* frameData = WEBKIT_WEB_FRAME_GET_PRIVATE(webViewData->mainFrame);
Frame* frame = core(webkit_web_view_get_main_frame(webView));
DeprecatedString string = DeprecatedString::fromUtf8(uri);
frameData->frame->loader()->load(ResourceRequest(KURL(string)));
frame->loader()->load(ResourceRequest(KURL(string)));
}
void webkit_web_view_reload(WebKitWebView* webView)
{
g_return_if_fail(WEBKIT_IS_WEB_VIEW(webView));
WebKitWebViewPrivate* webViewData = WEBKIT_WEB_VIEW_GET_PRIVATE(webView);
WebKitWebFramePrivate* frameData = WEBKIT_WEB_FRAME_GET_PRIVATE(webViewData->mainFrame);
frameData->frame->loader()->reload();
Frame* frame = core(webkit_web_view_get_main_frame(webView));
frame->loader()->reload();
}
void webkit_web_view_load_string(WebKitWebView* webView, const gchar* content, const gchar* contentMimeType, const gchar* contentEncoding, const gchar* baseUri)
{
g_return_if_fail(WEBKIT_IS_WEB_VIEW(webView));
WebKitWebViewPrivate* webViewData = WEBKIT_WEB_VIEW_GET_PRIVATE(webView);
WebKitWebFramePrivate* frameData = WEBKIT_WEB_FRAME_GET_PRIVATE(webViewData->mainFrame);
Frame* frame = core(webkit_web_view_get_main_frame(webView));
KURL url(DeprecatedString::fromUtf8(baseUri));
RefPtr<SharedBuffer> sharedBuffer = new SharedBuffer(strdup(content), strlen(content));
SubstituteData substituteData(sharedBuffer.release(), String(contentMimeType), String(contentEncoding), KURL("about:blank"), url);
frameData->frame->loader()->load(ResourceRequest(url), substituteData);
frame->loader()->load(ResourceRequest(url), substituteData);
}
void webkit_web_view_load_html_string(WebKitWebView* webView, const gchar* content, const gchar* baseUrl)
......@@ -912,10 +904,9 @@ void webkit_web_view_stop_loading(WebKitWebView* webView)
{
g_return_if_fail(WEBKIT_IS_WEB_VIEW(webView));
WebKitWebViewPrivate* webViewData = WEBKIT_WEB_VIEW_GET_PRIVATE(webView);
WebKitWebFramePrivate* frameData = WEBKIT_WEB_FRAME_GET_PRIVATE(webViewData->mainFrame);
Frame* frame = core(webkit_web_view_get_main_frame(webView));
if (FrameLoader* loader = frameData->frame->loader())
if (FrameLoader* loader = frame->loader())
loader->stopAllLoaders();
}
......@@ -932,10 +923,8 @@ void webkit_web_view_execute_script(WebKitWebView* webView, const gchar* script)
g_return_if_fail(WEBKIT_IS_WEB_VIEW(webView));
g_return_if_fail(script);
WebKitWebViewPrivate* webViewData = WEBKIT_WEB_VIEW_GET_PRIVATE(webView);
WebKitWebFramePrivate* frameData = WEBKIT_WEB_FRAME_GET_PRIVATE(webViewData->mainFrame);
if (FrameLoader* loader = frameData->frame->loader())
Frame* frame = core(webkit_web_view_get_main_frame(webView));
if (FrameLoader* loader = frame->loader())
loader->executeScript(String::fromUTF8(script), true);
}
......
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