Commit graph

34 commits

Author SHA1 Message Date
Liav A
649f78d0a4 LibGfx+Ladybird+Userland: Don't sniff for TGA images with only raw bytes
Because TGA images don't have magic bytes as a signature to be detected,
instead assume a sequence of ReadonlyBytes is a possible TGA image only
if we are given a path so we could check the extension of the file and
see if it's a TGA image.

When we know the path of the file being loaded, we will try to first
check its extension, and only if there's no match to a known decoder,
based on simple extension lookup, then we would probe for other formats
as usual with the normal sniffing method.
2023-01-18 21:48:35 +01:00
Sam Atkins
a8cf0c9371 LibCore+Userland: Make Core::Timer::create_single_shot() return ErrorOr
clang-format sure has some interesting opinions about where to put a
method call that comes after a lambda. :thonk:
2023-01-12 11:25:51 +01:00
Sam Atkins
affc8a22ca LibWeb+WebContent: Convert BrowsingContext to new pixel units
This fixes a few glitches. We no longer give the page double the width
it should have, and we mark the correct area of the page as needing
repainting.
2023-01-05 17:42:31 +01:00
Tim Schumacher
9805f73704 LibCore: Remove the force parameter from File::remove
About half of the usages were not using `force` anyways, and the other
half presumably just got confused about what "force" really means in
this context (which is "ignore nonexistent files").

The only 'legitimate' user, which is `rm`, instead now handles this
completely internally instead.
2022-12-23 10:38:14 -05:00
Timothy Flynn
cc62d33a07 headless-browser: Remove option to specify a WebDriver FD-passing socket 2022-12-15 17:29:19 +00:00
Tim Schumacher
c6d71ca727 LibCore: Rename MemoryStream to FixedMemoryStream
This is to differentiate between the upcoming `AllocatingMemoryStream`,
which automatically allocates memory as needed instead of operating on a
static memory area.
2022-12-15 13:28:29 +00:00
Cygnix Proto
806a55eda1 LibGfx+Userland: Make Gfx::SystemTheme propagate errors
This patch introduces error propagation to Gfx::SystemTheme to remove
instances of release_value_but_fixme_should_propagate_errors().

Userland applications that have been affected by this change have been
updated to utilise this propagation and as a result 4 such instances of
the aforementioned method have been removed.
2022-12-14 18:25:28 +00:00
Sam Atkins
4440af0870 LibWeb: Split PaintContext::viewport_rect() into device/css variants
For now, everyone uses `device_viewport_rect()`, until I convert them.
2022-12-14 16:47:57 +00:00
Sam Atkins
0be479dcfb LibWeb: Make PaintContext aware of CSS and DevicePixels
Store the ratio between device and CSS pixels on the PaintContext, so
that it can convert between the two.

Co-authored-by: MacDue <macdue@dueutil.tech>
2022-12-14 16:47:57 +00:00
Sam Atkins
d3476c28ba LibWeb+WebContent+headless-browser: Remove PaintContext::scroll_offset()
Nobody uses this. They get the scroll_offset from the BlockContainer
instead.
2022-12-10 12:03:19 +00:00
Sam Atkins
3c7bd5a317 LibWeb+WebContent+headless-browser: Use CSSPixels for PageClient events
...and also for hit testing, which is involved in most of them.

Much of this is temporary conversions and other awkwardness, which
should resolve itself as the rest of LibWeb is converted to these new
types. Hopefully. :thousandyakstare:
2022-12-10 12:03:19 +00:00
Sam Atkins
8dfeb67f8c LibWeb+WebContent+headless-browser: Make Page aware of the display scale
For now, we just report it as "1" everywhere.

Replaced `screen_rect()` with `web_exposed_screen_area()` from the spec.
2022-12-10 12:03:19 +00:00
Andreas Kling
d88c7fee32 LibGfx+Userland: Make PNGWriter::encode() return ErrorOr<ByteBuffer>
This is a first step towards handling PNG encoding failures instead of
just falling over and crashing the program.

This initial step will cause encode() to return an error if the final
ByteBuffer copy fails to allocate. There are more potential failures
that will be surfaced by subsequent commits.

Two FIXMEs were killed in the making of this patch. :^)
2022-12-08 13:01:11 +00:00
MacDue
7be0b27dd3 Meta+Userland: Pass Gfx::IntPoint by value
This is just two ints or 8 bytes or the size of the reference on
x86_64 or AArch64.
2022-12-07 11:48:27 +01:00
Linus Groh
6e19ab2bbc AK+Everywhere: Rename String to DeprecatedString
We have a new, improved string type coming up in AK (OOM aware, no null
state), and while it's going to use UTF-8, the name UTF8String is a
mouthful - so let's free up the String name by renaming the existing
class.
Making the old one have an annoying name will hopefully also help with
quick adoption :^)
2022-12-06 08:54:33 +01:00
Baitinq
45214fdb1a LibWeb+WebContent: Label redirects with new FrameLoader::Type::Redirect
Previously we labeled redirects as normal FrameLoader::Type::Navigation,
now we introduce a new FrameLoader::Type::Redirect and label redirects
with it. This will allow us to handle redirects in the browser
differently (such as for overwritting the latest history entry when a
redirect happens) :^)
2022-11-26 11:03:24 +01:00
Timothy Flynn
e840d27d8e headless-browser: Add a mode for being controlled by WebDriver
This adds command line flags for WebDriver to pass its IPC socket path
(if running on Serenity) or its FD passing socket (if running elsewhere)
for the headless-browser to connect to.
2022-11-24 00:10:56 +00:00
Timothy Flynn
c917a59abe LibWeb+WebContent: Virtualize PageClient methods needed for all clients 2022-11-24 00:10:56 +00:00
Timothy Flynn
1f08cb7020 LibWeb+WebContent: Move pending dialog handling from PageHost to Page
Currently, all handling of pending dialogs occurs in PageHost. In order
to re-use this functionality to run WebDriver in a headless move, move
it to Page.
2022-11-24 00:10:56 +00:00
Sam Atkins
78a94cd3b7 headless-browser: Port screenshot output to Core::Stream
As noted in https://github.com/SerenityOS/serenity/issues/15239
`headless-browser` is currently broken, with or without these changes.
2022-11-19 17:00:10 +00:00
MacDue
8a5d2be617 Everywhere: Remove unnecessary mutable attributes from lambdas
These lambdas were marked mutable as they captured a Ptr wrapper
class by value, which then only returned const-qualified references
to the value they point from the previous const pointer operators.

Nothing is actually mutating in the lambdas state here, and now
that the Ptr operators don't add extra const qualifiers these
can be removed.
2022-11-19 14:37:31 +00:00
leeight
2eb6dbd4f0 headless-browser: Add ca-certs-path options 2022-10-15 02:44:47 +03:30
networkException
4230dbbb21 AK+Everywhere: Replace "protocol" with "scheme" url helpers
URL had properly named replacements for protocol(), set_protocol() and
create_with_file_protocol() already. This patch removes these function
and updates all call sites to use the functions named according to the
specification.

See https://url.spec.whatwg.org/#concept-url-scheme
2022-09-29 09:39:04 +01:00
Sam Atkins
fb2e1c4611 headless-browser: Install EventLoop and Font plugins so it doesn't crash 2022-09-21 20:42:36 +01: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
69a45adfbe LibWeb: Remove page_did_set_document_in_top_level_browsing_context()
This PageClient callback was never used for anything.
2022-08-05 12:42:46 +02:00
Andreas Kling
548081ea23 Userland+Base: Make the window titlebar font configurable separately
Instead of defaulting to "bold variant of the system default font",
let's allow the user to set any font they want as the titlebar font.
2022-08-01 10:29:53 +02:00
DexesTTP
686c15149e headless-browser: Simplify the arguments used to select resources
We can just infer the favicon, fonts and palette from the location of
the /res folder, no need to ask each of the resources one by one.
2022-07-19 08:02:52 +01:00
DexesTTP
9e5af374d0 headless-browser: Split the setters for the screen and the viewport rect
These two represent different things, and should be handled by different
methods.
2022-07-19 08:02:52 +01:00
DexesTTP
9c431ede7a headless-browser: Use port 443 as default for HTTPS requests 2022-07-19 08:02:52 +01:00
Lucas CHOLLET
662711fa26 Browser+LibWeb+WebContent: Allow Browser to load local files
To achieve this goal:
 - The Browser unveils "/tmp/portal/filesystemaccess"
 - Pass the page through LoadRequest => ResourceLoader
 - ResourceLoader requests a file to the FileSystemAccessServer via IPC
 - OutOfProcessWebView handles it and sends a file descriptor back to
 the Page.
2022-06-27 20:22:15 +01:00
DexesTTP
a2161d8eb7 Utilities: Add networking to headless-browser
With this, the headless browser can now connect to the web.

Thanks a lot to Ali and Sin-ack for their help with this!

Co-authored-by: Ali Mohammad Pur <mpfard@serenityos.org>
Co-authored-by: sin-ack <sin-ack@users.noreply.github.com>
2022-05-29 23:00:04 +01:00
DexesTTP
f9d4c0ecbc Utilities: Add image decoding to headless-browser
With this, the headless browser can now decode images on its own!
2022-05-29 23:00:04 +01:00
DexesTTP
355e74cf65 Utilities: Add a simple headless-browser
This utility creates a 'screenshot' of the given page after a
few seconds of loading.
2022-05-29 23:00:04 +01:00