Commit graph

13210 commits

Author SHA1 Message Date
Peter Elliott
7907df7617 Applications: Use placeholders in TextBoxes where applicable 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
b7ce0680dd test-web: Keep the Interpreter on the VM interpreter stack during test 2020-09-21 14:34:40 +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
31bb107922 AK: Remove BufferStream class.
There are three classes avaliable that share the functionality of
BufferStream:

 1. InputMemoryStream is for reading from static buffers. Example:

        Bytes input = /* ... */;
        InputMemoryStream stream { input };

        LittleEndian<u32> little_endian_value;
        input >> little_endian_value;

        u32 host_endian_value;
        input >> host_endian_value;

        SomeComplexStruct complex_struct;
        input >> Bytes { &complex_struct, sizeof(complex_struct) };

 2. OutputMemoryStream is for writing to static buffers. Example:

        Array<u8, 4096> buffer;
        OutputMemoryStream stream;

        stream << LittleEndian<u32> { 42 };
        stream << ReadonlyBytes { &complex_struct, sizeof(complex_struct) };

        foo(stream.bytes());

 3. DuplexMemoryStream for writing to dynamic buffers, can also be used
    as an intermediate buffer by reading from it directly. Example:

        DuplexMemoryStream stream;

        stream << NetworkOrdered<u32> { 13 };
        stream << NetowkrOrdered<u64> { 22 };

        NetworkOrdered<u32> value;
        stream >> value;
        ASSERT(value == 13);

        foo(stream.copy_into_contiguous_buffer());

Unlike BufferStream these streams do not use a fixed endianness
(BufferStream used little endian) these have to be explicitly specified.
There are helper types in <AK/Endian.h>.
2020-09-21 09:37:49 +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
26f4b5e6ba TelnetServer: Use OutputMemoryStream instead of BufferStream.
I could not test these changes because I could not get my telnet client
(on Linux) to connect to the telnet server running in Serenity.

I tried the follwing:

    # Serenity
    su
    TelnetServer

    # Linux
    telnet localhost 8823

The server then immediatelly closes the connection:

    Connection closed by foreign host.

In the debug logs the following message appears:

    [NetworkTask(5:5)]: handle_tcp: unexpected flags in FinWait2 state
    [NetworkTask(5:5)]: handle_tcp: unexpected flags in Closed state
    [NetworkTask(5:5)]: handle_tcp: unexpected flags in Closed state

This seems to be an unrelated bug in the TCP implementation.
2020-09-21 09:37:49 +02:00
asynts
8f06e4aaa4 LookupServer: Use DuplexMemoryStream instead of BufferStream. 2020-09-21 09:37:49 +02:00
asynts
3fa0bba4b4 AudioServer: Use OutputMemoryStream 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
ae9f0e1cd8 AK: Add missing const in Span::operator==. 2020-09-21 09:37:49 +02:00
asynts
1a277ac291 AK: Add OutputMemoryStream::is_end. 2020-09-21 09:37:49 +02:00
AnotherTest
e7f5090808 Spreadsheet: Always keep the workbook interpreter in VM scope
Fixes #3570.
2020-09-21 00:10:19 +02:00
Tibor Nagy
cba5a69f07 FontEditor: Draw the baseline in the glyph editor widget 2020-09-20 23:23:56 +02:00
Valtteri Koskivuori
f0fdbb1d83 Meta: Fix build-root-filesystem.sh on macOS 2020-09-20 21:45:00 +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
876b7b4619 Meta: Add Itamar Shenhar to the contributors list :^) 2020-09-20 19:55:36 +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
Itamar
e3e5e57fde HackStudio: Move bulk of GUI logic into HackStudioWidget
Previously, the GUI logic of HackStudio was all stuffed into main(),
and it started getting a bit out of hand :)
2020-09-19 21:39:05 +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
d3fcba78b0 WindowServer: Shrink menubar menu text rects slightly
We don't want the menu titles to cover the entire menubar.
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
Liav A
d9863e0b6c Kernel: Remove unnecessary class member in UHCIController
The m_address member is not needed, since PCI::Device already has one.
2020-09-19 18:39:09 +02:00
Linus Groh
4e6a50f1d0 Meta: Add .clangd to .gitignore 2020-09-19 17:16:57 +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
Liav A
82b0171812 Kernel: Fix assertion statement in GenericInterruptHandler
We need to assert if interrupts are not disabled when changing the
interrupt number of an interrupt handler.
Before this fix, any change like this would lead to a crash,
because we are using InterruptDisabler in IRQHandler::change_irq_number.
2020-09-19 16:44:40 +02:00
Andreas Kling
2cb32f8356 Kernel: Let InodeWatcher track child inode numbers instead of names
First of all, this fixes a dumb info leak where we'd write kernel heap
addresses (StringImpl*) into userspace memory when reading a watcher.

Instead of trying to pass names to userspace, we now simply pass the
child inode index. Nothing in userspace makes use of this yet anyway,
so it's not like we're breaking anything. We'll see how this evolves.
2020-09-19 16:39:52 +02:00
Andreas Kling
55dd13ccac Kernel: Don't assert when reading too little from an InodeWatcher
If you provide a buffer that's too small, we'll still dequeue an event
and write whatever fits in the provided buffer.
2020-09-19 15:39:53 +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
Andreas Kling
e1965a5a8e FileManager: Prevent feedback loop between treeview and directory view
When opening something in the left-side treeview, it also opens in the
right-side directory view. That triggers the "path changed" hook in the
directory view, which causes us to fully reveal the opened directory
in the left-side treeview.

This feedback loop made the UI feel weird since it caused directories
to expand just by selecting them in the left-side treeview. So let's
break that loop.
2020-09-19 14:09:59 +02:00
Tom
ba238ac62a Kernel: Simplify ProcFS callbacks by using function pointers directly 2020-09-19 01:22:30 +02:00
Nico Weber
31e7f73aae UserspaceEmulator: Support all msg_iovlens in recvmsg and sendmsg
The kernel doesn't support msg_iovlens != 1 yet and nothing passes
an amount != 1, but if anyone ever adds support for this they won't
have to worry about ue at least.
2020-09-19 00:39:05 +02:00
AnotherTest
29ef65c458 Shell: Fix Vector OOB access in `add_entry_to_cache()'
Fixes #3530.
2020-09-19 00:38:41 +02:00
AnotherTest
a43d9c4fe0 Shell: Make a new session at start if there's no active session 2020-09-19 00:38:41 +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