summaryrefslogtreecommitdiff
path: root/src/ui/documentwidget.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/ui/documentwidget.c')
-rw-r--r--src/ui/documentwidget.c39
1 files changed, 29 insertions, 10 deletions
diff --git a/src/ui/documentwidget.c b/src/ui/documentwidget.c
index a52e99af..7d9ac154 100644
--- a/src/ui/documentwidget.c
+++ b/src/ui/documentwidget.c
@@ -358,6 +358,7 @@ static void updateSideIconBuf_DocumentWidget_ (const iDocumentWidget *d);
358static void prerender_DocumentWidget_ (iAny *); 358static void prerender_DocumentWidget_ (iAny *);
359static void scrollBegan_DocumentWidget_ (iAnyObject *, int, uint32_t); 359static void scrollBegan_DocumentWidget_ (iAnyObject *, int, uint32_t);
360static void refreshWhileScrolling_DocumentWidget_ (iAny *); 360static void refreshWhileScrolling_DocumentWidget_ (iAny *);
361static iBool requestMedia_DocumentWidget_ (iDocumentWidget *d, iGmLinkId linkId, iBool enableFilters);
361 362
362/* TODO: The following methods are called from DocumentView, which goes the wrong way. */ 363/* TODO: The following methods are called from DocumentView, which goes the wrong way. */
363 364
@@ -1824,7 +1825,7 @@ static void draw_DocumentView_(const iDocumentView *d) {
1824 } 1825 }
1825 if (d->drawBufs->flags & updateSideBuf_DrawBufsFlag) { 1826 if (d->drawBufs->flags & updateSideBuf_DrawBufsFlag) {
1826 updateSideIconBuf_DocumentView_(d); 1827 updateSideIconBuf_DocumentView_(d);
1827 } 1828 }
1828 const iRect docBounds = documentBounds_DocumentView_(d); 1829 const iRect docBounds = documentBounds_DocumentView_(d);
1829 const iRangei vis = visibleRange_DocumentView_(d); 1830 const iRangei vis = visibleRange_DocumentView_(d);
1830 iDrawContext ctx = { 1831 iDrawContext ctx = {
@@ -2410,6 +2411,20 @@ static const char *zipPageHeading_(const iRangecc mime) {
2410 2411
2411static void postProcessRequestContent_DocumentWidget_(iDocumentWidget *d, iBool isCached) { 2412static void postProcessRequestContent_DocumentWidget_(iDocumentWidget *d, iBool isCached) {
2412 iWidget *w = as_Widget(d); 2413 iWidget *w = as_Widget(d);
2414 /* Embedded images in data links can be shown immediately as they are already fetched
2415 data that is part of the document. */
2416 if (prefs_App()->openDataUrlImagesOnLoad) {
2417 iGmDocument *doc = d->view.doc;
2418 for (size_t linkId = 1; ; linkId++) {
2419 const int linkFlags = linkFlags_GmDocument(doc, linkId);
2420 const iString *linkUrl = linkUrl_GmDocument(doc, linkId);
2421 if (!linkUrl) break;
2422 if (scheme_GmLinkFlag(linkFlags) == data_GmLinkScheme &&
2423 (linkFlags & imageFileExtension_GmLinkFlag)) {
2424 requestMedia_DocumentWidget_(d, linkId, 0);
2425 }
2426 }
2427 }
2413 /* Gempub page behavior and footer actions. */ { 2428 /* Gempub page behavior and footer actions. */ {
2414 /* TODO: move this to gempub.c */ 2429 /* TODO: move this to gempub.c */
2415 delete_Gempub(d->sourceGempub); 2430 delete_Gempub(d->sourceGempub);
@@ -2681,7 +2696,7 @@ static void updateDocument_DocumentWidget_(iDocumentWidget *d,
2681 if (loadArchive_FontPack(fp, zip)) { 2696 if (loadArchive_FontPack(fp, zip)) {
2682 appendFormat_String(&str, "# " fontpack_Icon "%s\n%s", 2697 appendFormat_String(&str, "# " fontpack_Icon "%s\n%s",
2683 cstr_String(id_FontPack(fp).id), 2698 cstr_String(id_FontPack(fp).id),
2684 cstrCollect_String(infoText_FontPack(fp))); 2699 cstrCollect_String(infoText_FontPack(fp, iTrue)));
2685 } 2700 }
2686 appendCStr_String(&str, "\n"); 2701 appendCStr_String(&str, "\n");
2687 appendCStr_String(&str, cstr_Lang("fontpack.help")); 2702 appendCStr_String(&str, cstr_Lang("fontpack.help"));
@@ -3921,12 +3936,12 @@ static iBool handleCommand_DocumentWidget_(iDocumentWidget *d, const char *cmd)
3921 const char *unchecked = red_ColorEscape "\u2610"; 3936 const char *unchecked = red_ColorEscape "\u2610";
3922 const char *checked = green_ColorEscape "\u2611"; 3937 const char *checked = green_ColorEscape "\u2611";
3923 const iBool haveFingerprint = (d->certFlags & haveFingerprint_GmCertFlag) != 0; 3938 const iBool haveFingerprint = (d->certFlags & haveFingerprint_GmCertFlag) != 0;
3924 const int requiredForTrust = (available_GmCertFlag | haveFingerprint_GmCertFlag | 3939 const int requiredForTrust =
3925 timeVerified_GmCertFlag); 3940 (available_GmCertFlag | haveFingerprint_GmCertFlag | timeVerified_GmCertFlag);
3926 const iBool canTrust = ~d->certFlags & trusted_GmCertFlag && 3941 const iBool canTrust = ~d->certFlags & trusted_GmCertFlag &&
3927 ((d->certFlags & requiredForTrust) == requiredForTrust); 3942 ((d->certFlags & requiredForTrust) == requiredForTrust);
3928 const iRecentUrl *recent = constMostRecentUrl_History(d->mod.history); 3943 const iRecentUrl *recent = constMostRecentUrl_History(d->mod.history);
3929 const iString *meta = &d->sourceMime; 3944 const iString *meta = &d->sourceMime;
3930 if (recent && recent->cachedResponse) { 3945 if (recent && recent->cachedResponse) {
3931 meta = &recent->cachedResponse->meta; 3946 meta = &recent->cachedResponse->meta;
3932 } 3947 }
@@ -3991,6 +4006,10 @@ static iBool handleCommand_DocumentWidget_(iDocumentWidget *d, const char *cmd)
3991 if (haveFingerprint) { 4006 if (haveFingerprint) {
3992 pushBack_Array(items, &(iMenuItem){ "${dlg.cert.fingerprint}", 0, 0, "server.copycert" }); 4007 pushBack_Array(items, &(iMenuItem){ "${dlg.cert.fingerprint}", 0, 0, "server.copycert" });
3993 } 4008 }
4009 const iRangecc root = urlRoot_String(d->mod.url);
4010 if (!isEmpty_Range(&root)) {
4011 pushBack_Array(items, &(iMenuItem){ "${pageinfo.settings}", 0, 0, "document.sitespec" });
4012 }
3994 if (!isEmpty_Array(items)) { 4013 if (!isEmpty_Array(items)) {
3995 pushBack_Array(items, &(iMenuItem){ "---", 0, 0, 0 }); 4014 pushBack_Array(items, &(iMenuItem){ "---", 0, 0, 0 });
3996 } 4015 }
@@ -4922,7 +4941,7 @@ static iBool processEvent_DocumentWidget_(iDocumentWidget *d, const SDL_Event *e
4922 for (size_t i = 0; i < 64; ++i) { 4941 for (size_t i = 0; i < 64; ++i) {
4923 setByte_Block(seed, i, iRandom(0, 256)); 4942 setByte_Block(seed, i, iRandom(0, 256));
4924 } 4943 }
4925 setThemeSeed_GmDocument(view->doc, seed); 4944 setThemeSeed_GmDocument(view->doc, seed, NULL);
4926 delete_Block(seed); 4945 delete_Block(seed);
4927 invalidate_DocumentWidget_(d); 4946 invalidate_DocumentWidget_(d);
4928 refresh_Widget(w); 4947 refresh_Widget(w);
@@ -5545,10 +5564,10 @@ static void prerender_DocumentWidget_(iAny *context) {
5545 } 5564 }
5546 const iDocumentWidget *d = context; 5565 const iDocumentWidget *d = context;
5547 iDrawContext ctx = { 5566 iDrawContext ctx = {
5548 .view = &d->view, 5567 .view = &d->view,
5549 .docBounds = documentBounds_DocumentView_(&d->view), 5568 .docBounds = documentBounds_DocumentView_(&d->view),
5550 .vis = visibleRange_DocumentView_(&d->view), 5569 .vis = visibleRange_DocumentView_(&d->view),
5551 .showLinkNumbers = (d->flags & showLinkNumbers_DocumentWidgetFlag) != 0 5570 .showLinkNumbers = (d->flags & showLinkNumbers_DocumentWidgetFlag) != 0
5552 }; 5571 };
5553 // printf("%u prerendering\n", SDL_GetTicks()); 5572 // printf("%u prerendering\n", SDL_GetTicks());
5554 if (d->view.visBuf->buffers[0].texture) { 5573 if (d->view.visBuf->buffers[0].texture) {