Commit graph

19753 commits

Author SHA1 Message Date
Valtteri Koskivuori
1069979ddf AK: Implement Span::starts_with()
Useful for checking for contents at the start of a span.
2021-05-07 11:46:53 +01:00
Ali Mohammad Pur
aacbee8ed8 Tests: Add tests for Checked<T>::div() overflow 2021-05-07 09:26:11 +02:00
Ali Mohammad Pur
da68c4580c AK: Make Checked<T> check for division overflow as well
Signed integer overflow can occur with division when the RHS is -1,
as the negative values' range is one larger than the positives.
2021-05-07 09:26:11 +02:00
Luke
df52040ce9 LibWeb: Implement replacing the current body when setting document.body
Also adds an exception check to the append at the end.
2021-05-07 08:53:37 +02:00
Luke
b6004a4ce1 LibWeb: Add non-const variants of Document::{html_element,body,head}() 2021-05-07 08:53:37 +02:00
Luke
46f2c278b0 LibWeb: Implement Node.replaceChild
The `if (child->parent())` check seems to be redundant, but I'm keeping
it just to match the spec.
2021-05-07 08:53:37 +02:00
Max Wipfli
228c1f4968 LibGUI: Remove line-is-empty check in TextDocument return-early
This patch removes an incorrect way for TextDocument::text_in_range
to return early when the first line of the selection was empty. This
fixes an issue in TextEditor where the status bar showed that 0
characters are selected when the selection started on an empty line.
2021-05-06 23:00:43 +01:00
Andreas Kling
fb6d236ba2 Profiler: Add fixed track headers to the timeline view
The architecture here is a little bit convoluted. I ended up making a
new container widget (TimelineContainer) that works similarly to
GUI::ScrollableContainerWidget but has two subwidgets (a fixed header
that only scrolls vertically, and the timeline view that scrolls on
both axes.)

It would be nice to generalize this mechanism eventually and move it
back into LibGUI, but for now let's go with a special widget for
Profiler so we can continue iterating on the GUI. :^)
2021-05-06 22:18:45 +02:00
Andreas Kling
59da118f2e Profiler: Add a statusbar and show the timeline selection info in it :^) 2021-05-06 22:18:45 +02:00
Andreas Kling
814200f8da Profiler: Rename ProfileTimelineWidget => TimelineTrack 2021-05-06 22:18:45 +02:00
Andreas Kling
abc3ad01b2 Profiler: Add TimelineView widget and make the timeline cursor global
There's no longer a cursor in each process timeline, instead the parent
widget keeps track of it (along with the selection) and it all moves
in sync.
2021-05-06 22:18:45 +02:00
Andreas Kling
84c4c2d884 Profiler: Tweak timeline widget appearance
Use a thinner frame, and ColorRole::Base for the background.
2021-05-06 22:18:45 +02:00
Andreas Kling
9273054b2b Profiler: Show one timeline per process :^)
Instead of smashing together all the samples into a single timeline,
make one per process and put them all in a ScrollableContainerWidget.

This makes it much easier to see which processes were active and when.
No timeline is displayed for processes with zero samples in the profile.
2021-05-06 22:18:45 +02:00
Gunnar Beutner
017da44ac2 LibC: Make malloc(0) return a non-null pointer
Legally we could just return a null pointer, however returning a
pointer other than the null pointer is more compatible with
improperly written software that assumes that a null pointer means
allocation failure.
2021-05-06 21:25:37 +02:00
Gunnar Beutner
0615a4d42a LibC: Make scanf() not increment the assignment count for %n 2021-05-06 20:36:17 +02:00
Andreas Kling
f142b43e89 Base: Make the /bin/TextEditor desktop shortcut say "Text Editor" :^) 2021-05-06 17:54:36 +02:00
Brian Gianforcaro
6e918e4e02 Tests: Move LibRegex tests to Tests/LibRegex 2021-05-06 17:54:28 +02:00
Brian Gianforcaro
070cba9b0d Tests: Move LibCompress tests to Tests/LibCompress 2021-05-06 17:54:28 +02:00
Brian Gianforcaro
597de3356f Tests: Move LibSQL tests to Tests/LibSQL 2021-05-06 17:54:28 +02:00
Brian Gianforcaro
67322b0702 Tests: Move AK tests to Tests/AK 2021-05-06 17:54:28 +02:00
Brian Gianforcaro
fd0dbd1ebf Tests: Establish root Tests directory, move Userland/Tests there
With the goal of centralizing all tests in the system, this is a
first step to establish a Tests sub-tree. It will contain all of
the unit tests and test harnesses for the various components in the
system.
2021-05-06 17:54:28 +02:00
Mart G
6e641fadfa
Kernel: Resize Ext2FSInode when writing directory contents (#6897)
Ext2 directory contents are stored in a linked list of ext2_dir_entry
structs. There is no sentinel value to determine where the list ends.
Instead the list fills the entirety of the allocated space for the
inode.

Previously the inode was not correctly resized when it became smaller.
This resulted in stale data being interpreted as part of the linked list
of directory entries.
2021-05-06 17:53:59 +02:00
Linus Groh
f1791eca13 Ports: Always set Python MACHDEP to version-less 'serenityos'
This is used for `sys.platform`, so it's important to get it right and
ideally never change it again. When not cross-compiling this would
append the `uname -r` version number, so let's explicitly override the
generated value and set it to `serenityos`. Various other systems do
this as well.
2021-05-06 16:46:43 +01:00
Linus Groh
8cfbeb78ff Ports: Remove Python printf fraction length patch
This functionality was implemented in f0fe449, making the patch
unnecessary.
2021-05-06 15:26:49 +01:00
AnotherTest
ba6c9423b8 AK: Implement printf fraction length specification for strings
This adds support for '%.20s' and friends :^)
2021-05-06 15:20:31 +01:00
Linus Groh
9f970c3459 Ports: Register Browser in the Python webbrowser module
This makes the following work:

    >>> import webbrowser
    >>> webbrowser.open("http://serenityos.org")

As well as this well-known easter egg:

    >>> import antigravity

Pretty cool! :^)
2021-05-06 14:26:09 +01:00
Linus Groh
877996465a LibC: Update forkpty() master fd before fork()'s child branch 2021-05-06 14:04:07 +01:00
Linus Groh
5391836468 LibC: Remove 'int* aslave' parameter from forkpty()
Only keep track of that (and eventually close() it) internally instead.
This argument is not present on other systems, so we were running into
compatibility issues with ports.
Also bring the implementation closer to Linux and OpenBSD by making sure
to close the slave pty fd in the fork()'d child as well as _exit()'ing
on login_tty() failure - it's non-POSIX, so those are our references
here. :^)
2021-05-06 13:52:46 +01:00
Linus Groh
e76342e242 Ports: Update Python to 3.9.5
Released on 2021-05-03.
https://www.python.org/downloads/release/python-395/
2021-05-06 13:04:38 +01:00
Andreas Kling
6024617df3 LookupServer: Remove some unnecessary "rc" temporaries 2021-05-06 13:37:46 +02:00
Andreas Kling
f0629e29c9 LookupServer: Check the return value after calling unveil() 2021-05-06 13:34:36 +02:00
Andreas Kling
a7e44d8b3c Base: Remove unnecessary UID separation of multi-process Browser
After looking closely at this, I realized that we've been running
all the service processes under separate user accounts even though
there's actually no need to.

Since we already use pledge() and unveil() to limit the scope and
access of these programs, separating them to another UID doesn't
achieve anything meaningful. So let's bring them back to the "anon"
user account and simplify things.

Programs affected:

- ImageDecoder
- RequestServer
- WebContent
- WebSocket

Longer term, I'd like for all of these to get spawned for the current
desktop user somehow, possibly by some kind of session manager, or
perhaps by the Browser program itself. But for now they remain under
SystemServer's control.
2021-05-06 13:33:08 +02:00
Andreas Kling
434c190667 TextEditor: Minor cleanups in the FileArgument class
* Remove unnecessary #include statements
* Move it into the TextEditor namespace
* Mark the single-argument constructor explicit
* Use move() to avoid some unnecessary copies
2021-05-06 12:35:25 +02:00
Andreas Kling
297a2762cd TextEditor: Rename "file_name" => "filename" 2021-05-06 12:33:46 +02:00
Andreas Kling
f3091d89aa WindowServer: Don't let clients start resize of non-resizable windows
This came up in #6886. If resizing has been disabled for a window,
we shouldn't let clients bypass this via start_window_resize().
2021-05-06 12:09:03 +02:00
Andreas Kling
dfd8598bf7 LibGUI: Don't show resize corner in non-resizable window's statusbar
Fixes #6886.
2021-05-06 12:08:00 +02:00
Gunnar Beutner
3438829431 LibC: Lazily initialize malloc chunks
By default malloc manages memory internally in larger blocks. When
one of those blocks is added we initialize a free list by touching
each of the new block's pages, thereby committing all that memory
upfront.

This changes malloc to build the free list on demand which as a
bonus also distributes the latency hit for new blocks more evenly
because the page faults for the zero pages now don't happen all at
once.
2021-05-06 10:38:46 +02:00
Tom
3aaffa2c47 LibGUI: Move widget registration to LibCore
This also moves Widget::load_from_json into Core::Object as a virtual
function in order to allow loading non-widget objects in GML (e.g.
BoxLayout).

Co-authored-by: Gunnar Beutner <gbeutner@serenityos.org>
2021-05-06 08:50:39 +02:00
Gunnar Beutner
6e101adc28 DHCPClient: Handle invalid DHCP responses more gracefully 2021-05-06 08:49:35 +02:00
Gunnar Beutner
9213d1e926 Kernel: Truncate UDP packets on read
When reading UDP packets from userspace with recvmsg()/recv() we
would hit a VERIFY() if the supplied buffer is smaller than the
received UDP packet. Instead we should just return truncated data
to the caller.

This can be reproduced with:

    $ dd if=/dev/zero bs=1k count=1 | nc -u 192.168.3.190 68
2021-05-06 08:49:35 +02:00
Carlos César Neves Enumo
928f16d360 LibGUI: Remember modified state on undo/redo actions 2021-05-06 08:40:26 +02:00
Carlos César Neves Enumo
67537bfc80 LibGUI: Clear undo stack when opening a new document 2021-05-06 08:40:26 +02:00
Andreas Kling
88803b2e34 Meta: Add "Human language policy" to CONTRIBUTING.md 2021-05-05 23:15:08 +02:00
Spencer Dixon
0f89e47a1a
Kernel: Allow remapping Caps Lock to Control (#6883)
We use a global setting to determine if Caps Lock should be remapped to
Control because we don't care how keyboard events come in, just that they
should be massaged into different scan codes.

The `proc` filesystem is able to manipulate this global variable using
the `sysctl` utility like so:

```
# sysctl caps_lock_to_ctrl=1
```
2021-05-05 23:10:56 +02:00
Andreas Kling
18d344609f LibGUI: Add ScrollableContainerWidget :^)
This widget provides a scrollable view onto another (child) widget.
If the child is larger than the parent, scrollbars are provided for
panning around the child.
2021-05-05 22:17:33 +02:00
Andreas Kling
89f5f92b7e LibMarkdown: Convert a bunch of StringBuilder::appendf() => appendff() 2021-05-05 22:17:33 +02:00
Gunnar Beutner
beae2d5caa LibSQL: Fix incorrect return types
Right now RefPtr<T> is way more lenient than it should be. That might
change in the future though.
2021-05-05 22:00:57 +02:00
Timothy Flynn
e8b508516a Solitaire: Decrease new game animation delay
The current setting is an awful long time to wait for a game to start.
2021-05-05 21:38:45 +02:00
Timothy Flynn
a07c178a02 Solitaire: Add statusbar segment to display elapsed time
The timer begins after the new-game animation ends, and stops when
either the game-over animation begins or the new-game animation is
started again.
2021-05-05 21:38:45 +02:00
Timothy Flynn
ee1a4a06e0 LibGUI: Allow specifying GUI::Statusbar segment count in GML 2021-05-05 21:38:45 +02:00