NetSurf
content.c
Go to the documentation of this file.
1/*
2 * Copyright 2005-2007 James Bursa <bursa@users.sourceforge.net>
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/**
20 * \file
21 * Content handling implementation.
22 */
23
24#include <stdint.h>
25#include <stdlib.h>
26#include <string.h>
27#include <nsutils/time.h>
28
29#include "netsurf/inttypes.h"
30#include "utils/log.h"
31#include "utils/messages.h"
32#include "utils/corestrings.h"
34#include "netsurf/bitmap.h"
35#include "netsurf/content.h"
36#include "desktop/knockout.h"
37
39#include "content/textsearch.h"
41#include "content/hlcache.h"
42#include "content/urldb.h"
43
44#define URL_FMT_SPC "%.140s"
45
46const char * const content_status_name[] = {
47 "LOADING",
48 "READY",
49 "DONE",
50 "ERROR"
51};
52
53
54/**
55 * All data has arrived, convert for display.
56 *
57 * Calls the convert function for the content.
58 *
59 * - If the conversion succeeds, but there is still some processing required
60 * (eg. loading images), the content gets status CONTENT_STATUS_READY, and a
61 * CONTENT_MSG_READY is sent to all users.
62 * - If the conversion succeeds and is complete, the content gets status
63 * CONTENT_STATUS_DONE, and CONTENT_MSG_READY then CONTENT_MSG_DONE are sent.
64 * - If the conversion fails, CONTENT_MSG_ERROR is sent. The content will soon
65 * be destroyed and must no longer be used.
66 */
67static void content_convert(struct content *c)
68{
69 assert(c);
70 assert(c->status == CONTENT_STATUS_LOADING ||
72
74 return;
75
76 if (c->locked == true)
77 return;
78
79 NSLOG(netsurf, INFO, "content "URL_FMT_SPC" (%p)",
81
82 if (c->handler->data_complete != NULL) {
83 c->locked = true;
84 if (c->handler->data_complete(c) == false) {
86 }
87 /* Conversion to the READY state will unlock the content */
88 } else {
91 }
92}
93
94
95/**
96 * Handler for low-level cache events
97 *
98 * \param llcache Low-level cache handle
99 * \param event Event details
100 * \param pw Pointer to our context
101 * \return NSERROR_OK on success, appropriate error otherwise
102 */
103static nserror
105 const llcache_event *event, void *pw)
106{
107 struct content *c = pw;
108 union content_msg_data msg_data;
109 nserror error = NSERROR_OK;
110
111 switch (event->type) {
113 /* Will never happen: handled in hlcache */
114 break;
116 /* Will never happen: handled in hlcache */
117 break;
119 if (c->handler->process_data != NULL) {
120 if (c->handler->process_data(c,
121 (const char *) event->data.data.buf,
122 event->data.data.len) == false) {
125 /** \todo It's not clear what error this is */
126 error = NSERROR_NOMEM;
127 }
128 }
129 break;
131 {
132 size_t source_size;
133
134 (void) llcache_handle_get_source_data(llcache, &source_size);
135
136 content_set_status(c, messages_get("Processing"));
137 msg_data.explicit_status_text = NULL;
139
141 }
142 break;
144 /** \todo Error page? */
146 msg_data.errordata.errorcode = event->data.error.code;
147 msg_data.errordata.errormsg = event->data.error.msg;
149 break;
152 msg_data.explicit_status_text = NULL;
154 break;
156 msg_data.redirect.from = event->data.redirect.from;
157 msg_data.redirect.to = event->data.redirect.to;
159 break;
160 }
161
162 return error;
163}
164
165
166/**
167 * update content status message
168 *
169 * \param c the content to update.
170 */
171static void content_update_status(struct content *c)
172{
173 if (c->status == CONTENT_STATUS_LOADING ||
175 /* Not done yet */
176 snprintf(c->status_message, sizeof (c->status_message),
177 "%s%s%s", messages_get("Fetching"),
178 c->sub_status[0] != '\0' ? ", " : " ",
179 c->sub_status);
180 } else {
181 snprintf(c->status_message, sizeof (c->status_message),
182 "%s (%.1fs)", messages_get("Done"),
183 (float) c->time / 1000);
184 }
185}
186
187
188/* exported interface documented in content/protected.h */
191 const content_handler *handler,
192 lwc_string *imime_type,
193 const struct http_parameter *params,
195 const char *fallback_charset,
196 bool quirks)
197{
198 struct content_user *user_sentinel;
199 nserror error;
200
201 NSLOG(netsurf, INFO, "url "URL_FMT_SPC" -> %p",
203
204 user_sentinel = calloc(1, sizeof(struct content_user));
205 if (user_sentinel == NULL) {
206 return NSERROR_NOMEM;
207 }
208
209 if (fallback_charset != NULL) {
210 c->fallback_charset = strdup(fallback_charset);
211 if (c->fallback_charset == NULL) {
212 free(user_sentinel);
213 return NSERROR_NOMEM;
214 }
215 }
216
217 c->llcache = llcache;
218 c->mime_type = lwc_string_ref(imime_type);
219 c->handler = handler;
221 c->width = 0;
222 c->height = 0;
223 c->available_width = 0;
224 c->available_height = 0;
225 c->quirks = quirks;
226 c->refresh = 0;
227 nsu_getmonotonic_ms(&c->time);
228 c->size = 0;
229 c->title = NULL;
230 c->active = 0;
231 user_sentinel->callback = NULL;
232 user_sentinel->pw = NULL;
233 user_sentinel->next = NULL;
234 c->user_list = user_sentinel;
235 c->sub_status[0] = 0;
236 c->locked = false;
237 c->total_size = 0;
238 c->http_code = 0;
239
240 c->textsearch.string = NULL;
241 c->textsearch.context = NULL;
242
243 content_set_status(c, messages_get("Loading"));
244
245 /* Finally, claim low-level cache events */
248 if (error != NSERROR_OK) {
249 lwc_string_unref(c->mime_type);
250 return error;
251 }
252
253 return NSERROR_OK;
254}
255
256
257/* exported interface documented in content/content.h */
259{
260 struct content *c = hlcache_handle_get_content(h);
261
262 if (c == NULL)
263 return false;
264
265 return (c->handler->reformat != NULL);
266}
267
268
269/* exported interface documented in content/protected.h */
270void content_set_status(struct content *c, const char *status_message)
271{
272 size_t len = strlen(status_message);
273
274 if (len >= sizeof(c->sub_status)) {
275 len = sizeof(c->sub_status) - 1;
276 }
277 memcpy(c->sub_status, status_message, len);
278 c->sub_status[len] = '\0';
279
281}
282
283
284/* exported interface documented in content/protected.h */
286{
287 /* The content must be locked at this point, as it can only
288 * become READY after conversion. */
289 assert(c->locked);
290 c->locked = false;
291
295}
296
297
298/* exported interface documented in content/protected.h */
300{
301 uint64_t now_ms;
302
303 nsu_getmonotonic_ms(&now_ms);
304
306 c->time = now_ms - c->time;
309}
310
311
312/* exported interface documented in content/protected.h */
314{
315 c->locked = false;
317}
318
319
320/* exported interface documented in content/content.h */
321void content_reformat(hlcache_handle *h, bool background,
322 int width, int height)
323{
325 width, height);
326}
327
328
329/* exported interface documented in content/protected.h */
330void
331content__reformat(struct content *c, bool background, int width, int height)
332{
333 union content_msg_data data;
334 assert(c != 0);
335 assert(c->status == CONTENT_STATUS_READY ||
337 assert(c->locked == false);
338
341 if (c->handler->reformat != NULL) {
342
343 c->locked = true;
344 c->handler->reformat(c, width, height);
345 c->locked = false;
346
347 data.background = background;
349 }
350}
351
352
353/* exported interface documented in content/content.h */
355{
356 struct content_rfc5988_link *link;
357
358 assert(c);
359 NSLOG(netsurf, INFO, "content %p %s", c,
361 assert(c->locked == false);
362
363 if (c->handler->destroy != NULL)
364 c->handler->destroy(c);
365
367 c->llcache = NULL;
368
369 lwc_string_unref(c->mime_type);
370
371 /* release metadata links */
372 link = c->links;
373 while (link != NULL) {
374 link = content__free_rfc5988_link(link);
375 }
376
377 /* free the user list */
378 if (c->user_list != NULL) {
379 free(c->user_list);
380 }
381
382 /* free the title */
383 if (c->title != NULL) {
384 free(c->title);
385 }
386
387 /* free the fallback characterset */
388 if (c->fallback_charset != NULL) {
389 free(c->fallback_charset);
390 }
391
392 free(c);
393}
394
395
396/* exported interface documented in content/content.h */
397void
399 struct browser_window *bw,
401 int x, int y)
402{
403 struct content *c = hlcache_handle_get_content(h);
404 assert(c != NULL);
405
406 if (c->handler->mouse_track != NULL) {
407 c->handler->mouse_track(c, bw, mouse, x, y);
408 } else {
409 union content_msg_data msg_data;
410 msg_data.pointer = BROWSER_POINTER_AUTO;
412 }
413
414
415 return;
416}
417
418
419/* exported interface documented in content/content.h */
420void
422 struct browser_window *bw,
424 int x, int y)
425{
426 struct content *c = hlcache_handle_get_content(h);
427 assert(c != NULL);
428
429 if (c->handler->mouse_action != NULL)
430 c->handler->mouse_action(c, bw, mouse, x, y);
431
432 return;
433}
434
435
436/* exported interface documented in content/content.h */
437bool content_keypress(struct hlcache_handle *h, uint32_t key)
438{
439 struct content *c = hlcache_handle_get_content(h);
440 assert(c != NULL);
441
442 if (c->handler->keypress != NULL)
443 return c->handler->keypress(c, key);
444
445 return false;
446}
447
448
449/* exported interface documented in content/content.h */
451 int x, int y, int width, int height)
452{
454 x, y, width, height);
455}
456
457
458/* exported interface, documented in content/protected.h */
460 int x, int y, int width, int height)
461{
462 union content_msg_data data;
463
464 if (c == NULL)
465 return;
466
467 data.redraw.x = x;
468 data.redraw.y = y;
469 data.redraw.width = width;
470 data.redraw.height = height;
471
473}
474
475
476/* exported interface, documented in content/content.h */
477bool content_exec(struct hlcache_handle *h, const char *src, size_t srclen)
478{
479 struct content *c = hlcache_handle_get_content(h);
480
481 assert(c != NULL);
482
483 if (c->locked) {
484 /* Not safe to do stuff */
485 NSLOG(netsurf, DEEPDEBUG, "Unable to exec, content locked");
486 return false;
487 }
488
489 if (c->handler->exec == NULL) {
490 /* Can't exec something on this content */
491 NSLOG(netsurf, DEEPDEBUG, "Unable to exec, no exec function");
492 return false;
493 }
494
495 return c->handler->exec(c, src, srclen);
496}
497
498
499/* exported interface, documented in content/content.h */
501{
502 struct content *c = hlcache_handle_get_content(h);
503 struct nsurl *url = hlcache_handle_get_url(h);
504 lwc_string *scheme = nsurl_get_component(url, NSURL_SCHEME);
505 bool match;
506
507 /* Is this an internal scheme? If so, we trust here and stop */
508 if ((lwc_string_isequal(scheme, corestring_lwc_about,
509 &match) == lwc_error_ok &&
510 (match == true)) ||
511 (lwc_string_isequal(scheme, corestring_lwc_data,
512 &match) == lwc_error_ok &&
513 (match == true)) ||
514 (lwc_string_isequal(scheme, corestring_lwc_resource,
515 &match) == lwc_error_ok &&
516 (match == true)) ||
517 /* Our internal x-ns-css scheme is secure */
518 (lwc_string_isequal(scheme, corestring_lwc_x_ns_css,
519 &match) == lwc_error_ok &&
520 (match == true)) ||
521 /* We also treat file: as "not insecure" here */
522 (lwc_string_isequal(scheme, corestring_lwc_file,
523 &match) == lwc_error_ok &&
524 (match == true))) {
525 /* No insecurity to find */
526 lwc_string_unref(scheme);
527 return false;
528 }
529
530 /* Okay, not internal, am *I* secure? */
531 if ((lwc_string_isequal(scheme, corestring_lwc_https,
532 &match) == lwc_error_ok)
533 && (match == false)) {
534 /* I did see something insecure -- ME! */
535 lwc_string_unref(scheme);
536 return true;
537 }
538
539 lwc_string_unref(scheme);
540 /* I am supposed to be secure, but was I overridden */
542 /* I was https:// but I was overridden, that's no good */
543 return true;
544 }
545
546 /* Otherwise try and chain through the handler */
547 if (c != NULL && c->handler->saw_insecure_objects != NULL) {
548 return c->handler->saw_insecure_objects(c);
549 }
550
551 /* If we can't see insecure objects, we can't see them */
552 return false;
553}
554
555
556/* exported interface, documented in content/content.h */
557bool
559 struct content_redraw_data *data,
560 const struct rect *clip,
561 const struct redraw_context *ctx)
562{
563 struct content *c = hlcache_handle_get_content(h);
564
565 assert(c != NULL);
566
567 if (c->locked) {
568 /* not safe to attempt redraw */
569 return true;
570 }
571
572 /* ensure we have a redrawable content */
573 if (c->handler->redraw == NULL) {
574 return true;
575 }
576
577 return c->handler->redraw(c, data, clip, ctx);
578}
579
580
581/* exported interface, documented in content/content.h */
582bool
584 int width, int height,
585 const struct redraw_context *ctx)
586{
587 struct content *c = hlcache_handle_get_content(h);
588 struct redraw_context new_ctx = *ctx;
589 struct rect clip;
590 struct content_redraw_data data;
591 bool plot_ok = true;
592
593 assert(c != NULL);
594
595 /* ensure it is safe to attempt redraw */
596 if (c->locked) {
597 return true;
598 }
599
600 /* ensure we have a redrawable content */
601 if (c->handler->redraw == NULL) {
602 return true;
603 }
604
605 NSLOG(netsurf, INFO, "Content %p %dx%d ctx:%p", c, width, height, ctx);
606
607 if (ctx->plot->option_knockout) {
608 knockout_plot_start(ctx, &new_ctx);
609 }
610
611 /* Set clip rectangle to required thumbnail size */
612 clip.x0 = 0;
613 clip.y0 = 0;
614 clip.x1 = width;
615 clip.y1 = height;
616
617 new_ctx.plot->clip(&new_ctx, &clip);
618
619 /* Plot white background */
620 plot_ok &= (new_ctx.plot->rectangle(&new_ctx,
622 &clip) == NSERROR_OK);
623
624 /* Set up content redraw data */
625 data.x = 0;
626 data.y = 0;
627 data.width = width;
628 data.height = height;
629
630 data.background_colour = 0xFFFFFF;
631 data.repeat_x = false;
632 data.repeat_y = false;
633
634 /* Find the scale factor to use if the content has a width */
635 if (c->width) {
636 data.scale = (float)width / (float)c->width;
637 } else {
638 data.scale = 1.0;
639 }
640
641 /* Render the content */
642 plot_ok &= c->handler->redraw(c, &data, &clip, &new_ctx);
643
644 if (ctx->plot->option_knockout) {
646 }
647
648 return plot_ok;
649}
650
651
652/* exported interface documented in content/content.h */
653bool
655 void (*callback)(
656 struct content *c,
657 content_msg msg,
658 const union content_msg_data *data,
659 void *pw),
660 void *pw)
661{
662 struct content_user *user;
663
664 NSLOG(netsurf, INFO, "content "URL_FMT_SPC" (%p), user %p %p",
666 c, callback, pw);
667 user = malloc(sizeof(struct content_user));
668 if (!user)
669 return false;
670 user->callback = callback;
671 user->pw = pw;
672 user->next = c->user_list->next;
673 c->user_list->next = user;
674
675 if (c->handler->add_user != NULL)
676 c->handler->add_user(c);
677
678 return true;
679}
680
681
682/* exported interface documented in content/content.h */
683void
685 void (*callback)(
686 struct content *c,
687 content_msg msg,
688 const union content_msg_data *data,
689 void *pw),
690 void *pw)
691{
692 struct content_user *user, *next;
693 NSLOG(netsurf, INFO, "content "URL_FMT_SPC" (%p), user %p %p",
695 c, callback, pw);
696
697 /* user_list starts with a sentinel */
698 for (user = c->user_list; user->next != 0 &&
699 !(user->next->callback == callback &&
700 user->next->pw == pw); user = user->next)
701 ;
702 if (user->next == 0) {
703 NSLOG(netsurf, INFO, "user not found in list");
704 assert(0);
705 return;
706 }
707
708 if (c->handler->remove_user != NULL)
709 c->handler->remove_user(c);
710
711 next = user->next;
712 user->next = next->next;
713 free(next);
714}
715
716
717/* exported interface documented in content/content.h */
718uint32_t content_count_users(struct content *c)
719{
720 struct content_user *user;
721 uint32_t counter = 0;
722
723 assert(c != NULL);
724
725 for (user = c->user_list; user != NULL; user = user->next)
726 counter += 1;
727
728 assert(counter > 0);
729
730 return counter - 1; /* Subtract 1 for the sentinel */
731}
732
733
734/* exported interface documented in content/content.h */
735bool content_matches_quirks(struct content *c, bool quirks)
736{
737 if (c->handler->matches_quirks == NULL)
738 return true;
739
740 return c->handler->matches_quirks(c, quirks);
741}
742
743
744/* exported interface documented in content/content.h */
746{
747 return c->handler->no_share == false;
748}
749
750
751/* exported interface documented in content/protected.h */
753 const union content_msg_data *data)
754{
755 struct content_user *user, *next;
756 assert(c);
757
758 NSLOG(netsurf, DEEPDEBUG, "%p -> msg:%d", c, msg);
759 for (user = c->user_list->next; user != 0; user = next) {
760 next = user->next; /* user may be destroyed during callback */
761 if (user->callback != 0)
762 user->callback(c, msg, data, user->pw);
763 }
764}
765
766
767/* exported interface documented in content_protected.h */
768void
769content_broadcast_error(struct content *c, nserror errorcode, const char *msg)
770{
771 struct content_user *user, *next;
772 union content_msg_data data;
773
774 assert(c);
775
777 data.errordata.errormsg = msg;
778
779 for (user = c->user_list->next; user != 0; user = next) {
780 next = user->next; /* user may be destroyed during callback */
781 if (user->callback != 0) {
783 &data, user->pw);
784 }
785 }
786}
787
788
789/* exported interface, documented in content/content.h */
792 struct browser_window *bw,
793 struct content *page,
794 struct object_params *params)
795{
796 struct content *c;
797 nserror res;
798
800 assert(c != 0);
801 NSLOG(netsurf, INFO, "content %p %s", c,
803 if (c->handler->open != NULL) {
804 res = c->handler->open(c, bw, page, params);
805 } else {
806 res = NSERROR_OK;
807 }
808 return res;
809}
810
811
812/* exported interface, documented in content/content.h */
814{
815 struct content *c;
816 nserror res;
817
819 if (c == NULL) {
821 }
822
823 if ((c->status != CONTENT_STATUS_READY) &&
824 (c->status != CONTENT_STATUS_DONE)) {
825 /* status is not read or done so nothing to do */
826 return NSERROR_INVALID;
827 }
828
829 NSLOG(netsurf, INFO, "content %p %s", c,
831
832 if (c->textsearch.context != NULL) {
834 c->textsearch.context = NULL;
835 }
836
837 if (c->handler->close != NULL) {
838 res = c->handler->close(c);
839 } else {
840 res = NSERROR_OK;
841 }
842 return res;
843}
844
845
846/* exported interface, documented in content/content.h */
848{
849 struct content *c = hlcache_handle_get_content(h);
850 assert(c != 0);
851
852 if (c->handler->get_selection != NULL)
854}
855
856
857/* exported interface, documented in content/content.h */
859{
860 struct content *c = hlcache_handle_get_content(h);
861 assert(c != 0);
862
863 if (c->handler->get_selection != NULL)
864 return c->handler->get_selection(c);
865 else
866 return NULL;
867}
868
869
870/* exported interface documented in content/content.h */
873 int x, int y,
874 struct browser_window_features *data)
875{
876 struct content *c = hlcache_handle_get_content(h);
877 assert(c != 0);
878
879 if (c->handler->get_contextual_content != NULL) {
880 return c->handler->get_contextual_content(c, x, y, data);
881 }
882
883 data->object = h;
884 return NSERROR_OK;
885}
886
887
888/* exported interface, documented in content/content.h */
889bool
891 int x, int y,
892 int scrx, int scry)
893{
894 struct content *c = hlcache_handle_get_content(h);
895 assert(c != 0);
896
897 if (c->handler->scroll_at_point != NULL)
898 return c->handler->scroll_at_point(c, x, y, scrx, scry);
899
900 return false;
901}
902
903
904/* exported interface, documented in content/content.h */
905bool
907 int x, int y,
908 char *file)
909{
910 struct content *c = hlcache_handle_get_content(h);
911 assert(c != 0);
912
913 if (c->handler->drop_file_at_point != NULL)
914 return c->handler->drop_file_at_point(c, x, y, file);
915
916 return false;
917}
918
919
920/* exported interface documented in content/content.h */
923{
924 struct content *c = hlcache_handle_get_content(h);
925 assert(c != 0);
926
927 if (c->handler->debug_dump == NULL) {
929 }
930
931 return c->handler->debug_dump(c, f, op);
932}
933
934
935/* exported interface documented in content/content.h */
937{
938 struct content *c = hlcache_handle_get_content(h);
939
940 if (c == NULL) {
942 }
943
944 if (c->handler->debug == NULL) {
946 }
947
948 return c->handler->debug(c, op);
949}
950
951
952/* exported interface documented in content/content.h */
955{
956 struct content *c = hlcache_handle_get_content(h);
957 struct content_rfc5988_link *link = c->links;
958 bool rel_match = false;
959
960 while (link != NULL) {
961 if (lwc_string_caseless_isequal(link->rel, rel,
962 &rel_match) == lwc_error_ok && rel_match) {
963 break;
964 }
965 link = link->next;
966 }
967 return link;
968}
969
970
971/* exported interface documented in content/protected.h */
974{
976
977 next = link->next;
978
979 lwc_string_unref(link->rel);
980 nsurl_unref(link->href);
981 if (link->hreflang != NULL) {
982 lwc_string_unref(link->hreflang);
983 }
984 if (link->type != NULL) {
985 lwc_string_unref(link->type);
986 }
987 if (link->media != NULL) {
988 lwc_string_unref(link->media);
989 }
990 if (link->sizes != NULL) {
991 lwc_string_unref(link->sizes);
992 }
993 free(link);
994
995 return next;
996}
997
998
999/* exported interface documented in content/protected.h */
1000bool
1002 const struct content_rfc5988_link *link)
1003{
1004 struct content_rfc5988_link *newlink;
1005 union content_msg_data msg_data;
1006
1007 /* a link relation must be present for it to be a link */
1008 if (link->rel == NULL) {
1009 return false;
1010 }
1011
1012 /* a link href must be present for it to be a link */
1013 if (link->href == NULL) {
1014 return false;
1015 }
1016
1017 newlink = calloc(1, sizeof(struct content_rfc5988_link));
1018 if (newlink == NULL) {
1019 return false;
1020 }
1021
1022 /* copy values */
1023 newlink->rel = lwc_string_ref(link->rel);
1024 newlink->href = nsurl_ref(link->href);
1025 if (link->hreflang != NULL) {
1026 newlink->hreflang = lwc_string_ref(link->hreflang);
1027 }
1028 if (link->type != NULL) {
1029 newlink->type = lwc_string_ref(link->type);
1030 }
1031 if (link->media != NULL) {
1032 newlink->media = lwc_string_ref(link->media);
1033 }
1034 if (link->sizes != NULL) {
1035 newlink->sizes = lwc_string_ref(link->sizes);
1036 }
1037
1038 /* add to metadata link to list */
1039 newlink->next = c->links;
1040 c->links = newlink;
1041
1042 /* broadcast the data */
1043 msg_data.rfc5988_link = newlink;
1044 content_broadcast(c, CONTENT_MSG_LINK, &msg_data);
1045
1046 return true;
1047}
1048
1049
1050/* exported interface documented in content/content.h */
1052{
1053 if (c == NULL)
1054 return NULL;
1055
1057}
1058
1059
1060/* exported interface documented in content/content.h */
1062{
1063 struct content *c = hlcache_handle_get_content(h);
1064
1065 if (c == NULL)
1066 return CONTENT_NONE;
1067
1068 return c->handler->type();
1069}
1070
1071
1072/* exported interface documented in content/content.h */
1074{
1076}
1077
1078
1079/* exported interface documented in content/content_protected.h */
1080lwc_string *content__get_mime_type(struct content *c)
1081{
1082 if (c == NULL)
1083 return NULL;
1084
1085 return lwc_string_ref(c->mime_type);
1086}
1087
1088
1089/* exported interface documented in content/content_protected.h */
1090bool content__set_title(struct content *c, const char *title)
1091{
1092 char *new_title = strdup(title);
1093 if (new_title == NULL)
1094 return false;
1095
1096 if (c->title != NULL)
1097 free(c->title);
1098
1099 c->title = new_title;
1100
1101 return true;
1102}
1103
1104
1105/* exported interface documented in content/content.h */
1107{
1109}
1110
1111
1112/* exported interface documented in content/content_protected.h */
1113const char *content__get_title(struct content *c)
1114{
1115 if (c == NULL)
1116 return NULL;
1117
1118 return c->title != NULL ? c->title :
1120}
1121
1122
1123/* exported interface documented in content/content.h */
1125{
1127}
1128
1129
1130/* exported interface documented in content/content_protected.h */
1132{
1133 if (c == NULL)
1134 return CONTENT_STATUS_ERROR;
1135
1136 return c->status;
1137}
1138
1139
1140/* exported interface documented in content/content.h */
1142{
1144}
1145
1146
1147/* exported interface documented in content/content_protected.h */
1149{
1150 if (c == NULL)
1151 return NULL;
1152
1153 return c->status_message;
1154}
1155
1156
1157/* exported interface documented in content/content.h */
1159{
1161}
1162
1163
1164/* exported interface documented in content/content_protected.h */
1166{
1167 if (c == NULL)
1168 return 0;
1169
1170 return c->width;
1171}
1172
1173
1174/* exported interface documented in content/content.h */
1176{
1178}
1179
1180
1181/* exported interface documented in content/content_protected.h */
1183{
1184 if (c == NULL)
1185 return 0;
1186
1187 return c->height;
1188}
1189
1190
1191/* exported interface documented in content/content.h */
1193{
1195}
1196
1197
1198/* exported interface documented in content/content_protected.h */
1200{
1201 if (c == NULL)
1202 return 0;
1203
1204 return c->available_width;
1205}
1206
1207
1208/* exported interface documented in content/content.h */
1210{
1212}
1213
1214
1215/* exported interface documented in content/content_protected.h */
1216const uint8_t *content__get_source_data(struct content *c, size_t *size)
1217{
1218 assert(size != NULL);
1219
1220 /** \todo check if the content check should be an assert */
1221 if (c == NULL)
1222 return NULL;
1223
1225}
1226
1227
1228/* exported interface documented in content/content.h */
1230{
1232}
1233
1234
1235/* exported interface documented in content/content_protected.h */
1237{
1238 if (c == NULL || c->llcache == NULL)
1239 return;
1240
1241 /* Invalidate low-level cache data */
1243}
1244
1245
1246/* exported interface documented in content/content.h */
1248{
1250}
1251
1252
1253/* exported interface documented in content/content_protected.h */
1255{
1256 if (c == NULL)
1257 return NULL;
1258
1259 return c->refresh;
1260}
1261
1262
1263/* exported interface documented in content/content.h */
1265{
1267}
1268
1269
1270/* exported interface documented in content/content_protected.h */
1272{
1273 struct bitmap *bitmap = NULL;
1274
1275 if ((c != NULL) &&
1276 (c->handler != NULL) &&
1277 (c->handler->type != NULL) &&
1278 (c->handler->type() == CONTENT_IMAGE) &&
1279 (c->handler->get_internal != NULL) ) {
1280 bitmap = c->handler->get_internal(c, NULL);
1281 }
1282
1283 return bitmap;
1284}
1285
1286
1287/* exported interface documented in content/content.h */
1289{
1291}
1292
1293
1294/* exported interface documented in content/content_protected.h */
1296{
1297 if ((c != NULL) &&
1298 (c->handler != NULL) &&
1299 (c->handler->is_opaque != NULL)) {
1300 return c->handler->is_opaque(c);
1301 }
1302
1303 return false;
1304}
1305
1306
1307/* exported interface documented in content/content.h */
1309{
1310 struct content *c = hlcache_handle_get_content(h);
1311
1312 if (c == NULL)
1313 return false;
1314
1315 return c->quirks;
1316}
1317
1318
1319/* exported interface documented in content/content.h */
1320const char *
1322{
1324}
1325
1326
1327/* exported interface documented in content/content_protected.h */
1328const char *
1330{
1331 const char *encoding = NULL;
1332
1333 if ((c != NULL) &&
1334 (c->handler != NULL) &&
1335 (c->handler->get_encoding != NULL) ) {
1336 encoding = c->handler->get_encoding(c, op);
1337 }
1338
1339 return encoding;
1340}
1341
1342
1343/* exported interface documented in content/content.h */
1345{
1347}
1348
1349
1350/* exported interface documented in content/content_protected.h */
1352{
1353 return c->locked;
1354}
1355
1356
1357/* exported interface documented in content/content.h */
1359{
1360 if (c == NULL)
1361 return NULL;
1362
1363 return c->llcache;
1364}
1365
1366
1367/* exported interface documented in content/protected.h */
1369{
1370 struct content *nc;
1371 nserror error;
1372
1373 error = c->handler->clone(c, &nc);
1374 if (error != NSERROR_OK)
1375 return NULL;
1376
1377 return nc;
1378};
1379
1380
1381/* exported interface documented in content/protected.h */
1382nserror content__clone(const struct content *c, struct content *nc)
1383{
1384 nserror error;
1385
1386 error = llcache_handle_clone(c->llcache, &(nc->llcache));
1387 if (error != NSERROR_OK) {
1388 return error;
1389 }
1390
1393
1394 nc->mime_type = lwc_string_ref(c->mime_type);
1395 nc->handler = c->handler;
1396
1397 nc->status = c->status;
1398
1399 nc->width = c->width;
1400 nc->height = c->height;
1402 nc->quirks = c->quirks;
1403
1404 if (c->fallback_charset != NULL) {
1405 nc->fallback_charset = strdup(c->fallback_charset);
1406 if (nc->fallback_charset == NULL) {
1407 return NSERROR_NOMEM;
1408 }
1409 }
1410
1411 if (c->refresh != NULL) {
1412 nc->refresh = nsurl_ref(c->refresh);
1413 if (nc->refresh == NULL) {
1414 return NSERROR_NOMEM;
1415 }
1416 }
1417
1418 nc->time = c->time;
1420 nc->size = c->size;
1421
1422 if (c->title != NULL) {
1423 nc->title = strdup(c->title);
1424 if (nc->title == NULL) {
1425 return NSERROR_NOMEM;
1426 }
1427 }
1428
1429 nc->active = c->active;
1430
1431 nc->user_list = calloc(1, sizeof(struct content_user));
1432 if (nc->user_list == NULL) {
1433 return NSERROR_NOMEM;
1434 }
1435
1436 memcpy(&(nc->status_message), &(c->status_message), 120);
1437 memcpy(&(nc->sub_status), &(c->sub_status), 80);
1438
1439 nc->locked = c->locked;
1440 nc->total_size = c->total_size;
1441 nc->http_code = c->http_code;
1442
1443 return NSERROR_OK;
1444}
1445
1446
1447/* exported interface documented in content/content.h */
1449{
1450 NSLOG(netsurf, INFO, "Aborting %p", c);
1451
1452 if (c->handler->stop != NULL)
1453 c->handler->stop(c);
1454
1455 /* And for now, abort our llcache object */
1456 return llcache_handle_abort(c->llcache);
1457}
Browser window creation and manipulation interface.
const uint8_t * content_get_source_data(hlcache_handle *h, size_t *size)
Retrieve source of content.
Definition: content.c:1209
int content__get_available_width(struct content *c)
Retrieve available width of content.
Definition: content.c:1199
char * content_get_selection(hlcache_handle *h)
Get a text selection from a content.
Definition: content.c:858
const char * content_get_encoding(hlcache_handle *h, enum content_encoding_type op)
Retrieve the encoding of a content.
Definition: content.c:1321
nsurl * content__get_refresh_url(struct content *c)
Retrieve the refresh URL for a content.
Definition: content.c:1254
bool content_get_quirks(hlcache_handle *h)
Retrieve quirkiness of a content.
Definition: content.c:1308
void content_destroy(struct content *c)
Destroy and free a content.
Definition: content.c:354
nserror content_debug_dump(struct hlcache_handle *h, FILE *f, enum content_debug op)
Dump debug information to file.
Definition: content.c:922
bool content_exec(struct hlcache_handle *h, const char *src, size_t srclen)
Execute some JavaScript code inside a content object.
Definition: content.c:477
bool content_is_locked(hlcache_handle *h)
Return whether a content is currently locked.
Definition: content.c:1344
bool content__add_rfc5988_link(struct content *c, const struct content_rfc5988_link *link)
associate a metadata link with a content.
Definition: content.c:1001
struct content_rfc5988_link * content_find_rfc5988_link(hlcache_handle *h, lwc_string *rel)
find link in content that matches the rel string.
Definition: content.c:954
struct bitmap * content_get_bitmap(hlcache_handle *h)
Retrieve the bitmap contained in an image content.
Definition: content.c:1264
void content_mouse_action(hlcache_handle *h, struct browser_window *bw, browser_mouse_state mouse, int x, int y)
Handle mouse clicks and movements in a content window.
Definition: content.c:421
bool content__get_opaque(struct content *c)
Determine if a content is opaque.
Definition: content.c:1295
lwc_string * content__get_mime_type(struct content *c)
Retrieve mime-type of content.
Definition: content.c:1080
void content__reformat(struct content *c, bool background, int width, int height)
cause a content to be reformatted.
Definition: content.c:331
void content_broadcast(struct content *c, content_msg msg, const union content_msg_data *data)
Send a message to all users.
Definition: content.c:752
int content__get_height(struct content *c)
Retrieve height of content.
Definition: content.c:1182
void content_request_redraw(struct hlcache_handle *h, int x, int y, int width, int height)
Request a redraw of an area of a content.
Definition: content.c:450
void content_clear_selection(hlcache_handle *h)
Tell a content that any selection it has, or one of its objects has, must be cleared.
Definition: content.c:847
nserror content_close(hlcache_handle *h)
The window containing the content has been closed.
Definition: content.c:813
content_type content_get_type(hlcache_handle *h)
Retrieve computed type of content.
Definition: content.c:1061
void content_remove_user(struct content *c, void(*callback)(struct content *c, content_msg msg, const union content_msg_data *data, void *pw), void *pw)
Remove a callback user.
Definition: content.c:684
static void content_update_status(struct content *c)
update content status message
Definition: content.c:171
struct content_rfc5988_link * content__free_rfc5988_link(struct content_rfc5988_link *link)
free a rfc5988 link
Definition: content.c:973
struct bitmap * content__get_bitmap(struct content *c)
Retrieve the bitmap contained in an image content.
Definition: content.c:1271
void content_set_done(struct content *c)
Put a content in status CONTENT_STATUS_DONE.
Definition: content.c:299
int content__get_width(struct content *c)
Retrieve width of content.
Definition: content.c:1165
uint32_t content_count_users(struct content *c)
Count users for the content.
Definition: content.c:718
bool content_saw_insecure_objects(struct hlcache_handle *h)
Determine if the content referred to any insecure objects.
Definition: content.c:500
const char *const content_status_name[]
Definition: content.c:46
int content_get_width(hlcache_handle *h)
Retrieve width of content.
Definition: content.c:1158
const char * content_get_title(hlcache_handle *h)
Retrieve title associated with content.
Definition: content.c:1106
static void content_convert(struct content *c)
All data has arrived, convert for display.
Definition: content.c:67
bool content__set_title(struct content *c, const char *title)
Set title associated with content.
Definition: content.c:1090
bool content__is_locked(struct content *c)
Return whether a content is currently locked.
Definition: content.c:1351
nserror content__init(struct content *c, const content_handler *handler, lwc_string *imime_type, const struct http_parameter *params, llcache_handle *llcache, const char *fallback_charset, bool quirks)
Definition: content.c:190
const char * content__get_encoding(struct content *c, enum content_encoding_type op)
Retrieve the encoding of a content.
Definition: content.c:1329
bool content_scroll_at_point(struct hlcache_handle *h, int x, int y, int scrx, int scry)
scroll content at coordnate
Definition: content.c:890
bool content_is_shareable(struct content *c)
Determine if a content is shareable.
Definition: content.c:745
nserror content_get_contextual_content(struct hlcache_handle *h, int x, int y, struct browser_window_features *data)
Get positional contextural information for a content.
Definition: content.c:872
bool content_keypress(struct hlcache_handle *h, uint32_t key)
Handle keypresses.
Definition: content.c:437
void content_set_error(struct content *c)
Put a content in status CONTENT_STATUS_ERROR and unlock the content.
Definition: content.c:313
void content__request_redraw(struct content *c, int x, int y, int width, int height)
Request a redraw of an area of a content.
Definition: content.c:459
content_status content__get_status(struct content *c)
Retrieve status of content.
Definition: content.c:1131
void content_mouse_track(hlcache_handle *h, struct browser_window *bw, browser_mouse_state mouse, int x, int y)
Handle mouse movements in a content window.
Definition: content.c:398
lwc_string * content_get_mime_type(hlcache_handle *h)
Retrieve mime-type of content.
Definition: content.c:1073
nsurl * content_get_url(struct content *c)
Retrieve URL associated with content.
Definition: content.c:1051
bool content_can_reformat(hlcache_handle *h)
Get whether a content can reformat.
Definition: content.c:258
const uint8_t * content__get_source_data(struct content *c, size_t *size)
Retrieve source of content.
Definition: content.c:1216
const char * content__get_title(struct content *c)
Retrieve title associated with content.
Definition: content.c:1113
nserror content__clone(const struct content *c, struct content *nc)
Clone a content's data members.
Definition: content.c:1382
bool content_add_user(struct content *c, void(*callback)(struct content *c, content_msg msg, const union content_msg_data *data, void *pw), void *pw)
Register a user for callbacks.
Definition: content.c:654
void content_set_ready(struct content *c)
Put a content in status CONTENT_STATUS_READY and unlock the content.
Definition: content.c:285
bool content_drop_file_at_point(struct hlcache_handle *h, int x, int y, char *file)
Drag and drop a file at coordinate.
Definition: content.c:906
int content_get_height(hlcache_handle *h)
Retrieve height of content.
Definition: content.c:1175
struct content * content_clone(struct content *c)
Clone a content object in its current state.
Definition: content.c:1368
bool content_matches_quirks(struct content *c, bool quirks)
Determine if quirks mode matches.
Definition: content.c:735
#define URL_FMT_SPC
Definition: content.c:44
void content__invalidate_reuse_data(struct content *c)
Invalidate content reuse data.
Definition: content.c:1236
nserror content_abort(struct content *c)
Abort a content object.
Definition: content.c:1448
bool content_get_opaque(hlcache_handle *h)
Determine if a content is opaque from handle.
Definition: content.c:1288
const llcache_handle * content_get_llcache_handle(struct content *c)
Retrieve the low-level cache handle for a content.
Definition: content.c:1358
void content_reformat(hlcache_handle *h, bool background, int width, int height)
Reformat to new size.
Definition: content.c:321
nsurl * content_get_refresh_url(hlcache_handle *h)
Retrieve the refresh URL for a content.
Definition: content.c:1247
void content_invalidate_reuse_data(hlcache_handle *h)
Invalidate content reuse data.
Definition: content.c:1229
const char * content_get_status_message(hlcache_handle *h)
Retrieve status message associated with content.
Definition: content.c:1141
int content_get_available_width(hlcache_handle *h)
Retrieve available width of content.
Definition: content.c:1192
bool content_scaled_redraw(struct hlcache_handle *h, int width, int height, const struct redraw_context *ctx)
Redraw a content with scale set for horizontal fit.
Definition: content.c:583
const char * content__get_status_message(struct content *c)
Retrieve status message associated with content.
Definition: content.c:1148
static nserror content_llcache_callback(llcache_handle *llcache, const llcache_event *event, void *pw)
Handler for low-level cache events.
Definition: content.c:104
nserror content_debug(struct hlcache_handle *h, enum content_debug op)
Control debug con a content.
Definition: content.c:936
void content_set_status(struct content *c, const char *status_message)
Updates content with new status.
Definition: content.c:270
nserror content_open(hlcache_handle *h, struct browser_window *bw, struct content *page, struct object_params *params)
A window containing the content has been opened.
Definition: content.c:791
content_status content_get_status(hlcache_handle *h)
Retrieve status of content.
Definition: content.c:1124
void content_broadcast_error(struct content *c, nserror errorcode, const char *msg)
Send an error message to all users.
Definition: content.c:769
bool content_redraw(hlcache_handle *h, struct content_redraw_data *data, const struct rect *clip, const struct redraw_context *ctx)
Display content on screen with optional tiling.
Definition: content.c:558
Interface to content handling debug.
Protected interface to Content handling.
content_status
Status of a content.
Definition: content_type.h:87
@ CONTENT_STATUS_READY
Some parts of content still being loaded, but can be displayed.
Definition: content_type.h:92
@ CONTENT_STATUS_DONE
Content has completed all processing.
Definition: content_type.h:95
@ CONTENT_STATUS_ERROR
Error occurred, content will be destroyed imminently.
Definition: content_type.h:98
@ CONTENT_STATUS_LOADING
Content is being fetched or converted and is not safe to display.
Definition: content_type.h:89
content_type
The type of a content.
Definition: content_type.h:53
@ CONTENT_IMAGE
All images.
Definition: content_type.h:67
@ CONTENT_NONE
no type for content
Definition: content_type.h:55
content_msg
Used in callbacks to indicate what has occurred.
Definition: content_type.h:105
@ CONTENT_MSG_LINK
RFC5988 link.
Definition: content_type.h:143
@ CONTENT_MSG_STATUS
new status string
Definition: content_type.h:128
@ CONTENT_MSG_DONE
content has finished processing
Definition: content_type.h:119
@ CONTENT_MSG_ERROR
error occurred
Definition: content_type.h:122
@ CONTENT_MSG_REDIRECT
fetch url redirect occured
Definition: content_type.h:125
@ CONTENT_MSG_POINTER
Wants a specific mouse pointer set.
Definition: content_type.h:161
@ CONTENT_MSG_REDRAW
needs redraw (eg.
Definition: content_type.h:134
@ CONTENT_MSG_READY
may be displayed
Definition: content_type.h:116
@ CONTENT_MSG_REFORMAT
content_reformat done
Definition: content_type.h:131
content_debug
Debugging dump operations.
Definition: content_type.h:30
content_encoding_type
Content encoding information types.
Definition: content_type.h:43
Useful interned string pointers (interface).
nserror
Enumeration of error codes.
Definition: errors.h:29
@ NSERROR_NOT_IMPLEMENTED
Functionality is not implemented.
Definition: errors.h:61
@ NSERROR_BAD_PARAMETER
Bad Parameter.
Definition: errors.h:48
@ NSERROR_INVALID
Invalid data.
Definition: errors.h:49
@ NSERROR_NOMEM
Memory exhaustion.
Definition: errors.h:32
@ NSERROR_OK
No error.
Definition: errors.h:30
struct content * hlcache_handle_get_content(const hlcache_handle *handle)
Retrieve a content object from a cache handle.
Definition: hlcache.c:776
High-level resource cache interface.
Generic bitmap handling interface.
Public content interface.
struct nsurl * hlcache_handle_get_url(const struct hlcache_handle *handle)
Retrieve the URL associated with a high level cache handle.
@ BROWSER_POINTER_AUTO
Definition: mouse.h:155
browser_mouse_state
Mouse state: 1 is primary mouse button.
Definition: mouse.h:52
Netsurf additional integer type formatting macros.
bool knockout_plot_end(const struct redraw_context *ctx)
End a knockout plotting session.
Definition: knockout.c:997
bool knockout_plot_start(const struct redraw_context *ctx, struct redraw_context *knk_ctx)
Start a knockout plotting session.
Definition: knockout.c:971
Knockout rendering (interface).
nserror llcache_handle_clone(llcache_handle *handle, llcache_handle **result)
Clone a low-level cache handle, producing a new handle to the same fetch/content.
Definition: llcache.c:4082
static struct llcache_s * llcache
low level cache state
Definition: llcache.c:267
nserror llcache_handle_abort(llcache_handle *handle)
Abort a low-level fetch, informing all users of this action.
Definition: llcache.c:4098
nsurl * llcache_handle_get_url(const llcache_handle *handle)
Retrieve the post-redirect URL of a low-level cache object.
Definition: llcache.c:4195
const uint8_t * llcache_handle_get_source_data(const llcache_handle *handle, size_t *size)
Retrieve source data of a low-level cache object.
Definition: llcache.c:4201
nserror llcache_handle_change_callback(llcache_handle *handle, llcache_handle_callback cb, void *pw)
Change the callback associated with a low-level cache handle.
Definition: llcache.c:4047
nserror llcache_handle_invalidate_cache_data(llcache_handle *handle)
Invalidate cache data for a low-level cache object.
Definition: llcache.c:4182
nserror llcache_handle_release(llcache_handle *handle)
Release a low-level cache handle.
Definition: llcache.c:4058
@ LLCACHE_EVENT_DONE
Finished fetching data.
Definition: llcache.h:71
@ LLCACHE_EVENT_ERROR
An error occurred during fetch.
Definition: llcache.h:73
@ LLCACHE_EVENT_GOT_CERTS
SSL certificates arrived.
Definition: llcache.h:68
@ LLCACHE_EVENT_REDIRECT
Fetch URL redirect occured.
Definition: llcache.h:76
@ LLCACHE_EVENT_PROGRESS
Fetch progress update.
Definition: llcache.h:74
@ LLCACHE_EVENT_HAD_HEADERS
Received all headers.
Definition: llcache.h:69
@ LLCACHE_EVENT_HAD_DATA
Received some data.
Definition: llcache.h:70
#define NSLOG(catname, level, logmsg, args...)
Definition: log.h:116
const char * messages_get(const char *key)
Fast lookup of a message by key from the standard Messages hash.
Definition: messages.c:241
Localised message support (interface).
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.
const char * nsurl_access_log(const nsurl *url)
Variant of nsurl_access for logging.
nsurl * nsurl_ref(nsurl *url)
Increment the reference count to a NetSurf URL object.
lwc_string * nsurl_get_component(const nsurl *url, nsurl_component part)
Get part of a URL as a lwc_string, from a NetSurf URL object.
@ NSURL_SCHEME
Definition: nsurl.h:45
struct nsurl nsurl
NetSurf URL object.
Definition: nsurl.h:31
plot_style_t * plot_style_fill_white
Definition: plot_style.c:32
int width
Definition: gui.c:160
int height
Definition: gui.c:161
Interface to utility string handling.
RISC OS wimp toolkit bitmap.
Definition: bitmap.c:68
Page features at a specific spatial location.
struct hlcache_handle * object
Object at position or NULL.
Browser window data.
Content operation function table.
nserror(* close)(struct content *c)
void(* reformat)(struct content *c, int width, int height)
bool(* redraw)(struct content *c, struct content_redraw_data *data, const struct rect *clip, const struct redraw_context *ctx)
nserror(* open)(struct content *c, struct browser_window *bw, struct content *page, struct object_params *params)
nserror(* get_contextual_content)(struct content *c, int x, int y, struct browser_window_features *data)
nserror(* mouse_track)(struct content *c, struct browser_window *bw, browser_mouse_state mouse, int x, int y)
void(* clear_selection)(struct content *c)
bool(* data_complete)(struct content *c)
bool(* keypress)(struct content *c, uint32_t key)
bool(* scroll_at_point)(struct content *c, int x, int y, int scrx, int scry)
bool(* process_data)(struct content *c, const char *data, unsigned int size)
void(* add_user)(struct content *c)
bool(* saw_insecure_objects)(struct content *c)
void(* remove_user)(struct content *c)
void(* destroy)(struct content *c)
const char *(* get_encoding)(const struct content *c, enum content_encoding_type op)
nserror(* debug)(struct content *c, enum content_debug op)
nserror(* debug_dump)(struct content *c, FILE *f, enum content_debug op)
nserror(* mouse_action)(struct content *c, struct browser_window *bw, browser_mouse_state mouse, int x, int y)
bool(* exec)(struct content *c, const char *src, size_t srclen)
void(* stop)(struct content *c)
char *(* get_selection)(struct content *c)
content_type(* type)(void)
bool(* is_opaque)(struct content *c)
are the content contents opaque.
bool(* matches_quirks)(const struct content *c, bool quirks)
nserror(* clone)(const struct content *old, struct content **newc)
bool no_share
There must be one content per user for this type.
bool(* drop_file_at_point)(struct content *c, int x, int y, char *file)
void *(* get_internal)(const struct content *c, void *context)
handler dependant content sensitive internal data interface.
parameters to content redraw
Definition: content.h:40
int height
vertical dimension
Definition: content.h:48
bool repeat_y
whether content is tiled in y direction
Definition: content.h:59
bool repeat_x
whether content is tiled in x direction
Definition: content.h:58
int y
coordinate for top-left of redraw
Definition: content.h:42
int x
coordinate for top-left of redraw
Definition: content.h:41
colour background_colour
The background colour.
Definition: content.h:51
int width
dimensions to render content at (for scaling contents with intrinsic dimensions)
Definition: content.h:47
float scale
Scale for redraw (for scaling contents without intrinsic dimensions)
Definition: content.h:56
Linked list of users of a content.
void(* callback)(struct content *c, content_msg msg, const union content_msg_data *data, void *pw)
struct content_user * next
Content which corresponds to a single URL.
bool quirks
Content is in quirks mode.
int height
Height dimension, if applicable.
struct content_user * user_list
List of users.
lwc_string * mime_type
Original MIME type of data.
char * fallback_charset
Fallback charset, or NULL.
int width
Width dimension, if applicable.
const struct content_handler * handler
Handler for content.
unsigned int active
Number of child fetches or conversions currently in progress.
char status_message[120]
Full text for status bar.
struct llcache_handle * llcache
Low-level cache object.
int available_height
Viewport height.
unsigned long total_size
Total data size, 0 if unknown.
long http_code
HTTP status code, 0 if not HTTP.
struct content::@117 textsearch
Free text search state.
uint64_t time
Creation timestamp when LOADING or READY.
struct textsearch_context * context
content_status status
Current status.
unsigned int size
Estimated size of all data associated with this content.
uint64_t reformat_time
Earliest time to attempt a period reflow while fetching a page's objects.
struct content_rfc5988_link * links
list of metadata links
bool locked
Content is being processed: data structures may be inconsistent and content must not be redrawn or mo...
int available_width
Viewport width.
char sub_status[80]
Status of content.
struct nsurl * refresh
URL for refresh request.
char * title
Title for browser window.
High-level cache handle.
Definition: hlcache.c:66
Representation of an HTTP parameter.
Definition: parameter.c:31
Low-level cache events.
Definition: llcache.h:85
struct llcache_event::@124::@125 data
Received data.
size_t len
Byte length of buffer.
Definition: llcache.h:90
const char * progress_msg
Progress message.
Definition: llcache.h:96
llcache_event_type type
Type of event.
Definition: llcache.h:86
const uint8_t * buf
Buffer of data.
Definition: llcache.h:89
Handle to low-level cache object.
Definition: llcache.c:76
Parameters for object element and similar elements.
Definition: box.h:164
bool option_knockout
flag to enable knockout rendering.
Definition: plotters.h:328
nserror(* rectangle)(const struct redraw_context *ctx, const plot_style_t *pstyle, const struct rect *rectangle)
Plots a rectangle.
Definition: plotters.h:188
nserror(* clip)(const struct redraw_context *ctx, const struct rect *clip)
Sets a clip rectangle for subsequent plot operations.
Definition: plotters.h:111
Rectangle coordinates.
Definition: types.h:40
Redraw context.
Definition: plotters.h:51
const struct plotter_table * plot
Current plot operation table.
Definition: plotters.h:73
nserror content_textsearch_destroy(struct textsearch_context *textsearch)
Ends the search process, invalidating all state freeing the list of found boxes.
Definition: textsearch.c:647
Interface to HTML searching.
Extra data for some content_msg messages.
Definition: content.h:60
struct content_msg_data::@99 errordata
CONTENT_MSG_ERROR - Error from content or underlying fetch.
nserror errorcode
The error code to convey meaning.
Definition: content.h:88
int x
Carret x-coord.
Definition: content.h:110
const char * msg
The message to log.
Definition: content.h:68
int height
Carret height.
Definition: content.h:110
browser_pointer_shape pointer
CONTENT_MSG_POINTER - Mouse pointer to set.
Definition: content.h:192
const char * errormsg
The message.
Definition: content.h:95
struct content_rfc5988_link * rfc5988_link
CONTENT_MSG_RFC5988_LINK - rfc5988 link data.
Definition: content.h:138
struct nsurl * to
Redirect target.
Definition: content.h:103
struct nsurl * from
Redirect origin.
Definition: content.h:102
browser_window_console_source src
The source of the logging.
Definition: content.h:66
int y
Carret y-coord.
Definition: content.h:110
struct content_msg_data::@100 redirect
CONTENT_MSG_REDIRECT - Redirect info.
struct content_msg_data::@101 redraw
CONTENT_MSG_REDRAW - Area of content which needs redrawing.
const char * explicit_status_text
CONTENT_MSG_STATUS - Status message update.
Definition: content.h:128
bool background
CONTENT_MSG_REFORMAT - Reformat should not cause a redraw.
Definition: content.h:121
bool urldb_get_cert_permissions(nsurl *url)
Retrieve certificate verification permissions from database.
Definition: urldb.c:3480
Unified URL information database internal interface.
static nserror bitmap(const struct redraw_context *ctx, struct bitmap *bitmap, int x, int y, int width, int height, colour bg, bitmap_flags_t flags)
Plot a bitmap.
Definition: plot.c:857
static nserror clip(const struct redraw_context *ctx, const struct rect *clip)
Sets a clip rectangle for subsequent plot operations.
Definition: plot.c:357