diff options
Diffstat (limited to 'src/ui/documentwidget.c')
-rw-r--r-- | src/ui/documentwidget.c | 50 |
1 files changed, 38 insertions, 12 deletions
diff --git a/src/ui/documentwidget.c b/src/ui/documentwidget.c index b19958b2..3d2e31b2 100644 --- a/src/ui/documentwidget.c +++ b/src/ui/documentwidget.c | |||
@@ -1333,7 +1333,8 @@ static void drawRun_DrawContext_(void *context, const iGmRun *run) { | |||
1333 | run->text); | 1333 | run->text); |
1334 | } | 1334 | } |
1335 | else { | 1335 | else { |
1336 | if (d->showLinkNumbers && run->linkId && run->flags & decoration_GmRunFlag) { | 1336 | if (d->showLinkNumbers && run->linkId && run->flags & decoration_GmRunFlag && |
1337 | ~run->flags & caption_GmRunFlag) { | ||
1337 | const size_t ord = visibleLinkOrdinal_DocumentView_(d->view, run->linkId); | 1338 | const size_t ord = visibleLinkOrdinal_DocumentView_(d->view, run->linkId); |
1338 | if (ord >= d->view->owner->ordinalBase) { | 1339 | if (ord >= d->view->owner->ordinalBase) { |
1339 | const iChar ordChar = | 1340 | const iChar ordChar = |
@@ -1656,7 +1657,6 @@ static iBool render_DocumentView_(const iDocumentView *d, iDrawContext *ctx, iBo | |||
1656 | ctx->viewPos = init_I2(left_Rect(ctx->docBounds) - left_Rect(bounds), -buf->origin); | 1657 | ctx->viewPos = init_I2(left_Rect(ctx->docBounds) - left_Rect(bounds), -buf->origin); |
1657 | // printf(" buffer %zu: buf vis range %d...%d\n", i, bufVisRange.start, bufVisRange.end); | 1658 | // printf(" buffer %zu: buf vis range %d...%d\n", i, bufVisRange.start, bufVisRange.end); |
1658 | if (!prerenderExtra && !isEmpty_Range(&bufVisRange)) { | 1659 | if (!prerenderExtra && !isEmpty_Range(&bufVisRange)) { |
1659 | didDraw = iTrue; | ||
1660 | if (isEmpty_Rangei(buf->validRange)) { | 1660 | if (isEmpty_Rangei(buf->validRange)) { |
1661 | /* Fill the required currently visible range (vis). */ | 1661 | /* Fill the required currently visible range (vis). */ |
1662 | const iRangei bufVisRange = intersect_Rangei(bufRange, vis); | 1662 | const iRangei bufVisRange = intersect_Rangei(bufRange, vis); |
@@ -1669,26 +1669,46 @@ static iBool render_DocumentView_(const iDocumentView *d, iDrawContext *ctx, iBo | |||
1669 | extend_GmRunRange_(&meta->runsDrawn); | 1669 | extend_GmRunRange_(&meta->runsDrawn); |
1670 | buf->validRange = bufVisRange; | 1670 | buf->validRange = bufVisRange; |
1671 | // printf(" buffer %zu valid %d...%d\n", i, bufRange.start, bufRange.end); | 1671 | // printf(" buffer %zu valid %d...%d\n", i, bufRange.start, bufRange.end); |
1672 | didDraw = iTrue; | ||
1672 | } | 1673 | } |
1673 | } | 1674 | } |
1674 | else { | 1675 | else { |
1675 | /* Progressively fill the required runs. */ | 1676 | /* Progressively fill the required runs. */ |
1676 | if (meta->runsDrawn.start) { | 1677 | if (meta->runsDrawn.start && buf->validRange.start > bufRange.start) { |
1677 | beginTarget_Paint(p, buf->texture); | 1678 | beginTarget_Paint(p, buf->texture); |
1678 | meta->runsDrawn.start = renderProgressive_GmDocument(d->doc, meta->runsDrawn.start, | 1679 | iZap(ctx->runsDrawn); |
1679 | -1, iInvalidSize, | 1680 | const iGmRun *newStart = renderProgressive_GmDocument(d->doc, |
1680 | bufVisRange, | 1681 | meta->runsDrawn.start, |
1681 | drawRun_DrawContext_, | 1682 | -1, |
1682 | ctx); | 1683 | iInvalidSize, |
1683 | buf->validRange.start = bufVisRange.start; | 1684 | bufVisRange, |
1685 | drawRun_DrawContext_, | ||
1686 | ctx); | ||
1687 | if (ctx->runsDrawn.start) { | ||
1688 | /* Something was actually drawn, so update the valid range. */ | ||
1689 | const int newTop = top_Rect(ctx->runsDrawn.start->visBounds); | ||
1690 | if (newTop != buf->validRange.start) { | ||
1691 | didDraw = iTrue; | ||
1692 | // printf("render: valid:%d->%d run:%p->%p\n", | ||
1693 | // buf->validRange.start, newTop, | ||
1694 | // meta->runsDrawn.start, | ||
1695 | // ctx->runsDrawn.start); fflush(stdout); | ||
1696 | buf->validRange.start = newTop; | ||
1697 | } | ||
1698 | meta->runsDrawn.start = newStart; | ||
1699 | } | ||
1684 | } | 1700 | } |
1685 | if (meta->runsDrawn.end) { | 1701 | if (meta->runsDrawn.end) { |
1686 | beginTarget_Paint(p, buf->texture); | 1702 | beginTarget_Paint(p, buf->texture); |
1703 | iZap(ctx->runsDrawn); | ||
1687 | meta->runsDrawn.end = renderProgressive_GmDocument(d->doc, meta->runsDrawn.end, | 1704 | meta->runsDrawn.end = renderProgressive_GmDocument(d->doc, meta->runsDrawn.end, |
1688 | +1, iInvalidSize, | 1705 | +1, iInvalidSize, |
1689 | bufVisRange, | 1706 | bufVisRange, |
1690 | drawRun_DrawContext_, | 1707 | drawRun_DrawContext_, |
1691 | ctx); | 1708 | ctx); |
1709 | if (ctx->runsDrawn.start) { | ||
1710 | didDraw = iTrue; | ||
1711 | } | ||
1692 | buf->validRange.end = bufVisRange.end; | 1712 | buf->validRange.end = bufVisRange.end; |
1693 | } | 1713 | } |
1694 | } | 1714 | } |
@@ -3109,12 +3129,14 @@ static const char *humanReadableStatusCode_(enum iGmStatusCode code) { | |||
3109 | return format_CStr("%d ", code); | 3129 | return format_CStr("%d ", code); |
3110 | } | 3130 | } |
3111 | 3131 | ||
3112 | static void setUrl_DocumentWidget_(iDocumentWidget *d, const iString *url) { | 3132 | static iBool setUrl_DocumentWidget_(iDocumentWidget *d, const iString *url) { |
3113 | url = canonicalUrl_String(url); | 3133 | url = canonicalUrl_String(url); |
3114 | if (!equal_String(d->mod.url, url)) { | 3134 | if (!equal_String(d->mod.url, url)) { |
3115 | d->flags |= urlChanged_DocumentWidgetFlag; | 3135 | d->flags |= urlChanged_DocumentWidgetFlag; |
3116 | set_String(d->mod.url, url); | 3136 | set_String(d->mod.url, url); |
3137 | return iTrue; | ||
3117 | } | 3138 | } |
3139 | return iFalse; | ||
3118 | } | 3140 | } |
3119 | 3141 | ||
3120 | static void checkResponse_DocumentWidget_(iDocumentWidget *d) { | 3142 | static void checkResponse_DocumentWidget_(iDocumentWidget *d) { |
@@ -3139,7 +3161,9 @@ static void checkResponse_DocumentWidget_(iDocumentWidget *d) { | |||
3139 | iMediaRequest *mr = newReused_MediaRequest(d, d->requestLinkId, d->request); | 3161 | iMediaRequest *mr = newReused_MediaRequest(d, d->requestLinkId, d->request); |
3140 | unlockResponse_GmRequest(d->request); | 3162 | unlockResponse_GmRequest(d->request); |
3141 | d->request = NULL; /* ownership moved */ | 3163 | d->request = NULL; /* ownership moved */ |
3142 | postCommand_Widget(d, "document.request.cancelled doc:%p", d); | 3164 | if (!isFinished_GmRequest(mr->req)) { |
3165 | postCommand_Widget(d, "document.request.cancelled doc:%p", d); | ||
3166 | } | ||
3143 | pushBack_ObjectList(d->media, mr); | 3167 | pushBack_ObjectList(d->media, mr); |
3144 | iRelease(mr); | 3168 | iRelease(mr); |
3145 | /* Reset the fetch state, returning to the originating page. */ | 3169 | /* Reset the fetch state, returning to the originating page. */ |
@@ -3147,7 +3171,9 @@ static void checkResponse_DocumentWidget_(iDocumentWidget *d) { | |||
3147 | if (equal_String(&mostRecentUrl_History(d->mod.history)->url, url_GmRequest(mr->req))) { | 3171 | if (equal_String(&mostRecentUrl_History(d->mod.history)->url, url_GmRequest(mr->req))) { |
3148 | undo_History(d->mod.history); | 3172 | undo_History(d->mod.history); |
3149 | } | 3173 | } |
3150 | setUrl_DocumentWidget_(d, url_GmDocument(d->view.doc)); | 3174 | if (setUrl_DocumentWidget_(d, url_GmDocument(d->view.doc))) { |
3175 | postCommand_Widget(d, "!document.changed doc:%p url:%s", d, cstr_String(d->mod.url)); | ||
3176 | } | ||
3151 | updateFetchProgress_DocumentWidget_(d); | 3177 | updateFetchProgress_DocumentWidget_(d); |
3152 | postCommand_Widget(d, "media.updated link:%u request:%p", d->requestLinkId, mr); | 3178 | postCommand_Widget(d, "media.updated link:%u request:%p", d->requestLinkId, mr); |
3153 | if (isFinished_GmRequest(mr->req)) { | 3179 | if (isFinished_GmRequest(mr->req)) { |