WebKit Bugzilla
Attachment 370831 Details for
Bug 198324
: [GTK] Mouse wheel scroll doesn't update whole web view
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
test-wk2.c
test-wk2.c (text/x-csrc), 7.57 KB, created by
Milan Crha
on 2019-05-28 23:14:12 PDT
(
hide
)
Description:
test-wk2.c
Filename:
MIME Type:
Creator:
Milan Crha
Created:
2019-05-28 23:14:12 PDT
Size:
7.57 KB
patch
obsolete
>/* gcc `pkg-config --cflags --libs gtk+-3.0 webkit2gtk-4.0` test-wk2.c -g -O0 -o test-wk2 && ./test-wk2 */ > >#include <stdio.h> >#include <stdlib.h> >#include <string.h> >#include <gtk/gtk.h> >#include <webkit2/webkit2.h> > >static GTimer *timer = NULL; > >static void >ready_to_show_cb (WebKitWebView *web_view, > gpointer user_data) >{ > printf ("%s: after %gs\n", __FUNCTION__, g_timer_elapsed (timer, NULL)); >} > >static void >load_changed_cb (WebKitWebView *web_view, > WebKitLoadEvent load_event, > gpointer user_data) >{ > printf ("%s: %s after %gs\n", __FUNCTION__, > load_event == WEBKIT_LOAD_STARTED ? "WEBKIT_LOAD_STARTED" : > load_event == WEBKIT_LOAD_REDIRECTED ? "WEBKIT_LOAD_REDIRECTED" : > load_event == WEBKIT_LOAD_COMMITTED ? "WEBKIT_LOAD_COMMITTED" : > load_event == WEBKIT_LOAD_FINISHED ? "WEBKIT_LOAD_FINISHED" : "???", > g_timer_elapsed (timer, NULL)); >} > >static const gchar *html_content = > "<html><body>Text in body<br>" > "line1<br>" > "line2<br>" > "line3<br>" > "line4<br>" > "line5<br>" > "line6<br>" > "line7<br>" > "line8<br>" > "line9<br>" > "line10<br>" > "line11<br>" > "line12<br>" > "line13<br>" > "line14<br>" > "line15<br>" > "line16<br>" > "line17<br>" > "line18<br>" > "line19<br>" > "line20<br>" > "line21<br>" > "line22<br>" > "line23<br>" > "line24<br>" > "line25<br>" > "line26<br>" > "line27<br>" > "line28<br>" > "line29<br>" > "line30<br>" > "line31<br>" > "line32<br>" > "line33<br>" > "line34<br>" > "line35<br>" > "line36<br>" > "line37<br>" > "line38<br>" > "line39<br>" > "line40<br>" > "</body></html>"; > >static gboolean >fill_web_view_cb (gpointer web_view) >{ > webkit_web_view_load_html (web_view, html_content, "file://"); > > g_object_unref (web_view); > > return FALSE; >} > >static void >print_preview_cb (GtkWidget *button, > WebKitWebView *web_view) >{ > /*WebKitPrintOperation *prn; > > prn = webkit_print_operation_new (web_view); > webkit_print_operation_run_dialog (prn, NULL); > g_object_unref (prn);*/ > //webkit_web_inspector_show (webkit_web_view_get_inspector (web_view)); > > webkit_web_view_load_html (web_view, "<html><body>Loading...</body></html>", "file://"); > > g_timeout_add_seconds (2, fill_web_view_cb, g_object_ref (web_view)); >} > >gboolean >decide_policy_cb (WebKitWebView *web_view, > WebKitPolicyDecision *decision, > WebKitPolicyDecisionType decision_type, > gpointer user_data) >{ > printf ("%s: decision_type:%s\n", __FUNCTION__, > decision_type == WEBKIT_POLICY_DECISION_TYPE_NAVIGATION_ACTION ? "WEBKIT_POLICY_DECISION_TYPE_NAVIGATION_ACTION" : > decision_type == WEBKIT_POLICY_DECISION_TYPE_NEW_WINDOW_ACTION ? "WEBKIT_POLICY_DECISION_TYPE_NEW_WINDOW_ACTION" : > decision_type == WEBKIT_POLICY_DECISION_TYPE_RESPONSE ? "WEBKIT_POLICY_DECISION_TYPE_RESPONSE" : "??"); > if (decision_type == WEBKIT_POLICY_DECISION_TYPE_RESPONSE) { > WebKitURIRequest *req = webkit_response_policy_decision_get_request (WEBKIT_RESPONSE_POLICY_DECISION (decision)); > printf ("%s: req:'%s'\n", __FUNCTION__, webkit_uri_request_get_uri (req)); > } else if (decision_type == WEBKIT_POLICY_DECISION_TYPE_NAVIGATION_ACTION) { > WebKitNavigationAction *nav = webkit_navigation_policy_decision_get_navigation_action (WEBKIT_NAVIGATION_POLICY_DECISION (decision)); > WebKitURIRequest *req = webkit_navigation_action_get_request (nav); > printf ("%s: req:'%s'\n", __FUNCTION__, webkit_uri_request_get_uri (req)); > } else { > webkit_policy_decision_use (decision); > } > > return TRUE; >} > >static void >get_color_from_context (GtkStyleContext *context, > const gchar *name, > GdkRGBA *out_color) >{ > GdkColor *color = NULL; > > gtk_style_context_get_style (context, name, &color, NULL); > > #define hx(vl) ((gint) (255 * (vl))) > > if (color == NULL) { > gboolean is_visited = strstr (name, "visited") != NULL; > GtkStateFlags state; > > out_color->alpha = 1; > out_color->red = is_visited ? 1 : 0; > out_color->green = 0; > out_color->blue = is_visited ? 0 : 1; > > state = gtk_style_context_get_state (context); > state = state & (~(GTK_STATE_FLAG_VISITED | GTK_STATE_FLAG_LINK)); > state = state | (is_visited ? GTK_STATE_FLAG_VISITED : GTK_STATE_FLAG_LINK); > > gtk_style_context_save (context); > gtk_style_context_set_state (context, state); > gtk_style_context_get_color (context, state, out_color); > gtk_style_context_restore (context); > > printf (" %s: no '%s' property, got from style state rgba:%02x%02x%02x%02x\n", __FUNCTION__, name, > hx (out_color->red), hx (out_color->green), hx (out_color->blue), hx (out_color->alpha)); > } else { > out_color->alpha = 1; > out_color->red = ((gdouble) color->red) / G_MAXUINT16; > out_color->green = ((gdouble) color->green) / G_MAXUINT16; > out_color->blue = ((gdouble) color->blue) / G_MAXUINT16; > > gdk_color_free (color); > > printf (" %s: has '%s' property, rgba:%02x%02x%02x%02x\n", __FUNCTION__, name, > hx (out_color->red), hx (out_color->green), hx (out_color->blue), hx (out_color->alpha)); > } >} > >static gboolean >check_style_cb (gpointer user_data) >{ > GtkWidget *wk = user_data; > GtkStyleContext *style_context; > GdkRGBA rgba; > > style_context = gtk_widget_get_style_context (wk); > > get_color_from_context (style_context, "link-color", &rgba); > get_color_from_context (style_context, "visited-link-color", &rgba); > > return FALSE; >} > >int main (int argc, char *argv[]) >{ > GtkWidget *dialog, *container, *wk, *btn; > WebKitSettings *settings; > WebKitWebContext *context; > const gchar *spell_langs[2] = { "fi", NULL }; > > gtk_init (&argc, &argv); > > //g_setenv ("WEBKIT_DISABLE_COMPOSITING_MODE", "1", FALSE); > > dialog = gtk_dialog_new_with_buttons ("test-wk2", NULL, 0, "_Cancel", GTK_RESPONSE_CANCEL, NULL); > gtk_window_set_default_size (GTK_WINDOW (dialog), 320, 400); > > container = gtk_dialog_get_content_area (GTK_DIALOG (dialog)); > > btn = gtk_button_new_with_mnemonic ("_Reload"); > gtk_container_add (GTK_CONTAINER (container), btn); > > settings = webkit_settings_new_with_settings ( > "auto-load-images", FALSE, > "default-charset", "utf-8", > "enable-html5-database", FALSE, > "enable-dns-prefetching", FALSE, > "enable-html5-local-storage", FALSE, > "enable-java", FALSE, > "enable-javascript", TRUE, > "enable-offline-web-application-cache", FALSE, > "enable-page-cache", FALSE, > "enable-plugins", FALSE, > "enable-smooth-scrolling", FALSE, > "media-playback-allows-inline", FALSE, > NULL); > webkit_settings_set_enable_developer_extras (settings, TRUE); > webkit_settings_set_enable_frame_flattening (settings, TRUE); > > wk = webkit_web_view_new_with_settings (settings); > > webkit_web_view_set_editable (WEBKIT_WEB_VIEW (wk), TRUE); > > g_signal_connect (wk, "decide-policy", G_CALLBACK (decide_policy_cb), NULL); > > g_signal_connect (btn, "clicked", G_CALLBACK (print_preview_cb), wk); > > context = webkit_web_view_get_context (WEBKIT_WEB_VIEW (wk)); > webkit_web_context_set_spell_checking_enabled (context, TRUE); > > if (argc == 2) > spell_langs[0] = argv[1]; > > webkit_web_context_set_spell_checking_languages (context, (const gchar * const *) spell_langs); > > gtk_container_add (GTK_CONTAINER (container), wk); > g_object_set (G_OBJECT (wk), > "hexpand", TRUE, > "halign", GTK_ALIGN_FILL, > "vexpand", TRUE, > "valign", GTK_ALIGN_FILL, > "height-request", 90, > "width-request", 90, > NULL); > > timer = g_timer_new (); > g_signal_connect (wk, "ready-to-show", G_CALLBACK (ready_to_show_cb), NULL); > g_signal_connect (wk, "load-changed", G_CALLBACK (load_changed_cb), NULL); > webkit_web_view_load_html (WEBKIT_WEB_VIEW (wk), html_content, "file://"); > > gtk_widget_show_all (gtk_dialog_get_content_area (GTK_DIALOG (dialog))); > //gtk_widget_hide (btn); > > g_idle_add (check_style_cb, wk); > g_signal_connect (wk, "style-updated", G_CALLBACK (check_style_cb), NULL); > gtk_dialog_run (GTK_DIALOG (dialog)); > > gtk_widget_destroy (dialog); > g_timer_destroy (timer); > > return 0; >}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 198324
: 370831