2010-06-04 13:35:08 +04:00
|
|
|
/*
|
|
|
|
* Copyright 2006 James Bursa <bursa@users.sourceforge.net>
|
|
|
|
* Copyright 2006 Richard Wilson <info@tinct.net>
|
|
|
|
* Copyright 2008 Michael Drake <tlsa@netsurf-browser.org>
|
|
|
|
* Copyright 2009 Paul Blokus <paul_pl@users.sourceforge.net>
|
|
|
|
*
|
|
|
|
* This file is part of NetSurf, http://www.netsurf-browser.org/
|
|
|
|
*
|
|
|
|
* NetSurf is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; version 2 of the License.
|
|
|
|
*
|
|
|
|
* NetSurf is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/** \file
|
|
|
|
* User interaction with a CONTENT_HTML (implementation).
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <assert.h>
|
|
|
|
#include <stdbool.h>
|
|
|
|
|
2012-03-25 00:55:22 +04:00
|
|
|
#include <dom/dom.h>
|
|
|
|
|
2010-06-04 13:35:08 +04:00
|
|
|
#include "content/content.h"
|
|
|
|
#include "desktop/browser.h"
|
|
|
|
#include "desktop/frames.h"
|
|
|
|
#include "desktop/mouse.h"
|
|
|
|
#include "desktop/options.h"
|
2011-05-10 02:49:17 +04:00
|
|
|
#include "desktop/scrollbar.h"
|
2010-06-04 13:35:08 +04:00
|
|
|
#include "desktop/selection.h"
|
2013-02-07 02:39:45 +04:00
|
|
|
#include "desktop/textarea.h"
|
2010-06-04 13:35:08 +04:00
|
|
|
#include "desktop/textinput.h"
|
|
|
|
#include "render/box.h"
|
|
|
|
#include "render/font.h"
|
|
|
|
#include "render/form.h"
|
2011-05-07 00:40:09 +04:00
|
|
|
#include "render/html_internal.h"
|
2010-06-04 13:35:08 +04:00
|
|
|
#include "render/imagemap.h"
|
2012-12-03 21:09:44 +04:00
|
|
|
#include "javascript/js.h"
|
2010-06-04 13:35:08 +04:00
|
|
|
#include "utils/messages.h"
|
|
|
|
#include "utils/utils.h"
|
|
|
|
|
|
|
|
|
2012-08-17 01:54:00 +04:00
|
|
|
/**
|
|
|
|
* Get pointer shape for given box
|
|
|
|
*
|
|
|
|
* \param box box in question
|
|
|
|
* \param imagemap whether an imagemap applies to the box
|
|
|
|
*/
|
|
|
|
|
|
|
|
static browser_pointer_shape get_pointer_shape(struct box *box, bool imagemap)
|
|
|
|
{
|
|
|
|
browser_pointer_shape pointer;
|
|
|
|
css_computed_style *style;
|
|
|
|
enum css_cursor_e cursor;
|
|
|
|
lwc_string **cursor_uris;
|
|
|
|
|
|
|
|
if (box->type == BOX_FLOAT_LEFT || box->type == BOX_FLOAT_RIGHT)
|
|
|
|
style = box->children->style;
|
|
|
|
else
|
|
|
|
style = box->style;
|
|
|
|
|
|
|
|
if (style == NULL)
|
|
|
|
return BROWSER_POINTER_DEFAULT;
|
|
|
|
|
|
|
|
cursor = css_computed_cursor(style, &cursor_uris);
|
|
|
|
|
|
|
|
switch (cursor) {
|
|
|
|
case CSS_CURSOR_AUTO:
|
|
|
|
if (box->href || (box->gadget &&
|
|
|
|
(box->gadget->type == GADGET_IMAGE ||
|
|
|
|
box->gadget->type == GADGET_SUBMIT)) ||
|
|
|
|
imagemap) {
|
|
|
|
/* link */
|
|
|
|
pointer = BROWSER_POINTER_POINT;
|
|
|
|
} else if (box->gadget &&
|
|
|
|
(box->gadget->type == GADGET_TEXTBOX ||
|
|
|
|
box->gadget->type == GADGET_PASSWORD ||
|
|
|
|
box->gadget->type == GADGET_TEXTAREA)) {
|
|
|
|
/* text input */
|
|
|
|
pointer = BROWSER_POINTER_CARET;
|
|
|
|
} else {
|
|
|
|
/* html content doesn't mind */
|
|
|
|
pointer = BROWSER_POINTER_AUTO;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case CSS_CURSOR_CROSSHAIR:
|
|
|
|
pointer = BROWSER_POINTER_CROSS;
|
|
|
|
break;
|
|
|
|
case CSS_CURSOR_POINTER:
|
|
|
|
pointer = BROWSER_POINTER_POINT;
|
|
|
|
break;
|
|
|
|
case CSS_CURSOR_MOVE:
|
|
|
|
pointer = BROWSER_POINTER_MOVE;
|
|
|
|
break;
|
|
|
|
case CSS_CURSOR_E_RESIZE:
|
|
|
|
pointer = BROWSER_POINTER_RIGHT;
|
|
|
|
break;
|
|
|
|
case CSS_CURSOR_W_RESIZE:
|
|
|
|
pointer = BROWSER_POINTER_LEFT;
|
|
|
|
break;
|
|
|
|
case CSS_CURSOR_N_RESIZE:
|
|
|
|
pointer = BROWSER_POINTER_UP;
|
|
|
|
break;
|
|
|
|
case CSS_CURSOR_S_RESIZE:
|
|
|
|
pointer = BROWSER_POINTER_DOWN;
|
|
|
|
break;
|
|
|
|
case CSS_CURSOR_NE_RESIZE:
|
|
|
|
pointer = BROWSER_POINTER_RU;
|
|
|
|
break;
|
|
|
|
case CSS_CURSOR_SW_RESIZE:
|
|
|
|
pointer = BROWSER_POINTER_LD;
|
|
|
|
break;
|
|
|
|
case CSS_CURSOR_SE_RESIZE:
|
|
|
|
pointer = BROWSER_POINTER_RD;
|
|
|
|
break;
|
|
|
|
case CSS_CURSOR_NW_RESIZE:
|
|
|
|
pointer = BROWSER_POINTER_LU;
|
|
|
|
break;
|
|
|
|
case CSS_CURSOR_TEXT:
|
|
|
|
pointer = BROWSER_POINTER_CARET;
|
|
|
|
break;
|
|
|
|
case CSS_CURSOR_WAIT:
|
|
|
|
pointer = BROWSER_POINTER_WAIT;
|
|
|
|
break;
|
|
|
|
case CSS_CURSOR_PROGRESS:
|
|
|
|
pointer = BROWSER_POINTER_PROGRESS;
|
|
|
|
break;
|
|
|
|
case CSS_CURSOR_HELP:
|
|
|
|
pointer = BROWSER_POINTER_HELP;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
pointer = BROWSER_POINTER_DEFAULT;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return pointer;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Start drag scrolling the contents of a box
|
|
|
|
*
|
|
|
|
* \param box the box to be scrolled
|
|
|
|
* \param x x ordinate of initial mouse position
|
|
|
|
* \param y y ordinate
|
|
|
|
*/
|
|
|
|
|
|
|
|
static void html_box_drag_start(struct box *box, int x, int y)
|
|
|
|
{
|
|
|
|
int box_x, box_y;
|
|
|
|
int scroll_mouse_x, scroll_mouse_y;
|
|
|
|
|
|
|
|
box_coords(box, &box_x, &box_y);
|
|
|
|
|
|
|
|
if (box->scroll_x != NULL) {
|
|
|
|
scroll_mouse_x = x - box_x ;
|
|
|
|
scroll_mouse_y = y - (box_y + box->padding[TOP] +
|
|
|
|
box->height + box->padding[BOTTOM] -
|
|
|
|
SCROLLBAR_WIDTH);
|
|
|
|
scrollbar_start_content_drag(box->scroll_x,
|
|
|
|
scroll_mouse_x, scroll_mouse_y);
|
|
|
|
} else if (box->scroll_y != NULL) {
|
|
|
|
scroll_mouse_x = x - (box_x + box->padding[LEFT] +
|
|
|
|
box->width + box->padding[RIGHT] -
|
|
|
|
SCROLLBAR_WIDTH);
|
|
|
|
scroll_mouse_y = y - box_y;
|
|
|
|
|
|
|
|
scrollbar_start_content_drag(box->scroll_y,
|
|
|
|
scroll_mouse_x, scroll_mouse_y);
|
|
|
|
}
|
|
|
|
}
|
2010-06-04 13:35:08 +04:00
|
|
|
|
2011-08-31 21:53:40 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* End overflow scroll scrollbar drags
|
|
|
|
*
|
|
|
|
* \param h html content's high level cache entry
|
|
|
|
* \param mouse state of mouse buttons and modifier keys
|
|
|
|
* \param x coordinate of mouse
|
|
|
|
* \param y coordinate of mouse
|
|
|
|
*/
|
|
|
|
static size_t html_selection_drag_end(struct html_content *html,
|
|
|
|
browser_mouse_state mouse, int x, int y, int dir)
|
|
|
|
{
|
|
|
|
int pixel_offset;
|
|
|
|
struct box *box;
|
|
|
|
int dx, dy;
|
|
|
|
size_t idx = 0;
|
|
|
|
|
|
|
|
box = box_pick_text_box(html, x, y, dir, &dx, &dy);
|
|
|
|
if (box) {
|
|
|
|
plot_font_style_t fstyle;
|
|
|
|
|
|
|
|
font_plot_style_from_css(box->style, &fstyle);
|
|
|
|
|
|
|
|
nsfont.font_position_in_string(&fstyle, box->text, box->length,
|
|
|
|
dx, &idx, &pixel_offset);
|
|
|
|
|
|
|
|
idx += box->byte_offset;
|
|
|
|
}
|
|
|
|
|
|
|
|
return idx;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-06-04 13:35:08 +04:00
|
|
|
/**
|
|
|
|
* Handle mouse tracking (including drags) in an HTML content window.
|
|
|
|
*
|
|
|
|
* \param c content of type html
|
|
|
|
* \param bw browser window
|
|
|
|
* \param mouse state of mouse buttons and modifier keys
|
|
|
|
* \param x coordinate of mouse
|
|
|
|
* \param y coordinate of mouse
|
|
|
|
*/
|
|
|
|
|
|
|
|
void html_mouse_track(struct content *c, struct browser_window *bw,
|
|
|
|
browser_mouse_state mouse, int x, int y)
|
|
|
|
{
|
2011-07-13 17:20:26 +04:00
|
|
|
html_content *html = (html_content*) c;
|
2013-02-08 17:22:53 +04:00
|
|
|
union html_drag_owner drag_owner;
|
2010-06-04 13:35:08 +04:00
|
|
|
|
2013-02-08 17:22:53 +04:00
|
|
|
if (html->drag_type == HTML_DRAG_SELECTION && !mouse) {
|
|
|
|
/* End of selection drag */
|
2011-07-13 17:20:26 +04:00
|
|
|
int dir = -1;
|
|
|
|
size_t idx;
|
|
|
|
|
|
|
|
if (selection_dragging_start(&html->sel))
|
|
|
|
dir = 1;
|
|
|
|
|
2011-08-31 21:53:40 +04:00
|
|
|
idx = html_selection_drag_end(html, mouse, x, y, dir);
|
2011-07-13 17:20:26 +04:00
|
|
|
|
|
|
|
if (idx != 0)
|
|
|
|
selection_track(&html->sel, mouse, idx);
|
|
|
|
|
2013-02-08 17:22:53 +04:00
|
|
|
drag_owner.no_owner = true;
|
|
|
|
html_set_drag_type(html, HTML_DRAG_NONE, drag_owner, NULL);
|
2011-07-13 17:20:26 +04:00
|
|
|
}
|
|
|
|
|
2013-02-08 17:22:53 +04:00
|
|
|
if (html->drag_type == HTML_DRAG_SELECTION) {
|
|
|
|
/* Selection drag */
|
|
|
|
struct box *box;
|
|
|
|
int dir = -1;
|
|
|
|
int dx, dy;
|
2010-06-04 13:35:08 +04:00
|
|
|
|
2013-02-08 17:22:53 +04:00
|
|
|
if (selection_dragging_start(&html->sel))
|
|
|
|
dir = 1;
|
2011-07-13 17:20:26 +04:00
|
|
|
|
2013-02-08 17:22:53 +04:00
|
|
|
box = box_pick_text_box(html, x, y, dir, &dx, &dy);
|
2010-06-04 13:35:08 +04:00
|
|
|
|
2013-02-08 17:22:53 +04:00
|
|
|
if (box != NULL) {
|
|
|
|
int pixel_offset;
|
|
|
|
size_t idx;
|
|
|
|
plot_font_style_t fstyle;
|
2010-06-04 13:35:08 +04:00
|
|
|
|
2013-02-08 17:22:53 +04:00
|
|
|
font_plot_style_from_css(box->style, &fstyle);
|
2010-06-04 13:35:08 +04:00
|
|
|
|
2013-02-08 17:22:53 +04:00
|
|
|
nsfont.font_position_in_string(&fstyle,
|
|
|
|
box->text, box->length,
|
|
|
|
dx, &idx, &pixel_offset);
|
2010-06-04 13:35:08 +04:00
|
|
|
|
2013-02-08 17:22:53 +04:00
|
|
|
selection_track(&html->sel, mouse,
|
|
|
|
box->byte_offset + idx);
|
2010-06-04 13:35:08 +04:00
|
|
|
}
|
2013-02-08 17:22:53 +04:00
|
|
|
} else {
|
|
|
|
html_mouse_action(c, bw, mouse, x, y);
|
2010-06-04 13:35:08 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Handle mouse clicks and movements in an HTML content window.
|
|
|
|
*
|
|
|
|
* \param c content of type html
|
|
|
|
* \param bw browser window
|
|
|
|
* \param mouse state of mouse buttons and modifier keys
|
|
|
|
* \param x coordinate of mouse
|
|
|
|
* \param 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.
|
|
|
|
*/
|
|
|
|
|
|
|
|
void html_mouse_action(struct content *c, struct browser_window *bw,
|
|
|
|
browser_mouse_state mouse, int x, int y)
|
|
|
|
{
|
2011-07-13 17:20:26 +04:00
|
|
|
html_content *html = (html_content *) c;
|
2010-06-04 13:35:08 +04:00
|
|
|
enum { ACTION_NONE, ACTION_SUBMIT, ACTION_GO } action = ACTION_NONE;
|
2011-09-29 23:15:54 +04:00
|
|
|
const char *title = 0;
|
2011-10-04 00:28:29 +04:00
|
|
|
nsurl *url = 0;
|
2010-06-04 13:35:08 +04:00
|
|
|
const char *target = 0;
|
|
|
|
char status_buffer[200];
|
|
|
|
const char *status = 0;
|
2012-08-17 01:21:08 +04:00
|
|
|
browser_pointer_shape pointer = BROWSER_POINTER_DEFAULT;
|
2010-06-04 13:35:08 +04:00
|
|
|
bool imagemap = false;
|
|
|
|
int box_x = 0, box_y = 0;
|
|
|
|
int gadget_box_x = 0, gadget_box_y = 0;
|
2012-08-21 19:46:10 +04:00
|
|
|
int html_object_pos_x = 0, html_object_pos_y = 0;
|
2010-06-04 13:35:08 +04:00
|
|
|
int text_box_x = 0;
|
|
|
|
struct box *url_box = 0;
|
|
|
|
struct box *gadget_box = 0;
|
|
|
|
struct box *text_box = 0;
|
|
|
|
struct box *box;
|
|
|
|
struct form_control *gadget = 0;
|
|
|
|
hlcache_handle *object = NULL;
|
2012-08-21 19:46:10 +04:00
|
|
|
struct box *html_object_box = NULL;
|
2011-06-15 00:00:18 +04:00
|
|
|
struct browser_window *iframe = NULL;
|
2010-06-04 13:35:08 +04:00
|
|
|
struct box *next_box;
|
|
|
|
struct box *drag_candidate = NULL;
|
2011-05-10 02:49:17 +04:00
|
|
|
struct scrollbar *scrollbar = NULL;
|
2010-06-04 13:35:08 +04:00
|
|
|
plot_font_style_t fstyle;
|
|
|
|
int scroll_mouse_x = 0, scroll_mouse_y = 0;
|
|
|
|
int padding_left, padding_right, padding_top, padding_bottom;
|
2012-02-28 16:54:00 +04:00
|
|
|
browser_drag_type drag_type = browser_window_get_drag_type(bw);
|
2012-08-15 22:01:54 +04:00
|
|
|
union content_msg_data msg_data;
|
2012-12-03 21:09:44 +04:00
|
|
|
struct dom_node *node = NULL;
|
2010-06-04 13:35:08 +04:00
|
|
|
|
2012-02-28 16:54:00 +04:00
|
|
|
if (drag_type != DRAGGING_NONE && !mouse &&
|
2011-06-28 15:15:39 +04:00
|
|
|
html->visible_select_menu != NULL) {
|
|
|
|
/* drag end: select menu */
|
|
|
|
form_select_mouse_drag_end(html->visible_select_menu,
|
|
|
|
mouse, x, y);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (html->visible_select_menu != NULL) {
|
|
|
|
box = html->visible_select_menu->box;
|
2010-06-04 13:35:08 +04:00
|
|
|
box_coords(box, &box_x, &box_y);
|
|
|
|
|
|
|
|
box_x -= box->border[LEFT].width;
|
|
|
|
box_y += box->height + box->border[BOTTOM].width +
|
|
|
|
box->padding[BOTTOM] + box->padding[TOP];
|
2011-06-28 15:15:39 +04:00
|
|
|
status = form_select_mouse_action(html->visible_select_menu,
|
2010-06-04 13:35:08 +04:00
|
|
|
mouse, x - box_x, y - box_y);
|
2012-08-15 22:01:54 +04:00
|
|
|
if (status != NULL) {
|
|
|
|
msg_data.explicit_status_text = status;
|
|
|
|
content_broadcast(c, CONTENT_MSG_STATUS, msg_data);
|
|
|
|
} else {
|
2010-06-04 13:35:08 +04:00
|
|
|
int width, height;
|
2011-06-28 15:15:39 +04:00
|
|
|
form_select_get_dimensions(html->visible_select_menu,
|
2010-06-04 13:35:08 +04:00
|
|
|
&width, &height);
|
2011-06-28 15:15:39 +04:00
|
|
|
html->visible_select_menu = NULL;
|
2010-06-04 13:35:08 +04:00
|
|
|
browser_window_redraw_rect(bw, box_x, box_y,
|
|
|
|
width, height);
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
2011-05-10 02:49:17 +04:00
|
|
|
|
2013-02-08 17:22:53 +04:00
|
|
|
if (html->drag_type == HTML_DRAG_SCROLLBAR) {
|
|
|
|
struct scrollbar *scr = html->drag_owner.scrollbar;
|
|
|
|
struct html_scrollbar_data *data = scrollbar_get_data(scr);
|
|
|
|
|
|
|
|
if (!mouse) {
|
|
|
|
/* drag end: scrollbar */
|
|
|
|
html_overflow_scroll_drag_end(scr, mouse, x, y);
|
|
|
|
}
|
2011-06-28 02:21:15 +04:00
|
|
|
|
2010-06-04 13:35:08 +04:00
|
|
|
box = data->box;
|
|
|
|
box_coords(box, &box_x, &box_y);
|
2013-02-08 17:22:53 +04:00
|
|
|
if (scrollbar_is_horizontal(scr)) {
|
2010-06-04 13:35:08 +04:00
|
|
|
scroll_mouse_x = x - box_x ;
|
|
|
|
scroll_mouse_y = y - (box_y + box->padding[TOP] +
|
|
|
|
box->height + box->padding[BOTTOM] -
|
|
|
|
SCROLLBAR_WIDTH);
|
2013-02-08 17:22:53 +04:00
|
|
|
status = scrollbar_mouse_action(scr, mouse,
|
2010-06-04 13:35:08 +04:00
|
|
|
scroll_mouse_x, scroll_mouse_y);
|
|
|
|
} else {
|
|
|
|
scroll_mouse_x = x - (box_x + box->padding[LEFT] +
|
|
|
|
box->width + box->padding[RIGHT] -
|
|
|
|
SCROLLBAR_WIDTH);
|
|
|
|
scroll_mouse_y = y - box_y;
|
2013-02-08 17:22:53 +04:00
|
|
|
status = scrollbar_mouse_action(scr, mouse,
|
2010-06-04 13:35:08 +04:00
|
|
|
scroll_mouse_x, scroll_mouse_y);
|
|
|
|
}
|
2012-08-15 22:01:54 +04:00
|
|
|
|
|
|
|
msg_data.explicit_status_text = status;
|
|
|
|
content_broadcast(c, CONTENT_MSG_STATUS, msg_data);
|
2010-06-04 13:35:08 +04:00
|
|
|
return;
|
|
|
|
}
|
2011-06-28 14:07:53 +04:00
|
|
|
|
2013-02-08 17:22:53 +04:00
|
|
|
if (html->drag_type == HTML_DRAG_TEXTAREA_SELECTION ||
|
|
|
|
html->drag_type == HTML_DRAG_TEXTAREA_SCROLLBAR) {
|
|
|
|
box = html->drag_owner.textarea;
|
|
|
|
assert(box->gadget != NULL);
|
|
|
|
assert(box->gadget->type == GADGET_TEXTAREA ||
|
|
|
|
box->gadget->type == GADGET_PASSWORD ||
|
|
|
|
box->gadget->type == GADGET_TEXTBOX);
|
|
|
|
|
|
|
|
box_coords(box, &box_x, &box_y);
|
|
|
|
textarea_mouse_action(box->gadget->data.text.ta, mouse,
|
|
|
|
x - box_x, y - box_y);
|
|
|
|
|
|
|
|
/* TODO: Set appropriate statusbar message */
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (html->drag_type == HTML_DRAG_CONTENT_SELECTION ||
|
|
|
|
html->drag_type == HTML_DRAG_CONTENT_SCROLL) {
|
|
|
|
box = html->drag_owner.content;
|
|
|
|
assert(box->object != NULL);
|
|
|
|
|
|
|
|
box_coords(box, &box_x, &box_y);
|
|
|
|
content_mouse_track(box->object, bw, mouse,
|
|
|
|
x - box_x, y - box_y);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2011-06-28 14:07:53 +04:00
|
|
|
/* Content related drags handled by now */
|
2013-02-08 17:22:53 +04:00
|
|
|
assert(html->drag_type == HTML_DRAG_NONE);
|
2010-06-04 13:35:08 +04:00
|
|
|
|
|
|
|
/* search the box tree for a link, imagemap, form control, or
|
2012-12-03 21:09:44 +04:00
|
|
|
* box with scrollbars
|
|
|
|
*/
|
2010-06-04 13:35:08 +04:00
|
|
|
|
2012-08-17 23:57:35 +04:00
|
|
|
box = html->layout;
|
2010-06-04 13:35:08 +04:00
|
|
|
|
|
|
|
/* Consider the margins of the html page now */
|
|
|
|
box_x = box->margin[LEFT];
|
|
|
|
box_y = box->margin[TOP];
|
|
|
|
|
2012-12-03 22:47:22 +04:00
|
|
|
/* descend through visible boxes setting more specific values for:
|
|
|
|
* box - deepest box at point
|
|
|
|
* html_object_box - html object
|
|
|
|
* html_object_pos_x - html object
|
|
|
|
* html_object_pos_y - html object
|
|
|
|
* object - non html object
|
|
|
|
* iframe - iframe
|
|
|
|
* url - href or imagemap
|
|
|
|
* target - href or imagemap or gadget
|
|
|
|
* url_box - href or imagemap
|
|
|
|
* imagemap - imagemap
|
|
|
|
* gadget - gadget
|
|
|
|
* gadget_box - gadget
|
|
|
|
* gadget_box_x - gadget
|
|
|
|
* gadget_box_y - gadget
|
|
|
|
* title - title
|
|
|
|
* pointer
|
|
|
|
*
|
|
|
|
* drag_candidate - first box with scroll
|
|
|
|
* padding_left - box with scroll
|
|
|
|
* padding_right
|
|
|
|
* padding_top
|
|
|
|
* padding_bottom
|
|
|
|
* scrollbar - inside padding box stops decent
|
|
|
|
* scroll_mouse_x - inside padding box stops decent
|
|
|
|
* scroll_mouse_y - inside padding box stops decent
|
|
|
|
*
|
|
|
|
* text_box - text box
|
|
|
|
* text_box_x - text_box
|
|
|
|
*/
|
2012-12-03 21:09:44 +04:00
|
|
|
while ((next_box = box_at_point(box, x, y, &box_x, &box_y)) != NULL) {
|
2010-06-04 13:35:08 +04:00
|
|
|
box = next_box;
|
|
|
|
|
2012-12-03 22:47:22 +04:00
|
|
|
if ((box->style != NULL) &&
|
|
|
|
(css_computed_visibility(box->style) ==
|
|
|
|
CSS_VISIBILITY_HIDDEN)) {
|
2010-06-04 13:35:08 +04:00
|
|
|
continue;
|
2012-12-03 22:47:22 +04:00
|
|
|
}
|
2010-06-04 13:35:08 +04:00
|
|
|
|
2012-12-03 21:09:44 +04:00
|
|
|
if (box->node != NULL) {
|
|
|
|
node = box->node;
|
|
|
|
}
|
|
|
|
|
2012-08-21 18:27:52 +04:00
|
|
|
if (box->object) {
|
2012-08-21 19:46:10 +04:00
|
|
|
if (content_get_type(box->object) == CONTENT_HTML) {
|
|
|
|
html_object_box = box;
|
|
|
|
html_object_pos_x = box_x;
|
|
|
|
html_object_pos_y = box_y;
|
|
|
|
} else {
|
2012-08-21 18:27:52 +04:00
|
|
|
object = box->object;
|
2012-08-21 19:46:10 +04:00
|
|
|
}
|
2012-08-21 18:27:52 +04:00
|
|
|
}
|
2010-06-04 13:35:08 +04:00
|
|
|
|
2012-12-03 22:47:22 +04:00
|
|
|
if (box->iframe) {
|
2011-06-15 00:00:18 +04:00
|
|
|
iframe = box->iframe;
|
2012-12-03 22:47:22 +04:00
|
|
|
}
|
2011-06-15 00:00:18 +04:00
|
|
|
|
2010-06-04 13:35:08 +04:00
|
|
|
if (box->href) {
|
|
|
|
url = box->href;
|
|
|
|
target = box->target;
|
|
|
|
url_box = box;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (box->usemap) {
|
2011-09-06 20:26:02 +04:00
|
|
|
url = imagemap_get(html, box->usemap,
|
2010-06-04 13:35:08 +04:00
|
|
|
box_x, box_y, x, y, &target);
|
|
|
|
if (url) {
|
|
|
|
imagemap = true;
|
|
|
|
url_box = box;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (box->gadget) {
|
|
|
|
gadget = box->gadget;
|
|
|
|
gadget_box = box;
|
|
|
|
gadget_box_x = box_x;
|
|
|
|
gadget_box_y = box_y;
|
|
|
|
if (gadget->form)
|
|
|
|
target = gadget->form->target;
|
|
|
|
}
|
|
|
|
|
2012-12-03 22:47:22 +04:00
|
|
|
if (box->title) {
|
2010-06-04 13:35:08 +04:00
|
|
|
title = box->title;
|
2012-12-03 22:47:22 +04:00
|
|
|
}
|
2010-06-04 13:35:08 +04:00
|
|
|
|
2012-08-17 01:48:28 +04:00
|
|
|
pointer = get_pointer_shape(box, false);
|
2012-12-03 22:47:22 +04:00
|
|
|
|
|
|
|
if ((box->scroll_x != NULL) ||
|
|
|
|
(box->scroll_y != NULL)) {
|
2012-12-03 21:09:44 +04:00
|
|
|
|
|
|
|
if (drag_candidate == NULL) {
|
|
|
|
drag_candidate = box;
|
|
|
|
}
|
|
|
|
|
2011-05-10 02:49:17 +04:00
|
|
|
padding_left = box_x +
|
|
|
|
scrollbar_get_offset(box->scroll_x);
|
2010-06-04 13:35:08 +04:00
|
|
|
padding_right = padding_left + box->padding[LEFT] +
|
|
|
|
box->width + box->padding[RIGHT];
|
2011-05-10 02:49:17 +04:00
|
|
|
padding_top = box_y +
|
|
|
|
scrollbar_get_offset(box->scroll_y);
|
2010-06-04 13:35:08 +04:00
|
|
|
padding_bottom = padding_top + box->padding[TOP] +
|
|
|
|
box->height + box->padding[BOTTOM];
|
|
|
|
|
2012-12-03 22:47:22 +04:00
|
|
|
if ((x > padding_left) &&
|
|
|
|
(x < padding_right) &&
|
|
|
|
(y > padding_top) &&
|
|
|
|
(y < padding_bottom)) {
|
2010-06-04 13:35:08 +04:00
|
|
|
/* mouse inside padding box */
|
|
|
|
|
2012-12-03 22:47:22 +04:00
|
|
|
if ((box->scroll_y != NULL) &&
|
|
|
|
(x > (padding_right - SCROLLBAR_WIDTH))) {
|
2010-06-04 13:35:08 +04:00
|
|
|
/* mouse above vertical box scroll */
|
|
|
|
|
2011-05-10 02:49:17 +04:00
|
|
|
scrollbar = box->scroll_y;
|
2010-06-04 13:35:08 +04:00
|
|
|
scroll_mouse_x = x - (padding_right -
|
|
|
|
SCROLLBAR_WIDTH);
|
|
|
|
scroll_mouse_y = y - padding_top;
|
|
|
|
break;
|
|
|
|
|
2012-12-03 22:47:22 +04:00
|
|
|
} else if ((box->scroll_x != NULL) &&
|
|
|
|
(y > (padding_bottom - SCROLLBAR_WIDTH))) {
|
2010-06-04 13:35:08 +04:00
|
|
|
/* mouse above horizontal box scroll */
|
|
|
|
|
2011-05-10 02:49:17 +04:00
|
|
|
scrollbar = box->scroll_x;
|
2010-06-04 13:35:08 +04:00
|
|
|
scroll_mouse_x = x - padding_left;
|
|
|
|
scroll_mouse_y = y - (padding_bottom -
|
|
|
|
SCROLLBAR_WIDTH);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (box->text && !box->object) {
|
|
|
|
text_box = box;
|
|
|
|
text_box_x = box_x;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* use of box_x, box_y, or content below this point is probably a
|
|
|
|
* mistake; they will refer to the last box returned by box_at_point */
|
|
|
|
|
2011-05-10 02:49:17 +04:00
|
|
|
if (scrollbar) {
|
|
|
|
status = scrollbar_mouse_action(scrollbar, mouse,
|
2010-06-04 13:35:08 +04:00
|
|
|
scroll_mouse_x, scroll_mouse_y);
|
2012-08-17 01:21:08 +04:00
|
|
|
pointer = BROWSER_POINTER_DEFAULT;
|
2010-06-04 13:35:08 +04:00
|
|
|
} else if (gadget) {
|
|
|
|
switch (gadget->type) {
|
|
|
|
case GADGET_SELECT:
|
|
|
|
status = messages_get("FormSelect");
|
2012-08-17 01:21:08 +04:00
|
|
|
pointer = BROWSER_POINTER_MENU;
|
2010-06-04 13:35:08 +04:00
|
|
|
if (mouse & BROWSER_MOUSE_CLICK_1 &&
|
2012-03-22 13:34:34 +04:00
|
|
|
nsoption_bool(core_select_menu)) {
|
2011-06-28 15:15:39 +04:00
|
|
|
html->visible_select_menu = gadget;
|
|
|
|
form_open_select_menu(c, gadget,
|
2010-06-04 13:35:08 +04:00
|
|
|
form_select_menu_callback,
|
2011-06-28 15:15:39 +04:00
|
|
|
c);
|
2012-08-17 01:21:08 +04:00
|
|
|
pointer = BROWSER_POINTER_DEFAULT;
|
2010-06-04 13:35:08 +04:00
|
|
|
} else if (mouse & BROWSER_MOUSE_CLICK_1)
|
|
|
|
gui_create_form_select_menu(bw, gadget);
|
|
|
|
break;
|
|
|
|
case GADGET_CHECKBOX:
|
|
|
|
status = messages_get("FormCheckbox");
|
|
|
|
if (mouse & BROWSER_MOUSE_CLICK_1) {
|
|
|
|
gadget->selected = !gadget->selected;
|
2012-08-21 18:27:52 +04:00
|
|
|
html__redraw_a_box(html, gadget_box);
|
2010-06-04 13:35:08 +04:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case GADGET_RADIO:
|
|
|
|
status = messages_get("FormRadio");
|
|
|
|
if (mouse & BROWSER_MOUSE_CLICK_1)
|
2012-08-21 18:27:52 +04:00
|
|
|
form_radio_set(html, gadget);
|
2010-06-04 13:35:08 +04:00
|
|
|
break;
|
|
|
|
case GADGET_IMAGE:
|
|
|
|
if (mouse & BROWSER_MOUSE_CLICK_1) {
|
|
|
|
gadget->data.image.mx = x - gadget_box_x;
|
|
|
|
gadget->data.image.my = y - gadget_box_y;
|
|
|
|
}
|
|
|
|
/* drop through */
|
|
|
|
case GADGET_SUBMIT:
|
|
|
|
if (gadget->form) {
|
|
|
|
snprintf(status_buffer, sizeof status_buffer,
|
|
|
|
messages_get("FormSubmit"),
|
|
|
|
gadget->form->action);
|
|
|
|
status = status_buffer;
|
2012-08-17 01:48:28 +04:00
|
|
|
pointer = get_pointer_shape(gadget_box, false);
|
2010-06-04 13:35:08 +04:00
|
|
|
if (mouse & (BROWSER_MOUSE_CLICK_1 |
|
|
|
|
BROWSER_MOUSE_CLICK_2))
|
|
|
|
action = ACTION_SUBMIT;
|
|
|
|
} else {
|
|
|
|
status = messages_get("FormBadSubmit");
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case GADGET_TEXTBOX:
|
|
|
|
case GADGET_PASSWORD:
|
2013-02-07 02:39:45 +04:00
|
|
|
case GADGET_TEXTAREA:
|
|
|
|
if (gadget->type == GADGET_TEXTAREA)
|
|
|
|
status = messages_get("FormTextarea");
|
|
|
|
else
|
|
|
|
status = messages_get("FormTextbox");
|
2010-06-04 13:35:08 +04:00
|
|
|
|
2013-02-07 02:39:45 +04:00
|
|
|
pointer = get_pointer_shape(gadget_box, false);
|
2010-06-04 13:35:08 +04:00
|
|
|
|
2013-02-07 02:39:45 +04:00
|
|
|
textarea_mouse_action(gadget->data.text.ta, mouse,
|
|
|
|
x - gadget_box_x, y - gadget_box_y);
|
2010-06-04 13:35:08 +04:00
|
|
|
break;
|
|
|
|
case GADGET_HIDDEN:
|
|
|
|
/* not possible: no box generated */
|
|
|
|
break;
|
|
|
|
case GADGET_RESET:
|
|
|
|
status = messages_get("FormReset");
|
|
|
|
break;
|
|
|
|
case GADGET_FILE:
|
|
|
|
status = messages_get("FormFile");
|
|
|
|
break;
|
|
|
|
case GADGET_BUTTON:
|
|
|
|
/* This gadget cannot be activated */
|
|
|
|
status = messages_get("FormButton");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
} else if (object && (mouse & BROWSER_MOUSE_MOD_2)) {
|
|
|
|
|
2012-08-16 23:39:45 +04:00
|
|
|
if (mouse & BROWSER_MOUSE_DRAG_2) {
|
|
|
|
msg_data.dragsave.type = CONTENT_SAVE_NATIVE;
|
|
|
|
msg_data.dragsave.content = object;
|
|
|
|
content_broadcast(c, CONTENT_MSG_DRAGSAVE, msg_data);
|
|
|
|
|
|
|
|
} else if (mouse & BROWSER_MOUSE_DRAG_1) {
|
|
|
|
msg_data.dragsave.type = CONTENT_SAVE_ORIG;
|
|
|
|
msg_data.dragsave.content = object;
|
|
|
|
content_broadcast(c, CONTENT_MSG_DRAGSAVE, msg_data);
|
|
|
|
}
|
2010-06-04 13:35:08 +04:00
|
|
|
|
|
|
|
/* \todo should have a drag-saving object msg */
|
|
|
|
|
2011-06-15 00:00:18 +04:00
|
|
|
} else if (iframe) {
|
|
|
|
int pos_x, pos_y;
|
2012-02-28 02:44:59 +04:00
|
|
|
float scale = browser_window_get_scale(bw);
|
|
|
|
|
2011-06-15 00:00:18 +04:00
|
|
|
browser_window_get_position(iframe, false, &pos_x, &pos_y);
|
2012-02-28 02:44:59 +04:00
|
|
|
|
|
|
|
pos_x /= scale;
|
|
|
|
pos_y /= scale;
|
2011-06-15 00:00:18 +04:00
|
|
|
|
|
|
|
if (mouse & BROWSER_MOUSE_CLICK_1 ||
|
|
|
|
mouse & BROWSER_MOUSE_CLICK_2) {
|
|
|
|
browser_window_mouse_click(iframe, mouse,
|
|
|
|
x - pos_x, y - pos_y);
|
|
|
|
} else {
|
|
|
|
browser_window_mouse_track(iframe, mouse,
|
|
|
|
x - pos_x, y - pos_y);
|
|
|
|
}
|
2012-08-21 19:46:10 +04:00
|
|
|
} else if (html_object_box) {
|
2012-08-21 18:27:52 +04:00
|
|
|
if (mouse & BROWSER_MOUSE_CLICK_1 ||
|
|
|
|
mouse & BROWSER_MOUSE_CLICK_2) {
|
2012-08-21 19:46:10 +04:00
|
|
|
content_mouse_action(html_object_box->object,
|
|
|
|
bw, mouse,
|
|
|
|
x - html_object_pos_x,
|
|
|
|
y - html_object_pos_y);
|
2012-08-21 18:27:52 +04:00
|
|
|
} else {
|
2012-08-21 19:46:10 +04:00
|
|
|
content_mouse_track(html_object_box->object,
|
|
|
|
bw, mouse,
|
|
|
|
x - html_object_pos_x,
|
|
|
|
y - html_object_pos_y);
|
2012-08-21 18:27:52 +04:00
|
|
|
}
|
2010-06-04 13:35:08 +04:00
|
|
|
} else if (url) {
|
|
|
|
if (title) {
|
|
|
|
snprintf(status_buffer, sizeof status_buffer, "%s: %s",
|
2011-10-04 00:28:29 +04:00
|
|
|
nsurl_access(url), title);
|
2010-06-04 13:35:08 +04:00
|
|
|
status = status_buffer;
|
|
|
|
} else
|
2011-10-04 00:28:29 +04:00
|
|
|
status = nsurl_access(url);
|
2010-06-04 13:35:08 +04:00
|
|
|
|
2012-08-17 01:48:28 +04:00
|
|
|
pointer = get_pointer_shape(url_box, imagemap);
|
2010-06-04 13:35:08 +04:00
|
|
|
|
|
|
|
if (mouse & BROWSER_MOUSE_CLICK_1 &&
|
|
|
|
mouse & BROWSER_MOUSE_MOD_1) {
|
|
|
|
/* force download of link */
|
2011-10-04 00:28:29 +04:00
|
|
|
browser_window_go_post(bw, nsurl_access(url), 0, 0,
|
2012-08-17 02:26:05 +04:00
|
|
|
false,
|
2012-08-19 15:03:39 +04:00
|
|
|
nsurl_access(content_get_url(c)),
|
2011-10-03 19:56:47 +04:00
|
|
|
true, true, 0);
|
2012-08-17 02:26:05 +04:00
|
|
|
|
2010-06-04 13:35:08 +04:00
|
|
|
} else if (mouse & BROWSER_MOUSE_CLICK_2 &&
|
|
|
|
mouse & BROWSER_MOUSE_MOD_1) {
|
2012-08-17 02:26:05 +04:00
|
|
|
msg_data.savelink.url = nsurl_access(url);
|
|
|
|
msg_data.savelink.title = title;
|
|
|
|
content_broadcast(c, CONTENT_MSG_SAVELINK, msg_data);
|
|
|
|
|
2010-06-04 13:35:08 +04:00
|
|
|
} else if (mouse & (BROWSER_MOUSE_CLICK_1 |
|
|
|
|
BROWSER_MOUSE_CLICK_2))
|
|
|
|
action = ACTION_GO;
|
|
|
|
} else {
|
|
|
|
bool done = false;
|
|
|
|
|
|
|
|
/* frame resizing */
|
2012-08-16 19:14:15 +04:00
|
|
|
if (browser_window_frame_resize_start(bw, mouse, x, y,
|
|
|
|
&pointer)) {
|
|
|
|
if (mouse & (BROWSER_MOUSE_DRAG_1 |
|
|
|
|
BROWSER_MOUSE_DRAG_2)) {
|
|
|
|
status = messages_get("FrameDrag");
|
2012-08-16 18:38:06 +04:00
|
|
|
}
|
2012-08-16 19:14:15 +04:00
|
|
|
done = true;
|
2010-06-04 13:35:08 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/* if clicking in the main page, remove the selection from any
|
|
|
|
* text areas */
|
|
|
|
if (!done) {
|
2012-08-17 23:57:35 +04:00
|
|
|
struct box *layout = html->layout;
|
2010-06-04 13:35:08 +04:00
|
|
|
|
2011-07-13 17:20:26 +04:00
|
|
|
if (mouse && (mouse < BROWSER_MOUSE_MOD_1) &&
|
|
|
|
selection_root(&html->sel) != layout) {
|
|
|
|
selection_init(&html->sel, layout);
|
|
|
|
}
|
2010-06-04 13:35:08 +04:00
|
|
|
|
|
|
|
if (text_box) {
|
|
|
|
int pixel_offset;
|
|
|
|
size_t idx;
|
|
|
|
|
|
|
|
font_plot_style_from_css(text_box->style,
|
|
|
|
&fstyle);
|
|
|
|
|
|
|
|
nsfont.font_position_in_string(&fstyle,
|
|
|
|
text_box->text,
|
|
|
|
text_box->length,
|
|
|
|
x - text_box_x,
|
|
|
|
&idx,
|
|
|
|
&pixel_offset);
|
|
|
|
|
2011-07-13 17:20:26 +04:00
|
|
|
if (selection_click(&html->sel, mouse,
|
2010-06-04 13:35:08 +04:00
|
|
|
text_box->byte_offset + idx)) {
|
|
|
|
/* key presses must be directed at the
|
|
|
|
* main browser window, paste text
|
|
|
|
* operations ignored */
|
2013-02-08 17:22:53 +04:00
|
|
|
html_drag_type drag_type;
|
|
|
|
union html_drag_owner drag_owner;
|
2010-06-04 13:35:08 +04:00
|
|
|
|
2011-07-13 17:20:26 +04:00
|
|
|
if (selection_dragging(&html->sel)) {
|
2013-02-08 17:22:53 +04:00
|
|
|
drag_type = HTML_DRAG_SELECTION;
|
|
|
|
drag_owner.no_owner = true;
|
|
|
|
html_set_drag_type(html,
|
|
|
|
drag_type,
|
|
|
|
drag_owner,
|
|
|
|
NULL);
|
2012-08-19 14:34:46 +04:00
|
|
|
status = messages_get(
|
|
|
|
"Selecting");
|
|
|
|
}
|
2010-06-04 13:35:08 +04:00
|
|
|
|
|
|
|
done = true;
|
|
|
|
}
|
2012-08-19 14:39:00 +04:00
|
|
|
|
|
|
|
} else if (mouse & BROWSER_MOUSE_PRESS_1)
|
2011-07-13 17:20:26 +04:00
|
|
|
selection_clear(&html->sel, true);
|
2010-06-04 13:35:08 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!done) {
|
|
|
|
if (title)
|
|
|
|
status = title;
|
|
|
|
|
|
|
|
if (mouse & BROWSER_MOUSE_DRAG_1) {
|
|
|
|
if (mouse & BROWSER_MOUSE_MOD_2) {
|
2012-08-16 23:39:45 +04:00
|
|
|
msg_data.dragsave.type =
|
|
|
|
CONTENT_SAVE_COMPLETE;
|
2012-08-19 15:46:42 +04:00
|
|
|
msg_data.dragsave.content = NULL;
|
2012-08-16 23:39:45 +04:00
|
|
|
content_broadcast(c,
|
|
|
|
CONTENT_MSG_DRAGSAVE,
|
|
|
|
msg_data);
|
2010-06-04 13:35:08 +04:00
|
|
|
} else {
|
2012-08-19 14:39:00 +04:00
|
|
|
if (drag_candidate == NULL) {
|
2010-06-04 13:35:08 +04:00
|
|
|
browser_window_page_drag_start(
|
|
|
|
bw, x, y);
|
2012-08-19 14:39:00 +04:00
|
|
|
} else {
|
2010-06-04 13:35:08 +04:00
|
|
|
html_box_drag_start(
|
|
|
|
drag_candidate,
|
|
|
|
x, y);
|
|
|
|
}
|
2012-08-17 01:21:08 +04:00
|
|
|
pointer = BROWSER_POINTER_MOVE;
|
2010-06-04 13:35:08 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (mouse & BROWSER_MOUSE_DRAG_2) {
|
|
|
|
if (mouse & BROWSER_MOUSE_MOD_2) {
|
2012-08-16 23:39:45 +04:00
|
|
|
msg_data.dragsave.type =
|
|
|
|
CONTENT_SAVE_SOURCE;
|
2012-08-19 15:46:42 +04:00
|
|
|
msg_data.dragsave.content = NULL;
|
2012-08-16 23:39:45 +04:00
|
|
|
content_broadcast(c,
|
|
|
|
CONTENT_MSG_DRAGSAVE,
|
|
|
|
msg_data);
|
2010-06-04 13:35:08 +04:00
|
|
|
} else {
|
2012-08-19 14:39:00 +04:00
|
|
|
if (drag_candidate == NULL) {
|
2010-06-04 13:35:08 +04:00
|
|
|
browser_window_page_drag_start(
|
|
|
|
bw, x, y);
|
2012-08-19 14:39:00 +04:00
|
|
|
} else {
|
2010-06-04 13:35:08 +04:00
|
|
|
html_box_drag_start(
|
|
|
|
drag_candidate,
|
|
|
|
x, y);
|
|
|
|
}
|
2012-08-17 01:21:08 +04:00
|
|
|
pointer = BROWSER_POINTER_MOVE;
|
2010-06-04 13:35:08 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2011-07-13 17:20:26 +04:00
|
|
|
if (mouse && mouse < BROWSER_MOUSE_MOD_1) {
|
2010-06-04 13:35:08 +04:00
|
|
|
/* ensure key presses still act on the browser window */
|
|
|
|
browser_window_remove_caret(bw);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-08-21 19:46:10 +04:00
|
|
|
if (!iframe && !html_object_box) {
|
2012-08-15 22:01:54 +04:00
|
|
|
msg_data.explicit_status_text = status;
|
|
|
|
content_broadcast(c, CONTENT_MSG_STATUS, msg_data);
|
2010-06-04 13:35:08 +04:00
|
|
|
|
2012-08-17 13:02:10 +04:00
|
|
|
msg_data.pointer = pointer;
|
|
|
|
content_broadcast(c, CONTENT_MSG_POINTER, msg_data);
|
|
|
|
}
|
2010-06-04 13:35:08 +04:00
|
|
|
|
2012-12-03 21:09:44 +04:00
|
|
|
/* fire dom click event */
|
|
|
|
if ((mouse & BROWSER_MOUSE_CLICK_1) ||
|
|
|
|
(mouse & BROWSER_MOUSE_CLICK_2)) {
|
|
|
|
js_fire_event(html->jscontext, "click", html->document, node);
|
|
|
|
}
|
|
|
|
|
2010-06-04 13:35:08 +04:00
|
|
|
/* deferred actions that can cause this browser_window to be destroyed
|
|
|
|
* and must therefore be done after set_status/pointer
|
|
|
|
*/
|
|
|
|
switch (action) {
|
|
|
|
case ACTION_SUBMIT:
|
2012-08-17 23:26:00 +04:00
|
|
|
form_submit(content_get_url(c),
|
2010-06-04 13:35:08 +04:00
|
|
|
browser_window_find_target(bw, target, mouse),
|
|
|
|
gadget->form, gadget);
|
|
|
|
break;
|
|
|
|
case ACTION_GO:
|
|
|
|
browser_window_go(browser_window_find_target(bw, target, mouse),
|
2011-10-04 00:28:29 +04:00
|
|
|
nsurl_access(url),
|
2012-08-19 15:03:39 +04:00
|
|
|
nsurl_access(content_get_url(c)), true);
|
2010-06-04 13:35:08 +04:00
|
|
|
break;
|
|
|
|
case ACTION_NONE:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2011-06-28 02:21:15 +04:00
|
|
|
* Callback for in-page scrollbars.
|
2010-06-04 13:35:08 +04:00
|
|
|
*/
|
|
|
|
void html_overflow_scroll_callback(void *client_data,
|
2011-05-10 02:49:17 +04:00
|
|
|
struct scrollbar_msg_data *scrollbar_data)
|
2010-06-04 13:35:08 +04:00
|
|
|
{
|
2011-06-28 02:21:15 +04:00
|
|
|
struct html_scrollbar_data *data = client_data;
|
|
|
|
html_content *html = (html_content *)data->c;
|
2010-06-04 13:35:08 +04:00
|
|
|
struct box *box = data->box;
|
2012-08-17 13:02:10 +04:00
|
|
|
union content_msg_data msg_data;
|
2013-02-08 17:22:53 +04:00
|
|
|
html_drag_type drag_type;
|
|
|
|
union html_drag_owner drag_owner;
|
2010-06-04 13:35:08 +04:00
|
|
|
|
2011-05-10 02:49:17 +04:00
|
|
|
switch(scrollbar_data->msg) {
|
2013-02-08 17:22:53 +04:00
|
|
|
case SCROLLBAR_MSG_MOVED:
|
|
|
|
html__redraw_a_box(html, box);
|
|
|
|
break;
|
|
|
|
case SCROLLBAR_MSG_SCROLL_START:
|
|
|
|
{
|
|
|
|
struct rect rect = {
|
|
|
|
.x0 = scrollbar_data->x0,
|
|
|
|
.y0 = scrollbar_data->y0,
|
|
|
|
.x1 = scrollbar_data->x1,
|
|
|
|
.y1 = scrollbar_data->y1
|
|
|
|
};
|
|
|
|
drag_type = HTML_DRAG_SCROLLBAR;
|
|
|
|
drag_owner.scrollbar = scrollbar_data->scrollbar;
|
|
|
|
html_set_drag_type(html, drag_type, drag_owner, &rect);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case SCROLLBAR_MSG_SCROLL_FINISHED:
|
|
|
|
drag_type = HTML_DRAG_NONE;
|
|
|
|
drag_owner.no_owner = true;
|
|
|
|
html_set_drag_type(html, drag_type, drag_owner, NULL);
|
2012-08-17 13:02:10 +04:00
|
|
|
|
2013-02-08 17:22:53 +04:00
|
|
|
msg_data.pointer = BROWSER_POINTER_AUTO;
|
|
|
|
content_broadcast(data->c, CONTENT_MSG_POINTER, msg_data);
|
|
|
|
break;
|
2010-06-04 13:35:08 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* End overflow scroll scrollbar drags
|
|
|
|
*
|
|
|
|
* \param scroll scrollbar widget
|
|
|
|
* \param mouse state of mouse buttons and modifier keys
|
|
|
|
* \param x coordinate of mouse
|
|
|
|
* \param y coordinate of mouse
|
|
|
|
*/
|
2011-05-10 02:49:17 +04:00
|
|
|
void html_overflow_scroll_drag_end(struct scrollbar *scrollbar,
|
2010-06-04 13:35:08 +04:00
|
|
|
browser_mouse_state mouse, int x, int y)
|
|
|
|
{
|
|
|
|
int scroll_mouse_x, scroll_mouse_y, box_x, box_y;
|
2011-06-28 02:21:15 +04:00
|
|
|
struct html_scrollbar_data *data = scrollbar_get_data(scrollbar);
|
2010-06-04 13:35:08 +04:00
|
|
|
struct box *box;
|
|
|
|
|
|
|
|
box = data->box;
|
|
|
|
box_coords(box, &box_x, &box_y);
|
|
|
|
|
2011-05-10 02:49:17 +04:00
|
|
|
if (scrollbar_is_horizontal(scrollbar)) {
|
2010-06-04 13:35:08 +04:00
|
|
|
scroll_mouse_x = x - box_x;
|
|
|
|
scroll_mouse_y = y - (box_y + box->padding[TOP] +
|
|
|
|
box->height + box->padding[BOTTOM] -
|
|
|
|
SCROLLBAR_WIDTH);
|
2011-05-10 02:49:17 +04:00
|
|
|
scrollbar_mouse_drag_end(scrollbar, mouse,
|
2010-06-04 13:35:08 +04:00
|
|
|
scroll_mouse_x, scroll_mouse_y);
|
|
|
|
} else {
|
|
|
|
scroll_mouse_x = x - (box_x + box->padding[LEFT] +
|
|
|
|
box->width + box->padding[RIGHT] -
|
|
|
|
SCROLLBAR_WIDTH);
|
|
|
|
scroll_mouse_y = y - box_y;
|
2011-05-10 02:49:17 +04:00
|
|
|
scrollbar_mouse_drag_end(scrollbar, mouse,
|
2010-06-04 13:35:08 +04:00
|
|
|
scroll_mouse_x, scroll_mouse_y);
|
|
|
|
}
|
|
|
|
}
|
2013-02-08 17:22:53 +04:00
|
|
|
|
|
|
|
void html_set_drag_type(html_content *html, html_drag_type drag_type,
|
|
|
|
union html_drag_owner drag_owner, const struct rect *rect)
|
|
|
|
{
|
|
|
|
union content_msg_data msg_data;
|
|
|
|
|
|
|
|
assert(html != NULL);
|
|
|
|
|
|
|
|
html->drag_type = drag_type;
|
|
|
|
html->drag_owner = drag_owner;
|
|
|
|
|
|
|
|
switch (drag_type) {
|
|
|
|
case HTML_DRAG_NONE:
|
|
|
|
assert(drag_owner.no_owner == true);
|
|
|
|
msg_data.drag.type = CONTENT_DRAG_NONE;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case HTML_DRAG_SCROLLBAR:
|
|
|
|
case HTML_DRAG_TEXTAREA_SCROLLBAR:
|
|
|
|
case HTML_DRAG_CONTENT_SCROLL:
|
|
|
|
msg_data.drag.type = CONTENT_DRAG_SCROLL;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case HTML_DRAG_SELECTION:
|
|
|
|
assert(drag_owner.no_owner == true);
|
|
|
|
/* Fall through */
|
|
|
|
case HTML_DRAG_TEXTAREA_SELECTION:
|
|
|
|
case HTML_DRAG_CONTENT_SELECTION:
|
|
|
|
msg_data.drag.type = CONTENT_DRAG_SELECTION;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
msg_data.drag.rect = rect;
|
|
|
|
|
|
|
|
/* Inform the content's drag status change */
|
|
|
|
content_broadcast((struct content *)html, CONTENT_MSG_DRAG, msg_data);
|
|
|
|
}
|