Commit graph

14473 commits

Author SHA1 Message Date
AnotherTest
8066a623d9 LibCore: Make `guess_mime_type_based_on_filename()' recognise CSV files 2020-11-24 21:38:13 +01:00
AnotherTest
31523f6c64 Spreadsheet: Add a CSV reader and writer
This is not utilised yet.
2020-11-24 21:38:13 +01:00
Florian Förster
438829a1d5
MenuApplets: Added ability to remove entry from ClipboardHistory (#4143) 2020-11-24 21:37:04 +01:00
Sergey Bugaev
b1fd06eb4c Userland: Add a test for pthread_once() 2020-11-24 21:36:28 +01:00
Sergey Bugaev
d51173e4c4 LibThread: Add API to join a thread 2020-11-24 21:36:28 +01:00
Sergey Bugaev
3ac0c9b9e7 LibPthread: Implement pthread_once()
The implementation uses atomics and futexes (yay!) and is heavily based on the
implementation I did for my learning project named "Let's write synchronization
primitives" [0].

That project, in fact, started when I tried to implement pthread_once() for
Serenity (because it was needed for another project of mine, stay tuned ;) ) and
was not very sure I got every case right. So now, after learning some more about
code patterns around atomics and futexes, I am reasonably sure, and it's time to
contribute the implementation of pthread_once() to Serenity :^)

[0] To be published at https://github.com/bugaevc/lets-write-sync-primitives
2020-11-24 21:36:28 +01:00
Linus Groh
f6f0d3cbae LibJS: Support receiver in ProxyObject::get/put()
If a receiver is given, e.g. via Reflect.get/set(), forward it to the
target object's get()/put() or use it as last argument of the trap
function. The default value is the Proxy object itself.
2020-11-24 21:35:03 +01:00
Andreas Kling
76308c2e1f Kernel: Reduce ByteBuffer thrashing in inode block list generation
Instead of creating and destroying a new ByteBuffer for every block we
process during block list generation, just use stack memory instead.
2020-11-24 21:29:08 +01:00
Tom
68abd1cb29 Kernel: Fix SharedBuffer reference counting on fork
We need to not only add a record for a reference, but we need
to copy the reference count on fork as well, because the code
in the fork assumes that it has the same amount of references,
still.

Also, once all references are dropped when a process is disowned,
delete the shared buffer.

Fixes #4076
2020-11-24 21:26:39 +01:00
Zac
018eff802b
LibGUI: Remove redundant set_title() call in FilePicker (#4153) 2020-11-24 18:41:44 +01:00
Andreas Kling
5f2f31861c Kernel: Use a doubly-linked list for the BlockBasedFS cache
This makes misses in the BlockBasedFS's LRU block cache faster by
storing the cache entries in one of two doubly-linked list.

Dirty and clean cache entries are kept in two separate lists, and
move between them when their state changes. This can probably be
improved upon further.
2020-11-24 16:42:01 +01:00
Andreas Kling
c33d71c5ff AK: Add IntrusiveList::take_last() 2020-11-24 16:37:55 +01:00
Andreas Kling
3e3a72f2a2 Ext2FS: Oops, fix forgotten assignment in Ext2FSInode::resize()
If the inode's block list cache is empty, we forgot to assign the
result of computing the block list. The fact that this worked anyway
makes me wonder when we actually don't have a cache..

Thanks to szyszkienty for spotting this! :^)
2020-11-24 16:16:09 +01:00
Andreas Kling
a6a3c20071 Kernel: Add a fast lookup table to the BlockBasedFS disk cache
Instead of doing a linear scan of the entire cache when doing a lookup,
we now have a nice O(1) HashMap in front of the cache.

The cache miss case can still be improved, this patch really only helps
the cache hit case.

This dramatically improves cached filesystem I/O. :^)
2020-11-24 13:40:54 +01:00
Andreas Kling
20205708b9 Ext2FS: Use cached inode block list in resize() if available
If we have already cached the block list of an Ext2FSInode, we can save
a lot of time by not regenerating it.
2020-11-24 13:40:45 +01:00
Andreas Kling
541579bc04 Kernel: Remove unnecessary SmapDisablers in FileDescription
Since we're using UserOrKernelBuffers, SMAP will be automatically
disabled when we actually access the buffer later on. There's no need
to disable it wholesale across the entire read/write operations.
2020-11-24 11:26:40 +01:00
Zac
1dc480e097 Calculator: Changed 'CE' Button from 'Clear Error' To 'Clear Entry'
The CE button on the windows calculator was used to clear the current
entry rather than the current error. This commit changes the
calculator's CE button such that it now clears the current value being
entered into the keypad and errors are now cleared at the end of every
successful operation.
2020-11-23 18:41:54 +01:00
Simon Danner
751e759be2 UserspaceEmulator: Implement clock_nanosleep 2020-11-23 18:41:42 +01:00
Jakub Berkop
c6bb3d452a
LibGUI: Widget::action_for_key_event() should fail for invalid shortcuts (#4137)
Previously GUI::Actions which were constructed without initializing
m_shortcut could be activated via an invalid GUI::Shortcut.

Steps to reproduce:
It was possible to enable TextEditor's markdown preview by pressing
Ctrl or Alt (Cmd/Ctrl) keys, which should not happen, as this Action
did not specify a shortcut.

This fix should apply to all other cases where actions where declared
without specifying a shortcut.
2020-11-23 18:41:15 +01:00
Sergey Bugaev
e7e179212c HackStudio: Send an open file to language servers
Language servers will now receive an open file instead of just its path. This
means the language servers no longer need to access the filesystem to open the
file themselves.

The C++ language server now has no filesystem access whatsoever (although we
might need to relax this in the future if it learns to complete #include paths),
while the Shell language server can read /etc/passwd (it wants that in order to
get the user's home directory) and browse (but not read!) the whole file system
tree for completing paths.
2020-11-23 18:37:40 +01:00
Sergey Bugaev
098070b767 Kernel: Add unveil('b')
This is a new "browse" permission that lets you open (and subsequently list
contents of) directories underneath the path, but not regular files or any other
types of files.
2020-11-23 18:37:40 +01:00
Sergey Bugaev
23dc3ff0c2 LibIPC: Support sending file descriptors :^)
It is now possible to use the special IPC::File type in message arguments. In
C++, the type is nothing more than a wrapper over a file descriptor. But when
serializing/deserializing IPC::File arguments, LibIPC will use the sendfd/recvfd
kernel APIs instead of sending the integer inline.

This makes it quite convenient to pass files over IPC, and will allow us to
significantly tighten sandboxes in the future :^)

Closes https://github.com/SerenityOS/serenity/issues/3643
2020-11-23 18:37:40 +01:00
Sergey Bugaev
fa2e3e2be4 LibIPC: Prepend each message with its size
This makes it much simpler to determine when we've read a complete message, and
will make it possible to integrate recvfd() in the future commit.
2020-11-23 18:37:40 +01:00
Sergey Bugaev
d62346c0b1 AK: Add Vector::prepend() overload for multiple items
Much like with Vector::append(), you may want to append multiple items in one
go. It's actually more important to do this for prepending, because you don't
want to copy the rest of items further each time.
2020-11-23 18:37:40 +01:00
Tom
97b3035c14 Kernel: Don't resume thread into Running state directly on SIGCONT
We should never resume a thread by directly setting it to Running state.
Instead, if a thread was in Running state when stopped, record the state
as Runnable.

Fixes #4150
2020-11-23 18:33:19 +01:00
Andreas Kling
dfce9051fa ProcFS: Take the "all inodes" lock when generating /proc/inodes
Otherwise the kernel asserts.
2020-11-23 16:19:30 +01:00
Andreas Kling
086522537e Kernel: Don't leak ref on executable inode in sys$execve()
We were leaking a ref on the executed inode in successful calls to
sys$execve(). This meant that once a binary had ever been executed,
it was impossible to remove it from the file system.

The execve system call is particularly finicky since the function
does not return normally on success, so extra care must be taken to
ensure nothing is kept alive by stack variables.

There is a big NOTE comment about this, and yet the bug still got in.
It would be nice to enforce this, but I'm unsure how.
2020-11-23 16:08:42 +01:00
Andreas Kling
bb9c705fc2 Ext2FS: Move some EXT2_DEBUG logging behind EXT2_VERY_DEBUG
This makes the build actually somewhat usable with EXT2_DEBUG. :^)
2020-11-23 16:08:42 +01:00
Andreas Kling
1951dfa46a Kernel: Convert dbg() to dbgln() in Syscall.cpp 2020-11-23 16:08:42 +01:00
Zac
39bb346cef
LibGUI: Set FilePicker window icon based on mode (#4148) 2020-11-23 14:56:44 +01:00
Andreas Kling
df758a5a51 Ext2FS: Clear out the direct block list when an inode is resized to 0
e2fsck was complaining about blocks being allocated in an inode's list
of direct blocks while at the same time being free in the block bitmap.

It was easy to reproduce by creating a file with non-zero length and
then truncating it. This fixes the issue by clearing out the direct
block list when resizing a file to 0.
2020-11-23 14:08:50 +01:00
Andreas Kling
dd43cf2657 AK: Use ALWAYS_INLINE all over NonnullPtrVector
I saw NonnullOwnPtrVector::at() in a profile and that was silly, as we
should definitely be inlining it.
2020-11-23 14:08:50 +01:00
Tom
a89648e159 Kernel: Inherit shared buffers when forking
We need to create a reference for the new PID for each shared buffer
that the process had a reference to. If the process subsequently
get replaced through exec, those references will be dropped again.
But if exec for some reason fails then other code, such as global
destructors could still expect having access to them.

Fixes #4076
2020-11-23 09:39:32 +01:00
Linus Groh
48369194d2 LibJS: Forward receiver value to native property getters/setters
There's no reason why only (user-defined) accessors would have set the
receiver as this value for their getters/setters, this is an oversight.
2020-11-22 19:00:19 +01:00
Linus Groh
c52739ea4b LibJS: Make call_native_property_{g,s}etter() take a NativeProperty&
Passing in a plain Value and expecting it to be a native property is
error prone, let's use a more narrow type and pass a NativeProperty
reference directly.
2020-11-22 19:00:19 +01:00
Luke
773df8826d LibWeb: Add the submit event to HTMLFormElement
Also adds the ability to submit from JavaScript.
2020-11-22 18:20:56 +01:00
Luke
9950270808 LibWeb: Add HTML::EventNames and UIEvents::EventNames 2020-11-22 18:20:56 +01:00
Luke
e68348298f LibWeb: Add a test for the new event dispatcher 2020-11-22 18:20:56 +01:00
Luke
c5e15d9282 LibWeb: Expose ParentNode.{first,last}ElementChild
I needed these to write the event dispatcher test.
2020-11-22 18:20:56 +01:00
Luke
e8b3a65581 LibWeb: Make event dispatching spec-compliant
Specification: https://dom.spec.whatwg.org/#concept-event-dispatch

This also introduces shadow roots due to it being a requirement of
the event dispatcher.

However, it does not introduce the full shadow DOM, that can be
left for future work.

This changes some event dispatches which require certain attributes
to be initialised to a value.
2020-11-22 18:20:56 +01:00
Luke
819f099a8e AK: Add first_matching and last_matching to Vector
first_matching returns the first item in the vector that matches
the given condition.

last_matching returns the last item in the vector that matches
the given condition.
2020-11-22 18:20:56 +01:00
Andreas Kling
94ff04b536 Kernel: Make CLOCK_MONOTONIC respect the system tick frequency
The time returned by sys$clock_gettime() was not aligned with the delay
calculations in sys$clock_nanosleep(). This patch fixes that by taking
the system's ticks_per_second value into account in both functions.

This patch also removes the need for Thread::sleep_until() and uses
Thread::sleep() for both absolute and relative sleeps.

This was causing the nesalizer emulator port to sleep for a negative
amount of time at the end of each frame, making it run way too fast.
2020-11-22 17:20:58 +01:00
Andreas Kling
e07d14f4d9 LibWeb: Fix build with DEBUG_HIGHLIGHT_FOCUSED_FRAME 2020-11-22 16:07:53 +01:00
BenJilks
a27d118085 PixelPaint: Use UndoStack instead of History
This allows to share more code with other undo systems.
2020-11-22 16:07:00 +01:00
BenJilks
7707ebcd63 LibGUI: Fix undo stack
This would undo all commands at once instead of one at a time.
2020-11-22 16:07:00 +01:00
BenJilks
76aeb7cad8 PixelPaint: Applying filters should be an action
This allows you to undo filters
2020-11-22 16:07:00 +01:00
BenJilks
58c30959b1 PixelPaint: Export image as BMP
You can now export your masterpieces as fresh, crisp BMP files.
2020-11-22 16:07:00 +01:00
BenJilks
d8474d80f2 PixelPaint: Save and load to and from disk
Store a PixelPaint project in a .pp file (as there doesn't seem to
be any real standard on this). It's a very simple json file that
contains the bitmap as a base64 encoded bmp.
2020-11-22 16:07:00 +01:00
BenJilks
216385084b LibGfx: Add BMPWriter
This utility allows you to create a BMP file from a bitmap
2020-11-22 16:07:00 +01:00
BenJilks
91b2af34e1 base64: Fix not outputting all decoded data
It would use printf to output the data, so if it contains a null
terminator it'll stop.
2020-11-22 16:07:00 +01:00