summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/app.c3
-rw-r--r--src/history.c12
-rw-r--r--src/history.h6
-rw-r--r--src/ui/documentwidget.c30
-rw-r--r--src/ui/documentwidget.h2
-rw-r--r--src/ui/sidebarwidget.c1
6 files changed, 15 insertions, 39 deletions
diff --git a/src/app.c b/src/app.c
index 2590da0d..eea3689f 100644
--- a/src/app.c
+++ b/src/app.c
@@ -2780,8 +2780,7 @@ iBool handleCommand_App(const char *cmd) {
2780 urlEncodePath_String(url); 2780 urlEncodePath_String(url);
2781 } 2781 }
2782 setUrlFlags_DocumentWidget(doc, url, 2782 setUrlFlags_DocumentWidget(doc, url,
2783 (isHistory ? useCachedContentIfAvailable_DocumentWidgetSetUrlFlag : 0) | 2783 isHistory ? useCachedContentIfAvailable_DocumentWidgetSetUrlFlag : 0);
2784 (fromSidebar ? openedFromSidebar_DocumentWidgetSetUrlFlag : 0));
2785 /* Optionally, jump to a text in the document. This will only work if the document 2784 /* Optionally, jump to a text in the document. This will only work if the document
2786 is already available, e.g., it's from "about:" or restored from cache. */ 2785 is already available, e.g., it's from "about:" or restored from cache. */
2787 const iRangecc gotoHeading = range_Command(cmd, "gotoheading"); 2786 const iRangecc gotoHeading = range_Command(cmd, "gotoheading");
diff --git a/src/history.c b/src/history.c
index 91416020..837b38cb 100644
--- a/src/history.c
+++ b/src/history.c
@@ -37,7 +37,7 @@ void init_RecentUrl(iRecentUrl *d) {
37 d->normScrollY = 0; 37 d->normScrollY = 0;
38 d->cachedResponse = NULL; 38 d->cachedResponse = NULL;
39 d->cachedDoc = NULL; 39 d->cachedDoc = NULL;
40 d->flags.openedFromSidebar = iFalse; 40 d->flags = 0;
41} 41}
42 42
43void deinit_RecentUrl(iRecentUrl *d) { 43void deinit_RecentUrl(iRecentUrl *d) {
@@ -181,7 +181,7 @@ void serialize_History(const iHistory *d, iStream *outs) {
181 const iRecentUrl *item = i.value; 181 const iRecentUrl *item = i.value;
182 serialize_String(&item->url, outs); 182 serialize_String(&item->url, outs);
183 write32_Stream(outs, item->normScrollY * 1.0e6f); 183 write32_Stream(outs, item->normScrollY * 1.0e6f);
184 writeU16_Stream(outs, item->flags.openedFromSidebar ? iBit(1) : 0); 184 writeU16_Stream(outs, item->flags);
185 if (item->cachedResponse) { 185 if (item->cachedResponse) {
186 write8_Stream(outs, 1); 186 write8_Stream(outs, 1);
187 serialize_GmResponse(item->cachedResponse, outs); 187 serialize_GmResponse(item->cachedResponse, outs);
@@ -205,10 +205,7 @@ void deserialize_History(iHistory *d, iStream *ins) {
205 set_String(&item.url, canonicalUrl_String(&item.url)); 205 set_String(&item.url, canonicalUrl_String(&item.url));
206 item.normScrollY = (float) read32_Stream(ins) / 1.0e6f; 206 item.normScrollY = (float) read32_Stream(ins) / 1.0e6f;
207 if (version_Stream(ins) >= addedRecentUrlFlags_FileVersion) { 207 if (version_Stream(ins) >= addedRecentUrlFlags_FileVersion) {
208 uint16_t flags = readU16_Stream(ins); 208 item.flags = readU16_Stream(ins);
209 if (flags & iBit(1)) {
210 item.flags.openedFromSidebar = iTrue;
211 }
212 } 209 }
213 if (read8_Stream(ins)) { 210 if (read8_Stream(ins)) {
214 item.cachedResponse = new_GmResponse(); 211 item.cachedResponse = new_GmResponse();
@@ -409,7 +406,7 @@ void setCachedResponse_History(iHistory *d, const iGmResponse *response) {
409 unlock_Mutex(d->mtx); 406 unlock_Mutex(d->mtx);
410} 407}
411 408
412void setCachedDocument_History(iHistory *d, iGmDocument *doc, iBool openedFromSidebar) { 409void setCachedDocument_History(iHistory *d, iGmDocument *doc) {
413 lock_Mutex(d->mtx); 410 lock_Mutex(d->mtx);
414 iRecentUrl *item = mostRecentUrl_History(d); 411 iRecentUrl *item = mostRecentUrl_History(d);
415 iAssert(size_GmDocument(doc).x > 0); 412 iAssert(size_GmDocument(doc).x > 0);
@@ -421,7 +418,6 @@ void setCachedDocument_History(iHistory *d, iGmDocument *doc, iBool openedFromSi
421 cstr_String(url_GmDocument(doc))); 418 cstr_String(url_GmDocument(doc)));
422 } 419 }
423#endif 420#endif
424 item->flags.openedFromSidebar = openedFromSidebar;
425 if (item->cachedDoc != doc) { 421 if (item->cachedDoc != doc) {
426 iRelease(item->cachedDoc); 422 iRelease(item->cachedDoc);
427 item->cachedDoc = ref_Object(doc); 423 item->cachedDoc = ref_Object(doc);
diff --git a/src/history.h b/src/history.h
index bfb88cf4..383c132b 100644
--- a/src/history.h
+++ b/src/history.h
@@ -39,9 +39,7 @@ struct Impl_RecentUrl {
39 float normScrollY; /* normalized to document height */ 39 float normScrollY; /* normalized to document height */
40 iGmResponse *cachedResponse; /* kept in memory for quicker back navigation */ 40 iGmResponse *cachedResponse; /* kept in memory for quicker back navigation */
41 iGmDocument *cachedDoc; /* cached copy of the presentation: layout and media (not serialized) */ 41 iGmDocument *cachedDoc; /* cached copy of the presentation: layout and media (not serialized) */
42 struct { 42 uint16_t flags;
43 uint8_t openedFromSidebar : 1;
44 } flags;
45}; 43};
46 44
47iDeclareType(MemInfo) 45iDeclareType(MemInfo)
@@ -65,7 +63,7 @@ void clear_History (iHistory *);
65void add_History (iHistory *, const iString *url); 63void add_History (iHistory *, const iString *url);
66void replace_History (iHistory *, const iString *url); 64void replace_History (iHistory *, const iString *url);
67void setCachedResponse_History (iHistory *, const iGmResponse *response); 65void setCachedResponse_History (iHistory *, const iGmResponse *response);
68void setCachedDocument_History (iHistory *, iGmDocument *doc, iBool openedFromSidebar); 66void setCachedDocument_History (iHistory *, iGmDocument *doc);
69iBool goBack_History (iHistory *); 67iBool goBack_History (iHistory *);
70iBool goForward_History (iHistory *); 68iBool goForward_History (iHistory *);
71iRecentUrl *precedingLocked_History (iHistory *); /* requires manual lock/unlock! */ 69iRecentUrl *precedingLocked_History (iHistory *); /* requires manual lock/unlock! */
diff --git a/src/ui/documentwidget.c b/src/ui/documentwidget.c
index 4af3dd72..3bd9f059 100644
--- a/src/ui/documentwidget.c
+++ b/src/ui/documentwidget.c
@@ -220,13 +220,12 @@ enum iDocumentWidgetFlag {
220 movingSelectMarkEnd_DocumentWidgetFlag = iBit(11), 220 movingSelectMarkEnd_DocumentWidgetFlag = iBit(11),
221 otherRootByDefault_DocumentWidgetFlag = iBit(12), /* links open to other root by default */ 221 otherRootByDefault_DocumentWidgetFlag = iBit(12), /* links open to other root by default */
222 urlChanged_DocumentWidgetFlag = iBit(13), 222 urlChanged_DocumentWidgetFlag = iBit(13),
223 openedFromSidebar_DocumentWidgetFlag = iBit(14), 223 drawDownloadCounter_DocumentWidgetFlag = iBit(14),
224 drawDownloadCounter_DocumentWidgetFlag = iBit(15), 224 fromCache_DocumentWidgetFlag = iBit(15), /* don't write anything to cache */
225 fromCache_DocumentWidgetFlag = iBit(16), /* don't write anything to cache */ 225 animationPlaceholder_DocumentWidgetFlag = iBit(16), /* avoid slow operations */
226 animationPlaceholder_DocumentWidgetFlag = iBit(17), /* avoid slow operations */ 226 invalidationPending_DocumentWidgetFlag = iBit(17), /* invalidate as soon as convenient */
227 invalidationPending_DocumentWidgetFlag = iBit(18), /* invalidate as soon as convenient */ 227 leftWheelSwipe_DocumentWidgetFlag = iBit(18), /* swipe state flags are used on desktop */
228 leftWheelSwipe_DocumentWidgetFlag = iBit(19), /* swipe state flags are used on desktop */ 228 rightWheelSwipe_DocumentWidgetFlag = iBit(19),
229 rightWheelSwipe_DocumentWidgetFlag = iBit(20),
230 eitherWheelSwipe_DocumentWidgetFlag = leftWheelSwipe_DocumentWidgetFlag | 229 eitherWheelSwipe_DocumentWidgetFlag = leftWheelSwipe_DocumentWidgetFlag |
231 rightWheelSwipe_DocumentWidgetFlag, 230 rightWheelSwipe_DocumentWidgetFlag,
232}; 231};
@@ -2144,9 +2143,7 @@ static void documentWasChanged_DocumentWidget_(iDocumentWidget *d) {
2144 } 2143 }
2145 showOrHidePinningIndicator_DocumentWidget_(d); 2144 showOrHidePinningIndicator_DocumentWidget_(d);
2146 if (~d->flags & fromCache_DocumentWidgetFlag) { 2145 if (~d->flags & fromCache_DocumentWidgetFlag) {
2147 setCachedDocument_History(d->mod.history, 2146 setCachedDocument_History(d->mod.history, d->view.doc /* keeps a ref */);
2148 d->view.doc, /* keeps a ref */
2149 (d->flags & openedFromSidebar_DocumentWidgetFlag) != 0);
2150 } 2147 }
2151} 2148}
2152 2149
@@ -2905,14 +2902,11 @@ static void updateFromCachedResponse_DocumentWidget_(iDocumentWidget *d, float n
2905static iBool updateFromHistory_DocumentWidget_(iDocumentWidget *d) { 2902static iBool updateFromHistory_DocumentWidget_(iDocumentWidget *d) {
2906 const iRecentUrl *recent = constMostRecentUrl_History(d->mod.history); 2903 const iRecentUrl *recent = constMostRecentUrl_History(d->mod.history);
2907 if (recent && recent->cachedResponse && equalCase_String(&recent->url, d->mod.url)) { 2904 if (recent && recent->cachedResponse && equalCase_String(&recent->url, d->mod.url)) {
2908 iChangeFlags(d->flags,
2909 openedFromSidebar_DocumentWidgetFlag,
2910 recent->flags.openedFromSidebar);
2911 updateFromCachedResponse_DocumentWidget_( 2905 updateFromCachedResponse_DocumentWidget_(
2912 d, recent->normScrollY, recent->cachedResponse, recent->cachedDoc); 2906 d, recent->normScrollY, recent->cachedResponse, recent->cachedDoc);
2913 if (!recent->cachedDoc) { 2907 if (!recent->cachedDoc) {
2914 /* We have a cached copy now. */ 2908 /* We have a cached copy now. */
2915 setCachedDocument_History(d->mod.history, d->view.doc, iFalse); 2909 setCachedDocument_History(d->mod.history, d->view.doc);
2916 } 2910 }
2917 return iTrue; 2911 return iTrue;
2918 } 2912 }
@@ -5617,8 +5611,6 @@ void deserializeState_DocumentWidget(iDocumentWidget *d, iStream *ins) {
5617} 5611}
5618 5612
5619void setUrlFlags_DocumentWidget(iDocumentWidget *d, const iString *url, int setUrlFlags) { 5613void setUrlFlags_DocumentWidget(iDocumentWidget *d, const iString *url, int setUrlFlags) {
5620 iChangeFlags(d->flags, openedFromSidebar_DocumentWidgetFlag,
5621 (setUrlFlags & openedFromSidebar_DocumentWidgetSetUrlFlag) != 0);
5622 const iBool allowCache = (setUrlFlags & useCachedContentIfAvailable_DocumentWidgetSetUrlFlag) != 0; 5614 const iBool allowCache = (setUrlFlags & useCachedContentIfAvailable_DocumentWidgetSetUrlFlag) != 0;
5623 setLinkNumberMode_DocumentWidget_(d, iFalse); 5615 setLinkNumberMode_DocumentWidget_(d, iFalse);
5624 setUrl_DocumentWidget_(d, urlFragmentStripped_String(url)); 5616 setUrl_DocumentWidget_(d, urlFragmentStripped_String(url));
@@ -5631,7 +5623,6 @@ void setUrlFlags_DocumentWidget(iDocumentWidget *d, const iString *url, int setU
5631 5623
5632void setUrlAndSource_DocumentWidget(iDocumentWidget *d, const iString *url, const iString *mime, 5624void setUrlAndSource_DocumentWidget(iDocumentWidget *d, const iString *url, const iString *mime,
5633 const iBlock *source) { 5625 const iBlock *source) {
5634 d->flags &= ~openedFromSidebar_DocumentWidgetFlag;
5635 setLinkNumberMode_DocumentWidget_(d, iFalse); 5626 setLinkNumberMode_DocumentWidget_(d, iFalse);
5636 setUrl_DocumentWidget_(d, url); 5627 setUrl_DocumentWidget_(d, url);
5637 parseUser_DocumentWidget_(d); 5628 parseUser_DocumentWidget_(d);
@@ -5673,11 +5664,6 @@ void setRedirectCount_DocumentWidget(iDocumentWidget *d, int count) {
5673 d->redirectCount = count; 5664 d->redirectCount = count;
5674} 5665}
5675 5666
5676void setOpenedFromSidebar_DocumentWidget(iDocumentWidget *d, iBool fromSidebar) {
5677 iChangeFlags(d->flags, openedFromSidebar_DocumentWidgetFlag, fromSidebar);
5678// setCachedDocument_History(d->mod.history, d->doc, fromSidebar);
5679}
5680
5681iBool isRequestOngoing_DocumentWidget(const iDocumentWidget *d) { 5667iBool isRequestOngoing_DocumentWidget(const iDocumentWidget *d) {
5682 return d->request != NULL; 5668 return d->request != NULL;
5683} 5669}
diff --git a/src/ui/documentwidget.h b/src/ui/documentwidget.h
index 1405f19d..1bee8351 100644
--- a/src/ui/documentwidget.h
+++ b/src/ui/documentwidget.h
@@ -50,7 +50,6 @@ int documentWidth_DocumentWidget (const iDocumentWidget *);
50 50
51enum iDocumentWidgetSetUrlFlags { 51enum iDocumentWidgetSetUrlFlags {
52 useCachedContentIfAvailable_DocumentWidgetSetUrlFlag = iBit(1), 52 useCachedContentIfAvailable_DocumentWidgetSetUrlFlag = iBit(1),
53 openedFromSidebar_DocumentWidgetSetUrlFlag = iBit(2),
54}; 53};
55 54
56void setOrigin_DocumentWidget (iDocumentWidget *, const iDocumentWidget *other); 55void setOrigin_DocumentWidget (iDocumentWidget *, const iDocumentWidget *other);
@@ -60,7 +59,6 @@ void setUrlAndSource_DocumentWidget (iDocumentWidget *, const iString *url,
60void setInitialScroll_DocumentWidget (iDocumentWidget *, float normScrollY); /* set after content received */ 59void setInitialScroll_DocumentWidget (iDocumentWidget *, float normScrollY); /* set after content received */
61void setRedirectCount_DocumentWidget (iDocumentWidget *, int count); 60void setRedirectCount_DocumentWidget (iDocumentWidget *, int count);
62void setSource_DocumentWidget (iDocumentWidget *, const iString *sourceText); 61void setSource_DocumentWidget (iDocumentWidget *, const iString *sourceText);
63void setOpenedFromSidebar_DocumentWidget(iDocumentWidget *, iBool fromSidebar);
64 62
65void takeRequest_DocumentWidget (iDocumentWidget *, iGmRequest *finishedRequest); /* ownership given */ 63void takeRequest_DocumentWidget (iDocumentWidget *, iGmRequest *finishedRequest); /* ownership given */
66 64
diff --git a/src/ui/sidebarwidget.c b/src/ui/sidebarwidget.c
index 4b4968a3..fe8ec939 100644
--- a/src/ui/sidebarwidget.c
+++ b/src/ui/sidebarwidget.c
@@ -965,7 +965,6 @@ static void itemClicked_SidebarWidget_(iSidebarWidget *d, iSidebarItem *item, si
965 const iGmHeading *head = constAt_Array(headings_GmDocument(doc), item->id); 965 const iGmHeading *head = constAt_Array(headings_GmDocument(doc), item->id);
966 postCommandf_App("document.goto loc:%p", head->text.start); 966 postCommandf_App("document.goto loc:%p", head->text.start);
967 dismissPortraitPhoneSidebars_Root(as_Widget(d)->root); 967 dismissPortraitPhoneSidebars_Root(as_Widget(d)->root);
968 setOpenedFromSidebar_DocumentWidget(document_App(), iTrue);
969 } 968 }
970 break; 969 break;
971 } 970 }