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.
)
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)
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)
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)
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)
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)
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)
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.)
Use more widely recognized name among browser engine developers.
(cherry picked from commit 854b269338b1a1b31c0346f48dc58fa55ccf7d9f,
minorly amended due to the CornerRadius move in #24523)
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)
Now it's possible to query selected type from SVGPageClient.
(cherry picked from commit 6dd124fc876374f0da193da71f0fd6f103522810;
amended to remove skia parts)
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)
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.)
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 -
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)
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)
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)
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)
...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)
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.
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.
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>
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)
Previously, the fact that this wasn't accounted for could lead to a
crash when large messages were received.
(cherry picked from commit 34e465a67e41b82b276050dde0b4b321c2cf1b18)
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)
This will allow testing if they are for fragment parsing during methods
invoked from Document::initialize.
(cherry picked from commit c838ca78c81261e6111aa255c79e4a0599759c80)
(cherry picked from commit 75216182c9a04741b2f773eb2f26ceb7a96bfbba)
(cherry picked from commit 2a55ab13ef9c735a16674006a518c0e5acf7c88f)
Co-authored-by: Sam Atkins <atkinssj@serenityos.org>
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)
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)
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)
We don't need this for any case, so just remove it to simplify handling
in PlatformObject.
(cherry picked from commit 081c92bf3dc66773887243718cf41011289ac55e)