about summary refs log tree commit diff stats
path: root/src/server
Commit message (Collapse)AuthorAgeFilesLines
* Move SIGCHLD ignore call to forkserverbptato2024-03-171-0/+1
| | | | seems like it confuses popen()
* forkserver: set process titles for processesbptato2024-03-171-0/+4
| | | | | this is unfortunately truncated on Linux, but I don't care enough to hack around this
* io: add BuferedWriterbptato2024-03-162-41/+53
| | | | | | | | | | Unsurprisingly enough, calling `write` a million times is never going to be very fast. BufferedWriter basically does the same thing as serialize.swrite did, but queues up writes in batches before sending them. TODO: give sread a similar treatment
* Clean up BufferConfigbptato2024-03-151-0/+9
| | | | | | | | It was defined in the wrong module, and unnecessarily included LoaderClientConfig. Also, referrerPolicy was not being propagated to loader clients because it was (incorrectly) in BufferConfig instead of LoaderClientConfig.
* Move around some modulesbptato2024-03-142-3/+3
| | | | | | | | * extern -> gone, runproc absorbed by pager, others moved into io/ * display -> local/ (where else would we display?) * xhr -> html/ * move out WindowAttributes from term, so we don't depend on local from server
* rudimentary support for <video>, <audio>bptato2024-03-131-7/+22
| | | | | we just treat them as img tags. lazy, but works suprisingly well -- so long as the server sends us a Content-Type, anyway.
* loader: rework process modelbptato2024-03-112-282/+145
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Originally we had several loader processes so that the loader did not need asynchronity for loading several buffers at once. Since then, the scope of what loader does has been reduced significantly, and with that loader has become mostly asynchronous. This patch finishes the above work as follows: * We only fork a single loader process for the browser. It is a waste of resources to do otherwise, and would have made future work on a download manager very difficult. * loader becomes (almost) fully async. Now the only sync part is a) processing commands and b) waiting for clients to consume responses. b) is a bit more problematic than a), but should not cause problems unless some other horrible bug exists in a client. (TODO: make it fully async.) This gives us a noticable improvement in CSS loading speed, since all resources can now be queried at once (even before the previous ones are connected). * Buffers now only get processes when the *connection* is finished. So headers, status code, etc. are handled by the client, and the buffer is forked when the loader starts streaming the response body. As a result, mailcap entries can simply dup2 the first UNIX domain socket connection as their stdin. This allows us to remove the ugly (and slow) `canredir' hack, which required us to send file handles on a tour accross the entire codebase. * The "cache" has been reworked somewhat: - Since canredir is gone, buffer-level requests usually start in a suspended state, and are explicitly resumed only after the client could decide whether it wants to cache the response. - Instead of a flag on Request and the URL as the cache key, we now use a global counter and the special `cache:' scheme. * misc fixes: referer_from is now actually respected by buffers (not just the pager), load info display should work slightly better, etc.
* buffer: fix bug of eating chars before invalid UTF-8bptato2024-03-051-2/+2
| | | | | | | using this API is suffering (`n' is the last *valid* character ever since the validator API got fixed, so it must be included in the slice.)
* strwidth, renderdocument: small refactoringbptato2024-03-031-1/+1
| | | | | | * put attrs pointer in state * simplify width() * use unsigned int as ptint to avoid UB
* buffer: improve/fix onload return valuesbptato2024-03-031-6/+12
| | | | | | | | | Only report when bytesRead has changed, otherwise we get unnecessary load requests. (This means -2 return value no longer exists; it did not work correctly anyway.) Also, fix the race condition that broke onload returns when onload happened before client requested load.
* buffer: do not incrementally display in headless modebptato2024-03-021-3/+4
|
* buffer, client: fix deadlock with send() callsbptato2024-02-291-13/+20
| | | | | | | | | | This is an ancient bug, but it got much easier to trigger with mouse scrolling support so it's time to fix it. (The bug itself was that since both the client and buffer ends of the controlling stream are blocking, they could get stuck when both were trying to send() data to the other end but the buffer was full. So now we set the client end to non-blocking.)
* buffer: add image viewer supportbptato2024-02-271-22/+39
|
* misc refactoringsbptato2024-02-271-19/+18
| | | | | | * rename buffer enums * fix isAscii for char 0x80 * remove dead code from URL
* buffer: reset prevStyled in switchCharset, reshapebptato2024-02-271-3/+5
| | | | | | | | reshape must do a render from zero, as it's a last resort for users to fixup the page on a rendering bug. switchCharset must reset prevStyled for obvious reasons (it refers to a dead document).
* buffer: clean up onload, fix console updatebptato2024-02-261-17/+11
| | | | | | | | | | | | * reduce onload result size to a single int * clean up mess that was the container onload handler This fixes automatic refresh in console. Before, the client would only request a screen update after receiving the number of bytes read, but before the screen was actually reshaped (which obviously resulted in a race condition). Now, "I've reshaped the document" is a separate response (and is the only occasion where the screen is updated before the final render).
* term: improve pixels-per-column/line detectionbptato2024-02-252-2/+2
| | | | | | | | | Some terminal emulators (AKA vte) refuse to set ws_xpixel and ws_ypixel in the TIOCGWINSZ ioctl, so we now query for CSI 14 t as well. (Also CSI 18 t for good measure, just in case we can't ioctl for some reason.) Also added some fallback (optionally forced) config values for width, height, ppc, and ppl. (This is especially useful in dump mode.)
* buffer: remove incorrect assertionsbptato2024-02-251-3/+0
| | | | | `confidence' becomes ccCertain when PRES_STOP is returned, so asserting the opposite is incorrect (and was resulting in crashes).
* buffer: fix rewind with mailcap entriesbptato2024-02-251-5/+11
| | | | | | | | Cache mailcap entry output too, then delete it when the buffer can no longer read from it. (Maybe it would be useful to instead preserve it and allow viewSource for HTML output too? Hmm.)
* Separate ANSI text decoding from main binarybptato2024-02-251-77/+70
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Handling text/plain as ANSI colored text was problematic for two reasons: * You couldn't actually look at the real source of HTML pages or text files that used ANSI colors in the source. In general, I only want ANSI colors when piping something into my pager, not when viewing any random file. * More importantly, it introduced a separate rendering mode for plaintext documents, which resulted in the problem that only some buffers had DOMs. This made it impossible to add functionality that would operate on the buffer's DOM, to e.g. implement w3m's MARK_URL. Also, it locked us into the horribly inefficient line-based rendering model of entire documents. Now we solve the problem in two separate parts: * text/x-ansi is used automatically for documents received through stdin. A text/x-ansi handler ansi2html converts ANSI formatting to HTML. text/x-ansi is also used for .ans, .asc file extensions. * text/plain is a separate input mode in buffer, which places all text in a single <plaintext> tag. Crucially, this does not invoke the HTML parser; that would eat NUL characters, which we should avoid. One blind spot still remains: copiousoutput used to display ANSI colors, and now it doesn't. To solve this, users can put the x-ansioutput extension field to their mailcap entries, which behaves like x-htmloutput except it first pipes the output into ansi2html.
* buffer: improve cancel, use _exit, misc cleanupsbptato2024-02-231-44/+53
| | | | | | * cancel resources on cancel() call * call _exit in signal handler (also in loader) * misc cleanups
* buffer: remove BufferSourcebptato2024-02-222-61/+65
| | | | | | | | | | Aside from being a wrapper of Request, it was just storing the -I charset, except even that didn't actually work. Whoops. This fixes -I effectively not doing anything; now it's a forced override that even disables BOM sniffing. (If the user wants to decode a file using a certain encoding, it seems wise to assume that they really meant it.)
* buffer: clean up contentTypebptato2024-02-221-18/+4
| | | | | | | | | | This fixes a bug where setContentType would call setHTML twice, which messed up charsets and probably a couple more things. As a bonus, it allows us to pass around the content type less. In fact, buffer does not have to know its exact content type, just whether it is in HTML mode or not. So that's all we tell it now; only container still keeps track of the content type (as it should).
* Replace Chakasu with Chagashibptato2024-02-221-55/+153
| | | | | | The API is horrid :( but at least it copies less. TODO: think of a better API.
* buffer: fix broken jump-to-anchorbptato2024-02-181-1/+1
| | | | | source.request.url is not used after buffer initialization (because it may be replaced later), so we must set buffer.url instead.
* layout: use html/body bgcolor as canvas bgcolorbptato2024-02-171-17/+11
| | | | | | This is required by the standard. (Without this, lots of websites have incorrect background colors, because they set the body height to 100% of the viewport.)
* Various refactorings & fixesbptato2024-02-142-29/+23
| | | | | | | | * disallow Stream interface usage on non-blocking PosixStreams * do not read estream of forkserver byte-by-byte (it's slow) * do not call writeData with a zero len in formdata * do not quote numbers in mailcap quoteFile * remove some unused stuff
* buffer: improve style invalidationbptato2024-02-141-5/+5
|
* buffer: fix regression on htmloutput document baseURLbptato2024-02-141-3/+2
| | | | | readFromFd replacing the base URL of the buffer turns out to be a very bad idea.
* buffer: skip rewind after the first readbptato2024-02-131-7/+17
| | | | | Speeds up processing of pretty much all documents, because we rarely need to switch the charset after having downloaded the first chunk.
* loader: fix delOutput bug, remove ErrorWouldBlockbptato2024-02-131-4/+4
|
* loader: fixes & improvementsbptato2024-02-131-21/+18
| | | | | | | | * factor out pushBuffer to make loadFromCache async * fix incorrect cache path * replace rewind with loadFromCache (it does the same thing except actually works) * remove rewindImpl callback, rewind in buffer instead
* buffer: more form fixesbptato2024-02-131-11/+31
|
* buffer: fix wrong click behavior with JSbptato2024-02-131-1/+1
| | | | | do_reshape could move the target element, and thus call click on the wrong clickable.
* buffer: form fixesbptato2024-02-121-16/+10
| | | | | * show submission URL on hover for all form-associated elements * skip non-checked checkbox/radio inputs
* buffersource: remove location fieldbptato2024-02-121-3/+2
|
* Add pager.externFilterSourcebptato2024-02-121-4/+5
| | | | useful for filtering stuff through commands like rdrview
* Remove CLONE BufferSource; cache document sources in tmpdirbptato2024-02-122-131/+140
| | | | | | | | | | | | | | | | | | | | | | | At last all BufferSources are unified. To achieve the same effect as the previous CLONE source type, we now use the "fromcache" flag in Request. This *forces* the document to be streamed from the disk; if the file no longer exists for some reason, an error is returned (i.e. the document is not re-downloaded). For a document to be cached, it has to be the main document of the buffer (i.e. no additional resources requested with fetch()), and also not an x-htmloutput HTML file (for those, the original source is saved). The result is that toggleSource now always returns the actual source for e.g. markdown files, not the HTML-transformed version. Also, it is now possible to view the source of a document that is still being downloaded. buffer.sstream has almost been eliminated; it still exists, but only as a pseudo-buffer to interface with EncoderStream and DecoderStream. It no longer holds the entire source of a buffer at any point, and is cleared as soon as the buffer is completely loaded.
* Get rid of LOAD_PIPE BufferSourcebptato2024-02-112-33/+17
| | | | | Instead, use a stream: scheme and associate hostnames with file descriptors directly from the pager.
* loader: fix teebptato2024-02-101-4/+5
| | | | | | | | | | | | My eyes are bleeding, but at least there is a chance that this does what I wanted. The previous tee implementation mixed buffer and loader fds, so it was fundamentally broken. Also, it used MultiStream which makes asynchronous streaming impossible. This time we use a flat array of output handles and link to them any buffers not written to the target yet.
* buffer: fix index defect in updateHoverbptato2024-02-081-1/+2
| | | | | | Caused by a race condition when updateHover is executed after buffer.lines.len changed in buffer but before the change has been reported to container.
* buffer: use `of' instead of tagTypebptato2024-02-081-1/+1
|
* buffer: load external resources when they are attachedbptato2024-02-081-81/+6
| | | | | We no longer have to wait for the entire document to be loaded to start loading CSS.
* dom: enumize attribute namesbptato2024-02-081-8/+9
|
* dom: reduce tagType usebptato2024-02-081-8/+7
| | | | | tagType is now a function call, but usually it's enough to just test for the object type.
* Incremental renderingbptato2024-02-071-55/+69
| | | | | | | | | | | | Yay! Admittedly, it is not very useful in its current form, except maybe on very slow networks. The problem is that renderDocument is *slow*, so we only run it when onload fails to consume all bytes from the network in a single pass. Even then, we are guaranteed to get a FOUC, since CSS is only downloaded in finishLoad(). Well, I think it's cool, anyway.
* Update chamebptato2024-02-071-26/+52
| | | | | | | | * Update chame to the latest version * Get rid of nodeType usage * Add atoms * Re-implement DOM attributes * document.write
* forkserver: clean upbptato2024-01-291-7/+17
| | | | | Move forkBuffer into forkserver (why was it in container anyway), remove unused mainproc variable, etc.
* rendertext: add support for backspace overstrike, misc fixesbptato2024-01-231-1/+1
| | | | | * parse manpage output styled ugly backspace overstrike formatting * fix broken charset detection for large files
* Fix form action when submitter has a "form" attrbptato2024-01-191-3/+4
| | | | | | | * Unify form variable for all form-associated elements * Fix broken form association logic in resetFormOwner * Use form action for all form-associated submitters * Remove unused getElementsByTag + de-extern some functions