Commit graph

14949 commits

Author SHA1 Message Date
Sam Atkins 1ba6974b60 cmp: Implement cmp(1) 2022-03-19 11:01:49 -07:00
Sam Atkins 25c2a76d10 LibMain: Add the ability to configure the exit code on error
Some POSIX utilities are specified to return a specific value on error,
which is not 1. `Main::set_return_code_for_errors()` lets you set it to
that value.
2022-03-19 11:01:49 -07:00
Tim Schumacher 13ef8469da Utilities: Add support for setting permissions to install 2022-03-19 10:26:33 -07:00
Tim Schumacher 9de742e321 Utilities: Add support for multiple sources to install 2022-03-19 10:26:33 -07:00
Tim Schumacher 62f0fa818d LibCore: Add File::ensure_directories() 2022-03-19 10:26:33 -07:00
Tim Schumacher f44cd168b0 Utilities: Add the -c option to install 2022-03-19 10:26:33 -07:00
Andreas Kling cbd343dced LibWeb: Only delay "load" event for script elements that load something
We shouldn't delay the load event for scripts that we're completely
refusing to run anyway. Also, for scripts that have inline text content,
we don't need to delay them either, as they will become ready before
returning from "prepare script".

This makes the "load" event finally fire on lots of websites, including
Wikipedia. :^)
2022-03-19 16:11:36 +01:00
Andreas Kling c1f0d21bbe LibWeb: Rename the LayoutMode enum values and explain them
The old mode names, while mechanically accurate, didn't really reflect
their relationship to the CSS specifications.

This patch renames them as follows:

    Default => Normal
    AllPossibleLineBreaks => MinContent
    OnlyRequiredLineBreaks => MaxContent

There's also now an explainer comment with the LayoutMode enum about the
specific implications of layout in each mode.
2022-03-19 15:46:15 +01:00
Andreas Kling ceb055a75e LibWeb: Don't delay document "load" event for non-loading link elements
If we try loading a link element but it's reject for whatever reason
(broken URL, content filtering, etc.) make sure we don't mark that link
element as delaying the document load event.
2022-03-19 15:04:48 +01:00
Andreas Kling 2c9dfadb21 LibWeb: Don't delay document "load" event for unclosed script tags
We previously had a bug where markup with unclosed script tags caused
the document load event to be delayed indefinitely. Fix this by only
marking script elements as delaying the load event once we encounter
the script end tag.
2022-03-19 15:04:48 +01:00
Sam Atkins 2975d7275d LibWeb: Don't serialize hex-colors as identifiers
ID selectors need to be serialized as identifiers in the spec, but other
hash-values do not. This was causing hex colors that start with a
number, like `#54a3ff`, to serialize as `#\35 4a3ff`, which is silly
and unnecessary.

Selector serialization is done elsewhere, so this case in Token is
probably also unnecessary, but there might be situations I haven't
thought of where serializing an ID does need to happen while it's still
a Token.
2022-03-19 13:22:13 +01:00
Ali Mohammad Pur 8f7021faf7 LibJS: Implement bytecode generation for For-In/Of statements
This also implements the rather interesting behaviour that #12772 relies
on, so this fixes that bug in BC mode (the AST interp remains affected).
2022-03-19 12:51:29 +01:00
Andreas Kling 83afc1154c LibWeb: Fix IFC over-shrinking the available space for line boxes
After accounting for left-side floats, we have to subtract the offset of
the IFC's containing block again, to get the real starting X offset
for the current line.

This was done correctly in leftmost_x_offset_at() but incorrectly in
available_space_for_line(), causing IFC to break lines too early in
cases where the containing block had a non-zero X offset from the BFC
root block.
2022-03-19 12:42:10 +01:00
Andreas Kling 8d5768b103 LibWeb: Don't treat inline-level children of flex items as whitespace
This was causing us to collapse some children of flex items as if they
were useless whitespace text nodes.
2022-03-19 12:42:10 +01:00
Andreas Kling 28b771560a LibWeb: Make SVG <svg> elements behave as CSS replaced elements
This makes SVG-in-HTML behave quite a bit better by following general
replaced layout rules. It also turns <svg> elements into inline-level
boxes instead of block-level boxes.
2022-03-19 12:42:10 +01:00
Andreas Kling 48abbefb99 LibWeb: Make Paintable::hit_test() return nothing
For paintables that don't know how to hit test themselves, let's just
return nothing instead of crashing.
2022-03-19 12:42:10 +01:00
Andreas Kling 3f55271c8e LibWeb: Don't crash when dumping layout tree pre-layout
If we haven't run layout yet, there aren't any paintables attached to
the tree, so we have to null check them.
2022-03-19 12:42:10 +01:00
martinfalisse 11dffbd96f Spreadsheet+LibGUI: Calculate cell position given scroll position
Take into account the current scroll position when calculating the
position of cells. This way when the user scrolls either horizontally
or vertically, the calculations done to find the cell position
will be correct.
2022-03-19 09:31:29 +03:30
martinfalisse 5759b25ca8 Spreadsheet: Handle case when drag-and-drop location is out of bounds
When the drop location of a drag-and-drop operation is not valid, then
don't continue with the drop_event. For example, if the ending location
is the header row or header column, or is outside of the table, then
should not continue.
2022-03-19 09:31:29 +03:30
martinfalisse 9e54815799 Spreadsheet: Implement extend functionality
Implements ability to extend a cell's contents by clicking the bottom
right of the cell and dragging in a linear direction. For now, the
content that is extended is simply a copy of the target cell's
values.
2022-03-19 09:31:29 +03:30
martinfalisse f6ad98b1a1 Spreadsheet: Take into account cell order when copying and cutting
Since copying and cutting uses the cell values in the origin to decide
which values to paste in the destination, it is necessary to do it
in an ordered manner when the origin and destination ranges overlap.
Otherwise you may overwrite values in the origin unintentionally
before having successfully transferred them to the destination.
2022-03-19 09:31:29 +03:30
martinfalisse 2f2a705a8e Spreadsheet: Cut instead of copy when dragging a cell's items
Use cut instead of copy when dragging one or many cells' contents.
This is more intuitive as most other spreadsheet applications
handle the drag in this manner instead of as a copy operation.
2022-03-19 09:31:29 +03:30
martinfalisse 8a7d2c3336 Spreadsheet: Rename variables to better describe their function
Rename some variables relating to the drag-and-cut operations as
well as the select operation so that they are more clear.
2022-03-19 09:31:29 +03:30
martinfalisse e98d0dafa0 Spreadsheet: On cut end select same cells in target location
When finished dragging and cutting, select the cells in the
destination. E.g. if you select 5 cells and drag and paste
them in a new location, select the 5 pasted cells in the
destination.
2022-03-19 09:31:29 +03:30
martinfalisse 10bbb01ed8 Spreadsheet: Set cursor manually so that correct cells are outlined
Due to the fact that in the AbstractView, when multiple cells are
selected, and then another cell is selected within this selection,
the cursor is not updated as the user may be beginning to drag, have
to override this functionality for the Spreadsheet application.

This is because in spreadsheets when multiple cells are selected,
and then you click on one of the cells within the selection,
the selection should be cleared and the targetted cell highlighted.
2022-03-19 09:31:29 +03:30
martinfalisse 1287238430 Spreadsheet: Select the correct cell on click
Due to the margin that is given to be able to select cells for
cutting or extending, have to override the mouse click function
so that the targetted cell is chosen and not the one that may be
beneath the cursor.
2022-03-19 09:31:29 +03:30
martinfalisse 4f0a123b2f Spreadsheet: Display different cursors depending on action
Depending on the cursor location with respect to a selected cell,
display different icons pertaining to the distinct possible actions,
for example dragging and cutting, extending the cell's contents, or
doing a simple selection.
2022-03-19 09:31:29 +03:30
martinfalisse a378e3ccbf Spreadsheet: Add states for cursor hovering
Add states for the cutting and extending icons that are to be shown
depending on where the user's cursor is with respect to the target
cell.
2022-03-19 09:31:29 +03:30
Lenny Maiorani a0367aa43b DevTools+LibJS+LibWeb: Change class_name to use StringView
This helps make the overall codebase consistent. `class_name()` in
`Kernel` is always `StringView`, but not elsewhere.

Additionally, this results in the `strlen` (which needs to be done
when printing or other operations) always being computed at
compile-time.
2022-03-19 00:20:46 +00:00
Lenny Maiorani 5b7a5b3c01 LibCpp: Change class_name to use StringView instead of char const*
This helps make the overall codebase consistent. `class_name()` in
`Kernel` is always `StringView`, but not elsewhere.

Additionally, this results in the `strlen` (which needs to be done
when printing or other operations) always being computed at
compile-time.
2022-03-19 00:20:46 +00:00
Lenny Maiorani 327e9a2187 LibCore: Change class_name to use StringView instead of char const*
This helps make the overall codebase consistent. `class_name()` in
`Kernel` is always `StringView`, but not elsewhere.

Additionally, this results in the `strlen` (which needs to be done
when printing or other operations) always being computed at
compile-time.
2022-03-19 00:20:46 +00:00
Lenny Maiorani 66189169f9 LibGfx: Change class_name to use StringView instead of char const*
This helps make the overall codebase consistent. `class_name()` in
`Kernel` is always `StringView`, but not elsewhere.

Additionally, this results in the `strlen` (which needs to be done
when printing or other operations) always being computed at
compile-time.
2022-03-19 00:20:46 +00:00
Tim Schumacher aa9d6f17b6 Revert "LibC: Make WEOF a signed value on clang"
We have fixed Clang to define `wint_t` as an unsigned value.

This reverts commit ccb9cae8e9.
2022-03-19 00:11:45 +00:00
Karol Kosek 677e4845a7 PixelPaint: Add Cut action
It's just the Copy action with erasing selection at the end.
2022-03-19 00:50:59 +01:00
Karol Kosek 580c6080b5 PixelPaint: Put undo/redo actions on top of the Edit menu
To be consistent with the order with other apps on the system. :^)
2022-03-19 00:50:59 +01:00
Lenny Maiorani a51fce6c0f LibCards+Games: Change name of card type to card suit
Playing cards have a `suit` such as `hearts`/`diamonds`, not a
`type`. Make the internal naming consistent with the way playing cards
are typically named.
2022-03-18 23:49:34 +00:00
Lenny Maiorani 4c5e9f5633 Everywhere: Deduplicate day/month name constants
Day and month name constants are defined in numerous places. This
pulls them together into a single place and eliminates the
duplication. It also ensures they are `constexpr`.
2022-03-18 23:48:50 +00:00
Lenny Maiorani 759857b597 LibSoftGPU: Avoid copying data when doing triangle rasterization
Several large-ish objects shouldn't be copied to the stack when a
reference will do.
2022-03-18 23:41:06 +00:00
Tom 9f59d7d9a0 WindowServer: Fix animation crash
If an Animation's on_stop handler cleared itself inside the on_stop
event handler, it would remove itself from the animation map that was
still being iterated, leading to a crash.

To solve this, we'll iterate over the animations using the
remove_all_matching function, which enables us to delete it by simply
returning true when the animation finished. In the event that the
Animation is kept alive elsewhere and the on_stop event clears its own
reference, we need to temporarily bump the reference count. Another
advantage is that we only need to bump the reference count when an
animation is finished, whereas before this we bumped it
unconditionally.
2022-03-18 20:00:30 +01:00
Lenny Maiorani 56046d3f9b Libraries: Change enums to enum classes in LibCards 2022-03-18 19:59:43 +01:00
Lenny Maiorani d3893a73fb Libraries: Change enums to enum classes in LibAudio 2022-03-18 19:59:43 +01:00
Lenny Maiorani be360db223 Libraries: Change enums to enum classes in LibArchive 2022-03-18 19:59:43 +01:00
Daniel Lemos 3eb6016dda LibWeb: Add some default style for <textarea> elements and a test 2022-03-18 19:59:19 +01:00
Lenny Maiorani f912a48315 Userland: Change static const variables to static constexpr
`static const` variables can be computed and initialized at run-time
during initialization or the first time a function is called. Change
them to `static constexpr` to ensure they are computed at
compile-time.

This allows some removal of `strlen` because the length of the
`StringView` can be used which is pre-computed at compile-time.
2022-03-18 19:58:57 +01:00
Andreas Kling 3b037726e9 LibWeb: Invalidate layout after setting Element.innerHTML
It's not enough to only relayout here, since the API can substantially
change the DOM. We have to rebuild the layout tree.
2022-03-18 19:54:46 +01:00
Andreas Kling a19b9b727d LibWeb: Place right-side floats relative to their containing block
We were incorrectly placing them relative to the BFC root, but CSS2
says they are relative to their own containing block.
2022-03-18 19:28:58 +01:00
Simon Wanner 48efdaa8c4 LibWeb: Update hit_test for CSS Transforms
This now also takes a FloatPoint instead of an IntPoint to avoid
excessive rounding when multiple transforms apply on top of each other.
2022-03-18 18:51:42 +01:00
Simon Wanner a2331e8dd3 LibWeb: Implement CSS transforms on stacking contexts
Since there is currently no easy way to handle rotations and skews
with LibGfx this only implements translation and scaling by first
constructing a general 4x4 transformation matrix like outlined in
the css-transforms-1 specification. This is then downgraded to a
Gfx::AffineTransform in order to transform the destination rectangle
used with draw_scaled_bitmap()

While rotation would be nice this already looks pretty good :^)
2022-03-18 18:51:42 +01:00
Simon Wanner 7c79fc209f LibWeb: Establish a new stacking context for elements with transform 2022-03-18 18:51:42 +01:00
Simon Wanner 9c97bd0de4 LibGfx: Add AffineTransform::inverse 2022-03-18 18:51:42 +01:00