diff options
author | Tomas Popela <tpopela@redhat.com> | 2014-06-25 20:11:05 +0800 |
---|---|---|
committer | Tomas Popela <tpopela@redhat.com> | 2014-06-25 21:59:50 +0800 |
commit | 177b1a6abfe7b73d7534db819d52e3d87ad76756 (patch) | |
tree | 6253884f88ce3959fc391ae020a99719270134d9 /e-util | |
parent | 04bdc935dfa2df5006ca2d8f19b4aa83901506f1 (diff) | |
download | gsoc2013-evolution-177b1a6abfe7b73d7534db819d52e3d87ad76756.tar gsoc2013-evolution-177b1a6abfe7b73d7534db819d52e3d87ad76756.tar.gz gsoc2013-evolution-177b1a6abfe7b73d7534db819d52e3d87ad76756.tar.bz2 gsoc2013-evolution-177b1a6abfe7b73d7534db819d52e3d87ad76756.tar.lz gsoc2013-evolution-177b1a6abfe7b73d7534db819d52e3d87ad76756.tar.xz gsoc2013-evolution-177b1a6abfe7b73d7534db819d52e3d87ad76756.tar.zst gsoc2013-evolution-177b1a6abfe7b73d7534db819d52e3d87ad76756.zip |
Bug 732202 - [webkit-composer] Paste scrolls view
We have to check if the caret is inside the viewport when we are trying to
scroll to it. If it is in the viewport we won't scroll.
Diffstat (limited to 'e-util')
-rw-r--r-- | e-util/e-html-editor-selection.c | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/e-util/e-html-editor-selection.c b/e-util/e-html-editor-selection.c index 1cb540b2ca..4db05b4730 100644 --- a/e-util/e-html-editor-selection.c +++ b/e-util/e-html-editor-selection.c @@ -5681,11 +5681,34 @@ e_html_editor_selection_move (EHTMLEditorSelection *selection, void e_html_editor_selection_scroll_to_caret (EHTMLEditorSelection *selection) { + glong element_top, element_left; + glong window_top, window_left, window_right, window_bottom; + EHTMLEditorView *view; + WebKitDOMDocument *document; + WebKitDOMDOMWindow *window; WebKitDOMElement *caret; caret = e_html_editor_selection_save_caret_position (selection); - webkit_dom_element_scroll_into_view (caret, TRUE); + view = e_html_editor_selection_ref_html_editor_view (selection); + document = webkit_web_view_get_dom_document (WEBKIT_WEB_VIEW (view)); + g_object_unref (view); + + window = webkit_dom_document_get_default_view (document); + + window_top = webkit_dom_dom_window_get_scroll_y (window); + window_left = webkit_dom_dom_window_get_scroll_x (window); + window_bottom = window_top + webkit_dom_dom_window_get_inner_height (window); + window_right = window_left + webkit_dom_dom_window_get_inner_width (window); + + element_left = webkit_dom_element_get_offset_left (caret); + element_top = webkit_dom_element_get_offset_top (caret); + + /* Check if caret is inside viewport, if not move to it */ + if (!(element_top >= window_top && element_top <= window_bottom && + element_left >= window_left && element_left <= window_right)) { + webkit_dom_element_scroll_into_view (caret, TRUE); + } e_html_editor_selection_clear_caret_position_marker (selection); } |