about summary refs log tree commit diff stats
path: root/src/html
Commit message (Collapse)AuthorAgeFilesLines
* stylednode: remove `text' fieldbptato2024-05-281-1/+1
| | | | This avoids some unnecessary string copying.
* stylednode: move invalidation data to DOMbptato2024-05-271-0/+7
| | | | this way, we do not refer to nodes of previous cascade passes
* html: improve Request, derive Client from Windowbptato2024-05-205-57/+103
| | | | | | | * make Client an instance of Window (for less special casing) * misc work on Request & fetch * improve origin comparison (opaque origins of same URLs are now considered the same)
* css/values -> css/cssvaluesbptato2024-05-161-3/+3
| | | | for consistency
* js: allow var instead of ptrbptato2024-05-122-53/+53
|
* buffer: fix multipart formsbptato2024-05-113-51/+40
| | | | | | | | | * fix enctype not getting picked up * fix form data constructor requiring open() syscall (which gets blocked by our seccomp filter) * add closing boundary to multipart end * pass fds instead of path names through WebFile/Blob and send those through bufwriter/bufreader
* dom: simplify ButtonTypebptato2024-05-082-11/+7
|
* js: fix compileModulebptato2024-05-081-1/+1
|
* js: refactorbptato2024-05-084-7/+12
| | | | | | | * prefix to-be-separated modules with js * remove dynstreams dependency * untangle from EmptyPromise * move typeptr into tojs
* dom: fix area relList elementbptato2024-05-071-1/+1
|
* Use isSome instead of isOkbptato2024-05-052-12/+12
| | | | no point in having identical overloads
* js: fix various leaks etc.bptato2024-05-033-26/+34
| | | | | | | | | | | | | | | | | | | | | | | | | | Previously we didn't actually free the main JS runtime, probably because you can't do this without first waiting for JS to unwind the stack. (This has the unfortunate effect that code now *can* run after quit(). TODO: find a fix for this.) This isn't a huge problem per se, we only have one of these and the OS can clean it up. However, it also disabled the JS_FreeRuntime leak check, which resulted in sieve-like behavior (manual refcounting is a pain). So now we choose the other tradeoff: quit no longer runs exitnow, but it waits for the event loop to run to the end and only then exits the browser. Then, before exit we free the JS context & runtime, and also all JS values allocated by config. Fixes: * fix `ad' flag not being set for just one siteconf/omnirule * fix various leaks (since leak check is enabled now) * use ptr UncheckedArray[JSValue] for QJS bindings that take an array * allow JSAtom in jsgetprop etc., also disallow int types other than uint32 * do not set a destructor for globals
* cssparser: refactorbptato2024-05-011-10/+7
| | | | | | | | | * factor out skipWhitespace * remove streams dependency (cssparser could never stream without blocking the event loop, so we were just passing a StringStream in all cases, which made the whole streaming pointless.)
* css, dom: simplify ident parsing, canvas fixesbptato2024-05-011-8/+40
| | | | | | | | * add CSSStyleDeclaration setter * move ident maps directly into enums * more complete CSSComputedValue stringifier * turn canvas into a pseudo-image in cascade * set canvas to inline-block
* color: RGBAColor -> ARGBColorbptato2024-04-261-5/+5
|
* Initial image supportbptato2024-04-251-1/+1
| | | | | | | | | | | | | | | | | * png: add missing filters, various decoder fixes * term: fix kitty response interpretation, add support for kitty image detection * buffer, pager: initial image display support Emphasis on "initial"; it only "works" with kitty output and PNG input. Also, it's excruciatingly slow, and repaints images way too often. Left undocumented intentionally it for now, until it actually becomes useful. In the meantime, adventurous users can find out themselves why: [[siteconf]] url = "https://.*" images = true
* dom: remove unnecessary/unused propertiesbptato2024-04-222-11/+8
| | | | | | | | | | * remove some properties we no longer use * convert novalidate into a reflected attribute * fix satClassList * remove reference to root node in every Node The last one is an obvious win when considering how often rootNode is used vs the memory used by a pointless pointer on every single object.
* dom: fix property event handler settersbptato2024-04-212-23/+52
|
* js: fix some incorrect defineProperty usagebptato2024-04-211-2/+2
| | | | It consumes a value, so we must dup those that we pass.
* base64: rewrite btoa toobptato2024-04-211-2/+2
| | | | why not
* dom: sort attributesbptato2024-04-201-21/+30
| | | | needed for isEqualNode to work correctly
* dom: add isSameNode, isEqualNodebptato2024-04-201-0/+54
| | | | TODO: isEqualNode is not quite correct yet, because we don't sort attrs.
* Update code stylebptato2024-04-178-396/+432
| | | | | | * separate params with ; (semicolon) instead of , (colon) * reduce screaming snake case use * wrap long lines
* js: remove automatic function -> closure conversionbptato2024-04-152-7/+5
| | | | | | | | | | | | | | | It's a bad idea for several reasons: * it's inefficient; must allocate an environment for a closure in Nim, even though we already have one in JS * writing macros for automatically creating functions with variadic arguments is suprisingly difficult (see the entire `js/javascript' module) * it never really worked properly, because we never freed the associated function pointer. We hardly used it anyway, so the easiest fix is to get rid of it completely.
* dom: use pointers instead of numerical ids for collectionsbptato2024-04-141-10/+9
| | | | | | | | | | The "id" scheme had obvious problems when multiple documents existed. Originally it was needed because the old hacky integration with QuickJS would occasionally result in objects being moved to other addresses. This has been fixed long ago when I decided to vendor in a fork, so we can just use pointers as ids unique to the entire process.
* dom: add onclick attribute supportbptato2024-04-143-30/+78
| | | | | + better align attribute-based event handler behavior with other browsers
* dom: fix missing attribute reflection for <button>bptato2024-04-111-0/+1
|
* remove dead code, fix openArray casingbptato2024-04-081-1/+1
|
* js: proper distinction between Opt/Optionbptato2024-03-243-16/+17
| | | | | | | | | | | | | | | | until now, this had very strange (and inconsistent) semantics: * err() was used for exception propagation, but also as a null value * Option accepted undefined as a none value, but not null * Opt and Option were used interchangeably (and mostly randomly) Now, Result is always used for error reporting, and err(nil) means JS_EXCEPTION. (Opt is a special case of Result where we don't care about the error type, and is not used in JS.) Option on the other hand means "nullable variation of normally non-nullable type", and translates to JS_NULL. In JS we mainly use it for turning strings nullable.
* io: derive DynStream from RootObj (not Stream)bptato2024-03-242-9/+11
| | | | | | | | This way they are no longer compatible, but we no longer need them to be compatible anyway. (This also forces us to throw out the old serialize module, and use packet writers everywhere.)
* buffer: form fixes & improvementsbptato2024-03-244-41/+58
| | | | | | | * fall back to text for unimplemented input types * add custom prompt to all text-like input types * show min/max for range * fix accidental override of repaint
* catom: at -> satbptato2024-03-213-169/+164
| | | | just for consistency
* buffer: send title during load + other title stuffbptato2024-03-211-2/+2
| | | | | | | * send title to pager as soon as it's available * expose `title' to DOM * rename undocumented `getTitle' js function to `title' getter in Container
* buffer: add markURLbptato2024-03-191-4/+4
| | | | Useful when browsing plaintext files; w3m has it too.
* Move around some modulesbptato2024-03-144-4/+299
| | | | | | | | * 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-0/+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: remove applyHeadersbptato2024-03-121-2/+2
| | | | | | | Better compute the values we need on-demand at the call sites; this way, we can pass through content type attributes to mailcap too. (Also, remove a bug where applyResponse was called twice.)
* loader: rework process modelbptato2024-03-112-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* catom: merge TagType with AttrTypebptato2024-03-043-110/+131
| | | | | it's inefficient and pointless to treat them differently, so just derive a new enum from TagType with a macro
* dom: use relList for stylesheet checksbptato2024-03-042-10/+17
|
* dom: misc fixesbptato2024-03-041-2/+28
| | | | | | | | * parse XHR URL with document base URL * allow setting XHR responseType * add tagName, nodeName * make hasChildNodes a function * fix horribly broken insertNode
* quickjs: reduce diff with upstreambptato2024-03-021-2/+3
| | | | | | * the uint8array thing is probably from txiki.js, but we never used it * upstream now has JS_GetClassID, importing that instead... (so this commit won't build :/)
* env: add window.screenbptato2024-03-022-1/+25
|
* dom: fix canvas element crashbptato2024-03-011-2/+3
|
* dom: fix non-stylesheets being downloaded as stylesheetsbptato2024-02-271-0/+2
|
* 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.)
* Separate ANSI text decoding from main binarybptato2024-02-251-10/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* dom: use AttrType in DOMTokenList supportsbptato2024-02-241-5/+3
|
* dom: check rel attribute for link tags before downloadbptato2024-02-241-1/+1
|
* Allow non-RGB colors in CSSbptato2024-02-241-2/+8
| | | | | | | | | | | The -cha-ansi color type now sets ANSI colors in CSS. Also, color correction etc. has been improved a bit: * don't completely reset output state in processFormat for new colors * defaultColor is now separated from ANSI color type 0 * bright ANSI colors are no longer replaced with bold + dark variant * replaced ANSI color map to match xterm defaults