NetSurf
browser.c
Go to the documentation of this file.
1/*
2 * Copyright 2011 Daniel Silverstone <dsilvers@digital-scurf.org>
3 *
4 * This file is part of NetSurf, http://www.netsurf-browser.org/
5 *
6 * NetSurf is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; version 2 of the License.
9 *
10 * NetSurf is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18
19/* Browser-related callbacks */
20
21#include <stdio.h>
22#include <stdlib.h>
23#include <string.h>
24
25#include "utils/utils.h"
26#include "utils/ring.h"
27#include "utils/log.h"
28#include "utils/messages.h"
29#include "utils/nsurl.h"
30#include "netsurf/mouse.h"
31#include "netsurf/window.h"
33#include "netsurf/plotters.h"
34
35#include "monkey/output.h"
36#include "monkey/browser.h"
37#include "monkey/plot.h"
38
39static uint32_t win_ctr = 0;
40
41static struct gui_window *gw_ring = NULL;
42
43/* exported function documented in monkey/browser.h */
44nserror monkey_warn_user(const char *warning, const char *detail)
45{
46 moutf(MOUT_WARNING, "%s %s", warning, detail);
47 return NSERROR_OK;
48}
49
50struct gui_window *
52{
53 struct gui_window *ret = NULL;
54
55 RING_ITERATE_START(struct gui_window, gw_ring, c_ring) {
56 if (c_ring->win_num == win_num) {
57 ret = c_ring;
59 }
60 } RING_ITERATE_END(gw_ring, c_ring);
61
62 return ret;
63}
64
65void
67{
68 while (gw_ring != NULL) {
70 }
71}
72
73static struct gui_window *
75 struct gui_window *existing,
77{
78 struct gui_window *ret = calloc(sizeof(*ret), 1);
79 if (ret == NULL)
80 return NULL;
81
82 ret->win_num = win_ctr++;
83 ret->bw = bw;
84
85 ret->width = 800;
86 ret->height = 600;
87
89 "NEW WIN %u FOR %p EXISTING %p NEWTAB %s CLONE %s",
90 ret->win_num, bw, existing,
91 flags & GW_CREATE_TAB ? "TRUE" : "FALSE",
92 flags & GW_CREATE_CLONE ? "TRUE" : "FALSE");
94 "SIZE WIN %u WIDTH %d HEIGHT %d",
95 ret->win_num, ret->width, ret->height);
96
97 RING_INSERT(gw_ring, ret);
98
99 return ret;
100}
101
102static void
104{
105 moutf(MOUT_WINDOW, "DESTROY WIN %u", g->win_num);
107 free(g);
108}
109
110static void
111gui_window_set_title(struct gui_window *g, const char *title)
112{
113 moutf(MOUT_WINDOW, "TITLE WIN %u STR %s", g->win_num, title);
114}
115
116/**
117 * Find the current dimensions of a monkey browser window content area.
118 *
119 * \param g The gui window to measure content area of.
120 * \param width receives width of window
121 * \param height receives height of window
122 * \return NSERROR_OK on sucess and width and height updated.
123 */
124static nserror
126{
127 *width = g->width;
128 *height = g->height;
129
131 "GET_DIMENSIONS WIN %u WIDTH %d HEIGHT %d",
132 g->win_num, *width, *height);
133
134 return NSERROR_OK;
135}
136
137static void
139{
140 moutf(MOUT_WINDOW, "NEW_CONTENT WIN %u", g->win_num);
141}
142
143static void
145{
146 moutf(MOUT_WINDOW, "NEW_ICON WIN %u", g->win_num);
147}
148
149static void
151{
152 moutf(MOUT_WINDOW, "START_THROBBER WIN %u", g->win_num);
153}
154
155static void
157{
158 moutf(MOUT_WINDOW, "STOP_THROBBER WIN %u", g->win_num);
159}
160
161
162/**
163 * Set the scroll position of a monkey browser window.
164 *
165 * Scrolls the viewport to ensure the specified rectangle of the
166 * content is shown.
167 *
168 * \param gw gui window to scroll
169 * \param rect The rectangle to ensure is shown.
170 * \return NSERROR_OK on success or apropriate error code.
171 */
172static nserror
173gui_window_set_scroll(struct gui_window *gw, const struct rect *rect)
174{
175 gw->scrollx = rect->x0;
176 gw->scrolly = rect->y0;
177
178 moutf(MOUT_WINDOW, "SET_SCROLL WIN %u X %d Y %d",
179 gw->win_num, rect->x0, rect->y0);
180 return NSERROR_OK;
181}
182
183
184/**
185 * Invalidates an area of a monkey browser window
186 *
187 * \param gw gui_window
188 * \param rect area to redraw or NULL for the entire window area
189 * \return NSERROR_OK on success or appropriate error code
190 */
191static nserror
193{
194 if (rect != NULL) {
196 "INVALIDATE_AREA WIN %u X %d Y %d WIDTH %d HEIGHT %d",
197 gw->win_num,
198 rect->x0, rect->y0,
199 (rect->x1 - rect->x0), (rect->y1 - rect->y0));
200 } else {
201 moutf(MOUT_WINDOW, "INVALIDATE_AREA WIN %u ALL", gw->win_num);
202 }
203
204 return NSERROR_OK;
205}
206
207static void
209{
210 int width, height;
211
213 return;
214
215 moutf(MOUT_WINDOW, "UPDATE_EXTENT WIN %u WIDTH %d HEIGHT %d",
216 g->win_num, width, height);
217}
218
219static void
220gui_window_set_status(struct gui_window *g, const char *text)
221{
222 moutf(MOUT_WINDOW, "SET_STATUS WIN %u STR %s", g->win_num, text);
223}
224
225static void
227{
228 const char *ptr_name = "UNKNOWN";
229
230 switch (shape) {
232 ptr_name = "POINT";
233 break;
235 ptr_name = "CARET";
236 break;
237 case GUI_POINTER_UP:
238 ptr_name = "UP";
239 break;
240 case GUI_POINTER_DOWN:
241 ptr_name = "DOWN";
242 break;
243 case GUI_POINTER_LEFT:
244 ptr_name = "LEFT";
245 break;
247 ptr_name = "RIGHT";
248 break;
249 case GUI_POINTER_LD:
250 ptr_name = "LD";
251 break;
252 case GUI_POINTER_RD:
253 ptr_name = "RD";
254 break;
255 case GUI_POINTER_LU:
256 ptr_name = "LU";
257 break;
258 case GUI_POINTER_RU:
259 ptr_name = "RU";
260 break;
262 ptr_name = "CROSS";
263 break;
264 case GUI_POINTER_MOVE:
265 ptr_name = "MOVE";
266 break;
267 case GUI_POINTER_WAIT:
268 ptr_name = "WAIT";
269 break;
270 case GUI_POINTER_HELP:
271 ptr_name = "HELP";
272 break;
273 case GUI_POINTER_MENU:
274 ptr_name = "MENU";
275 break;
277 ptr_name = "PROGRESS";
278 break;
280 ptr_name = "NO_DROP";
281 break;
283 ptr_name = "NOT_ALLOWED";
284 break;
286 ptr_name = "DEFAULT";
287 break;
288 default:
289 break;
290 }
291
292 moutf(MOUT_WINDOW, "SET_POINTER WIN %u POINTER %s",
293 g->win_num, ptr_name);
294}
295
296static nserror
298{
299 moutf(MOUT_WINDOW, "SET_URL WIN %u URL %s",
301 return NSERROR_OK;
302}
303
304static bool
305gui_window_get_scroll(struct gui_window *g, int *sx, int *sy)
306{
307 moutf(MOUT_WINDOW, "GET_SCROLL WIN %u X %d Y %d",
308 g->win_num, g->scrollx, g->scrolly);
309 *sx = g->scrollx;
310 *sy = g->scrolly;
311 return true;
312}
313
314static bool
316{
317 moutf(MOUT_WINDOW, "SCROLL_START WIN %u", g->win_num);
318 g->scrollx = g->scrolly = 0;
319 return true;
320}
321
322
323static void
324gui_window_place_caret(struct gui_window *g, int x, int y, int height,
325 const struct rect *clip)
326{
327 moutf(MOUT_WINDOW, "PLACE_CARET WIN %u X %d Y %d HEIGHT %d",
328 g->win_num, x, y, height);
329}
330
331static void
333{
334 moutf(MOUT_WINDOW, "REMOVE_CARET WIN %u", g->win_num);
335}
336
337static bool
339 const struct rect *rect)
340{
341 moutf(MOUT_WINDOW, "SCROLL_START WIN %u TYPE %i", g->win_num, type);
342 return false;
343}
344
345static nserror
347{
348 moutf(MOUT_WINDOW, "SAVE_LINK WIN %u URL %s TITLE %s",
350 return NSERROR_OK;
351}
352
353static void
356 const char *msg,
357 size_t msglen,
359{
360 bool foldable = !!(flags & BW_CS_FLAG_FOLDABLE);
361 const char *src_text;
362 const char *level_text;
363
364 switch (src) {
365 case BW_CS_INPUT:
366 src_text = "client-input";
367 break;
369 src_text = "scripting-error";
370 break;
372 src_text = "scripting-console";
373 break;
374 default:
375 assert(0 && "Unknown scripting source");
376 src_text = "unknown";
377 break;
378 }
379
380 switch (flags & BW_CS_FLAG_LEVEL_MASK) {
382 level_text = "DEBUG";
383 break;
385 level_text = "LOG";
386 break;
388 level_text = "INFO";
389 break;
391 level_text = "WARN";
392 break;
394 level_text = "ERROR";
395 break;
396 default:
397 assert(0 && "Unknown console logging level");
398 level_text = "unknown";
399 break;
400 }
401
402 moutf(MOUT_WINDOW, "CONSOLE_LOG WIN %u SOURCE %s %sFOLDABLE %s %.*s",
403 g->win_num, src_text, foldable ? "" : "NOT-", level_text,
404 (int)msglen, msg);
405}
406
407static void
409{
410 const char *state = "***WAH***";
411
414 state = "UNKNOWN";
415 break;
416
418 state = "INTERNAL";
419 break;
420
421 case PAGE_STATE_LOCAL:
422 state = "LOCAL";
423 break;
424
426 state = "INSECURE";
427 break;
428
430 state = "SECURE_OVERRIDE";
431 break;
432
434 state = "SECURE_ISSUES";
435 break;
436
438 state = "SECURE";
439 break;
440
441 default:
442 assert(0 && "Monkey needs some lovin' here");
443 break;
444 }
445 moutf(MOUT_WINDOW, "PAGE_STATUS WIN %u STATUS %s",
446 g->win_num, state);
447}
448
449/**** Handlers ****/
450
451static void
452monkey_window_handle_new(int argc, char **argv)
453{
454 nsurl *url = NULL;
455 nserror error = NSERROR_OK;
456
457 if (argc > 3)
458 return;
459
460 if (argc == 3) {
461 error = nsurl_create(argv[2], &url);
462 }
463 if (error == NSERROR_OK) {
465 url,
466 NULL,
467 NULL,
468 NULL);
469 if (url != NULL) {
471 }
472 }
473 if (error != NSERROR_OK) {
475 }
476}
477
478static void
479monkey_window_handle_destroy(int argc, char **argv)
480{
481 struct gui_window *gw;
482 uint32_t nr = atoi((argc > 2) ? argv[2] : "-1");
483
485
486 if (gw == NULL) {
487 moutf(MOUT_ERROR, "WINDOW NUM BAD");
488 } else {
490 }
491}
492
493static void
494monkey_window_handle_go(int argc, char **argv)
495{
496 struct gui_window *gw;
497 nsurl *url;
498 nsurl *ref_url = NULL;
499 nserror error;
500
501 if (argc < 4 || argc > 5) {
502 moutf(MOUT_ERROR, "WINDOW GO ARGS BAD");
503 return;
504 }
505
506 gw = monkey_find_window_by_num(atoi(argv[2]));
507
508 if (gw == NULL) {
509 moutf(MOUT_ERROR, "WINDOW NUM BAD");
510 return;
511 }
512
513 error = nsurl_create(argv[3], &url);
514 if (error == NSERROR_OK) {
515 if (argc == 5) {
516 error = nsurl_create(argv[4], &ref_url);
517 }
518
519 if (error == NSERROR_OK) {
520 error = browser_window_navigate(gw->bw,
521 url,
522 ref_url,
524 NULL,
525 NULL,
526 NULL);
527 if (ref_url != NULL) {
528 nsurl_unref(ref_url);
529 }
530 }
532 }
533
534 if (error != NSERROR_OK) {
536 }
537}
538
539/**
540 * handle WINDOW STOP command
541 */
542static void
543monkey_window_handle_stop(int argc, char **argv)
544{
545 struct gui_window *gw;
546 if (argc != 3) {
547 moutf(MOUT_ERROR, "WINDOW STOP ARGS BAD\n");
548 return;
549 }
550
551 gw = monkey_find_window_by_num(atoi(argv[2]));
552
553 if (gw == NULL) {
554 moutf(MOUT_ERROR, "WINDOW NUM BAD");
555 } else {
557 }
558}
559
560
561static void
562monkey_window_handle_redraw(int argc, char **argv)
563{
564 struct gui_window *gw;
565 struct rect clip;
566 struct redraw_context ctx = {
567 .interactive = true,
568 .background_images = true,
569 .plot = monkey_plotters
570 };
571
572 if (argc != 3 && argc != 7) {
573 moutf(MOUT_ERROR, "WINDOW REDRAW ARGS BAD");
574 return;
575 }
576
577 gw = monkey_find_window_by_num(atoi(argv[2]));
578
579 if (gw == NULL) {
580 moutf(MOUT_ERROR, "WINDOW NUM BAD");
581 return;
582 }
583
584 clip.x0 = 0;
585 clip.y0 = 0;
586 clip.x1 = gw->width;
587 clip.y1 = gw->height;
588
589 if (argc == 7) {
590 clip.x0 = atoi(argv[3]);
591 clip.y0 = atoi(argv[4]);
592 clip.x1 = atoi(argv[5]);
593 clip.y1 = atoi(argv[6]);
594 }
595
596 NSLOG(netsurf, INFO, "Issue redraw");
597 moutf(MOUT_WINDOW, "REDRAW WIN %d START", atoi(argv[2]));
598 browser_window_redraw(gw->bw, gw->scrollx, gw->scrolly, &clip, &ctx);
599 moutf(MOUT_WINDOW, "REDRAW WIN %d STOP", atoi(argv[2]));
600}
601
602static void
603monkey_window_handle_reload(int argc, char **argv)
604{
605 struct gui_window *gw;
606 if (argc != 3 && argc != 4) {
607 moutf(MOUT_ERROR, "WINDOW RELOAD ARGS BAD\n");
608 return;
609 }
610
611 gw = monkey_find_window_by_num(atoi(argv[2]));
612
613 if (gw == NULL) {
614 moutf(MOUT_ERROR, "WINDOW NUM BAD");
615 } else {
616 browser_window_reload(gw->bw, argc == 4);
617 }
618}
619
620static void
621monkey_window_handle_exec(int argc, char **argv)
622{
623 struct gui_window *gw;
624 if (argc < 5) {
625 moutf(MOUT_ERROR, "WINDOW EXEC ARGS BAD\n");
626 }
627
628 gw = monkey_find_window_by_num(atoi(argv[2]));
629
630 if (gw == NULL) {
631 moutf(MOUT_ERROR, "WINDOW NUM BAD");
632 } else {
633 /* Gather argv[4] onward into a string to pass to js_exec */
634 int total = 0;
635 for (int i = 4; i < argc; ++i) {
636 total += strlen(argv[i]) + 1;
637 }
638 char *cmd = calloc(total, 1);
639 if (cmd == NULL) {
640 moutf(MOUT_ERROR, "JS WIN %d RET ENOMEM", atoi(argv[2]));
641 return;
642 }
643 strcpy(cmd, argv[4]);
644 for (int i = 5; i < argc; ++i) {
645 strcat(cmd, " ");
646 strcat(cmd, argv[i]);
647 }
648 /* Now execute the JS */
649
650 moutf(MOUT_WINDOW, "JS WIN %d RET %s", atoi(argv[2]),
651 browser_window_exec(gw->bw, cmd, total - 1) ? "TRUE" : "FALSE");
652
653 free(cmd);
654 }
655}
656
657
658static void
659monkey_window_handle_click(int argc, char **argv)
660{
661 /* `WINDOW CLICK WIN` _%id%_ `X` _%num%_ `Y` _%num%_ `BUTTON` _%str%_ `KIND` _%str%_ */
662 /* 0 1 2 3 4 5 6 7 8 9 10 11 */
663 struct gui_window *gw;
664 if (argc != 12) {
665 moutf(MOUT_ERROR, "WINDOW CLICK ARGS BAD\n");
666 }
667
668 gw = monkey_find_window_by_num(atoi(argv[2]));
669
670 if (gw == NULL) {
671 moutf(MOUT_ERROR, "WINDOW NUM BAD");
672 } else {
673 int x = atoi(argv[5]);
674 int y = atoi(argv[7]);
676 const char *button = argv[9];
677 const char *kind = argv[11];
678 if (strcmp(button, "LEFT") == 0) {
680 } else if (strcmp(button, "RIGHT") == 0) {
682 } else {
683 moutf(MOUT_ERROR, "WINDOW BUTTON BAD");
684 return;
685 }
686 if (strcmp(kind, "SINGLE") == 0) {
687 /* Nothing */
688 } else if (strcmp(kind, "DOUBLE") == 0) {
690 } else if (strcmp(kind, "TRIPLE") == 0) {
692 } else {
693 moutf(MOUT_ERROR, "WINDOW KIND BAD");
694 return;
695 }
697 }
698}
699
700void
701monkey_window_handle_command(int argc, char **argv)
702{
703 if (argc == 1)
704 return;
705
706 if (strcmp(argv[1], "NEW") == 0) {
707 monkey_window_handle_new(argc, argv);
708 } else if (strcmp(argv[1], "DESTROY") == 0) {
710 } else if (strcmp(argv[1], "GO") == 0) {
711 monkey_window_handle_go(argc, argv);
712 } else if (strcmp(argv[1], "STOP") == 0) {
713 monkey_window_handle_stop(argc, argv);
714 } else if (strcmp(argv[1], "REDRAW") == 0) {
715 monkey_window_handle_redraw(argc, argv);
716 } else if (strcmp(argv[1], "RELOAD") == 0) {
717 monkey_window_handle_reload(argc, argv);
718 } else if (strcmp(argv[1], "EXEC") == 0) {
719 monkey_window_handle_exec(argc, argv);
720 } else if (strcmp(argv[1], "CLICK") == 0) {
721 monkey_window_handle_click(argc, argv);
722 } else {
723 moutf(MOUT_ERROR, "WINDOW COMMAND UNKNOWN %s\n", argv[1]);
724 }
725
726}
727
728/**
729 * process miscellaneous window events
730 *
731 * \param gw The window receiving the event.
732 * \param event The event code.
733 * \return NSERROR_OK when processed ok
734 */
735static nserror
737{
738 switch (event) {
741 break;
742
745 break;
746
749 break;
750
753 break;
754
757 break;
758
761 break;
762
765 break;
766
767 default:
768 break;
769 }
770 return NSERROR_OK;
771}
772
775 .destroy = gui_window_destroy,
776 .invalidate = monkey_window_invalidate_area,
777 .get_scroll = gui_window_get_scroll,
778 .set_scroll = gui_window_set_scroll,
779 .get_dimensions = gui_window_get_dimensions,
780 .event = gui_window_event,
781
782 .set_title = gui_window_set_title,
783 .set_url = gui_window_set_url,
784 .set_icon = gui_window_set_icon,
785 .set_status = gui_window_set_status,
786 .set_pointer = gui_window_set_pointer,
787 .place_caret = gui_window_place_caret,
788 .drag_start = gui_window_drag_start,
789 .save_link = gui_window_save_link,
790
791 .console_log = gui_window_console_log,
792};
793
Browser window creation and manipulation interface.
nserror browser_window_navigate(struct browser_window *bw, struct nsurl *url, struct nsurl *referrer, enum browser_window_nav_flags flags, char *post_urlenc, struct fetch_multipart_data *post_multipart, struct hlcache_handle *parent)
Start fetching a page in a browser window.
bool browser_window_redraw(struct browser_window *bw, int x, int y, const struct rect *clip, const struct redraw_context *ctx)
Redraw an area of a window.
bool browser_window_exec(struct browser_window *bw, const char *src, size_t srclen)
Execute some JavaScript code in a browsing context.
void browser_window_mouse_click(struct browser_window *bw, browser_mouse_state mouse, int x, int y)
Handle mouse clicks in a browser window.
void browser_window_destroy(struct browser_window *bw)
Close and destroy a browser window.
nserror browser_window_reload(struct browser_window *bw, bool all)
Reload the page in a browser window.
@ PAGE_STATE_INSECURE
Insecure page load.
@ PAGE_STATE_UNKNOWN
Unable to determine.
@ PAGE_STATE_SECURE_ISSUES
Secure load, but has insecure elements.
@ PAGE_STATE_SECURE
Secure load.
@ PAGE_STATE_SECURE_OVERRIDE
Secure load, but had to override.
@ PAGE_STATE_LOCAL
Page loaded from file:/// etc.
@ PAGE_STATE_INTERNAL
Page loaded from internal handler.
nserror browser_window_get_extents(struct browser_window *bw, bool scaled, int *width, int *height)
Get a browser window's content extents.
nserror browser_window_create(enum browser_window_create_flags flags, struct nsurl *url, struct nsurl *referrer, struct browser_window *existing, struct browser_window **bw)
Create and open a new root browser window with the given page.
void browser_window_stop(struct browser_window *bw)
Stop all fetching activity in a browser window.
browser_window_page_info_state browser_window_get_page_info_state(const struct browser_window *bw)
Request the current browser window page info state.
@ BW_CREATE_HISTORY
this will form a new history node (don't set for back/reload/etc)
@ BW_NAVIGATE_HISTORY
this will form a new history node (don't set for back/reload/etc)
browser_window_console_source
Sources of messages which end up in the browser window console.
Definition: console.h:30
@ BW_CS_SCRIPT_CONSOLE
Logging from some running script.
Definition: console.h:33
@ BW_CS_INPUT
Input from the client.
Definition: console.h:31
@ BW_CS_SCRIPT_ERROR
Error from some running script.
Definition: console.h:32
browser_window_console_flags
Flags for browser window console logging.
Definition: console.h:41
@ BW_CS_FLAG_LEVEL_LOG
Logged at the 'log' level, please only use one of the LEVEL flags.
Definition: console.h:55
@ BW_CS_FLAG_LEVEL_DEBUG
Logged at the 'debug' level, please use only one of the LEVEL flags.
Definition: console.h:53
@ BW_CS_FLAG_LEVEL_INFO
Logged at the 'info' level, please use only one of the LEVEL flags.
Definition: console.h:57
@ BW_CS_FLAG_LEVEL_MASK
Mask for the error level to allow easy comparison using the above.
Definition: console.h:64
@ BW_CS_FLAG_LEVEL_WARN
Logged at the 'warn' level, please use only one of the LEVEL flags.
Definition: console.h:59
@ BW_CS_FLAG_LEVEL_ERROR
Logged at the 'error' level, please use only one of the LEVEL flags.
Definition: console.h:61
@ BW_CS_FLAG_FOLDABLE
The log entry is foldable.
Definition: console.h:50
nserror
Enumeration of error codes.
Definition: errors.h:29
@ NSERROR_OK
No error.
Definition: errors.h:30
const char * type
Definition: filetype.cpp:44
static void monkey_window_handle_destroy(int argc, char **argv)
Definition: browser.c:479
nserror monkey_warn_user(const char *warning, const char *detail)
Definition: browser.c:44
static nserror gui_window_save_link(struct gui_window *g, nsurl *url, const char *title)
Definition: browser.c:346
static nserror gui_window_set_scroll(struct gui_window *gw, const struct rect *rect)
Set the scroll position of a monkey browser window.
Definition: browser.c:173
static void gui_window_set_status(struct gui_window *g, const char *text)
Definition: browser.c:220
static nserror gui_window_event(struct gui_window *gw, enum gui_window_event event)
process miscellaneous window events
Definition: browser.c:736
static void gui_window_destroy(struct gui_window *g)
Definition: browser.c:103
static void gui_window_set_pointer(struct gui_window *g, gui_pointer_shape shape)
Definition: browser.c:226
static void gui_window_remove_caret(struct gui_window *g)
Definition: browser.c:332
static void gui_window_update_extent(struct gui_window *g)
Definition: browser.c:208
static void monkey_window_handle_new(int argc, char **argv)
Definition: browser.c:452
void monkey_kill_browser_windows(void)
Definition: browser.c:66
static void monkey_window_handle_stop(int argc, char **argv)
handle WINDOW STOP command
Definition: browser.c:543
static struct gui_window * gui_window_create(struct browser_window *bw, struct gui_window *existing, gui_window_create_flags flags)
Definition: browser.c:74
static void monkey_window_handle_exec(int argc, char **argv)
Definition: browser.c:621
static nserror monkey_window_invalidate_area(struct gui_window *gw, const struct rect *rect)
Invalidates an area of a monkey browser window.
Definition: browser.c:192
static void gui_window_start_throbber(struct gui_window *g)
Definition: browser.c:150
static struct gui_window_table window_table
Definition: browser.c:773
static void monkey_window_handle_redraw(int argc, char **argv)
Definition: browser.c:562
static void gui_window_set_title(struct gui_window *g, const char *title)
Definition: browser.c:111
static nserror gui_window_set_url(struct gui_window *g, nsurl *url)
Definition: browser.c:297
struct gui_window_table * monkey_window_table
Definition: browser.c:794
struct gui_window * monkey_find_window_by_num(uint32_t win_num)
Definition: browser.c:51
static void gui_window_stop_throbber(struct gui_window *g)
Definition: browser.c:156
static bool gui_window_scroll_start(struct gui_window *g)
Definition: browser.c:315
static void monkey_window_handle_reload(int argc, char **argv)
Definition: browser.c:603
static void gui_window_place_caret(struct gui_window *g, int x, int y, int height, const struct rect *clip)
Definition: browser.c:324
static struct gui_window * gw_ring
Definition: browser.c:41
static void gui_window_report_page_info(struct gui_window *g)
Definition: browser.c:408
static bool gui_window_get_scroll(struct gui_window *g, int *sx, int *sy)
Definition: browser.c:305
static uint32_t win_ctr
Definition: browser.c:39
static void gui_window_set_icon(struct gui_window *g, struct hlcache_handle *icon)
Definition: browser.c:144
void monkey_window_handle_command(int argc, char **argv)
Definition: browser.c:701
static void gui_window_new_content(struct gui_window *g)
Definition: browser.c:138
static nserror gui_window_get_dimensions(struct gui_window *g, int *width, int *height)
Find the current dimensions of a monkey browser window content area.
Definition: browser.c:125
static void monkey_window_handle_go(int argc, char **argv)
Definition: browser.c:494
static void monkey_window_handle_click(int argc, char **argv)
Definition: browser.c:659
static bool gui_window_drag_start(struct gui_window *g, gui_drag_type type, const struct rect *rect)
Definition: browser.c:338
static void gui_window_console_log(struct gui_window *g, browser_window_console_source src, const char *msg, size_t msglen, browser_window_console_flags flags)
Definition: browser.c:354
Core mouse and pointer states.
browser_mouse_state
Mouse state.
Definition: mouse.h:43
@ BROWSER_MOUSE_CLICK_2
button 2 clicked.
Definition: mouse.h:57
@ BROWSER_MOUSE_TRIPLE_CLICK
button triple clicked
Definition: mouse.h:62
@ BROWSER_MOUSE_CLICK_1
button 1 clicked.
Definition: mouse.h:55
@ BROWSER_MOUSE_DOUBLE_CLICK
button double clicked
Definition: mouse.h:60
gui_pointer_shape
Definition: mouse.h:89
@ GUI_POINTER_WAIT
Definition: mouse.h:104
@ GUI_POINTER_RIGHT
Definition: mouse.h:97
@ GUI_POINTER_MOVE
Definition: mouse.h:103
@ GUI_POINTER_CARET
Definition: mouse.h:92
@ GUI_POINTER_PROGRESS
Definition: mouse.h:108
@ GUI_POINTER_RD
Definition: mouse.h:101
@ GUI_POINTER_LD
Definition: mouse.h:99
@ GUI_POINTER_NO_DROP
Definition: mouse.h:106
@ GUI_POINTER_DOWN
Definition: mouse.h:95
@ GUI_POINTER_UP
Definition: mouse.h:94
@ GUI_POINTER_RU
Definition: mouse.h:98
@ GUI_POINTER_DEFAULT
Definition: mouse.h:90
@ GUI_POINTER_HELP
Definition: mouse.h:105
@ GUI_POINTER_MENU
Definition: mouse.h:93
@ GUI_POINTER_POINT
Definition: mouse.h:91
@ GUI_POINTER_LEFT
Definition: mouse.h:96
@ GUI_POINTER_NOT_ALLOWED
Definition: mouse.h:107
@ GUI_POINTER_LU
Definition: mouse.h:100
@ GUI_POINTER_CROSS
Definition: mouse.h:102
Target independent plotting interface.
Interface to platform-specific graphical user interface window operations.
gui_window_create_flags
Window creation control flags.
Definition: window.h:66
@ GW_CREATE_TAB
Create tab in same window as existing.
Definition: window.h:69
@ GW_CREATE_CLONE
Clone existing window.
Definition: window.h:68
gui_drag_type
Definition: window.h:56
gui_window_event
Window events.
Definition: window.h:80
@ GW_EVENT_SCROLL_START
Starts drag scrolling of a browser window.
Definition: window.h:113
@ GW_EVENT_PAGE_INFO_CHANGE
Page status has changed and so the padlock should be updated.
Definition: window.h:129
@ GW_EVENT_REMOVE_CARET
Remove the caret, if present.
Definition: window.h:98
@ GW_EVENT_NEW_CONTENT
Called when the gui_window has new content.
Definition: window.h:118
@ GW_EVENT_STOP_THROBBER
stop the navigation throbber.
Definition: window.h:108
@ GW_EVENT_UPDATE_EXTENT
Update the extent of the inside of a browser window to that of the current content.
Definition: window.h:93
@ GW_EVENT_START_THROBBER
start the navigation throbber.
Definition: window.h:103
#define NSLOG(catname, level, logmsg, args...)
Definition: log.h:116
const char * messages_get_errorcode(nserror code)
lookup of a message by errorcode from the standard Messages hash.
Definition: messages.c:248
Localised message support (interface).
const struct plotter_table * monkey_plotters
Definition: plot.c:267
NetSurf URL handling (interface).
nserror nsurl_create(const char *const url_s, nsurl **url)
Create a NetSurf URL object from a URL string.
void nsurl_unref(nsurl *url)
Drop a reference to a NetSurf URL object.
const char * nsurl_access(const nsurl *url)
Access a NetSurf URL object as a string.
struct nsurl nsurl
NetSurf URL object.
Definition: nsurl.h:31
int moutf(enum monkey_output_type mout_type, const char *fmt,...)
Definition: output.c:39
@ MOUT_WINDOW
Definition: output.h:27
@ MOUT_WARNING
Definition: output.h:25
@ MOUT_ERROR
Definition: output.h:24
Ring list structure.
#define RING_ITERATE_STOP(ring, iteratorptr)
Definition: ring.h:133
#define RING_REMOVE(ring, element)
Remove the given element from the specified ring.
Definition: ring.h:53
#define RING_INSERT(ring, element)
Insert the given item into the specified ring.
Definition: ring.h:40
#define RING_ITERATE_END(ring, iteratorptr)
Definition: ring.h:136
#define RING_ITERATE_START(ringtype, ring, iteratorptr)
Definition: ring.h:127
int width
Definition: gui.c:159
int height
Definition: gui.c:160
Interface to utility string handling.
Browser window data.
Graphical user interface window function table.
Definition: window.h:137
struct gui_window *(* create)(struct browser_window *bw, struct gui_window *existing, gui_window_create_flags flags)
Create and open a gui window for a browsing context.
Definition: window.h:164
first entry in window list
Definition: gui.c:296
uint32_t win_num
Definition: browser.h:31
int state
Definition: window.cpp:73
int height
height of drawing area
Definition: browser.h:34
int width
width of window
Definition: browser.h:34
char * url
Definition: gui.h:154
int scrollx
current scroll location
Definition: gui.c:305
struct bitmap * icon
Definition: gui.h:156
struct gui_window::@32 mouse
char * title
Definition: gui.h:153
int scrolly
current scroll location
Definition: gui.c:306
struct browser_window * bw
The 'content' window that is rendered in the gui_window.
Definition: gui.c:314
High-level cache handle.
Definition: hlcache.c:66
Rectangle coordinates.
Definition: types.h:40
int x0
Definition: types.h:41
int y0
Top left.
Definition: types.h:41
int x1
Definition: types.h:42
int y1
Bottom right.
Definition: types.h:42
Redraw context.
Definition: plotters.h:51
bool interactive
Redraw to show interactive features.
Definition: plotters.h:59
Interface to a number of general purpose functionality.
static nserror text(const struct redraw_context *ctx, const struct plot_font_style *fstyle, int x, int y, const char *text, size_t length)
Text plotting.
Definition: plot.c:978
static nserror clip(const struct redraw_context *ctx, const struct rect *clip)
Sets a clip rectangle for subsequent plot operations.
Definition: plot.c:357