Commit Graph

5765 Commits

Author SHA1 Message Date
Aliaksandr Kalenik
31b9729333 LibWeb: Add Page::has_ongoing_navigation()
Introduce has_ongoing_navigation() that allows to check if resource
state in FrameLoading is pending. This API is going to be used in
upcoming fix for wait_for_navigation_to_complete() in WebDriver.
2023-05-30 20:40:23 +02:00
Aliaksandr Kalenik
857ceb215c LibWeb/WebDriver: Support resolve with callback in execute_async_script
Before execute_async_script supported returning value from script to
/execute/async caller only if script returns promise that resolves into
returned value. This change fixes execute_async_script to also support
returning value to caller using callback that is always passed to
script as a last argument.
2023-05-30 18:55:47 +02:00
Ali Mohammad Pur
0e3fb39a0a LibWeb: Make 'optional BufferSource' IDL arguments actually optional
Previously this was compiled to require an object despite the IDL file
specifying 'optional'.
This commit makes IDLGenerator respect this modifier, and fixes the only
affected instance.
2023-05-30 12:50:13 +02:00
Andi Gallo
7f9ede07bc LibWeb: Set margin, padding and border for replaced boxes
Separating the paths for replaced and non-replaced floating boxes lost
the logic for margin, padding and border which was done by
compute_width_for_floating_box. Set them the same way as we do for
block-level replaced elements, per the specification.
2023-05-30 10:09:47 +02:00
Andi Gallo
e48074e401 LibWeb: Make font selection closer to specification
Add matching on family name, style and weight. This improves the fonts
used by the MDN examples.
2023-05-30 07:47:57 +02:00
stelar7
518679b0dd LibWeb: Adjust change event timing for input elements 2023-05-30 06:17:36 +02:00
FalseHonesty
cabfb7867c LibWeb: Add support for parsing 'inset' shorthand CSS property 2023-05-30 06:02:06 +02:00
Timothy Flynn
e129c8049b LibWeb: Restore protection against empty HTMLImageElement resources
This if-statement was erroneously dropped in commit 8ff8309.
2023-05-30 05:50:07 +02:00
Aliaksandr Kalenik
0bef3085dd LibWeb: Output names of inner table boxes in layout dump
Since there are no table-specific boxes anymore it would be nice to
output their types additionally in layout dump so we can tell table
boxes from "regular" boxes.
2023-05-29 21:36:17 +02:00
Aliaksandr Kalenik
787f2d2a10 LibWeb: Remove Layout::TableCellBox
Special box types for inner table boxes might conflict with special
types for <button>, <input> or <label>.
2023-05-29 21:36:17 +02:00
Aliaksandr Kalenik
3a3a085404 LibWeb: Remove Layout::TableRowBox
Special box types for inner table boxes might conflict with special
types for <button>, <input> or <label>.
2023-05-29 21:36:17 +02:00
Aliaksandr Kalenik
578a937f94 LibWeb: Remove Layout::TableRowGroupBox
Special box types for inner table boxes might conflict with special
types for <button>, <input> or <label>.
2023-05-29 21:36:17 +02:00
Andreas Kling
af004ff0ef LibWeb: Support min-content for width, min-width and max-width
We're gonna need to handle this in many more places, this patch only
adds it to calculate_inner_width().
2023-05-29 21:29:25 +02:00
Andreas Kling
97c510329c LibWeb: Support max-content for width, min-width and max-width
We're gonna need to handle this in many more places, this patch only
adds it to calculate_inner_width().
2023-05-29 21:29:25 +02:00
Timothy Flynn
8ff8309202 LibWeb: Update workarounds for fetching CORS cross-origin responses
Now that the processResponseConsumeBody algorithm receives the internal
response body of the fetched object, we do not need to go out of our way
to read its body from outside of fetch.

However, several elements do still need to manually inspect the internal
response for other data, such as response headers and status. Note that
HTMLScriptElement already does the new workaround as a proper spec step.
2023-05-29 17:12:46 +02:00
Timothy Flynn
6406a561ef LibWeb: Handover the fetch response's internal body data upon completion
These is a normative change to the Fetch spec. See:
https://github.com/whatwg/fetch/commit/9003266
https://github.com/whatwg/fetch/commit/b5a587b
2023-05-29 17:12:46 +02:00
Aliaksandr Kalenik
258f3ea952 LibWeb: Remove Layout::TableBox
Solves conflict in layout tree "type system" when elements <label> (or
<button>) can't have `display: table` because Box can't be
Layout::Label (or Layout::ButtonBox) and Layout::TableBox at the same
time.
2023-05-29 14:12:29 +02:00
Andreas Kling
5857f24bc8 LibWeb: Only update style for the element being animated by CSS
Unlike DOM mutations, CSS animations don't affect the style of the
entire subtree of the element being animated. This means we only have to
recompute style for the animating element, which is significantly
faster than doing the whole subtree.

This takes idle CPU usage on https://shopify.com/ from 100% to 30% on my
(not massively powerful) laptop. :^)
2023-05-29 06:05:03 +02:00
Ali Mohammad Pur
3ed26e9af8 LibWeb: Respect the CSS animation-direction property for animations 2023-05-29 05:35:41 +02:00
Ali Mohammad Pur
19c92fa354 LibWeb: Respect the animation-fill-mode CSS property 2023-05-29 05:35:41 +02:00
Ali Mohammad Pur
2e71263c5c LibWeb: Make sure finished animations are not restarted
This commit makes the StyleComputer avoid restarting finished animations
(e.g. animations with finite iteration counts that have run to
completion).
As a bonus, it also disables the animation timer when all animations
have finished running.
2023-05-29 05:35:41 +02:00
Ali Mohammad Pur
e90752cc21 LibWeb: Add preliminary support for CSS animations
This partially implements CSS-Animations-1 (though there are references
to CSS-Animations-2).
Current limitations:
- Multi-selector keyframes are not supported.
- Most animation properties are ignored.
- Timing functions are not applied.
- Non-absolute values are not interpolated unless the target is also of
  the same non-absolute type (e.g. 10% -> 25%, but not 10% -> 20px).
- The JavaScript interface is left as an exercise for the next poor soul
  looking at this code.

With those said, this commit implements:
- Interpolation for most common types
- Proper keyframe resolution (including the synthetic from-keyframe
  containing the initial state)
- Properly driven animations, and proper style invalidation

Co-Authored-By: Andreas Kling <kling@serenityos.org>
2023-05-29 05:35:41 +02:00
Ali Mohammad Pur
f07c4ffbc8 LibWeb: Add CSS::Time::to_milliseconds() 2023-05-29 05:35:41 +02:00
Ali Mohammad Pur
b7e3a68bfc LibWeb: Keep track of CSS property source declarations
This allows us to figure out where a specific CSS property comes from,
which is going to be used in a future commit to uniquely identify
running animations.
2023-05-29 05:35:41 +02:00
Ali Mohammad Pur
279924242d LibWeb: Add CSS CompositeStyleValue
This represents the value of properties assigned via their shorthands,
and is expanded when computing actual property values.
2023-05-29 05:35:41 +02:00
Ali Mohammad Pur
49bb04a6ba LibWeb: Visit CSS block tokens for var() tokens as well
Also extract the equirecursive lambda functions into separate functions
to simplify the code a little bit.
2023-05-29 05:35:41 +02:00
Ali Mohammad Pur
5cd01bd644 LibWeb: Allow '0' as a CSS dimension value
The comment mentions that zero is let through, but then immediately
errors out if it sees any number outside quirks mode.
This commit makes that check let zeros through.
2023-05-29 05:35:41 +02:00
Aliaksandr Kalenik
ac280277b7 LibWeb: Use HashMap instead of Vector to store grid areas in GFC
Grid areas are accessed by their name (string) so HashMap is more
appropriate data structure to store them.
2023-05-28 21:28:28 +02:00
Aliaksandr Kalenik
94fd17a467 LibWeb: Wrap child text sequences of grid container in anonymous blocks
From spec https://drafts.csswg.org/css-grid/#grid-items:
"Each in-flow child of a grid container becomes a grid item, and each
child text sequence is wrapped in an anonymous block container grid
item."

Fixes the problem that text sequences inside grid containers are
ignored and not displayed.
2023-05-28 21:12:04 +02:00
Aliaksandr Kalenik
537256fae2 LibWeb: Treat unresolvable percentages as auto to resolve sizes in GFC
Fixes the bug that currently we always consider tracks with percentage
size as ones with "fixed" length even when available size is not
definite. With this change tracks with percentage size when available
size is not definite will be considered as "intrinsic" sized.
2023-05-28 20:26:05 +02:00
Andreas Kling
30feb95d53 LibWeb: Support reverse flex layout with space-around/space-between
We were not taking reverse flex directions into account when choosing
the initial offset for flex item placement if justify-content were
either space-around or space-between.
2023-05-28 18:02:00 +02:00
Andi Gallo
b8a097f74b LibWeb: Add missing check in CrossOriginGetOwnPropertyHelper
We have to check that the entry in CrossOriginProperties is the one
actually requested from the caller before executing the body of the
loop. This fixes a crash triggered by YouTube iframe embedding.
2023-05-28 18:00:54 +02:00
Shannon Booth
500552df54 LibWeb: Apply rules for parsing a legacy color value 2023-05-28 13:24:37 +02:00
Shannon Booth
bc54560e59 LibWeb: Add Web::HTML::parse_legacy_color_value
This function follows the "rules for parsing a legacy color value"
which is used in some legacy attributes, such as 'bgcolor' in the body
element.
2023-05-28 13:24:37 +02:00
Andi Gallo
c411b5408e LibWeb: Improve support for selecting an image source
Apply media conditions before selecting a size and add an algorithm to
select an image source based on pixel density.
2023-05-28 12:11:10 +02:00
Andi Gallo
29d29134ba LibWeb: Skip children based on media when updating the source set
If child has a media attribute and its value does not match the
environment, continue to the next child.
2023-05-28 12:11:10 +02:00
Andreas Kling
87ac906ee6 LibJS: Make Error stack traces lazier
Instead of eagerly populating the stack trace with a textual
representation of every call frame, just store the raw source code range
(code, start offset, end offset). From that, we can generate the full
rich backtrace when requested, and save ourselves the trouble otherwise.

This makes test-wasm take ~7 seconds on my machine instead of ~60. :^)
2023-05-28 10:03:11 +02:00
MacDue
02d131bc4d LibWeb: Fix goofy CRC2D.arc() behaviour
This PR corrects the signs of the start/end points that are passed
to the elliptical_arc_to(), it also removes the bogus path.close()
after creating the arc. Now .arc() seems to work correctly.
2023-05-27 22:13:26 +02:00
Sam Atkins
af68bf862f LibWeb: Resolve border[-color,-style,-width] properties 2023-05-27 20:55:00 +02:00
Sam Atkins
abdd4a8733 LibWeb: Add helper for creating resolved values for sided shorthands
...and use it for `margin` and `padding`.

So now, if all four margins are 12px, we output "12px" instead of "12px
12px 12px 12px". This matches the spec's requirement to use the smallest
non-ambiguous representation.
2023-05-27 20:55:00 +02:00
Sam Atkins
e8dc8f697b LibWeb: Alphabetize style_value_for_property() property list 2023-05-27 20:55:00 +02:00
Sam Atkins
ee1fc56f02 LibWeb: Resolve background-size property 2023-05-27 20:55:00 +02:00
Sam Atkins
d5fbec8a49 LibWeb: Resolve background-position[-x,-y] properties 2023-05-27 20:55:00 +02:00
Sam Atkins
3ed2c6da72 LibWeb: Resolve appearance property 2023-05-27 20:55:00 +02:00
Sam Atkins
db09f0e0c1 LibWeb: Resolve align-{content,items,self} properties 2023-05-27 20:55:00 +02:00
Sam Atkins
6a51ef9c9b LibWeb: Resolve accent-color property 2023-05-27 20:55:00 +02:00
Sam Atkins
0374b42f20 LibWeb: Remove CSS:: prefix from ResolvedCSSStyleDeclaration.cpp code
These prefixes weren't adding anything except some visual clutter, in
code that already has A::Lot::Of::This.
2023-05-27 20:55:00 +02:00
MacDue
6f8c2dc322 LibWeb: Make SVG transform parser less crashy
Previously, this would blindly use parse_number() without checking if
there was a number to parse. This meant we would crash on transforms
like:
	rotate(BAD 32 0)

Now the attribute just gracefully fails to parse.
2023-05-27 18:40:41 +02:00
Andreas Kling
33500bb6db LibWeb: Protect against null deref during Web::Page initialization
BrowsingContext::set_active_document() may end up asking for the Page's
top level browsing context before Page has one. Do a workaround for now
where we have an API to ask if it's initialized.

Long-term we should find a cleaner solution.
2023-05-27 18:38:40 +02:00
Andreas Kling
fdbdc4d5ff LibWeb: Only forward scroll requests for the top-level browsing context
We don't want to scroll the whole web view just because some iframe is
asking to be scrolled.
2023-05-27 17:26:29 +02:00