Commit graph

41886 commits

Author SHA1 Message Date
Andreas Kling
2c37df6241 LibWeb: Don't include DOMStringMap.h quite so much
This file was being included everywhere via HTMLElement and SVGElement,
but we don't actually need to do that.
2022-10-10 20:22:50 +02:00
Luke Wilde
081a617d8d LibWeb: Use the default CSS attributes for embedded content from HTML
The main benefit of this is respecting the iframe frameborder
attribute, as frameborder="0" is a pretty common way of removing
the default <iframe> border.

For example, it's on all YouTube embeds by default and on some
ReCAPTCHA embeds.
2022-10-10 19:33:34 +02:00
Luke Wilde
6a7c560849 LibWeb: Respect width and height attributes of <iframe>
We have to respect the width and height attributes of <iframe> elements
the same way as <img> elements.
2022-10-10 19:33:34 +02:00
Sam Atkins
8589f1115e Solitaire: Ignore all key presses while dragging cards
This prevents you from tab-moving cards while dragging some.
2022-10-10 16:16:01 +01:00
Sam Atkins
ff175389ab Solitaire: Make auto_move_eligible_cards_to_foundations() iterative
This doesn't need to be recursive, so let's make it not so.
2022-10-10 16:16:01 +01:00
Sam Atkins
5186e617bd LibCards+Games: Remove concept of a CardStack being focused
This was only used for asking the stack if it is the one we are moving
cards from. We now have a better way to do that, by comparing against
`CardGame::moving_cards_source_stack()`, which doesn't require manually
telling a stack that it is/isn't focused.
2022-10-10 16:16:01 +01:00
Sam Atkins
ef8b1e25aa LibCards: If dropping cards over multiple valid stacks, pick the closest
Previously, dropping a card that overlapped multiple stacks that could
accept it, would always choose the stack that came first in the stacks
list, usually the leftmost one. This would feel very odd if the card
was only slightly overlapping the left stack, and 90% over the right
one. So now, we keep looking for closer stacks even once we've found a
valid one.

There may be an option that feels even better, based on the position of
the card being dragged and the card on top of the stack we're dropping
onto, but this already fixes the issue and feels very nice. :^)
2022-10-10 16:16:01 +01:00
Sam Atkins
a4c1ee905f Spider: Use CardGame dragging functionality 2022-10-10 16:16:01 +01:00
Sam Atkins
7d37aebc07 Solitaire: Use CardGame dragging functionality 2022-10-10 16:16:01 +01:00
Sam Atkins
a2f0b67aea LibCards: Add support for card dragging
Solitaire and Spider have almost identical code for dragging cards from
one stack to another, so it makes sense to move that here. But using
the term "moving" for them, instead of "focused" which (to me at least)
was not clear what it meant.
2022-10-10 16:16:01 +01:00
Sam Atkins
5960c0556f LibCards+Games: Move mark_intersecting_stacks_dirty() to CardGame
As part of this, made a const overload for `Card::rect()`. We need the
non-const one too as it's used for modifying the position of a card
that's being dragged. I plan on changing that soon but we'll see.
2022-10-10 16:16:01 +01:00
Sam Atkins
12612703f9 LibCards+Spider: Move ensure_top_card_is_visible() logic to CardStack 2022-10-10 16:16:01 +01:00
Sam Atkins
b26383bc6c LibCards: Fix some minor clang-tidy issues 2022-10-10 16:16:01 +01:00
Sam Atkins
21a818ab50 LibCards: Combine CardStack constructors
And while I'm at it, clarify the name of `associated_stack` to
`covered_stack`. It's used in exactly one way, so we can make the code
clearer by giving it a less generic name.
2022-10-10 16:16:01 +01:00
Sam Atkins
bfa9ae809f LibCards+Games: Rename "draw" methods to "paint" for clarity
"Draw" is already a card-game term so using it for graphics was
 confusing me a lot!
2022-10-10 16:16:01 +01:00
Sam Atkins
6ef0504a42 LibCards+Games: Make CardGame responsible for managing CardStacks
Just moving some code around really.
2022-10-10 16:16:01 +01:00
Sam Atkins
46299f3853 LibCards+Games: Move "create a deck" logic to LibCards
`create_standard_deck()` is the usual 52-card deck, but more custom
setups (such as Spider's multiples-of-one-suit) can be created by
passing suit counts to `create_deck()`.
2022-10-10 16:16:01 +01:00
Andrew Kaster
1d533acbc0 AK+Userland: Replace Linux, macOS, and *BSD macros with platform defines
We have such nice platform macros, let's clean up any remnants of manual
__my_platform__ macros in LibCore, LibCompress and AK.
2022-10-10 12:23:12 +02:00
Andrew Kaster
539fb08551 Userland: Remove unecessary uses of __serenity__ macro 2022-10-10 12:23:12 +02:00
Andrew Kaster
828441852f Everywhere: Replace uses of __serenity__ with AK_OS_SERENITY
Now that we have OS macros for essentially every supported OS, let's try
to use them everywhere.
2022-10-10 12:23:12 +02:00
Andrew Kaster
896d4e8dc1 LibRegex: Don't build LibRegex/C/Regex.cpp on Lagom
This file implements the POSIX APIs from <regex.h>, and is not suitable
for inclusion in a Lagom build. If we do include it, it will override
the host's regex functions and wreak havoc if it's resolved before the
host's implementation.
2022-10-10 12:23:12 +02:00
Andrew Kaster
a81475d9fb LibCore: Don't assume that the first address from getaddrinfo is IPv4
By passing AF_UNSPEC to getaddrinfo, we're telling the system's
implementation that we are ok getting either (or both) IPv4 and IPv6
addresses in our result. On my Ubuntu 22.04 system, the first addrinfo
returned for "www.google.com" holds an IPv6 address, which when
interpreted as an IPv4 sockaddr_in gives an address of 0.0.0.0.

This fixes TestTLSHandshake in Lagom locally.
2022-10-10 12:23:12 +02:00
Andrew Kaster
51ebf20200 Tests: Remove LibRegex benchmark test file that has become stale
This test file had #ifdef macros at the top that caused none of the
content to be compiled unless a developer manually wanted to run the
specific benchmarks within. As such, it has become stale. Remove it for
now, if someone wants to restore it in an always-runnable state, we can
restore the specific tests it's trying to benchmark.
2022-10-10 12:23:12 +02:00
Zaggy1024
0c07bed89c LibVideo: Initialize VP9 BitStream's reservoir field
Leaving it uninitialized could lead to undefined behavior.
2022-10-10 11:04:39 +01:00
MacDue
fef19aa589 PixelPaint: Add Hue/Saturation filter
This filter mimics the functionality from Photoshop and other image
editors, allowing you to adjust the hue, saturation, and lightness of
an image. I always found this a very handy feature :^)
2022-10-10 11:02:10 +01:00
MacDue
71fb1ed226 PixelPaint: Add InplaceFilter and convert FastBoxBlur to be one
This is a simple base class for filters that need to work on the image
in-place.
2022-10-10 11:02:10 +01:00
MacDue
467565e3d4 LibGfx: Add TintFilter
This is a very simpler filter that tints an image with a color.
2022-10-10 11:02:10 +01:00
MacDue
35b714163d LibWeb: Fix wrapping glitches on repeating-linear-gradient()s
This fixes some off-by-one wrapping issues that became visible when
running on x86_64. The problem still existed on i686, but by chance
did not show up due to a -/+ 0.000001 difference between the two.
2022-10-10 10:47:50 +02:00
Zaggy1024
bbc053fa56 LibVideo: Add LibVideo test to Lagom 2022-10-09 20:32:40 -06:00
Zaggy1024
d67231312e LibVideo: Add test to ensure that a VP9 WebM file will decode
This will test decoding of one second of video, to ensure that it can
fully decode the entire file.
2022-10-09 20:32:40 -06:00
Zaggy1024
b71d13be82 VideoPlayer: Allow display of multiple frames by clicking the image
For testing purposes, this allows opening of any filename by passing it
as an argument.

Additionally, there is a --benchmark option that will just call decode
for 100 frames and then exit, printing the time spent in the decoder.
2022-10-09 20:32:40 -06:00
Zaggy1024
63ba01cad2 LibVideo: Remove unnecessary dbgln calls
Debug prints are expensive, so doing them every frame seems excessive
now that the decoder is completely functional on some test videos.
2022-10-09 20:32:40 -06:00
Zaggy1024
7dcd5ed206 LibVideo: Make probability tables save to the specified index
Previously, saved probability tables were being inserted, causing the
Vector to increase in size when it should say fixed at a size of 4. This
changes the Vector to an Array<T, 4> which will default-initalize and
allow assigning to any index without previously setting size.
2022-10-09 20:32:40 -06:00
Zaggy1024
7d27273dc7 LibVideo: Ensure that syntax element counts don't overflow
Integer overflow could sometimes occur due to counts going above 255,
where the values should instead be clamped at their maximum to avoid
wrapping to 0.
2022-10-09 20:32:40 -06:00
Zaggy1024
7c87a8e302 LibVideo: Prevent decode_block from saving motion vectors out of bounds
This fixes an issue causing frame 3 of the test video to fail to parse
because a reference vector was incorrectly within the range for a high
precision delta vector read.
2022-10-09 20:32:40 -06:00
Zaggy1024
be0760871e LibVideo: Add support for VP9 superframes
This allows the second shown frame of the VP9 test video to be decoded,
as the second chunk uses a superframe to encode a reference frame and
a second to inter predict between the keyframe and the reference frame.
2022-10-09 20:32:40 -06:00
Zaggy1024
b0187dfc27 LibVideo: Implement inter prediction
This enables the second frame of the test video to be decoded.

It appears that the test video uses a superframe (group of multiple
frames) for the first chunk of the file, but we haven't implemented
superframe parsing.

We also ignore the show_frame flag, so for now, this
means that the second frame read out is shown when it should not be. To
fix this, another error type needs to be implemented that is "thrown" to
decoder's client so they know to send another sample buffer.
2022-10-09 20:32:40 -06:00
Zaggy1024
50d4217dbc LibVideo: Look up interpolation filter probability correctly
The above interpolation filter mode was being taken from the left side
instead, causing some parsing errors.

This also changes the magic number 3 to SWITCHABLE_FILTERS.
Unfortunately, the spec uses the magic number, so this value was taken
instead from the reference codec, libvpx.
2022-10-09 20:32:40 -06:00
Zaggy1024
17107303f0 LibVideo: Fix incorrect VP9 InterMode enum values
These values were referencing the wrong column of a table in the spec,
the values should start from 10.
2022-10-09 20:32:40 -06:00
Zaggy1024
03738aa006 LibVideo: Implement block parsing for inter frames
This gets the decoder closer to fully parsing the second frame without
any errors. It will still be unable to output an inter-predicted frame.
The lack of output causes VideoPlayer to crash if it attempts to read
the buffers for frame 1, so it is still limited to the first frame.
2022-10-09 20:32:40 -06:00
Zaggy1024
6c648329c4 LibVideo: Add MotionVector lookup tables as constant expressions
This changes MotionVector by removing the cpp file and moving all
functions to the header, where they are now declared as constexpr
so that they can be compile-time evaluated in LookupTables.h.
2022-10-09 20:32:40 -06:00
Zaggy1024
1dc4652683 LibVideo: Rename MV to MotionVector for clarity 2022-10-09 20:32:40 -06:00
Zaggy1024
85fd56cf48 VideoPlayer: Display frames from the VP9 decoder
For testing purposes, the output buffer is taken directly from the
decoder and displayed in an image widget.

The first keyframe can be displayed, but the second will not decode
so VideoPlayer will stop at frame 0 for now.

This implements a BT.709 YCbCr to RGB conversion in VideoPlayer, but
that should be moved to a library for handling color space conversion.
2022-10-09 20:32:40 -06:00
Zaggy1024
1514004cd5 LibVideo: Implement VP9 intra-predicted frame decoding
The first keyframe of the test video can be decoded with these changes.

Raw memory allocations in the Parser have been replaced with Vector or
Array to avoid memory leaks and OOBs.
2022-10-09 20:32:40 -06:00
Zaggy1024
da9ff31166 LibVideo: Make new DecoderError class to report useful errors
This allows runtime strings, so we can format the errors to make them
more helpful. Errors in the VP9 decoder will now print out a function,
filename and line number for where a read or bitstream requirement
has failed.

The DecoderErrorCategory enum will classify the errors so library users
can show general user-friendly error messages, while providing the
debug information separately.

Any non-DecoderErrorOr<> results can be wrapped by DECODER_TRY to
return from decoder functions. This will also add the extra information
mentioned above to the error message.
2022-10-09 20:32:40 -06:00
Zaggy1024
72efd9a5ff LibVideo: Change decode_term_subexp read to the correct number of bits
This allows parsing of the implemented functions from the VP9 spec in
the test video included in /home/anon/Videos.
2022-10-09 20:32:40 -06:00
Zaggy1024
647472b716 LibVideo: Read multiple raw bits at once to refill the range decoder
This will allow BitStream::read_bool() to read more than one bit from
the range-coded bitstream at a time if needed.
2022-10-09 20:32:40 -06:00
Zaggy1024
13ccde8637 LibVideo: Improve error reporting for VP9 range decoder
init_bool will now check whether there is enough data in the bitstream
for the range coding size to be fully read.

exit_bool will now read the entire padding element regardless of size,
which the spec does not specify a limit on.
2022-10-09 20:32:40 -06:00
Zaggy1024
7f46033c01 LibVideo: Cache 64 bits at a time for reading in BitStream
Reads will now be done in larger chunks at a time.

The public read_byte() function was removed in favor of a private
fill_reservoir() function which will be used to fill the 64-bit
reservoir field which will then be bit-shifted and masked as necessary
for subsequent arbitrary bit-sized reads.

read_f(n) was renamed to read_bits to be clearer about its use.
2022-10-09 20:32:40 -06:00
Zaggy1024
b37ea6b414 LibVideo: Allow bit stream reads to throw errors
Errors are propagated to the user of the decoder so that they can be
aware of specific places where a read failed.
2022-10-09 20:32:40 -06:00