about summary refs log tree commit diff stats
path: root/src
Commit message (Collapse)AuthorAgeFilesLines
...
* dom: fix property event handler settersbptato2024-04-212-23/+52
|
* js: fix some incorrect defineProperty usagebptato2024-04-214-7/+7
| | | | It consumes a value, so we must dup those that we pass.
* js: override default toString tag of globalbptato2024-04-211-1/+5
| | | | Some JS modules use this to check if they are running in a browser.
* base64: rewrite btoa toobptato2024-04-212-5/+41
| | | | why not
* base64: rewrite atobbptato2024-04-211-6/+65
| | | | | | | | | Turns out std/base64's `decode' is broken: atob(" ") would panic. So we no longer use that. Basic testing indicates that the new version is closer to the standard- mandated behavior than the old one was. OTOH I assume it's somewhat slower, but that can be improved later if it proves to be a bottleneck.
* layout: slightly refactor layoutInlinebptato2024-04-211-40/+42
|
* layout: flex item margin fixesbptato2024-04-201-25/+34
| | | | Still far from perfect, but it's an improvement.
* layout: fix double padding in flexbptato2024-04-201-2/+4
| | | | | | | | sizes.space regulates content-box width, in which padding is not included, so we must to subtract padding here. (Neither is margin, but margin is applied by outer layout, in this case flex itself, so it's not relevant here. Not to say it isn't broken...)
* dom: sort attributesbptato2024-04-201-21/+30
| | | | needed for isEqualNode to work correctly
* buffer: fix switch from charset decoder to UTF-8 validatorbptato2024-04-201-1/+3
| | | | | The validator is used only if the decoder is nil, so it must be cleared in switchCharset.
* dom: add isSameNode, isEqualNodebptato2024-04-201-0/+54
| | | | TODO: isEqualNode is not quite correct yet, because we don't sort attrs.
* sandbox: allow syscalls for epoll Nim selectorsbptato2024-04-201-0/+4
| | | | | | | | | | | | This fixes setTimeout/setInterval causing crashes. Note: timerfd_gettime is not actually used by Nim right now. However, it seems like a good idea to add it to the set in case a future Nim version needs it, as it does no harm. We still do not allow signalfd, because it would let rogue buffers override our SIGSYS handler. (Not sure if this really matters, but we don't need it for now anyway.)
* layout: fix a list style positioning bugbptato2024-04-201-2/+2
| | | | | | If we are going to move out the child's offset, then we must also tell the child where it starts so it can behave correctly when it encounters exclusions.
* layout: float sizing fixesbptato2024-04-191-8/+21
| | | | | | | | | | | Turns out our shrink-to-fit emulation was inadequate: it assumed all floats are positioned on a separate line, which is the *opposite* of what we want, as that would be the behavior of min-content. Now we instead sum together the width of all floats and the widest non-floating child, and then clamp that to the target fitContent width. This correctly gives us max-content width in the first pass, still without having to actually position the floats.
* http: fix sandbox violation in readFromStdinbptato2024-04-191-0/+2
| | | | | | | | | glibc apparently calls fstat from fread, and we didn't allow it in seccomp. So: * allow fstat in the sandbox; no reason not to, and it seems too big of a footgun to assume we never call fread * use read(2) in http; no need for buffered i/o here
* twtstr: remove pointless checks in parseIntImplbptato2024-04-191-5/+3
|
* url, twtstr: correct number parsingbptato2024-04-185-68/+75
| | | | | | | | | * do not use std's parse*Int; they accept weird stuff that we do not want to accept in any case * fix bug in parseHost where a parseIpv4 failure would result in an empty host * do not use isDigit, isAlphaAscii * improve parse*IntImpl error handling
* sandbox: seccomp support on Linuxbptato2024-04-1810-44/+275
| | | | | | | | | | | | | | | | | We use libseccomp, which is now a semi-mandatory dependency on Linux. (You can still build without it, but only if you pass a scary long flag to make.) For this to work I had to disable getTimezoneOffset, which would otherwise call localtime_r which in turn reads in some files from /usr/share/zoneinfo. To allow this we would have to give unrestricted openat(2) access to buffer processes, which is unacceptable. (Giving websites access to the local timezone is a fingerprinting vector so if this ever gets fixed then it should be an opt-in config setting.) This patch also includes misc fixes to buffer cloning, and fixes the LIBEXECDIR override in the makefile so that it is actually useful.
* layout: accept inline-flex in iflushbptato2024-04-171-1/+1
|
* strwidth: return alpha for underscore in vi wordsbptato2024-04-171-1/+1
|
* Update code stylebptato2024-04-1777-2689/+2821
| | | | | | * separate params with ; (semicolon) instead of , (colon) * reduce screaming snake case use * wrap long lines
* term: save/restore title after "set title"bptato2024-04-161-2/+12
| | | | | | | | | It is quite straightforward, because XTerm has a functionality to do just this. (In fact, it automatically restores the title when I use smcup/rmcup. But when I don't, it will linger until I close the window or change the title again.)
* url: fix flipped comparisonbptato2024-04-161-1/+1
|
* layout: fix list-item positioningbptato2024-04-162-3/+12
| | | | we also have to move the inner box offset to the parent
* url: refactorbptato2024-04-161-186/+187
| | | | | * clean up formatting * more efficient endsInNumber
* js: remove automatic function -> closure conversionbptato2024-04-158-105/+75
| | | | | | | | | | | | | | | 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.
* layout: remove ListItemBox, handle inline-flex correctlybptato2024-04-153-91/+65
| | | | | This allows us to unify BlockBox instantiation and block-level inner layout calls.
* 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-144-53/+112
| | | | | + better align attribute-based event handler behavior with other browsers
* utils: polyfill addr/unsafeAddr distinction in Nim 2+bptato2024-04-141-0/+18
| | | | | | | | | | | | | | | | | | | | | I wish they didn't change this. unsafeAddr may be a confusing name, but it's more powerful than addr. Merging them violates the principle of least power. e.g. say I get n thru a param, and shadow it proc x(n: int) = var n = n + 1 a screen or two later I call mutates_variable_in_c(addr i) then later I no longer need to add 1, so I remove the var line. In Nim 1.6 the compiler refuses to compile, I can instantly find the bug. In 2.0 it does... whatever?? Maybe for an int it "works", for an object it likely doesn't. Certainly not something I'd enjoy debugging.
* layout: height fixesbptato2024-04-121-41/+22
| | | | | | * fix percHeight not being passed down properly * simplify addTableCaption; get rid of hack that turned caption outer height into inner height
* bind_unix, connect_unix: add string.h includebptato2024-04-122-0/+2
| | | | | it's needed for memcpy; it usually compiles without the include, but that's not guaranteed.
* dom: fix missing attribute reflection for <button>bptato2024-04-111-0/+1
|
* renderdocument: do not layout with styledRoot == nilbptato2024-04-111-1/+4
| | | | it can happen when do_reshape is called before any parsing happens.
* twtstr: remove isAscii, simplify onlyWhitespacebptato2024-04-102-12/+3
|
* url: use AsciiDigit, not Digitsbptato2024-04-101-5/+5
|
* twtstr: remove pointless lookup tablesbptato2024-04-101-18/+10
| | | | it's a waste of space; we don't use these *that* much.
* term: do not eat last DA1 valuebptato2024-04-101-3/+9
|
* layout: slightly hacky flex-basis implementationbptato2024-04-091-2/+21
| | | | | | | | it's better than nothing. I suppose. (Two-value flex syntax is encouraged even by the standard, so it gets used a lot, and that sets 0, not flex-basis: auto, so not having flex-basis breaks too many things.)
* Update Chamebptato2024-04-091-1/+1
|
* Remove unnecessary std/math importsbptato2024-04-082-9/+6
|
* remove dead code, fix openArray casingbptato2024-04-083-7/+4
|
* css, layout: flexbox fixesbptato2024-04-062-8/+31
| | | | | | | * do not re-resolve FlexPendingItem sizes; it's pointless and it breaks percentage sizes * fix some bugs in `flex' shorthand parsing * add `flex-flow' shorthand
* layout: clean up resolveSizesbptato2024-04-051-80/+74
|
* Initial flexbox supportbptato2024-04-052-163/+537
| | | | | | | | | Still far from being fully standards-compliant, or even complete, but it seems to work slightly less horribly than having no flexbox support at all on sites that do use it. (Also includes various refactorings in layout to make it possible at all to add flexbox.)
* sandbox: add OpenBSD pledge/unveil supportbptato2024-04-034-8/+39
| | | | | | | | | | | | pledge is a bit more fine-grained than Capsicum's capability mode, so the buffer & http ("network") sandboxes are now split up into two parts. I applied the same hack as in FreeBSD for overriding the buffer selector kqueue, because a) I didn't want to request sysctl promise b) I'm not sure if it would even work and c) if it breaks on OpenBSD, then it's broken on FreeBSD too, so there's a greater chance of discovering the bug.
* loader: constant time key comparisonbptato2024-04-021-1/+13
| | | | | GCC seems to generate something that strongly resembles a constant time comparison, so I guess this should be good enough.
* pager: fix incremental search with empty stringbptato2024-03-301-3/+11
| | | | | | | | | | | | | | This is broken in w3m too, so we take nvi behavior instead. Also, we now consistently complain when the user tries to search for an empty string instead of just occasionally spitting out "invalid regex" alerts. (In w3m, /search^M/^M just jumps to the first search result with ISEARCH. In nvi, it jumps to the second one with both searchincr on and off. w3m only produces the latter behavior with regular search, which is I assume why I made it work this way, but it's still inconsistent for no good reason.)
* pager: fix weird halfPage* behaviorbptato2024-03-301-6/+6
| | | | | | | | | For some reason, halfPageDown decremented height instead of incrementing it, which caused some rather weird behavior where halfPageUp + halfPageDown would put the cursor in a different position than it was before. Also, we must increment *before* dividing to mimic vi behavior properly.
* pager: exclude status line from buffer heightbptato2024-03-302-1/+9
|