Commit graph

4559 commits

Author SHA1 Message Date
Andreas Kling
d1b58ee9ad LibJS: Move well-known symbols to the VM
No need to instantiate unique symbols for each Interpreter; they can
be VM-global. This reduces the memory cost and startup time anyway.
2020-09-22 20:10:20 +02:00
Andreas Kling
676cb87a8f LibJS: Use VM::exception() instead of Interpreter::exception() a bunch
There's a lot more of these things to fix. We'll also want to move from
passing Interpreter& around to VM& instead wherever that is enough.
2020-09-22 20:10:20 +02:00
Andreas Kling
d74bb87d46 LibJS: Add a way to get from a Cell to the VM 2020-09-22 20:10:20 +02:00
Andreas Kling
4a8bfcdd1c LibJS: Move the current exception from Interpreter to VM
This will allow us to throw exceptions even when there is no active
interpreter in the VM.
2020-09-22 20:10:20 +02:00
Peter Elliott
3d34724d37 LibCore: Add Core::Account for login management.
Core::Account abstracts login semantics like password checking and
switching uid/gid.
2020-09-21 20:18:05 +02:00
Itamar
b7bd2ed9d2 HackStudio: Add auto-complete capability to the Editor 2020-09-21 20:16:03 +02:00
Peter Elliott
253ab7536a Base: Add the PlaceholderText attribute to themes 2020-09-21 20:15:10 +02:00
Peter Elliott
fa96e57c15 LibGUI: Add optional placeholder to TextEditor
This lets you show some disabled text when no text is entered, and the
editor is not focused.
2020-09-21 20:15:10 +02:00
Andreas Kling
5b6ccbb918 LibJS: VM::interpreter() should just assert when no active interpreter
I accidentally committed some code here to force a crash, but this
should just assert.
2020-09-21 14:42:26 +02:00
Andreas Kling
c8baf29d82 LibJS: Assert if garbage collection is restarted while ongoing
We can't GC while we're already in GC. Assert if this happens.
2020-09-21 14:35:19 +02:00
Andreas Kling
df3ff76815 LibJS: Rename InterpreterScope => InterpreterExecutionScope
To make it a little clearer what this is for. (This is an RAII helper
class for adding and removing an Interpreter to a VM's list of the
currently active (executing code) Interpreters.)
2020-09-21 14:35:12 +02:00
Andreas Kling
fbe2907510 LibJS: GC should gather roots from all active interpreters
If we are in a nested execution context, we shouldn't only mark things
used by the active interpreter.
2020-09-21 14:34:40 +02:00
asynts
c879ecf509 LibIPC: Use InputMemoryStream instead of BufferStream. 2020-09-21 09:37:49 +02:00
asynts
7d1b22bbb1 LibGfx+JPGLoader: Use InputMemoryStream instead of BufferStream. 2020-09-21 09:37:49 +02:00
asynts
d050dede7a LibGfx+ICOLoader: Use InputMemoryStream instead of BufferStream. 2020-09-21 09:37:49 +02:00
asynts
0f5b42ac80 LibGfx+GIFLoader: Use InputMemoryStream instead of BufferStream. 2020-09-21 09:37:49 +02:00
asynts
5056d8bb20 LibGfx+Font: Use OutputFileStream instead of BufferStream. 2020-09-21 09:37:49 +02:00
asynts
fa43bf92e4 LibAudio: Use InputMemoryStream instead of BufferStream. 2020-09-21 09:37:49 +02:00
asynts
03a27bc693 LibGUI: Remove unnecessary type cast in JsonArrayModel.
Since TCP sequence numbers are randomly choosen 32-bit numbers, it often
happend that the most significant bit was set. The cast to a 32-bit
signed integer then made the number negative.

Thus TCP sequence were shown negative in the SystemMonitor every so
often.
2020-09-20 21:10:46 +02:00
Tibor Nagy
3ce97b9c0e LibGUI: Pad row/column headers of AbstractTableView 2020-09-20 20:54:23 +02:00
Andreas Kling
1c43442be4 LibJS+Clients: Add JS::VM object, separate Heap from Interpreter
Taking a big step towards a world of multiple global object, this patch
adds a new JS::VM object that houses the JS::Heap.

This means that the Heap moves out of Interpreter, and the same Heap
can now be used by multiple Interpreters, and can also outlive them.

The VM keeps a stack of Interpreter pointers. We push/pop on this
stack when entering/exiting execution with a given Interpreter.
This allows us to make this change without disturbing too much of
the existing code.

There is still a 1-to-1 relationship between Interpreter and the
global object. This will change in the future.

Ultimately, the goal here is to make Interpreter a transient object
that only needs to exist while you execute some code. Getting there
will take a lot more work though. :^)

Note that in LibWeb, the global JS::VM is called main_thread_vm(),
to distinguish it from future worker VM's.
2020-09-20 19:24:44 +02:00
Andreas Kling
c6ae0c41d9 LibWeb: Add Bindings::ScriptExecutionContext
This will be inherited by documents and workers, to provide a common
abstraction for script execution. (We don't have workers yet, but we
might as well make this little space for them now to simplify things
down the road.)
2020-09-20 19:22:44 +02:00
Andreas Kling
976e55e942 LibJS: Remove some unnecessary indirection in Object constructors 2020-09-20 19:18:05 +02:00
Andreas Kling
668e73df8a LibJS: Make Interpreter::in_strict_mode() work outside of scope
This one is a little weird. I don't know why it's okay for this
function to assume that there is a current scope on the scope stack
when it can be called during global object initialization etc.

For now, just make it say "we are in strict mode" when there is no
currently active scope.
2020-09-20 19:16:34 +02:00
Andreas Kling
893df28e80 LibJS: Don't allocate property table during GC marking phase
Shape was allocating property tables inside visit_children(), which
could cause garbage collection to happen. It's not very good to start
a new garbage collection while you are in the middle of one already.
2020-09-20 19:11:49 +02:00
Andreas Kling
4036ff9d91 LibJS: Remove unused argument in NativeFunction constructor 2020-09-20 19:11:11 +02:00
Itamar
32d0d00ab2 LibGUI: Fix row_rect(int) calculation in AbstractTableView
Previously, it didn't take into account the visibility of
column headers.
2020-09-20 16:34:56 +02:00
Andreas Kling
606c0e1672 LibGfx: Move vertically centered text down slightly based on baseline
To make slightly more aesthetically pleasing use of the vertical space,
we now move all vertically centered text lines down by half the amount
of space below the font's baseline.

This is probably not the "correct" way to do this, but it does make
things look nicer with some of our fonts already.
2020-09-19 19:16:22 +02:00
Andreas Kling
5f8a9d348d LibGfx: Add a helper to check if a TextAlignment is vertically centered 2020-09-19 19:16:22 +02:00
Andreas Kling
95eeb321f9 LibGfx+FontEditor+Base: Add "baseline" value to all fonts
This does nothing at the moment but will soon allow us to improve the
vertical positioning of text.
2020-09-19 19:16:22 +02:00
Jakob-Niklas See
eeb3ef405c
LibGUI: Increase slider acceleration with Ctrl (#3499)
When holding Ctrl and scrolling on a slider widget, the scrolling
acceleration gets increased.

This can make it faster to get to the knob location you want to
get to. :^)
2020-09-19 16:45:51 +02:00
Linus Groh
c0e4353bde LibJS: Handle getter exception in JSONObject::serialize_json_property()
In the case of an exception in a property getter function we would not
return early, and a subsequent attempt to call the replacer function
would crash the interpreter due to call_internal() asserting.

Fixes #3548.
2020-09-19 14:17:22 +02:00
AnotherTest
21f513fe0f LibJS: Do not revisit already visited values in update_function_name()
Fixes #3471, adds a test.
2020-09-19 00:33:56 +02:00
Andreas Kling
3bccd99fe9 LibGUI: Add TreeView::expand_all_parents_of(ModelIndex)
This does exactly what it sounds like. :^)
2020-09-18 21:29:01 +02:00
Andreas Kling
76ae47c6ed LibGUI: Unbreak FileSystemModel::index(path) after virtual root changes
Now that the "/" directory can have a (virtual) parent index, we need
to account for that when converting a full path to a model index.
2020-09-18 21:29:01 +02:00
Andreas Kling
e4c23b0151 iLibGUI+Base: Show inaccessible directories with special icon in views 2020-09-18 21:29:01 +02:00
Andreas Kling
fad6b8f267 LibGUI: FileSystemModel should provide full paths to FileIconProvider
This will allow FileIconProvider to check additional things about
the specified path. (We previously only had access to the basename.)
2020-09-18 21:29:01 +02:00
Andreas Kling
9b89303767 LibGUI: StackWidget should not steal focus when switching active child
Only focus the new active child if the old one had focus previously.
2020-09-18 21:29:01 +02:00
Linus Groh
a9f5b0339d LibJS: Simplify toEval() implementation 2020-09-18 20:49:35 +02:00
Linus Groh
5fd87ccd16 LibJS: Add FIXMEs for parsing increment operators with function LHS/RHS
The parser considers it a syntax error at the moment, other engines
throw a ReferenceError during runtime for ++foo(), --foo(), foo()++ and
foo()--, so I assume the spec defines this.
2020-09-18 20:49:35 +02:00
Linus Groh
fd32f00839 LibJS: Mark more ASTNode classes as final 2020-09-18 20:49:35 +02:00
Nico Weber
47b3e98af8 Kernel+LibC+UserspaceEmulator: Add SO_TIMESTAMP, and cmsg definitions
When SO_TIMESTAMP is set as an option on a SOCK_DGRAM socket, then
recvmsg() will return a SCM_TIMESTAMP control message that
contains a struct timeval with the system time that was current
when the socket was received.
2020-09-17 17:23:01 +02:00
Nico Weber
ae5ba4074d LibC: Convert SO_ constants to enum
I want to add another entry to this list and don't want to
have to think of a number for it.
2020-09-17 17:23:01 +02:00
Nico Weber
b36a2d6686 Kernel+LibC+UserspaceEmulator: Mostly add recvmsg(), sendmsg()
The implementation only supports a single iovec for now.
Some might say having more than one iovec is the main point of
recvmsg() and sendmsg(), but I'm interested in the control message
bits.
2020-09-17 17:23:01 +02:00
Uma Sankar
19f2203b53
LibGUI: Set ProcessChooser key column and sort order after set_model (#3521)
Need to set the sort order after model was set to sort the table.
2020-09-17 16:17:14 +02:00
Uma Sankar
d7673b41ef
LibGUI: Respect the previously selected sort order in HeaderView (#3522)
Instead of forcefully setting the sort order to Ascending upon column
sort, setting it to the previously selected sort order
2020-09-17 16:15:35 +02:00
Tom
5ee29e8a26 LibIPC: Check if socket is still open before using socket descriptor
Writing to the socket may trigger a close of the socket descriptor
if a disconnect was detected. We need to check if it is still valid
when waiting for a response after attempting to send a synchronous
message.

Fixes #3515
2020-09-17 09:47:29 +02:00
Peter Elliott
1720030625 LibGUI: Don't recalcuate color from hue if it was not set by hue
Basically, setting the hue is numerically sensitive when the value or
saturation are low.
2020-09-17 09:47:05 +02:00
Peter Elliott
9670d9ad50 LibGUI: Don't allow 4 character html color codes in GUI::ColorPicker
When 4 character colors were allowed, backspace misbehaved and you
couldn't backspace the whole color.
2020-09-17 09:47:05 +02:00
Andreas Kling
d89cad7c57 LibGUI: Use FileIconProvider in the FilePicker dialog 2020-09-16 21:08:55 +02:00