This reduces the minimum size of a basic block from 4 KiB to 0 bytes.
With this change, memory usage at the end of Speedometer is 1.2 GiB,
down from 1.8 GiB.
ImageStyleValue has a visit_edges() method, although it is not a
GC-allocated object. This is necessary because it owns a GC-allocated
ImageRequest that we want to visit, instead of using JS::Handle, to
avoid leaks. In the future, we might want to make StyleValue be
GC-allocated.
For now, this change adds missing visit_edges() calls for objects that
own ImageStyleValue.
Instead of calling out to helper functions for flow control (and then
checking control flags on every iteration), we now simply inline those
ops in the interpreter loop directly.
If we don't have a local unwind context to handle the exception, we can
just return right away. This allows us to remove one check from the
inner loop.
Nuke all the per-instruction bounds checking when iterating instructions
by using raw pointers instead of indexing into a ReadonlyBytes.
The interpreter loop already checks that we're in-bounds anyway.
Using JS::Handle in WebEngineCustomData means that mutation observers
will live as long as VM while actually they should be deallocated as
soon as they are no longer used in a script that created them.
There is not need to use SafeFunction because
define_native_function or define_native_accessor will pass callback
forward to NativeFunction that uses HeapFunction to visit it.
This commit introduces 3 things:
- Support for the color type in HTMLInputElement itself
- A mechanism for handling non event loop blocking dialogs in Page
- The associated plumbing up to ViewImplementation
Frontends may add support for the color picker with the
ViewImplementation.on_request_color_picker function
This is 10-20% of a speed increase on platforms with fast I/O (Linux)
and not a slowdown on Serenity. Again, the file system layer is the
limit for us :^)
The internal reuse of FixedMemoryStream makes this straightforward.
There alread is one user of the new API, demonstrating the need for this
change beyond what I said out to use it for :^)
Since it will become a stream in a little bit, it should behave like all
non-trivial stream classes, who are not primarily intended to have
shared ownership to make closing behavior more predictable. Across all
uses of MappedFile, there is only one use case of shared mapped files in
LibVideo, which now uses the thin SharedMappedFile wrapper.
Previously, the same file would be counted more than once if its
containing directory was visited multiple times, or there were
multiple hard links pointing to it.
We now keep track of every visited inode to ensure that files aren't
evaluated multiple times. This matches the behavior of `du` on FreeBSD
and Linux.
Most shorthands can be reconstructed this way, using our generated
property data, so let's use them instead of manually implementing the
code.
Some of these were previously doing some form of error checking or
defaulting, but both of those are unnecessary. (And actually, would
crash if there wasn't a value available due to calling release_nonnull()
on a null RefPtr.) At this point, the CSS machinery has already made
sure each property has a value, and that the value is valid for that
property.
These three are the ones that ShorthandStyleValue uses to serialize
`grid`, so let's use them here.
The spec also mentions `grid-auto-*` properties as being set by `grid`,
but I'll leave that for someone who understands grid better.
When parsing these, <number> is allowed anywhere that would usually
allow a <length>, <length-percentage>, or <angle>. The spec is not
clear on exactly how this should work
(see https://github.com/w3c/svgwg/issues/792 ) so I'm using some
artistic license until things are clearer:
- If we expected a <length>, treat the <number> as pixels.
- If we expected an <angle>, treat the <number> as degrees.
- Only allow direct <number> tokens, not calc() or other functions.
From what I can tell this is what the spec *intended* but I may be very
wrong. In any case, telling the ParsingContext whether we're parsing
one of these attributes is a cleaner approach and more correct than
temporarily enabling quirks mode, which we did previously.
Before the completion_steps for timer were casted from JS::SafeFunction
to Function in HTML::Timer constructor, which is incorrect because then
callback's captured GC-allocated objects are not protected from being
deallocated. Let's modify HTML::Timer to use JS::HeapFunction for the
callback instead.
By using Core::Timer that accepts Function instead of JS::SafeFunction
in Platform::Timer does we fix memory leak caused by circular
dependency of timer's callback and timer itself.
This change implements a step from the document's destroy procedure in
the specification, saying that all active timers should be cleared.
By doing this, we also fix the leaking of a document in case where we
have navigated away from a page that has scheduled timers that haven't
yet been triggered.
aafef1e92d broke this while trying to
make the global import available in initialisation, this commit makes
sure we place the module's own functions after all resolved imports.
If a function that captures a GC-allocated object is owned by another
GC-allocated object, it is more preferable to use JS::HeapFunction.
This is because JS::HeapFunction is visited, unlike introducing a new
heap root as JS::SafeFunction does.
If a function that captures a GC-allocated object is owned by another
GC-allocated object, it is more preferable to use JS::HeapFunction.
This is because JS::HeapFunction is visited, unlike introducing a new
heap root as JS::SafeFunction does.
When there is no `catch` parameter to bind the error, we don't need
to allocate an environment, since there's nothing to add to it.
This avoids one environment allocation every time we catch like this:
try {
...
} catch {
...
}
These functions are deferring to NamedNodeMap::get_attribute which
already takes a StringView. This changes also leads to finding some
places which were passing though a const char* instead of an entry from
Attribute names. Fix that where applicable, and switch to has_attribute
in some of those places instead of deprecated_attribute where
equivalent.
Ideally this should be taking a 'FlyString const&', but to continue
porting away from DeprecatedString, just leave a FIXME for now.
It calls Element::get_attribute which takes a StringView. Ultimately,
this should be taking a FlyString, but to help in porting away from
DeprecatedString, just leave a FIXME for that for now.
It already delegates to a function which accepts a StringView, so there
is no advantage here in taking a FlyString. Ideally, both of these
functions should be taking a 'FlyString const&', so leave a FIXME for
that. In the meantime, this should help in porting away from
DeprecatedString.
There are an unfortunate number of DeprecatedString conversions required
here, but these should all fall away and look much more pretty again
when other places are also ported away from DeprecatedString.
Leaves only the Element IDL interface left :^)
The SVGDecodedImageData creates a new Page and replaces its document
with a new one that contains SVG content. This change adds a destroy
call on the replaced document. Without this addition, all tasks
scheduled on the event loop during navigation, initiated while the
page's traversable is being created, will never execute, as the
initial replaced document will become inactive. This leads to a
document leak because the tasks use JS::Handle to hold document
pointer. Making the destroy call resolves the issue because it removes
all tasks associated with the destroyed document from the queue.
Before this change, whenever ImageStyleValue had a non-null
`m_image_request`, it was always leaked along with everything related
to the document to which this value belongs. The issue arises due to
the use of `JS::Handle` for the image request, as it introduces a
cyclic dependency where `ImageRequest` prevents the `CSSStyleSheet`,
that owns `ImageStyleValue`, from being deallocated:
- ImageRequest
- FetchController
- FetchParams
- Window
- HTMLDocument
- HTMLHtmlElement
- HTMLBodyElement
- Text
- HTMLHeadElement
- Text
- HTMLMetaElement
- Text
- HTMLTitleElement
- Text
- HTMLStyleElement
- CSSStyleSheet
This change solves this by visiting `m_image_request` from
`visit_edges` instead of introducing new heap root by using
`JS::Handle`.
Previously, exiting a fullscreen application when
`save_size_and_position_on_close()` was used would lead to the
application having an unexpectedly large size when it was reopened.
Exiting a maximized application would lead to the restore button not
working as expected when the application was reopened.
DOMMatrix fromMatrix was using create_from_dom_matrix_2d_init to make
a DOMMatrix for it's init struct this is wrong because only the 2D
params of the DOMMatrix are put into the new matrix. I have added
a non 2D version of that function that takes the full DOMMatrixInit
so now fromMatrix works correctly again. I also have added some
text tests to test if it works correctly.
I split the dommatrix.html text tests into multiple files because that
file was becoming to big so now every sub function is a seperate file.
Now that shorthands use ShorthandStyleValue, the only bespoke code left
for them applies to CSS-wide keywords. We can automate expanding those,
so let's do so. :^)
This isn't included in the base definition of a CSS-wide keyword, but
the CASCADE-4 spec which adds it says:
> The revert CSS-wide keyword rolls back the cascade to the cascaded
value of the earlier origin.
So it is one. While I'm at it, rename `is_builtin()` to match the spec
terminology. It's not used currently, but will be in the next commit.
Previously, argument-less options could only set a boolean to true. This
lets them also set an enum variable to a specific value, as is currently
done by the `ls` utility.
This algorithm is the meat of firing the NavigateEvent at navigation.
In order to implement it, we also need to add some getters/setters on
NavigateEvent. The implemetentation deviates from the spec in when
exactly the NavigateEvent is created. In following the pattern for other
events. we construct the event from the NavigateEventInit structure from
our native code. This makes the code a lot simpler than adding 10
getters to the NavigateEvent that are only ever used just after
construction. I'm not 100% conviced the promise resolution code is
correct, but we can add tests for that later :^).
These Navigation API Method Tracker AOs are called by the inner navigate
event firing algorithm. Implement them beforehand to make the diff look
pretty :^).
The potentially scroll/focus and finish AOs are called by the inner
navigate event firing algorithm. Implement them beforehand to make the
diff look pretty :^).
For now, part of this is commented-out. Our current implementations of
`<mask>` and `<symbol>` rely on creating layout nodes, so they can't be
`display: none`.
It does not currently handle any of the actual scripting, but this
should at least allow us to create an instance of the element.
The test being added here isn't actually testing much, but before the
previous commit we used to crash parsing the page due to a TODO().
These allow accessing embeds, forms, images and objects with a given
name attribute, and any element with a given id attribute, as top level
properties on the global object.
It also allows accessing NavigableContainers by target name as top level
properties on the global object.
The current implementation feels very expensive. It's likely that
these values will need smarter caching in the future.
And implement WindowProperties, the "named properties object" for Window
according to the spec.
This involves moving an AO out of LegacyPlatformObject and into a common
place that the WindowProperties class can access.
This doesn't implement the AOs on Window that actually name lookup for
the unenumerable named properties on the window yet, just the
scaffolding.
And remove assorted spec FIXMEs along the way. Also align
populate_session_history_entry_document to the spec, with a bonus spec
bug to be filed.
This involves creating a new NonFetchSchemeNavigationParams spec, and
having the associated AOs take a Variant rather than Optional to
accomodate the fact that this extra struct could be returned by the
algorithm. We don't actually *do* anything with these params, but the
scaffolding is there now, with less TODOs.
Before, we only ensured that boxes establishing BFC did not overlap
with floats because that is what CSS 2.2 specification says. However,
we should also apply the same for boxes establishing FFC or GFC as this
aligns with the behavior of other browsers.
Fixes https://github.com/SerenityOS/serenity/issues/21095
This was a remnant from the AST/BC hybrid interpreter times. We've had
a VERIFY in here for weeks now that would catch anything depending on
this behavior, and nothing has hit it, so let's remove the unnecessary
code (but leave the VERIFY) :^)
Our implementation of environment.CreateImmutableBinding(name, true)
in this AO was not correctly initializing const variables in strict
mode. This would mean that constant declarations in for loop bodies
would not throw if they were modified.
To fix this, add a new parameter to CreateVariable to set strict mode.
Also remove the vm.is_strict mode check here, as it doesn't look like
anywhere in the spec will change strict mode depending on whether the
script itself is running in script mode or not.
This fixes two of our test-js tests, no change to test262.
Otherwise `attr(|name, "fallback")` becomes `attr(| name , "fallback")`
The test here is slightly aspirational. There are other rules for
serialization we don't follow (like stripping whitespace entirely from
many places) so these are marked with FIXMEs.
The `to_string()` for this is modified a little from the original,
because we have to calculate what the layer-count is then, instead of
having it already calculated.
We don't need to check if a function parameter is already declared
while creating bindings for them because we deduplicate their names by
storing them in a hash table in one of the previous steps.
This change makes React-Redux-TodoMVC test in Speedometer run 2%
faster.
The existing implementation has some pre-existing issues where it is
incorrectly assumes that byte offsets are given through the IDL instead
of UTF-16 code units. While making these changes, leave some FIXMEs for
that.
This is required in porting over CharacterData from DeprecatedString to
String.
Unfortunately, as with ParentNode, we cannot yet remove the
DeprecatedString variants of these functions as the Element interface
includes ChildNode and has not yet been ported over from
DeprecatedString.
This allows applying SVG <mask>s to elements. It is only implemented for
the simplest (and default) case:
- mask-type = luminance
- maskContentUnits = maskContentUnits
- maskUnits = objectBoundingBox
- Default masking area
It should be possible to extend to cover more cases. Though the layout
for maskContentUnits = objectBoundingBox will be tricky to figure out.
This allows SVG mask elements to have layout computed, but not connected
to the main paint tree. They should only be reachable if (and painted)
if referenced by the "mask" attribute of another element.
This is controlled by the forms_unconnected_subtree() function on the
paintable, which (if it returns true) prevents the paintable from being
added as a child to what would be its parent.
A Paintable is not created for an SVG <defs> element (nor should it),
but it can contain SVG <mask> elements that need a paintable.
This change forces those paintables to be created (without a parent).
The masks are then only painted by being referenced from another
element.
This change moves steps that can be executed only once and then reused
in subsequent function instantiations from
`function_declaration_instantiation` to the ECMAScriptFunctionObject:
- Determine if there are any parameters with duplicate names.
- Determine if there are any parameters with expressions.
- Determine if an arguments object needs to be created.
- Create a list of distinct function names for which bindings need to
be created.
- Create a list of distinct variable names for which bindings need to
be created.
This change makes React-Redux-TodoMVC test in Speedometer
run 10% faster :)
We were parsing these all right, but ignoring them in StyleComputer.
No test unfortunately, since we don't currently have a way to delay
the load event until a @font-face has been fully loaded. (Any test
of this right now would be flaky.)
This fixes an issue where the value would be out of sync with reality
in anonymous wrapper block boxes, since we forgot to compute m_visible
after assigning the computed values to them.
Fixes#21106
Support for this element has been removed from all major engines years
ago already, and it's currently the only reason we have a weird
"visible" flag on Layout::Node (which we toggle on a timer here..)
This makes CMake pass `-fpie` instead of `-fpic` to the compiler when
building the Kernel and userland *executables*. This allows the compiler
to make certain optimizations based on the fact that the code will be
used in an executable, such as not having to emit `.localalias` symbols.
This leads to a 450 KiB decrease in the size of the Kernel binary.
This is a rickety solution to a problem when using LibTimeZone as a
static archive, like we do for Android. When pulling symbols from an
archive into a shared library, lld will pick the weak symbols for our
timezone helpers and keep them. Even if there's a strong symbol in
another object file in the same archive, it ignores them. However,
if we make sure that the strong symbols for the generated files are
first in the list, then we avoid the problem altogether by relying
on linker specifics.
Some websites, such as m.youtube.com, sniff for a version after the
Android OS version. Chrome has recently taken to always reporting
Android 10, so let's follow suit.
Previously, trying to access a non-readable file would cause a
connection reset in the browser; trying to access a non-executable
directory would show a completely empty directory listing.