Commit Graph

2685 Commits

Author SHA1 Message Date
Aliaksandr Kalenik
2764966ccc LibWeb: Reduce paintable tree traversals during hit-testing
By storing a list of positioned and floating descendants within the
stacking context tree node, we can eliminate the need for costly
paintable tree traversals during hit-testing.

This optimization results in hit-testing being 2 to 2.5 times faster
on https://ziglang.org/documentation/master/
2024-03-01 13:03:53 +01:00
Luke Wilde
48e11a1f12 LibWeb: Empty CE reaction queue instead of destroying it on exception
If an exception occurs in a custom element constructor, we clear the
reaction queue by destroying it, instead of emptying the Vector.
3da6916383/Userland/Libraries/LibWeb/DOM/Element.cpp (L2033)

This causes a UAF here, as async upgrades (i.e. custom elements not
created by document.createElement) are performed in this loop:
3da6916383/Userland/Libraries/LibWeb/Bindings/MainThreadVM.cpp (L657)

Fixes crash when loading https://github.com/SerenityOS/serenity
2024-02-29 21:58:01 -05:00
Tim Ledbetter
5b4533cab8 LibWeb: Don't crash in offset_parent() if no ancestor element found
The specification says the final step of this algorithm is to return
null. Previously, the browser would crash if the content of an iframe
was appended to the document before its offsetParent property was
queried.
2024-02-29 21:54:53 -05:00
Timothy Flynn
3da6916383 CI: Remove the WPT directory after tests have completed
This directory is about 600MB. Remove it after running WPT as an attempt
to alleviate CI disk space issues.
2024-02-29 14:27:25 -05:00
Aliaksandr Kalenik
90879a07ba LibWeb: Skip page scrolling for wheel events consumed by scrollable box
Fixes the bug when we scroll both scrollable box and page.
2024-02-29 13:18:57 +01:00
Tim Ledbetter
3bd9566847 LibWeb: Fix typo on CSSConditionRule test 2024-02-29 09:01:04 +01:00
Tim Ledbetter
4646a87eba LibWeb: Make CSSConditionRule.conditionText read-only
Previously @media rule conditions could be updated by assigning to
`conditionText`. This change aligns our implementation with the CSSOM
specification, which says `CSSConditionRule.conditionText` should be
read-only.
2024-02-28 22:14:58 +01:00
implicitfield
b08fd1b9ae LibWeb: Improve support for 'vertical-align: middle'
This rebaselines a few table-related layout tests since our default
stylesheet applies 'vertical-align: middle' to a few table-related
elements.
2024-02-28 16:11:05 -05:00
Aliaksandr Kalenik
b821f7b283 LibWeb: Implement scrollbar painting
Introduces the rendering of scroll thumbs in vertical and horizontal
directions. Currently, the thumbs are purely graphical elements that
do not respond to mouse events. Nevertheless, this is beneficial as it
makes it easier to identify elements that should respond to scrolling
events.

Painting of scrollbars uncovers numerous bugs in the calculation of
scrollable overflow rectangles highlighting all the places where
elements are made scrollable whey they shouldn't be. Positively, this
issue might motivate us to pay more attention to this problem to
eliminate unnecessary scrollbars.

Currently, the scrollbar style is uniform across all platforms: a
semi-transparent gray rectangle with rounded corners.

Also here we add `scrollbar-width: none` to all existing scrolling
ref-tests, so they keep working with this change.
2024-02-28 07:51:13 -05:00
Aliaksandr Kalenik
8d9e20cb03 LibWeb: Parse the CSS scrollbar-width property 2024-02-28 07:51:13 -05:00
Aliaksandr Kalenik
c74fc4c171 LibWeb: Clean previous border radii clips in refresh_clip_state()
The list of border radii clips needs to be reset before being populated
with new clips that have refreshed positions. Besides fixing painting,
this also improves performance because the number of sample/blit
commands does not increase as we scroll.
2024-02-28 07:44:12 -05:00
Tim Ledbetter
ae42c6ed80 LibWeb: Implement AbortSignal.timeout()
This method returns a signal that will automatically abort after a
given number of milliseconds.
2024-02-28 07:42:43 -05:00
Bastiaan van der Plaat
05e78dabdb LibWeb: Add textarea readonly support 2024-02-27 18:03:20 -05:00
Nico Weber
f5eb57f6bb Tests/LibPDF: Make standard-14-fonts.pdf 200 units less high
No need for a bunch of whitespace at the bottom.

No behavior change.
2024-02-27 17:42:08 -05:00
Sam Atkins
dd92c33498 Tests: Use Core::Environment instead of Core::System::*env() 2024-02-27 08:33:48 +00:00
Kenneth Myhra
0f168d9ca2 Tests/LibWeb: Add test to prove we can {,de}serialize File
This test proves the ability of structuredClone() to serialize and
deserialize a File object.
2024-02-26 16:10:20 -07:00
Kenneth Myhra
44e5c62545 Tests/LibWeb: Add test to prove we can {,de}serialize Blob
This test proves the ability of structuredClone() to serialize and
deserialize a Blob object.
2024-02-26 16:10:20 -07:00
Andrew Kaster
ea59bfaae7 Ladybird: Move helper processes to CMAKE_INSTALL_LIBEXECDIR
It aligns better with the Filesystem Heirarchy Standard[1] to put our
program-specific helper programs that are not intended to be executed by
the user of the application in $prefix/libexec or in whatever the
packager sets as the CMake equivalent. Namely, on Debian systems this
should be /usr/lib/Ladybird or similar.

[1] https://refspecs.linuxfoundation.org/FHS_3.0/fhs-3.0.html#usrlibexec
2024-02-26 13:16:27 -07:00
Andrew Kaster
21ac431fac AK: Allow reading from EOF buffered streams better in read_line()
If the BufferedStream is able to fill its entire circular buffer in
populate_read_buffer() and is later asked to read a line or read until
a delimiter, it could erroneously return EMSGSIZE if the caller's buffer
was smaller than the internal buffer. In this case, all we really care
about is whether the caller's buffer is big enough for however much data
we're going to copy into it. Which needs to take into account the
candidate.
2024-02-26 13:16:27 -07:00
Andrew Kaster
86c1d97e3c Ladybird: Always place helper processes in bundle directory on macOS
Don't put them in bin/ and then copy them to the bundle dir later, as
this means that they only get updated in the bundle directory if the
Ladybird binary itself needs updated. Which is not a fun workflow if you
are working on WPT and want to hack on the WebDriver binary.
2024-02-26 13:16:27 -07:00
Timothy Flynn
108521a566 LibWeb+LibWebView+WebContent: Implement more <input type=file> behavior
We had previous implemented some plumbing for file input elements in
commit 636602a54e.

This implements the return path for chromes to inform WebContent of the
file(s) the user selected. This patch includes a dummy implementation
for headless-browser to enable testing.
2024-02-26 14:18:49 +01:00
Timothy Flynn
435c2c24d1 LibWeb: Create a shadow tree for <input type=file> elements
This creates a button to prompt users to select a file, and a label to
show information about the selected file(s). Clicking either shadow
element will activate the input element.
2024-02-26 14:18:49 +01:00
Timothy Flynn
090dbac5a3 Revert "LibWeb: Allow bypassing transient activation checks for tests"
This reverts commit e52c30cbd5.

It's highly possible that this test was flaky on CI due to mixing units
of seconds and milliseconds in the transient activation calculation.
Revert the workaround for that commit in an attempt to avoid needless
ad-hoc behavior.
2024-02-25 12:35:49 -05:00
Andreas Kling
a61f09a010 LibWeb: Stretch-fit flex items with aspect ratio but no fixed sizes
This solves a particular issue with SVG as flex items, where the SVG has
an intrinsic aspect ratio via its viewBox, but no explicit natural width
or height.

Makes all corporate sponsor logos show up on https://ziglang.org/ :^)
2024-02-25 14:06:06 +01:00
Aliaksandr Kalenik
8a829be25c LibWeb: Handle scenario when Window property setter is called on global
This commit fixes a regression introduced in
1528e9109c.

Turns out that the type of `this_value` in the property setter of the
Window object depends on how the variable is accessed. If the property
is accessed as a global variable, then this_value is of type `Window`.
For example:
```js
performance = null
```

However, when it is accessed as a property of the window object,
`this_value` is of type `WindowProxy`. For example:
```js
window.performance = null
```

This commit updates the window property setters generator to handle
both scenarios.

With this change https://discord.com/login works again.
2024-02-25 12:55:30 +01:00
Aliaksandr Kalenik
e3c75d7b6f LibWeb: Add HTMLElement::is_content_editable() 2024-02-25 10:17:25 +01:00
Aliaksandr Kalenik
934aa6af6a LibWeb: Emit "focusin" and "focusout" events 2024-02-25 10:17:25 +01:00
Aliaksandr Kalenik
cd7b5b18e4 LibWeb: Emit "selectionchange" event on document 2024-02-25 10:17:25 +01: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
Bastiaan van der Plaat
089a98607c LibWeb: Add HTMLPreElement width property 2024-02-24 16:35:11 -07:00
Dan Klishch
4d8f74c149 JSSpecCompiler: Parse method headers 2024-02-24 15:03:08 -07:00
Dan Klishch
a35a751f9e JSSpecCompiler: Parse optional arguments groups 2024-02-24 15:03:08 -07:00
Dan Klishch
86d54a8684 JSSpecCompiler: Parse arbitrarily large rational numbers in xspec mode 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
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
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
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
1528e9109c LibWeb: Add special handling for WindowProxy in [Replaceable] setters
Setters for Window object should consider WindowProxy wrapper by:
- Verifying `this_value` is `WindowProxy` (not `HTML::Window`)
- Defining properties on the underlying Window object instead of on
  the WindowProxy itself.
2024-02-24 08:05:55 +01:00
Aliaksandr Kalenik
05d5e11966 LibWeb: Allow HTMLElement with contenteditable=true to be focusable 2024-02-24 00:19:55 +01:00
Thomas Queiroz
2de9ffa632 Kernel+Tests: Don't panic when LocalSocket is already bound 2024-02-23 09:49:23 +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
Timothy Flynn
3f3db34587 LibWeb: Support setting dimensions on input image buttons
Users are allowed to specify the height and width of an image button
directly in the HTML.
2024-02-21 19:52:59 +01:00
Tim Ledbetter
1560bfc6c9 LibWeb: Ensure DOMRect top, bottom, left and right handle NaN correctly 2024-02-21 19:38:17 +01:00
Tim Ledbetter
b03c94c26e Tests/LibWeb: Add tests for DOMRect construction 2024-02-21 19:38:17 +01:00
Tim Ledbetter
fe66aeb225 LibWeb: Validate arguments when creating DOMPoint from matrix transform
Previously, it was possible to create a DOMPoint from a matrix
transform with inconsistent arguments. A TypeError is now thrown in
this case.
2024-02-21 19:38:17 +01:00
Tim Ledbetter
c5d1ec4dea LibWeb/CSS: Ensure length is absolute before converting to pixels
Previously, creating a DOMMatrix with a transform that contained
non-absolute units would cause a crash.
2024-02-21 19:38:17 +01:00
Tim Ledbetter
5136b495a6 LibWeb: Use NaN safe min() and max() functions to compute DOMQuad bounds 2024-02-21 19:38:17 +01:00
Andreas Kling
f963bb4f36 LibWeb: Don't mark heights as definite in set_content_height()
Height definiteness is now preserved as intended by CSS-SIZING-3
(assuming I've understood it correctly) and not implicitly granted by
layout algorithms when they assign height.

For the specific special/magical cases where some sizes become definite
during layout, the preceding commits have made them explicit in code.

This fixes a number of flex layout issues where we were previously
resolving percentage values against post-layout flex container heights,
but other browsers don't.
2024-02-21 17:54:05 +01:00
Shannon Booth
d18f7145ad patch: Remove empty files after patching 2024-02-21 14:11:49 +01:00
Shannon Booth
df6a627323 LibDiff: Reject patches adding files when a file already exists
We should still add an informational message about when this happens
before we even get here - but we still shouldn't be able to locate a
place to apply a hunk as it ends up producing unexpected results where
the patch is prepended to the existing file.
2024-02-21 14:11:49 +01:00
Shannon Booth
c72c3d5f3b LibDiff/Tests: Add support for expected patch failures 2024-02-21 14:11:49 +01:00
Shannon Booth
9e36ba0a55 LibDiff/Tests: Use ByteString for filepaths in tests 2024-02-21 14:11:49 +01:00
Shannon Booth
947075ea7b LibDiff/Tests: Make verifying against stdout optional
It's not always important to verify what the contents of stdout are when
adding a patch test - especially if it's not exactly what we want it to
be, so make this optional when running patch for a test.
2024-02-21 14:11:49 +01:00
Lucas CHOLLET
9ec3480207 LibGfx/TIFF: Add support for Group4Fax encoded images
Note that we don't parse the T6 option group yet.

The test case was generated with GIMP.
2024-02-21 13:49:43 +01:00
Tim Ledbetter
3b7c252175 LibWeb: Implement AbortSignal.abort()
This returns an AbortSignal that is already set as aborted.
2024-02-21 10:34:44 +01:00
Andrew Kaster
9d7e234439 Tests/WPT: Update expectations metadata for new passing tests 2024-02-21 10:10:44 +01:00
Aliaksandr Kalenik
aee5120078 LibWeb: Fix infinite recursion when grid has "max-width: max-content"
With this change "max-width: max-content" is treated as "none" when
the available width is also "max-content". This fix prevents a stack
overflow in the grid track size maximization algorithm by avoiding
recursive calls to calculate_max_width() when determining the maximum
grid container size.
2024-02-21 10:06:19 +01:00
Timothy Flynn
e52c30cbd5 LibWeb: Allow bypassing transient activation checks for tests
We have a 5 second timeout between a user-activated event occurring and
an activation-gated API being invoked in order for that API to succeed.
This is quite fine in normal circumstances, but the machines used in CI
often exceed that limit (we see upwards of 10 seconds passing between
generating the user-activated event and the API call running).

So instead of generating a user-activated event, add a hook to allow
tests to bypass the very next activation check.
2024-02-20 18:53:59 -05:00
Aliaksandr Kalenik
c4f49e343a LibWeb: Fix division by zero in solve_replaced_size_constraint()
Fixes crashes that occur in Discord after clicking on a direct messages
conversation.
2024-02-20 20:35:34 +01:00
Timothy Flynn
af57bd5cca LibWeb: Stop parsing after document.write at the insertion point
If a call to `document.write` inserts an incomplete HTML tag, e.g.:

    document.write("<p");

we would previously continue parsing the document until we reached a
closing angle bracket. However, the spec states we should stop once we
reach the new insertion point.
2024-02-20 17:04:36 +01:00
Ali Mohammad Pur
99f8ac84ef Tests/LibWeb: Make the WPT runner grab only the one commit it needs 2024-02-20 11:11:19 +01:00
Aliaksandr Kalenik
036cd9b2dd LibWeb: Null layout and paintable pointers of removed DOM::Node
When a node is removed from the DOM tree, its paintable needs to be
removed to ensure that it is not used to obtain sizes that are no
longer valid.

This change enables the ResizeObserver to send a notification if a node
is removed, as it should, because a removed node now has a size of zero

It should be okay to nullify pointers without concerning
parent/sibling/child relationships because the layout and paintable
trees will be rebuilt following any DOM mutation anyway.
2024-02-20 10:55:10 +01:00
Aliaksandr Kalenik
2b7e7cc1ad LibWeb: Implement ResizeObserver::disconnect() 2024-02-20 10:55:10 +01:00
Aliaksandr Kalenik
70a0f07732 LibWeb: Implement ResizeObserver::unobserve() 2024-02-20 10:55:10 +01:00
Aliaksandr Kalenik
fcf293a8df LibWeb: Implement gathering and broadcasting of resize observations
Extends event loop processing steps to include gathering and
broadcasting resize observations.

Moves layout updates from Navigable::paint() to event loop processing
steps. This ensures resize observation processing occurs between layout
updates and painting.
2024-02-20 10:55:10 +01:00
Timothy Flynn
abaca60f9a Tests/LibWeb: Move LibWeb test SVGs to their own directory 2024-02-19 22:11:59 -05:00
Timothy Flynn
e030193e5f Tests/LibWeb: Move LibWeb test frames to their own directory
We currently have a handful of iframe tests whose sources are in the
"input" directory. This means they get run as their own tests, when they
are really just helper files. We've had to add empty test expectation
files for these "tests", and invoke a dummy test() method just to keep
the test runner happy.

Instead, move them to their own directory so the test runner does not
see them at all.
2024-02-19 22:11:59 -05:00
Jelle Raaijmakers
aa3a6767f6 LibGL+LibGPU+LibSoftGPU: Implement blend equations
This implements support for `glBlendEquation` and
`glBlendEquationSeparate`. These functions modify the calculation of the
resulting color in blending mode.
2024-02-19 23:23:40 +01:00
Aliaksandr Kalenik
591c8d2b68 LibWeb: Return overflow rect height from Element::scroll_height()
Spec says that this function has to return "height of the element
scrolling area" which is height of "scrolling overflow rect" in our
model.
2024-02-19 20:07:12 +01:00
Aliaksandr Kalenik
9f581d0bc9 LibWeb: Return overflow rect width from Element::scroll_width()
Spec says that this function has to return "width of the element
scrolling area" which is width of "scrolling overflow rect" in our
model.
2024-02-19 20:07:12 +01:00
Timothy Flynn
94c67c364d LibWeb: Implement HTMLInputElement's selected coordinates
When an <input type=image> button is clicked, we now send the (x,y)
coordinates of the click event (relative to the image) along with the
form submission data.

Regarding the text test, we can currently only test this feature with
dialogs. The headless-browser test infrastructure cannot yet handle the
resulting navigation that would occur if we were to test with normal
form submission.
2024-02-19 11:07:30 +01:00
Timothy Flynn
debb5690ce LibWeb: Begin implementing the HTMLInputElement 'image' type state
This implements enough to represent <input type=image> with its loaded
source image (or fallback to its alt text, if applicable). This does not
implement acquring coordinates from user-activated click events on the
image.
2024-02-19 11:07:30 +01:00
Tim Ledbetter
02c2b1e67e LibWeb: Implement document.createCDATASection() 2024-02-19 10:42:56 +01:00
Lucas CHOLLET
be9ec591e7 LibGfx/CCITT: Add support for Group3 2D
The two test images were created with:
tiffcp ccit3.tiff -c g3:2d ccit3_2d.tiff
tiffcp ccit3.tiff -c g3:2d:fill ccit3_2d_fill.tiff
2024-02-19 01:40:04 +01:00
Timothy Flynn
ce9ad3a236 LibWeb: Fully implement the HTMLInputElement value setter and getter
The setter was missing an implementation for the default and default/on
value attribute modes. This patch adds a method to get the current value
attribute mode, and implements the value setter and getter based on that
mode according to the spec.
2024-02-18 18:44:45 +01:00
MacDue
bbba484a7e Tests/LibWeb: Test hit testing in XML .svg files does not crash 2024-02-18 18:33:11 +01:00
MacDue
2ede299b4a headless-browser: Run .svg dump tests
Previously, the check for `.html` meant that `.svg` tests were excluded.
This led to a few `.svg` with missing or bit-rotted expectations, which
have now been added/updated.
2024-02-18 18:33:11 +01:00
Andrew Kaster
5d2a36f244 LibWeb: Stub out all the functions from the execCommand spec
Per the specification, it's ok if we say that nothing is supported.

It's not ok if we say something is supported but do nothing, apparently.
2024-02-16 19:31:54 -05:00
Tim Ledbetter
f5266e0096 Tests/LibWeb: Verify dialog return value is correct in dialog test 2024-02-16 17:21:48 -05:00
Tim Ledbetter
88fe236c77 Tests/LibWeb: Remove unused code from dialog test 2024-02-16 17:21:48 -05:00
Tim Ledbetter
816d24f647 LibWeb: Implement HTMLFormElement.requestSubmit()
This can be used to submit a form using a specific submit button.
2024-02-16 17:21:48 -05:00
Andrew Kaster
94149db073 LibWeb: Implement Document named properties with light caching
We now cache potentially named elements on the Document when elements
are inserted and removed. This allows us to do lookup of what names are
supported much faster than if we had to iterate the tree every time.

This first cut doesn't implement the rules for 'exposed' object and
embed elements.
2024-02-16 16:18:31 -05:00
Tim Ledbetter
c24652bd2e LibWeb: Implement document.scrollingElement
This returns a reference to the element that scrolls the document. In
standards mode it is equivalent to `document.documentElement`.
2024-02-15 22:51:15 -05:00
Gurkirat Singh
ee639fa1df Libraries: Implement SemVer for version parsing and comparisons
Semantic Versioning (SemVer) is a versioning scheme for software that
uses MAJOR.MINOR.PATCH format. MAJOR for significant, possibly
breaking changes; MINOR for backward-compatible additions; PATCH for
bug fixes. It aids communication, compatibility prediction, and
dependency management. In apps dependent on specific library versions,
SemVer guides parsing and validates compatibility, ensuring apps use
appropriate dependencies.

    <valid semver> ::= <version core>
                     | <version core> "-" <pre-release>
                     | <version core> "+" <build>
                     | <version core> "-" <pre-release> "+" <build>
2024-02-15 18:23:05 +01:00
Tim Ledbetter
0ecbdc4627 LibWeb: Add support for form submission method 'dialog' 2024-02-14 22:20:44 -05:00
Tim Ledbetter
151cd11b5b LibWeb: Implement HTMLDialogElement::show() 2024-02-14 22:20:44 -05:00
Tim Ledbetter
8042558805 LibWeb: Implement HTMLDialogElement::close() for non-modal dialogs 2024-02-14 22:20:44 -05:00
Tim Ledbetter
3ffa2a39bc Tests: Propagate errors with TRY_OR_FAIL() where possible 2024-02-14 17:46:06 -05:00
Aliaksandr Kalenik
5bea99367a LibWeb: Add hit-testing test for SVG path
Adds a test for <rect> to ensure we have at least some hit-testing
coverage for SVGs.
2024-02-14 06:56:22 +01:00
Aliaksandr Kalenik
88ad871e2b LibWeb: Do paint-order traversal in Document::element_from_point()
Specify callback for hit-test function to identify closest DOM element,
excluding text nodes. Add a previously failing test case.
2024-02-14 06:56:22 +01:00
Aliaksandr Kalenik
9d2809146f LibWeb: Do paint-order traversal in Document::elements_from_point()
Elements are now collected according to paint order as spec says,
replacing the depth-first traversal of the paint tree with hit-testing
on each box.

This change resolves a FIXME in an existing test and adds a new
previously non-working test.
2024-02-14 06:56:22 +01:00
Aliaksandr Kalenik
9c99182b1e LibWeb: Change StackingContext::hit_test() to accept callback
This change modifies hit_test() to no longer return the first paintable
encountered at a specified position. Instead, this function accepts a
callback that is invoked for each paintable located at a position, in
hit-testing order.

This modification will allow us to reuse this call for
`Document.elementsFromPoint()` in upcoming changes.
2024-02-14 06:56:22 +01:00
Andrew Kaster
e64aa7da7a Tests: Add patch to WPT to let our metadata update script work again 2024-02-14 06:55:40 +01:00
Andrew Kaster
52f1eaefa0 Tests: Update WPT metadata for current state of Ladybird 2024-02-14 06:55:40 +01:00
Andrew Kaster
2819067370 Tests: Pass WPT certificate to WebDriver when running CI tests 2024-02-14 06:55:40 +01:00
Nico Weber
b27aca9300 Tests/LibPDF: Add a benchmark for SampledFunction::evaluate()
Takes 235.6±2.3ms to run over here, with `--benchmark_repetitions 5`.
2024-02-13 19:45:19 +01:00
Aliaksandr Kalenik
edab67d5e8 LibWeb: Fix hit-testing for button element
Change 'dom_node_for_event_dispatch' to locate the closest layout node
with a DOM node instead of only checking the direct ancestor.

This fixes hit-testing for buttons because they are wrapped into
multiple anonymous layout nodes (internally we use flex formatting for
them).
2024-02-13 14:22:14 +01:00
Lucas CHOLLET
8e21bbf7bf LibGfx/TIFF: Add support for tiled images
A tile is basically a strip with a user-defined width. With that in
mind, adding support for them is quite straightforward. As a lot the
common code was named after 'strips', to avoid future confusion I
renamed everything that interact with either strips or tiles to a
global term: 'segment'.

Note that tiled images are supposed to always have a 'TileOffsets' tag
instead of 'StripOffset'. However, this doesn't seem to be enforced by
encoders, so we support having either of them indifferently.

The test case was generated with the following Python script:

import pyvips

img = pyvips.Image.new_from_file('deflate.tiff')
img.write_to_file('tiled.tiff',
                  compression=pyvips.ForeignTiffCompression.DEFLATE,
                  tile=True, tile_width=64, tile_height=64)
2024-02-13 10:13:11 +01:00
Andrew Kaster
6a0fe08604 LibWeb: Implement document.elementsFromPoint
This API seems to be used by WPT for sending synthetic input events.

Implementing the naive translation of elementFromPoint to the spec steps
for this algorithm turns 4 'tests had errors unexpectedly' and 3 'tests
had timeouts unexpectedly' into 1 pass and 7 'tests had unexpected
subtest results' on the infrastructure/ subdirectory of WPT.
2024-02-12 11:43:22 -07:00
Lucas CHOLLET
b9afac0a06 LibGfx/CCITT: Consider the UseFillBits option 2024-02-12 14:08:56 +01:00
Aliaksandr Kalenik
95d91a37d2 LibWeb: Resolve outline CSS property before paint commands recording
Refactor to resolve paint-only properties before painting, aiming to
stop using layout nodes during recording of painting commands.

Also adds a test, as we have not had any for outlines yet.
2024-02-12 13:38:24 +01:00
MacDue
f19b17e089 LibWeb: Use paths for text in CRC2D (if possible)
This allows for:

  * Transformed text (e.g. rotated text)
  * Stroked text
  * Filling/stroking text with PaintStyles (e.g. gradients)
  * Squashed/condensed text (via maxWidth parameter)

Fixes part of #22817
2024-02-12 13:38:10 +01:00
Tim Ledbetter
774119bb57 LibWeb: Implement document.designMode
Setting this attribute to "on" makes the entire document editable.
2024-02-12 07:35:14 +01:00
Nico Weber
986872800e Tests/AK: Add a test for the array ctor deduction guide 2024-02-11 18:53:00 +01:00
Nico Weber
d84b69ace9 AK: Add to_array()
This is useful if you want an array with an explicit type but still
want its size to be inferred.
2024-02-11 18:53:00 +01:00
Nico Weber
4409b33145 AK: Make IndexSequence use size_t
This makes it possible to use MakeIndexSequqnce in functions like:

    template<typename T, size_t N>
    constexpr auto foo(T (&a)[N])

This means AK/StdLibExtraDetails.h must now include AK/Types.h
for size_t, which means AK/Types.h can no longer include
AK/StdLibExtras.h (which arguably it shouldn't do anyways),
which requires rejiggering some things.

(IMHO Types.h shouldn't use AK::Details metaprogramming at all.
FlatPtr doesn't necessarily have to use Conditional<> and ssize_t could
maybe be in its own header or something. But since it's tangential to
this PR, going with the tried and true "lift things that cause the
cycle up to the top" approach.)
2024-02-11 18:53:00 +01:00
Tommy van der Vorst
1c7ec9c770 LibWeb: Ignore repeat(auto-fit/auto-fill, auto) as it is not allowed 2024-02-11 17:51:50 +01:00
Aliaksandr Kalenik
d4932196cc LibWeb: Account for all clipped border radii in containing block chain
With this change, instead of applying only the border-radius clipping
from the closest containing block with hidden overflow, we now collect
all boxes within the containing block chain and apply the clipping from
all of them.
2024-02-11 08:12:31 +01:00
MacDue
1d999fa780 LibWeb: Return milliseconds from unsafe_shared_current_time()
This was incorrectly changed to returning seconds in fc5cab5, which
meant the time passed to the callbacks of requestAnimationFrame() was
wrong.
2024-02-11 08:10:45 +01:00
Tim Ledbetter
0577a664dd LibWeb: Use correct offset value when replacing character data
Previously, the range's end offset was being set using it's previous
value.
2024-02-10 11:18:51 +01:00
Aliaksandr Kalenik
40246adfb9 LibWeb: Add internals.wheel() to simulate mouse wheel events
This function allows us to write tests for scrolling scenarios where
the events are processed by the EventHandler.
2024-02-10 11:18:40 +01:00
Tim Ledbetter
4a7236cabf Everywhere: Prefer _string when constructing strings from literals 2024-02-08 11:01:10 -05:00
Andrew Kaster
f739e976a4 Tests: Pass App Bundle path to WebDriver to WPT CTest test on macOS
The WebDriver binary in ${CMAKE_CURRENT_BINARY_DIR}/bin doesn't actually
have access to the Ladybird binary in the default CMake setup.
2024-02-08 15:53:46 +01:00
Aliaksandr Kalenik
ff3e454565 LibWeb: Invalidate paint-only property after relayout
Before this change, `set_needs_to_resolve_paint_only_properties()` was
only called after style invalidation. However, since relayout can be
triggered independently from style invalidation, we need to ensure that
paint-only properties are updated in that case too.
2024-02-08 13:08:10 +01:00
Nico Weber
cd5aeb0f22 Tests: Remove UserspaceEmulator more
These files don't contain "UserspaceEmulator", so I missed them
in #22998.

No behavior change.
2024-02-06 05:53:05 -07:00
Aliaksandr Kalenik
4a41a65ec5 LibWeb: Shift button paintable clip rectangle by scroll offset
Rectangles should be recorded using absolute coordinates, including
the scroll offset.
2024-02-06 13:06:16 +01:00
Aliaksandr Kalenik
d43dbe2842 LibWeb: Shift SVG paintable clip rectangle by scroll offset
Rectangles should be recorded using absolute coordinates, including
the scroll offset.
2024-02-06 13:06:16 +01:00
Tim Ledbetter
69df94ec5c LibWeb: Implement document.elementFromPoint()
This function uses our existing hit testing code to determine the
topmost element at the given coordinates relative to the viewport.
2024-02-06 08:43:03 +01:00
Aliaksandr Kalenik
7411f66fcf LibWeb/CSS: Resolve value of "height" in special way according to spec
Per spec value of height should be resolved to used value if "display"
property is not "none" or "contents".
2024-02-06 08:41:21 +01:00
Aliaksandr Kalenik
623ad94582 LibWeb: Resolve effective overflow-x and overflow-y according to spec
Implements following rule from CSS Overflow Module Level 3:
"The visible/clip values of overflow compute to auto/hidden
(respectively) if one of overflow-x or overflow-y is neither visible
nor clip."
2024-02-06 08:39:06 +01:00
vincent-rg
a9df60ff1c AK: Update OptionParser::m_arg_index by substracting skipped args
On argument swapping to put positional ones toward the end,
m_arg_index was pointing at "last arg  index" + "skipped args" +
"consumed args" and thus was pointing ahead of the skipped ones.

m_arg_index now points after the current parsed option arguments.
2024-02-06 00:08:30 +01:00
Dan Klishch
3e43d15440 Everywhere: Prefer VERIFY over assert() 2024-02-05 07:03:53 -05:00
Timothy Flynn
5d1657f57f LibWeb: Implement implicit submission of HTMLFormElement 2024-02-03 15:30:16 -07:00
Timothy Flynn
a17074422e LibWeb: Reset form association when any element with an ID changes
When an element with an ID is added to or removed from the DOM, or if
an ID is added, removed, or changed, then we must reset the form owner
of all form-associated elements who have a form attribute.

We do this in 2 steps, using the DOM document as the messenger to handle
these changes:

1. All form-associated elements with a form attribute are stored on the
   document. If the form attribute is removed, the element is removed
   from that list as well.

2. When a DOM element with an ID undergoes any of the aforementioned
   changes, it notifies the document of the change. The document then
   forwards that change to the stored form-associated elements.
2024-02-03 15:30:16 -07:00
Timothy Flynn
960dcf0e56 LibWeb: Reset form association when the element's form attribute changes 2024-02-03 15:30:16 -07:00
Aliaksandr Kalenik
36553d4566 LibWeb: Do not add CSS transforms into clip rect in PaintableWithLines
Painting command executor already accounts for CSS transforms so clip
rect only needs to be adjusted by scroll offset.
2024-02-03 20:05:09 +01:00
Aliaksandr Kalenik
bf14de4118 LibWeb: Remove direct calls of page_did_request_scroll_to()
By replacing the `page_did_request_scroll_to()` calls with a request
to perform scrolling in the corresponding navigable, we ensure that
the scrolling of iframes will scroll within them instead of triggering
scroll of top level document.
2024-02-03 19:00:26 +01:00
Aliaksandr Kalenik
1af466babf LibWeb: Fix invalidation of CSS properties that do not affect layout
Recently, we moved the resolution of CSS properties that do not affect
layout to occur within LayoutState::commit(). This decision was a
mistake as it breaks invalidation. With this change, we now re-resolve
all properties that do not affect layout before each repaint.
2024-02-03 09:28:03 +01:00
Kemal Zebari
8e5410347b LibWeb/MimeSniff: Add non-standard text or binary context sniffing
This is used in cases where the spec expects us to only run the
"rules for distinguishing if a resource is a text or binary" algo.
2024-02-02 14:34:17 -05:00
Nico Weber
9c762b9650 LibPDF+Meta: Use a CMYK ICC profile to convert CMYK to RGB
CMYK data describes which inks a printer should use to print a color.
If a screen should display a color that's supposed to look similar
to what the printer produces, it results in a color very different
to what Color::from_cmyk() produces. (It's also printer-dependent.)

There are many ICC profiles describing printing processes. It doesn't
matter too much which one we use -- most of them look somewhat
similar, and they all look dramatically better than Color::from_cmyk().

This patch adds a function to download a zip file that Adobe offers
on their web site. They even have a page for redistribution:
https://www.adobe.com/support/downloads/iccprofiles/icc_eula_win_dist.html

(That one leads to a broken download though, so this downloads the
end-user version.)

In case we have to move off this download at some point, there are also
a whole bunch of profiles at https://www.color.org/registry/index.xalter
that "may be used, embedded, exchanged, and shared without restriction".

The adobe zip contains a whole bunch of other useful and fun profiles,
so I went with it.

For now, this only unzips the USWebCoatedSWOP.icc file though, and
installs it in ${CMAKE_BINARY_DIR}/Root/res/icc/Adobe/CMYK/. In
Serenity builds, this will make it to /res/icc/Adobe/CMYK in the
disk image. And in lagom build, after #23016 this is the
lagom res staging directory that tools can install via
Core::ResourceImplementation. `pdf` and `MacPDF` already do that,
`TestPDF` now does it too.

The final piece is that LibPDF then loads the profile from there
and uses it for DeviceCMYK color conversions.

(Doing file access from the bowels of a library is a bit weird,
especially in a system that has sandboxing built in. But LibGfx does
that in FontDatabase too already, and LibPDF uses that, so it's not a
new problem.)
2024-02-01 13:42:04 -07:00
Aliaksandr Kalenik
5484062095 LibWeb: Apply scroll offset to PushStackingContext command
In cases where the stacking context painting requires a separate
bitmap, the destination position needs to be translated by the
scrolling offset to ensure it ends up in the correct position.
2024-02-01 13:38:45 +01:00
Aliaksandr Kalenik
9dddd6b028 LibWeb: Account for scroll offset in overflow clip rect calculation
This change addresses an issue with overflow clipping in scenarios
where `overflow: hidden` is applied to boxes nested within elements
with `overflow: scroll`.

Fixes https://github.com/SerenityOS/serenity/issues/22733
2024-01-31 07:15:25 +01:00
Dan Klishch
4330cdee74 Tests/Kernel: Properly synchronize threads in TestTCPSocket
We should wait for a server thread to actually listen(2) a server socket
before trying to connect to it. This hopefully should make the test less
flaky.
2024-01-30 18:46:37 -07:00
Nico Weber
69964e10f4 LibGfx+Tests: Improve calculation of restart interval
JPEGs can store a `restart_interval`, which controls how many
minimum coded units (MCUs) apart the stream state resets.
This can be used for error correction, decoding parts of a jpeg
in parallel, etc.

We tried to use

    u32 i = vcursor * context.mblock_meta.hpadded_count + hcursor;
    i % (context.dc_restart_interval *
         context.sampling_factors.vertical *
         context.sampling_factors.horizontal) == 0

to check if we hit a multiple of an MCU.

`hcursor` is the horizontal offset into 8x8 blocks, vcursor the
vertical offset, and hpadded_count stores how many 8x8 blocks
we have per row, padded to a multiple of the sampling factor.

This isn't quite right if hcursor isn't divisible by both
the vertical and horizontal sampling factor. Tweak things so
that they work.

Also rename `i` to `number_of_mcus_decoded_so_far` since that
what it is, at least now.

For the test case, I converted an existing image to a ppm:

    Build/lagom/bin/image -o out.ppm \
        Tests/LibGfx/test-inputs/jpg/12-bit.jpg

Then I resized it to 102x77px in Photoshop and saved it again.
Then I turned it into a jpeg like so:

    path/to/cjpeg \
        -outfile Tests/LibGfx/test-inputs/jpg/odd-restart.jpg \
        -sample 2x2,1x1,1x1 -quality 5 -restart 3B out.ppm

The trick here is to:

a) Pick a size that's not divisible by the data size width (8),
   and that when rounded to a block size (13) still isn't divisible
   by the subsample factor -- done by picking a width of 102.
b) Pick a huffman table that doesn't happen to contain the bit
   pattern for a restart marker, so that reading a restart marker
   from the bitstream as data causes a failure (-quality 5 happens
   to do this)
c) Pick a restart interval where we fail to skip it if our calculation
   is off (-restart 3B)

Together with #22987, fixes #22780.
2024-01-30 14:50:43 +01:00
Aliaksandr Kalenik
fb2166f19c LibWeb: Account for CSS transform in Element::getClientRects() 2024-01-30 14:50:25 +01:00
Aliaksandr Kalenik
768b8415f2 LibWeb: Follow the spec more precisely in Element::getClientRects()
Now, `Element::getBoundingClientRect()` implementation depends on
`Element::getClientRects()`, as defined in the specification.
2024-01-30 14:50:25 +01:00
Aliaksandr Kalenik
16f1962f10 LibWeb: Use clip rectangles assigned to paintables in hit-testing
This change makes hit-testing more consistent in the handling of hidden
overflow by reusing the same clip-rectangles.

Also, it fixes bugs where the box is visible for hit-testing even
though it is clipped by the hidden overflow of the containing block.
2024-01-30 11:22:22 +01:00
Nico Weber
6971ba35d5 LibGfx+Tests: Support grayscale jpegs with 2x2 sampling and MCU reset
Non-interleaved files always have an MCU of one data unit.

(A "data unit" is an 8x8 tile of pixels, and an "MCU" is a
"minium coded unit", e.g. 2x2 data units for luminance and
1 data unit each for Cr and Cb for a YCrCb image with
4:2:0 subsampling.)

For the test case, I converted an existing image to a ppm:

    Build/lagom/bin/image -o out.ppm \
        Tests/LibGfx/test-inputs/jpg/12-bit.jpg

Then I converted it to grayscale and saved it as a pgm in Photoshop.
Then I turned it into a weird jpeg like so:

    path/to/cjpeg \
        -outfile Tests/LibGfx/test-inputs/jpg/grayscale_mcu.jpg \
        -sample 2x2 -restart 3 out.pgm

Makes 3 of the 5 jpegs failing to decode at #22780 go.
2024-01-30 05:35:22 +01:00
Timothy Flynn
5a99a6afb4 LibWeb: Implement ReadableStreamBYOBRequest.respondWithNewView
The AO behind this prototype was added in commit ed1076d9ca,
so we can now trivially expose the prototype as well.
2024-01-29 17:10:56 -05:00
Nico Weber
fd316728a0 Everywhere: Remove references to UserspaceEmulator 2024-01-29 20:20:55 +00:00
Tim Ledbetter
4e383bdac1 LibWeb: Set select element text when an option is initially selected
Previously, a select element's text would initially be empty if the
`selected` property was set on one of its options.
2024-01-29 20:05:14 +00:00
MacDue
b10f58a1fe LibWeb: Support x and y attributes on nested SVGs
This allows positioning a child SVG relative to its parent SVG.

Note: These have been implemented as CSS properties as in SVG 2, these
are geometry properties that can be used in CSS (see
https://www.w3.org/TR/SVG/geometry.html), but there is not much browser
support for this. It is nicer to implement than the ad-hoc SVG
attribute parsing though, so I feel it may make sense to port the rest
of the attributes specified here (which should fix some issues with
viewport relative sizes).
2024-01-29 10:01:10 +00:00
Aliaksandr Kalenik
556679fedd LibWeb: Account for scroll offset in hit-testing
The hit-testing position is now shifted by the scroll offsets before
performing any checks for containment. This is implemented by assigning
each PaintableBox/InlinePaintable an offset corresponding to the scroll
frame in which it is contained. The non-scroll-adjusted position is
still passed down when recursing to children because the assigned
offset accumulated for nested scroll frames.

With this change, hit testing works in the Inspector.
Fixes https://github.com/SerenityOS/serenity/issues/22068
2024-01-29 09:57:40 +01:00
Timothy Flynn
6981ddfe13 LibWeb: Implement the ReadableByteStreamTee half of ReadableStreamTee 2024-01-29 07:21:59 +01:00
Timothy Flynn
debfe996d7 LibWeb: Implement the ReadableStreamDefaultTee half of ReadableStreamTee 2024-01-29 07:21:59 +01:00
Aliaksandr Kalenik
20de69693b LibWeb: Fix hidden overflow clipping with nested CSS transforms
This is a fix for regression introduced in
0bf82f748f

All CSS transforms need to be removed from the clip rectangle before
applying it. However, it is still necessary to calculate it with
applied transforms to find the correct intersection of all clip
rectangles in the containing block chain.
2024-01-29 07:21:38 +01:00
Tim Ledbetter
d1226f0b15 LibWeb: Don't crash when querying offsets of empty inline elements
Previously, querying `offsetTop` or `offsetLeft` of an inline element
with no text would cause a crash.
2024-01-28 23:32:40 +01:00
Tim Ledbetter
99fbd33d7d LibWeb: Make button flex wrapper inherit min-height property
This ensures that the vertical positioning of button text is correct
if a `min-height` property is present.
2024-01-28 14:48:33 +01:00
Aliaksandr Kalenik
0bf82f748f LibWeb: Move clip rect calculation to happen before painting
With this change, clip rectangles for boxes with hidden overflow or the
clip property are no longer calculated during the recording of painting
commands. Instead, it has moved to the "pre-paint" phase, along with
the assignment of scrolling offsets, and works in the following way:

1. The paintable tree is traversed to collect all paintable boxes that
   have hidden overflow or use the CSS clip property. For each of these
   boxes, the "final" clip rectangle is calculated by intersecting clip
   rectangles in the containing block chain for a box.
2. The paintable tree is traversed another time, and a clip rectangle
   is assigned for each paintable box contained by a node with hidden
   overflow or the clip property.

This way, clipping becomes much easier during the painting commands
recording phase, as it only concerns the use of already assigned clip
rectangles. The same approach is applied to handle scrolling offsets.

Also, clip rectangle calculation is now implemented more correctly, as
we no longer stop at the stacking context boundary while intersecting
clip rectangles in the containing block chain.

Fixes:
https://github.com/SerenityOS/serenity/issues/22932
https://github.com/SerenityOS/serenity/issues/22883
https://github.com/SerenityOS/serenity/issues/22679
https://github.com/SerenityOS/serenity/issues/22534
2024-01-28 08:25:28 +01:00
MacDue
5cf1570f40 LibWeb: Add initial support for nesting SVG viewports
Previously, we were handling viewBoxes/viewports in a slightly hacky
way, asking graphics elements to figure out what viewBox to use during
layout. This does not work in all cases, and can't allow for more
complex SVGs where it is possible to have nested viewports.

This commit makes the SVGFormattingContext keep track of the
viewport/boxes, and it now lays out each viewport recursively, where
each nested `<svg>` or `<symbol>` can establish a new viewport.

This fixes some previous edge cases, and starts to allow nested
viewports (there's still some issues to resolve there).

Fixes #22931
2024-01-27 18:12:13 +01:00
Andreas Kling
546143e9a6 LibWeb: Fix vector OOB access when comparing some calc() values
Before comparing the elements of two vectors, we have to check that
they have the same length. :^)

Fixes a crash seen on https://chat.openai.com/
2024-01-27 17:06:43 +01:00
Timothy Flynn
9272d185ad LibWeb: Implement a slightly better ad-hoc Body::clone method
Just creating a stream on the JS heap isn't enough, as we will later
crash when trying to read from that stream as it hasn't been properly
initialized. Instead, until we have teeing implemented (which is a
rather huge part of the Streams spec), create streams using proper AOs
that do initialize the stream.
2024-01-27 16:01:56 +01:00
Andrew Kaster
08a3c562f3 LibWeb: Resolve postMessage test promises if iframes already loaded
For some reason on macOS with ASAN enabled, the test promises in
HTML/Window-postMessage do not resolve. These promises wait for both
the in-document and the blob url iframes to load. It's not clear why
this works fine in Linux nor why the onload handler doesn't fire
when the iframe has already loaded.
2024-01-27 07:51:30 +01:00
Sam Atkins
e025bcc4f9 LibWeb: Make use of transform-box when calculating transforms
We don't currently calculate the fill- or stroke-boxes of SVG elements,
so for now we use the content- and border-boxes respectively, as those
are the closest equivalents. The test will need updating when we do
support them.

Also, the test is a screenshot because of rendering differences when
applying transforms: a 20px box does not get painted the same as a 10px
box scaled up 2x. Otherwise that would be the more ideal form of test.
2024-01-27 07:46:37 +01:00
Sam Atkins
391cfdc085 LibWeb: Parse the CSS transform-box property 2024-01-27 07:46:37 +01:00
Nico Weber
c694d4326b Tests: Add a pam cmyk test file
Hand-written in a text editor.

I verified that `convert` converts it to a png that looks like the
rgb test expectations.
2024-01-26 07:36:53 +01:00
Nico Weber
ba8f4e73bf Tests: Add a pam test file
Hand-written in a text editor.

I verified that `convert` converts it to a png that looks like the
test expectations.
2024-01-26 07:36:53 +01:00
Aliaksandr Kalenik
d5e3158cfe LibWeb: Use PaintableFragment::baseline() in paint_text_decoration()
No need to calculate baseline based on glyph height when we can get
this information from a fragment.
2024-01-26 07:36:40 +01:00
Timothy Flynn
09124fc3a5 LibWeb: Set up the Fetch response's body with the appropriate stream 2024-01-25 21:34:03 +01:00
Nico Weber
550937f5dd Tests: Add a test cmyk jpeg file with an embedded color profile
I opened Base/res/graphics/buggie.png in Photoshop, converted it
to U.S. Web Coated (SWOP) v2, flattened the image so we don't have
CMYK with alpha, and saved it as a jpeg (with color profile embedded).
2024-01-25 15:53:44 +01:00
Aliaksandr Kalenik
c02820759b LibWeb: Test nested elements in InlinePaintable::hit_test()
Before this change we were ignoring nested paintables inside inline
paintable during hit-testing, but now we recurse into subtree.

Fixes https://github.com/SerenityOS/serenity/issues/22927
2024-01-25 15:53:18 +01:00
Andreas Kling
1583e6ce07 LibWeb: Clamp justification space between flex items to 0
Before this change, it was possible for flex lines with negative
remaining space (due to overflowing items) to put a negative amount
of space between items for some values of `justify-content`.

This makes https://polar.sh/SerenityOS look much better :^)
2024-01-25 15:10:21 +01:00
Andreas Kling
e668cdcf22 Tests/LibWeb: Skip HTML/Window-postMessage.html since it's flakey 2024-01-25 13:50:40 +01:00
Andreas Kling
b12541b286 LibWeb: Add SVGSVGElement.viewBox attribute
This attribute has some compatbility issues...
- The spec says it should be an SVGAnimatedRect which contains
  a DOMRect and a DOMReadOnlyRect.
- Blink gives you an SVGAnimatedRect with 2x SVGRect
- Gecko gives you an SVGAnimatedRect with 2x SVGRect? (nullable)

I ended up with something similar to Gecko, an SVGAnimatedRect
with 2x DOMRect? (nullable)

With this fixed, we can now load https://polar.sh/ :^)
2024-01-25 08:23:41 +01:00
Lucas CHOLLET
a17041fe7f LibGfx/TIFF: Add support for CMYK
The test case has been generated with Krita.
2024-01-24 22:16:22 -07:00
Andrew Kaster
bf32a2027b LibWeb: Add happy path test for SubtleCrypto importKey and digest 2024-01-23 14:07:06 -07:00
Tim Ledbetter
7a3fc621bd LibWeb: Remove invalid assertion in table fixup
Previously, our code for the fixup of table rows assumed that missing
cells in a table row must be sequential. This may not be true if the
table contains cells have a rowspan greater than one.
2024-01-23 10:17:00 +01:00
Lucas CHOLLET
1faf9bb44f LibGfx/TIFF: Apply the HorizontalDifferencing on the alpha channel
When present, the alpha channel is also affected by the horizontal
differencing predictor.

The test case was generated with GIMP with the following steps:
 - Open an RGB image
 - Add a transparency layer
 - Export as TIFF with the LZW compression scheme
2024-01-22 20:10:48 -07:00
Aliaksandr Kalenik
1294cfb55c LibWeb: Find font that has whitespace glyph in first_available_font()
Fixes https://github.com/SerenityOS/serenity/issues/22853
2024-01-22 14:14:59 +01:00
MacDue
9f710b0fb6 Revert "LibGfx: Slightly simplify Color::blend()"
This was producing incorrect results.

This reverts commit a1bafafd78.
2024-01-22 07:12:25 +01:00
Dan Klishch
b5f1a48a7c AK+Everywhere: Remove JsonValue APIs with implicit default values 2024-01-21 15:47:53 -07:00
Dan Klishch
faef802229 AK+GMLCompiler: Remove JsonValue::as_double()
Replace its single (non-test) usage with newly created as_number(),
which does not leak information about internal integer storage type.
2024-01-21 15:47:53 -07:00
Dan Klishch
5230d2af91 AK+WebContent: Remove JsonValue::as_{i,u}{32,64}() 2024-01-21 15:47:53 -07:00
Dan Klishch
b74df136fe JSSpecCompiler: Always treat trailing MemberAccess as punctuation
Due to the way expression parser is written, we need to resolve the
ambiguity between member access operators and dots used for punctuation
during lexing. The lexer uses a (totally bulletproof) heuristic to do
that: whenever '.' is followed by ' ' or '\n', it is considered a dot
and member access otherwise. While it works fine for prettified test
cases, non-prettified files often lack enter after a trailing dot
character. Since MemberAccess will always be invalid at that position,
explicitly treat trailing dot as a part of punctuation.
2024-01-21 14:57:10 -07:00
Dan Klishch
b4a9fde756 JSSpecCompiler: Recurse into the correct subtrees in RecursiveASTVisitor
RecursiveASTVisitor was recursing into the subtrees of an old root if it
was changed in on_entry callback. Fix that by querying root pointer just
after on_entry callback returns. While on it, also use
`AK::TemporaryChange` instead of setting `m_current_subtree_pointer`
manually.

As it turns out, `FunctionCallCanonicalizationPass` was relying on being
able to replace tree on entry, and the bug in RecursiveASTVisitor made
the pass to not fully canonicalize nested function calls.

The changes to GenericASTPass.cpp alone are enough to fix the problem
but it is canonical (for some definition of canonicity) to only change
trees in on_leave. Therefore, the commit also switches
FunctionCallCanonicalizationPass to on_leave callback.

A test for this fix and one from the previous commit is also included.
2024-01-21 14:57:10 -07:00
Ali Mohammad Pur
4f6c9f410c AK+LibCore: Add BufferedSocket::can_read_up_to_delimiter()
This method (unlike can_read_line) ensures that the delimiter is present
in the buffer, and doesn't return true after eof when the delimiter is
absent.
2024-01-21 21:13:58 +01:00
Aliaksandr Kalenik
7e2308d290 LibWeb: Treat null as empty string in CSSStyleDeclaration::internal_set
Spec defines `[LegacyNullToEmptyString]` on `value` argument of
`setProperty` but since `internal_set` calls `setProperty` directly
instead of using IDL generated binding, we need to make sure that null
is treated as empty string.

Fixes items grid loading on https://d.rsms.me/stuff/
2024-01-21 21:03:39 +01:00
MacDue
e9e1ee11d4 LibGfx: Decrease flatness a little in Path::stroke_to_fill()
Noticed larger stroke widths were looking a little 'low poly', this
looks a little nicer.

(Minor LibWeb test changes)
2024-01-21 19:23:31 +01:00
Tim Ledbetter
58df9c45b9 LibWeb: Avoid division by zero when computing table width
Previously, a crash could occur when computing the width of a table
with cells that had a percentage width of 0.
2024-01-21 16:11:25 +01:00
Andreas Kling
1041dbb007 LibWeb: Don't lose track of inline margins when collapsing whitespace
When iterating inline level chunks for a piece of text like " hello ",
we will get three separate items from InlineLevelIterator:

- Text " "
- Text "hello"
- Text " "

If the first item also had some leading margin (e.g margin-left: 10px)
we would lose that information when deciding that the whitespace is
collapsible.

This patch fixes the issue by accumulating the amount of leading margin
present in any collapsed whitespace items, and then adding them to the
next non-whitespace item in IFC.

It's a wee bit hackish, but so is the rest of the leading/trailing
margin mechanism.

This makes the header menu on https://www.gimp.org/ look proper. :^)
2024-01-20 23:29:51 +01:00
Aliaksandr Kalenik
c1161111a7 LibWeb: Stop assuming navigable's existance in FrameBox
If the loading of iframe's navigable has not finished by the time
FrameBox layout occurs, we should not crash.

Fixes https://github.com/SerenityOS/serenity/issues/22874
2024-01-20 20:34:30 +00:00
Bastiaan van der Plaat
e2bc606eeb LibWeb: Add MouseEvent JavaScript constructor 2024-01-20 08:57:37 +01:00
Bastiaan van der Plaat
9aadc6c8c9 LibWeb: Add missing EventModifierInit fields and getModifierState 2024-01-20 08:57:37 +01:00
Sam Atkins
071f7fd818 LibCore+JSSpecCompiler: Add option for Process::spawn() to use spawnp()
Add a boolean to ProcessSpawnOptions, `search_for_executable_in_path`,
which when true, calls into posix_spawnp() instead of posix_spawn().
This defaults to false to maintain the existing behavior.

The `path` field is renamed to `executable` because having two fields
refer to "path" and mean different things seemed unnecessarily
confusing.
2024-01-19 12:16:21 -07:00
Lucas CHOLLET
c2c7365494 LibGfx/TIFF: Accept images with a single strip and no RowsPerStrip tag
This tag is required by the specification, but some encoders (at least
Krita) don't write it for images with a single strip.

The test file was generated by opening deflate.tiff in Krita and saving
it with the DEFLATE compression.
2024-01-19 14:13:44 +01:00
Andrew Kaster
682a6d5882 Tests: Add tests for navigation.navigate() 2024-01-19 11:47:59 +01:00
Andrew Kaster
6c1944ee61 LibWeb: Flesh out apply the history step to setup the navigation API
We now populate the navigation history entries in the navigation API and
fire more navigation events as appropriate.
2024-01-19 11:47:59 +01:00
Andreas Kling
9f6841a65c LibWeb: Update layout before looking at overflow in window.scroll()
Fixes a crash seen on https://www.ekioh.com/
2024-01-19 09:16:54 +01:00
Andrew Kaster
2505cecc0f LibWeb: Exclude [Global] interfaces from legacy platform object methods
Window and other global objects are not technically legacy platform
objects, and have other ways to override their setters and getters.

However, Window does need to share some code with the legacy platform
object paths, and simply adding another bool check to the mix seems
the shortest putt.
2024-01-19 09:02:00 +01:00
Timothy Flynn
2b22402c6a LibWeb: Correctly categorize Fetch responses as network errors
The condition here is flipped. From the spec:

     A network error is a response whose ... body is null ...
2024-01-18 23:10:56 +01:00
implicitfield
05ee5ffa36 LibCrypto: Add support for the POSIX cksum algorithm 2024-01-18 18:01:26 +03:30
Nico Weber
09a91e54c0 Tests: Add a pdf with text rotation
As usual, lovingly hand-written, with offsets fixed up with

    mutool clean Tests/LibPDF/rotate.pdf  Tests/LibPDF/rotate.pdf
2024-01-18 14:01:30 +01:00
Nico Weber
8507151850 Tests/LibPDF: Make text.pdf also use Tz, Tc, Tw, Ts operators
These set the horizontal scale factor, character spacing, word
spacing, and text rise respectively.

Also add a global scale transform, and set a text transform matrix
with a scale for some of the text.
2024-01-18 14:01:30 +01:00