Commit Graph

12185 Commits

Author SHA1 Message Date
Tim Schumacher
ef9b543426 LibC: Remove the LibM interface target 2022-09-16 16:09:19 +00:00
Tim Schumacher
1b25c38b8b Everywhere: Fully remove the separate LibM directory 2022-09-16 16:09:19 +00:00
Tim Schumacher
81d46fa100 LibM: Move the math standard library to LibC 2022-09-16 16:09:19 +00:00
Andrew Kaster
eef989f9ed LibGPU: Don't use relative paths for libsoftgpu in Lagom environments
We can count on the dynamic loader for each platform, and the RPATH of
our build infrastrucuture, to load the lib up automagically.
2022-09-16 15:32:38 +02:00
Andrew Kaster
8ed5ed3ec0 LibGL: Make GL::create_context fallible
Propagate errors in places that are already set up to handle them, like
WebGLRenderingContext and the Tubes demo, and convert other callers
to using MUST.
2022-09-16 15:32:38 +02:00
Timothy Flynn
7e5080ea53 LibGUI: Load emoji icons for EmojiInputDialog through Gfx::Emoji
No difference when cold-loading the emoji icons, but for a warm load,
this provides a per-process cache of the loaded icons.
2022-09-16 15:20:59 +02:00
Timothy Flynn
98f99a9f7e LibGfx: Change Emoji::emoji_for_code_points to accept const code points
Span<u32 const> is the type used when converting a constant Vector<u32>
to a Span.
2022-09-16 15:20:59 +02:00
Timothy Flynn
35b74ebbfc LibGUI: Defer loading emoji icons until their first paint event
The EmojiInputDialog re-uses emoji buttons to help with performance as
filters are applied / removed. The downside of pre-creating the buttons
is that it currently takes upwards of 600ms (on my machine) to load all
emoji icons from disk at once. This will only become worse over time as
more emoji are added.

To alleviate this, defer loading the icons until they are needed for
painting (i.e. come into view).
2022-09-16 15:20:59 +02:00
Andreas Kling
cd7262ee56 LibWeb+LibWebView+WebContent: Add Web::Platform::ImageCodecPlugin
This replaces the previous Web::ImageDecoding::Decoder interface.
While we're doing this, also move the SerenityOS implementation of this
interface from LibWebView to WebContent. That means we no longer have to
link with LibImageDecoderClient in applications that use a web view.
2022-09-16 15:15:50 +02:00
Andreas Kling
412b2313f3 LibWeb: Improve inline flow around floating boxes
This patch combines a number of techniques to make inline content flow
more correctly around floats:

- During inline layout, BFC now lets LineBuilder decide the Y coordinate
  when inserting a new float. LineBuilder has more information about the
  currently accumulated line, and can make better breaking decisions.

- When inserting a float on one side, and the top of the newly inserted
  float is below the bottommost float on the opposite side, we now reset
  the opposite side back to the start of that edge. This improves
  breaking behavior between opposite-side floats.

- After inserting a float during inline layout, we now recalculate the
  available space on the line, but don't adjust X offsets of already
  existing fragments. This is handled by update_last_line() anyway,
  so it was pointless busywork.

- When measuring whether a line can fit at a given Y coordinate, we now
  consider both the top and bottom Y values of the line. This fixes an
  issue where the bottom part of a line would bleed over other content
  (since we had only checked that the top Y coordinate of that line
  would fit.)

There are some pretty brain-dead algorithms in here that we need to make
smarter, but I didn't want to complicate this any further so I've left
FIXMEs about them instead.
2022-09-16 15:15:50 +02:00
Andreas Kling
54e7359243 LibWeb: Repaint the page immediately when using the mouse to select
Otherwise we'd repaint the next time our "caret blink" timer would fire
(or something else caused a repaint). This made selection feel sluggish.
2022-09-16 15:15:50 +02:00
Enver Balalic
11a44ffb69 LibGfx: Recurse TrueType composite glyphs until a simple glyph is found
This fixes a bug in ladybird where it was crashing while rendering
characters like ščćž in the Noto Sans Regular font.

That font renders those characters as a composite where the caret
has numberOfContours = -1. When using the rasterize_impl simple path
for that, it would negatively overflow the offsets.
2022-09-16 14:52:03 +02:00
MacDue
011439d3e3 LibWeb: Paint backdrop-filter effects!
This implements all the filters other than `saturate()`,
`hue-rotate()`, and `drop-shadow()`.

There are still a lot of FIXMEs to handle in the actual implementation
though, particularly around supporting transforms, but this handles
the most common use cases :^)
2022-09-16 10:50:48 +01:00
MacDue
60356c8dde LibGfx: Support getting a bitmap for a region of painter
This will be needed so we can apply filter effects to the backdrop
of an element in LibWeb.

This now also allows getting a crop of a bitmap in a different format
than the source bitmap. This is for if the painter's bitmap does not
have an alpha channel, but you want to ensure the cropped bitmap does.
2022-09-16 10:50:48 +01:00
MacDue
978a70ddcc LibGfx: Add BrightnessFilter, ContrastFilter, and OpacityFilter
These filters are based off the ones defined in:
https://drafts.fxtf.org/filter-effects-1/#supported-filter-functions
2022-09-16 10:50:48 +01:00
MacDue
8f225acf58 LibGfx: Allow applying all color filters with an amount
This amount can be handled in the filter's implementation or if
not it will default to mixing between the new and previous pixel.

This behaviour is used for implementing CSS filters that allow stuff
like grayscale(70%).
2022-09-16 10:50:48 +01:00
MacDue
7bc0c66290 LibWeb+LibGfx: Move premultiplied alpha mixing to color.mixed_with()
This will be needed for mixing filters in LibGfx (and may be
generally useful elsewhere).
2022-09-16 10:50:48 +01:00
MacDue
ec4de1e07d LibWeb: Plumb style/computed values for backdrop-filter 2022-09-16 10:50:48 +01:00
MacDue
d1b99282d8 LibWeb+Meta: Parse the backdrop-filter CSS property
Note: The parsing and style value completely ignores the SVG filters
part of the spec for now... That's a yak for another day :^)
2022-09-16 10:50:48 +01:00
MacDue
980c92e9b5 LibWeb: Add FilterValueListStyleValue
This style value holds a list of CSS filter function calls e.g.

blur(10px) invert() grayscale()

It will be used to implement backdrop-filter, but the same style value
can be used for the image filter property.

(The name is a little awkward but it's referenced to as
filter-value-list in the spec too).
2022-09-16 10:50:48 +01:00
MacDue
776538a6c4 LibWeb: Add operator== to CSS::Number
This will be needed for the .equals() function of the backdrop-filter
style value.
2022-09-16 10:50:48 +01:00
MacDue
84d9a226e6 LibWeb: Add NumberPercentage CSS type
This type is used quite a bit in CSS filters.
2022-09-16 10:50:48 +01:00
MacDue
b219931dfc LibWeb: Pass values by reference in style value operator== functions 2022-09-16 10:50:48 +01:00
Tim Schumacher
88ff01bb17 LibC: Remove _aligned_malloc and _aligned_free
We now have a proper aligned allocation implementation, and the
toolchain patch to make Clang use the intermediary implementation
has already been removed in an earlier iteration.
2022-09-16 05:39:28 +00:00
Tim Schumacher
388dc9cc5f LibJS: Supress an unused bind when wrapping float atomic operations 2022-09-16 05:39:28 +00:00
Tim Schumacher
8763dbcccc Everywhere: Remove a bunch of dead write-only variables
LLVM 15 now warns (and thus errors) about this, and there is really no
point in keeping them.
2022-09-16 05:39:28 +00:00
Andreas Kling
d1dac8695c LibWeb: Don't set initial font+color on both HTML and BODY elements
It's enough to set it on the HTML element. That way, it doesn't get
reset in content that sets its own font on HTML but not on BODY.
2022-09-15 16:16:56 +02:00
Andreas Kling
1dd4e2dc87 LibWeb: Cache lowercased names in SimpleSelector
When matching selectors in HTML documents, we know that all the elements
have lowercase local names already (the parser makes sure of this.)

Style sheets still need to remember the original name strings, in case
we want to match against non-HTML content like XML/SVG. To make the
common HTML case faster, we now cache a lowercase version of the name
with each type/class/id SimpleSelector.

This makes tag type checks O(1) instead of O(n).
2022-09-15 16:16:56 +02:00
Andreas Kling
d9c64ee876 LibWeb: Hoist case sensitivity check out of loop in Element::has_class() 2022-09-15 16:16:56 +02:00
Ben Wiederhake
8deced39a8 LibWeb: Resolve cyclic declaration/definitions involving Length
This remained undetected for a long time as HeaderCheck is disabled by
default. This commit makes the following file compile again:

    // file: compile_me.cpp
    #include <LibWeb/CSS/GridTrackSize.h>
    // That's it, this was enough to cause a compilation error.
2022-09-15 14:45:38 +01:00
Lucas CHOLLET
4ab8ad2ed2 LibCrypto: Fix -0 and 0 non-equality
SignedBigInteger::operator==(const UnsignedBigInteger&) was rejecting
all negative value before testing for equality. It now accepts negative
zero and test for a value equality with the UnsignedBigInteger.
2022-09-15 14:08:21 +01:00
Lucas CHOLLET
6a937312b3 LibCrypto: Add BigFraction
This new abstraction allows the user to store rational numbers with
infinite precision.
2022-09-15 14:08:21 +01:00
Lucas CHOLLET
d589898f5b LibCrypto: Add SignedBigInteger::negated_value()
Return the negated value of the current number.
2022-09-15 14:08:21 +01:00
Andreas Kling
a60c5166c6 LibWeb: Don't ignore data: URLs in @font-face src
Since data: URLs don't have a path, we shouldn't be checking for a TTF
or WOFF extension.

Thanks Timon for pointing this out! :^)
2022-09-15 12:45:00 +02:00
Andreas Kling
4910cc1879 LibGfx: Cache vector fonts by family name
Instead of just keeping them in an unsorted Vector, which led to
increasingly noticeable O(n) lookups, we now cache a list of Typefaces
per family name.
2022-09-15 12:45:00 +02:00
sin-ack
a192095594 LibCore: Rewrite Core::Stream::read_all_impl
The previous version relied on manually setting the amount of data to
read for the next chunk and was overall unclear. The new version uses
the Bytes API to vastly improve readability, and fixes a bug where
reading from files where a single read that wasn't of equal size to the
block size would cause the byte buffer to be incorrectly resized causing
corrupted output.
2022-09-15 12:01:16 +02:00
sin-ack
d3979b0bbd LibCore: Add documentation to Stream functions + make parameter clearer
file_size was not very clear about what it was being used for, so I
switched it to say expected_file_size to make it clear that it's just a
heuristic.
2022-09-15 12:01:16 +02:00
Luke Wilde
6a4934a030 LibWeb: Implement document.domain getter
The document.domain setter is currently stubbed as that is a doozy to
implement, given how much restrictions there are in place to try and
prevent use of it and potential multi-process implications.

This was the only thing preventing us from being able to start
displaying ads delivered via Google Syndication.
2022-09-15 09:46:04 +02:00
Timothy Flynn
85e313077a LibJS: Do not invoke Cell::vm in constructors before Cell is constructed
In a subclass of Cell, we cannot use Cell::vm() before the base Cell
object itself is constructed. Use the Realm's VM instead.

This was caught by UBSAN with vptr sanitation enabled.
2022-09-15 09:45:13 +02:00
Timothy Flynn
3efe611dbf LibJS: Do not assume that IsArray means the object type is an Array
IsArray returns true if the object is an Array *or* if it is a
ProxyObject whose target is an Array. Therefore, we cannot downcast to
an Array based on IsArray.

Luckily, we don't actually need an Array here; SerializeJSONArray only
needs an Object.

This was caught by UBSAN with vptr sanitation enabled.
2022-09-15 09:45:13 +02:00
Timothy Flynn
98a6f962a0 LibJS: Use correct include + object class for Function{Object,Prototype}
Not causing any real issue, just noticed while debugging vptr sanitation
errors.
2022-09-15 09:45:13 +02:00
Andreas Kling
1c0fc75cb6 LibWeb: Fix bogus condition when checking CSS font file extensions
Thanks Idan for pointing this out! :^)
2022-09-15 01:20:35 +02:00
Andreas Kling
6d92c1d231 LibWeb: Be slightly better at @font-face rules with multiple sources
This patch improves @font-face loading when there are multiple src
values in two ways:

- Invalid/empty URLs are ignored
- Fonts with unsupported file extensions are ignored

This makes us load and display the emblem font on modern Reddit,
which is pretty neat! :^)
2022-09-14 21:46:34 +02:00
Andreas Kling
c5a19a4d55 LibWeb: Allow CSS at-rules to have an empty prelude
I don't see any indication in the spec that an empty prelude should be
disallowed. This fixes rules like `@font-face{...}` (note the absence
of whitespace before the `{`.)
2022-09-14 21:37:19 +02:00
Andreas Kling
f64c175960 LibWeb: Invalidate layout whenever a CSS font is loaded
It's not enough to invalidate only the style, we have to do a full
layout invalidation since new fonts might mean new metrics, etc.
2022-09-14 21:24:31 +02:00
Andreas Kling
df49a6ae9b LibWeb: Schedule a layout update in Document::invalidate_layout()
Otherwise, nothing will repaint until someone else decides to trigger
an update.
2022-09-14 21:23:39 +02:00
Andreas Kling
463355d1eb LibWeb: Allow data: URLs with font/ MIME type in @font-face CSS rules 2022-09-14 21:14:16 +02:00
Andreas Kling
34025442ff LibWeb: Account for float's container offsets in BFC root auto height
When calculating the automatic height of a BFC root, we stretch it to
contain the bottommost margin edge of floating boxes.

Before this change, we assumed that floating boxes had coordinates
relative to the BFC root, when they're actually relative to the floating
box's containing block. This may or may not be the BFC root, so we have
to use margin_box_in_ancestor_coordinate_space() to apply offsets from
all boxes in the containing block chain (up to the BFC root).
2022-09-14 20:18:49 +02:00
Jelle Raaijmakers
8ff7c52cf4 LibSoftGPU: Return a const& texel in Image to prevent copying
On every texel access, some floating point instructions involved in
copying 4 floats popped up. Let `Image::texel() const` return a
`FloatVector4 const&` to prevent these operations.

This results in a ~7% FPS increase in GLQuake on my machine.
2022-09-14 17:17:36 +02:00
Jelle Raaijmakers
e9d2f9a95e LibSoftGPU: Use memcpy instead of a loop to blit the color buffer
Looking at `Tubes` before and after this change, comparing the original
loop to the one using `memcpy`, including the time for `memcpy` itself,
resulted in ~15% fewer samples in profiles on my machine.
2022-09-14 17:17:19 +02:00