Refactor WebKitWebFrame assignment
authorChris Salzberg <chris@dejimata.com>
Thu, 22 Oct 2015 15:16:52 +0000 (00:16 +0900)
committerChris Salzberg <chris@dejimata.com>
Thu, 22 Oct 2015 15:16:52 +0000 (00:16 +0900)
src/main.c

index 132fef7..0b62ba9 100644 (file)
@@ -713,12 +713,12 @@ static void webview_download_progress_cb(WebKitWebView *view, GParamSpec *pspec)
 static void webview_load_status_cb(WebKitWebView *view, GParamSpec *pspec)
 {
     const char *uri;
+    WebKitWebFrame *frame = webkit_web_view_get_main_frame(view);
 
     switch (webkit_web_view_get_load_status(view)) {
         case WEBKIT_LOAD_PROVISIONAL:
 #ifdef FEATURE_AUTOCMD
             {
-                WebKitWebFrame *frame     = webkit_web_view_get_main_frame(view);
                 WebKitWebDataSource *src  = webkit_web_frame_get_provisional_data_source(frame);
                 WebKitNetworkRequest *req = webkit_web_data_source_get_initial_request(src);
                 uri = webkit_network_request_get_uri(req);
@@ -737,7 +737,6 @@ static void webview_load_status_cb(WebKitWebView *view, GParamSpec *pspec)
             autocmd_run(AU_LOAD_COMMITED, uri, NULL);
 #endif
             {
-                WebKitWebFrame *frame = webkit_web_view_get_main_frame(view);
                 JSContextRef ctx;
                 /* set the status */
                 if (g_str_has_prefix(uri, "https://")) {
@@ -781,14 +780,12 @@ static void webview_load_status_cb(WebKitWebView *view, GParamSpec *pspec)
                 vb_enter('n');
             }
 
-            WebKitWebFrame *frame = webkit_web_view_get_main_frame(view);
             dom_install_focus_blur_callbacks(webkit_web_frame_get_dom_document(frame));
             vb.state.done_loading_page = false;
 
             break;
 
         case WEBKIT_LOAD_FINISHED:
-            frame = webkit_web_view_get_main_frame(view);
             dom_install_focus_blur_callbacks(webkit_web_frame_get_dom_document(frame));
             uri = webkit_web_view_get_uri(view);
 #ifdef FEATURE_AUTOCMD
@@ -809,7 +806,6 @@ static void webview_load_status_cb(WebKitWebView *view, GParamSpec *pspec)
                 /* In case the requested uri could not be loaded the Current
                  * uri of the Webview would still be the PRevious one. So We
                  * use the provisional uri here. */
-                WebKitWebFrame *frame     = webkit_web_view_get_main_frame(view);
                 WebKitWebDataSource *src  = webkit_web_frame_get_provisional_data_source(frame);
                 if (src) {
                     WebKitNetworkRequest *req = webkit_web_data_source_get_initial_request(src);