summaryrefslogtreecommitdiff
path: root/src/ui
diff options
context:
space:
mode:
Diffstat (limited to 'src/ui')
-rw-r--r--src/ui/documentwidget.c19
1 files changed, 16 insertions, 3 deletions
diff --git a/src/ui/documentwidget.c b/src/ui/documentwidget.c
index 337e2a03..40b3d7a4 100644
--- a/src/ui/documentwidget.c
+++ b/src/ui/documentwidget.c
@@ -222,6 +222,7 @@ enum iDocumentWidgetFlag {
222 movingSelectMarkStart_DocumentWidgetFlag = iBit(10), 222 movingSelectMarkStart_DocumentWidgetFlag = iBit(10),
223 movingSelectMarkEnd_DocumentWidgetFlag = iBit(11), 223 movingSelectMarkEnd_DocumentWidgetFlag = iBit(11),
224 otherRootByDefault_DocumentWidgetFlag = iBit(12), /* links open to other root by default */ 224 otherRootByDefault_DocumentWidgetFlag = iBit(12), /* links open to other root by default */
225 urlChanged_DocumentWidgetFlag = iBit(13),
225}; 226};
226 227
227enum iDocumentLinkOrdinalMode { 228enum iDocumentLinkOrdinalMode {
@@ -1414,6 +1415,7 @@ static void updateFromCachedResponse_DocumentWidget_(iDocumentWidget *d, float n
1414 moveSpan_SmoothScroll(&d->scrollY, 0, 0); /* clamp position to new max */ 1415 moveSpan_SmoothScroll(&d->scrollY, 0, 0); /* clamp position to new max */
1415 cacheDocumentGlyphs_DocumentWidget_(d); 1416 cacheDocumentGlyphs_DocumentWidget_(d);
1416 d->drawBufs->flags |= updateTimestampBuf_DrawBufsFlag | updateSideBuf_DrawBufsFlag; 1417 d->drawBufs->flags |= updateTimestampBuf_DrawBufsFlag | updateSideBuf_DrawBufsFlag;
1418 d->flags &= ~urlChanged_DocumentWidgetFlag;
1417 postCommandf_Root(as_Widget(d)->root, "document.changed doc:%p url:%s", d, cstr_String(d->mod.url)); 1419 postCommandf_Root(as_Widget(d)->root, "document.changed doc:%p url:%s", d, cstr_String(d->mod.url));
1418} 1420}
1419 1421
@@ -1662,7 +1664,10 @@ static void checkResponse_DocumentWidget_(iDocumentWidget *d) {
1662 break; 1664 break;
1663 } 1665 }
1664 case categorySuccess_GmStatusCode: 1666 case categorySuccess_GmStatusCode:
1665 //reset_SmoothScroll(&d->scrollY); 1667 if (d->flags & urlChanged_DocumentWidgetFlag) {
1668 /* Keep scroll position when reloading the same page. */
1669 reset_SmoothScroll(&d->scrollY);
1670 }
1666 reset_GmDocument(d->doc); /* new content incoming */ 1671 reset_GmDocument(d->doc); /* new content incoming */
1667 delete_Gempub(d->sourceGempub); 1672 delete_Gempub(d->sourceGempub);
1668 d->sourceGempub = NULL; 1673 d->sourceGempub = NULL;
@@ -2321,6 +2326,7 @@ static iBool handleCommand_DocumentWidget_(iDocumentWidget *d, const char *cmd)
2321 if (category_GmStatusCode(status_GmRequest(d->request)) == categorySuccess_GmStatusCode) { 2326 if (category_GmStatusCode(status_GmRequest(d->request)) == categorySuccess_GmStatusCode) {
2322 init_Anim(&d->scrollY.pos, d->initNormScrollY * size_GmDocument(d->doc).y); /* TODO: unless user already scrolled! */ 2327 init_Anim(&d->scrollY.pos, d->initNormScrollY * size_GmDocument(d->doc).y); /* TODO: unless user already scrolled! */
2323 } 2328 }
2329 d->flags &= ~urlChanged_DocumentWidgetFlag;
2324 d->state = ready_RequestState; 2330 d->state = ready_RequestState;
2325 postProcessRequestContent_DocumentWidget_(d, iFalse); 2331 postProcessRequestContent_DocumentWidget_(d, iFalse);
2326 /* The response may be cached. */ 2332 /* The response may be cached. */
@@ -4410,9 +4416,16 @@ void deserializeState_DocumentWidget(iDocumentWidget *d, iStream *ins) {
4410 updateFromHistory_DocumentWidget_(d); 4416 updateFromHistory_DocumentWidget_(d);
4411} 4417}
4412 4418
4419static void setUrl_DocumentWidget_(iDocumentWidget *d, const iString *url) {
4420 if (!equal_String(d->mod.url, url)) {
4421 d->flags |= urlChanged_DocumentWidgetFlag;
4422 set_String(d->mod.url, url);
4423 }
4424}
4425
4413void setUrlFromCache_DocumentWidget(iDocumentWidget *d, const iString *url, iBool isFromCache) { 4426void setUrlFromCache_DocumentWidget(iDocumentWidget *d, const iString *url, iBool isFromCache) {
4414 setLinkNumberMode_DocumentWidget_(d, iFalse); 4427 setLinkNumberMode_DocumentWidget_(d, iFalse);
4415 set_String(d->mod.url, urlFragmentStripped_String(url)); 4428 setUrl_DocumentWidget_(d, urlFragmentStripped_String(url));
4416 /* See if there a username in the URL. */ 4429 /* See if there a username in the URL. */
4417 parseUser_DocumentWidget_(d); 4430 parseUser_DocumentWidget_(d);
4418 if (!isFromCache || !updateFromHistory_DocumentWidget_(d)) { 4431 if (!isFromCache || !updateFromHistory_DocumentWidget_(d)) {
@@ -4423,7 +4436,7 @@ void setUrlFromCache_DocumentWidget(iDocumentWidget *d, const iString *url, iBoo
4423void setUrlAndSource_DocumentWidget(iDocumentWidget *d, const iString *url, const iString *mime, 4436void setUrlAndSource_DocumentWidget(iDocumentWidget *d, const iString *url, const iString *mime,
4424 const iBlock *source) { 4437 const iBlock *source) {
4425 setLinkNumberMode_DocumentWidget_(d, iFalse); 4438 setLinkNumberMode_DocumentWidget_(d, iFalse);
4426 set_String(d->mod.url, url); 4439 setUrl_DocumentWidget_(d, url);
4427 parseUser_DocumentWidget_(d); 4440 parseUser_DocumentWidget_(d);
4428 iGmResponse *resp = new_GmResponse(); 4441 iGmResponse *resp = new_GmResponse();
4429 resp->statusCode = success_GmStatusCode; 4442 resp->statusCode = success_GmStatusCode;