Commit Graph

2596 Commits

Author SHA1 Message Date
Bastiaan van der Plaat
f19a183fe0 LibWeb: Add URL reflection to obsolete HTMLImageElement lowsrc property
(cherry picked from commit f2034270f14a72ebf0ac09493837c21bae0b4adf)
2024-10-19 15:26:29 -04:00
Colin Reeder
cd78e84e68 LibWeb: Also invalidate placeholder style on focus change
(cherry picked from commit cca03e484be96a3d833beff5834416c3c07dfbb2)
2024-10-19 15:26:14 -04:00
Timothy Flynn
c62dd41874 LibWeb: Move the navigable's cursor position to be owned by the document
Navigables are re-used for navigations within the same tab. Its current
ownership of the cursor position is a bit ad-hoc, so nothing in the spec
indicates when to reset the cursor, nor do we manually do so. So when a
cursor update happens on one page, that cursor is retained on the next
page.

Instead, let's have the document own the cursor. Each navigation results
in a new document, thus we don't need to worry about resetting cursors.

This also makes many of the callsites feel nicer. We were previously
often going from the node, to the document, to the navigable, to the
cursor. This patch removes the navigable hop.

(cherry picked from commit faebbbc281d1267062770b02fc6d962d92a3bd62)
2024-10-18 21:58:17 -04:00
Shannon Booth
b37d0b4bbb HTML: Partially implement HTMLInputElement's selection{Start,End}
Now that the implementation is in FormAssociatedElement, the
implementation in HTMLInputElement is effectively just a passthrough,
with some minor differences to handle small behavioural quirks between
the two (such as the difference in nullability of types).

(cherry picked from commit 9f24176cac862c42c9cf4d3ac0e757397a5f6ae1)
2024-10-18 21:58:17 -04:00
Shannon Booth
744b0e2d02 HTML: Put HTMLTextAreaElement selection helpers in FormAssociatedElement
This will allow us to more closely follow the spec and share these
functions with HTMLInputElement.

(cherry picked from commit 62bf428a7f57b585e6d0b8c01af2c0aca336fe2c)
2024-10-18 21:58:17 -04:00
Shannon Booth
8a469cf7e4 HTML: Add const qualified form_associated_element_to_html_element
Put the const cast in a common location to make the helper more
convenient to use.

(cherry picked from commit 28ed8e5d0f79fc9d961f746367127e137faaf46b)
2024-10-18 21:58:17 -04:00
Timothy Flynn
cb17194de8 LibWeb: Avoid allocating UTF-16 strings only the UTF-16 length is needed
(cherry picked from commit 4a166a45ec9db910542893133f08cc7de4ec974f,
minorly amended to resolve #include conflict due to our LibLocale
and LibUnicode being separate -- we don't want
https://github.com/LadybirdBrowser/ladybird/pull/257)
2024-10-18 18:21:18 -04:00
Tim Ledbetter
df8eec7786 LibWeb: Change attribute type to USVString where applicable
Also mark USVString attributes as containing a URL, where applicable.

(cherry picked from commit 1369fc5069598644842defabbfbf3d30d2f3e647)
2024-10-17 21:31:52 -04:00
Shannon Booth
db4bab8041 LibURL: Make percent_encode return a String
This simplifies a bunch of places which were needing to error check and
convert from a ByteString to String.

(cherry picked from commit 84a7fead0eefd967d4319f4d71c0a0ca3095d2d1)
2024-10-16 23:56:40 -04:00
Bastiaan van der Plaat
1a7a5e5172 LibWeb: Fix HTMLFrameElement noresize obsolete property typo
(cherry picked from commit e0c8a14fab937beb9e7c30740724bb0be6d3114e)
2024-10-16 19:46:21 -04:00
Bastiaan van der Plaat
67382ffa1f LibWeb: Add HTMLImageElement lowsrc obsolete property
(cherry picked from commit 4712f53dd7a9ea8c173c179869017738ed2ca1d1)
2024-10-16 19:46:21 -04:00
Bastiaan van der Plaat
f48fac2817 LibWeb: Add HTMLObjectElement codebase obsolete property
(cherry picked from commit d1fad9869bed8e0a8c8314968ffc8923ef239410)
2024-10-16 19:46:21 -04:00
Jamie Mansfield
21c4d1e088 LibWeb/HTML: Implement HTMLImageElement.longDesc
(cherry picked from commit 77a30bad9ffb52804b0cfd26f3589ab4c70fc2e3)
2024-10-16 19:40:02 -04:00
Jamie Mansfield
cadbe270f0 LibWeb/HTML: Implement HTMLIFrameElement.longDesc
(cherry picked from commit 45c2b1f62c5931a3dd9b573fc01095d95289d7e0)
2024-10-16 19:40:02 -04:00
Nico Weber
83facae137 LibWeb: Hook up square linecap support for canvas paths 2024-10-16 18:18:43 -04:00
BenJilks
4167d1214a LibTextCodec+LibURL: Implement utf-8 and euc-jp encoders
Implements the corresponding encoders, selects the appropriate one when
encoding URL search params. If an encoder for the given encoding could
not be found, fallback to utf-8.

(cherry picked from commit 72d0e3284b604c4c1373fb019250cdf5bd492300)
2024-10-15 22:54:51 -04:00
Shannon Booth
1308cab372 LibURL+LibWeb: Do not percent decode in password/username getters
Doing it is not part of the spec. Whenever needed, the spec will
explicitly percent decode the username and password.

This fixes some URL WPT tests.

(cherry picked from commit f511c0b441a591bc85f409242229c7b295e118e4)
2024-10-15 12:08:50 -04:00
Tim Ledbetter
84187c2252 LibWeb: Don't crash when parsing HTMLInputElement invalid time values
(cherry picked from commit fe42e2719f1ba92e04a530ca3910a7c8bfbbf1af)
2024-10-11 21:15:10 -04:00
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