Commit graph

4633 commits

Author SHA1 Message Date
Andreas Kling
d783076a30 Userland: Rename LibSymbolClient => LibSymbolication 2021-05-22 18:54:22 +02:00
Gunnar Beutner
21cd278b8a Userland: Rename e1k0 to ep0s7 2021-05-22 15:42:54 +01:00
Gunnar Beutner
e087a65775 Userland: Rename loop0 to loop
Now that the kernel picks a different name for the loopback adapter
we should update userland to account for this.
2021-05-22 15:42:54 +01:00
Brendan Coles
e5e00bec8f HexEditor: Construct user interface from GML 2021-05-22 15:41:58 +01:00
Itamar
6738a966ec CppLanguageServer: Add test case for auto-completing include paths 2021-05-22 15:52:11 +02:00
Itamar
c003c3c76d CppLanguageServer+LibGUI: Autocomplete #include paths
The C++ language-server can now autocomplete include paths.

Paths that start with '<' will be searched in /usr/include, and paths
that start with '"' will be searched in the project's root directory.
2021-05-22 15:52:11 +02:00
Itamar
ccd491594f LibGUI: Increase width of Autocomplete suggestions box 2021-05-22 15:52:11 +02:00
Itamar
c4ff7c6f8e LanguageServers: Add FileDB::project_root() getter 2021-05-22 15:52:11 +02:00
Itamar
b50eaf75eb CppLanguageServer: Rename Optional<> autocomplete* to try_autocomplete*
autocomplete_property => try_autocomplete_property
autocomplete_name => try_autocomplete_name

This makes it more clear that these variants may fail because e.g
the node is not a property / not a name.
2021-05-22 15:52:11 +02:00
Itamar
0522a4360b LibCpp: Add option in Preprocessor to keep #include's in processed text 2021-05-22 15:52:11 +02:00
Itamar
14e0011825 LibCpp: Make Preprocessor::handle_preprocessor_line return keyword
This also moves most of the logic that was in handle_preprocessor_line
into handle_preprocessor_keyword.
2021-05-22 15:52:11 +02:00
Itamar
1c3c043cd3 CppLanguageServer: Rename all_definitions=>preprocessor_definitions 2021-05-22 15:52:11 +02:00
Itamar
1f96d9b03a CppLanguageServer: remove no-op move() 2021-05-22 15:52:11 +02:00
Itamar
0c9db38e8f LibCpp: Modify Token::to_string() to include more information
Token::to_string() now includes not only the token's type, but also its
text and span in the document.
2021-05-22 15:52:11 +02:00
Brendan Coles
cdea9f5339 HexEditor: Fix typo: ASCII 2021-05-22 14:24:07 +01:00
Gunnar Beutner
661a8707f0 LibCards: Fix alignment for the card labels
Previously the code didn't take into account that the label for the
"10" card is larger than for the other cards.
2021-05-22 13:15:59 +01:00
Marcus Nilsson
ee48dac300 Bitmap: Don't call Bitmap::create with width/height equal to 0
With very small bitmaps and small scale factor, such as tile.png, the
type conversion in the call to Bitmap:create would cause width or
height to be 0.

Fixes #7352
2021-05-22 13:26:08 +02:00
Gunnar Beutner
1ae18c1228 Hearts: Let the AI pick better lead cards
Instead of picking the card with the lowest value we should pick the
card with the highest value for which we know no lower value card is
in play anymore and that someone else still has an even higher value
card.
2021-05-22 12:03:31 +01:00
Gunnar Beutner
c2a4b581fe Hearts: Prefer to play Queen of Spades when we're the trailing player
Previously in a trick like 2S, KS, 5S we'd rather follow up with AS
instead of QS. We should prefer to play QS in this case.
2021-05-22 12:03:31 +01:00
Gunnar Beutner
0dd22c4e23 Hearts: Fix crash when starting an animation when there already is one
This ensures that the preceding animation is stopped first.
2021-05-22 12:03:31 +01:00
Gunnar Beutner
630430379e LibCards: Correct a spelling mistake 2021-05-22 12:03:31 +01:00
Gunnar Beutner
dfa2075887 Hearts: Remove dead code 2021-05-22 12:03:31 +01:00
Ryan Wilson
1965d60aeb
GameOfLife: Add choosable patterns 2021-05-22 09:54:58 +01:00
Brendan Coles
d1623350b5 HexEditor: Add 'Select All' action 2021-05-22 13:13:49 +04:30
Andreas Kling
ee5cf92b3d LibVT: Don't cache bold variant of VT font in a member variable
Remove some leftovers from back when we had to resolve a bold variant
of the terminal font manually. Now we can just use bold_variant().
2021-05-22 10:21:52 +02:00
Andreas Kling
636c43db6c WindowServer: Notify window-less clients about theme/font changes 2021-05-22 10:21:52 +02:00
Tobias Christiansen
155d876c44 LibGfx: Support alpha in rendering methods for border-radius
The methods used in displaying border-radius were ignoring alpha.
2021-05-22 00:21:02 +02:00
Lenny Maiorani
6ac454e70a DevTools: Remove redundant default destructor and forward declarations
Problem:
- Default destructors (and constructors) are in `.cpp` files. This
  prevents the compiler's optimizer from inlining them when it thinks
  inlining is appropriate (unless LTO is used).
- Forward declarations can prevent some optimizations, such as
  inlining of constructors and destructors.

Solution:
- Remove them or set them to `= default` and let the compiler handle
  the generation of them.
- Remove unneeded forward declarations.
2021-05-21 22:53:33 +01:00
Luke
4d34802f74 LibJS: Expose TypedArray.prototype.byteOffset 2021-05-21 22:52:35 +01:00
Luke
58afd71ad2 LibJS: Expose TypedArray.prototype.byteLength 2021-05-21 22:52:35 +01:00
Luke
8004a2dc77 LibJS: Expose TypedArray.prototype.buffer 2021-05-21 22:52:35 +01:00
Luke
6f1688279a LibJS: Expose BYTES_PER_ELEMENT on each TypedArray 2021-05-21 22:52:35 +01:00
Gunnar Beutner
c3efae85f2 Games: Add Hearts 2021-05-21 23:38:18 +02:00
Gunnar Beutner
3e47eec862 Solitaire: Move cards functionality into LibCards 2021-05-21 23:38:18 +02:00
Max Wipfli
9440a3c280 LibWeb: Improve Unicode compatibility of HTML contenteditable
This patch updates the Page::keydown_event event handler to implement
crude Unicode support. It implements new method in EditEventHandler to
more easily handle deleting a single character after the cursor.
Furthermore, it makes use of the previously implemented methods to
increment and decrement the cursor position, which take into account
that Unicode codepoint may be multiple bytes wide.

This means it is now possible to mostly edit Unicode in editable DOM
nodes without any crashes. :^)
2021-05-21 21:57:03 +02:00
Max Wipfli
7181cb3a9c LibWeb: Frame/Position: Implement cursor increment/decrement methods
This introduces methods to increment and decrement the cursor position.
This is non-trivial as the cursor position is specified in bytes rather
than codepoints. Thus, it sometimes needs to be incremented or
decremented by more than one, depending on the codepoint to "jump over".

Because the cursor blink cycle needs to be reset after moving the
cursor, methods calling the ones in DOM::Position are implemented in
Frame. Furthermore, this allows the cursor_position() getter to stay
const. :^)

Additionally, it adds a offset_is_at_end_of_node() method which checks
if the current offset points to the end of the node.
2021-05-21 21:57:03 +02:00
Max Wipfli
08d09c4afb LibWeb: Improving cursor behavior in editable DOM nodes
This patch makes two modifications to improve the behavior of cursors in
editable DOM nodes, such as HTML tags with the contenteditable
attribute.

When the cursor blink cycle is reset in an editable DOM node, a repaint
should be initiated. For this, set_needs_display() needs to be called on
the layout node. Previously, the cursor blink cycle would not reset
properly and moving the cursor with the arrow keys did not feel
intuitive.

Furthermore, this modifies one of the conditions necessary to actually
paint the cursor, which previously prevented it from being painted when
at the end of a text node, after all the text present.
2021-05-21 21:57:03 +02:00
Max Wipfli
d7df6de6a6 LibWeb: Do nothing when pressing modifier keys in HTML contenteditable
Before this patch, pressing modifier keys such as Ctrl would insert
whitespace into editable DOM nodes. This patch crudely fixes that
behavior by checking if the codepoint associated with the event is
non-zero.
2021-05-21 21:57:03 +02:00
Max Wipfli
157f72e9d7 LibWeb: Replace some TODO() calls with FIXME comments in EventHandler
This patch downgrades some TODO() calls when the cursor in an editable
DOM node should move to the previous or next node. Previously, the
process would crash, whereas now, the cursor will just stay where it
was.

This seems more sensible for now, as there is no reason to crash just
because of this.
2021-05-21 21:57:03 +02:00
Andrew Kaster
c6eff55439 Shell: Make sure all tests put their temp dirs in /tmp
Follow-on to #7337. Been seeing other CI test failures that point to
these temp directories, so let's just move all of them to /tmp. I'm sure
someone will write ext2fs stress tests later :^)

Example:

/usr/Tests/Shell/control-structure-as-command.sh
  Core::Socket: Failed to connect() to /tmp/portal/inspectables: ...
  + rm -rf shell-test 2>/dev/null
  + mkdir shell-test
  Error: The action has timed out.
2021-05-22 00:24:27 +04:30
Linus Groh
3a4cbbf01c LibJS: Fix indexed access of TypedArray with byte offset
By doing the offset calculation in {get,put}_by_index() we would
delegate these operations to Object for any index >= (array length -
byte offset). By doing the offset calculation in data() instead, we can
just use the unaltered property index for indexing the returned Span.
In other words: data()[0] now returns the same value as indexing the
TypedArray at index 0 in JS.

This also fixes a bug in the js REPL which would not consider the byte
offset and subsequently access the underlying ArrayBuffer data with a
wrong index.
2021-05-21 19:29:23 +01:00
Linus Groh
9003dd907e js: Don't print newline for empty ArrayBuffer
If we don't have any bytes to print in hex representation, just return
early instead of printing a newline in preparation for the data that
won't follow. :^)
2021-05-21 19:29:23 +01:00
Andreas Kling
be3f4c86de DisplaySettings: Restrict selection of fixed-width fonts
Only allow fixed-width fonts to be the system fixed-width font. :^)
2021-05-21 20:15:51 +02:00
Andreas Kling
59fd1f40ce WindowServer: Store system font queries in WindowServer.ini :^)
Changes to the system font settings are now persisted in /etc.
Note that you still need to restart the system for changes to fully
apply in all programs.
2021-05-21 20:15:51 +02:00
Andreas Kling
8ac0d4abe1 DisplaySettings: Add "Fonts" tab
This allows you to view, edit, and apply changes to the system fonts.
2021-05-21 20:15:51 +02:00
Andreas Kling
c778130d63 WindowServer+LibGUI: Add an IPC API to change the current system fonts
This patch adds a set_system_fonts() IPC API that takes the two main
font queries as parameters. We'll probably expand this with additional
queries when we figure out what they should be.

Note that changing the system fonts on a live system mostly takes
effect in newly launched programs. This is because GUI::Widget will
currently cache a pointer to the Gfx::FontDatabase::default_font()
when first constructed. This is something we'll have to fix somehow.

Also note that the settings are not yet persisted.
2021-05-21 20:15:51 +02:00
Andreas Kling
bb23e61fbf LibGfx+WindowServer: Have WindowServer broadcast system font settings
Instead of everybody getting their system fonts from Gfx::FontDatabase
(where it's all hardcoded), they now get it from WindowServer.

These are then plumbed into the usual Gfx::FontDatabase places so that
the old default_font() and default_fixed_width_font() APIs keep working.
2021-05-21 20:15:51 +02:00
Tobias Christiansen
66ad739934 LibWeb: Ignore vendor-specific CSS properties
If we can't parse a property we previously a log-line was generated.
However it is in our best interest to simply ignore vendor-specific
properties (e.g -moz-something or -webkit-something) since they are not
part of the spec.
The vendor-specific-ness is determined by looking whether the property
starts with '-'.
If we want to support some vendor-specific stuff, this doesn't get in
the way since this check takes place after the parser determined that
the current property is invalid.
This cuts down the log-noise of the parser.
2021-05-21 20:11:22 +02:00
Max Wipfli
229414b002 Applications: Use titlecase and distinct underlined characters in menus
This changes (context) menus across the system to conform to titlecase
capitalization and to not underline the same character twice (for
accessing actions with Alt).
2021-05-21 18:41:28 +01:00
Linus Groh
95a11d5737 FileManager: Change shortcut of Display Settings desktop option
'D' is already used by 'New Directory', let's use 'S'.

Fixes #7350.
2021-05-21 17:56:10 +01:00
Jagger De Leo
1d959a7b81 DisplaySettings: Allow deselection of background image
Previously, if you selected a background image you could not revert to a
solid color background.
2021-05-21 21:17:30 +04:30
Andreas Kling
6048e245ee 3DFileViewer: Make the main widget a GUI::Frame 2021-05-21 16:14:40 +02:00
Andreas Kling
8a3e622538 Browser: Stop leaking popup windows
We were leaking the "view source" and "downloading file" windows for
some reason, presumably it was necessary when these were first added.
Since they are owned by the spawning browser window, there's no need
to leak them.
2021-05-21 15:32:53 +02:00
Andreas Kling
81641ee469 LibWeb: Make tag names bold in syntax-highlighted HTML :^) 2021-05-21 15:32:53 +02:00
Linus Groh
d60ebbbba6 Revert "Userland: static vs non-static constexpr variables"
This reverts commit 800ea8ea96.

Booting the system no longer worked after these changes.
2021-05-21 10:30:52 +01:00
Lenny Maiorani
68f76b9e37 Userland: Change typedef to using directive
Problem:
- `typedef`s are read backwards making it confusing.
- `using` statements can be used in template aliases.
- `using` provides similarity to most other C++ syntax.

- C++ core guidelines say to prefer `using` over `typedef`:
  https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#Rt-using

Solution:
- Switch these where appropriate.
2021-05-21 10:07:22 +01:00
Lenny Maiorani
800ea8ea96 Userland: static vs non-static constexpr variables
Problem:
- `static` variables consume memory and sometimes are less
  optimizable.
- `static const` variables can be `constexpr`, usually.
- `static` function-local variables require an initialization check
  every time the function is run.

Solution:
- If a global `static` variable is only used in a single function then
  move it into the function and make it non-`static` and `constexpr`.
- Make all global `static` variables `constexpr` instead of `const`.
- Change function-local `static const[expr]` variables to be just
  `constexpr`.
2021-05-21 10:07:06 +01:00
Andrew Kaster
413d98fb45 Shell: Use /tmp for all file operations valid.sh test
Not doing so sometimes intermittently caused the '*' glob expansion test
to fail and lock up the shell.
2021-05-21 13:30:45 +04:30
Andrew Kaster
a5889b9aad Shell: Hide job times behind SHELL_JOB_DEBUG flag 2021-05-21 12:05:34 +04:30
Ali Mohammad Pur
1822d6b8ac LibWeb: Fix invalid behaviour of HTMLTokenizer::skip() and restore_to()
skip() is supposed to end up keeping the previous iterator only one
index behind the current one, and restore_to() should actually do the
restore instead of just removing the now-useless source positions.
Fixes #7331.
2021-05-21 09:22:35 +02:00
Linus Groh
9dd3203cc6 LibGfx: Add missing TextAlignment::BottomLeft 2021-05-21 08:04:31 +02:00
Ali Mohammad Pur
8cbdcffd05 LibWasm: Print instruction arguments too 2021-05-21 00:15:23 +01:00
Ali Mohammad Pur
207379165f LibWasm: Fix nested structured instruction parsing
Previously, the ip would not be propagated correctly, and we would
produce invalid jumps when more than one level of nesting was involved.
This makes loops work :P
2021-05-21 00:15:23 +01:00
Ali Mohammad Pur
29b193d25d LibWasm: Resolve labels starting from the top of the stack
Otherwise "label index 0" would be the first ever created label, not the
last one (as the spec wants) :^(
2021-05-21 00:15:23 +01:00
Ali Mohammad Pur
35b3ae26ed LibWasm: Implement a very basic linker
This will simply "link" any given module instances and produce a list of
external values that can be used to instantiate a module.
Note that this is extremely basic and cannot resolve circular
dependencies, and depends on the instance order.
2021-05-21 00:15:23 +01:00
Ali Mohammad Pur
3283c8a495 LibWasm: Make the instantiation process produce an OwnPtr
Managing the instantiated modules becomes a pain if they're on the
stack, since an instantiated module will eventually reference itself.
To make using this simpler, just avoid copying the instance.
2021-05-21 00:15:23 +01:00
Ali Mohammad Pur
efb106069b LibWasm: Decouple ModuleInstance from the AbstractMachine
This fixes a FIXME and will allow linking only select modules together,
instead of linking every instantiated module into a big mess of exported
entities :P
2021-05-21 00:15:23 +01:00
Ali Mohammad Pur
541091500c LibWasm: Trap instead of VERIFY()'ing
...unless something really is an assertion.
2021-05-21 00:15:23 +01:00
Ali Mohammad Pur
b3c13c3e8a LibWasm+Meta: Add test-wasm and optionally test the conformance tests
This only tests "can it be parsed", but the goal of this commit is to
provide a test framework that can be built upon :)
The conformance tests are downloaded, compiled* and installed only if
the INCLUDE_WASM_SPEC_TESTS cmake option is enabled.
(*) Since we do not yet have a wast parser, the compilation is delegated
to an external tool from binaryen, `wasm-as`, which is required for the
test suite download/install to succeed.
This *does* run the tests in CI, but it currently does not include the
spec conformance tests.
2021-05-21 00:15:23 +01:00
r-paiva
943f4eb287 LibCore: Let IODevice::can_read_line() buffer until \n or EOF
If a line was larger than 1024 bytes or the file ended without a
newline character, can_read_line would return false.

IODevice::can_read_line() now reads until a newline is found or
EOF is reached.

fixes #5907
2021-05-20 23:53:06 +02:00
r-paiva
68de9008e7 Utilities: Fix grep match when reading from stdin
When reading from stdin, grep discards the last character,
even if that character is not \n.

This commit changes grep to no longer discard the last character from
a line.
2021-05-20 23:53:06 +02:00
Stephan Unverwerth
eed0bcaf42 LibGL: Implement glHint() 2021-05-20 23:29:56 +02:00
Gunnar Beutner
2a16c8bdb8 3DFileViewer: Clean up file handling
This unifies how 3DFileViewer handles the initial file when starting
the application and when opening files later on via the menu.

Errors are shown both for the initial load as well as when loading
files later on. An error during file load no longer clears the
existing model.

It also adds support for specifying the filename as a command-line
argument.

The opened file's name is shown in the titlebar.
2021-05-20 22:22:56 +02:00
Gunnar Beutner
728e6dad73 3DFileViewer: Move the example model into the home directory 2021-05-20 22:22:56 +02:00
Andreas Kling
1e0d855fdf TextEditor: Don't launch a WebContent process until it's needed
The HTML and Markdown preview modes both use an OutOfProcessWebView to
render the preview pane, and we were instantiating this view from GML.
This caused us to always spawn a WebContent process alongside every
TextEditor instance.

Fix this by deferring the OOPWV construction until we actually need it.
This makes launching TextEditor on a text file quite a bit faster. :^)
2021-05-20 22:12:42 +02:00
Andreas Kling
e95e64972c Clipboard+LibGUI: Remove unnecessary client/server greeting message 2021-05-20 22:12:42 +02:00
Andreas Kling
ec8363aec3 WindowServer+LibGUI: Make client/server greeting faster
Instead of doing a full IPC round-trip for the client and server to
greet each other upon connecting, the server now automatically sends
a "fast_greet" message when a client connects.

The client simply waits for that message to arrive before proceeding.
(Waiting is necessary since LibGUI relies on the palette information
included in the greeting.)
2021-05-20 22:12:42 +02:00
Andreas Kling
1150e9fe79 LibGfx: Remove unused current_system_theme() function 2021-05-20 22:12:42 +02:00
Max Wipfli
4cd8ca07e3 FontEditor: Make statusbar text generation more robust
This makes a few modifications to the statusbar text generation:
* Use the canonical U+XXXX representation of unicode characters.
* For control characters, display their alias instead of whitespace.
* Substitute RTL codepoints with U+FFFD so the text paints correctly.
* Only show the glyph's dimensions if it actually exists in the font.

This fixes #7286.
2021-05-20 22:10:45 +02:00
Max Wipfli
621a4008e6 FontEditor: Add tooltip to "Move Glyph" button
This adds a simple tooltip to the "Move Glyph" button to indicate its
functionality.
2021-05-20 22:10:45 +02:00
Tobias Christiansen
adfdfd6aba LibWeb: Deal with Boxes that have a background, border and -radius
This hack allows for Boxes that have a background to be painted and a
border to accurately paint their border-radii if needed.
For that the box in with the background is drawn is extended to the
bordered_rect. The border is later drawn over this regardless.
Previously when drawing a Box that had all three, background, border
and a border-radius, there could be some white between the filling and
the border.
2021-05-20 22:08:02 +02:00
Tobias Christiansen
a49812cb07 LibWeb: Take border-radius into account when painting borders
This applies to thicker borders. When drawing them we now don't
chamfer the corner if there is a border-radius present.
2021-05-20 22:08:02 +02:00
Tobias Christiansen
7a566e54e5 LibWeb: Introduce struct to hold border radii and normalize once
The struct BorderRadiusData contains the four radii of the box.
In case the specified borders are too large for the dimensions of the
box, they get scaled down.
2021-05-20 22:08:02 +02:00
Tobias Christiansen
c31046d952 LibWeb: Draw rounded corners for the backgrounds of Boxes
Even if the Box doesn't have a border-radius, we'll pass the rendering
of the Box and its corners to the Painter.
2021-05-20 22:08:02 +02:00
Tobias Christiansen
9e04c0598b LibWeb: Basic rendering of border-radius
It supports all four corners.
2021-05-20 22:08:02 +02:00
Tobias Christiansen
8b63c2a10e LibGfx: Add Painter::draw_circle_arc_intersecting()
This adds a function to draw a circle specified by a center point (
relative to the given Rect) and a radius. The circle arc is only drawn
inside the specified Rect as to allow for circle arc segments.
Technically this was already possible using draw_elliptical_arc(), but
the algorithm is quite involved and lead to wonky arcs when trying to
draw circle arc segments.
2021-05-20 22:08:02 +02:00
Tobias Christiansen
819e0e0440 LibGfx: Add Painter::fill_rect_with_rounded_corners()
This paints a rectangle with rounded corners each specified by a
radius.
2021-05-20 22:08:02 +02:00
Tobias Christiansen
520441d472 LibWeb: Resolve shorthand for border-radius
This takes care of the 1, 2, 3 and 4 parameter shorthand of the border-
radius identifier.
There are more as well as the ominous '/' character but that is for
another time. The 2 and 3 parameter versions are weird enough already.
I don't think anybody uses anything other than the 1 or 4 parameter
version or even the elliptical stuff.
2021-05-20 22:08:02 +02:00
Tobias Christiansen
499934a848 LibWeb: Make border-radius attibutes accessible 2021-05-20 22:08:02 +02:00
Tobias Christiansen
0c261a1c95 LibWeb: Add border-radius to the CSS-parser
And resolve the shorthands.
2021-05-20 22:08:02 +02:00
Tobias Christiansen
d13526e1e7 LibWeb: Handle background-painting of Box in seperate function 2021-05-20 22:08:02 +02:00
Tobias Christiansen
ff0b3518fa LibWeb: Move the painting of the border out of paint()
So other Boxes can override this function.
2021-05-20 22:08:02 +02:00
Gunnar Beutner
3f42d39dce Solitaire: Fix a spelling mistake in one of the variable names 2021-05-20 22:07:20 +02:00
Ali Mohammad Pur
dc388297eb TextEditor+Browser: Enable HTML syntax highlighting on HTML documents 2021-05-20 22:06:45 +02:00
Ali Mohammad Pur
97a230e4ef LibWeb: Add a super basic HTML syntax highlighter
This can currently highlight tag names and attribute names/values.
2021-05-20 22:06:45 +02:00
Ali Mohammad Pur
aa7939bc6c LibWeb: Add position tracking information to HTML tokens 2021-05-20 22:06:45 +02:00
Ali Mohammad Pur
fd982f6562 LibWeb: Sort CMakeLists SOURCES entries 2021-05-20 22:06:45 +02:00
Andreas Kling
54f6ac1854 LibGUI: Don't mark "open" FilePicker as done if the file is not found
If you type in a filename that doesn't exist, show an error message
instead of closing the FilePicker "successfully."
2021-05-20 20:55:29 +02:00
Andreas Kling
9b9966b63b LibGUI: Make GUI::FilePicker handle absolute paths better
Some people apparently like to type in full absolute paths into the
filename box of GUI::FilePicker. So let's handle that as you'd expect
by using the full path as the selected path.
2021-05-20 20:55:29 +02:00
Andreas Kling
3773e72752 LibGUI: Tweak API for getting the selected path
Return a String instead of a LexicalPath. Also call it a path instead
of a file since that's what we're really returning.
2021-05-20 20:55:29 +02:00
Andreas Kling
8a6c37deef LibGfx: Remove Gfx::FontDatabase::default_bold_fixed_width_font()
Ask for a bold_variant() of the default_fixed_width_font() instead.
2021-05-20 20:55:29 +02:00
Andreas Kling
6a012ad79f LibGfx: Remove Gfx::FontDatabase::default_bold_font()
Instead use default_font().bold_variant() in cases where we want a bold
variant of the default font. :^)
2021-05-20 20:55:29 +02:00
Brendan Coles
3bbae6c18b HexEditor: find_and_highlight: Limit search to remaining buffer size 2021-05-20 18:40:18 +02:00
Andreas Kling
93ef661914 WindowServer+DisplaySettings: Remove the weird "simple" wallpaper mode
Painting the wallpaper at 100% scale in the top left corner is a weird
mode and I don't think we need it. :^)
2021-05-20 17:52:38 +02:00
Andreas Kling
3046b3467c DisplaySettings: Improve wallpaper preview code
Previously, this code would create a bitmap with the size of the screen
resolution, draw the new wallpaper into it, and then scale it down for
display inside the MonitorWidget.

This was done on every paint event, which made the code quite slow and
allocation-happy.

Instead of this, we now scale down the new wallpaper to a miniature
of the same scale as the little MonitorWidget screen. The miniature is
then used for tiling, etc. The miniature is cached and reused across
paint events if nothing else changes.
2021-05-20 17:52:38 +02:00
Andreas Kling
df5f382b50 3DFileViewer: Remove unveil() calls and add "thread" pledge
An application that allows opening arbitrary files from the filesystem
needs to allow itself to access the filesystem, otherwise there's no
point in supporting the feature. :^)

And the "thread" pledge is needed for background thumbnail generation.
2021-05-20 17:52:38 +02:00
Ali Mohammad Pur
c6b12841ee Meta: Make generate_state_machine() generate a proper target
And use GENERATED_SOURCES (or add_dependencies) to make LibVT depend on
that target.
Fixes a FIXME.
2021-05-20 12:11:27 +01:00
Josh Perry
c46ab4fbb9
LibChess: Fixed PGN export bug (#7300)
In cases with ambiguous captures involving pawns (where multiple pieces
could have made the capture), we were exporting invalid syntax for
the move:

`1. e4 e5 2. Bb5 c6 3. Bxc6 ddxc6`

Move 3 should be `Bxc6 dxc6`, but we were duplicating the d on the pawn
move.
2021-05-20 08:32:19 +02:00
Anand
4a2dd5bf66 Inspector: Throw an error when inspecting a process it has no access to 2021-05-20 08:21:48 +02:00
Linus Groh
9c19e62675 LibMarkdown: Wrap code block language string in escape_html_entities()
This would allow HTML injection as the string was inserted into the HTML
output with no sanitation whatsoever.

Fixes #7123.
2021-05-19 23:31:00 +01:00
Andreas Kling
0a70e1728a DisplaySettings: Fix broken path to MonitorSettingsWidget's GML 2021-05-20 00:25:15 +02:00
Linus Groh
c2fb252ebf LibWeb: Use -libweb-palette-base-text for text color in default CSS
This makes un-styled text readable when using a dark system theme,
previously such text would be black, regardless of the theme background
color.

Fixes #7274.
2021-05-19 23:23:48 +01:00
Andreas Kling
6394ea00d8 DisplaySettings: Remove icon from browse-for-wallpaper button
The icon on this button looked out of place.
2021-05-20 00:13:56 +02:00
Andreas Kling
7f206ca6de DisplaySettings: Select the currently used wallpaper on startup 2021-05-20 00:03:30 +02:00
Andreas Kling
7ba644456e LibGUI: Don't invalidate FileSystemModel indices on thumbnail update
Finishing a thumbnail generation doesn't affect indices at all.
2021-05-20 00:03:30 +02:00
Andreas Kling
bb9e955ef8 DisplaySettings: Make MonitorWidget update itself on property changes 2021-05-20 00:03:30 +02:00
Andreas Kling
c79e33d00c DisplaySettings: Rename DisplaySettingsWidget => MonitorSettingsWidget 2021-05-20 00:03:30 +02:00
Andreas Kling
540acc1a32 DisplaySettings: Give the UI a facelift :^)
- Split the main UI into two tabs: "Background" and "Monitor".
- Use a GUI::IconView for selecting background pictures.
- Tweak layout, spacing, etc.
2021-05-20 00:03:30 +02:00
Andreas Kling
ff519e5421 LibGUI: Add widget registration for GUI::IconView 2021-05-20 00:03:30 +02:00
Andreas Kling
c14ffdef00 DisplaySettings: Tweak main window layout & setup code
Get rid of the menu and put some padding around the main tab widget.
2021-05-20 00:03:30 +02:00
Andreas Kling
83f43b6464 DisplaySettings: Replace the monitor image with something more thematic
This is a drawing of my own monitor in a familiar style. :^)
2021-05-20 00:03:30 +02:00
Ali Mohammad Pur
a57f152ec7 LibHTTP: Relax the assertion on extra reads after transfer is finished
This was added in #4831, but it didn't account for extra newlines after
the response (seems like some servers like to do this).
2021-05-19 23:57:04 +02:00
Itamar
832e9c6e02 LibCpp: Add regression tests for the parser
For each .cpp file in the test suite data, there is a .ast file that
represents the "known good" baseline of the parser result.

Each .cpp file goes through the parser, and the result of
invoking `ASTNode::dump()` on the root node is compared to the
baseline to find regressions.

We also check that there were no parser errors when parsing the .cpp
files.
2021-05-19 23:19:07 +02:00
Itamar
fbf796cd9f LibCpp: Fix "NumricLiteral" => "NumericLiteral" typo 2021-05-19 23:19:07 +02:00
Itamar
402483ec1f LibCpp: Generalize ASTNode::dump() to support redirecting its output
Previously, ASTNode::dump() used outln() for output, which meant it
always wrote its output to stdout.

After this commit, ASTNode::dump() receives an 'output' argument (which
is stdout by default). This enables writing the output to somewhere
else.

This will be useful for testing the LibCpp Parser with the output of
ASTNode::dump.
2021-05-19 23:19:07 +02:00
Itamar
463a91c4a2 Utilities: Rename CppParserTest => cpp-parser
This is a utility program that runs the LibCpp parser on a program and
dumps out the AST.
2021-05-19 23:19:07 +02:00
Itamar
ef95ddcbfa LibCpp: Fix match_expression()
match_expression() will now return true if there's a match for a Name
node.
2021-05-19 23:19:07 +02:00
Itamar
f28d944122 LibCpp: Support 'auto' Type 2021-05-19 23:19:07 +02:00
Itamar
eeb98335d5 CppLanguageServer: Put cpp test files in /home/anon/cpp-tests/
This is similar to the LibJS test data that resides in
/home/anon/js-tests.
It's more convenient than storing the test programs as raw strings
in the code.
2021-05-19 23:19:07 +02:00
Stephan Unverwerth
28ed518142 LibGL: Implement all of glVertex{2,3,4}{d,dv,f,fv,i,iv,s,sv} 2021-05-19 23:18:13 +02:00
Marcus Nilsson
41e74d4d31 CatDog: Don't show context menu when clicking outside of widget
The context menu for CatDog was shown when right clicking anywhere on
the screen because of global cursor tracking being enabled.
Also fix event not being passed by reference.

Fixes #7285
2021-05-19 23:14:07 +02:00
Brian Gianforcaro
83fc591cea Kernel: Generate page fault events from the kernel profiler
Hook the kernel page fault handler and capture page fault events when
the fault has a current thread attached in TLS. We capture the eip and
ebp so we can unwind the stack and locate which pieces of code are
generating the most page faults.

Co-authored-by: Gunnar Beutner <gbeutner@serenityos.org>
2021-05-19 22:51:42 +02:00
Gunnar Beutner
6ac1ca5a9a Profiler: Remove ability to filter Kernel::Scheduler::yield() frames
Hiding those frames doesn't really make sense. They're a major
contributor to a process' spent CPU time and show up in a lot of
profiles. That however is because those processes really do spend
quite a bit of time in the scheduler by doing lots of context
switches, like WindowServer when responding to IPC calls.

Instead of hiding these for aesthetic reasons we should instead
improve the scheduler.
2021-05-19 22:51:42 +02:00
Gunnar Beutner
277f333b2b Kernel: Add support for profiling kmalloc()/kfree() 2021-05-19 22:51:42 +02:00
Gunnar Beutner
572bbf28cc Kernel+LibC: Add support for filtering profiling events
This adds the -t command-line argument for the profile tool. Using this
argument you can filter which event types you want in your profile.
2021-05-19 22:51:42 +02:00
Gunnar Beutner
8b2ace0326 Kernel: Track performance events for context switches 2021-05-19 22:51:42 +02:00
Ali Mohammad Pur
c94440860e LibCrypto: Use the new return-from-Variant::visit() mechanism
And simplify the code _even further_!
2021-05-19 22:45:34 +02:00
Maciej Zygmanowski
4aaf8df865 Browser: Do not use AK::Format for search engine formatting
It is too complex because it supports many options that are not
used by the search engine. It just makes format validation more
complicated.

Additionaly, now it's possible to have { } characters in search
engine URL (although they are not valid URL characters) :)
2021-05-19 20:51:51 +01:00
Maciej Zygmanowski
78bc6c09ba Browser: Add support for custom search engines 2021-05-19 20:51:51 +01: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
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
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
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
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
Dmitrii Ubskii
7c67c9b45f Pong: Fix score display
Player 1's score used to be score's width offset to the right. Now it's
score_margin away from the divider line, same as player 2's.

Also factored out score margin and increased it from 2px to 5px just
to make it look a little nicer.
2021-05-18 18:58:07 +01:00
Ali Mohammad Pur
d897abf4c2 LibWeb: Implement test-web in terms of LibTest/JavaScriptTestRunner
This deduplicates the test-js copy-ism :^)
2021-05-18 18:48:15 +01:00
Ali Mohammad Pur
f137c1bfaa LibJS+LibTest: Move out the test-js test runner into LibTest 2021-05-18 18:48:15 +01:00
Timothy Flynn
547c7ba57f Solitaire: Display high score in status bar 2021-05-18 17:57:23 +02:00
Timothy Flynn
3d3a75f1b9 Solitaire: Track and persist high score 2021-05-18 17:57:23 +02:00
Timothy Flynn
7d062d0033 Solitaire: Persist game mode to config file 2021-05-18 17:57:23 +02:00
Timothy Flynn
8afaa7f30e 2048: Display action status tips in status bar 2021-05-18 16:48:39 +02:00
Timothy Flynn
97cee35471 2048: Do not default to only temporarily applying settings changes
Also tweak its text in the settings window to be clearer on what this
check box is doing. Seemed a bit confusing that settings changes
required an extra action to persist.
2021-05-18 16:48:39 +02:00
Timothy Flynn
1a66f487a5 2048: Widen the settings window
It's currently too small to fit the text of some of the settings (in
particular, the "Target tile" text).
2021-05-18 16:48:39 +02:00
Timothy Flynn
f02a13c884 2048: Intialize settings window with current values
Currently, each time you open the settings window in 2048, it displays
the default values rather than the current values. This is confusing, so
display the current values instead.
2021-05-18 16:48:39 +02:00
Matthew Olsson
fe2d4d85c4 PDFViewer: Add some padding to the outside of the page 2021-05-18 16:35:23 +02:00
Matthew Olsson
c3c2121b57 PDFViewer: Allow zooming in and out + scrolling
When holding ctrl and scrolling, the page will be zoomed in an out.
When zoomed in on a page, scrolling with move vertically up and down
the page (or horizontally if shift is being held).

In order to speed up zooming, zoomed bitmaps are cached per-page at
each distinct zoom level. This cache is cleared every 30 seconds to
prevent OOM problems.
2021-05-18 16:35:23 +02:00
Matthew Olsson
d5f94aaa7b LibPDF/PDFViewer: Support rotated pages 2021-05-18 16:35:23 +02:00
Matthew Olsson
fbe712e265 LibGfx: Rename RotationDirection members
Left => CounterClockwise
Right => Clockwise

Makes much more sense for a rotation
2021-05-18 16:35:23 +02:00
Matthew Olsson
f7ea1eb610 Applications: Add a very simple PDFViewer 2021-05-18 16:35:23 +02:00
Matthew Olsson
309105678b LibPDF: Fix bad resolve_to calls in Document
We can't call resolve_to with IndirectValue{,Ref}, since the values
will obviously be resolved, and will not give us the object of the
correct type.
2021-05-18 16:35:23 +02:00
Matthew Olsson
4479c1bff0 LibPDF: Add a bitmap renderer
This commit adds the Renderer class, which is responsible for rendering
a page into a Gfx::Bitmap. There are many improvements to make here,
but this is a great start!
2021-05-18 16:35:23 +02:00
Matthew Olsson
d6a9b41bac LibPDF: Parse page crop box and user units 2021-05-18 16:35:23 +02:00
Matthew Olsson
101639e526 LibPDF: Parse graphics commands 2021-05-18 16:35:23 +02:00
Matthew Olsson
03649f85e2 LibPDF: Don't rely on a stream's /Length key existing
Some PDFs omit this key apparently, but Firefox opens them fine. Let's
emulate that behavior.
2021-05-18 16:35:23 +02:00