summaryrefslogtreecommitdiff
path: root/Source/WebKit2/UIProcess/API/gtk/WebKitWebView.cpp
diff options
context:
space:
mode:
authorSimon Hausmann <simon.hausmann@nokia.com>2012-08-21 10:57:44 +0200
committerSimon Hausmann <simon.hausmann@nokia.com>2012-08-21 10:57:44 +0200
commit5ef7c8a6a70875d4430752d146bdcb069605d71d (patch)
treef6256640b6c46d7da221435803cae65326817ba2 /Source/WebKit2/UIProcess/API/gtk/WebKitWebView.cpp
parentdecad929f578d8db641febc8740649ca6c574638 (diff)
downloadqtwebkit-5ef7c8a6a70875d4430752d146bdcb069605d71d.tar.gz
Imported WebKit commit 356d83016b090995d08ad568f2d2c243aa55e831 (http://svn.webkit.org/repository/webkit/trunk@126147)
New snapshot including various build fixes for newer Qt 5
Diffstat (limited to 'Source/WebKit2/UIProcess/API/gtk/WebKitWebView.cpp')
-rw-r--r--Source/WebKit2/UIProcess/API/gtk/WebKitWebView.cpp150
1 files changed, 46 insertions, 104 deletions
diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitWebView.cpp b/Source/WebKit2/UIProcess/API/gtk/WebKitWebView.cpp
index 80e5fff23..ee86d448a 100644
--- a/Source/WebKit2/UIProcess/API/gtk/WebKitWebView.cpp
+++ b/Source/WebKit2/UIProcess/API/gtk/WebKitWebView.cpp
@@ -79,7 +79,7 @@ enum {
MOUSE_TARGET_CHANGED,
- PRINT_REQUESTED,
+ PRINT,
RESOURCE_LOAD_STARTED,
@@ -106,13 +106,6 @@ enum {
PROP_ZOOM_LEVEL
};
-typedef enum {
- NotReplacingContent,
- WillReplaceContent,
- ReplacingContent,
- DidReplaceContent
-} ReplaceContentStatus;
-
typedef HashMap<uint64_t, GRefPtr<WebKitWebResource> > LoadingResourcesMap;
typedef HashMap<String, GRefPtr<WebKitWebResource> > ResourcesMap;
@@ -122,7 +115,6 @@ struct _WebKitWebViewPrivate {
CString customTextEncoding;
double estimatedLoadProgress;
CString activeURI;
- ReplaceContentStatus replaceContentStatus;
bool waitingForMainResource;
gulong mainResourceResponseHandlerID;
@@ -159,7 +151,7 @@ static gboolean webkitWebViewLoadFail(WebKitWebView* webView, WebKitLoadEvent, c
return FALSE;
GOwnPtr<char> htmlString(g_strdup_printf("<html><body>%s</body></html>", error->message));
- webkit_web_view_replace_content(webView, htmlString.get(), failingURI, 0);
+ webkit_web_view_load_alternate_html(webView, htmlString.get(), failingURI, 0);
return TRUE;
}
@@ -882,7 +874,7 @@ static void webkit_web_view_class_init(WebKitWebViewClass* webViewClass)
WEBKIT_TYPE_HIT_TEST_RESULT,
G_TYPE_UINT);
/**
- * WebKitWebView::print-requested:
+ * WebKitWebView::print:
* @web_view: the #WebKitWebView on which the signal is emitted
* @print_operation: the #WebKitPrintOperation that will handle the print request
*
@@ -899,11 +891,11 @@ static void webkit_web_view_class_init(WebKitWebViewClass* webViewClass)
* Returns: %TRUE to stop other handlers from being invoked for the event.
* %FALSE to propagate the event further.
*/
- signals[PRINT_REQUESTED] =
- g_signal_new("print-requested",
+ signals[PRINT] =
+ g_signal_new("print",
G_TYPE_FROM_CLASS(webViewClass),
G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET(WebKitWebViewClass, print_requested),
+ G_STRUCT_OFFSET(WebKitWebViewClass, print),
g_signal_accumulator_true_handled, 0,
webkit_marshal_BOOLEAN__OBJECT,
G_TYPE_BOOLEAN, 1,
@@ -1107,25 +1099,6 @@ static void webkit_web_view_class_init(WebKitWebViewClass* webViewClass)
WEBKIT_TYPE_FORM_SUBMISSION_REQUEST);
}
-static bool updateReplaceContentStatus(WebKitWebView* webView, WebKitLoadEvent loadEvent)
-{
- if (webView->priv->replaceContentStatus == ReplacingContent) {
- if (loadEvent == WEBKIT_LOAD_FINISHED)
- webView->priv->replaceContentStatus = DidReplaceContent;
- return true;
- }
-
- if (loadEvent == WEBKIT_LOAD_STARTED) {
- if (webView->priv->replaceContentStatus == WillReplaceContent) {
- webView->priv->replaceContentStatus = ReplacingContent;
- return true;
- }
- webView->priv->replaceContentStatus = NotReplacingContent;
- }
-
- return false;
-}
-
static void setCertificateToMainResource(WebKitWebView* webView)
{
WebKitWebViewPrivate* priv = webView->priv;
@@ -1169,21 +1142,16 @@ void webkitWebViewLoadChanged(WebKitWebView* webView, WebKitLoadEvent loadEvent)
webView->priv->waitingForMainResource = false;
} else if (loadEvent == WEBKIT_LOAD_COMMITTED) {
webView->priv->subresourcesMap.clear();
- if (webView->priv->replaceContentStatus != ReplacingContent) {
- if (!webView->priv->mainResource) {
- // When a page is loaded from the history cache, the main resource load callbacks
- // are called when the main frame load is finished. We want to make sure there's a
- // main resource available when load has been committed, so we delay the emission of
- // load-changed signal until main resource object has been created.
- webView->priv->waitingForMainResource = true;
- } else
- setCertificateToMainResource(webView);
- }
+ if (!webView->priv->mainResource) {
+ // When a page is loaded from the history cache, the main resource load callbacks
+ // are called when the main frame load is finished. We want to make sure there's a
+ // main resource available when load has been committed, so we delay the emission of
+ // load-changed signal until main resource object has been created.
+ webView->priv->waitingForMainResource = true;
+ } else
+ setCertificateToMainResource(webView);
}
- if (updateReplaceContentStatus(webView, loadEvent))
- return;
-
if (webView->priv->waitingForMainResource)
webView->priv->lastDelayedEvent = loadEvent;
else
@@ -1192,9 +1160,6 @@ void webkitWebViewLoadChanged(WebKitWebView* webView, WebKitLoadEvent loadEvent)
void webkitWebViewLoadFailed(WebKitWebView* webView, WebKitLoadEvent loadEvent, const char* failingURI, GError *error)
{
- if (webView->priv->replaceContentStatus == ReplacingContent)
- return;
-
gboolean returnValue;
g_signal_emit(webView, signals[LOAD_FAILED], 0, loadEvent, failingURI, error, &returnValue);
g_signal_emit(webView, signals[LOAD_CHANGED], 0, WEBKIT_LOAD_FINISHED);
@@ -1212,9 +1177,6 @@ void webkitWebViewSetTitle(WebKitWebView* webView, const CString& title)
void webkitWebViewSetEstimatedLoadProgress(WebKitWebView* webView, double estimatedLoadProgress)
{
- if (webView->priv->replaceContentStatus != NotReplacingContent)
- return;
-
if (webView->priv->estimatedLoadProgress == estimatedLoadProgress)
return;
@@ -1321,7 +1283,7 @@ void webkitWebViewPrintFrame(WebKitWebView* webView, WKFrameRef wkFrame)
{
GRefPtr<WebKitPrintOperation> printOperation = adoptGRef(webkit_print_operation_new(webView));
gboolean returnValue;
- g_signal_emit(webView, signals[PRINT_REQUESTED], 0, printOperation.get(), &returnValue);
+ g_signal_emit(webView, signals[PRINT], 0, printOperation.get(), &returnValue);
if (returnValue)
return;
@@ -1349,16 +1311,8 @@ static void waitForMainResourceResponseIfWaitingForResource(WebKitWebView* webVi
g_signal_connect(priv->mainResource.get(), "notify::response", G_CALLBACK(mainResourceResponseChangedCallback), webView);
}
-static inline bool webkitWebViewIsReplacingContentOrDidReplaceContent(WebKitWebView* webView)
-{
- return (webView->priv->replaceContentStatus == ReplacingContent || webView->priv->replaceContentStatus == DidReplaceContent);
-}
-
void webkitWebViewResourceLoadStarted(WebKitWebView* webView, WKFrameRef wkFrame, uint64_t resourceIdentifier, WebKitURIRequest* request, bool isMainResource)
{
- if (webkitWebViewIsReplacingContentOrDidReplaceContent(webView))
- return;
-
WebKitWebViewPrivate* priv = webView->priv;
WebKitWebResource* resource = webkitWebResourceCreate(wkFrame, request, isMainResource);
if (WKFrameIsMainFrame(wkFrame) && (isMainResource || !priv->mainResource)) {
@@ -1371,9 +1325,6 @@ void webkitWebViewResourceLoadStarted(WebKitWebView* webView, WKFrameRef wkFrame
WebKitWebResource* webkitWebViewGetLoadingWebResource(WebKitWebView* webView, uint64_t resourceIdentifier)
{
- if (webkitWebViewIsReplacingContentOrDidReplaceContent(webView))
- return 0;
-
GRefPtr<WebKitWebResource> resource = webView->priv->loadingResourcesMap.get(resourceIdentifier);
ASSERT(resource.get());
return resource.get();
@@ -1381,9 +1332,6 @@ WebKitWebResource* webkitWebViewGetLoadingWebResource(WebKitWebView* webView, ui
void webkitWebViewRemoveLoadingWebResource(WebKitWebView* webView, uint64_t resourceIdentifier)
{
- if (webkitWebViewIsReplacingContentOrDidReplaceContent(webView))
- return;
-
WebKitWebViewPrivate* priv = webView->priv;
ASSERT(priv->loadingResourcesMap.contains(resourceIdentifier));
priv->loadingResourcesMap.remove(resourceIdentifier);
@@ -1391,9 +1339,6 @@ void webkitWebViewRemoveLoadingWebResource(WebKitWebView* webView, uint64_t reso
WebKitWebResource* webkitWebViewResourceLoadFinished(WebKitWebView* webView, uint64_t resourceIdentifier)
{
- if (webkitWebViewIsReplacingContentOrDidReplaceContent(webView))
- return 0;
-
WebKitWebViewPrivate* priv = webView->priv;
WebKitWebResource* resource = webkitWebViewGetLoadingWebResource(webView, resourceIdentifier);
if (resource != priv->mainResource)
@@ -1597,6 +1542,33 @@ void webkit_web_view_load_html(WebKitWebView* webView, const gchar* content, con
}
/**
+ * webkit_web_view_load_alternate_html:
+ * @web_view: a #WebKitWebView
+ * @content: the new content to display as the main page of the @web_view
+ * @content_uri: the URI for the alternate page content
+ * @base_uri: (allow-none): the base URI for relative locations or %NULL
+ *
+ * Load the given @content string for the URI @content_uri.
+ * This allows clients to display page-loading errors in the #WebKitWebView itself.
+ * When this method is called from #WebKitWebView::load-failed signal to show an
+ * error page, the the back-forward list is maintained appropriately.
+ * For everything else this method works the same way as webkit_web_view_load_html().
+ */
+void webkit_web_view_load_alternate_html(WebKitWebView* webView, const gchar* content, const gchar* contentURI, const gchar* baseURI)
+{
+ g_return_if_fail(WEBKIT_IS_WEB_VIEW(webView));
+ g_return_if_fail(content);
+ g_return_if_fail(contentURI);
+
+ WKRetainPtr<WKStringRef> htmlString(AdoptWK, WKStringCreateWithUTF8CString(content));
+ WKRetainPtr<WKURLRef> contentURL(AdoptWK, WKURLCreateWithUTF8CString(contentURI));
+ WKRetainPtr<WKURLRef> baseURL = baseURI ? adoptWK(WKURLCreateWithUTF8CString(baseURI)) : 0;
+ WebPageProxy* page = webkitWebViewBaseGetPage(WEBKIT_WEB_VIEW_BASE(webView));
+ WKPageLoadAlternateHTMLString(toAPI(page), htmlString.get(), baseURL.get(), contentURL.get());
+ webkitWebViewUpdateURI(webView);
+}
+
+/**
* webkit_web_view_load_plain_text:
* @web_view: a #WebKitWebView
* @plain_text: The plain text to load
@@ -1637,36 +1609,6 @@ void webkit_web_view_load_request(WebKitWebView* webView, WebKitURIRequest* requ
}
/**
- * webkit_web_view_replace_content:
- * @web_view: a #WebKitWebView
- * @content: the new content to display as the main page of the @web_view
- * @content_uri: the URI for the page content
- * @base_uri: (allow-none): the base URI for relative locations or %NULL
- *
- * Replace the content of @web_view with @content using @content_uri as page URI.
- * This allows clients to display page-loading errors in the #WebKitWebView itself.
- * This is typically called from #WebKitWebView::load-failed signal. The URI passed in
- * @base_uri has to be an absolute URI. The mime type of the document will be "text/html".
- * Signals #WebKitWebView::load-changed and #WebKitWebView::load-failed are not emitted
- * when replacing content of a #WebKitWebView using this method.
- */
-void webkit_web_view_replace_content(WebKitWebView* webView, const gchar* content, const gchar* contentURI, const gchar* baseURI)
-{
- g_return_if_fail(WEBKIT_IS_WEB_VIEW(webView));
- g_return_if_fail(content);
- g_return_if_fail(contentURI);
-
- webView->priv->replaceContentStatus = WillReplaceContent;
-
- WKRetainPtr<WKStringRef> htmlString(AdoptWK, WKStringCreateWithUTF8CString(content));
- WKRetainPtr<WKURLRef> contentURL(AdoptWK, WKURLCreateWithUTF8CString(contentURI));
- WKRetainPtr<WKURLRef> baseURL = baseURI ? adoptWK(WKURLCreateWithUTF8CString(baseURI)) : 0;
- WebPageProxy* page = webkitWebViewBaseGetPage(WEBKIT_WEB_VIEW_BASE(webView));
- WKPageLoadAlternateHTMLString(toAPI(page), htmlString.get(), baseURL.get(), contentURL.get());
- webkitWebViewUpdateURI(webView);
-}
-
-/**
* webkit_web_view_get_title:
* @web_view: a #WebKitWebView
*
@@ -1815,6 +1757,10 @@ gboolean webkit_web_view_can_go_forward(WebKitWebView* webView)
* the requested URI is "about:blank".
* </para></listitem>
* <listitem><para>
+ * If the load operation was started by webkit_web_view_load_alternate_html(),
+ * the requested URI is content URI provided.
+ * </para></listitem>
+ * <listitem><para>
* If the load operation was started by webkit_web_view_go_back() or
* webkit_web_view_go_forward(), the requested URI is the original URI
* of the previous/next item in the #WebKitBackForwardList of @web_view.
@@ -1838,10 +1784,6 @@ gboolean webkit_web_view_can_go_forward(WebKitWebView* webView)
* one and it will not change unless a new load operation is started
* or a navigation action within the same page is performed.
* </para></listitem>
- * <listitem><para>
- * When the page content is replaced using webkit_web_view_replace_content(),
- * the active URI is the content_uri provided.
- * </para></listitem>
* </orderedlist>
*
* You can monitor the active URI by connecting to the notify::uri