NetSurf
|
implementation of user interaction with a CONTENT_HTML. More...
#include <assert.h>
#include <stdbool.h>
#include <dom/dom.h>
#include "utils/corestrings.h"
#include "utils/messages.h"
#include "utils/utils.h"
#include "utils/log.h"
#include "utils/nsoption.h"
#include "netsurf/content.h"
#include "netsurf/browser_window.h"
#include "netsurf/mouse.h"
#include "netsurf/misc.h"
#include "netsurf/layout.h"
#include "netsurf/keypress.h"
#include "content/hlcache.h"
#include "desktop/frames.h"
#include "desktop/scrollbar.h"
#include "desktop/selection.h"
#include "desktop/textarea.h"
#include "javascript/js.h"
#include "desktop/gui_internal.h"
#include "html/box.h"
#include "html/box_textarea.h"
#include "html/font.h"
#include "html/form_internal.h"
#include "html/html_internal.h"
#include "html/imagemap.h"
#include "html/search.h"
Go to the source code of this file.
Functions | |
static browser_pointer_shape | get_pointer_shape (struct box *box, bool imagemap) |
Get pointer shape for given box. More... | |
static void | html_box_drag_start (struct box *box, int x, int y) |
Start drag scrolling the contents of a box. More... | |
static size_t | html_selection_drag_end (struct html_content *html, browser_mouse_state mouse, int x, int y, int dir) |
End overflow scroll scrollbar drags. More... | |
void | html_mouse_track (struct content *c, struct browser_window *bw, browser_mouse_state mouse, int x, int y) |
Handle mouse tracking (including drags) in an HTML content window. More... | |
static void | html__image_coords_dom_user_data_handler (dom_node_operation operation, dom_string *key, void *_data, struct dom_node *src, struct dom_node *dst) |
Helper for file gadgets to store their filename. More... | |
static void | html_overflow_scroll_drag_end (struct scrollbar *scrollbar, browser_mouse_state mouse, int x, int y) |
End overflow scroll scrollbar drags. More... | |
void | html_mouse_action (struct content *c, struct browser_window *bw, browser_mouse_state mouse, int x, int y) |
Handle mouse clicks and movements in an HTML content window. More... | |
bool | html_keypress (struct content *c, uint32_t key) |
Handle keypresses. More... | |
void | html_search (struct content *c, void *context, search_flags_t flags, const char *string) |
Handle search. More... | |
void | html_search_clear (struct content *c) |
Terminate a search. More... | |
void | html_overflow_scroll_callback (void *client_data, struct scrollbar_msg_data *scrollbar_data) |
Callback for in-page scrollbars. More... | |
void | html_set_drag_type (html_content *html, html_drag_type drag_type, union html_drag_owner drag_owner, const struct rect *rect) |
Set our drag status, and inform whatever owns the content. More... | |
void | html_set_focus (html_content *html, html_focus_type focus_type, union html_focus_owner focus_owner, bool hide_caret, int x, int y, int height, const struct rect *clip) |
Set our input focus, and inform whatever owns the content. More... | |
void | html_set_selection (html_content *html, html_selection_type selection_type, union html_selection_owner selection_owner, bool read_only) |
Set our selection status, and inform whatever owns the content. More... | |
implementation of user interaction with a CONTENT_HTML.
Definition in file html_interaction.c.
|
static |
Get pointer shape for given box.
box | box in question |
imagemap | whether an imagemap applies to the box |
Definition at line 66 of file html_interaction.c.
References BOX_FLOAT_LEFT, BOX_FLOAT_RIGHT, BROWSER_POINTER_AUTO, BROWSER_POINTER_CARET, BROWSER_POINTER_CROSS, BROWSER_POINTER_DEFAULT, BROWSER_POINTER_DOWN, BROWSER_POINTER_HELP, BROWSER_POINTER_LD, BROWSER_POINTER_LEFT, BROWSER_POINTER_LU, BROWSER_POINTER_MOVE, BROWSER_POINTER_POINT, BROWSER_POINTER_PROGRESS, BROWSER_POINTER_RD, BROWSER_POINTER_RIGHT, BROWSER_POINTER_RU, BROWSER_POINTER_UP, BROWSER_POINTER_WAIT, box::children, box::gadget, GADGET_IMAGE, GADGET_PASSWORD, GADGET_SUBMIT, GADGET_TEXTAREA, GADGET_TEXTBOX, box::href, box::style, form_control::type, and box::type.
Referenced by html_mouse_action().
|
static |
Helper for file gadgets to store their filename.
Stores the filename unencoded on the dom node associated with the gadget.
operation | DOM operation |
key | DOM node key being considerd |
_data | The data assocated with the key |
src | The source DOM node. |
dst | The destination DOM node. |
Definition at line 254 of file html_interaction.c.
References NSLOG.
Referenced by html_mouse_action().
|
static |
Start drag scrolling the contents of a box.
box | the box to be scrolled |
x | x ordinate of initial mouse position |
y | y ordinate |
Definition at line 164 of file html_interaction.c.
References BOTTOM, box_coords(), box::height, LEFT, box::padding, RIGHT, box::scroll_x, box::scroll_y, scrollbar_start_content_drag(), SCROLLBAR_WIDTH, TOP, and box::width.
Referenced by html_mouse_action().
bool html_keypress | ( | struct content * | c, |
uint32_t | key | ||
) |
Handle keypresses.
c | content of type HTML |
key | The UCS4 character codepoint |
Definition at line 1124 of file html_interaction.c.
References box_textarea_keypress(), html_focus_owner::content, content_keypress(), html_content::focus_owner, html_content::focus_type, HTML_FOCUS_CONTENT, HTML_FOCUS_TEXTAREA, NS_KEY_CLEAR_SELECTION, NS_KEY_COPY_SELECTION, NS_KEY_ESCAPE, NS_KEY_SELECT_ALL, NSERROR_OK, box::object, html_content::sel, selection_clear(), selection_copy_to_clipboard(), selection_defined, selection_select_all(), and html_focus_owner::textarea.
void html_mouse_action | ( | struct content * | c, |
struct browser_window * | bw, | ||
browser_mouse_state | mouse, | ||
int | x, | ||
int | y | ||
) |
Handle mouse clicks and movements in an HTML content window.
c | content of type html |
bw | browser window |
mouse | state of mouse buttons and modifier keys |
x | coordinate of mouse |
y | coordinate of mouse |
This function handles both hovering and clicking. It is important that the code path is identical (except that hovering doesn't carry out the action), so that the status bar reflects exactly what will happen. Having separate code paths opens the possibility that an attacker will make the status bar show some harmless action where clicking will be harmful.
Definition at line 352 of file html_interaction.c.
References form::action, box::border, BOTTOM, form_control::box, html_scrollbar_data::box, box_at_point(), box_coords(), box_pick_text_box(), BROWSER_MOUSE_CLICK_1, BROWSER_MOUSE_CLICK_2, BROWSER_MOUSE_DRAG_1, BROWSER_MOUSE_DRAG_2, BROWSER_MOUSE_MOD_1, BROWSER_MOUSE_MOD_2, BROWSER_MOUSE_PRESS_1, BROWSER_MOUSE_PRESS_2, BROWSER_POINTER_DEFAULT, BROWSER_POINTER_MENU, BROWSER_POINTER_MOVE, browser_window_find_target(), browser_window_frame_resize_start(), browser_window_get_content(), browser_window_get_drag_type(), browser_window_get_position(), browser_window_get_scale(), browser_window_mouse_click(), browser_window_mouse_track(), browser_window_navigate(), browser_window_page_drag_start(), BW_NAVIGATE_DOWNLOAD, BW_NAVIGATE_HISTORY, box::byte_offset, html_drag_owner::content, html_selection_owner::content, content_msg_data::content, content_broadcast(), content_get_type(), content_get_url(), CONTENT_HTML, content_mouse_action(), content_mouse_track(), CONTENT_MSG_DRAGSAVE, CONTENT_MSG_GADGETCLICK, CONTENT_MSG_POINTER, CONTENT_MSG_SAVELINK, CONTENT_MSG_SELECTMENU, CONTENT_MSG_STATUS, content_request_redraw(), form_control::data, html_content::drag_owner, html_content::drag_type, DRAGGING_NONE, content_msg_data::dragsave, content_msg_data::explicit_status_text, fire_dom_event(), html_content::focus_type, font_plot_style_from_css(), form_control::form, form_open_select_menu(), form_radio_set(), form_select_get_dimensions(), form_select_menu_callback(), form_select_mouse_action(), form_select_mouse_drag_end(), form_submit(), content_msg_data::gadget, box::gadget, GADGET_BUTTON, GADGET_CHECKBOX, content_msg_data::gadget_click, GADGET_FILE, GADGET_HIDDEN, GADGET_IMAGE, GADGET_PASSWORD, GADGET_RADIO, GADGET_RESET, GADGET_SELECT, GADGET_SUBMIT, GADGET_TEXTAREA, GADGET_TEXTBOX, get_pointer_shape(), guit, box::height, height, box::href, html__image_coords_dom_user_data_handler(), html__redraw_a_box(), html_box_drag_start(), HTML_DRAG_CONTENT_SCROLL, HTML_DRAG_CONTENT_SELECTION, HTML_DRAG_NONE, HTML_DRAG_SCROLLBAR, HTML_DRAG_SELECTION, HTML_DRAG_TEXTAREA_SCROLLBAR, HTML_DRAG_TEXTAREA_SELECTION, HTML_FOCUS_SELF, html_overflow_scroll_drag_end(), HTML_SELECTION_CONTENT, html_selection_drag_end(), HTML_SELECTION_NONE, HTML_SELECTION_SELF, HTML_SELECTION_TEXTAREA, html_set_drag_type(), html_set_focus(), html_set_selection(), box::iframe, imagemap_get(), html_content::layout, netsurf_table::layout, LEFT, html_content::len_ctx, box::length, box::margin, messages_get(), messages_get_errorcode(), html_drag_owner::no_owner, form_control::node, box::node, html_selection_owner::none, NSERROR_OK, NSLOG, nsoption_bool, nsurl_access(), nsurl_get_utf8(), box::object, box::padding, content_msg_data::pointer, gui_layout_table::position, RIGHT, content_msg_data::savelink, box::scroll_x, box::scroll_y, html_drag_owner::scrollbar, scrollbar_get_data(), scrollbar_get_offset(), scrollbar_is_horizontal(), scrollbar_mouse_action(), scrollbar_mouse_status_to_message(), SCROLLBAR_WIDTH, html_content::sel, content_msg_data::select_menu, form_control::selected, selection_clear(), selection_click(), selection_defined, selection_dragging, selection_dragging_start, html_content::selection_owner, selection_track(), html_content::selection_type, html_focus_owner::self, box::style, form::target, box::target, box::text, html_drag_owner::textarea, html_selection_owner::textarea, textarea_mouse_action(), TEXTAREA_MOUSE_EDITOR, content_msg_data::title, box::title, TOP, form_control::type, content_msg_data::type, content_msg_data::url, box::usemap, html_content::visible_select_menu, box_border::width, box::width, width, image_input_coords::x, and image_input_coords::y.
Referenced by html_mouse_track().
void html_mouse_track | ( | struct content * | c, |
struct browser_window * | bw, | ||
browser_mouse_state | mouse, | ||
int | x, | ||
int | y | ||
) |
Handle mouse tracking (including drags) in an HTML content window.
c | content of type html |
bw | browser window |
mouse | state of mouse buttons and modifier keys |
x | coordinate of mouse |
y | coordinate of mouse |
Definition at line 233 of file html_interaction.c.
References html_mouse_action().
void html_overflow_scroll_callback | ( | void * | client_data, |
struct scrollbar_msg_data * | scrollbar_data | ||
) |
Callback for in-page scrollbars.
Definition at line 1250 of file html_interaction.c.
References html_scrollbar_data::box, BROWSER_POINTER_AUTO, html_scrollbar_data::c, content_broadcast(), CONTENT_MSG_POINTER, html__redraw_a_box(), HTML_DRAG_NONE, HTML_DRAG_SCROLLBAR, html_set_drag_type(), scrollbar_msg_data::msg, html_content::reflowing, scrollbar_msg_data::scrollbar, SCROLLBAR_MSG_MOVED, SCROLLBAR_MSG_SCROLL_FINISHED, SCROLLBAR_MSG_SCROLL_START, rect::x0, scrollbar_msg_data::x0, scrollbar_msg_data::x1, scrollbar_msg_data::y0, and scrollbar_msg_data::y1.
Referenced by box_handle_scrollbars().
|
static |
End overflow scroll scrollbar drags.
scrollbar | scrollbar widget |
mouse | state of mouse buttons and modifier keys |
x | coordinate of mouse |
y | coordinate of mouse |
Definition at line 307 of file html_interaction.c.
References BOTTOM, html_scrollbar_data::box, box_coords(), box::height, LEFT, box::padding, RIGHT, scrollbar_get_data(), scrollbar_is_horizontal(), scrollbar_mouse_drag_end(), SCROLLBAR_WIDTH, TOP, and box::width.
Referenced by html_mouse_action().
void html_search | ( | struct content * | c, |
void * | context, | ||
search_flags_t | flags, | ||
const char * | string | ||
) |
Handle search.
c | content of type HTML |
context | front end private data |
flags | search flags |
string | search string |
Definition at line 1181 of file html_interaction.c.
References CONTENT_HTML, html_search_clear(), html_content::search, search_create_context(), search_destroy_context(), search_step(), and html_content::search_string.
void html_search_clear | ( | struct content * | c | ) |
Terminate a search.
c | content of type HTML |
Definition at line 1231 of file html_interaction.c.
References html_content::search, search_destroy_context(), and html_content::search_string.
Referenced by html_search().
|
static |
End overflow scroll scrollbar drags.
html | html content |
mouse | state of mouse buttons and modifier keys |
x | coordinate of mouse |
y | coordinate of mouse |
dir | Direction of drag |
Definition at line 199 of file html_interaction.c.
References box_pick_text_box(), box::byte_offset, font_plot_style_from_css(), guit, netsurf_table::layout, html_content::len_ctx, box::length, gui_layout_table::position, box::style, and box::text.
Referenced by html_mouse_action().
void html_set_drag_type | ( | html_content * | html, |
html_drag_type | drag_type, | ||
union html_drag_owner | drag_owner, | ||
const struct rect * | rect | ||
) |
Set our drag status, and inform whatever owns the content.
html | HTML content |
drag_type | Type of drag |
drag_owner | What owns the drag |
rect | Pointer movement bounds |
Definition at line 1297 of file html_interaction.c.
References content_broadcast(), content_msg_data::CONTENT_DRAG_NONE, content_msg_data::CONTENT_DRAG_SCROLL, content_msg_data::CONTENT_DRAG_SELECTION, CONTENT_MSG_DRAG, content_msg_data::drag, html_content::drag_owner, html_content::drag_type, HTML_DRAG_CONTENT_SCROLL, HTML_DRAG_CONTENT_SELECTION, HTML_DRAG_NONE, HTML_DRAG_SCROLLBAR, HTML_DRAG_SELECTION, HTML_DRAG_TEXTAREA_SCROLLBAR, HTML_DRAG_TEXTAREA_SELECTION, html_drag_owner::no_owner, content_msg_data::rect, and content_msg_data::type.
Referenced by box_textarea_callback(), html_mouse_action(), html_object_callback(), and html_overflow_scroll_callback().
void html_set_focus | ( | html_content * | html, |
html_focus_type | focus_type, | ||
union html_focus_owner | focus_owner, | ||
bool | hide_caret, | ||
int | x, | ||
int | y, | ||
int | height, | ||
const struct rect * | clip | ||
) |
Set our input focus, and inform whatever owns the content.
html | HTML content |
focus_type | Type of input focus |
focus_owner | What owns the focus |
hide_caret | True iff caret to be hidden |
x | Carret x-coord rel to owner |
y | Carret y-coord rel to owner |
height | Carret height |
clip | Carret clip rect |
Definition at line 1334 of file html_interaction.c.
References box_coords(), content_msg_data::caret, clip(), html_focus_owner::content, content_broadcast(), CONTENT_MSG_CARET, html_content::focus_owner, html_content::focus_type, height, HTML_FOCUS_CONTENT, HTML_FOCUS_SELF, HTML_FOCUS_TEXTAREA, content_msg_data::pos, html_focus_owner::self, html_focus_owner::textarea, content_msg_data::type, rect::x0, rect::x1, rect::y0, and rect::y1.
Referenced by box_textarea_callback(), html_mouse_action(), and html_object_callback().
void html_set_selection | ( | html_content * | html, |
html_selection_type | selection_type, | ||
union html_selection_owner | selection_owner, | ||
bool | read_only | ||
) |
Set our selection status, and inform whatever owns the content.
html | HTML content |
selection_type | Type of selection |
selection_owner | What owns the selection |
read_only | True iff selection is read only |
Definition at line 1392 of file html_interaction.c.
References html_selection_owner::content, content_broadcast(), content_clear_selection(), CONTENT_MSG_SELECTION, form_control::data, box::gadget, HTML_SELECTION_CONTENT, HTML_SELECTION_NONE, HTML_SELECTION_SELF, HTML_SELECTION_TEXTAREA, html_selection_owner::none, box::object, html_content::sel, content_msg_data::selection, selection_clear(), html_content::selection_owner, html_content::selection_type, html_selection_owner::textarea, and textarea_clear_selection().
Referenced by box_textarea_callback(), html_mouse_action(), and html_object_callback().