diff options
author | Jaakko Keränen <jaakko.keranen@iki.fi> | 2021-11-22 10:58:37 +0200 |
---|---|---|
committer | Jaakko Keränen <jaakko.keranen@iki.fi> | 2021-11-22 10:58:37 +0200 |
commit | 3d02b7b06ae9a1473d0ffa43ec39330dd3a10215 (patch) | |
tree | 15d29fa60fc00c8a7b8d7de24584c60a933288e3 | |
parent | e72764f55b49643160e387fb942ac113d66620cf (diff) |
Input queries vs. navigation history
Input query responses (status 1x) are not preserved in History so that when navigating back, they are skipped.
The corresponding URLs are flagged as Transient so they are not shown in the History sidebar.
The History sidebar shows the query string in URLs.
IssueID #382
-rw-r--r-- | src/ui/documentwidget.c | 10 | ||||
-rw-r--r-- | src/ui/root.c | 10 | ||||
-rw-r--r-- | src/ui/sidebarwidget.c | 6 | ||||
-rw-r--r-- | src/visited.c | 2 |
4 files changed, 22 insertions, 6 deletions
diff --git a/src/ui/documentwidget.c b/src/ui/documentwidget.c index f2553632..0f0aeae8 100644 --- a/src/ui/documentwidget.c +++ b/src/ui/documentwidget.c | |||
@@ -3012,7 +3012,9 @@ static iBool handleCommand_DocumentWidget_(iDocumentWidget *d, const char *cmd) | |||
3012 | } | 3012 | } |
3013 | else if (equal_Command(cmd, "document.input.submit") && document_Command(cmd) == d) { | 3013 | else if (equal_Command(cmd, "document.input.submit") && document_Command(cmd) == d) { |
3014 | postCommandf_Root(w->root, | 3014 | postCommandf_Root(w->root, |
3015 | "open url:%s", | 3015 | /* use the `redirect:1` argument to cause the input query URL to be |
3016 | replaced in History; we don't want to navigate onto it */ | ||
3017 | "open redirect:1 url:%s", | ||
3016 | cstrCollect_String(makeQueryUrl_DocumentWidget_ | 3018 | cstrCollect_String(makeQueryUrl_DocumentWidget_ |
3017 | (d, collect_String(suffix_Command(cmd, "value"))))); | 3019 | (d, collect_String(suffix_Command(cmd, "value"))))); |
3018 | return iTrue; | 3020 | return iTrue; |
@@ -3066,7 +3068,11 @@ static iBool handleCommand_DocumentWidget_(iDocumentWidget *d, const char *cmd) | |||
3066 | iReleasePtr(&d->request); | 3068 | iReleasePtr(&d->request); |
3067 | updateVisible_DocumentWidget_(d); | 3069 | updateVisible_DocumentWidget_(d); |
3068 | d->drawBufs->flags |= updateSideBuf_DrawBufsFlag; | 3070 | d->drawBufs->flags |= updateSideBuf_DrawBufsFlag; |
3069 | postCommandf_Root(w->root, "document.changed doc:%p url:%s", d, cstr_String(d->mod.url)); | 3071 | postCommandf_Root(w->root, |
3072 | "document.changed doc:%p status:%d url:%s", | ||
3073 | d, | ||
3074 | d->sourceStatus, | ||
3075 | cstr_String(d->mod.url)); | ||
3070 | /* Check for a pending goto. */ | 3076 | /* Check for a pending goto. */ |
3071 | if (!isEmpty_String(&d->pendingGotoHeading)) { | 3077 | if (!isEmpty_String(&d->pendingGotoHeading)) { |
3072 | scrollToHeading_DocumentWidget_(d, cstr_String(&d->pendingGotoHeading)); | 3078 | scrollToHeading_DocumentWidget_(d, cstr_String(&d->pendingGotoHeading)); |
diff --git a/src/ui/root.c b/src/ui/root.c index 4849d0c7..5bfae857 100644 --- a/src/ui/root.c +++ b/src/ui/root.c | |||
@@ -760,9 +760,17 @@ static iBool handleNavBarCommands_(iWidget *navBar, const char *cmd) { | |||
760 | if (equal_Command(cmd, "document.changed")) { | 760 | if (equal_Command(cmd, "document.changed")) { |
761 | iInputWidget *url = findWidget_Root("url"); | 761 | iInputWidget *url = findWidget_Root("url"); |
762 | const iString *urlStr = collect_String(suffix_Command(cmd, "url")); | 762 | const iString *urlStr = collect_String(suffix_Command(cmd, "url")); |
763 | const enum iGmStatusCode statusCode = argLabel_Command(cmd, "status"); | ||
763 | trimCache_App(); | 764 | trimCache_App(); |
764 | trimMemory_App(); | 765 | trimMemory_App(); |
765 | visitUrl_Visited(visited_App(), urlStr, 0); | 766 | visitUrl_Visited(visited_App(), |
767 | urlStr, | ||
768 | /* The transient flag modifies history navigation behavior on | ||
769 | special responses like input queries. */ | ||
770 | category_GmStatusCode(statusCode) == categoryInput_GmStatusCode || | ||
771 | category_GmStatusCode(statusCode) == categoryRedirect_GmStatusCode | ||
772 | ? transient_VisitedUrlFlag | ||
773 | : 0); | ||
766 | postCommand_App("visited.changed"); /* sidebar will update */ | 774 | postCommand_App("visited.changed"); /* sidebar will update */ |
767 | setText_InputWidget(url, urlStr); | 775 | setText_InputWidget(url, urlStr); |
768 | checkLoadAnimation_Root_(get_Root()); | 776 | checkLoadAnimation_Root_(get_Root()); |
diff --git a/src/ui/sidebarwidget.c b/src/ui/sidebarwidget.c index 4b6fde3c..3abfd498 100644 --- a/src/ui/sidebarwidget.c +++ b/src/ui/sidebarwidget.c | |||
@@ -2019,7 +2019,7 @@ static void draw_SidebarItem_(const iSidebarItem *d, iPaint *p, iRect itemRect, | |||
2019 | add_I2(topLeft_Rect(itemRect), | 2019 | add_I2(topLeft_Rect(itemRect), |
2020 | init_I2(3 * gap_UI, (itemHeight - lineHeight_Text(font)) / 2)), | 2020 | init_I2(3 * gap_UI, (itemHeight - lineHeight_Text(font)) / 2)), |
2021 | fg, | 2021 | fg, |
2022 | "%s%s%s%s%s%s", | 2022 | "%s%s%s%s%s%s%s%s", |
2023 | isGemini ? "" : cstr_Rangecc(parts.scheme), | 2023 | isGemini ? "" : cstr_Rangecc(parts.scheme), |
2024 | isGemini ? "" : isAbout ? ":" : "://", | 2024 | isGemini ? "" : isAbout ? ":" : "://", |
2025 | escape_Color(isHover ? (isPressing ? uiTextPressed_ColorId | 2025 | escape_Color(isHover ? (isPressing ? uiTextPressed_ColorId |
@@ -2027,7 +2027,9 @@ static void draw_SidebarItem_(const iSidebarItem *d, iPaint *p, iRect itemRect, | |||
2027 | : uiTextStrong_ColorId), | 2027 | : uiTextStrong_ColorId), |
2028 | cstr_Rangecc(parts.host), | 2028 | cstr_Rangecc(parts.host), |
2029 | escape_Color(fg), | 2029 | escape_Color(fg), |
2030 | cstr_Rangecc(parts.path)); | 2030 | cstr_Rangecc(parts.path), |
2031 | !isEmpty_Range(&parts.query) ? escape_Color(uiAnnotation_ColorId) : "", | ||
2032 | !isEmpty_Range(&parts.query) ? cstr_Rangecc(parts.query) : ""); | ||
2031 | } | 2033 | } |
2032 | iEndCollect(); | 2034 | iEndCollect(); |
2033 | } | 2035 | } |
diff --git a/src/visited.c b/src/visited.c index 466add5b..4552a053 100644 --- a/src/visited.c +++ b/src/visited.c | |||
@@ -46,7 +46,7 @@ static int cmpUrl_VisitedUrl_(const void *a, const void *b) { | |||
46 | } | 46 | } |
47 | 47 | ||
48 | static int cmpNewer_VisitedUrl_(const void *insert, const void *existing) { | 48 | static int cmpNewer_VisitedUrl_(const void *insert, const void *existing) { |
49 | return seconds_Time(&((const iVisitedUrl *) insert )->when) > | 49 | return seconds_Time(&((const iVisitedUrl *) insert )->when) >= |
50 | seconds_Time(&((const iVisitedUrl *) existing)->when); | 50 | seconds_Time(&((const iVisitedUrl *) existing)->when); |
51 | } | 51 | } |
52 | 52 | ||