summaryrefslogtreecommitdiff
path: root/src/gmdocument.c
diff options
context:
space:
mode:
authorJaakko Keränen <jaakko.keranen@iki.fi>2020-12-02 15:07:17 +0200
committerJaakko Keränen <jaakko.keranen@iki.fi>2020-12-02 15:07:17 +0200
commit849fd39d08bd4164ed486c2f4addc2cab7a85f9c (patch)
tree2e4c82c362c042abfe610b3d1c2bca1a2e21134e /src/gmdocument.c
parent9c384de6e9aa02a628b54b9930c22730f0a22dad (diff)
Show a banner warning about certificate issues
Diffstat (limited to 'src/gmdocument.c')
-rw-r--r--src/gmdocument.c19
1 files changed, 13 insertions, 6 deletions
diff --git a/src/gmdocument.c b/src/gmdocument.c
index 9e78c2e0..d01ba0b9 100644
--- a/src/gmdocument.c
+++ b/src/gmdocument.c
@@ -64,10 +64,10 @@ struct Impl_GmDocument {
64 iString source; 64 iString source;
65 iString url; /* for resolving relative links */ 65 iString url; /* for resolving relative links */
66 iString localHost; 66 iString localHost;
67 iBool siteBannerEnabled;
68 iInt2 size; 67 iInt2 size;
69 iArray layout; /* contents of source, laid out in document space */ 68 iArray layout; /* contents of source, laid out in document space */
70 iPtrArray links; 69 iPtrArray links;
70 enum iGmDocumentBanner bannerType;
71 iString bannerText; 71 iString bannerText;
72 iString title; /* the first top-level title */ 72 iString title; /* the first top-level title */
73 iArray headings; 73 iArray headings;
@@ -310,7 +310,7 @@ static void doLayout_GmDocument_(iGmDocument *d) {
310 int preFont = preformatted_FontId; 310 int preFont = preformatted_FontId;
311 uint16_t preId = 0; 311 uint16_t preId = 0;
312 iBool enableIndents = iFalse; 312 iBool enableIndents = iFalse;
313 iBool addSiteBanner = d->siteBannerEnabled; 313 iBool addSiteBanner = d->bannerType != none_GmDocumentBanner;
314 enum iGmLineType prevType = text_GmLineType; 314 enum iGmLineType prevType = text_GmLineType;
315 if (d->format == plainText_GmDocumentFormat) { 315 if (d->format == plainText_GmDocumentFormat) {
316 isPreformat = iTrue; 316 isPreformat = iTrue;
@@ -383,6 +383,10 @@ static void doLayout_GmDocument_(iGmDocument *d) {
383 iGmRun banner = { .flags = decoration_GmRunFlag | siteBanner_GmRunFlag }; 383 iGmRun banner = { .flags = decoration_GmRunFlag | siteBanner_GmRunFlag };
384 banner.bounds = zero_Rect(); 384 banner.bounds = zero_Rect();
385 banner.visBounds = init_Rect(0, 0, d->size.x, lineHeight_Text(banner_FontId) * 2); 385 banner.visBounds = init_Rect(0, 0, d->size.x, lineHeight_Text(banner_FontId) * 2);
386 if (d->bannerType == certificateWarning_GmDocumentBanner) {
387 banner.visBounds.size.y += iMaxi(6000 * lineHeight_Text(uiLabel_FontId) /
388 d->size.x, lineHeight_Text(uiLabel_FontId) * 5);
389 }
386 banner.font = banner_FontId; 390 banner.font = banner_FontId;
387 banner.text = bannerText; 391 banner.text = bannerText;
388 banner.color = tmBannerTitle_ColorId; 392 banner.color = tmBannerTitle_ColorId;
@@ -620,7 +624,7 @@ void init_GmDocument(iGmDocument *d) {
620 init_String(&d->source); 624 init_String(&d->source);
621 init_String(&d->url); 625 init_String(&d->url);
622 init_String(&d->localHost); 626 init_String(&d->localHost);
623 d->siteBannerEnabled = iTrue; 627 d->bannerType = siteDomain_GmDocumentBanner;
624 d->size = zero_I2(); 628 d->size = zero_I2();
625 init_Array(&d->layout, sizeof(iGmRun)); 629 init_Array(&d->layout, sizeof(iGmRun));
626 init_PtrArray(&d->links); 630 init_PtrArray(&d->links);
@@ -661,7 +665,6 @@ void reset_GmDocument(iGmDocument *d) {
661 clear_String(&d->url); 665 clear_String(&d->url);
662 clear_String(&d->localHost); 666 clear_String(&d->localHost);
663 d->themeSeed = 0; 667 d->themeSeed = 0;
664 d->siteBannerEnabled = iTrue;
665} 668}
666 669
667static void setDerivedThemeColors_(enum iGmDocumentTheme theme) { 670static void setDerivedThemeColors_(enum iGmDocumentTheme theme) {
@@ -1085,8 +1088,8 @@ void setFormat_GmDocument(iGmDocument *d, enum iGmDocumentFormat format) {
1085 d->format = format; 1088 d->format = format;
1086} 1089}
1087 1090
1088void setSiteBannerEnabled_GmDocument(iGmDocument *d, iBool siteBannerEnabled) { 1091void setBanner_GmDocument(iGmDocument *d, enum iGmDocumentBanner type) {
1089 d->siteBannerEnabled = siteBannerEnabled; 1092 d->bannerType = type;
1090} 1093}
1091 1094
1092void setWidth_GmDocument(iGmDocument *d, int width) { 1095void setWidth_GmDocument(iGmDocument *d, int width) {
@@ -1203,6 +1206,10 @@ iInt2 size_GmDocument(const iGmDocument *d) {
1203 return d->size; 1206 return d->size;
1204} 1207}
1205 1208
1209enum iGmDocumentBanner bannerType_GmDocument(const iGmDocument *d) {
1210 return d->bannerType;
1211}
1212
1206iBool hasSiteBanner_GmDocument(const iGmDocument *d) { 1213iBool hasSiteBanner_GmDocument(const iGmDocument *d) {
1207 return siteBanner_GmDocument(d) != NULL; 1214 return siteBanner_GmDocument(d) != NULL;
1208} 1215}