Commit graph

5928 commits

Author SHA1 Message Date
Emanuele Torre
91222a67c8 LibCore: get_password() now removes the trailing '\n' read by getline()
This avoids unintentionally adding a newline character at the end of
user passwords when they are set using passwd(1).

I also fixed these two issues:

- The return value of getline() was being saved in an `int` variable
instead of in a `ssize_t` variable; I replaced the `int` keyword with
`auto` to fix this issue.

- Prior to this patch, get_password() could potentially return
tcsetattr()'s errno instead of getline()'s errno in case of an error.
We now make sure it always returns the right errno in case of an error.
2021-01-10 16:40:05 +01:00
Andreas Kling
f152b6f7ed LibCore: Don't try to unlink stale sockets in /tmp/rpc/
This was very obviously racy and would only succeed if we already own
the socket anyway. (And if we do, we can bind to it without unlinking!)

Work towards #4876.
2021-01-10 11:25:59 +01:00
Andreas Kling
d38b9916c9 SystemServer+LibCore: Move /tmp/rpc/ directory creation to SystemServer
This doesn't solve half of the problems with /tmp/rpc, but this way we
can at least make it sticky instead of having it fully world-writable
and owned by whoever was the first to bind an RPC socket.
2021-01-10 10:34:45 +01:00
Andreas Kling
f35a723f61 Everywhere: Convert a bunch of dbgprintf() to dbgln() 2021-01-10 10:02:20 +01:00
Andreas Kling
13e8a2a671 LibVT: Don't assert if ioctl(TIOCSWINSZ) fails
This ioctl can fail if we're resizing the terminal right when the shell
inside it has exited. Instead of throwing up a crash reporter, whine a
little bit in the debug log and exit cleanly moments later.
2021-01-10 09:40:59 +01:00
Andreas Kling
e855aac1f5 LibELF: Convert many dbgprintf() to dbgln() and tweak debug macro name 2021-01-10 09:40:47 +01:00
AnotherTest
d3f51ee5c3 LibLine: It's okay to be interrupted while reading the DSR response
Fixes #4855.
2021-01-10 00:03:52 +01:00
AnotherTest
7059ca9b15 LibLine: Don't clear the displayed buffer when interrupted
Since we always restart on a new line, there's no reason to clear the
previous lines.
2021-01-10 00:03:52 +01:00
AnotherTest
9b126a2250 LibLine: Unregister signal handlers on destruction
This fixes an issue that shows up as a nice crash when "^R<enter>^C",
which is actually the event loop trying to call into a deleted object
(the search editor).
2021-01-10 00:03:52 +01:00
Tom
21e6f5176c LibCore: Harden signal handling code to be called in global destrcutors
Move some more complex globals into a Singleton, which allows it being
used from global destructors. It solves problems where some global
variables, such as HashMaps may already be deleted, triggering crashes
trying to use them.
2021-01-09 21:12:31 +01:00
Tom
8548ec357c LibCore: Allow adding/removing signal handlers while handling signals
This allows adding and removing of asynchronous signal handlers while
executing signal handlers, even if it is for the same signal that is
being handled right now.
2021-01-09 21:12:31 +01:00
asynts
938e5c7719 Everywhere: Replace a bundle of dbg with dbgln.
These changes are arbitrarily divided into multiple commits to make it
easier to find potentially introduced bugs with git bisect.Everything:

The modifications in this commit were automatically made using the
following command:

    find . -name '*.cpp' -exec sed -i -E 's/dbg\(\) << ("[^"{]*");/dbgln\(\1\);/' {} \;
2021-01-09 21:11:09 +01:00
asynts
7235ddfd98 LibGUI: Add formatter for Widget. 2021-01-09 21:11:09 +01:00
asynts
1160817a9e AK: Add Formatter<FormatString> as helper class. 2021-01-09 21:11:09 +01:00
Andreas Kling
9a842ec419 LibC: Add explicit_bzero()
This is a variant of bzero() that is guaranteed to not get optimized
away by the compiler. Useful for clearing out sensitive data.
2021-01-09 20:04:18 +01:00
Andreas Kling
b4918bbe2f LibC: Move bzero() and bcopy() per Dr. POSIX 2021-01-09 19:56:59 +01:00
Andreas Kling
9a688af4b1 LibCore+passwd+su+Base: Add /etc/shadow to hide hashes from users :^)
This patch moves the user account password hashes from /etc/passwd,
where they were world-readable, to /etc/shadow, where only root can
access them.

The Core::Account class is extended to support both authentication
against, and modification of /etc/shadow.

The default password for "anon" as of this commit is "foo" :^)
2021-01-09 19:41:12 +01:00
Linus Groh
7b2fdd08ce LibJS: Add tests for bitwise NOT operator 2021-01-09 19:09:02 +01:00
Linus Groh
9fca86109b LibJS: Make bitwise NOT work correctly with NaN and Infinity
This was missing a "toInt32()" which returns 0 for NaN and Infinity.
From the spec:

    6.1.6.1.2 Number::bitwiseNOT ( x )

    The abstract operation Number::bitwiseNOT takes argument x (a Number).
    It performs the following steps when called:

        Let oldValue be ! ToInt32(x).
        Return the result of applying bitwise complement to oldValue.
        The mathematical value of the result is exactly representable as
        a 32-bit two's complement bit string.

Fixes #4868.
2021-01-09 19:09:02 +01:00
Linus Groh
c55cb7843a LibJS: Use INVALID some more in abstract operations 2021-01-09 19:09:02 +01:00
Andreas Kling
e08e1a89d9 LibWeb: No need to report that we encountered <svg> or <math>
These things happen, and it's not particularly noteworthy.
2021-01-09 15:22:23 +01:00
Andreas Kling
1d75e82101 LibWeb: Coalesce layouts that happen in response to style changes
Instead of doing a forced layout synchronously whenever an element's
style is changed, use a zero-timer to do the forced relayout on next
event loop iteration.

This effectively coalesces a lot of layouts and makes many pages such
as GitHub spend way less time doing redundant layout work.
2021-01-09 15:22:23 +01:00
Andreas Kling
d56f4f635a LibDebug: Convert a bunch of dbg() to dbgln() 2021-01-09 15:22:23 +01:00
Andreas Kling
0a3b834346 LibWeb: Convert a bunch of dbg() to dbgln() 2021-01-09 14:03:06 +01:00
Andreas Kling
6a19542715 LibVT+Terminal: Resize terminal when font changes
When the font is changed in the Terminal application, we now resize the
terminal window to accomodate the new font.
2021-01-09 14:03:06 +01:00
Andreas Kling
9d6198b683 Everywhere: Colour => Color
The system language is US English. :^)
2021-01-09 14:03:06 +01:00
TheMorc
d0adaf4465 LibGUI: Add set_tab_index method
This method sets the current tab index to the value specified.
2021-01-09 13:27:23 +01:00
Andreas Kling
5f364f5dc1 LibGUI: Clear the application's drag-hovered widget on drop event
When we drop something on any window, there's no longer an ongoing drag
so let's forget the drag-hovered widget.
2021-01-09 12:02:07 +01:00
Andreas Kling
9e60fc5006 LibGUI: Add visual indicators for accepted drags to view classes
All the view classes used in FileManager now indicate when they are
ready to accept a drop by showing a rounded rectangle around the item.
2021-01-09 12:02:07 +01:00
Andreas Kling
607c01fad1 LibGUI: Add visual indicator for accepted drags to BreadcrumbBar
BreadcrumbBar segments will now indicate drag acceptance with a rounded
rectangle around the accepting segment.
2021-01-09 12:02:07 +01:00
Andreas Kling
b08ed1b560 LibGUI: Make AbstractView accept drags (and delegate to model) 2021-01-09 12:02:07 +01:00
Andreas Kling
7baaa34490 LibGUI: Make SortingProxyModel proxy accepts_drag() 2021-01-09 12:02:07 +01:00
Andreas Kling
12d0d12a78 FileManager+LibGUI: Make the breadcrumb bar accept text/uri-list drags 2021-01-09 12:02:07 +01:00
Andreas Kling
67b91d51a7 WindowServer+LibGUI: Pass the set of mime types being dragged to client
Previously the client would only learn the mime type of what was being
dropped on it once the drop occurred. To enable more sophisticated
filtering of drag & drop, we now pass along the list of mime types being
dragged to the client with each MouseMove event.

(Note that MouseMove is translated to the various Drag* events in LibGUI
on the client side.)
2021-01-09 12:02:07 +01:00
Andreas Kling
3b94af2c07 LibGUI: Have widgets signal willingness to accept drops
If a widget accept()'s a "drag enter" event, that widget now becomes
the application-wide "pending drop" widget. That state is cleared if
the drag moves over another widget (or leaves the window entirely.)
2021-01-09 12:02:07 +01:00
Andreas Kling
dbd090fd95 LibCore: Don't auto-accept events that hit bubbling limit
We were using the "accept" flag on the event to break out of the
bubbling loop, but this had lasting consequences since all events that
bubbled too far came out looking as if someone had accepted them.

If an event is ignored by everyone, it should appear ignored.
2021-01-09 12:02:07 +01:00
Andreas Kling
094b47971b LibGUI: Make Widget::HitTestResult::widget a WeakPtr 2021-01-09 12:02:07 +01:00
Andreas Kling
c17fa67f51 WindowServer+LibGUI: Notify hovered window when drag&drop is cancelled
The hovered window may want to react to a drag being cancelled, even
if the drag originated in some other window.
2021-01-09 12:02:07 +01:00
Andreas Kling
9acb72e804 LibGUI: Add "drag enter" and "drag leave" events
These events allow widgets to react when a drag enters/leaves their
rectangle. The enter event carries position + mime type, while the
leave event has no information.
2021-01-09 12:02:07 +01:00
Itamar
65ffd8de69 LibCoreDump: Add 'library_containing' API to CoreDump::Reader
This API returns info about the library whose range in memory contains
a given address (similar to 'region_containing', but for libraries).
2021-01-09 10:56:04 +01:00
Itamar
399091dec3 LibELF: Fix cached sorted symbols in ELF::Image
Previously, we didn't set the 'symbol' field of SortedSymbol objects in
some code paths that populate the sorted symbol cache.
2021-01-09 10:56:04 +01:00
Itamar
a4b74cba0b Loader.so+LibELF: Do not read environment variables if AT_SECURE is set
AT_SECURE is set in the auxiliary vector when we execute setuid/setgid
programs.
In those cases, we do not want to read environment variables that
influence the logic of the dynamic loader, as they can be controlled
by the user.
2021-01-09 10:55:46 +01:00
Itamar
20974b0772 LibDebug: Keep going when parent's location info could not be computed
Previously, when trying to parse the location info of a member
variable, we asserted that the location info of its parent is of type
'Address'.

However, there are cases where we cannot compute the location info of
the parent (for example - because we do not yet support the type of
debug info generated for it).
In those cases, it is better to just leave the location info of the
member variable empty instead of crashing.
2021-01-09 10:55:46 +01:00
Itamar
4b91e7c821 LibDebug: Support shared libraries
DebugSession now makes the loader stop after loading the libraries,
and parses the loaded libraries of the program before continuing its
execution.

DebugSession now also supports inserting a breakpoint at a given symbol
or source position.
Additionally, DebugInfo now takes the base address of its object into
consideration.
2021-01-09 10:55:46 +01:00
Itamar
ca9d6d21b5 Loader.so+LibELF: Introduce "_LOADER_BREAKPOINT" environment variable
If set, the dynamic loader will perform a software breakpoint after
loading all libraries, and just before jumping to the main entry point.

This allows a debugger to inspect the loaded libraries before the
program starts executing.
2021-01-09 10:55:46 +01:00
Itamar
bb90d961b8 LibELF: Add Symbol::is_undefined() 2021-01-09 10:55:46 +01:00
Itamar
f95f15e0bd CMake: Install sources of LibELF 2021-01-09 10:55:46 +01:00
Andreas Kling
6159630fa0 LibGUI: Make BreadcrumbBar report drop events
Dropping something on a breadcrumb segment button will now fire the
BreadcrumbBar::on_drop hook.

Fixes #4792.
2021-01-08 19:51:44 +01:00
Tyler Lanphear
c762a0c4d6 LibC: Implement tgoto(). 2021-01-08 17:09:40 +01:00
Tyler Lanphear
0f988424cf LibVT: Implement ICH sequence. 2021-01-08 17:09:40 +01:00
Andreas Kling
56c2cc4162 LibWeb: Implement most of the CSS table fixup algorithm
This patch implements the "remove irrelevant boxes" and "generate
missing child wrappers" parts of table fixup.

"Generate missing parents" is left as a task for our future selves.
2021-01-07 18:00:51 +01:00
Andreas Kling
0fd577084f LibWeb: Specialize is<DOM::Element>() and is<Layout::Box>()
These two show up in profiles, so let's add specializations for them.
2021-01-07 17:33:29 +01:00
Andreas Kling
d3046a2649 LibWeb: Allow anonymous table, table-row and table-cell layout nodes 2021-01-07 17:33:29 +01:00
Andreas Kling
75829c1b81 LibWeb: Move remove_all_children() from Node to TreeNode<T>
This is useful in all tree types.
2021-01-07 17:33:29 +01:00
Andreas Kling
fe9de4b55c LibWeb: Add the computed "display" values to CSS::ComputedValues 2021-01-07 17:33:29 +01:00
Andreas Kling
f655a60773 LibWeb: Add some more CSS "display" values 2021-01-07 17:33:29 +01:00
Andreas Kling
7ed89703fe LibCrypto+LibJS: Fix broken subtraction of two negative signed bigints
Found by oss-fuzz: https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=29326
2021-01-07 08:57:37 +01:00
AnotherTest
ddc255a6c0 LibHTTP: Take the final EOF read notification into account
Fixes the HTTP part of #3691.
2021-01-06 19:50:34 +01:00
Andreas Kling
80cffdc0a1 LibWeb: Compute width of absolutely positioned, replaced elements
Fixes #4589.
2021-01-06 19:20:49 +01:00
Andreas Kling
0ecefbff57 LibWeb: Move absolute positioning up to FormattingContext
It seems like both BFC and IFC can have absolutely positioned children.
It's a bit strange, but consider the following HTML:

<html><body>foobar<img style="position: absolute"></body></html>

In such a document, the <img> element is an absolutely positioned child
of a block-level element (<body>) with no block-level children.
An IFC is established for <body>, and needs to handle layout for <img>.
2021-01-06 19:20:49 +01:00
AnotherTest
4c98d00bef LibLine: Don't ignore ^C inputs when there are no registered handlers
Some people really like their ^C's, let's not make them sad.
2021-01-06 19:20:36 +01:00
Sergey Semushin
277fc41f47 LibKeyboard: don't null codepoint for numpad return key 2021-01-06 19:20:18 +01:00
Andreas Kling
612827eff3 LibWeb: Don't prune whitespace nodes from layout tree
Various whitespace-related issues have been fixed, and support for the
different CSS white-space values is improved enough that I think we can
stop doing the hack where we just prune whitespace nodes from the tree
and actually let them show up.

This is a nice step forward for correctness with the slight downside of
cluttering up layout tree dumps with tons of whitespace text nodes.
But hey, that's the web we know & love. :^)

Fixes #4427.
2021-01-06 14:58:48 +01:00
Andreas Kling
29a4da30b7 LibWeb: Make DOM::Node::create_layout_node() not need parent's style
The StyleResolver can find the specified CSS values for the parent
element via the DOM. Forcing everyone to locate specified values for
their parent was completely unnecessary.
2021-01-06 14:58:48 +01:00
Andreas Kling
d9b2650dcc LibWeb: Remove specified style from layout nodes
Layout nodes now only carry CSS computer values with them. The main
idea here is to give them only what they need to perform layout, and
leave the rest back in the DOM.
2021-01-06 14:58:48 +01:00
Andreas Kling
cc024bdcc0 LibWeb: Split CSS::ComputedValues members into structs by inheritance
Put all the inherited members in one struct and all the non-inherited
ones in another.

This makes it clear which is which, and also makes it easy to copy all
the inherited values while ignoring the non-inherited ones.
2021-01-06 14:58:48 +01:00
Andreas Kling
981758a8b1 LibWeb: Use the specified CSS values from element in more places
Instead of using the specified style stored on Layout::Node, use the
specified CSS values kept by the DOM::Element in more places.
2021-01-06 14:58:48 +01:00
Andreas Kling
63046d82f4 LibWeb: Use the cached background-image value in Layout::Box::paint() 2021-01-06 14:58:48 +01:00
Andreas Kling
ba8990fb6c LibWeb: Rename Element::resolved_style() => specified_css_values()
This object represents the specified CSS values, so let's call it that.
2021-01-06 14:58:48 +01:00
Andreas Kling
2cc39cfb0e LibWeb: Copy some properties from specified style into layout node
Another step towards not having to carry the full specified style with
us everywhere. This isn't the ideal final layout, since we're mixing
computed and used values a bit randomly here, but one step at a time.
2021-01-06 14:58:48 +01:00
Andreas Kling
e5490ae1d1 LibWeb: Rename Layout::Node::style() => computed_values() 2021-01-06 14:58:48 +01:00
Andreas Kling
e187a5365a LibWeb: Store the used font in Layout::NodeWithStyle
This is a step towards not having to carry the full set of specified
values around with every layout node.
2021-01-06 14:58:48 +01:00
Andreas Kling
5721b2a3da LibWeb: Rename LayoutStyle => CSS::ComputedValues
This object represents the CSS "computed values" so let's call it that.
2021-01-06 14:58:48 +01:00
Sahan Fernando
b370ee3423 LibELF: Implement GNU Hashing algorithm for dyn relocations 2021-01-06 09:42:08 +01:00
Davide Carella
f146ff87f1 CharacterMap: Added a new Shift+AltGr map.
If this map isn't found in a keymap the Alt+Gr map gets used.
2021-01-06 09:32:08 +01:00
Andreas Kling
92fe63fbec LibGfx: Tolerate PNGs with fewer palette entries than possible
We shouldn't reject indexed palette PNGs just because they have fewer
palette entries than the bit depth allows. Instead, we need to check
for OOB palette accesses and fail the decode *then*.
2021-01-06 01:34:25 +01:00
Andreas Kling
4a7d948f14 LibWeb: Simplify one kind of whitespace collapsing
For a non-empty TextNode chunk that begins with collapsible whitespace,
we can simply step right over the whitespace by adjusting the chunk.
2021-01-06 00:54:54 +01:00
Andreas Kling
8649f923ea LibWeb: Set override cursor on IPWV itself instead of whole window
When changing the mouse cursor (e.g when hovering over a link) we now
only change the InProcessWebView's override cursor instead of setting
the cursor at the window level.

This fixes an issue where the I-beam or hand cursors would somehow
"escape" from the web view and over to other widgets.
2021-01-05 22:22:44 +01:00
Andreas Kling
a6d52e0c97 LibWeb: Add a basic content filter (ad blocking!) :^)
This patch adds a global (per-process) filter list to LibWeb that is
used to filter all outgoing resource load requests.

Basically we check the URL against a list of filter patterns and if
it's a match for any one of them, we immediately fail the load.

The filter list is a simple text file:

    ~/.config/BrowserContentFilters.txt

It's one filter per line and they are simple glob filters for now,
with implicit asterisks (*) at the start and end of the line.
2021-01-05 21:20:15 +01:00
Andreas Kling
1c8eaf28cd LibGUI: Add GUI::Application::active_window()
Instead of each window having a bool flag that says whether that window
is currently active, have a pointer to the active window on the app
object instead.
2021-01-05 17:13:17 +01:00
Andreas Kling
8b90e8d08b LibGUI: Remove unused hook Window::on_activity_change 2021-01-05 17:13:16 +01:00
Andreas Kling
7d5a369ac9 LibGfx: Fail PGM decode if there isn't enough color data in image
If we have less pixel color data than we need to fill the image, just
fail the decode.

Found by oss-fuzz: https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=29127
2021-01-05 15:14:29 +01:00
Andreas Kling
5e95d62ffe LibTTF: Guard against unsigned overflow in TTF table parsing
Found by oss-fuzz: https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=29170
2021-01-05 14:50:17 +01:00
Andreas Kling
51b880b038 LibJS: Disable ASAN during the conservative GC stack scan
This allows the JS fuzzer to survive garbage collection (so we can find
more interesting bugs!)

Found by oss-fuzz: https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=29266
2021-01-05 12:27:45 +01:00
Andreas Kling
fdd974b7ef LibJS: Fix UB downcast during GlobalObject construction
When constructing a GlobalObject, it has to pass itself as the global
object to its own Shape. Since this is done in the Object constructor,
and Object is a base class of GlobalObject, it's not yet valid to cast
"this" to a GlobalObject*.

Fix this by having Shape store the global object as an Object& and move
Shape::global_object() to GlobalObject.h where we can at least perform a
valid static_cast in the getter.

Found by oss-fuzz: https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=29267
2021-01-05 12:02:59 +01:00
Rok Povsic
b4a783d923 TextEditor+EditingEngine: Add support for the basics of Vim emulation 2021-01-05 00:00:36 +01:00
Andreas Kling
da536c8d22 LibGUI: Add CommonActions::make_about_action()
This creates an "About" menu action given the app name and icon.
It takes care of showing the about dialog for you.
2021-01-04 23:31:42 +01:00
Andreas Kling
22325dd63e LibWeb: Don't careleslly insert inline-level boxes into inline-blocks
Just because an inline-block is inline doesn't mean it's ready to
accept random inline children. If it's a block, we may need to create
an anonymous wrapper first.

Fixes #4604.
2021-01-04 22:32:34 +01:00
Andreas Kling
d991658794 Kernel+LibC: Tidy up assertion failures with a dedicated syscall
This patch adds sys$abort() which immediately crashes the process with
SIGABRT. This makes assertion backtraces a lot nicer by removing all
the gunk that otherwise happens between __assertion_failed() and
actually crashing from the SIGABRT.
2021-01-04 21:57:30 +01:00
Andreas Kling
ce2894c95b LibWeb: Restart the cursor blink cycle whenever the user edits content
Having the text cursor disappear during rapid continuous editing is
quite jarring, so let's make sure we always restart the blink cycle
whenever the user performs some kind of editing action in a frame.
2021-01-04 20:48:27 +01:00
AnotherTest
1c4a425bff LibLine: Don't overwrite stuff when moving origin around
This fixes an issue (mainly) with multiline prompts, where a multiline
prompt would overwrite the lines before it when libline tries to display
it.
To reproduce, set `PROMPT="a\nb\nc> "` in the shell, then press return
a few times.
2021-01-04 19:13:18 +01:00
Andreas Kling
1e4b9a9cd9 LibGUI: Don't include invisible widgets in BoxLayout preferred size 2021-01-04 18:48:41 +01:00
Andreas Kling
21bacec13f LibGUI: Simplify ToolBarContainer by using shrink-to-fit
This class was implementing shrink-to-fit manually. No need for that
anymore now that we can use Widget's shrink-to-fit mode.
2021-01-04 18:21:05 +01:00
Andreas Kling
b03e1b08b5 LibGUI: Add Widget shrink-to-fit layout flag
If this flag is enabled for a widget, it will be automatically sized
based on its children. This only works for widgets using a layout.

This allows you to put widgets inside each other without having to
manually calculate how large the container should be. It's not the
perfect API but it's a decent progression in ergonomics. :^)
2021-01-04 18:17:14 +01:00
Andreas Kling
6041e48eaa LibCore: Make Core::Object::property() const 2021-01-04 13:41:13 +01:00
Emanuele Torre
370ce42430 Toolchain+LibTTF: Remove some blank line at the end of CMake files. 2021-01-03 23:58:54 +01:00
Linus Groh
0571a17f57 Kernel+LibELF: Store termination signal in coredump ProcessInfo 2021-01-03 22:12:42 +01:00
Tom
bc3c0fa936 LibCore: Allow caching and reusing the ProcFS file descriptors
Because ProcFS will refresh the data upon seek to 0, we can re-use
the same file descriptor. This saves us from having to open it every
time, but it also reduces the odds that we are unable to open a new
file descriptor due to low memory conditions.
2021-01-03 22:12:19 +01:00
Tom
cf89180c35 LibCore: Report error condition when reading process statistics failed 2021-01-03 22:12:19 +01:00
Linus Groh
e608723031 LibGUI: Add GMLFormatter
This will be useful for both the Playground app as well as for a
standalone CLI tool (à la clang-format). It cannot handle comments yet
(and will drop them from the formatted output), but other than that it
produces valid GML that matches the formatting we have so far! :^)
2021-01-03 22:12:08 +01:00
Linus Groh
acdbf66b54 LibGUI: Allow comment(s) before first class marker in GML parser
This wasn't considered valid GML but now is:

    // This is a comment
    // This as well
    @Foo::Bar {}
2021-01-03 22:12:08 +01:00
Andreas Kling
5cbcb35d34 LibELF: Add missing newlines at end of files 2021-01-03 17:26:03 +01:00
Andreas Kling
7e0226dd02 LibVT: Show terminal hyperlink targets as tooltips
This lets you see the target of a hyperlink before deciding to drag or
double click it.
2021-01-03 17:25:06 +01:00
Andreas Kling
347e5aa7b5 LibGUI: Hide the tooltip if widget with open tooltip unsets it
If you call set_tooltip({}) on a widget currently showing a tooltip,
we will now remove the tooltip window from screen.
2021-01-03 17:25:06 +01:00
Andreas Kling
a0f2135f47 LibVT: Make terminal hyperlinks double-click-to-activate
This patch makes hyperlinked terminal cells require a double click
to activate. The appearance of a hovered link is changed to not look
like a classic underlined link, but instead like some kind of typical
double-clickable GUI widget.

Also the hover cursor for links is changed from Hand to Arrow.
2021-01-03 17:25:06 +01:00
William Marlow
05345fc07d LibELF: Support relocating weak symbols against global libraries
A strong symbol anywhere in an executable must override any
weak symbol used in any library. This means that the weak symbol
must be overridden by a strong symbol even if the strong symbol
is in a dependent library. This means we need to perform relocations
twice, and resolve weak symbols globally before attempting to resolve
them locally. Consequentially we need to defer performing any
initialisations until after we have performed the second round of
relocations.
2021-01-03 17:15:55 +01:00
William Marlow
3e815ad5b1 Loader.so+LibELF: Move most of Loader.so's logic into ELF::DynamicLinker
Loader.so now just performs the initial self relocations and static
LibC initialisation before handing over to ELF::DynamicLinker::linker_main
to handle the rest of the process.

As a trade-off, ELF::DynamicLinker needs to be explicitly excluded from
Lagom unless we really want to try writing a cross platform dynamic loader
2021-01-03 17:15:55 +01:00
Emanuele Torre
ec8577ac3c LibGfx+Ports: Add missing newlines at the end of file. 2021-01-03 17:12:50 +01:00
Andreas Kling
7bb18215cb LibGUI: Use String::formatted() and String::number() more 2021-01-03 15:26:47 +01:00
Andreas Kling
f181ddb56a LibGUI: Use String::formatted() and String::number() more 2021-01-03 14:52:50 +01:00
Andreas Kling
5e157eaf37 LibWeb: Convert a bunch of String::format() => String::formatted() 2021-01-03 14:35:09 +01:00
Andreas Kling
70c59dcbf8 LaunchServer+LibDesktop: Add ability to allow URL without handler
This lets clients say they want to be able to open a specific URL
without specifying which handler to use.
2021-01-03 12:10:01 +01:00
Andreas Kling
1f1763c37a LaunchServer+LibDesktop: Add unveil-like mechanism for LaunchServer
Clients of LaunchServer can now provide a list of allowed handlers,
optionally with a specific set of URLs. The list can be sealed to
prevent future additions to it.

If LaunchServer receives a request to open something not on the allowed
handlers list, it will disconnect the client immediately.

The main idea here is to allow otherwise restricted programs to launch
specific things, e.g "Help" to open their manual, or "Browser" to load
the SerenityOS home page. :^)
2021-01-03 11:39:33 +01:00
Andreas Kling
8b2e7628fa LibGUI: Also specialize PgUp/PgDn/Home/End in line-wrapped TextEditors
This exposes some bugs in TextEditor's widget/document coordinate
conversions which we'll need to track down separately.
2021-01-03 10:49:20 +01:00
Andreas Kling
906e310411 LibGUI: Improve up/down arrow behavior in TextEditor with wrapping
Instead of moving between physical lines, the up/down arrow keys now
move between visual lines.
2021-01-03 10:49:20 +01:00
AnotherTest
7f7656fe4e LibGUI: Make the autocomplete box window a child of its editor's window
Fixes #4761.
2021-01-03 10:47:29 +01:00
AnotherTest
432c37cafc LibGUI: Stop the automatic autocomplete timer when typing whitespace
There's no reason to bring up autocomplete when the user is just
inserting indentation and spaces and such.
2021-01-03 10:47:29 +01:00
AnotherTest
3b2668e996 LibGUI: Register the various BoxLayouts
They're not exactly "widgets", but the widget registration registers
Core::Objects anyway.
2021-01-03 10:47:29 +01:00
AnotherTest
2b38b2f83b LibCore: Add a way to check if a property is readonly 2021-01-03 10:47:29 +01:00
Glenford Williams
b795f582cf LibGUI: Add missing properties to Widget gml
Add a few properties to Widget class for usage when in a gml environment
2021-01-03 10:34:55 +01:00
Andrew Kaster
39908fd569 LibGUI: Move widget registrations to the corresponding cpp file
This gets a lot of unecessary includes out of Widget.cpp. Doing this
didn't work before, but improvements in the C library and using dynamic
libraries have likely un-broken it :^).

Also, move the registration global object to an anonymous namespace. No
reason it has to be an extern symbol.
2021-01-03 10:31:42 +01:00
Luke
0bf44ac9d8 LibWeb: Fully implement end tag parsing in foreign content
Required to view the Spotify home page
2021-01-03 00:29:28 +01:00
Linus Groh
306aff80d0 LibGUI: Remove Widget's unused m_{foreground,background}_color
...as well as the few remaining references to set_foreground_color().

These properties are not being used for rendering anymore, presumably
because they completely mess up theming - assigning random white and
gray backgrounds just doesn't work with dark themes.
I've chosen to not replace most of the few remaining uses of this
broken functionality with custom palette colors (the closest
replacement is background_role) for now (except for Minesweeper where
squares with mines are painted red again now), as no one has actually
complained about them being broken, so it must look somewhat decent
(some just look right anyway). :^)

Examples of this are the taskbar buttons, which apparently had a
DarkGray foreground color for minimized windows once - this has since
been replaced with bold/regular font. Another one is the Profiler's
ProfileTimelineWidget, which is supposed to have a white background -
which it didn't have for quite some time, it's grey now (with the
default theme, that is). Doesn't look bad either.
2021-01-02 23:31:22 +01:00
Andreas Kling
05f5d0dda3 LibGfx: Add Gfx::TextAttributes (and use it in GUI::TextDocumentSpan) 2021-01-02 20:57:43 +01:00
Andreas Kling
1898aa8cd4 LibWeb: Use Gfx::Bitmap::create_shareable() in OOPWV
We were jumping through some pretty wasteful hoops in the resize event
handler of OOPWV by first creating a bitmap and then immediately
creating a new (shareable) clone of that bitmap. Now we go straight
to the shareable bitmap instead.
2021-01-02 16:57:31 +01:00
Andreas Kling
0bc8d58c3b LibGfx: Add Gfx::Bitmap::create_shareable(format, size)
This helper allocates a shbuf and returns it wrapped in a Bitmap.
2021-01-02 16:57:31 +01:00
Brian Gianforcaro
fd08c93ef5 LibC: Randomize the stack check cookie value on initialization
Previously we had a static stack check cookie value for LibC.
Now we randomize the cookie value on LibC initialization, this should
help make the stack check more difficult to attack (still possible just
a bigger pain). This should also help to catch more bugs.
2021-01-02 13:55:48 +01:00
Brendan Coles
69e3879b7a LibGUI: CommonActions: Add make_help_action common action 2021-01-02 11:43:25 +01:00
AnotherTest
a4a238ddc8 LibGUI: Add an optional "automatic" autocomplete feature to TextEditor
This aims to be a "smart" autocomplete that tries to present the user
with useful suggestions without being in the way (too much).
Here is its current configuration:
- Show suggestions 800ms after something is inserted in the editor
- if something else is inserted in that period, reset it back to 800ms
  to allow the user to type uninterrupted
- cancel any shown autocomplete (and the timer) on external changes
  (paste, cut, etc)
2021-01-02 11:37:01 +01:00
Brian Gianforcaro
06da50afc7 Build + LibC: Enable -fstack-protector-strong in user space
Modify the user mode runtime to insert stack canaries to find stack corruptions.

The `-fstack-protector-strong` variant was chosen because it catches more
issues than vanilla `-fstack-protector`, but doesn't have substantial
performance impact like `-fstack-protector-all`.

Details:

    -fstack-protector enables stack protection for vulnerable functions that contain:

    * A character array larger than 8 bytes.
    * An 8-bit integer array larger than 8 bytes.
    * A call to alloca() with either a variable size or a constant size bigger than 8 bytes.

    -fstack-protector-strong enables stack protection for vulnerable functions that contain:

    * An array of any size and type.
    * A call to alloca().
    * A local variable that has its address taken.

Example of it catching corrupting in the `stack-smash` test:
```
courage ~ $ ./user/Tests/LibC/stack-smash
[+] Starting the stack smash ...
Error: Stack protector failure, stack smashing detected!
Shell: Job 1 (/usr/Tests/LibC/stack-smash) Aborted
```
2021-01-02 11:34:55 +01:00
Andreas Kling
bf3772362a LibWeb: When collapsing margins, consider border box heights
Empty boxes should be fully collapsed, but a box with border and/or
padding is not empty.

This fixes an issue where <hr> elements were getting weirdly collapsed
since they have zero content height (but some border height.)
2021-01-02 03:48:35 +01:00
Andreas Kling
5116b94114 LibWeb: Fix unnecessary wrapping of block boxes in anonymous blocks
Outside of tables, we don't need to wrap block-level boxes in anymous
blocks. Only inline-level boxes need this treatment.
2021-01-02 03:48:35 +01:00
Andreas Kling
042890d319 LibMarkdown: Parse horizontal rules
A horizontal rule is generated by a line with three or more of these
characters: '*', '-', '_'.
2021-01-02 02:41:15 +01:00
Andreas Kling
b4af4a4085 LibGUI: Allow widget sibling navigation with arrow keys
There's no spatial navigation here, Left/Up moves to the previous
sibling in the tab order, while Right/Down moves to the next.

The arrow keys keep focus within the same parent widget, unlike the tab
key which cycles through all focusable widgets in the window.

This makes GUI::MessageBox feel a bit nicer since you can now arrow
between the Yes/No/Cancel buttons. :^)
2021-01-02 01:56:59 +01:00
Luke
5dfcecd244 Lagom/Fuzzers: Add TTF fuzzer 2021-01-02 01:39:34 +01:00
Luke
ad243ef3aa LibTTF: Add option to load font from a byte buffer 2021-01-02 01:39:34 +01:00
Brian Gianforcaro
84c2be604a
Kernel+LibELF: Use hex instead of decimal for stack offsets in back traces (#4728)
Hex is the de facto format for representing memory addresses, make backtraces
conform to that convention.
2021-01-02 01:38:43 +01:00
Andreas Kling
4cfef0cd95 LibGUI: Tweak MessageBox layout slightly 2021-01-02 01:36:24 +01:00
Andreas Kling
f5384d7c70 LibGUI: Correct selection width when using fonts with glyph spacing
We were not adding the glyph spacing after the last character in the
selection, causing it to be slightly too small in some cases.
2021-01-02 00:39:52 +01:00
Andreas Kling
c1339baba8 LibGUI: Fix cursor height in single-line text boxes
We should use the TextEditor::line_height() for the cursor height,
same as we do in multi-line mode.
2021-01-02 00:35:34 +01:00
Andreas Kling
c381e7f5a0 LibGUI: Add Window::on_close hook
This will be invoked when the window is closed, which is helpful if you
want to remove the window from some kind of owner after it's closed.
2021-01-02 00:35:34 +01:00
Tom
e21cc4cff6 Kernel: Remove MAP_PURGEABLE from mmap
This brings mmap more in line with other operating systems. Prior to
this, it was impossible to request memory that was definitely committed,
instead MAP_PURGEABLE would provide a region that was not actually
purgeable, but also not fully committed, which meant that using such memory
still could cause crashes when the underlying pages could no longer be
allocated.

This fixes some random crashes in low-memory situations where non-volatile
memory is mapped (e.g. malloc, tls, Gfx::Bitmap, etc) but when a page in
these regions is first accessed, there is insufficient physical memory
available to commit a new page.
2021-01-01 23:43:44 +01:00
Andreas Kling
849e2ded24 LibGfx: Tweak color of checkmark in disabled+checked GUI::CheckBox 2021-01-01 23:08:59 +01:00
Andrew Kaster
8d0b4657e7 LibThread: Improve semantics of Thread::join, and remove Thread::quit.
Thread::quit was created before the pthread_create_helper in pthread.cpp
that automagically calls pthread_exit from all pthreads after the user's
thread function exits. It is unused, and unecessary now.

Cleanup some logging, and make join return a Result<T, ThreadError>.
This also adds a new type, LibThread::ThreadError as an
AK::DistinctNumeric. Hopefully, this will make it possible to have a
Result<int, ThreadError> and have it compile? It also makes it clear
that the int there is an error at the call site.

By default, the T on join is void, meaning the caller doesn't care about
the return value from the thread.

As Result is a [[nodiscard]] type, also change the current caller of
join to explicitly ignore it.

Move the logging out of join as well, as it's the user's
responsibility whether to log or not.
2021-01-01 23:01:48 +01:00
Andrew Kaster
7b94ca21b3 LibPthread: Implement destruction of pthread_keys
Add a function to destroy any keys that were set on the current thread
using the algorithm from Dr. POSIX's pthread_key_create. Add some
defines to pthread.h for pthread key use, and implement
pthread_key_delete. It has a prototype in pthread.h, but any program
trying to actually use it would be in for a link-time surprise.

Currently, keys are destroyed either via global destructors, with the
s_key_destroyer object, or in exit_thread. exit_thread is invoked by
pthread_exit, and transitively by pthread_create, via the
pthread_create_helper that ensures all threads created with the pthread
API properly clean up for themselves when they exit gracefully.

A future patch might make s_key_destroyer a C++11 thread_local instead,
assuming we get thread_local and thread_local destructors working.
2021-01-01 23:01:48 +01:00
Andreas Kling
19ffa676f2 LibWeb: Use is<T> in XMLHttpRequestPrototype 2021-01-01 22:41:50 +01:00
asynts
e77031ce67 AK: Deal with unsigned integers in binary search. 2021-01-01 22:23:13 +01:00
Andreas Kling
db790dda62 LibJS: Remove hand-rolled type information in JS AST in favor of RTTI 2021-01-01 19:34:07 +01:00
Andreas Kling
07dd73c351 LibWeb: Remove hand-rolled is_foo() helpers in Layout::Node classes 2021-01-01 18:56:49 +01:00
Andreas Kling
3bb0cb2202 LibWeb: Remove more hand-rolled type information :^)
Hoo boy, we've really accumulated a lot of this stuff.
2021-01-01 18:14:00 +01:00