diff options
author | Simon Hausmann <simon.hausmann@digia.com> | 2012-11-30 16:58:06 +0100 |
---|---|---|
committer | Simon Hausmann <simon.hausmann@digia.com> | 2012-11-30 17:03:09 +0100 |
commit | 32ea33253afbbdefd2680aa95ab5f57455272ae7 (patch) | |
tree | 2389569585b666c310fbb36d3fb8e6ab94462967 /Source/WebKit2/UIProcess/API | |
parent | 41c25f231cbca1babc445187283524cc6c751c71 (diff) | |
download | qtwebkit-32ea33253afbbdefd2680aa95ab5f57455272ae7.tar.gz |
Imported WebKit commit 6a4a1d32e1d779548c726c4826cba9d69eb87601 (http://svn.webkit.org/repository/webkit/trunk@136242)
Final import for the Qt 5.x series that implements the QtWebKit / QtWebKitWidgets split
Extra fixes will be cherry-picked.
Change-Id: I844f1ebb99c6d6b75db31d6538c2acd628e79681
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Diffstat (limited to 'Source/WebKit2/UIProcess/API')
27 files changed, 379 insertions, 23 deletions
diff --git a/Source/WebKit2/UIProcess/API/efl/EwkViewImpl.cpp b/Source/WebKit2/UIProcess/API/efl/EwkViewImpl.cpp index 50e4cb205..2f2629ce0 100644 --- a/Source/WebKit2/UIProcess/API/efl/EwkViewImpl.cpp +++ b/Source/WebKit2/UIProcess/API/efl/EwkViewImpl.cpp @@ -114,6 +114,9 @@ const Evas_Object* EwkViewImpl::viewFromPageViewMap(const WKPageRef page) EwkViewImpl::EwkViewImpl(Evas_Object* view, PassRefPtr<EwkContext> context, PassRefPtr<WebPageGroup> pageGroup, ViewBehavior behavior) : m_view(view) , m_context(context) +#if USE(ACCELERATED_COMPOSITING) + , m_pendingSurfaceResize(false) +#endif , m_pageClient(behavior == DefaultBehavior ? PageClientDefaultImpl::create(this) : PageClientLegacyImpl::create(this)) , m_pageProxy(m_context->webContext()->createWebPage(m_pageClient.get(), pageGroup.get())) , m_pageLoadClient(PageLoadClientEfl::create(this)) @@ -361,7 +364,12 @@ void EwkViewImpl::displayTimerFired(Timer<EwkViewImpl>*) #if USE(COORDINATED_GRAPHICS) Ewk_View_Smart_Data* sd = smartData(); - evas_gl_make_current(m_evasGL.get(), evasGLSurface(), evasGLContext()); + if (m_pendingSurfaceResize) { + // Create a GL surface here so that Evas has no chance of painting to an empty GL surface. + createGLSurface(IntSize(sd->view.w, sd->view.h)); + m_pendingSurfaceResize = false; + } else + evas_gl_make_current(m_evasGL.get(), evasGLSurface(), evasGLContext()); // We are supposed to clip to the actual viewport, nothing less. IntRect viewport(sd->view.x, sd->view.y, sd->view.w, sd->view.h); diff --git a/Source/WebKit2/UIProcess/API/efl/EwkViewImpl.h b/Source/WebKit2/UIProcess/API/efl/EwkViewImpl.h index cb1875672..bb93fedb1 100644 --- a/Source/WebKit2/UIProcess/API/efl/EwkViewImpl.h +++ b/Source/WebKit2/UIProcess/API/efl/EwkViewImpl.h @@ -161,6 +161,7 @@ public: bool createGLSurface(const WebCore::IntSize& viewSize); bool enterAcceleratedCompositingMode(); bool exitAcceleratedCompositingMode(); + void setNeedsSurfaceResize() { m_pendingSurfaceResize = true; } #endif #if ENABLE(INPUT_TYPE_COLOR) @@ -246,6 +247,7 @@ private: OwnPtr<Evas_GL> m_evasGL; OwnPtr<WebKit::EvasGLContext> m_evasGLContext; OwnPtr<WebKit::EvasGLSurface> m_evasGLSurface; + bool m_pendingSurfaceResize; #endif OwnPtr<WebKit::PageClientBase> m_pageClient; RefPtr<WebKit::WebPageProxy> m_pageProxy; diff --git a/Source/WebKit2/UIProcess/API/efl/ewk_view.cpp b/Source/WebKit2/UIProcess/API/efl/ewk_view.cpp index d5d50ed0a..349b086e9 100644 --- a/Source/WebKit2/UIProcess/API/efl/ewk_view.cpp +++ b/Source/WebKit2/UIProcess/API/efl/ewk_view.cpp @@ -387,8 +387,7 @@ static void _ewk_view_smart_calculate(Evas_Object* ewkView) impl->page()->drawingArea()->setSize(IntSize(width, height), IntSize()); #if USE(ACCELERATED_COMPOSITING) - if (width && height) - impl->createGLSurface(IntSize(width, height)); + impl->setNeedsSurfaceResize(); #endif #if USE(TILED_BACKING_STORE) impl->pageClient()->updateViewportSize(IntSize(width, height)); diff --git a/Source/WebKit2/UIProcess/API/efl/tests/test_ewk2_view.cpp b/Source/WebKit2/UIProcess/API/efl/tests/test_ewk2_view.cpp index 25fe0698b..922c3ec21 100644 --- a/Source/WebKit2/UIProcess/API/efl/tests/test_ewk2_view.cpp +++ b/Source/WebKit2/UIProcess/API/efl/tests/test_ewk2_view.cpp @@ -134,7 +134,7 @@ TEST_F(EWK2UnitTestBase, ewk_view_navigation) ASSERT_FALSE(ewk_view_forward_possible(webView())); } -TEST_F(EWK2UnitTestBase, ewk_view_setting_encoding_custom) +TEST_F(EWK2UnitTestBase, DISABLED_ewk_view_setting_encoding_custom) { ASSERT_FALSE(ewk_view_custom_encoding_get(webView())); ASSERT_TRUE(ewk_view_custom_encoding_set(webView(), "UTF-8")); diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKit2GtkAuthenticationDialog.cpp b/Source/WebKit2/UIProcess/API/gtk/WebKit2GtkAuthenticationDialog.cpp index ef2da1c98..13efe8c68 100644 --- a/Source/WebKit2/UIProcess/API/gtk/WebKit2GtkAuthenticationDialog.cpp +++ b/Source/WebKit2/UIProcess/API/gtk/WebKit2GtkAuthenticationDialog.cpp @@ -23,15 +23,40 @@ #include "AuthenticationChallengeProxy.h" #include "AuthenticationDecisionListener.h" #include "WebCredential.h" +#include "WebKitWebViewBasePrivate.h" +#include "WebKitWebViewPrivate.h" +#include <gtk/gtk.h> namespace WebKit { +// This is necessary because GtkEventBox does not draw a background by default, +// but we want it to have a normal GtkWindow background. +static gboolean drawSignal(GtkWidget* widget, cairo_t* cr, GtkStyleContext* styleContext) +{ + gtk_render_background(styleContext, cr, 0, 0, + gtk_widget_get_allocated_width(widget), gtk_widget_get_allocated_height(widget)); + return FALSE; +} + WebKit2GtkAuthenticationDialog::WebKit2GtkAuthenticationDialog(AuthenticationChallengeProxy* authenticationChallenge) - : GtkAuthenticationDialog(0, authenticationChallenge->core()) + : GtkAuthenticationDialog(authenticationChallenge->core()) , m_authenticationChallenge(authenticationChallenge) + , m_styleContext(adoptGRef(gtk_style_context_new())) { - // We aren't passing a toplevel to the GtkAuthenticationDialog constructor, - // because eventually this widget will be embedded into the WebView itself. + m_dialog = gtk_event_box_new(); + + GtkWidget* frame = gtk_frame_new(0); + gtk_frame_set_shadow_type(GTK_FRAME(frame), GTK_SHADOW_IN); + gtk_container_add(GTK_CONTAINER(m_dialog), frame); + createContentsInContainer(frame); + + gtk_style_context_add_class(m_styleContext.get(), GTK_STYLE_CLASS_BACKGROUND); + GtkWidgetPath* path = gtk_widget_path_new(); + gtk_widget_path_append_type(path, GTK_TYPE_WINDOW); + gtk_style_context_set_path(m_styleContext.get(), path); + gtk_widget_path_free(path); + + g_signal_connect(m_dialog, "draw", G_CALLBACK(drawSignal), m_styleContext.get()); } void WebKit2GtkAuthenticationDialog::authenticate(const WebCore::Credential& credential) diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKit2GtkAuthenticationDialog.h b/Source/WebKit2/UIProcess/API/gtk/WebKit2GtkAuthenticationDialog.h index 60c5e0588..67064622c 100644 --- a/Source/WebKit2/UIProcess/API/gtk/WebKit2GtkAuthenticationDialog.h +++ b/Source/WebKit2/UIProcess/API/gtk/WebKit2GtkAuthenticationDialog.h @@ -17,22 +17,32 @@ * Boston, MA 02110-1301, USA. */ +#ifndef WebKit2GtkAuthenticationDialog_h +#define WebKit2GtkAuthenticationDialog_h + #include "AuthenticationChallengeProxy.h" #include "WKRetainPtr.h" +#include "WebKitWebViewBase.h" #include <WebCore/Credential.h> #include <WebCore/GtkAuthenticationDialog.h> +#include <wtf/gobject/GRefPtr.h> namespace WebKit { class WebKit2GtkAuthenticationDialog : public WebCore::GtkAuthenticationDialog { public: WebKit2GtkAuthenticationDialog(AuthenticationChallengeProxy*); + virtual ~WebKit2GtkAuthenticationDialog() { } + GtkWidget* widget() { return m_dialog; } protected: virtual void authenticate(const WebCore::Credential&); private: RefPtr<AuthenticationChallengeProxy> m_authenticationChallenge; + GRefPtr<GtkStyleContext> m_styleContext; }; } // namespace WebKit + +#endif // WebKit2GtkAuthenticationDialog_h diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitLoaderClient.cpp b/Source/WebKit2/UIProcess/API/gtk/WebKitLoaderClient.cpp index be06eddf6..1eae26753 100644 --- a/Source/WebKit2/UIProcess/API/gtk/WebKitLoaderClient.cpp +++ b/Source/WebKit2/UIProcess/API/gtk/WebKitLoaderClient.cpp @@ -118,8 +118,7 @@ static void didChangeBackForwardList(WKPageRef page, WKBackForwardListItemRef ad static void didReceiveAuthenticationChallengeInFrame(WKPageRef page, WKFrameRef frame, WKAuthenticationChallengeRef authenticationChallenge, const void *clientInfo) { - WebKit2GtkAuthenticationDialog* dialog = new WebKit2GtkAuthenticationDialog(toImpl(authenticationChallenge)); - dialog->show(); + webkitWebViewHandleAuthenticationChallenge(WEBKIT_WEB_VIEW(clientInfo), toImpl(authenticationChallenge)); } void attachLoaderClientToView(WebKitWebView* webView) diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitWebView.cpp b/Source/WebKit2/UIProcess/API/gtk/WebKitWebView.cpp index 6598b6602..fb0c5ed9a 100644 --- a/Source/WebKit2/UIProcess/API/gtk/WebKitWebView.cpp +++ b/Source/WebKit2/UIProcess/API/gtk/WebKitWebView.cpp @@ -1261,6 +1261,7 @@ static void webkitWebViewEmitLoadChanged(WebKitWebView* webView, WebKitLoadEvent if (loadEvent == WEBKIT_LOAD_STARTED) { webkitWebViewSetIsLoading(webView, true); webkitWebViewWatchForChangesInFavicon(webView); + webkitWebViewBaseCancelAuthenticationDialog(WEBKIT_WEB_VIEW_BASE(webView)); } else if (loadEvent == WEBKIT_LOAD_FINISHED) { webkitWebViewSetIsLoading(webView, false); webView->priv->waitingForMainResource = false; @@ -1609,6 +1610,13 @@ void webkitWebViewSubmitFormRequest(WebKitWebView* webView, WebKitFormSubmission g_signal_emit(webView, signals[SUBMIT_FORM], 0, request); } +void webkitWebViewHandleAuthenticationChallenge(WebKitWebView* webView, AuthenticationChallengeProxy* authenticationChallenge) +{ + WebKit2GtkAuthenticationDialog* dialog = new WebKit2GtkAuthenticationDialog(authenticationChallenge); + webkitWebViewBaseAddAuthenticationDialog(WEBKIT_WEB_VIEW_BASE(webView), dialog); + dialog->show(); +} + /** * webkit_web_view_new: * diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitWebViewBase.cpp b/Source/WebKit2/UIProcess/API/gtk/WebKitWebViewBase.cpp index de741c2e3..c46deb27a 100644 --- a/Source/WebKit2/UIProcess/API/gtk/WebKitWebViewBase.cpp +++ b/Source/WebKit2/UIProcess/API/gtk/WebKitWebViewBase.cpp @@ -83,7 +83,7 @@ struct _WebKitWebViewBasePrivate { _WebKitWebViewBasePrivate() : imContext(adoptGRef(gtk_im_multicontext_new())) #if USE(TEXTURE_MAPPER_GL) - , redirectedWindow(RedirectedXCompositeWindow::create(IntSize(1, 1))) + , redirectedWindow(RedirectedXCompositeWindow::create(IntSize(1, 1), RedirectedXCompositeWindow::DoNotCreateGLContext)) #endif { } @@ -106,6 +106,7 @@ struct _WebKitWebViewBasePrivate { IntSize resizerSize; GRefPtr<AtkObject> accessible; bool needsResizeOnMap; + WebKit2GtkAuthenticationDialog* authenticationDialog; GtkWidget* inspectorView; unsigned inspectorViewHeight; GOwnPtr<GdkEvent> contextMenuEvent; @@ -272,16 +273,20 @@ static void webkitWebViewBaseRealize(GtkWidget* widget) webkitWebViewBaseSetToplevelOnScreenWindow(webView, GTK_WINDOW(toplevel)); } +static bool webkitWebViewChildIsInternalWidget(WebKitWebViewBase* webViewBase, GtkWidget* widget) +{ + WebKitWebViewBasePrivate* priv = webViewBase->priv; + return widget == priv->inspectorView || (priv->authenticationDialog && priv->authenticationDialog->widget() == widget); +} + static void webkitWebViewBaseContainerAdd(GtkContainer* container, GtkWidget* widget) { WebKitWebViewBase* webView = WEBKIT_WEB_VIEW_BASE(container); WebKitWebViewBasePrivate* priv = webView->priv; - if (WEBKIT_IS_WEB_VIEW_BASE(widget) - && WebInspectorProxy::isInspectorPage(WEBKIT_WEB_VIEW_BASE(widget)->priv->pageProxy.get())) { - ASSERT(!priv->inspectorView); - priv->inspectorView = widget; - } else { + // Internal widgets like the web inspector and authentication dialog have custom + // allocations so we don't need to add them to our list of children. + if (!webkitWebViewChildIsInternalWidget(webView, widget)) { GtkAllocation childAllocation; gtk_widget_get_allocation(widget, &childAllocation); priv->children.set(widget, childAllocation); @@ -290,6 +295,26 @@ static void webkitWebViewBaseContainerAdd(GtkContainer* container, GtkWidget* wi gtk_widget_set_parent(widget, GTK_WIDGET(container)); } +void webkitWebViewBaseAddAuthenticationDialog(WebKitWebViewBase* webViewBase, WebKit2GtkAuthenticationDialog* dialog) +{ + webViewBase->priv->authenticationDialog = dialog; + gtk_container_add(GTK_CONTAINER(webViewBase), dialog->widget()); + gtk_widget_queue_draw(GTK_WIDGET(webViewBase)); // We need to draw the shadow over the widget. +} + +void webkitWebViewBaseCancelAuthenticationDialog(WebKitWebViewBase* webViewBase) +{ + WebKitWebViewBasePrivate* priv = webViewBase->priv; + if (priv->authenticationDialog) + priv->authenticationDialog->destroy(); +} + +void webkitWebViewBaseAddWebInspector(WebKitWebViewBase* webViewBase, GtkWidget* inspector) +{ + webViewBase->priv->inspectorView = inspector; + gtk_container_add(GTK_CONTAINER(webViewBase), inspector); +} + static void webkitWebViewBaseContainerRemove(GtkContainer* container, GtkWidget* widget) { WebKitWebViewBase* webView = WEBKIT_WEB_VIEW_BASE(container); @@ -302,6 +327,8 @@ static void webkitWebViewBaseContainerRemove(GtkContainer* container, GtkWidget* if (priv->inspectorView == widget) { priv->inspectorView = 0; priv->inspectorViewHeight = 0; + } else if (priv->authenticationDialog && priv->authenticationDialog->widget() == widget) { + priv->authenticationDialog = 0; } else { ASSERT(priv->children.contains(widget)); priv->children.remove(widget); @@ -322,12 +349,14 @@ static void webkitWebViewBaseContainerForall(GtkContainer* container, gboolean i if (includeInternals && priv->inspectorView) (*callback)(priv->inspectorView, callbackData); + + if (includeInternals && priv->authenticationDialog) + (*callback)(priv->authenticationDialog->widget(), callbackData); } void webkitWebViewBaseChildMoveResize(WebKitWebViewBase* webView, GtkWidget* child, const IntRect& childRect) { const IntRect& geometry = webView->priv->children.get(child); - if (geometry == childRect) return; @@ -359,6 +388,8 @@ static void webkitWebViewBaseConstructed(GObject* object) if (priv->redirectedWindow) priv->redirectedWindow->setDamageNotifyCallback(redirectedWindowDamagedCallback, object); #endif + + priv->authenticationDialog = 0; } #if USE(TEXTURE_MAPPER_GL) @@ -400,6 +431,12 @@ static gboolean webkitWebViewBaseDraw(GtkWidget* widget, cairo_t* cr) WebCore::Region unpaintedRegion; // This is simply unused. drawingArea->paint(cr, clipRect, unpaintedRegion); + if (webViewBase->priv->authenticationDialog) { + cairo_set_operator(cr, CAIRO_OPERATOR_OVER); + cairo_set_source_rgba(cr, 0, 0, 0, 0.5); + cairo_paint(cr); + } + return FALSE; } @@ -434,6 +471,22 @@ static void resizeWebKitWebViewBaseFromAllocation(WebKitWebViewBase* webViewBase viewRect.setHeight(allocation->height - priv->inspectorViewHeight); } + // The authentication dialog is centered in the view rect, which means that it + // never overlaps the web inspector. Thus, we need to calculate the allocation here + // after calculating the inspector allocation. + if (priv->authenticationDialog) { + GtkRequisition naturalSize; + gtk_widget_get_preferred_size(priv->authenticationDialog->widget(), 0, &naturalSize); + + GtkAllocation childAllocation = { + (viewRect.width() - naturalSize.width) / 2, + (viewRect.height() - naturalSize.height) / 2, + naturalSize.width, + naturalSize.height + }; + gtk_widget_size_allocate(priv->authenticationDialog->widget(), &childAllocation); + } + #if USE(TEXTURE_MAPPER_GL) if (sizeChanged && webViewBase->priv->redirectedWindow) webViewBase->priv->redirectedWindow->resize(viewRect.size()); @@ -515,6 +568,9 @@ static gboolean webkitWebViewBaseKeyPressEvent(GtkWidget* widget, GdkEventKey* e WebKitWebViewBase* webViewBase = WEBKIT_WEB_VIEW_BASE(widget); WebKitWebViewBasePrivate* priv = webViewBase->priv; + if (priv->authenticationDialog) + return GTK_WIDGET_CLASS(webkit_web_view_base_parent_class)->key_press_event(widget, event); + #if ENABLE(FULLSCREEN_API) if (priv->fullScreenModeActive) { switch (event->keyval) { @@ -561,6 +617,10 @@ static gboolean webkitWebViewBaseButtonPressEvent(GtkWidget* widget, GdkEventBut { WebKitWebViewBase* webViewBase = WEBKIT_WEB_VIEW_BASE(widget); WebKitWebViewBasePrivate* priv = webViewBase->priv; + + if (priv->authenticationDialog) + return TRUE; + gtk_widget_grab_focus(widget); if (!priv->clickCounter.shouldProcessButtonEvent(buttonEvent)) @@ -579,6 +639,9 @@ static gboolean webkitWebViewBaseButtonReleaseEvent(GtkWidget* widget, GdkEventB WebKitWebViewBase* webViewBase = WEBKIT_WEB_VIEW_BASE(widget); WebKitWebViewBasePrivate* priv = webViewBase->priv; + if (priv->authenticationDialog) + return TRUE; + gtk_widget_grab_focus(widget); priv->pageProxy->handleMouseEvent(NativeWebMouseEvent(reinterpret_cast<GdkEvent*>(event), 0 /* currentClickCount */)); @@ -590,6 +653,9 @@ static gboolean webkitWebViewBaseScrollEvent(GtkWidget* widget, GdkEventScroll* WebKitWebViewBase* webViewBase = WEBKIT_WEB_VIEW_BASE(widget); WebKitWebViewBasePrivate* priv = webViewBase->priv; + if (priv->authenticationDialog) + return TRUE; + priv->pageProxy->handleWheelEvent(NativeWebWheelEvent(reinterpret_cast<GdkEvent*>(event))); return TRUE; @@ -600,6 +666,9 @@ static gboolean webkitWebViewBaseMotionNotifyEvent(GtkWidget* widget, GdkEventMo WebKitWebViewBase* webViewBase = WEBKIT_WEB_VIEW_BASE(widget); WebKitWebViewBasePrivate* priv = webViewBase->priv; + if (priv->authenticationDialog) + return TRUE; + priv->pageProxy->handleMouseEvent(NativeWebMouseEvent(reinterpret_cast<GdkEvent*>(event), 0 /* currentClickCount */)); return TRUE; @@ -737,7 +806,20 @@ static void webkitWebViewBaseParentSet(GtkWidget* widget, GtkWidget* oldParent) { if (!gtk_widget_get_parent(widget)) webkitWebViewBaseSetToplevelOnScreenWindow(WEBKIT_WEB_VIEW_BASE(widget), 0); +} + +static gboolean webkitWebViewBaseFocus(GtkWidget* widget, GtkDirectionType direction) +{ + // If the authentication dialog is active, we need to forward focus events there. This + // ensures that you can tab between elements in the box. + WebKitWebViewBasePrivate* priv = WEBKIT_WEB_VIEW_BASE(widget)->priv; + if (priv->authenticationDialog) { + gboolean returnValue; + g_signal_emit_by_name(priv->authenticationDialog->widget(), "focus", direction, &returnValue); + return returnValue; + } + return GTK_WIDGET_CLASS(webkit_web_view_base_parent_class)->focus(widget, direction); } static void webkit_web_view_base_class_init(WebKitWebViewBaseClass* webkitWebViewBaseClass) @@ -748,6 +830,7 @@ static void webkit_web_view_base_class_init(WebKitWebViewBaseClass* webkitWebVie widgetClass->size_allocate = webkitWebViewBaseSizeAllocate; widgetClass->map = webkitWebViewBaseMap; widgetClass->unmap = webkitWebViewBaseUnmap; + widgetClass->focus = webkitWebViewBaseFocus; widgetClass->focus_in_event = webkitWebViewBaseFocusInEvent; widgetClass->focus_out_event = webkitWebViewBaseFocusOutEvent; widgetClass->key_press_event = webkitWebViewBaseKeyPressEvent; diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitWebViewBasePrivate.h b/Source/WebKit2/UIProcess/API/gtk/WebKitWebViewBasePrivate.h index ef05f2289..2bd0bc002 100644 --- a/Source/WebKit2/UIProcess/API/gtk/WebKitWebViewBasePrivate.h +++ b/Source/WebKit2/UIProcess/API/gtk/WebKitWebViewBasePrivate.h @@ -29,6 +29,7 @@ #define WebKitWebViewBasePrivate_h #include "WebContextMenuProxyGtk.h" +#include "WebKit2GtkAuthenticationDialog.h" #include "WebKitPrivate.h" #include "WebKitWebViewBase.h" #include "WebPageProxy.h" @@ -64,4 +65,8 @@ typedef void (*WebKitWebViewBaseDownloadRequestHandler) (WebKitWebViewBase*, Web void webkitWebViewBaseSetDownloadRequestHandler(WebKitWebViewBase*, WebKitWebViewBaseDownloadRequestHandler); void webkitWebViewBaseHandleDownloadRequest(WebKitWebViewBase*, WebKit::DownloadProxy*); +void webkitWebViewBaseAddAuthenticationDialog(WebKitWebViewBase*, WebKit::WebKit2GtkAuthenticationDialog*); +void webkitWebViewBaseCancelAuthenticationDialog(WebKitWebViewBase*); +void webkitWebViewBaseAddWebInspector(WebKitWebViewBase*, GtkWidget* inspector); + #endif // WebKitWebViewBasePrivate_h diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitWebViewPrivate.h b/Source/WebKit2/UIProcess/API/gtk/WebKitWebViewPrivate.h index 2e1fed30e..66da58476 100644 --- a/Source/WebKit2/UIProcess/API/gtk/WebKitWebViewPrivate.h +++ b/Source/WebKit2/UIProcess/API/gtk/WebKitWebViewPrivate.h @@ -55,5 +55,6 @@ bool webkitWebViewEnterFullScreen(WebKitWebView*); bool webkitWebViewLeaveFullScreen(WebKitWebView*); void webkitWebViewPopulateContextMenu(WebKitWebView*, WebKit::ImmutableArray* proposedMenu, WebKit::WebHitTestResult*); void webkitWebViewSubmitFormRequest(WebKitWebView*, WebKitFormSubmissionRequest*); +void webkitWebViewHandleAuthenticationChallenge(WebKitWebView*, WebKit::AuthenticationChallengeProxy*); #endif // WebKitWebViewPrivate_h diff --git a/Source/WebKit2/UIProcess/API/mac/PageClientImpl.h b/Source/WebKit2/UIProcess/API/mac/PageClientImpl.h index 8768fd067..66b23e47c 100644 --- a/Source/WebKit2/UIProcess/API/mac/PageClientImpl.h +++ b/Source/WebKit2/UIProcess/API/mac/PageClientImpl.h @@ -139,6 +139,7 @@ private: virtual void recommendedScrollbarStyleDidChange(int32_t newStyle); virtual WKView* wkView() const { return m_wkView; } + virtual void intrinsicContentSizeDidChange(const WebCore::IntSize& intrinsicContentSize) OVERRIDE; #if USE(DICTATION_ALTERNATIVES) virtual uint64_t addDictationAlternatives(const RetainPtr<NSTextAlternatives>&); diff --git a/Source/WebKit2/UIProcess/API/mac/PageClientImpl.mm b/Source/WebKit2/UIProcess/API/mac/PageClientImpl.mm index 9ed7feea1..0172cb077 100644 --- a/Source/WebKit2/UIProcess/API/mac/PageClientImpl.mm +++ b/Source/WebKit2/UIProcess/API/mac/PageClientImpl.mm @@ -558,6 +558,11 @@ void PageClientImpl::recommendedScrollbarStyleDidChange(int32_t newStyle) #endif } +void PageClientImpl::intrinsicContentSizeDidChange(const IntSize& intrinsicContentSize) +{ + [m_wkView _setIntrinsicContentSize:intrinsicContentSize]; +} + bool PageClientImpl::executeSavedCommandBySelector(const String& selectorString) { return [m_wkView _executeSavedCommandBySelector:NSSelectorFromString(selectorString)]; diff --git a/Source/WebKit2/UIProcess/API/mac/WKView.mm b/Source/WebKit2/UIProcess/API/mac/WKView.mm index 4e30b3368..b1470fea9 100644 --- a/Source/WebKit2/UIProcess/API/mac/WKView.mm +++ b/Source/WebKit2/UIProcess/API/mac/WKView.mm @@ -215,6 +215,8 @@ struct WKViewInterpretKeyEventsParameters { RefPtr<WebCore::Image> _promisedImage; String _promisedFilename; String _promisedURL; + + NSSize _intrinsicContentSize; } @end @@ -356,6 +358,11 @@ struct WKViewInterpretKeyEventsParameters { return YES; } +- (NSSize)intrinsicContentSize +{ + return _data->_intrinsicContentSize; +} + - (void)setFrameSize:(NSSize)size { if (!NSEqualSizes(size, [self frame].size)) @@ -2925,6 +2932,12 @@ static NSString *pathWithUniqueFilenameForPath(NSString *path) return ![sink.get() didReceiveUnhandledCommand]; } +- (void)_setIntrinsicContentSize:(NSSize)intrinsicContentSize +{ + _data->_intrinsicContentSize = intrinsicContentSize; + [self invalidateIntrinsicContentSize]; +} + - (void)_cacheWindowBottomCornerRect { #if __MAC_OS_X_VERSION_MIN_REQUIRED >= 1070 @@ -3021,6 +3034,8 @@ static NSString *pathWithUniqueFilenameForPath(NSString *path) _data->_mouseDownEvent = nil; _data->_ignoringMouseDraggedEvents = NO; + _data->_intrinsicContentSize = NSMakeSize(NSViewNoInstrinsicMetric, NSViewNoInstrinsicMetric); + [self _registerDraggedTypes]; if ([self _shouldUseTiledDrawingArea]) { @@ -3126,6 +3141,16 @@ static NSString *pathWithUniqueFilenameForPath(NSString *path) #endif } +- (CGFloat)minimumLayoutWidth +{ + return _data->_page->minimumLayoutWidth(); +} + +- (void)setMinimumLayoutWidth:(CGFloat)minimumLayoutWidth +{ + _data->_page->setMinimumLayoutWidth(minimumLayoutWidth); +} + @end @implementation WKResponderChainSink diff --git a/Source/WebKit2/UIProcess/API/mac/WKViewInternal.h b/Source/WebKit2/UIProcess/API/mac/WKViewInternal.h index 3f612d240..9b02947a3 100644 --- a/Source/WebKit2/UIProcess/API/mac/WKViewInternal.h +++ b/Source/WebKit2/UIProcess/API/mac/WKViewInternal.h @@ -61,6 +61,7 @@ namespace WebKit { - (BOOL)_interpretKeyEvent:(NSEvent *)theEvent savingCommandsTo:(Vector<WebCore::KeypressCommand>&)commands; - (void)_doneWithKeyEvent:(NSEvent *)event eventWasHandled:(BOOL)eventWasHandled; - (bool)_executeSavedCommandBySelector:(SEL)selector; +- (void)_setIntrinsicContentSize:(NSSize)intrinsicContentSize; - (NSRect)_convertToDeviceSpace:(NSRect)rect; - (NSRect)_convertToUserSpace:(NSRect)rect; - (void)_setFindIndicator:(PassRefPtr<WebKit::FindIndicator>)findIndicator fadeOut:(BOOL)fadeOut animate:(BOOL)animate; diff --git a/Source/WebKit2/UIProcess/API/mac/WKViewPrivate.h b/Source/WebKit2/UIProcess/API/mac/WKViewPrivate.h index 51578764f..2161eb786 100644 --- a/Source/WebKit2/UIProcess/API/mac/WKViewPrivate.h +++ b/Source/WebKit2/UIProcess/API/mac/WKViewPrivate.h @@ -50,4 +50,6 @@ - (void)performDictionaryLookupAtCurrentMouseLocation; + (void)hideWordDefinitionWindow; +@property (readwrite) CGFloat minimumLayoutWidth; + @end diff --git a/Source/WebKit2/UIProcess/API/qt/qquickwebview.cpp b/Source/WebKit2/UIProcess/API/qt/qquickwebview.cpp index a45636a79..e83e13379 100644 --- a/Source/WebKit2/UIProcess/API/qt/qquickwebview.cpp +++ b/Source/WebKit2/UIProcess/API/qt/qquickwebview.cpp @@ -319,6 +319,7 @@ void QQuickWebViewPrivate::initialize(WKContextRef contextRef, WKPageGroupRef pa webPageProxy->pageGroup()->preferences()->setAcceleratedCompositingEnabled(true); webPageProxy->pageGroup()->preferences()->setForceCompositingMode(true); webPageProxy->pageGroup()->preferences()->setFrameFlatteningEnabled(true); + webPageProxy->pageGroup()->preferences()->setWebGLEnabled(true); pageClient.initialize(q_ptr, pageViewPrivate->eventHandler.data(), &undoController); webPageProxy->initializeWebPage(); diff --git a/Source/WebKit2/UIProcess/API/qt/raw/qrawwebview.cpp b/Source/WebKit2/UIProcess/API/qt/raw/qrawwebview.cpp index f5f0bd3f9..3f9c3b2ae 100644 --- a/Source/WebKit2/UIProcess/API/qt/raw/qrawwebview.cpp +++ b/Source/WebKit2/UIProcess/API/qt/raw/qrawwebview.cpp @@ -130,6 +130,11 @@ void QRawWebViewPrivate::updateTextInputState() notImplemented(); } +void QRawWebViewPrivate::handleWillSetInputMethodState() +{ + notImplemented(); +} + #if ENABLE(GESTURE_EVENTS) void QRawWebViewPrivate::doneWithGestureEvent(const WebKit::WebGestureEvent& event, bool wasEventHandled) { diff --git a/Source/WebKit2/UIProcess/API/qt/raw/qrawwebview_p_p.h b/Source/WebKit2/UIProcess/API/qt/raw/qrawwebview_p_p.h index 545096d02..7bc6f1162 100644 --- a/Source/WebKit2/UIProcess/API/qt/raw/qrawwebview_p_p.h +++ b/Source/WebKit2/UIProcess/API/qt/raw/qrawwebview_p_p.h @@ -71,6 +71,7 @@ public: #endif // USE(ACCELERATED_COMPOSITING) virtual void updateTextInputState(); + virtual void handleWillSetInputMethodState(); #if ENABLE(GESTURE_EVENTS) virtual void doneWithGestureEvent(const WebKit::WebGestureEvent& event, bool wasEventHandled); #endif diff --git a/Source/WebKit2/UIProcess/API/qt/tests/inspectorserver/inspectorserver.pro b/Source/WebKit2/UIProcess/API/qt/tests/inspectorserver/inspectorserver.pro index bc5307f2d..4a8d86f80 100644 --- a/Source/WebKit2/UIProcess/API/qt/tests/inspectorserver/inspectorserver.pro +++ b/Source/WebKit2/UIProcess/API/qt/tests/inspectorserver/inspectorserver.pro @@ -1,4 +1,4 @@ include(../tests.pri) SOURCES += $${TARGET}.cpp -QT += webkitwidgets-private +QT += webkit-private DEFINES += IMPORT_DIR=\"\\\"$${ROOT_BUILD_DIR}$${QMAKE_DIR_SEP}imports\\\"\" diff --git a/Source/WebKit2/UIProcess/API/qt/tests/publicapi/publicapi.pro b/Source/WebKit2/UIProcess/API/qt/tests/publicapi/publicapi.pro index ba8f4cea3..02dc197c7 100644 --- a/Source/WebKit2/UIProcess/API/qt/tests/publicapi/publicapi.pro +++ b/Source/WebKit2/UIProcess/API/qt/tests/publicapi/publicapi.pro @@ -1,3 +1,3 @@ include(../tests.pri) SOURCES += $${TARGET}.cpp -QT += webkitwidgets-private +QT += webkit-private diff --git a/Source/WebKit2/UIProcess/API/qt/tests/qmltests/DesktopBehavior.pro b/Source/WebKit2/UIProcess/API/qt/tests/qmltests/DesktopBehavior.pro index 7c72fd2f1..3fd3d4583 100644 --- a/Source/WebKit2/UIProcess/API/qt/tests/qmltests/DesktopBehavior.pro +++ b/Source/WebKit2/UIProcess/API/qt/tests/qmltests/DesktopBehavior.pro @@ -3,7 +3,7 @@ SOURCES += tst_qmltests.cpp TARGET = tst_qmltests_DesktopBehavior OBJECTS_DIR = obj_DesktopBehavior/$$activeBuildConfig() -QT += webkitwidgets-private +QT += webkit-private CONFIG += warn_on testcase QT += qmltest diff --git a/Source/WebKit2/UIProcess/API/qt/tests/qmltests/WebView.pro b/Source/WebKit2/UIProcess/API/qt/tests/qmltests/WebView.pro index 3e217b369..b340235e4 100644 --- a/Source/WebKit2/UIProcess/API/qt/tests/qmltests/WebView.pro +++ b/Source/WebKit2/UIProcess/API/qt/tests/qmltests/WebView.pro @@ -3,7 +3,7 @@ SOURCES += tst_qmltests.cpp TARGET = tst_qmltests_WebView OBJECTS_DIR = obj_WebView/$$activeBuildConfig() -QT += webkitwidgets-private +QT += webkit-private CONFIG += warn_on testcase QT += qmltest diff --git a/Source/WebKit2/UIProcess/API/qt/tests/qmltests/WebView/tst_resize.qml b/Source/WebKit2/UIProcess/API/qt/tests/qmltests/WebView/tst_resize.qml new file mode 100644 index 000000000..5f6c63b57 --- /dev/null +++ b/Source/WebKit2/UIProcess/API/qt/tests/qmltests/WebView/tst_resize.qml @@ -0,0 +1,175 @@ +import QtQuick 2.0 +import QtTest 1.0 +import QtWebKit 3.0 +import QtWebKit.experimental 1.0 +import Test 1.0 +import "../common" + +Item { + TestWebView { + id: webView + width: 320 + height: 480 + + property variant result + + property variant content: "data:text/html," + + "<head>" + + " <meta name='viewport' content='width=device-width'>" + + "</head>" + + "<body>" + + " <div id='target' style='width: 240px; height: 360px;'>" + + " </div>" + + "</body>" + + signal resultReceived + } + + SignalSpy { + id: resultSpy + target: webView + signalName: "resultReceived" + } + + SignalSpy { + id: scaleSpy + target: webView.experimental.test + signalName: "contentsScaleCommitted" + } + + SignalSpy { + id: sizeSpy + target: webView.experimental.test + signalName: "contentsSizeChanged" + } + + TestCase { + name: "Resize" + when: windowShown + + property variant test: webView.experimental.test + + function init() { + resultSpy.clear() + scaleSpy.clear() + viewportSpy.clear() + } + + function run(signalSpy, script) { + signalSpy.clear(); + var result; + webView.experimental.evaluateJavaScript( + script, + function(value) { webView.resultReceived(); result = value }); + signalSpy.wait(); + return result; + } + + function contentsSize() { + return test.contentsSize.width + "x" + test.contentsSize.height; + } + + function elementRect(id) { + return JSON.parse(run(resultSpy, "JSON.stringify(document.getElementById('" + id + "').getBoundingClientRect());")) + } + + function doubleTapAtPoint(x, y) { + scaleSpy.clear() + test.touchDoubleTap(webView, x, y) + scaleSpy.wait() + } + + function resize(w, h) { + sizeSpy.clear() + webView.width = w + sizeSpy.wait() + webView.height = h + sizeSpy.wait() + } + + function test_basic() { + webView.url = webView.content + verify(webView.waitForViewportReady()) + + compare(contentsSize(), "320x480") + compare(test.contentsScale, 1.0) + + resize(480, 720) + compare(contentsSize(), "480x720") + compare(test.contentsScale, 1.0) + + resize(320, 480) + compare(contentsSize(), "320x480") + compare(test.contentsScale, 1.0) + + } + + function test_resizeAfterNeutralZoom() { + webView.url = webView.content + verify(webView.waitForViewportReady()) + + compare(contentsSize(), "320x480") + compare(test.contentsScale, 1.0) + + var target = elementRect("target"); + var targetScale = webView.width / (target.width + 2 * 10) // inflated by 10px + + // Zoom in and out. + doubleTapAtPoint(100, 50) + + compare(test.contentsScale, targetScale) + + doubleTapAtPoint(100, 50) + + compare(test.contentsScale, 1.0) + + // Now check resizing still works as expected. + resize(480, 720) + compare(contentsSize(), "480x720") + compare(test.contentsScale, 1.0) + + resize(320, 480) + compare(contentsSize(), "320x480") + compare(test.contentsScale, 1.0) + } + + function test_resizeZoomedIn() { + // Note that if we change the behavior of resize on zoomed-in content, for instance + // to preserve the visible width (like rotate), this test will need to be updated. + webView.url = webView.content + verify(webView.waitForViewportReady()) + + compare(contentsSize(), "320x480") + compare(test.contentsScale, 1.0) + + var target = elementRect("target"); + var targetScale = webView.width / (target.width + 2 * 10) // inflated by 10px + + // Double tap to zoom in. + doubleTapAtPoint(100, 50) + + compare(test.contentsScale, targetScale) + + // Resize just a small bit, not changing scale. + resize(288, 432) + compare(contentsSize(), "288x432") + compare(test.contentsScale, targetScale) + + // And double tap to reset zoom. + target = elementRect("target"); + targetScale = webView.width / (target.width + 2 * 10) + doubleTapAtPoint(100, 50) + compare(test.contentsScale, targetScale) + + // Double tap again to zoom out. + doubleTapAtPoint(100, 50) + compare(contentsSize(), "288x432") + compare(test.contentsScale, 1.0) + + // And reset + resize(320, 480) + compare(contentsSize(), "320x480") + compare(test.contentsScale, 1.0) + } + } +} diff --git a/Source/WebKit2/UIProcess/API/qt/tests/qquickwebview/qquickwebview.pro b/Source/WebKit2/UIProcess/API/qt/tests/qquickwebview/qquickwebview.pro index bc5307f2d..4a8d86f80 100644 --- a/Source/WebKit2/UIProcess/API/qt/tests/qquickwebview/qquickwebview.pro +++ b/Source/WebKit2/UIProcess/API/qt/tests/qquickwebview/qquickwebview.pro @@ -1,4 +1,4 @@ include(../tests.pri) SOURCES += $${TARGET}.cpp -QT += webkitwidgets-private +QT += webkit-private DEFINES += IMPORT_DIR=\"\\\"$${ROOT_BUILD_DIR}$${QMAKE_DIR_SEP}imports\\\"\" diff --git a/Source/WebKit2/UIProcess/API/qt/tests/qrawwebview/qrawwebview.pro b/Source/WebKit2/UIProcess/API/qt/tests/qrawwebview/qrawwebview.pro index ba8f4cea3..02dc197c7 100644 --- a/Source/WebKit2/UIProcess/API/qt/tests/qrawwebview/qrawwebview.pro +++ b/Source/WebKit2/UIProcess/API/qt/tests/qrawwebview/qrawwebview.pro @@ -1,3 +1,3 @@ include(../tests.pri) SOURCES += $${TARGET}.cpp -QT += webkitwidgets-private +QT += webkit-private diff --git a/Source/WebKit2/UIProcess/API/qt/tests/tests.pri b/Source/WebKit2/UIProcess/API/qt/tests/tests.pri index 123b25ce2..a1133530d 100644 --- a/Source/WebKit2/UIProcess/API/qt/tests/tests.pri +++ b/Source/WebKit2/UIProcess/API/qt/tests/tests.pri @@ -6,7 +6,7 @@ TARGET = tst_$$TARGET INCLUDEPATH += $$PWD SOURCES += ../util.cpp -QT += testlib webkitwidgets +QT += testlib webkit have?(QTQUICK) { QT += qml quick quick-private HEADERS += ../bytearraytestdata.h \ |