Commit Graph

53090 Commits

Author SHA1 Message Date
Sam Atkins
4df5e24926 LibWeb: Implement the :playing and :paused pseudo-classes
These match media elements (`<video>` and `<audio>`) which are playing
or paused, respectively.
2023-08-01 12:50:40 -04:00
Sam Atkins
a336fe4fc4 LibWeb: Include all pseudo-classes in SimpleSelector::serialize
Rather than logging ones that are missed, just rely on the compiler to
complain if one is missing. `:indeterminate` was. :^)
2023-08-01 12:50:40 -04:00
Timothy Flynn
44911173f5 LibWeb: Make VideoPaintable's clip rect temporary
Otherwise, in a simple page such as:

    <video src=...>
    <audio src=...>

The video's clip rect would "leak" to the AudioPaintable, preventing the
audio controls from rendering at all.
2023-08-01 11:14:26 -04:00
Timothy Flynn
902c2ef5a3 LibWeb: Add a clip rect for AudioPaintable
Not a huge deal because the base MediaPaintable class goes very out of
its way to paint within the confines of its own box, but just to be
safe, this was missed when adding the AudioPaintable class.
2023-08-01 11:14:26 -04:00
Timothy Flynn
c31e8cad1e LibWeb: Remove unused VideoBox preferred width/height methods
These were copied from some other paintable, but were never used for
video.
2023-08-01 11:14:26 -04:00
Aliaksandr Kalenik
338fa8261e LibWeb: Use item minimum contribution while sizing "fr" track in GFC
Fixes the issue that before "automatic minimum size" were used to size
flexible tracks even though specification says is should be "minimum
contribution"
2023-08-01 16:25:10 +02:00
Andreas Kling
e91bdedc93 LibJS: Use correct this value when callee is a with binding
If we're inside of a `with` statement scope, we have to take care to
extract the correct `this` value for use in calls when calling a method
on the binding object via an Identifier instead of a MemberExpression.

This makes Vue.js work way better in the bytecode VM. :^)

Also, 1 new pass on test262.
2023-08-01 16:08:21 +02:00
Tom
e61fdd1dc6 LibWeb: Use viewbox attribute in SVG symbol element
Previously when a viewBox was passed to a SVG symbol element it would
not be taken into account when drawing the SVG.
2023-08-01 14:40:51 +02:00
stelar7
9f73fc87a8 LibWeb: Add tests for calc function nodes 2023-08-01 14:39:31 +02:00
Karol Kosek
eb41f0144b AK: Decode data URLs to separate class (and parse like every other URL)
Parsing 'data:' URLs took it's own route. It never set standard URL
fields like path, query or fragment (except for scheme) and instead
gave us separate methods called `data_payload()`, `data_mime_type()`,
and `data_payload_is_base64()`.

Because parsing 'data:' didn't use standard fields, running the
following JS code:

    new URL('#a', 'data:text/plain,hello').toString()

not only cleared the path as URLParser doesn't check for data from
data_payload() function (making the result be 'data:#a'), but it also
crashes the program because we forbid having an empty MIME type when we
serialize to string.

With this change, 'data:' URLs will be parsed like every other URLs.
To decode the 'data:' URL contents, one needs to call process_data_url()
on a URL, which will return a struct containing MIME type with already
decoded data! :^)
2023-08-01 14:19:05 +02:00
Karol Kosek
f27b9b9563 LibWeb: Set Content-Type for data: URLs instead of checking MIME on load
This makes the loader more agnostic.

Additionally, this allows us to load tab in Ladybird with a 'data:' URL
containing parameters, as a Resource will now call
`mime_type_from_content_type` to extract the content type from MIME. :^)
2023-08-01 14:19:05 +02:00
Karol Kosek
16836e7e62 LibWeb: Remove checking for AllowedDataUrlType
CSS shouldn't probably check if a MIME type in the 'data:' URL is
correct or not. Every URL gets sent to a ResourceLoader so a client can
just validate if got file with correct media type.

This also makes loading 'data:' URLs in @import work now, as we didn't
have AllowedDataUrlType for stylesheets.
2023-08-01 14:19:05 +02:00
Karol Kosek
58017a0581 AK: Clear buffer after leaving CannotBeABaseUrlPath in URLParser
By not clearing the buffer, we were leaking the path part of a URL into
the query for URLs without an authority component (no '//host').

This could be seen most noticeably in mailto: URLs with header fields
set, as the query part of `mailto:user@example.com?subject=test` was
parsed to `user@example.comsubject=test`.

data: URLs didn't have this problem, because we have a special case for
parsing them.
2023-08-01 10:10:07 +02:00
Andreas Kling
28fdc7af05 LibWeb: Detach stale layout nodes from DOM during layout tree build
When toggling `display: none` on an element, it can go from having a
layout subtree to not having one. In the `none` case, we were previously
leaving stale layout nodes hanging off DOM nodes in the subtree.

These layout nodes could be queried for outdated information and
probably other things that we shouldn't allow.

Fix this by having TreeBuilder prune any old layout nodes hanging off
nodes in a subtree after its subtree root doesn't produce a layout node.
2023-08-01 09:19:41 +02:00
Sam Atkins
0805060e5e LibWeb: Speed up CSS namespace checking
CSSStyleSheet now caches the CSSNamespaceRule for the default namespace,
which is the only one we currently care about. This saves us from
iterating over its list of rules every time we want to know what that
default namespace is.

The spec dictates that `@namespace` rules are only valid near the start
of a stylesheet, so we also take advantage of that to quit searching
for namespaces as soon as we see a non-import rule.

Also renamed `namespace_filter()` to `default_namespace()` since that's
what it actually returns.

This makes github.com/serenityos/serenity snappy again. :^)
2023-08-01 07:41:06 +02:00
Sam Atkins
496db17c2d LibWeb: Add callback for when a CSSRuleList's rules change 2023-08-01 07:41:06 +02:00
Andi Gallo
62f15f94d2 LibWeb: Better handling of floating boxes from inline formatting context
Handle the clear property for floating boxes and add tracking for
vertical clearence within an inline formatting context.
2023-08-01 07:38:19 +02:00
Sebastian Zaha
fd86509ef8 Ladybird: Remove unused spawn helper
The spawn_helper_process method was introduced together with
get_paths_for_helper_process but was only ever used briefly to spawn
WebContent. Other helper processes (SqlServer, headless_browser etc)
are either execed or spawned with their own helpers & custom arguments.
2023-08-01 07:36:15 +02:00
Sebastian Zaha
05fc63932b Ladybird: Fix JS console crash when history is empty
Do not try to navigate JS console history forward when it is empty. A
crash was occurring because of size_t underflow.
2023-08-01 07:33:36 +02:00
Lucas CHOLLET
cd0fe4bb48 Kernel: Mark sys$poll as not needing the big lock 2023-08-01 05:35:26 +02:00
Lucas CHOLLET
00240cb0b3 LibGfx/JPEGXL: Fix property 8
The first implementation of this property was just plain wrong. Looks
like this property isn't used a lot as I found the issue by reviewing
the code and not because of a specific image.

The test image is a 32x32 mosaic of alternating black and yellow pixels,
it was generated using this code:

Bitdepth 8
RCT 1
Width 32
Height 32

if W-WW-NW+NWW > -300
 - Set -1000
 - Set 900
2023-08-01 05:35:01 +02:00
Lucas CHOLLET
6b41fef2e4 LibGfx/JPEGXL: Add default values for ToneMapping 2023-08-01 05:35:01 +02:00
Andrew Kaster
b6d60980bb Ladybird: Rename FontPluginQt -> Ladybird as it is unrelated to Qt now
The Qt relationship was removed in de31a8a4, so let's acknowledge that
and make it clearer to potential non-Qt ports that this file is usable
by them :^).
2023-08-01 05:06:40 +02:00
Tim Ledbetter
6ba38494c5 Ports: Add cowsay 2023-08-01 04:42:20 +02:00
Nico Weber
ecef13338e Meta: Only write first output file to depfile
There's no advantage to writing more than one file, and it lets the
depfile work with older versions of ninja.
2023-07-31 14:55:03 -06:00
Sam Atkins
f9ad5a450c Documentation: Fix typo in Spice documentation filename 2023-07-31 20:01:56 +01:00
ronak69
39e58f8954 Documentation: Add links of all docs that aren't mentioned anywhere 2023-07-31 19:59:33 +01:00
Andrew Kaster
804188ac0c Meta: Port 1d59a62944 to gn build 2023-07-31 12:02:17 -06:00
Timothy Flynn
1d59a62944 Ladybird: Remove macOS workaround for WebContent GUI interaction
This reverts commit 4dcdc3bd25.

Now that WebContent is a QCoreApplication, this workaround is no longer
needed.
2023-07-31 20:00:49 +02:00
Shannon Booth
aa7ca80d7c AK: Fix missing step step for serialization of IPv6 hosts
This was resulting in the incorrect host serialization of:

http://[0:1:0:1:0:1:0:1] to [::1:0:1:0:1:0:1]

and:

http://[1:0:1:0:1:0:1:0] to [1::1:0:1:0:1:0]
2023-07-31 14:48:24 +02:00
Shannon Booth
4fdd4dd979 AK: Add missing default port definitions for FTP scheme URLs
This is defined in the spec, but was missing in our table. Fix this, and
add a spec comment for what is missing. Also begin a basic text based
test for URL, so we can get some coverage of LibWeb's usage of URL too.
2023-07-31 14:48:24 +02:00
Shannon Booth
25153703c9 headless-browser: Improve error on failure to open expectation file
Mostly to output the path of the file which failed to open. This is
mostly helpful if you create a test, but forget to 'touch' the
expectation path.
2023-07-31 14:48:24 +02:00
Kemal Zebari
590f0f85e0 nohup: Don't leak fd used to open nohup.out
Since we may redirect stdout, stderr, or both to the file description
referring to the nohup.out file, there is no need to keep the fd that
created that file description around.
2023-07-31 10:47:59 +02:00
Kenneth Myhra
7da055e3e1 LibWeb: Remove unused headers in StructuredSerialize.cpp 2023-07-31 10:41:38 +02:00
Kenneth Myhra
9a007ccdbe LibWeb: Serialize strings into a more storage efficient format
This patch changes the way StructuredSerializeInternal() serialize
strings by storing four bytes into a 32-bit entry, instead of one code
point per 32-bit entry.

StructuredDeserialize() has also been changed to deserialize strings by
the same ruleset.
2023-07-31 10:41:38 +02:00
Andi Gallo
4cde5f6d76 LibWeb: Fix border for cells spanning entire table width or height
When a cell spans the entire width or height of a table, create its
border from the table box.
2023-07-31 10:40:31 +02:00
Andreas Kling
9937fcc5e1 LibWeb: Don't assume opacity values are CSS numbers
...since they can also be percentages. Better to resolve them to a pair
of absolute values, and then compare those. :^)

Regressed in 921aee8c66.
2023-07-31 09:16:18 +02:00
Andreas Kling
cb8664e2e1 LibWeb/BindingsGenerator: Fix the build
I'm not sure why this didn't break on CI, but none of my machines were
able to build without this change.
2023-07-31 07:39:49 +02:00
Tim Schumacher
5f69b0d6ad Base: Remove the empty /usr/lib and /usr/include directories
These have been there since the initial revision of the toolchain build
script, but we don't seem to require them being present in `Base` any
longer.
2023-07-31 06:26:58 +02:00
Ali Mohammad Pur
d9ed58eb39 LibRegex: Make OpCode_Compare use a switch-case instead of if-else
This has no performance impact, the if-elses have been annoying as it's
impossible to fold the entire thing in basically any IDE.
2023-07-31 05:31:33 +02:00
Ali Mohammad Pur
4e69eb89e8 LibRegex: Generate a search tree when patterns would benefit from it
This takes the previous alternation optimisation and applies it to all
the alternation blocks instead of just the few instructions at the
start.
By generating a trie of instructions, all logically equivalent
instructions will be consolidated into a single node, allowing the
engine to avoid checking the same thing multiple times.
For instance, given the pattern /abc|ac|ab/, this optimisation would
generate the following tree:
    - a
    | - b
    | | - c
    | | | - <accept>
    | | - <accept>
    | - c
    | | - <accept>
which will attempt to match 'a' or 'b' only once, and would also limit
the number of backtrackings performed in case alternatives fails to
match.

This optimisation is currently gated behind a simple cost model that
estimates the number of instructions generated, which is pessimistic for
small patterns, though the change in performance in such patterns is not
particularly large.
2023-07-31 05:31:33 +02:00
Ali Mohammad Pur
18f4b6c670 LibRegex: Add the literal string search optimisation
This switches to using a simple string equality check if the regex
pattern is strictly a string literal.
Technically this optimisation can also be made on bounded literal
patterns like /[abc]def/ or /abc|def/ as well, but those are
significantly more complex to implement due to our bytecode-only
approach.
2023-07-31 05:31:33 +02:00
Ali Mohammad Pur
221c52c696 LibRegex: Avoid slicing a RegexStringView in non-unicode Compare ops
Getting a single code point is much faster than slicing into the string.
2023-07-31 05:31:33 +02:00
Ali Mohammad Pur
11abca421a LibRegex: Always inline get_opcode()
This function's prologue was showing up as very hot in profiles, taking
almost 9% of runtime in our Regex test suite.
2023-07-31 05:31:33 +02:00
Ali Mohammad Pur
a539c261b1 Profiler: Correct the event names for 'malloc' and 'free'
These were renamed to 'kmalloc' and 'kfree' in the profile recording
infrastructure, but the Profiler application expected the old names
still.
2023-07-31 05:31:33 +02:00
Ali Mohammad Pur
7a471b7cf5 AK: Allow customising Trie's underlying map type
This makes it possible to use an ordered map and keep the insertion
order intact.
2023-07-31 05:31:33 +02:00
Hendiadyoin1
07e4358c63 AK: Use correct builtins for fmod and remainder
Similar to floor and ceil, we were forcing the values to be doubles here

Also adds a big FIXME about my findings trying to add a general
implementation for these
2023-07-31 05:22:12 +02:00
Hediadyoin1
c9808f0d4a AK: Use correct builtins for floor and ceil
We were using the double ones, forcing casts to and from them for floats
2023-07-31 05:22:12 +02:00
Hediadyoin1
29e0494e56 AK: Use builtins in fabs implementation and move it to the top
Both GCC and Clang inline this function to use bit-wise logic and/or
appropriate instructions even on -O0 and allow their use in a constexpr
context, see
https://godbolt.org/z/de1393vha
2023-07-31 05:22:12 +02:00
Hediadyoin1
594369121a AK: Add trunc and rint to AK/Math.h
These are useful in some algorithms, which require specific rounding.
2023-07-31 05:22:12 +02:00