Commit graph

27971 commits

Author SHA1 Message Date
Sam Atkins
5c7dca3526 LibWeb: Stop rejecting valid values for several CSS properties
In StyleResolver, we were rejecting single values for properties that
take 1-4: `border-color`, `border-style`, and `border-width`. Now, we
handle them correctly. I also added support for `calc()` and `var()` to
`padding` and `margin`.

This fixes the orange border on Acid2, which now correctly appears
black. :^)
2021-09-22 20:32:35 +02:00
Andreas Kling
635ab6db0b LibWeb: Expose the GlobalEventHandlers mixin on the Window object
We now expose all the `onfoo` event handler attributes on the window
object. This makes `window.onload = ...` actually work. :^)
2021-09-22 16:40:24 +02:00
Andreas Kling
fb2f7c7b9c LibWeb: Remove unnecessary WindowObject.h include in DOMException.h 2021-09-22 15:37:50 +02:00
Andreas Kling
1884e2caf1 LibWeb: Add DOM::ExceptionOr<T> to forwarding header 2021-09-22 15:37:21 +02:00
Andreas Kling
fccf0a466b LibWeb: Log resource load success before invoking success callback
The success callback may trigger JavaScript execution, causing resource
load times to appear much longer than they actually are. :^)
2021-09-22 14:35:13 +02:00
Andreas Kling
784ab75d2d LibCoredump: Don't copy uncompressed coredumps into a ByteBuffer
This was completely unnecessary and accounted for 6% of the total time
spent when loading a WebContent coredump into CrashReporter.
2021-09-22 00:40:07 +02:00
Idan Horowitz
1da8faebf5 LibJS: Convert perform_eval to ThrowCompletionOr 2021-09-21 23:28:38 +03:00
Idan Horowitz
e24d4c346d LibJS: Add VM::throw_completion helper for throwing custom Strings 2021-09-21 23:28:38 +03:00
Idan Horowitz
f302b114f3 LibJS: Convert get_substitution to ThrowCompletionOr 2021-09-21 23:28:38 +03:00
Idan Horowitz
69430855e0 LibJS: Remove non-specification compliant exception check 2021-09-21 23:28:38 +03:00
Idan Horowitz
e90e4ac1e2 LibJS: Convert length_of_array_like to ThrowCompletionOr 2021-09-21 23:28:38 +03:00
Idan Horowitz
02a88c5063 LibJS: Convert make_super_property_reference to ThrowCompletionOr 2021-09-21 23:28:38 +03:00
Andreas Kling
9d7fe39640 CrashReporter: Show coredump loading progress in the Taskbar :^) 2021-09-21 20:52:29 +02:00
Andreas Kling
f6f9599899 CrashReporter+LibCoredump: Show progress window while loading coredump
Some coredumps take a long time to symbolicate, so let's show a simple
window with a progress bar while they are loading.

I'm not super happy with the factoring of this feature, but it's an
absolutely kickass feature that makes crashing feel 100% more responsive
than before, since you now get GUI feedback almost immediately after a
crash occurs. :^)
2021-09-21 20:52:29 +02:00
Andreas Kling
4f224b15ed CrashDaemon+CrashReporter: Streamline crash reporting a little bit
Before this patch, this is what would happen after something crashed:

1. CrashDaemon finds a new coredump in /tmp
2. CrashDaemon compresses the new coredump (gzip)
3. CrashDaemon parses the uncompressed coredump and prints a backtrace
4. CrashDaemon launches CrashReporter
5. CrashReporter parses the uncompressed coredump (again)
6. CrashReporter unlinks the uncompressed coredump
7. CrashReporter displays a GUI

This was taking quite a long time when dealing with large programs
crashing (like Browser's WebContent processes.)

The new flow:

1. CrashDaemon finds a new coredump in /tmp
2. CrashDaemon mmap()'s the (uncompressed) coredump
3. CrashDaemon launches CrashReporter
4. CrashDaemon goes to sleep for 3 seconds (hack alert!)
5. CrashReporter parses the (uncompressed) coredump
6. CrashReporter unlinks the (uncompressed) coredump
7. CrashReporter displays a GUI
8. CrashDaemon wakes up (after step 4)
9. CrashDaemon compresses the coredump (gzip)

TL;DR: we no longer parse the coredumps twice, and we also prioritize
launching the CrashReporter GUI immediately when a new coredump shows
up, instead of compressing and parsing it in CrashDaemon first.

The net effect of this is that you get a backtrace on screen much
sooner. That's pretty nice. :^)
2021-09-21 20:52:29 +02:00
Andreas Kling
38b0200151 LibCoredump: Make Backtrace getters return const references 2021-09-21 20:52:29 +02:00
Idan Horowitz
e12a707ca1 checksum: Stop reusing the same Core::File for multiple files
Since we were just repeatedly calling `->open()` on the same Core::File
no one was clearing it's internal buffer, which means hashing multiple
files in one go would result in different hashes than hashing each file
separately.
2021-09-21 20:36:19 +03:00
Linus Groh
d792869799 LibJS: Update spec comment to convert mathematical to number value
This is an editorial change in the Temporal spec.

See: https://github.com/tc39/proposal-temporal/commit/d2ae357
2021-09-21 19:13:22 +02:00
Andreas Kling
ca45d34055 LibWeb: Don't add shorthand CSS properties to cascaded values
We already expand shorthands in the cascade, so there's no need to
preserve them in the output.

This patch reorganizes the CSS::PropertyID enum values so that we can
easily iterate over all shorthand or longhand properties.
2021-09-21 16:54:28 +02:00
Sam Atkins
e07cf6f41b LibWeb: Paint bitmaps with rounded_int_rect(), not enclosing_int_rect()
This fixes the issue where an `<img>` set to its native size would
sometimes still appear blurry, because it had a fractional position,
causing `enclosing_int_rect()` to expand by 1px.
2021-09-21 16:53:46 +02:00
Sam Atkins
0b7eefd4e5 LibGfx: Add rounded_int_rect() function for Rects
We were seeing a problem in LibWeb, where layout elements would be 1px
larger than they should be, due to layout positions using float values,
and then converting using `enclosing_int_rect()`. `rounded_int_rect()`
replaces that use, by maintaining the original rect's size.
2021-09-21 16:53:46 +02:00
Sam Atkins
8817ea83d6 LibWeb: Display actual (float) values when dumping layout 2021-09-21 16:53:46 +02:00
Ben Wiederhake
ac00d8b4eb LibWeb: Use AK::Variant default initialization in one more place 2021-09-21 15:25:17 +02:00
Timothy Flynn
8084957e88 CI: Create a secondary ccache for the Clang toolchain build
We bust the prebuilt cache when any header in e.g. LibC changes. Doing a
full toolchain rebuild probably isn't necessary, so this adds a separate
ccache to speed up toolchain builds.
2021-09-21 15:39:17 +03:00
Timothy Flynn
4a4e614387 CI: Set ccache path based on template parameter
Currently, the templated steps in Caches.yml rely on the environment
variable CCACHE_DIR being set to configure the ccache location. To
prepare for multiple ccache paths, do not rely on this environment
variable because only one ccache can use it at a time. Instead, pass
the path into the template as a parameter.
2021-09-21 15:39:17 +03:00
Timothy Flynn
5a2f41fff0 Toolchain: Add --ci option to BuildClang to enable ccache 2021-09-21 15:39:17 +03:00
Andreas Kling
aa7c590130 Base: Add 0x00A0 (non-breaking space) glyph to all our bitmap fonts
This is frequently used in web content (&nbsp;) so this change makes us
display it properly as whitespace. :^)
2021-09-21 13:04:02 +02:00
Andreas Kling
d965a9552f LibWeb: Start implementing the CSS cascade
The 'C' in "CSS" is for Cascade, so let's actually implement the cascade
in LibWeb. :^)

StyleResolver::resolve_style() now begins by collecting all the matching
CSS rules for the given DOM::Element. Rules are then processed in the
spec's cascade order (instead of in the order we encounter them.)

With this, "!important" is now honored on CSS properties.

After performing the cascade, we do another pass of what the spec calls
"defaulting" where we resolve "inherit" and "initial" values.
I've left a FIXME about supporting correct "initial" values for every
property, since we're currently lacking some coverage there.

Note that this mechanism now resolves every known CSS property. This is
*not* space-efficient and we'll eventually need to come up with some
strategies to reduce memory usage around this. However, this will do
fine until we have more of the engine working correctly. :^)
2021-09-21 12:49:28 +02:00
Andreas Kling
c55909f175 LibWeb: Add a specialized BorderRadiusStyleValue::equals()
This allows fast comparison of two BorderRadiusStyleValues.
2021-09-21 12:33:15 +02:00
Andreas Kling
ae7bbd93b8 LibWeb: Add a specialized NumericStyleValue::equals()
This allows fast comparison of two NumericStyleValues.
2021-09-21 12:33:15 +02:00
Andreas Kling
3e4fffec26 LibWeb: Make DOM::Element::resolve_custom_property() const 2021-09-21 12:33:15 +02:00
Andreas Kling
56710fab34 LibWeb: Include the "important" flag in CSS dumps 2021-09-21 12:33:15 +02:00
Andreas Kling
7ed49e954f LibWeb: Don't print debug spam when looking up missing initial values
I'm about to look up a lot of missing values, and the spam was getting
out of hand.
2021-09-21 12:33:15 +02:00
Andreas Kling
720d494799 LibWeb: Make CSS::Length::m_calculated_style a RefPtr
Let's now have CSS::Length holding raw pointers to things.
2021-09-21 12:33:15 +02:00
Ben Wiederhake
32e98d0924 Libraries: Use AK::Variant default initialization where appropriate 2021-09-21 04:22:52 +04:30
Ben Wiederhake
98a0f9c0bd LibPDF: Rely on default-constructor of Variant 2021-09-21 04:22:52 +04:30
Ben Wiederhake
9265595e42 LibIMAP: Remove unused Variant option 2021-09-21 04:22:52 +04:30
Ben Wiederhake
12247fe9b4 Kernel: Use AK::Variant default initialization where appropriate 2021-09-21 04:22:52 +04:30
Ben Wiederhake
743470c8f2 AK: Introduce ability to default-initialize a Variant
I noticed that Variant<Empty, …> is a somewhat common pattern while
working on #10080, and this will simplify a few use-cases. :^)
2021-09-21 04:22:52 +04:30
David Isaksson
f261b68408 WindowServer: Apply screen scaling when getting bitmap around cursor
This fixes an issue for the magnifier that when the screen scaling is
increased to 2 the magnifier doesn't center around the cursor.

Since booting Serenity with multiple displays doesn't work at the moment
the rescaling is only added for the one display case.
2021-09-20 22:25:24 +02:00
Tobias Christiansen
548ebbc233 LibWeb: Resolve 'inherit' property-value somewhat
This doesn't capture the whole picture as shorthands are not considered
in a careful way.
A very dirty hack is included to not try to resolve 'font' as the amount
of debug spam it generated ("No inital value found for...") was
unhelpful.
2021-09-20 22:18:45 +02:00
Sam Atkins
a50f4d2fc9 LibWeb: Enable bilinear blending for bitmaps
This is slower, but looks a lot nicer. :^)
2021-09-20 22:18:20 +02:00
Sam Atkins
1c807410cd LibGfx: Add optional bilinear filtering to draw_scaled_bitmap()
The algorithm is quite simple: You grab a 2x2 area of pixels around the
point you want from the source bitmap, and then linearly interpolate
between them based on how far they are from that point.

This works well when scaling up images, and moderately well when scaling
down - small details may get skipped over. The way GPUs solve this is
with mipmaps, which is not something I want to get into right now. (And
increases the memory usage per bitmap by 50%.)

I have not focused on performance, but this does reuse much of the
existing fixed-point calculation, and uses constexpr so that the
performance for nearest-neighbor should be the same as it was
previously.
2021-09-20 22:18:20 +02:00
Sam Atkins
10e54a29b2 Base: Add several scaled images to test page
These look really bad with our current nearest-neighbor image scaling,
so they are a good test case to see how well other scaling algorithms
work.
2021-09-20 22:18:20 +02:00
Itamar
a3360bcee8 LibC+DynamicLoader: Store the auxiliary vector address at startup
Previously, getauxval() got the address of the auxiliary vector by
traversing to the end of the `environ` pointer.

The assumption that the auxiliary vector comes after the environment
array is true at program startup, however the environment array may
be re-allocated and change its address during runtime which would cause
getauxval() to work with an incorrect auxiliary vector address.

To fix this, we now get the address of the auxiliary vector once in
__libc_init and store it in a libc-internal pointer which is then used
by getauxval().

Fixes #10087.
2021-09-20 18:32:09 +02:00
Andreas Kling
01900801e3 LibWeb: Implement <script src> execution for non-blocking scripts 2021-09-20 17:22:25 +02:00
Andreas Kling
c34da16089 LibWeb: Make <script src> loads partially async (by following the spec)
Instead of firing up a network request and synchronously blocking for it
to finish via a nested event loop, we now start an asynchronous request
when encountering <script src>.

Once the script load finishes (or fails), it gets executed at one of the
synchronization points in the HTML parser.

This solves some long-standing issues with random unexpected events
getting dispatched in the middle of parsing.
2021-09-20 17:22:25 +02:00
Andreas Kling
e11ae33c66 LibWeb: Pop entire stack of open elements at the end of parsing 2021-09-20 17:22:25 +02:00
Andreas Kling
398692722b LibWeb: Implement an ad-hoc version of EventLoop::spin_until(condition)
This doesn't follow the exact spec steps but instead simply makes a
nested Core::EventLoop and spins it while a periodic timer tests the
goal condition.
2021-09-20 17:22:25 +02:00
Andreas Kling
60d0f041b7 LibWeb: Use Document::realm() in HTMLScriptElement::prepare_script() 2021-09-20 17:22:25 +02:00