Commit Graph

31868 Commits

Author SHA1 Message Date
Matthew Olsson
c8b9c137a1 LibWeb: Handle discrete properties
This also changes transform's animation-type to by-computed-value. It is
far easier to handle since we switch on StyleValue::type(), and it might
be the case that this applies to all custom animated properties and we
don't need "custom" at all, but let's wait until we get to those
properties to make that decision.
2024-02-25 08:51:50 +01:00
Matthew Olsson
ee63c729e5 LibWeb: Expand shorthand properties in KeyframeEffect 2024-02-25 08:51:50 +01:00
Matthew Olsson
9e0ff9c140 LibWeb: Expose CSS shorthand -> longhand conversion
This conversion needs to be done by KeyframEffect as well
2024-02-25 08:51:50 +01:00
Matthew Olsson
af1f0c673e LibWeb: Remove old animation-direction handling from StyleComputer
This is now handled by Web Animations, so if the animation was ever
running backwards, this logic would re-reverse it so that it played
forwards again.
2024-02-25 08:51:50 +01:00
Matthew Olsson
70ded2ef42 LibGfx: Add Oklab support to Gfx::Color
Interpolation of color on the web is done via the oklab colorspace
2024-02-25 08:51:50 +01:00
Domenico Iezzi
71a784741f LibGUI: Add Calendar property for mode
If a user selects Year as the default view mode for Calendar app, then
all apps using Calendar widget will default to this view if not
manually overridden with a Calendar::toggle_mode call.

This commit introduces a "mode" property that allows the selection of
the default mode for the calendar widget in GML files. In this way
there is no need to manually call toggle_mode when constructing
UIs with Calendar widget.
2024-02-24 18:54:51 -07:00
Domenico Iezzi
1153068407 LibGUI: Remove redundant Widget::update calls from DatePicker
In DatePicker constructor, calling to Widget::update after
Calendar::update_tiles is redundant since it is already called
internally by update_tiles.

This commit also remove unused header files from DatePicker header.
2024-02-24 18:54:51 -07:00
Domenico Iezzi
bc9bba1d9b LibGUI: Explicitly fire a resize event when toggling Calendar mode
Calendar::toggle_mode function performed a call to Widget::resize with
swapped width and height parameters as a quick way to trigger a
resize_event (resize event is generated only when the new rect size is
different from the old one, hence the swapped parameters).

This method does not work when width and height are equal, such as in
the DatePicker widget where width and height are fixed to 200x200. In
such case, calls to Calendar::toggle_mode would not generate a resize
event, leaving tiles uninitialized, therefore the widget was not able
to properly paint the Month view.

This commit replaces Widget::resize call with a manual triggering of
the event.
2024-02-24 18:54:51 -07:00
Hediadyoin1
21a21c6a11 LibDeviceTree: Add a simple DeviceTree class
This makes it easier to work with device tree nodes and properties, then
writing simple state machines to parse the device tree.
This also makes the old slow traversal methods use the
DeviceTreeProperty helper class, and adds a simple test.
2024-02-24 16:43:44 -07:00
Hendiadyoin1
d6bb5579ad LibDeviceTree: Make the dump more akin to the original fdtdump
This also makes it possible to compile the library in the Kernel
2024-02-24 16:43:44 -07:00
Bastiaan van der Plaat
089a98607c LibWeb: Add HTMLPreElement width property 2024-02-24 16:35:11 -07:00
Hugh Davenport
2e8ff1855c Browser: Allow system shortcuts to function
Before shortcuts like ALT-F4, etc did not work. This makes the window
ignore keydown events. In the future this may be altered to allow for
custom shortcuts from within ladybird?
2024-02-24 16:30:50 -07:00
Lucas CHOLLET
cb03ab4a5a LibPDF: Handle the BlackIs1 parameter of the CCITTFaxDecode Filter 2024-02-24 16:24:45 -07:00
Lucas CHOLLET
6b3bab5c8a LibPDF: Plug in the CCITTFaxDecode filter to our CCITT decoder
We only call the decoder for Group 4 images. We do support Group 3
images, but let's wait to find a PDF with these before adding support.
2024-02-24 16:24:45 -07:00
Sönke Holz
0b0ea19d12 LibELF+readelf: Add support for RISC-V dynamic relocation types 2024-02-24 16:05:50 -07:00
Sönke Holz
f8628f94b8 LibELF: Refactor how arch-specific dynamic relocation types are handled
We currently expect that the relocation type numbers are unique across
all architectures. But RISC-V and x86_64 use the same numbers for
different relocation types (R_X86_64_COPY = R_RISCV_JUMP_SLOT = 5).

So create a generic reloc type enum which maps to the arch-specific
reloc types instead of checking for all arch reloc types individually
everywhere.
2024-02-24 16:05:50 -07:00
Tim Ledbetter
f3a68fc80d mktemp: Ensure --tmpdir and template paths are concatenated correctly
Previously, using the `--tempdir` option with a template containing a
path didn't work correctly, as the template path would be discarded.
2024-02-24 15:57:14 -07:00
implicitfield
84252db976 Utilities: Add mkfs.fat
This adds a basic `mkfs.fat` utility, which can format FAT12, FAT16
and FAT32 partitions.

This does have a few limitations, namely in that FAT12 formatting is
limited to a set known floppy disk sizes, and we can only generate
512-byte sectors.
2024-02-24 15:54:52 -07:00
implicitfield
f2503b2048 CMake: Allow the names of utilities to contain extensions
Previously, we would remove the "longest extension" from each file name
when parsing it as the name of a utility, which made it impossible for
the names of utilities to contain any extensions.
2024-02-24 15:54:52 -07:00
implicitfield
8384bb138e LibFileSystem: Add a helper to get the size of a block device 2024-02-24 15:54:52 -07:00
implicitfield
a70d79ff98 LibFileSystem: Add a helper to get the file size from fstat 2024-02-24 15:54:52 -07:00
implicitfield
896f213c6f LibFileSystem+Userland: Rename size() to size_from_stat()
This reflects what the functions does more accurately, and allows for
adding functions to get sizes through other methods.

This also corrects the return type of said function, as size_t may only
hold sizes up to 4GB on 32-bit platforms.
2024-02-24 15:54:52 -07:00
Fabian Dellwing
29ef508b4e tail: Collapse repeated error handling into statement expression
Co-authored-by: Timothy Flynn <trflynn89@pm.me>
2024-02-24 15:48:36 -07:00
Fabian Dellwing
e40aca2d77 tail: Handle truncation in follow mode 2024-02-24 15:48:36 -07:00
Sönke Holz
525555181e LibELF: Add riscv64 PLT trampoline
This code is based on the aarch64 implementation.
2024-02-24 15:41:23 -07:00
Dan Klishch
8ac0e3f0e5 AK+LibJS: Remove null state from DeprecatedFlyString :^) 2024-02-24 15:06:52 -07:00
Dan Klishch
026c1caba0 LibJS: Don't use null DFS for binding_name parameters in ClassExpression 2024-02-24 15:06:52 -07:00
Dan Klishch
d558468d03 LibJS: Don't differentiate between empty and null DFS in CatchClause 2024-02-24 15:06:52 -07:00
Dan Klishch
fb2c929310 LibJS: Don't use null DFS in {Import,Export}Entry 2024-02-24 15:06:52 -07:00
Dan Klishch
78491204d9 LibJS: Don't use null DFS for break/continue statements without a label 2024-02-24 15:06:52 -07:00
Dan Klishch
761d16141d LibJS: Store DFS instead of opaque StringImpl inside StringOrSymbol
Additionally, use the second bit (instead of the first) to differentiate
between strings and symbols there. This will allow transparent
conversion of DFS to StringBase in the future.
2024-02-24 15:06:52 -07:00
Dan Klishch
a53911717f LibJS: Remove DeprecatedFlyString::impl use in PrimitiveString 2024-02-24 15:06:52 -07:00
Dan Klishch
061f902f95 AK+Userland: Introduce ByteString::create_and_overwrite
And replace two users of raw StringImpl with it.
2024-02-24 15:06:52 -07:00
Dan Klishch
86d54a8684 JSSpecCompiler: Parse arbitrarily large rational numbers in xspec mode 2024-02-24 15:03:08 -07:00
Dan Klishch
2a2e31f2ed LibCrypto: Avoid UB in BigFraction::to_byte_string for 0/x fractions 2024-02-24 15:03:08 -07:00
Tim Ledbetter
1d825f17c0 LibWeb: Remove first rule if no argument is given for remove_rule()
While this isn't explicitly mentioned in the specification, there is a
WPT test that checks for this behavior.
2024-02-24 21:59:28 +01:00
Tim Ledbetter
3ea318ca8b LibWeb: Implement CSSStyleSheet.addRule()
This is a legacy method that has been superseded by `insertRule()`,
although it is supported by all modern browser engines.
2024-02-24 21:59:28 +01:00
Tim Ledbetter
87b52a1816 LibWeb: Implement CSSStyleSheet.replaceSync()
This method behaves the same as `CSSStyleSheet.replace()` but the
operation is performed synchronously.
2024-02-24 21:59:28 +01:00
Tim Ledbetter
81c67d34eb LibWeb: Implement CSSStyleSheet.replace()
This method asynchronously replaces the content of the given stylesheet
with the content passed to it.

An exception is thrown if this method is used by a stylesheet not
created with the `CSSStyleSheet()` constructor.
2024-02-24 21:59:28 +01:00
Tim Ledbetter
d209d5a84f LibWeb: Ensure CSSStyleSheet::css_rules() always returns the same object
Instead of having a method that replaces the stylesheet's CSSRuleList,
we now have a method on CSSRuleList to modify it's underlying CSSRules.
2024-02-24 21:59:28 +01:00
Tim Ledbetter
811033ec19 LibWeb: Disallow inserting @import rules into a constructed stylesheet 2024-02-24 21:59:28 +01:00
Tim Ledbetter
b0f57a2785 LibWeb: Add CSSStyleSheet constructor binding 2024-02-24 21:59:28 +01:00
Tim Ledbetter
f303905875 LibWeb: Add the CSSStyleSheet.rules alias for CSSStyleSheet.cssRules 2024-02-24 21:59:28 +01:00
Tim Ledbetter
9b1ea4e2fc LibWeb: Add CSSStyleSheet.ownerRule attribute
This returns the `CSSImportRule` corresponding to the `@import` at-rule
that imported the stylesheet into the document. If the stylesheet
wasn't imported then this property is null.
2024-02-24 21:59:28 +01:00
Tim Ledbetter
588a031e2d LibWeb: Clamp calculated border width values to zero
Previously, a calculated CSS border-width property with a resolved
value of less than zero pixels would cause a crash.
2024-02-24 21:57:24 +01:00
Andreas Kling
8addfc14af LibWeb: Implement IntersectionObserver "intersection roots" per spec
In particular, get the implicit root correctly for intersection
observers that don't have an explicit root specified.

This makes it possible to load the Terminal app on https://puter.com/
2024-02-24 19:56:08 +01:00
Andreas Kling
8586897928 headless-browser: Don't choke on subframe load completions
This didn't break any existing tests, but I have to do this for an
upcoming test to not bring everything down.
2024-02-24 19:56:08 +01:00
Andreas Kling
9759f44faf LibWeb: Allow SVGDecodedImageData to cache bitmaps at different sizes
This avoids constantly re-rendering the same SVG image over and over
during painting when it's being used at a couple of different sizes
(for example when used as a CSS background).
2024-02-24 19:56:08 +01:00
Andreas Kling
2484324f9a LibGfx: Add hash traits for the Size family 2024-02-24 19:56:08 +01:00
Andreas Kling
11b4216e65 LibWeb: Run IntersectionObserver steps only when needed
Instead of updating IOs in every iteration of the HTML event loop,
we now only do it after a relayout, or after the viewport changes.
2024-02-24 19:56:08 +01:00
Aliaksandr Kalenik
d3f8d24abb LibWeb+WebContent: Remove PageClient::page_did_invalidate()
...and schedule repainting directly from Navigable::set_needs_display()
bypassing PageClient.
2024-02-24 16:54:55 +01:00
Aliaksandr Kalenik
c3f5dbb101 LibWeb: Paint page only if something that requires repaint happened
Resolves a performance regression from
8ba18dfd40, where moving paint scheduling
to `EventLoop::process()` led to unnecessary repaints.

This update introduces a flag to trigger repaints only when necessary,
addressing the issue where repaints previously occurred with each event
loop process, irrespective of actual changes.
2024-02-24 16:54:55 +01:00
Aliaksandr Kalenik
906ac71eca LibWeb: Fix crashing after input into empty contenteditable
Change `EventHandler::handle_keydown()` to no longer assume the cursor
position's node is always a `DOM::Text`. While this assumption holds
for `HTMLInputElement` that has a shadow DOM with a text node, an empty
`contenteditable` might not have any children. With this change,
`handle_keydown()` creates a new text node if the cursor position's
node is not a text node.
2024-02-24 08:09:01 +01:00
Aliaksandr Kalenik
5d76fa72e9 LibWeb: Add HTMLElement::did_receive_focus() 2024-02-24 08:09:01 +01:00
Aliaksandr Kalenik
6b17ab77f3 LibWeb: Do not delete empty range in EventHandler::handle_keydown()
Fixes a crash that occurs when inputting into an empty contenteditable
element (`EditEventHandler::handle_delete()` assumes the cursor
position's node is always `DOM::Text`, which is not the case for an
empty `contenteditable`).
2024-02-24 08:09:01 +01:00
Aliaksandr Kalenik
05d5e11966 LibWeb: Allow HTMLElement with contenteditable=true to be focusable 2024-02-24 00:19:55 +01:00
Matthew Olsson
d2cfea5acc LibWeb: Add Animation event handler attributes 2024-02-23 21:23:57 +01:00
Matthew Olsson
2dd5d0c310 LibWeb: Implement Animation.reverse() 2024-02-23 21:23:57 +01:00
Matthew Olsson
9ab73f2675 LibWeb: Implement Animation.updatePlaybackRate() 2024-02-23 21:23:57 +01:00
Matthew Olsson
d351389d72 LibWeb: Implement Animation.persist() 2024-02-23 21:23:57 +01:00
Matthew Olsson
3c055ff76d LibWeb: Implement Animation.cancel() 2024-02-23 21:23:57 +01:00
Matthew Olsson
9abe472928 LibWeb: Implement Animation.finish() 2024-02-23 21:23:57 +01:00
Matthew Olsson
c0b9179d9a LibWeb: Implement Animation.pause() 2024-02-23 21:23:57 +01:00
Matthew Olsson
fc62989f1a LibWeb: Add missing visits for Document's pending animation event queue 2024-02-23 20:52:37 +01:00
Matthew Olsson
4e27d07ff2 LibWeb: Use initial value for animation start if it does not exist
This fixes an issue where a property could not be animated unless the
element had a specified value for that property somewhere in its
styling.
2024-02-23 20:52:37 +01:00
Matthew Olsson
65858154de LibWeb: Dispatch Animation events 2024-02-23 20:52:37 +01:00
Matthew Olsson
ae3326a447 LibWeb: Transition StyleComputer to Web Animations
With this commit, we are finally running animations off of the web
animations spec! A lot of the work StyleComputer is doing is now done
elsewhere. For example, fill-forward animations are handled by
Animation::is_relevant() returning true in the after phase, meaning the
"active_state_if_fill_forward" map is no longer needed.
2024-02-23 20:52:37 +01:00
Nico Weber
b258ba2767 LibPDF: Use decode_hex_digit() more
For `:#xx` in names, we now also handle lower-case hex digits.
The spec is silent on the case of these hex digits.
Our previous check (isxdigit(), and now is_ascii_hex_digit()) lets
through lower-case hex digits, so it seems better to handle them
rather than computing e.g. `'a' - 'A' + 10` (== 42 -- off by 32!).
I don't know if this has any visible effect on any files, but it's
more correct, and less code, and the code looks more like the code
in Filter::decode_ascii_hex().
2024-02-23 12:11:25 -05:00
Nico Weber
783b1d1c11 LibPDF: Use is_ascii_hex_digit() instead of isxdigit()
See description of #7684 for motivation.

Also, makes this code look more like the hex code in
Filter::decode_ascii_hex().

No behavior change.
2024-02-23 12:11:25 -05:00
Andreas Kling
6402ad29a6 LibJS/Bytecode: Don't clobber dst when assigning from object expression
When compiling code like this:

    x = { foo: x }

We don't want to put a new JS::Object in `x` until *after* we've
evaluated `x` for the `foo` field.

This fixes an issue when loading https://puter.com/ :^)
2024-02-23 14:34:00 +01:00
Tim Ledbetter
b073fdd570 LibWeb: Invert return value from EventHandler key event handling methods
`EventHandler::handle_keyup()` and `EventHandler::handle_keydown()`
return true if the event has been handled and false otherwise. This is
the opposite behavior to `EventHandler::fire_keyboard_event()`.
This change inverts the return value from `fire_keyboard_event` in
these methods, allowing shortcut keys to be propagated to the Serenity
Browser UI as expected.
2024-02-23 09:53:00 +01:00
ddorando
7eec2d6c21 useradd: Don't crash on -m if directory already exists 2024-02-23 09:52:08 +01:00
Kemal Zebari
111e4162d0 LibGUI/Application: Resize recent files list to max open file size
Since it's possible to have the actual recently opened files <
max_recently_open_files(), which causes us to crash when we try to
access new_recent_files_list where index >= the list's size.
2024-02-23 09:51:42 +01:00
Hugh Davenport
b365356eba Assistant: Check for access before showing file results
Fixing up from #22597.

This change checks whether a file is readable to the user before adding
files to the cache.
2024-02-23 09:48:28 +01:00
Hugh Davenport
bba53441ef Assistant: Enable escalation of commands that need it
Ideal for applications such as PartitionEditor. Previously an error
about how it needs to run as root was displayed which differed from
the behaviour when clicking from the system menus.

Use the new AppFile::spawn_with_escalation to perform the escalation
2024-02-23 09:47:27 +01:00
Hugh Davenport
45c35267f6 Taskbar: Use AppFile::spawn_with_escalation 2024-02-23 09:47:27 +01:00
Hugh Davenport
c4abb367a4 AppFile: Add spawn_with_escalation 2024-02-23 09:47:27 +01:00
Lucas CHOLLET
83f1775f15 LibGfx/CCITT: Reimplement PassMode in a less naive way
The old implementation of PassMode has only been tested with a single
image, and let's say that it didn't survive long in the wild. A few
cases were not considered:
 - We only supported VerticalMode right after PassMode.
 - It can happen that token need to be used but not consumed from the
 reference line.

 With that fix, we are able to decode every single PDF file from the
 1000-file zip "0000" (except 0000871.pdf, which uses byte alignment).
 This is massive progress compared to the hundred of errors that we were
 previously receiving.
2024-02-22 16:45:03 +01:00
Andreas Kling
883b2268c0 LibJS: Protect private elements from GC during class construction
Fixes an issue caught by test-js -g + UBSAN.
2024-02-22 16:44:54 +01:00
Andreas Kling
4bbb0a5c35 LibJS: Add ConservativeVector<T>
This works very similarly to MarkedVector<T>, but instead of expecting
T to be Value or a GC-allocated pointer type, T can be anything.
Every pointer-sized value in the vector's storage will be checked during
conservative root scanning.

In other words, this allows you to put something like this in a
ConservativeVector<Foo> and it will be protected from GC:

    struct Foo {
        i64 number;
        Value some_value;
        GCPtr<Object> some_object;
    };
2024-02-22 16:44:54 +01:00
Aliaksandr Kalenik
9968c9f7a6 LibWeb: Fix hit-testing by excluding CSS transform from clip rect check
Transforms are applied to both clip rectangle and position, so we need
to remove the transform from clip rectangle before checking if position
falls within the clip rectangle.

In this change, the removal of transform is moved into
`Paintable::clip_rect()` that is shared between hit-testing and
painting.

This change fixes hit-testing in Discord's multifactor authentication
form.
2024-02-22 07:36:20 +01:00
Aliaksandr Kalenik
309259aeb6 LibWeb: Clamp scroll offset into valid range after relayout
If the layout has been recalculated and the sizes of scrollable
overflow rectangles could have changed, we need to ensure that scroll
offsets remain within the valid range.
2024-02-22 07:35:30 +01:00
Aliaksandr Kalenik
155070cfd8 LibWeb: Clamp scroll offset to valid range in set_scroll_offset()
By moving scroll offset clamp from `PaintableBox::scroll_by()` to
`PaintableBox::set_scroll_offset()`, we ensure that updates from
`Element::set_scroll_top()` and `Element::set_scroll_left()` are
constrained to a valid range.
2024-02-22 07:35:30 +01:00
Matthew Olsson
ee4abacde6 LibWeb: Add AnimationEffect::target_properties() 2024-02-22 07:31:54 +01:00
Matthew Olsson
10fddb99fc LibWeb: Implement Document::remove_replaced_animations() 2024-02-22 07:31:54 +01:00
Matthew Olsson
fe848487db LibWeb: Add Document::update_animations_and_send_events 2024-02-22 07:31:54 +01:00
Matthew Olsson
9bab1a95a5 LibWeb: Keep track of AnimationEffect's previous phase and iteration
This will be required for detecting transitions in StyleComputer
2024-02-22 07:31:54 +01:00
Matthew Olsson
35859c0467 LibWeb: Add helpers to convert between FillMode and Direction enums 2024-02-22 07:31:54 +01:00
Nico Weber
c9234f35f1 LibPDF/CFF: Clear stack after "endchar" commands
Both type 1 and type 2 spec tell us to do this.

I haven't observed a difference from this, but I noticed it in the
spec while I was touching this code. Probably good to do what the
spec tells us to do.
2024-02-22 06:59:28 +01:00
Nico Weber
020c00ede2 LibPDF/CFF: Use offset in accented_character() data
Without this, the dieresis above an a is all the way to the left
instead of over the letter.
2024-02-22 06:59:28 +01:00
Nico Weber
12859dfde5 LibPDF/CFF: Treat endchar in type 2 as type 2 "seac" when requested
With this, a character can be defined that uses two existing glyphs.
This is useful for umlauts and the like, which then just need to
reference e.g. the glyphs named "a" and "dieresis" and provide a
translation.

Makes umlauts appear on some PDFs using CFF type2 data in Type 1
fonts.
2024-02-22 06:59:28 +01:00
Jelle Raaijmakers
857ab2e06d LibGL: Create symlinks for headers and shared library
This allows ports to access the OpenGL headers using `#include
<GL/gl.h>` and find the shared library at `/usr/lib/libGL.so` or
`/usr/lib/libGL.so.1`, removing the need for explicit include paths or
changed library names.
2024-02-22 03:48:08 +01:00
Jelle Raaijmakers
5cff59557e LibGL: Add all glPushAttrib bit flags
This is required to build the `sdl12-compat` port when it's using our
header files to compile.
2024-02-22 03:48:08 +01:00
Tim Ledbetter
3f6f3a90c1 HexEditor: Fix typo in parameter name 2024-02-21 23:32:15 +01:00
Tim Ledbetter
f742334b93 HexEditor: Prefer enum class to enum for FindDialog::OptionId 2024-02-21 23:32:15 +01:00
Tim Ledbetter
b330d83be4 HexEditor: Prefer ErrorOr to Result in FindDialog 2024-02-21 23:32:15 +01:00
ronak69
a42cf020ea LibTest: Return 0 if all test cases pass and 1 otherwise from TEST_MAIN
Before, TEST_MAIN used to return the return value of TestSuite::main()
function (which returns the number of test cases that did not pass, so
it can be >=256) directly.

The run-tests utility determines the success / failure of a test suite
binary by examining its (or i.e. TEST_MAIN's) exit status.

But as exit status values are supposed to be between 0 and 255, values
>=256 will get wrapped around (modulo 256), converting a return value of
256 to 0.

So, in a rare case where exactly 256 test cases are failing in your test
suite, run-tests utility will display that the test suite passed without
any failures.

Now, TEST_MAIN just returns 0 if all of the test cases pass and returns
1 otherwise.
2024-02-21 22:45:51 +01:00
Tim Ledbetter
1a223d07e1 LibGUI: Assert that most recently open file path isn't empty
Attempting to do this causes a crash. It's better to fail early in this
case, so that the cause of the failure is clear.
2024-02-21 22:37:34 +01:00
Tim Ledbetter
ad62e433f0 PixelPaint: Don't crash when cancel is pressed when saving a file
Previously, we were attempting to add an empty string to the most
recently open files list when no file was saved.
2024-02-21 22:37:34 +01:00
Sönke Holz
a203837b1f LibC: Save callee-saved floating-point registers in setjmp for riscv64 2024-02-21 21:59:01 +01:00