Commit Graph

20631 Commits

Author SHA1 Message Date
Gunnar Beutner
661d1aa8d1 AK: Add inline storage support for the Function class
This allows us to allocate most Function objects on the stack or as
part of other objects and gets rid of quite a few allocations.
2021-05-19 21:36:57 +02:00
Ali Mohammad Pur
fdfa5c0bc7 Shell: Avoid moving AK::Function instances while inside them 2021-05-19 21:36:57 +02:00
Gunnar Beutner
d954c11f66 Everywhere: Add missing includes for <AK/OwnPtr.h>
Previously <AK/Function.h> also included <AK/OwnPtr.h>. That's about to
change though. This patch fixes a few build problems that will occur
when that change happens.
2021-05-19 21:36:57 +02:00
Justin
45a1a7e1e6 LibC: Add functions for the new statvfs syscalls
This commit adds the statvfs() and fstatvfs() functions into LibC.
2021-05-19 21:33:29 +02:00
Justin
1c3badede3 Kernel: Add statvfs & fstatvfs Syscalls
These syscalls fill a statvfs struct with various data
about the mount on the VFS.
2021-05-19 21:33:29 +02:00
Justin
721a867c65 Kernel: Expose FileSystem's fragment size
This commit will add a fragment_size() function similar to the
block_size() function.
2021-05-19 21:33:29 +02:00
Timothy Flynn
145e246a5e AK: Allow AK::Variant::visit to return a value
This changes Variant::visit() to forward the value returned by the
selected visitor invocation. By perfectly forwarding the returned value,
this allows for the visitor to return by value or reference.

Note that all provided visitors must return the same type - the compiler
will otherwise fail with the message: "inconsistent deduction for auto
return type".
2021-05-19 20:41:09 +02:00
Erik Biederstadt
585e7890cd 3DFileViewer: Move Demos/GLTeapot to Applications/3DFileViewer
Also changes the category to `Graphics`
2021-05-19 19:34:12 +01:00
Erik Biederstadt
132ecfc47b GLTeapot: Adds a help menu to the GLTeapot demo
Having a help menu maintains better consistency with the other GUI apps
 on the system.
2021-05-19 19:34:12 +01:00
Erik Biederstadt
d9dc42fab5 GLTeapot: Adds additional error checking when loading files
- If the 3D file contains no vertices then an error is raised
- If the file is not an OBJ file then an error is raised
2021-05-19 19:34:12 +01:00
Erik Biederstadt
01a5ffdae0 GLTeapot: Add the ability to open 3D files
This change makes it possible for the GLTeapot demo to open any OBJ
file.
2021-05-19 19:34:12 +01:00
Brendan Coles
076cd58817 LibWeb: Support X-Content-Type-Options to opt out of MIME type sniffing 2021-05-19 18:10:43 +01:00
Lenny Maiorani
0681086cad Time: Remove static from function local constexpr variable
Problem:
- Function local `constexpr` variables do not need to be
  `static`. This consumes memory which is unnecessary and can prevent
  some optimizations.
- C-style arrays are not as safe as AK::Arrays and require the user to
  specify the length of the array manually.

Solution:
- Remove `static` keyword.
- Change from C-style array for AK::Array.
2021-05-19 16:24:02 +02:00
Max Wipfli
9cc201fb29 Kernel: Ignore null parent custody without error in VFS::open
This modifies the error checks in VFS::open after the call to
resolve_path to ignore a null parent custody if there is no error, as
this is expected when the path to resolve points to "/". Rather, a null
parent custody only constitutes an error if it is accompanied by ENOENT.
This behavior is documented in the VFS::resolve_path_without_veil
method.

To accompany this change, the order of the error checks have been
changed to more naturally fit the new logic.
2021-05-19 12:27:25 +02:00
Ali Mohammad Pur
73cb566041 AK: Make vout() log to debug instead of VERIFY()'ing
In case the write was to stderr/stdout, and it just so happened to fail
because of an issue like "the pty is gone", VERIFY() would end up
calling vout() back to write to stderr, which would then fail forever
until the stack is exhausted.
"Fixes" the issue where the Shell would crash in horrible ways when the
terminal is closed.
2021-05-19 09:19:29 +02:00
DexesTTP
ed1800547e LibTLS: Enable the RSA_WITH_AES_256_GCM_SHA384 cipher
This is more of an example commit of how to add new ciphers to TLS.
2021-05-19 09:18:45 +02:00
DexesTTP
68f6796e72 LibTLS: Use RSA key exchange based on the cipher
After this, we aren't hardcoding RSA in everything we do anymore!
2021-05-19 09:18:45 +02:00
DexesTTP
9bb823a6ab LibTLS: Generate cipher variants based on the cipher
This is better than using the AEAD flag :^)
2021-05-19 09:18:45 +02:00
DexesTTP
2e9a4bb95c LibTLS: Replace cipher selection with a variant 2021-05-19 09:18:45 +02:00
DexesTTP
851e254e8f LibTLS: Rework method names and arrangement in cpp files
This commit only moves and renames methods. The code hasn't changed.
2021-05-19 09:18:45 +02:00
DexesTTP
6d190b299e LibTLS: Define cipher suite parameters and components in a macro
Instead of sprinkling the definition of the ciper suites all over the
TLS implementation, let's regroup it all once and for all in a single
place, and then add our new implementations there.
2021-05-19 09:18:45 +02:00
DexesTTP
17a1f51579 LibTLS: Move the asn certificate parser to Certificate.cpp 2021-05-19 09:18:45 +02:00
DexesTTP
45d55ecacc LibTLS: Move the cipher list to the CipherSuite.h header 2021-05-19 09:18:45 +02:00
DexesTTP
3d27550ab7 LibCrypto: Make GCM movable 2021-05-19 09:18:45 +02:00
DexesTTP
f11f629731 LibCrypto: Use AK::Variant in HashManager 2021-05-19 09:18:45 +02:00
DexesTTP
73f585ceb4 LibCrypto: Use AK::Variant in MultiHashDigestVariant 2021-05-19 09:18:45 +02:00
DexesTTP
2c1916dd8d LibCrypto: Add the SHA-384 hash algorithm
This is a truncated version of SHA-512, so it was fairly trivial.
2021-05-19 09:18:45 +02:00
brapru
b985eb1613 Utilities: Allow for white spaces in lsof name parsing
Previously lsof would crash by incorrectly parsing valid file names
that contain spaces.

For example, established TCP socket file descriptors would cause an
lsof crash:

	socket:127.0.0.1:33985 / 127.0.0.1:8080 (connected)

This commit fixes the issue by not parsing for white spaces to set the
file name.
2021-05-19 09:13:12 +02:00
Linus Groh
36e7733dec CrashDaemon: Fix CrashReporter argument order
For compressed coredumps, CrashReporter's argv were in this order:

    CrashReporter path --unlink

Core::ArgsParser doesn't like that at all and would immediately exit
from main(), causing the crash reporter to never display.
2021-05-18 23:42:02 +01:00
Marcus Nilsson
7aaef8fd4b Browser: Don't add multiple page reloads to history
When reloading a page multiple times, it was also added multiple
times to the history. This commit prohibits an url to be added
twice in a row.

Fixes #7264

Co-authored-by: Linus Groh <mail@linusgroh.de>
2021-05-18 23:14:37 +01:00
Gunnar Beutner
598d7f4127 AK: StringBuilder should prefer to use its inline capacity first
Previously StringBuilder would start allocating an external buffer
once the caller has used up more than half of the inline buffer's
capacity. Instead we should prefer to use the inline buffer until
it is full and only then start to allocate an external buffer.
2021-05-18 21:49:10 +02:00
Andreas Kling
076018b74b PDFViewer: Ignore wheel events when there is no document loaded 2021-05-18 21:25:35 +02:00
Max Wipfli
f808279769 LibWeb: Implement encoding sniffing algorithm
This patch implements the HTML specification's "encoding sniffing
algorithm", which is used when no encoding can be obtained from the
Content-Type header (either because it doesn't contain a charset=...)
value or the file has not been opened via HTTP (as with local files).

It also modifies the creator of the HTMLDocumentParser to use the new
HTMLDocumentParser::create_with_uncertain_encoding static method, which
runs the encoding sniffing algorithm before instantiating the parser.

This now allows us to load local HTML pages (or remote pages without a
charset specified in the 'Content-Type' header) with a non-UTF-8
encoding such as 'windows-1252'. This would previously crash the
browser. :^)
2021-05-18 21:02:07 +02:00
Max Wipfli
67a9ebc817 LibWeb: Change Document's m_encoding to Optional<String>
This modifies the Document class to use Optional<String> for the
encoding. If the encoding is unknown, the Optional will not have a
value. It also implements the has_encoding() and encoding_or_default()
instance methods, the latter of which will return "UTF-8" as a fallback
if no encoding is present.

The usage of Optional<String> instead of the null string is part of an
effort to explicitly indicate that a string could not have a value.

This also modifies the former callers of encoding() to use
encoding_or_default(). Furthermore, the encoding will now only be set if
it is actually known, rather than just guessed by earlier code.
2021-05-18 21:02:07 +02:00
Max Wipfli
a7681dbeea LibWeb: Change Resource's m_encoding to Optional<String>
This modifies the Resource class to use Optional<String> for the
encoding. If the encoding is unknown, the Optional will not have a
value (instead of using the null state of the String class). It also
implements a has_encoding() instance method and modifies the callers
of Resource::encoding() to use the new API.
2021-05-18 21:02:07 +02:00
Max Wipfli
ce6d6706a6 LibWeb: Use Optional<String> for encoding_from_content_type
This patch changes the encoding_from_content_type function to only
return an encoding if it actually finds one, and leave it up to the
caller to decided on a default to use.

It also modifies the caller to expect an Optional<String> (instead of
relying on the null state of the String class) as a return value and
separates the encoding and MIME type determination. This will be built
upon in a further commit.
2021-05-18 21:02:07 +02:00
Max Wipfli
d325403cb5 LibTextCodec: Use Optional<String> for get_standardized_encoding
This patch changes get_standardized_encoding to use an Optional<String>
return type instead of just returning the null string when unable to
match the provided encoding to one of the canonical encoding names.

This is part of an effort to move away from using null strings towards
explicitly using Optional<String> to indicate that the String may not
have a value.
2021-05-18 21:02:07 +02:00
Max Wipfli
f51b0729f5 AK: Implement StringBuilder::append_as_lowercase(char ch)
This patch adds a convenience method to AK::StringBuilder which converts
ASCII uppercase characters to lowercase before appending them.
2021-05-18 21:02:07 +02:00
Andreas Kling
df29d58e19 PDFViewer+Base: Display application title as "PDF Viewer"
This matches other applications in the system. :^)
2021-05-18 21:00:32 +02:00
Valtteri Koskivuori
eb9a0ace28 LibCore+Userland: Add two more detectable formats
Second batch of detectable formats, this time with verious offsets, as
enabled by the previous commit.
This adds tar, and the three signature variants for iso-9660 image
files.
2021-05-18 19:57:53 +01:00
Valtteri Koskivuori
241b378e4b LibCore: Add offsets to binary signature matching
Some file signatures are at an offset into the file, so we need to be
able to specify an offset to start matching bytes at.
2021-05-18 19:57:53 +01:00
Valtteri Koskivuori
105bbc457d LibCore+Userland: Add 5 more detectable filetypes
This adds gzip, sqlite, 7-Zip, flac and midi.
2021-05-18 19:57:53 +01:00
Jesse Buhagiar
2f49241296 Solitaire: Prevent player dragging entire stack to foundation
Currently, it is possible for the player to drag an entire stack
of cards to the foundation stack, provided the top card of the stack
(i.e the "root" card) can be dropped onto the foundation stack.
This causes an invalid state where, e.g, red cards end up in a
black foundation stack, or vice versa.
2021-05-18 20:05:10 +02:00
Andreas Kling
a743075b9f Browser: Move actions from Tab to BrowserWindow
Navigation actions (back/forward/home/reload) now live in BrowserWindow
instead of being duplicated in every new Tab instance.
2021-05-18 20:02:00 +02:00
Andreas Kling
aed695d4b2 Browser: Move menu management from Tab to BrowserWindow
It was very confusing for every Tab to have their own GUI::Menubar that
got dynamically swapped in/out when switching tabs.

This change moves us to a single menubar per window, and BrowserWindow
is the owner of its own menubar.
2021-05-18 20:02:00 +02:00
Marcus Nilsson
e5367c13d8 CatDog: Remove global menu and add context menu
There was no way to close catdog since it relied on global menus, this
adds a context menu for opening the about dialog and quitting.

Fixes #7252
2021-05-18 18:59:18 +01:00
Dmitrii Ubskii
9c963fa17b Pong: Make the game winnable
- Make the ball chill out a bit by reducing its x velocity by 1.
- Make the AI dumber. It now relaxes until the ball is coming towards it
  and is in its half of the court.
2021-05-18 18:58:07 +01:00
Dmitrii Ubskii
9a7aac1c6a Pong: Fix paddle movement across resets if keys are held
The game waited for the next key down event before moving the player
paddle. Now the state of the arrow keys is carried over between resets.
2021-05-18 18:58:07 +01:00
Dmitrii Ubskii
58131082f4 Pong: Improve mouse controls
Just because you're the player, doesn't mean you can cheat ;)

- Limit paddle speed when following mouse cursor.
- Unhide pointer -- can't grab it, can't see when it's about to leave
  the window otherwise.
- Add last pointer y position indication for the player paddle.
- Prevent the paddle from following the mouse when Up or Down is being
  held (avoid controls fighting).
2021-05-18 18:58:07 +01:00
Dmitrii Ubskii
bb76bcde57 Pong: Improve AI paddle movement
Begin and end triggers for AI paddle to start moving prevent it from
continually jerking around the ball's position. It still moves in steps
of paddle.speed though, but overall experience is smoother.
2021-05-18 18:58:07 +01:00