This method accepts a namespace URI as an argument and returns true if
the given URI is the default namespace on the given node, false
otherwise.
(cherry picked from commit 055c902a375bb34b8c0e31f015c2815fe935c6a9)
This method takes a prefix and returns the namespace URI associated
with it on the given node, or null if no namespace is found.
(cherry picked from commit 27d429a85f359b9c87bf9807e4dea33f7092308a)
This change implements the download, ping, rel, hreflang, and type
attributes using the [Reflect] annotation in the IDL file.
(cherry picked from commit 7562f89d4e2b0dd22430962e102a2195186f8458)
Add fetch group concept from the '2.4. Fetch groups' in
the fetch specs to the environment settings object.
(cherry picked from commit 9e223f6daeb3969d3997084a973b26daff6b4f7e)
Previously, `Node::is_equal_node()` would return true for nodes in
different namespaces that were otherwise equal.
(cherry picked from commit 7ab7be694d1232f4cdc108a2adc88812fc0a9ca9)
This matches the behavior of other browsers. Previously, a click event
was used, so the value was only updated when the mouse was released.
(cherry picked from commit b4b947c60797328d930c8d3de466b8ef292d0ed4)
An input event is now fired when the step up or step down button of an
input element of type number is clicked.
This ensures that any associated <output> element is updated when these
buttons are clicked.
(cherry picked from commit 2a980816e756d727261d53450b4b3f48069d5d50)
Input elements without a defined user-interaction behavior need to fire
an input event when the user changes the element's value in some way.
This change moves the code to do this into its own function and adds
some spec text to explain what is being done.
(cherry picked from commit a3d12e569c88d0dae530657e5bddc18699fb9c9b)
The spec allows setting a constructor on non built-in Iterator objects.
This is a normative change in the Iterator Helpers proposal. See:
https://github.com/tc39/proposal-iterator-helpers/commit/30b3501
(cherry picked from commit fb228a3d850eb5e4b06550823755719a377b41e6)
The spec allows setting the prototype on non built-in Iterator objects.
This is a normative change in the Iterator Helpers proposal. See:
https://github.com/tc39/proposal-iterator-helpers/commit/30b3501
(cherry picked from commit 734e37442db4419b58228e25702bfe176e52f5e3)
The EntryType has three possible values: Fetching, Failed or
ModuleScript. It is possible that we transition from Fetching to Failed
as in #13.1. Change the assertion to include the failed scenario.
Fixes: https://github.com/LadybirdBrowser/ladybird/issues/661
(cherry picked from commit 319bb6353e0ba64fc5e54b32ddb2b38736cedef9)
This fixes some bugs on wpt.dom/events/Event-init-while-dispatching.html,
although the test still fails due to [GH-23722].
[GH-23722]: https://github.com/SerenityOS/serenity/issues/23722
(cherry picked from commit aefab1de38948b0d86a6aed33647e995340859e2)
- Change min track sizing function to be "auto" when flex size is
specified.
- Never check if min track sizing funciton is flexible, because only
max is allowed to be flexible.
- Address FIXME in automatic_minimum_size to avoid regressions after
making two fixes mentioned above.
(cherry picked from commit 3270df476dd46b140e1b9de1e8328647744b56ab)
Areas are disassembled into boundary lines on `build_grid_areas()` step,
so we can always use them to find grid item's position during placement.
This way we support both ways to define area: `grid-template-areas` and
implicitly using `-start` and `-end` boundary line names.
(cherry picked from commit 7a1f3f7ae3af2744e2f99df29baf09153d631b24)
We're expected to handle this situation gracefully, and certainly not
by falling apart like we were.
Found by Domato.
(cherry picked from commit 33207174a9c1c87657e2ae0875cc85cbf41075f8)
If the anchor and focus nodes are not within the same document, we can't
use them for a selection range.
Found by Domato.
(cherry picked from commit 416c4788763baa778465d1d004080d322462c0bf)
Instead of allowing arbitrarily large values (which could eventually
overflow an i32), let's just cap them at the same limit as Firefox does.
Found by Domato.
(cherry picked from commit 4e0edd42b95abf8ad707c64414dbe618313ce89e)
We were incorrectly assuming that setAttribute() could never fail here,
even when passed an invalid name.
Found by Domato.
(cherry picked from commit 093f1dd805f699801079f55d0d490d80b463ccbb)
We already have a FlyString of its value from parsing, and most users
also want a FlyString from it, so let's use that instead of converting
backwards and forwards.
The two users that did want a String are:
- Quotes, which make sense as FlyString instead, so I've converted that.
- Animation names, which should probably be FlyString too, but the code
currently also allows for other kinds of StyleValue, and I don't want
to dive into this right now to figure out if that's needed or not.
(cherry picked from commit 9fb44cb05777c6d7a8a1950258edadfcee6d4e09)
This does not appear to be correct; the `grid-area` property's value is
quite complicated, and not just a string.
(cherry picked from commit d2f04b9f0415ebfebb1d8f6386ff13f8df053674)
The JS::Error types all store their exception messages as a String. So
by using ByteString, we hit the StringView constructor, and end up
allocating the same string twice.
(cherry picked from commit c3f8202d0ca7761caaabf0af5f413dc25337801f)
We had a const and non-const version of this function, with slightly
different behavior (oops!)
This patch consolidates the implementations and keeps only the correct
behavior in there.
Fixes an issue where comments were not collapsible on Hacker News.
(cherry picked from commit 98f88d49de852e1e524655accb39724f1134a23f)
These were being immediately stored in JS::GCPtrs (and dutifully visited
by HTMLParser), so creating temporary handles for them was a complete
waste of time.
(cherry picked from commit f9f11dc51d50746ccb1a82cd304fe30901edc347)
When loading a canned version of reddit.com, we end up parsing many many
shadow tree style sheets of roughly ~170 KiB text each.
None of them have '\r' or '\f', yet we spend 2-3 ms for each sheet just
looping over and reconstructing the text to see if we need to normalize
any newlines.
This patch makes the common case faster in two ways:
- We use TextCodec::Decoder::to_utf8() instead of process()
This way, we do a one-shot fast validation and conversion to UTF-8,
instead of using the generic code-point-at-a-time callback API.
- We scan for '\r' and '\f' before filtering, and if neither is present,
we simply use the unfiltered string.
With these changes, we now spend 0 ms in the filtering function for the
vast majority of style sheets I've seen so far.
(cherry picked from commit dba6216caa71796f25831908035cd9eb0fb54715)
When appending a single Unicode code point, we don't have to go through
the trouble of creating a Utf32View wrapper over it.
(cherry picked from commit 7892ee355df95f6414ab5334d8d997c2c0356a45)
Implement for CreatePerIterationEnvironment for 'for' loops per the Ecma
Standard. This ensures each iteration of a 'for' loop has its own
lexical environment so that variables declared in the loop are scoped to
the current iteration.
(cherry picked from commit dbc2f7ed48f00234f5f94a30b06b83842d9cf4dd)
When traversing the layout tree to find an appropriate box child to
derive the baseline from. Only the child's margin and offset was being
applied. Now we sum each offset on the recursive call.
(cherry picked from commit 3c897e7cf3594f02f559599e1bf28747c9edba13)
The LibELF validate_program_headers method tried to do too many things
at once, and as a result, we had an awkward return type from it.
To be able to simplify it, we no longer allow passing a StringBuilder*
but instead we require to pass an Optional<Elf_Phdr> by reference so
it could be filled with actual ELF program header that corresponds to
an INTERP header if such found.
As a result, we ensure that only certain implementations that actually
care about the ELF interpreter path will actually try to load it on
their own and if they fail, they can have better diagnostics for an
invalid INTERP header.
This change also fixes a bug that on which we failed to execute an ELF
program if the INTERP header is located outside the first 4KiB page of
the ELF file, as the kernel previously didn't have support for looking
beyond that for that header.
This new syscall will be used by the upcoming runc (run-container)
utility.
In addition to that, this syscall allows userspace to neatly copy RAMFS
instances to other places, which was not possible in the past.
The whole concept of Jails was far more complicated than I actually want
it to be, so let's reduce the complexity of how it works from now on.
Please note that we always leaked the attach count of a Jail object in
the fork syscall if it failed midway.
Instead, we should have attach to the jail just before registering the
new Process, so we don't need to worry about unsuccessful Process
creation.
The reduction of complexity in regard to jails means that instead of
relying on jails to provide PID isolation, we could simplify the whole
idea of them to be a simple SetOnce, and let the ProcessList (now called
ScopedProcessList) to be responsible for this type of isolation.
Therefore, we apply the following changes to do so:
- We make the Jail concept no longer a class of its own. Instead, we
simplify the idea of being jailed to a simple ProtectedValues boolean
flag. This means that we no longer check of matching jail pointers
anywhere in the Kernel code.
To set a process as jailed, a new prctl option was added to set a
Kernel SetOnce boolean flag (so it cannot change ever again).
- We provide Process & Thread methods to iterate over process lists.
A process can either iterate on the global process list, or if it's
attached to a scoped process list, then only over that list.
This essentially replaces the need of checking the Jail pointer of a
process when iterating over process lists.
Expose some initial interfaces in the mount-related syscalls to select
the desired VFSRootContext, by specifying the VFSRootContext index
number.
For now there's still no way to create a different VFSRootContext, so
the only valid IDs are -1 (for currently attached VFSRootContext) or 1
for the first userspace VFSRootContext.
Negative numbers now display correctly in SpinBox.
Previously, they displayed as the negative sign only (no number).
Now the user can also type negative numbers into the SpinBox.
These were accidentally no longer set after
2c396b5378fec5f4470e1e1e950806dff8005f08
(cherry picked from commit f20010c1d3a66aaabd5da5a96c578ad013756f99)
Previously we relied on signed overflow, this commit makes the same
behaviour explicit (avoiding UB in the process).
(cherry picked from commit 8c8310f0bddc874a9f7f07c4158f0abc799357d4)
With this we pass an additional ~2100 tests.
We are left with 7106 WASM fails :).
There's still some test cases in the iNxM tests that fail with
this PR, but they are somewhat weird.
(cherry picked from commit b4acd4fb0b7f4105c7ef673ccc00904114c3c468)
Co-authored-by: Diego Frias <styx5242@gmail.com>
Previously the validator put a `v128` on the stack, which is not what
the spec defines.
(cherry picked from commit 0d38572d8bd2a276be1b6066b62efd376ddbd4d6)
After a `memory.grow`, the type of the memory instance should be
updated so potential memory imports on the boundary are unlinkable.
(cherry picked from commit cdb6e834a1c0eaa6e62a9018026a599916332ab3)
Single-type blocktypes previously gave loop labels an arity of 1, even
though they're shorthand for `[] -> [T]`.
(cherry picked from commit ad6a80144c23f9ccdeeccb123a9de85396524040)
Since be2bf05 the ThreadEventQueue is now destroyed via a phread key
destructor, which leads to many other objects being destroyed. A bunch
of these destructors reference globals, but exit() calls destructors
on globals before phread destructors, this bad state leads to the hangs
seen in #24694.
Fixes#24694
When the min option is given the read will only be fulfilled when there
are min or more elements available in the readable byte stream.
When the min option is not given the default value for min is 1.
(cherry picked from commit 907dc84c1e8c3c236ade581f46dabdb144915c1d)
Lossless WebP allows having a 1-bit to 11-bit addressed
"color cache", where pixels are inserted into a content-addressed
cache of size `1 << color_cache_bits`. Pixels in the color
cache can be addressed using their index. This can be used
to refer to literal pixels using a single color_cache_bits
large symbol, instead of up to 4 symbols for GBRA.
We default to always using a color cache with 6 bits, unless
the input image already uses only a single channel already
(either as-is, or if we write a color indexing transform).
Due to this change, the size of the first prefix group
changes from being known at compile time (256 + 24)
to being known at runtime (256 + 24 + color_cache_size).
Change a few Array<>s to Vector<>s to make this work.
sunset_retro.png (876K):
1.6M -> 1.4M, 29.1 ms ± 0.9 ms -> 31.7 ms ± 0.9 ms
From 83% larger than the input file to 60% larger (12.5% smaller),
for a 9% slowdown.
The two gifs I usually test with don't change: Files using the
color _index_ transform (i.e. that have < 256 colors) don't
use the color _cache_ in our encoder.
This property is now correctly parsed.
Ladybird always uses overlay scrollbars so this property does nothing.
(cherry picked from commit 662317726549cd2dde4c7902b99f0b83397a3396)
The spec doesn't explicitly forbid calling this when the document
doesn't have a node navigable, so let's handle that situation gracefully
by just returning an empty list of ancestors.
I hit this VERIFY somewhere on the web, but I don't know how to
reproduce it.
Previously, the presence of surrounding whitespace would give file paths
the `https` schema instead of the `file` schema, making navigation
unsuccessful.
(cherry picked from commit ff7ca5c48c316e07b1bf631b2d7ed14c358dfa42)
This fixes many tests on
wpt/html/webappapis/scripting/events/event-handler-all-global-events.html
(cherry picked from commit 59f74b909ba161a143fb4cd5cbaf6dcf6734d240)
This fixes wpt/html/webappapis/scripting/events/messageevent-constructor.https.html
(cherry picked from commit ffb3a28684b1b4c028af93aa6d7d9194f002d503)
This allows selection to work within shadow roots and prevents the
selection being cleared if the mouse moves outside of the current
document or shadow root.
(cherry picked from commit e5d1261640a71a672c5cd19910f5f6288e65ed04)
Previously the input element was displayed with value 0, when no value
was set in the HTML. Now it uses `value_sanitization_algorithm()`, which
will calculate the default value.
In `value_sanitization_algorithm()` there was a logical mistake/typo.
The comment from the spec says "unless the maximum is less than the
minimum".
The added layout test would fail without the code changes.
Fixes#520
(cherry picked from commit 191531b7b18d2edf97dc7bf88a9c19903eeae2d5)
Now that we pass an `old_value` parameter to `attribute_changed` it is
no longer necessary to store the current attribute state in
`HTMLScriptElement`.
(cherry picked from commit aa4e18fca50b261eabd5672a3f1163b4ac7ef50b)
This aligns AO transform_stream_error_writable_and_unblock_write() with
the spec.
No functional change is introduced by this amendment.
(cherry picked from commit 24bed027b2db59935da185d3bd490718ccb37baa)
We now defer looking up the various identifiers by IdentifierTableIndex
until the last moment. This allows us to avoid the retrieval in common
cases like when a property access is cached.
Knocks a ~12% item off the profile on https://ventrella.com/Clusters/
(cherry picked from commit 509c10d14db0f2e2ce2b89f307d9dd360b855eb5,
amended to mark the two `throw_null_or_undefined_property_get` functions
static, as -Wmissing-declarations pointed out on CI)
Now that the Interpreter is the only user of these functions, we might
as well keep them in Interpreter.cpp which makes CLion less confused.
(cherry picked from commit ae0cfe4f2d260bfd804364c17f28494e3e8964c9)
Previously, when `WindowOrWorkerGlobalScope.reportError()` was called
the `filename` property of the dispatched error event was blank. It is
now populated with the full path of the active script.
(cherry picked from commit 34b987366449313c96a73ec1d70e88e60f2c4510)
Previously, setting CSS `line-height: 0` on an `input` element would
result in no text being displayed.
Other browsers handle this by setting the minimum height to the
"normal" value for single line inputs.
(cherry picked from commit 629068c2a7eb02db37ffb4fe8d536306ee71e156)
This method was unused and a FIXME remained for combining it with
another, similar method.
(cherry picked from commit df7f7268db5edb37b735f30586d774544537e342)
Previously the entire slider track was colored.
Now only the lower part of the slider track (left side of the thumb) is
colored.
Chrome and Firefox do the same.
(cherry picked from commit 7766909415312b971252f8c7750b0a1873fd5ba0)
This fixes some WPT failures caused by the "view" parameter not being
initialized from the property bag.
(cherry picked from commit 932a7d4d819fac9d0acfe4184574488dd69f94ec)
These methods were overriding properties specified by the EventInit
property bags in the constructor for WheelEvent and MouseEvent.
They appear to be legacy code and no longer relevant, as they would have
been used for ensuring natively dispatched events had the correct
properties --- This is now done in separate create methods, such as
MouseEvent::create_from_platform_event.
This fixes a couple WPT failures (e.g. in
/dom/events/Event-subclasses-constructors.html)
(cherry picked from commit 2c396b5378fec5f4470e1e1e950806dff8005f08)
This method puts the given node and all of its sub-tree into a
normalized form. A normalized sub-tree has no empty text nodes and no
adjacent text nodes.
(cherry picked from commit 0a0651f34ea927a0ca44dc5d2c7786f3dcf8da25)
Solving using the unconstrained height, when solving for bottom, would
either leave a gap over overflow its container.
(cherry picked from commit bee42160c5e2cdb949e6057f029391ee7e0fa9fa)
The first time Document learns its viewport size, we now suppress firing
of the resize event.
This fixes an issue on multiple websites that were not expecting resize
events to fire so early in the loading process.
(cherry picked from commit 4e7558c88b7a993686bb3dc173731e677efe5e26)
This allows global `let` and `const` variable accesses to be cached
by the GetGlobal instruction, and works even when the access is in a
different translation unit from the declaration.
Knocks a ~10% item off the profile on https://ventrella.com/Clusters/
(cherry picked from commit 9448c957c136e62b374a0f8998d1d51906e59fb5)
From https://html.spec.whatwg.org/multipage/scripting.html#script-processing-model:
When a script element el that is not parser-inserted experiences one
of the events listed in the following list, the user agent must
immediately prepare the script element el:
- [...]
- The script element is connected and has a src attribute set where
previously the element had no such attribute.
(cherry picked from commit d890be6e0f7db08ab39ba546cb3421b50b687cda)
The style of input and textarea elements is now invalidated when focus
is changed to a new element. This ensures any `:focus` selectors are
applied correctly.
(cherry picked from commit 572324d47b99bcfbc5db5ff6aef0d6c4eb15ce4c)
Instead of using fixed arbitrary colors for the background of the bar,
AccentColor and Background are now used.
(cherry picked from commit 062a266574a24fe13f2a77401b97f833c3cdd099)
If a favicon image response status was not ok,
we would still attempt to decode the received body data.
(cherry picked from commit 7f04ceb4f6889921ba055ce87476762b9eba262e)
If an image response status was not ok, we would still pass the received
body data to ImageDecoder which is not correct.
(cherry picked from commit 8085e3eb2655ba412fd803a38c4e58d1dc3b3c3b)
Like 1132c858e9, out-of-flow elements such
as float elements would get inserted into block level `::before` and
`::after` pseudo-element nodes when they should instead be inserted as a
sibling to the pseudo element. This change fixes that.
This fixes a few layout issues on the swedish tax agency website
(skatteverket.se). :^)
(cherry picked from commit 9ed2669fc801a3475c9f383ae7221b6a2b1a7fa5)
The concept of out-of-flow and in-flow elements is used in a few places
in the layout code. This change refactors these concepts into functions.
(cherry picked from commit 196922ae5b44044cbf7baaf28fbfedba1b3d11f3)
The logic of the comment "the region between the high boundary and the
maximum value must be treated as the optimum region" is correct.
However, the code below covered only two cases, the optimum case was
missing.
Fixes#473
(cherry picked from commit a676bd97a745cd7a4b33bb779e00ec68cb1d3c7c)
This matches libwebp (see ZeroFillCanvas() call in
libwebp/src/demux/anim_decode.c:355 and ZeroFillFrameRect() call
in line 435, but in WebPAnimDecoderGetNext()) and makes files
written e.g. by asesprite look correct -- even though the old
behavior is also spec-compliant and arguably makes more sense.
Now nothing looks at the background color stored in the file.
See PR for an example image where it makes a visible difference.
It turns out we cannot use function multi-versioning with "sha" feature
or even just plain ifunc resolvers without preprocessor guards. So,
instead of feeding ifdef-soup monster, we just use static member
function pointer.
Moving the kernel into the SHA1 class makes it possible to not pass
class members as parameters to it. This, however, requires us to
disambiguate different target "clones" of the kernel using some kind
of template.
This also removes `[[gnu::target("sse4.2")]]` from nested functions:
since we don't explicitly use any of the SSE4.2 intrinsics there, the
said target is unneeded. Note that this won't prevent compiler from
choosing SSE4.2 intrinsics as the affected functions are always inlined
into `transform_impl_sha1` that has `[[gnu::target("sse4.2")]]`.
This warning is triggered when one accepts or returns vectors from a
function (that is not marked with [[gnu::target(...)]]) which would have
been otherwise passed in register if the current translation unit had
been compiled with more permissive flags wrt instruction selection (i.
e. if one adds -mavx2 to cmdline). This will never be a problem for us
since we (a) never use different instruction selection options across
ABI boundaries; (b) most of the affected functions are actually
TU-local.
Moreover, even if we somehow properly annotated all of the SIMD helpers,
calling them across ABI (or target) boundaries would still be very
dangerous because of inconsistent and bogus handling of
[[gnu::target(...)]] across compilers. See
https://github.com/llvm/llvm-project/issues/64706 and
https://www.reddit.com/r/cpp/comments/17qowl2/comment/k8j2odi .
This patch adds the common Ctrl-W shortcut to make_quit_action as an
alternate shortcut by default.
The shortcut can be disabled in programs using this key binding for a
different purpose, e.g. closing tabs, or instances where the "close
window" concept would not be applicable, such as CatDog.
To the best of my knowledge, I have disabled the shortcut for any
existing programs in the system where the aforementioned examples or any
additional conflicts would apply.
Using the path rasterizer here is much slower than simply drawing four
lines. This also more accurately shows the (real) clip as the bounding
box is truncated to an int before adding it as a clip rect.
Fixes#23056
This now matches the behavior of did_request_link_context_menu and
friends. Previously the coordinates relative to the page rather than
viewport were sent to the chrome.
(cherry picked from commit 990cf9b4e9476d15494a9538614762119d759b2d)
As far as I know, they're not in the spec and don't serve any purposes
in the internals of LibWasm.
(cherry picked from commit 5382fbb6171555264e29872029330e1373b39671)
NaN bit patterns are now (hopefully) preserved. `static_cast` does not
preserve the bit pattern of a given NaN, so ideally we'd use some other
sort of cast and avoid `static_cast` altogether, but that's a large
change for this commit. For now, this fixes the issues found in spec
tests.
(cherry picked from commit c882498d4450c4c2e46d77a8ab36afc4eb412c00)
The main intention of this change is to have a consistent look and
behavior across all scrollbars, including elements with
`overflow: scroll` and `overflow: auto`, iframes, and a page.
Before:
- Page's scrollbar is painted by Browser (Qt/AppKit) using the
corresponding UI framework style,
- Both WebContent and Browser know the scroll position offset.
- WebContent uses did_request_scroll_to() IPC call to send updates.
- Browser uses set_viewport_rect() to send updates.
After:
- Page's scrollbar is painted on WebContent side using the same style as
currently used for elements with `overflow: scroll` and
`overflow: auto`. A nice side effects: scrollbars are now painted for
iframes, and page's scrollbar respects scrollbar-width CSS property.
- Only WebContent knows scroll position offset.
- did_request_scroll_to() is no longer used.
- set_viewport_rect() is changed to set_viewport_size().
(cherry picked from commit 5285e22f2aa09152365179865f135e7bc5d254a5)
Co-authored-by: Jamie Mansfield <jmansfield@cadixdev.org>
Co-authored-by: Nico Weber <thakis@chromium.org>
This is a hack needed to preserve current behaviour after making set
viewport_rect() being not async in upcoming changes.
For example both handle_mousedown and handle_mouseup should use the same
viewport scroll offset even though handle_mousedown runs focusing steps
that might cause scrolling to focused element:
- handle_mousedown({ 0, 0 })
- run_focusing_steps()
- set_focused_element()
- scroll_into_viewport() changes viewport scroll offset
- handle_mouseup({ 0, 0 })
(cherry picked from commit 50920b05953a6bc2aacb07d291d503052caadf15)
When compiling with `-O2 -g1` optimizations (as done in the main
Serenity build), no out-of-line definitions end up emitted for
`Value::to_numeric`, causing files that reference the function but don't
include the definition from `ValueInlines.h` to add an undefined
reference in LibJS.so.
Otherwise we'd hit a VERIFY in AK::SIMD::shuffle() when that operand
contains an out-of-range value, the spec tests indicate that a swizzle
with an out-of-range index should return 0.
We currently pretend that these return an ElfAddr, while in actuality
they return a function pointer.
UBSAN may check this and complain about it, so let's just disable it
for that line.
Any data that sticks around in a decoder, especially frames that
haven't been retrieved, may cause issues for playback.
(cherry picked from commit c128a19903c42d5a66153445c457d41dc7ed30a1)
The timestamp offset of a block was being converted from i16 to u64, so
negative values would overflow and cause timestamps that fall before
the cluster's timestamp from being close to the minimum representable
i64.
The math is also now done using saturating operations to prevent any
other similar issues from occurring.
(cherry picked from commit ef99e701b7372a409b11a4fa1d1196a76580eb0e)
H.264 in Matroska can have blocks with unordered timestamps. Without
passing these to the decoder when providing data, the decoder will be
unable to reorder the frames to presentation order.
VideoFrame will now include a timestamp that is used by the
PlaybackManager, rather than assuming that it is the same timestamp
returned by the demuxer.
(cherry picked from commit f6a4973578c4692f33283aee1c089afd0cdae508)
This is necessary to give H.264 decoders the data they need to
initialize, including frame size and profile.
(cherry picked from commit 457a69786b788d3158813156d11e70980f50f7b7)
The function is separated from the string-to-enum function it uses, and
the order is also inconsistent with header.
(cherry picked from commit bf1e0fac94e0d8599c0c540c24883ca5f5ea4131)
These aren't particularly small objects, but we were still copying them
around all over the place. When TrackEntry contains data buffers, they
won't need to be copied as well.
(cherry picked from commit 55fda2068b7334acaba2673c80c01c019aaf7075)
This should halve the size of frames in memory for frames with 8-bit
color components, which is the majority of videos.
Calculation of the size of subsampled planes has also been consolidated
into a struct. There are likely some places that will still need to
change over to this, but it should prevent issues due to differing
handling of rounding/ceiling.
(cherry picked from commit 40fe0cb9d5c40a5ee568a3196bf19452ea8fed2b)
BT.2020 will mainly be used with bit depths greater than 8, so having
this specialization is mostly pointless until we use fixed-point math
for higher bit depths.
(cherry picked from commit fe2a63d485bc9d494b06a780043eae21adfd6854)
Apparently I forgot to put read the value for this field, though this
generally doesn't matter since video bitstreams usually specify CICP as
well.
(cherry picked from commit d3f88b4987730e396bc41c2674edddb53845cb37)
This change is in preparation for implementing audio codecs into the
library and using audio as timing for video playback.
(cherry picked from commit 7c10e1a08d7a109b63c9258578eb98aa9dcc1425)
No effect on sunset-retro.png since that's not animated.
wow.gif (nee giphy.gif) (184k):
1.4M -> 255K
74.0 ms ± 1.1 ms -> 86.9 ms ± 3.3 ms
(from 7.6x as big as the gif input to 1.4x as big.
About 82% smaller, for a 16% slowdown.)
7z7c.gif (11K):
8.4K -> 8.6K
12.9 ms ± 0.5 ms -> 12.7 ms ± 0.5 ms
(2.4% bigger, so the transform makes things a bit worse for this
image.)
AnimationWriter already only stores the smallest rect that contains
changing pixels between two frames. For example, when doing a screen
recording and only the mouse cursor moves, we already only encode
the pixels in the (single) rectangle containing old and new mouse cursor
positions.
Within that rectangle, there can still be many pixels that are identical
over the two frames. When possible, we now replace all identical pixels
with transparent black. This has two advantages:
1. It can reduce the number of colors in the image. In particular,
for wow.gif (and likely many other gifs), new frames had more
than 256 colors before, and have fewer than 256 colors after this
change.
2. Long run of identical pixels compress better.
In some cases, this transform might make things slighly worse,
for example if the input image already consists of long runs of
a single color. We'll now add another color to it (transparent black),
without it helping much. And the decoder now must do some blending,
slowing down decoding a bit.
But most of the time this should be a pretty big win. We can tweak
the heuristic when to do it later.
This transform is possible when:
* The new frame doesn't already have transparent pixels (which are
different from the old frame)
* The encoder/decoder can handle frames with transparent pixels
For the latter reason, encoders currently have to opt in to this.
This is an attempt to fix the hanging CI on macOS caused by some
screenshot requests being stuck unprocessed. With this change, we at
least make sure that the HTML event loop processing, which triggers
repainting, will happen as long as there are navigables that need to be
repainted.
(cherry picked from commit 72b4d44d07e12cc04bde90872e2f31aaab64aa00)
There are a few instances where comments and documentation have minor
grammar issues likely resulting from English being the author's second
language.
This PR fixes several such cases, changing to idiomatic English and
resolving where it is unclear whether the user or program/code is
being referred to.
This avoids an unnecessary lossy conversion for the current time from
double to i32. And avoids an UBSAN failure on macOS that's dependent
on the current uptime.
(cherry picked from commit 55c1b5d1f4d7c82f0a68323260cb2e0f7de2faae,
amended to fix a typo in the commit message)
This implements the start of lossless webp's compression scheme,
which is almost, but not quite, entirely unlike deflate.
The green channel is now green-or-length, and has up to 280
entries, instead of up to 256 before. We now use the 40-entry
distance code (even though it only ever stores 1s now).
Due to this, a few places change to taking spans instead of
Array<256>s.
The spec only has the transform from prefix or distance code
to value. The inverse prefix_decompose() in this patch is
my own invention. I checked with a python script that it's
a true inverse (see PR for the script).
We now look for back-references with a distance of 1, which is
equivalent to run-length encoding. It's fairly fast to compute,
but leaves compression on the table. Full window-based
back references will be in a future PR.
We also still don't do color cache entries yet, but that should
be fairly straightforward to add. (It will make the green channel
larger than 280 entries.)
We still use a single global huffman table for the entire image.
Doing one per tile should be doable with the organization we now
have, and might also be in a future PR.
File sizes, and perf numbers on HEAD before this patch series (see
previous commit for perf comparison to previous commit):
sunset-retro.png (876K):
1.7M -> 1.6M,
25.3 ms ± 0.5 ms -> 27.5 ms ± 0.8 ms
(helps little; from 1.94x as input to 1.83x as large.
About 5% smaller, for about a 10% slowdown.)
wow.gif (nee giphy.gif) (184k):
3.9M -> 1.4M
105.7 ms ± 1.7 ms -> 74.0 ms ± 1.1 ms
(from 21.2x as big as the gif input to 7.6x as big.
About 64% smaller, for a 28% speed _up_.)
7z7c.gif (11K):
40K -> 8.4K
13.9 ms ± 0.6 ms -> 12.9 ms ± 0.5 ms
(from 3.6x as big as the gif input to 0.76x as big :^)
About 79% smaller, for a 7% speed _up_.)
We now do this in two passes instead of in one. This is virtually free
performance-wise, and allows nicer factoring.
Perf numbers after this change (see previous commit for perf numbers
before):
Benchmark 1: image -o sunset-retro.webp sunset-retro.bmp
Time (mean ± σ): 26.7 ms ± 0.8 ms
Benchmark 1: animation -o 7z7c.webp 7z7c.gif
Time (mean ± σ): 14.5 ms ± 0.6 ms
Benchmark 1: animation -o wow.webp wow.gif
Time (mean ± σ): 108.2 ms ± 2.2 ms
No behavior change yet, but this will allow us to emit distance/length
and color cache symbols in addition to literal symbols.
Not super expensive perf-wise. Before:
Benchmark 1: image -o sunset-retro.webp sunset-retro.bmp
Time (mean ± σ): 25.3 ms ± 0.5 ms
Benchmark 1: animation -o 7z7c.webp 7z7c.gif
Time (mean ± σ): 13.9 ms ± 0.6 ms
Benchmark 1: animation -o wow.webp wow.gif
Time (mean ± σ): 105.7 ms ± 1.7 ms
After:
Benchmark 1: image -o sunset-retro.webp sunset-retro.bmp
Time (mean ± σ): 26.1 ms ± 0.6 ms
Benchmark 1: animation -o 7z7c.webp 7z7c.gif
Time (mean ± σ): 14.4 ms ± 0.6 ms
Benchmark 1: animation -o wow.webp wow.gif
Time (mean ± σ): 106.5 ms ± 1.9 ms
Take Spans instead of Arrays. There's no need to have one copy of this
function for every possible array size passed to it.
Hardcode the inline size of the BinaryHeap to 288 for now. If this
becomes a performance issue in the future, we can make that size
an (optional) template parameter then.
No behavior change.