Commit b99a79f9 authored by carlosgc@webkit.org's avatar carlosgc@webkit.org
Browse files

[GTK] Implement ViewState methods in PageClientImpl in WebKit2

https://bugs.webkit.org/show_bug.cgi?id=97202

Reviewed by Martin Robinson.

Source/WebKit2:

Implement isViewWindowActive(), isViewFocused(), isViewVisible()
and isViewInWindow() in PageClientImpl.

* GNUmakefile.list.am: Add new files to compilation.
* UIProcess/API/C/gtk/WKView.cpp:
(WKViewSetFocus): New private method used by WTR to focus the
WebView.
* UIProcess/API/C/gtk/WKViewPrivate.h: Added.
* UIProcess/API/gtk/PageClientImpl.cpp:
(WebKit::PageClientImpl::isViewWindowActive): Return
webkitWebViewBaseIsInWindowActive().
(WebKit::PageClientImpl::isViewFocused): Return
webkitWebViewBaseIsFocused().
(WebKit::PageClientImpl::isViewVisible): Return
webkitWebViewBaseIsVisible().
(WebKit::PageClientImpl::isViewInWindow): Return
webkitWebViewBaseIsInWindow().
* UIProcess/API/gtk/WebKitWebViewBase.cpp:
(webkitWebViewBaseNotifyResizerSize): Updated to not receive the
window as parameter since it's now saved in the instance struct.
(toplevelWindowResizeGripVisibilityChanged): Update to
webkitWebViewBaseNotifyResizerSize() API change.
(toplevelWindowFocusInEvent): Update ViewWindowIsActive flag and
notify the WebPageProxy if it changed.
(toplevelWindowFocusOutEvent): Ditto.
(webkitWebViewBaseSetToplevelOnScreenWindow): Set the toplevel
on-screen window where the view is currently added and notify
WebPageProxy if it changed.
(webkitWebViewBaseRealize): Call
webkitWebViewBaseSetToplevelOnScreenWindow() if the view has been
added to an on-screen window.
(webkitWebViewBaseFinalize): Reset the toplevel on-screen window
to make sure all signals are disconnected when the view is
destroyed.
(webkit_web_view_base_init): Remove unneeded initialization.
(resizeWebKitWebViewBaseFromAllocation): Update to
webkitWebViewBaseNotifyResizerSize() API change.
(webkitWebViewBaseMap): Update ViewIsVisible flag and notify
WebPageProxy if it changed.
(webkitWebViewBaseUnmap): Ditto.
(webkitWebViewBaseFocusInEvent): Call webkitWebViewBaseSetFocus()
passing true to focus the view.
(webkitWebViewBaseFocusOutEvent): Call webkitWebViewBaseSetFocus()
passing false to unfocus the view.
(webkitWebViewBaseParentSet): Reset the toplevel on-screen window
if the view is re-parented.
(webkit_web_view_base_class_init): Add implementations for map and
parent-set virtual functions.
(webkitWebViewBaseSetFocus): Update the ViewIsFocused and notify
WebPageProxy if it changed.
(webkitWebViewBaseIsInWindowActive):
(webkitWebViewBaseIsFocused):
(webkitWebViewBaseIsVisible):
(webkitWebViewBaseIsInWindow):
* UIProcess/API/gtk/WebKitWebViewBasePrivate.h:
* UIProcess/API/gtk/tests/TestWebKitWebView.cpp:
(testWebViewMouseTarget): Use a GTK_WINDOW_TOPLEVEL instead of
POPUP for this test to make sure the view receives focus change
events.

Tools:

* WebKitTestRunner/gtk/PlatformWebViewGtk.cpp:
(WTR::PlatformWebView::focus): Focus the view.

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@129238 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 1d43a702
2012-09-21 Carlos Garcia Campos <cgarcia@igalia.com>
[GTK] Implement ViewState methods in PageClientImpl in WebKit2
https://bugs.webkit.org/show_bug.cgi?id=97202
Reviewed by Martin Robinson.
Implement isViewWindowActive(), isViewFocused(), isViewVisible()
and isViewInWindow() in PageClientImpl.
* GNUmakefile.list.am: Add new files to compilation.
* UIProcess/API/C/gtk/WKView.cpp:
(WKViewSetFocus): New private method used by WTR to focus the
WebView.
* UIProcess/API/C/gtk/WKViewPrivate.h: Added.
* UIProcess/API/gtk/PageClientImpl.cpp:
(WebKit::PageClientImpl::isViewWindowActive): Return
webkitWebViewBaseIsInWindowActive().
(WebKit::PageClientImpl::isViewFocused): Return
webkitWebViewBaseIsFocused().
(WebKit::PageClientImpl::isViewVisible): Return
webkitWebViewBaseIsVisible().
(WebKit::PageClientImpl::isViewInWindow): Return
webkitWebViewBaseIsInWindow().
* UIProcess/API/gtk/WebKitWebViewBase.cpp:
(webkitWebViewBaseNotifyResizerSize): Updated to not receive the
window as parameter since it's now saved in the instance struct.
(toplevelWindowResizeGripVisibilityChanged): Update to
webkitWebViewBaseNotifyResizerSize() API change.
(toplevelWindowFocusInEvent): Update ViewWindowIsActive flag and
notify the WebPageProxy if it changed.
(toplevelWindowFocusOutEvent): Ditto.
(webkitWebViewBaseSetToplevelOnScreenWindow): Set the toplevel
on-screen window where the view is currently added and notify
WebPageProxy if it changed.
(webkitWebViewBaseRealize): Call
webkitWebViewBaseSetToplevelOnScreenWindow() if the view has been
added to an on-screen window.
(webkitWebViewBaseFinalize): Reset the toplevel on-screen window
to make sure all signals are disconnected when the view is
destroyed.
(webkit_web_view_base_init): Remove unneeded initialization.
(resizeWebKitWebViewBaseFromAllocation): Update to
webkitWebViewBaseNotifyResizerSize() API change.
(webkitWebViewBaseMap): Update ViewIsVisible flag and notify
WebPageProxy if it changed.
(webkitWebViewBaseUnmap): Ditto.
(webkitWebViewBaseFocusInEvent): Call webkitWebViewBaseSetFocus()
passing true to focus the view.
(webkitWebViewBaseFocusOutEvent): Call webkitWebViewBaseSetFocus()
passing false to unfocus the view.
(webkitWebViewBaseParentSet): Reset the toplevel on-screen window
if the view is re-parented.
(webkit_web_view_base_class_init): Add implementations for map and
parent-set virtual functions.
(webkitWebViewBaseSetFocus): Update the ViewIsFocused and notify
WebPageProxy if it changed.
(webkitWebViewBaseIsInWindowActive):
(webkitWebViewBaseIsFocused):
(webkitWebViewBaseIsVisible):
(webkitWebViewBaseIsInWindow):
* UIProcess/API/gtk/WebKitWebViewBasePrivate.h:
* UIProcess/API/gtk/tests/TestWebKitWebView.cpp:
(testWebViewMouseTarget): Use a GTK_WINDOW_TOPLEVEL instead of
POPUP for this test to make sure the view receives focus change
events.
2012-09-21 Carlos Garcia Campos <cgarcia@igalia.com>
 
[GTK] Add WebKitWebView:is-loading property to WebKit2 GTK+ API
......
......@@ -511,6 +511,7 @@ webkit2_sources += \
Source/WebKit2/UIProcess/API/C/gtk/WKInspectorClientGtk.h \
Source/WebKit2/UIProcess/API/C/gtk/WKView.cpp \
Source/WebKit2/UIProcess/API/C/gtk/WKView.h \
Source/WebKit2/UIProcess/API/C/gtk/WKViewPrivate.h \
Source/WebKit2/UIProcess/API/C/soup/WKAPICastSoup.h \
Source/WebKit2/UIProcess/API/C/soup/WKContextSoup.cpp \
Source/WebKit2/UIProcess/API/C/soup/WKContextSoup.h \
......
......@@ -29,6 +29,7 @@
#include "WKView.h"
#include "WKAPICast.h"
#include "WKViewPrivate.h"
#include "WebKitWebViewBasePrivate.h"
using namespace WebKit;
......@@ -44,4 +45,7 @@ WKPageRef WKViewGetPage(WKViewRef viewRef)
return toAPI(webkitWebViewBaseGetPage(toImpl(viewRef)));
}
void WKViewSetFocus(WKViewRef viewRef, bool focused)
{
webkitWebViewBaseSetFocus(toImpl(viewRef), focused);
}
/*
* Copyright (C) 2012 Igalia S.L.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
* THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef WKViewPrivate_h
#define WKViewPrivate_h
#include <WebKit2/WKBase.h>
#ifdef __cplusplus
extern "C" {
#endif
WK_EXPORT void WKViewSetFocus(WKViewRef viewRef, bool focused);
#ifdef __cplusplus
}
#endif
#endif /* WKViewPrivate_h */
......@@ -98,26 +98,22 @@ WebCore::IntSize PageClientImpl::viewSize()
bool PageClientImpl::isViewWindowActive()
{
notImplemented();
return true;
return webkitWebViewBaseIsInWindowActive(WEBKIT_WEB_VIEW_BASE(m_viewWidget));
}
bool PageClientImpl::isViewFocused()
{
notImplemented();
return true;
return webkitWebViewBaseIsFocused(WEBKIT_WEB_VIEW_BASE(m_viewWidget));
}
bool PageClientImpl::isViewVisible()
{
notImplemented();
return true;
return webkitWebViewBaseIsVisible(WEBKIT_WEB_VIEW_BASE(m_viewWidget));
}
bool PageClientImpl::isViewInWindow()
{
notImplemented();
return true;
return webkitWebViewBaseIsInWindow(WEBKIT_WEB_VIEW_BASE(m_viewWidget));
}
void PageClientImpl::PageClientImpl::processDidCrash()
......
......@@ -79,7 +79,6 @@ struct _WebKitWebViewBasePrivate {
WebKitWebViewChildrenMap children;
OwnPtr<PageClientImpl> pageClient;
RefPtr<WebPageProxy> pageProxy;
bool isPageActive;
bool shouldForwardNextKeyEvent;
GRefPtr<GtkIMContext> imContext;
GtkClickCounter clickCounter;
......@@ -95,6 +94,16 @@ struct _WebKitWebViewBasePrivate {
GOwnPtr<GdkEvent> contextMenuEvent;
WebContextMenuProxyGtk* activeContextMenuProxy;
GtkWindow* toplevelOnScreenWindow;
unsigned long toplevelResizeGripVisibilityID;
unsigned long toplevelFocusInEventID;
unsigned long toplevelFocusOutEventID;
// View State.
bool isInWindowActive : 1;
bool isFocused : 1;
bool isVisible : 1;
#if ENABLE(FULLSCREEN_API)
bool fullScreenModeActive;
WebFullScreenClientGtk fullScreenClient;
......@@ -108,30 +117,93 @@ struct _WebKitWebViewBasePrivate {
G_DEFINE_TYPE(WebKitWebViewBase, webkit_web_view_base, GTK_TYPE_CONTAINER)
static void webkitWebViewBaseNotifyResizerSizeForWindow(WebKitWebViewBase* webViewBase, GtkWindow* window)
static void webkitWebViewBaseNotifyResizerSize(WebKitWebViewBase* webViewBase)
{
WebKitWebViewBasePrivate* priv = webViewBase->priv;
if (!priv->toplevelOnScreenWindow)
return;
gboolean resizerVisible;
g_object_get(G_OBJECT(window), "resize-grip-visible", &resizerVisible, NULL);
g_object_get(G_OBJECT(priv->toplevelOnScreenWindow), "resize-grip-visible", &resizerVisible, NULL);
IntSize resizerSize;
if (resizerVisible) {
GdkRectangle resizerRect;
gtk_window_get_resize_grip_area(window, &resizerRect);
gtk_window_get_resize_grip_area(priv->toplevelOnScreenWindow, &resizerRect);
GdkRectangle allocation;
gtk_widget_get_allocation(GTK_WIDGET(webViewBase), &allocation);
if (gdk_rectangle_intersect(&resizerRect, &allocation, 0))
resizerSize = IntSize(resizerRect.width, resizerRect.height);
}
if (resizerSize != webViewBase->priv->resizerSize) {
webViewBase->priv->resizerSize = resizerSize;
webViewBase->priv->pageProxy->setWindowResizerSize(resizerSize);
if (resizerSize != priv->resizerSize) {
priv->resizerSize = resizerSize;
priv->pageProxy->setWindowResizerSize(resizerSize);
}
}
static void toplevelWindowResizeGripVisibilityChanged(GObject*, GParamSpec*, WebKitWebViewBase* webViewBase)
{
webkitWebViewBaseNotifyResizerSize(webViewBase);
}
static gboolean toplevelWindowFocusInEvent(GtkWidget* widget, GdkEventFocus*, WebKitWebViewBase* webViewBase)
{
WebKitWebViewBasePrivate* priv = webViewBase->priv;
if (!priv->isInWindowActive) {
priv->isInWindowActive = true;
priv->pageProxy->viewStateDidChange(WebPageProxy::ViewWindowIsActive);
}
return FALSE;
}
static gboolean toplevelWindowFocusOutEvent(GtkWidget* widget, GdkEventFocus*, WebKitWebViewBase* webViewBase)
{
WebKitWebViewBasePrivate* priv = webViewBase->priv;
if (priv->isInWindowActive) {
priv->isInWindowActive = false;
priv->pageProxy->viewStateDidChange(WebPageProxy::ViewWindowIsActive);
}
return FALSE;
}
static void toplevelWindowResizeGripVisibilityChanged(GObject* object, GParamSpec*, WebKitWebViewBase* webViewBase)
static void webkitWebViewBaseSetToplevelOnScreenWindow(WebKitWebViewBase* webViewBase, GtkWindow* window)
{
webkitWebViewBaseNotifyResizerSizeForWindow(webViewBase, GTK_WINDOW(object));
WebKitWebViewBasePrivate* priv = webViewBase->priv;
if (priv->toplevelOnScreenWindow == window)
return;
if (priv->toplevelResizeGripVisibilityID) {
g_signal_handler_disconnect(priv->toplevelOnScreenWindow, priv->toplevelResizeGripVisibilityID);
priv->toplevelResizeGripVisibilityID = 0;
}
if (priv->toplevelFocusInEventID) {
g_signal_handler_disconnect(priv->toplevelOnScreenWindow, priv->toplevelFocusInEventID);
priv->toplevelFocusInEventID = 0;
}
if (priv->toplevelFocusOutEventID) {
g_signal_handler_disconnect(priv->toplevelOnScreenWindow, priv->toplevelFocusOutEventID);
priv->toplevelFocusOutEventID = 0;
}
priv->toplevelOnScreenWindow = window;
priv->pageProxy->viewStateDidChange(WebPageProxy::ViewIsInWindow);
if (!priv->toplevelOnScreenWindow)
return;
webkitWebViewBaseNotifyResizerSize(webViewBase);
priv->toplevelResizeGripVisibilityID =
g_signal_connect(priv->toplevelOnScreenWindow, "notify::resize-grip-visible",
G_CALLBACK(toplevelWindowResizeGripVisibilityChanged), webViewBase);
priv->toplevelFocusInEventID =
g_signal_connect(priv->toplevelOnScreenWindow, "focus-in-event",
G_CALLBACK(toplevelWindowFocusInEvent), webViewBase);
priv->toplevelFocusOutEventID =
g_signal_connect(priv->toplevelOnScreenWindow, "focus-out-event",
G_CALLBACK(toplevelWindowFocusOutEvent), webViewBase);
}
static void webkitWebViewBaseRealize(GtkWidget* widget)
......@@ -178,11 +250,8 @@ static void webkitWebViewBaseRealize(GtkWidget* widget)
gtk_im_context_set_client_window(priv->imContext.get(), window);
GtkWidget* toplevel = gtk_widget_get_toplevel(widget);
if (widgetIsOnscreenToplevelWindow(toplevel)) {
webkitWebViewBaseNotifyResizerSizeForWindow(webView, GTK_WINDOW(toplevel));
g_signal_connect(toplevel, "notify::resize-grip-visible",
G_CALLBACK(toplevelWindowResizeGripVisibilityChanged), webView);
}
if (widgetIsOnscreenToplevelWindow(toplevel))
webkitWebViewBaseSetToplevelOnScreenWindow(webView, GTK_WINDOW(toplevel));
}
static void webkitWebViewBaseContainerAdd(GtkContainer* container, GtkWidget* widget)
......@@ -251,9 +320,12 @@ void webkitWebViewBaseChildMoveResize(WebKitWebViewBase* webView, GtkWidget* chi
static void webkitWebViewBaseFinalize(GObject* gobject)
{
WebKitWebViewBase* webkitWebViewBase = WEBKIT_WEB_VIEW_BASE(gobject);
webkitWebViewBase->priv->pageProxy->close();
WebKitWebViewBasePrivate* priv = webkitWebViewBase->priv;
priv->pageProxy->close();
webkitWebViewBaseSetToplevelOnScreenWindow(webkitWebViewBase, 0);
webkitWebViewBase->priv->~WebKitWebViewBasePrivate();
priv->~WebKitWebViewBasePrivate();
G_OBJECT_CLASS(webkit_web_view_base_parent_class)->finalize(gobject);
}
......@@ -263,7 +335,6 @@ static void webkit_web_view_base_init(WebKitWebViewBase* webkitWebViewBase)
webkitWebViewBase->priv = priv;
new (priv) WebKitWebViewBasePrivate();
priv->isPageActive = TRUE;
priv->shouldForwardNextKeyEvent = FALSE;
GtkWidget* viewWidget = GTK_WIDGET(webkitWebViewBase);
......@@ -366,9 +437,7 @@ static void resizeWebKitWebViewBaseFromAllocation(WebKitWebViewBase* webViewBase
if (priv->pageProxy->drawingArea())
priv->pageProxy->drawingArea()->setSize(viewRect.size(), IntSize());
GtkWidget* toplevel = gtk_widget_get_toplevel(GTK_WIDGET(webViewBase));
if (widgetIsOnscreenToplevelWindow(toplevel))
webkitWebViewBaseNotifyResizerSizeForWindow(webViewBase, GTK_WINDOW(toplevel));
webkitWebViewBaseNotifyResizerSize(webViewBase);
}
static void webkitWebViewBaseSizeAllocate(GtkWidget* widget, GtkAllocation* allocation)
......@@ -392,28 +461,37 @@ static void webkitWebViewBaseMap(GtkWidget* widget)
GTK_WIDGET_CLASS(webkit_web_view_base_parent_class)->map(widget);
WebKitWebViewBase* webViewBase = WEBKIT_WEB_VIEW_BASE(widget);
if (!webViewBase->priv->needsResizeOnMap)
WebKitWebViewBasePrivate* priv = webViewBase->priv;
if (!priv->isVisible) {
priv->isVisible = true;
priv->pageProxy->viewStateDidChange(WebPageProxy::ViewIsVisible);
}
if (!priv->needsResizeOnMap)
return;
GtkAllocation allocation;
gtk_widget_get_allocation(widget, &allocation);
resizeWebKitWebViewBaseFromAllocation(webViewBase, &allocation, true /* sizeChanged */);
webViewBase->priv->needsResizeOnMap = false;
priv->needsResizeOnMap = false;
}
static gboolean webkitWebViewBaseFocusInEvent(GtkWidget* widget, GdkEventFocus* event)
static void webkitWebViewBaseUnmap(GtkWidget* widget)
{
WebKitWebViewBase* webViewBase = WEBKIT_WEB_VIEW_BASE(widget);
WebKitWebViewBasePrivate* priv = webViewBase->priv;
GTK_WIDGET_CLASS(webkit_web_view_base_parent_class)->unmap(widget);
GtkWidget* toplevel = gtk_widget_get_toplevel(widget);
if (widgetIsOnscreenToplevelWindow(toplevel) && gtk_window_has_toplevel_focus(GTK_WINDOW(toplevel))) {
gtk_im_context_focus_in(priv->imContext.get());
if (!priv->isPageActive) {
priv->isPageActive = TRUE;
priv->pageProxy->viewStateDidChange(WebPageProxy::ViewWindowIsActive);
}
WebKitWebViewBasePrivate* priv = WEBKIT_WEB_VIEW_BASE(widget)->priv;
if (priv->isVisible) {
priv->isVisible = false;
priv->pageProxy->viewStateDidChange(WebPageProxy::ViewIsVisible);
}
}
static gboolean webkitWebViewBaseFocusInEvent(GtkWidget* widget, GdkEventFocus* event)
{
WebKitWebViewBase* webViewBase = WEBKIT_WEB_VIEW_BASE(widget);
webkitWebViewBaseSetFocus(webViewBase, true);
gtk_im_context_focus_in(webViewBase->priv->imContext.get());
return GTK_WIDGET_CLASS(webkit_web_view_base_parent_class)->focus_in_event(widget, event);
}
......@@ -421,12 +499,8 @@ static gboolean webkitWebViewBaseFocusInEvent(GtkWidget* widget, GdkEventFocus*
static gboolean webkitWebViewBaseFocusOutEvent(GtkWidget* widget, GdkEventFocus* event)
{
WebKitWebViewBase* webViewBase = WEBKIT_WEB_VIEW_BASE(widget);
WebKitWebViewBasePrivate* priv = webViewBase->priv;
priv->isPageActive = FALSE;
priv->pageProxy->viewStateDidChange(WebPageProxy::ViewWindowIsActive);
if (priv->imContext)
gtk_im_context_focus_out(priv->imContext.get());
webkitWebViewBaseSetFocus(webViewBase, false);
gtk_im_context_focus_out(webViewBase->priv->imContext.get());
return GTK_WIDGET_CLASS(webkit_web_view_base_parent_class)->focus_out_event(widget, event);
}
......@@ -654,6 +728,13 @@ static gboolean webkitWebViewBaseDragDrop(GtkWidget* widget, GdkDragContext* con
return TRUE;
}
static void webkitWebViewBaseParentSet(GtkWidget* widget, GtkWidget* oldParent)
{
if (!gtk_widget_get_parent(widget))
webkitWebViewBaseSetToplevelOnScreenWindow(WEBKIT_WEB_VIEW_BASE(widget), 0);
}
static void webkit_web_view_base_class_init(WebKitWebViewBaseClass* webkitWebViewBaseClass)
{
GtkWidgetClass* widgetClass = GTK_WIDGET_CLASS(webkitWebViewBaseClass);
......@@ -661,6 +742,7 @@ static void webkit_web_view_base_class_init(WebKitWebViewBaseClass* webkitWebVie
widgetClass->draw = webkitWebViewBaseDraw;
widgetClass->size_allocate = webkitWebViewBaseSizeAllocate;
widgetClass->map = webkitWebViewBaseMap;
widgetClass->unmap = webkitWebViewBaseUnmap;
widgetClass->focus_in_event = webkitWebViewBaseFocusInEvent;
widgetClass->focus_out_event = webkitWebViewBaseFocusOutEvent;
widgetClass->key_press_event = webkitWebViewBaseKeyPressEvent;
......@@ -677,6 +759,7 @@ static void webkit_web_view_base_class_init(WebKitWebViewBaseClass* webkitWebVie
widgetClass->drag_drop = webkitWebViewBaseDragDrop;
widgetClass->drag_data_received = webkitWebViewBaseDragDataReceived;
widgetClass->get_accessible = webkitWebViewBaseGetAccessible;
widgetClass->parent_set = webkitWebViewBaseParentSet;
GObjectClass* gobjectClass = G_OBJECT_CLASS(webkitWebViewBaseClass);
gobjectClass->finalize = webkitWebViewBaseFinalize;
......@@ -878,3 +961,44 @@ void webkitWebViewBaseQueueDrawOfAcceleratedCompositingResults(WebKitWebViewBase
g_timeout_add(1000 / 60, reinterpret_cast<GSourceFunc>(queueAnotherDrawOfAcceleratedCompositingResults), webViewBasePointer);
}
#endif
void webkitWebViewBaseSetFocus(WebKitWebViewBase* webViewBase, bool focused)
{
WebKitWebViewBasePrivate* priv = webViewBase->priv;
if (priv->isFocused == focused)
return;
unsigned viewStateFlags = WebPageProxy::ViewIsFocused;
priv->isFocused = focused;
// If the view has received the focus and the window is not active
// mark the current window as active now. This can happen if the
// toplevel window is a GTK_WINDOW_POPUP and the focus has been
// set programatically like WebKitTestRunner does, because POPUP
// can't be focused.
if (priv->isFocused && !priv->isInWindowActive) {
priv->isInWindowActive = true;
viewStateFlags |= WebPageProxy::ViewWindowIsActive;
}
priv->pageProxy->viewStateDidChange(viewStateFlags);
}
bool webkitWebViewBaseIsInWindowActive(WebKitWebViewBase* webViewBase)
{
return webViewBase->priv->isInWindowActive;
}
bool webkitWebViewBaseIsFocused(WebKitWebViewBase* webViewBase)
{
return webViewBase->priv->isFocused;
}
bool webkitWebViewBaseIsVisible(WebKitWebViewBase* webViewBase)
{
return webViewBase->priv->isVisible;
}
bool webkitWebViewBaseIsInWindow(WebKitWebViewBase* webViewBase)
{
return webViewBase->priv->toplevelOnScreenWindow;
}
......@@ -56,4 +56,10 @@ GdkEvent* webkitWebViewBaseTakeContextMenuEvent(WebKitWebViewBase*);
void webkitWebViewBaseQueueDrawOfAcceleratedCompositingResults(WebKitWebViewBase*);
#endif
void webkitWebViewBaseSetFocus(WebKitWebViewBase*, bool focused);
bool webkitWebViewBaseIsInWindowActive(WebKitWebViewBase*);
bool webkitWebViewBaseIsFocused(WebKitWebViewBase*);
bool webkitWebViewBaseIsVisible(WebKitWebViewBase*);
bool webkitWebViewBaseIsInWindow(WebKitWebViewBase*);
#endif // WebKitWebViewBasePrivate_h
......@@ -464,7 +464,7 @@ static void testWebViewWindowProperties(UIClientTest* test, gconstpointer)
static void testWebViewMouseTarget(UIClientTest* test, gconstpointer)
{
test->showInWindowAndWaitUntilMapped();
test->showInWindowAndWaitUntilMapped(GTK_WINDOW_TOPLEVEL);
const char* linksHoveredHTML =
"<html><body>"
......
2012-09-21 Carlos Garcia Campos <cgarcia@igalia.com>
[GTK] Implement ViewState methods in PageClientImpl in WebKit2
https://bugs.webkit.org/show_bug.cgi?id=97202
Reviewed by Martin Robinson.
* WebKitTestRunner/gtk/PlatformWebViewGtk.cpp:
(WTR::PlatformWebView::focus): Focus the view.
2012-09-21 Sudarsana Nagineni <sudarsana.nagineni@intel.com>
 
[WTR] Memory leaks in InjectedBundleController::initialize()
......
......@@ -28,6 +28,7 @@
#include "config.h"
#include "PlatformWebView.h"
#include <WebKit2/WKViewPrivate.h>
#include <gtk/gtk.h>
namespace WTR {
......@@ -70,6 +71,8 @@ WKPageRef PlatformWebView::page()
void PlatformWebView::focus()
{
WKViewSetFocus(m_view, true);
setWindowIsKey(true);
}
WKRect PlatformWebView::windowFrame()
......
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