Commit Graph

2578 Commits

Author SHA1 Message Date
Sam Atkins
b65ccb4dc6 LibWeb: Introduce color-function-specific style values
Instead of CSSColorValue holding a Gfx::Color, make it an abstract class
with subclasses for each different color function, to match the Typed-OM
spec. This means moving the color calculations from the parsing code to
the `to_color()` method on the style value.

This lets us have calc() inside a color function, instead of having to
fully resolve the color at parse time. The canvas fillStyle tests have
been updated to reflect this.

The other test change is Screenshot/css-color-functions.html: previously
we produced slightly different colors for an alpha of 0.5 and one of
50%, and this incorrect behavior was baked into the test. So now it's
more correct. :^)

(cherry picked from commit 3af6a69f1e13803c64466a9b24b7bd7d75d459df;
amended to:
* resolve a minor conflict in Parser.cpp due to upstream not having
  https://github.com/LadybirdBrowser/ladybird/pull/385#issuecomment-2227130015
* rebaseline canvas-fillstyle-rgb.png since the diff didn't apply due to
  us not having https://github.com/LadybirdBrowser/ladybird/pull/999
* remove css-color-functions-ref.png and instead update
  css-color-functions-ref.html since that file is still a reftest due to us
  not having https://github.com/LadybirdBrowser/ladybird/pull/736
  Makes it much easier to see what actually changed.
)
2024-10-11 10:12:33 -04:00
Sam Atkins
ff37cf75a2 LibWeb: Rename CSSColorValue::create() to create_from_color()
Soon, CSSColorValue will be an abstract class, and we'll instead create
a CSSRGB, CSSHSL, or other specific color type from the Typed-OM spec.
However, it's still useful to have an easy "just give me a style value
for this color" method. So change the name to distinguish this from the
usual StyleValue::create() methods.

(cherry picked from commit 37ea4e3b5f33464a58ee1260fe3ce5fc0699e29a)
2024-10-11 10:12:33 -04:00
Sam Atkins
250613d494 LibWeb: Rename ColorStyleValue -> CSSColorValue
This matches the name in the CSS Typed OM spec.
https://drafts.css-houdini.org/css-typed-om-1/#csscolorvalue

This is not (yet) the same as the CSSColorValue, but one step at a time.

(cherry picked from commit 581d00293c184e47015a5d7e9c4230410567db45)
2024-10-11 10:12:33 -04:00
Andreas Kling
eacf504b30 LibWeb: Make HTML::Task IDs a sequential, distinct numeric type
This also fixes a bug where task IDs were being deallocated from the
wrong IDAllocator. I don't know if it was actually possible to cause any
real trouble with that mistake, nor do I know how to write a test for
it, but this makes the bug go away.

(cherry picked from commit 08d60d7521915b4f73fd3bb40a1aa159f4f31eb1)
2024-10-11 09:27:51 -04:00
Andreas Kling
dc8eb851ca LibWeb: Make requestAnimationFrame() callback IDs sequential
This is required by the spec, so let's stop returning random IDs in
favor of a simple sequential integer sequence.

(cherry picked from commit 0e1256e5a405627fda18b597d8fd08073dd60b77)
2024-10-11 09:27:51 -04:00
Sam Atkins
0a3b33e6f6 LibWeb: Rename "identifier" and "ValueID" to "Keyword" where correct
For a long time, we've used two terms, inconsistently:
- "Identifier" is a spec term, but refers to a sequence of alphanumeric
  characters, which may or may not be a keyword. (Keywords are a
  subset of all identifiers.)
- "ValueID" is entirely non-spec, and is directly called a "keyword" in
  the CSS specs.

So to avoid confusion as much as possible, let's align with the spec
terminology. I've attempted to change variable names as well, but
obviously we use Keywords in a lot of places in LibWeb and so I may
have missed some.

One exception is that I've not renamed "valid-identifiers" in
Properties.json... I'd like to combine that and the "valid-types" array
together eventually, so there's no benefit to doing an extra rename
now.

(cherry picked from commit 6a74b0164423d63904cf5a5b594772b595f57600;
very minorly amended to fix conflict in GenerateCSSKeyword.cpp caused
by #22870, and in libweb_generators.cmake due to us not having
https://github.com/LadybirdBrowser/ladybird/pull/741)
2024-10-10 10:08:59 -04:00
Sam Atkins
63e3442b15 LibWeb: Rename IdentifierStyleValue -> CSSKeywordValue
This matches the name in the CSS Typed OM spec.
https://drafts.css-houdini.org/css-typed-om-1/#csskeywordvalue

(cherry picked from commit 9559f0f123fcd1c2fddba625d4bdc4806bb8bd68)
2024-10-10 10:08:59 -04:00
Sam Atkins
a4981ae745 LibWeb: Rename StyleValue -> CSSStyleValue
This matches the name in the CSS Typed OM spec.
https://drafts.css-houdini.org/css-typed-om-1/#cssstylevalue

No behaviour changes.

(cherry picked from commit 0e3487b9ab455a7648185995363bb3b487551d40)
2024-10-10 10:08:59 -04:00
Andreas Kling
727e7c4fe7 LibGfx: Make Painter::target() return a Bitmap&
Painter always has a target bitmap, so let's return a reference.

(cherry picked from commit f42c18bc4c4a5d49fccbfab996bf04d77476b366;
amended to resolve conflicts in Painter due to us having more APIs,
and to update code no longer in ladybird: DisplayListPlayerCPU, and
Magnifier and ThemeEditor)
2024-10-08 07:21:19 -04:00
Aliaksandr Kalenik
2fd718b708 LibWeb: Rename CommandExecutor to DisplayListPlayer
Use more widely recognized name among browser engine developers.

(cherry picked from commit 760dfdcc1ae361c2741843642869de5724d243fa;
amended quite a bit because we don't have DisplayListPlayerSkia but
we do have AffineCommandExecutorCPU -> AffineDisplayListPlayerCPU due
to not merging https://github.com/LadybirdBrowser/ladybird/pull/212,
and we don't have the first commit from
https://github.com/LadybirdBrowser/ladybird/pull/182 since us
having #24523 doesn't make it trivial to merge.)
2024-10-03 12:06:45 -04:00
Aliaksandr Kalenik
705755a20d LibWeb: Rename RecordingPainter to DisplayListRecorder
Use more widely recognized name among browser engine developers.

(cherry picked from commit 854b269338b1a1b31c0346f48dc58fa55ccf7d9f,
minorly amended due to the CornerRadius move in #24523)
2024-10-03 12:06:45 -04:00
Aliaksandr Kalenik
9ea1b9b12d LibWeb: Rename CommandList to DisplayList
Use more widely recognized name among browser engine developers.

(cherry picked from commit 5570e6b648ddaed7028f8c534874629ca6afcf0f;
minorly amended in TraversableNavigable.cpp and SVGDecodedImageData.cpp
due to some skia bits, and because we still have
CPUWithExperimentalTransformSupport)
2024-10-03 12:06:45 -04:00
Aliaksandr Kalenik
57704de205 LibWeb+WebContent+WebWorker: Allow to query painter type from PageClient
Now it's possible to query selected type from SVGPageClient.

(cherry picked from commit 6dd124fc876374f0da193da71f0fd6f103522810;
amended to remove skia parts)
2024-10-03 07:09:55 -04:00
Andreas Kling
4d1319e798 Everywhere: Include <LibGfx/Painter.h> in fewer places
Touching Painter.h now rebuilds ~40 files instead of ~300.

(cherry picked from commit fe4cc32380124e15439c97664881ca6856037358;
amended for conflict in AntiAliasingPainter.h includes due to #24523,
and to make LibCore/Resource.h include OpenType/Font.h, which was in
https://github.com/LadybirdBrowser/ladybird/pull/42 which we don't want
to cherry-pick)
2024-10-01 19:53:31 -04:00
Andreas Kling
7f083829e1 LibGfx: Move Gfx::Painter::WindingRule => Gfx::WindingRule
(cherry picked from commit 57906a4e1b85df73a2fdf58a83cdcd191be29632;
amended to add a forwarding enum in Painter, and to fix conflicts due
to us still having bitmap fonts, due to our AffineCommandExecutorCPU
supporting clipping, and due to us cherry-picking
https://github.com/LadybirdBrowser/ladybird/pull/143 before
cherry-picking these commits from
https://github.com/LadybirdBrowser/ladybird/pull/50)
2024-10-01 19:53:31 -04:00
Andreas Kling
1d08615063 LibGfx: Move Gfx::Painter::ScalingMode => Gfx::ScalingMode
This will allow users to avoid including Painter.h

(cherry picked from commit 254d040ff4f81a0e04364d5d29a25c98d580cbb5;
amended to fix conflict in Painter.cpp because we didn't remove the
scale concept, and to keep a forwarding enum in place until we've
converted the rest of our code.)
2024-10-01 19:53:31 -04:00
Andrew Kaster
fa54314551 LibWeb: Use Web::UIEvents::KeyCode
This cherrypicks most of commit d90a9ab70c7ef73577775f0abed8552907899f75
It doesn't actually remove Kernel/API/KeyCode.h though, since we still
need that :^)

Patch created by running (in zsh, where the `${=foo}` syntax is needed
to tell zsh to convert space-separated strings into separate args):

    files=$(git show --name-only --pretty='' d90a9ab70c7e |
            rg -v 'CMakeLists.txt|KeyCode.h' | tr '\n' ' ')
    git show d90a9ab70c7e -- ${=files} | git apply -3 -
2024-09-29 11:13:23 -04:00
Sam Atkins
2660c80a98 LibWeb: Implement getComputedStyle() pseudoElement parameter
Right now, we deviate from the CSSOM spec regarding our
CSSStyleDeclaration classes, so this is not as close to the spec as I'd
like. But it works, which means we'll be able to test pseudo-element
styling a lot more easily. :^)

(cherry picked from commit 14611de362d1d41429688dc02ffaf037a32e2e5d)
2024-09-28 14:14:28 -04:00
Luke Warlow
f747be119d LibWeb: Add motion preference
This adds a motion preference to the browser UI similar to the existing
ones for color scheme and contrast.
Both AppKit UI and Qt UI has this new preference.
The auto value is currently the same as NoPreference, follow-ups can
address wiring that up to the actual preference for the OS.

(cherry picked from commit 099b77d60f6c30b4d533872fda29ea6d660ed358)
2024-09-28 07:57:00 -04:00
Luke Warlow
2dce7000c8 LibWeb: Add Contrast preference
(cherry picked from commit ee6468456580fa0380daeb0b9ab0bdf2832f9dcf)
2024-09-27 23:31:40 -04:00
Shannon Booth
9d729e19bf LibWeb: Rename SharedImageRequest to SharedResourceRequest
For the SVG <use> element, we want to support loading HTML documents
that have a SVG element inside of it pointed to by the URL fragment.

In this situation we would need to fetch and parse the entire document
in SharedImageRequest (so that we can still cache the SVGs). Rename
SharedImageRequest to SharedResourceRequest to make the class a little
more generic for future usecases.

(cherry picked from commit a342370dfb4f1eeabc7dcb8fbe6f8e4eb6f6b1f4)
2024-09-27 22:27:02 -04:00
Shannon Booth
f0874f37d1 LbiWeb: Add and use SharedImageRequest::handle_successful_resource_load
This closer mirrors handle_failed_fetch, making the handling slightly
more clear to understand. It also means that we don't need to take a
strong reference to this on a successful SVG resource load.

(cherry picked from commit 2fb50546036f02bbc94e65ccbcd16f2f9275d46c)
2024-09-27 22:27:02 -04:00
Shannon Booth
1b783f6faa LibWeb: Use handle_failed_fetch to implement handle_failed_decode
...When loading images through SharedImageRequest.

There is a small behavioural difference here - handle_failed_fetch
clears the pending callbacks whereas handled_failed_decode was
previously not. This does not seem intentional, and appears like a bug.

Implementing it this way is _slightly_ simpler - and also means we
don't need to take a strong handle to this in the case of loading an
SVG image.

(cherry picked from commit e0f2e42687583aa7ae997de21f5504ba45c2985c)
2024-09-27 22:27:02 -04:00
Nico Weber
c30188cd6a LibWeb: Hook up canvas lineCap and plumb it to LibGfx
To rebaseline image test expecatations, I ran:

    out/gn/Ladybird.app/Contents/MacOS/headless-browser \
        --resources $PWD/out/gn/Ladybird.app/Contents/Resources \
        --dump-failed-ref-tests \
        --run-tests $PWD/Tests/LibWeb \
        --filter 'canvas-*'

I then copied over the new baselines with

    D=Tests/LibWeb/Ref/reference/images
    cp test-dumps/canvas-implict-moves-and-lines.png \
        $D/canvas-implict-moves-and-lines-ref.png

(Note: No `-ref` suffix on first path, yes suffix on second path.)

We currently don't track if a path is open or closed, and paint
butt linecaps at the end of closed paths too. We did that with
round linecaps as well, but there that wasn't visible. This makes
closed paths look a bit weird now; we'll have to fix this in a
follow-up. In a way, this just exposes another not-yet-implemented
feature.
2024-09-27 15:05:30 -04:00
kleines Filmröllchen
a3077203fe AK: Don't implicitly convert Optional<T&> to Optional<T>
C++ will jovially select the implicit conversion operator, even if it's
complete bogus, such as for unknown-size types or non-destructible
types. Therefore, all such conversions (which incur a copy) must
(unfortunately) be explicit so that non-copyable types continue to work.
2024-09-14 13:30:27 +02:00
Aliaksandr Kalenik
f7227550a7 LibWeb+WebContent: Move PageClient::paint() into TraversableNavigable
This way we leak less LibWeb implementation details into WebContent.

(cherry picked from commit cbd566a3543d5ad50db3b68890ff23f76ca3b4bd)

Patched to fix build on SerenityOS

Co-authored-by: circl <circl.lastname@gmail.com>
2024-09-13 11:11:24 -04:00
Aliaksandr Kalenik
aae5ad0b7c LibWeb: Rename Navigable::paint() to record_painting_commands()
This method does not paint, but only records painting commands that
could be passed to painting commands executor, which will perform
actual painting.

(cherry picked from commit c7133faf264901ace5e1fb3b97aaddc504d45005)
2024-09-13 11:11:24 -04:00
Tim Ledbetter
cbf1905621 LibWeb: Account for header size when reading MessagePort message payload
Previously, the fact that this wasn't accounted for could lead to a
crash when large messages were received.

(cherry picked from commit 34e465a67e41b82b276050dde0b4b321c2cf1b18)
2024-08-13 15:44:49 -04:00
Andreas Kling
225dc0be5a LibWeb: Only remember source CSSStyleDeclaration for animation-name
We were saving to source declarations for *every* property, even though
we only ever looked it up for animation-name.

This patch gets rid of the per-property source pointer and we now keep
a single pointer to the animation-name source only.

This shrinks StyleProperties from 6512 bytes to 4368 bytes per instance.

(cherry picked from commit c288bfb40453d4abe95af694dfc7c2175cd04a14)
2024-08-13 15:42:19 -04:00
Timothy Flynn
aab5320900 LibWeb: Indicate documents are for fragment parsing during construction
This will allow testing if they are for fragment parsing during methods
invoked from Document::initialize.

(cherry picked from commit c838ca78c81261e6111aa255c79e4a0599759c80)
2024-08-13 15:39:53 -04:00
Jamie Mansfield
f82e976df4 LibWeb: Implement DOMStringList
(cherry picked from commit 75216182c9a04741b2f773eb2f26ceb7a96bfbba)
(cherry picked from commit 2a55ab13ef9c735a16674006a518c0e5acf7c88f)

Co-authored-by: Sam Atkins <atkinssj@serenityos.org>
2024-07-29 09:14:06 -04:00
Tim Ledbetter
92ef7f08df LibWeb: Set correct prototype for WorkerLocation
(cherry picked from commit 354e5a6624a92952b1f3b86f98d9b1d0cb0ec048)
2024-07-28 20:48:58 -04:00
simonkrauter
d314a5a887 LibWeb: Rename HTMLInputElement members related to range shadow tree
Choose a better name for private members which were added in
https://github.com/LadybirdBrowser/ladybird/pull/513

(cherry picked from commit b1d7a27468e5dca58039c79a455c9f8ac1b80680)
2024-07-28 17:35:10 -04:00
Jamie Mansfield
9bbf50b755 LibWeb: Stub BroadcastChannel interface
This is enough to get the 1Password login page to load :^)

(cherry picked from commit d4a7cfb68fddbcfaaaddbd7f159c502c869281bf)
2024-07-28 16:44:35 -04:00
Jamie Mansfield
3a508ecf27 LibWeb: Implement HTMLMarqueeElement.trueSpeed
(cherry picked from commit 1f1276ffb10e0403e8880ff229e84be8f07f0d90)
2024-07-28 16:44:22 -04:00
Jamie Mansfield
47df84b14d LibWeb: Implement HTMLMarqueeElement.scrollDelay
(cherry picked from commit a917f8124cbf1aece0a8a623d4ce47a2464115b6)
2024-07-28 16:44:22 -04:00
Jamie Mansfield
43efbdd4b3 LibWeb: Implement HTMLMarqueeElement.scrollAmount
(cherry picked from commit 2a408ecfbc4b8cbc788230aa06fa30d32721922c)
2024-07-28 16:44:22 -04:00
Jamie Mansfield
5c9e947ebc LibWeb: Implement HTMLFrameElement.noResize
(cherry picked from commit 66528a17cb60c44d8cb946785b19d92a125c923a)
2024-07-28 16:44:22 -04:00
Jamie Mansfield
4b6801c13d LibWeb: Implement HTMLFrameElement.marginWidth
(cherry picked from commit e363e8918901ac33ceecc088f30c66797c069c8c)
2024-07-28 16:44:22 -04:00
Jamie Mansfield
0fa1f703d6 LibWeb: Implement HTMLFrameElement.marginHeight
(cherry picked from commit 4edc946aed6c2bceca4f8bfe9dca799d2cfe4743)
2024-07-28 16:44:22 -04:00
Braydn
2e8c178a03 LibWeb: Add Web Worker Origin Inheritance
Fetch requests from web workers fail CORS checks because the origin is
not inherited from the outside settings. Ensure web worker origin is
correctly inherited from outside settings

(cherry picked from commit 24adb1c4526fe29bbc332780272251be1635cf05)
2024-07-28 16:44:11 -04:00
Sam Atkins
c90492a50c LibWeb/CSS: Make CSS Parser::create() infallible
Now that `Tokenizer::tokenize()` just returns a String, there are no
errors to propagate, and we can simplify the user code a bit.

(cherry picked from commit 59778d2b365476ecb5b50218dae4457493ee7bf7)
2024-07-28 16:44:00 -04:00
Shannon Booth
1ffbd29683 Bindings: Implement is_supported_property_index in terms of item_value
Greatly simplifying the code :^)

(cherry picked from commit 9b1af542e7a718d110786551a1a18914cc386a2d)
2024-07-28 14:12:04 -04:00
Shannon Booth
930725ce8d Bindings: Make item_value return an Optional<JS::Value>
This removes some ambiguity about what the return value should be if
the index is out of range.

Previously, we would sometimes return a JS null, and other times a JS
undefined.

It will also let us fold together the checks for whether an index is a
supported property index, followed by getting the value just afterwards.

(cherry picked from commit c5c1a8fcc78af986e5dd1a1f0bef1223e458ed37)
2024-07-28 14:12:04 -04:00
Shannon Booth
daa4dc63f5 Bindings: Remove exception handling for named_item_value
(cherry picked from commit 9b59dc5e8b88d311089e57fe134a1377a39242cb)
2024-07-28 14:12:04 -04:00
Shannon Booth
7bcb02822e Bindings: Remove exception handling for named_item
We don't need this for any case, so just remove it to simplify handling
in PlatformObject.

(cherry picked from commit 081c92bf3dc66773887243718cf41011289ac55e)
2024-07-28 14:12:04 -04:00
Sam Atkins
1ea6e6c395 LibWeb: Correct logic for removing end nodes from HTMLOptionsCollection
This test case would previously crash.

Found with domato.

(cherry picked from commit 0cec68ea996623ee652900986c7232c8d538a209)
2024-07-28 13:00:11 -04:00
Timur Sultanov
9e36f7c86c LibWeb: Improve HTMLSelectElement spec compliance
Set default `size` value according to spec

(cherry picked from commit ad7b2b7c26c343504be32b9da8961e4fb5df3e86)
2024-07-28 12:59:58 -04:00
Timur Sultanov
54afd8bdc9 LibWeb: Improve HTMLOptionElement spec compliance
Implement ask_for_a_reset() function

(cherry picked from commit 9d4f3c938fd182d5cd195beefb1adf4d1bde376b)
2024-07-28 12:59:58 -04:00
Timur Sultanov
8344a54408 LibWeb: Implement selectedness algorithm
Implement selectedness setting algorithm in HTMLSelectElement

(cherry picked from commit f4102b1dc99c9bb1ec012106d28a35e03a6faea3)
2024-07-28 12:59:58 -04:00