Commit Graph

28 Commits

Author SHA1 Message Date
Sam Atkins
f4d8a24fe4 LibWeb: Propagate errors from parse_css_value and property_initial_value 2023-05-06 08:07:28 +02:00
MacDue
afd355c135 LibWeb: Resolve and paint SVG gradient fills
This bit is mostly ad-hoc for now. This simply turns fill: url(#grad1)
into document().get_element_by_id('grad1') then resolves the gradient.
This seems to do the trick for most use cases, but this is not
attempting to follow the spec yet to keep things simple.
2023-04-28 09:42:28 +02:00
Nico Weber
f56b897622 Everywhere: Fix a few typos
Some even user-visible!
2023-04-12 19:37:35 +02:00
MacDue
570d71f869 LibWeb: Parse the transform attribute when set on SVGGraphicsElements
This uses the new attribute parser functionality, and then resolves the
transform list into a single Gfx::AffineTransform.

This also adds a .get_transform() function which resolves the final
transform, by applying all parent transforms.
2023-04-12 07:40:22 +02:00
MacDue
6482c306f1 LibWeb: Parse and apply fill-opacity attribute to SVG paths
This is needed to fix the rendering of the Street View directional
controls (which have paths with various levels of opacity set by
this attribute).
2023-04-12 07:40:22 +02:00
Andreas Kling
a504ac3e2a Everywhere: Rename equals_ignoring_case => equals_ignoring_ascii_case
Let's make it clear that these functions deal with ASCII case only.
2023-03-10 13:15:44 +01:00
Timothy Flynn
2692db8699 LibJS+Everywhere: Allow Cell::initialize overrides to throw OOM errors
Note that as of this commit, there aren't any such throwers, and the
call site in Heap::allocate will drop exceptions on the floor. This
commit only serves to change the declaration of the overrides, make sure
they return an empty value, and to propagate OOM errors frm their base
initialize invocations.
2023-01-29 00:02:45 +00:00
Timothy Flynn
834202aeb9 LibWeb: Move setting of Web object prototypes to initialize()
This needs to happen before prototype/constructor intitialization can be
made lazy. Otherwise, GC could run during the C++ constructor and try to
collect the object currently being created.
2023-01-10 16:08:14 +01:00
Sam Atkins
8cc0bdf777 LibWeb: Resolve Lengths to CSSPixels 2023-01-05 17:42:31 +01:00
Sam Atkins
7d40e3eb0d LibWeb: Replace all px Length creation with Length::make_px(CSSPixels) 2023-01-05 17:42:31 +01:00
Andrew Kaster
56b381aac0 LibWeb: Cleanup unecessary uses and includes of HTML::Window
The big global refactor left some stragglers behind for atomicity.

Clean up the rest, and remove a ton of includes of LibWeb/HTML/Window.h
2022-10-01 21:05:32 +01:00
Andrew Kaster
320dddde6a LibWeb: Remove unecessary dependence on Window from SVG classes
These classes only needed Window to get at its realm. Pass a realm
directly to construct SCG classes.
2022-10-01 21:05:32 +01:00
Andreas Kling
ffad902c07 LibWeb: Use cached_web_prototype() as much as possible
Unlike ensure_web_prototype<T>(), the cached version doesn't require the
prototype type to be fully formed, so we can use it without including
the FooPrototype.h header. It's also a bit less verbose. :^)
2022-09-06 00:27:09 +02:00
Andreas Kling
6f433c8656 LibWeb+LibJS: Make the EventTarget hierarchy (incl. DOM) GC-allocated
This is a monster patch that turns all EventTargets into GC-allocated
PlatformObjects. Their C++ wrapper classes are removed, and the LibJS
garbage collector is now responsible for their lifetimes.

There's a fair amount of hacks and band-aids in this patch, and we'll
have a lot of cleanup to do after this.
2022-09-06 00:27:09 +02:00
sin-ack
3f3f45580a Everywhere: Add sv suffix to strings relying on StringView(char const*)
Each of these strings would previously rely on StringView's char const*
constructor overload, which would call __builtin_strlen on the string.
Since we now have operator ""sv, we can replace these with much simpler
versions. This opens the door to being able to remove
StringView(char const*).

No functional changes.
2022-07-12 23:11:35 +02:00
Andreas Kling
cefc931347 LibWeb: Make sure CSS::ComputedValues has initial size values
Instead of using Optional<LengthPercentage>, we now use LengthPercentage
for these values. The initial values are all `auto`.

This avoids having to check `has_value()` in a ton of places.
2022-07-09 22:16:35 +02:00
Sam Atkins
c449cabae3 LibWeb: Move CSS Parser into new Web::CSS::Parser namespace
The goal here is to move the parser-internal classes into this namespace
so they can have more convenient names without causing collisions. The
Parser itself won't collide, and would be more convenient to just
remain `CSS::Parser`, but having a namespace and a class with the same
name makes C++ unhappy.
2022-04-12 23:03:46 +02:00
Andreas Kling
b5faeb7840 LibWeb: Resolve SVG "scaled viewport size" without triggering layout
Percentage stroke widths are resolved against the scaled viewport size
which we were retrieving by calling client_width() and client_height()
on the element. Now that those accessors may trigger layout, this means
that we can't use them from the stroke_width() getter, which is itself
used *from within* layout.
2022-04-10 20:18:38 +02:00
Simon Wanner
a3c80f05ba LibWeb: Apply the 'transform' presentational attribute to SVG elements 2022-03-18 18:51:42 +01:00
Andreas Kling
1b6ed558bb LibWeb: Move QualifiedName into the Web::DOM namespace 2022-02-19 14:45:59 +01:00
Sam Atkins
ce0de4b2b4 LibWeb: Allow LengthPercentage to hold a calculated value
Most of the time, we cannot resolve a `calc()` expression until we go to
use it. Since any `<length-percentage>` can legally be a `calc
()`, let's store it in `LengthPercentage` rather than make every single
user care about this distinction.
2022-02-04 13:52:02 +01:00
Sam Atkins
ae99cbe534 LibWeb: Treat SVG fill/stroke/stroke-width attributes as CSS properties
Rather than having separate systems for the attributes and their CSS
equivalents, we can treat the attributes as presentational hints and
convert them to CSS properties. This means they can be inherited, as
they should. :^)

As noted, the `fill` and `stroke` attributes do not fully match the
`fill` and `stroke` properties. The CSS spec is still an early draft and
not entirely helpful, so we can just pretend they are the same for now.
2022-01-24 17:04:00 +01:00
Sam Atkins
a26cec3805 LibWeb: Convert stroke-width to LengthPercentage
This is a guinea pig. So far so good?
2022-01-20 00:04:10 +01:00
Sam Atkins
3964b81d2b LibWeb: Add for CSS fill/stroke/stroke-color properties for SVG
In the spec, `fill` and `stroke` are supposed to be a shorthands for
various properties. But since the spec is still a working draft, and
neither Firefox or Chrome support the `fill-color` or `stroke-color`
properties, we'll stick with `fill` and `stroke` as simple colors for
now.

Also, note that SVG expects things in "user units", and we are assuming
that 1px = 1 user unit for now.
2021-09-16 22:30:33 +02:00
Matthew Olsson
fcd3b9a0df Userland: Use mattco@serenityos.org for my copyright headers 2021-04-23 08:24:53 +02:00
Brian Gianforcaro
1682f0b760 Everything: Move to SPDX license identifiers in all files.
SPDX License Identifiers are a more compact / standardized
way of representing file license information.

See: https://spdx.dev/resources/use/#identifiers

This was done with the `ambr` search and replace tool.

 ambr --no-parent-ignore --key-from-file --rep-from-file key.txt rep.txt *
2021-04-22 11:22:27 +02:00
Andreas Kling
330c3fcb59 LibWeb: Use move semantics for QualifiedName more often 2021-02-07 11:20:15 +01:00
Andreas Kling
13d7c09125 Libraries: Move to Userland/Libraries/ 2021-01-12 12:17:46 +01:00