Commit graph

54459 commits

Author SHA1 Message Date
Shannon Booth
c3e6077cfc LibWeb: Make Document::{visibility,read}_state return a StringView
Also using the visibility state enum to change strcmp to a simple
enum state check :^)
2023-09-13 07:26:35 +02:00
Shannon Booth
49eb3bfb1d LibWeb: Make Document::run_the_document_write_steps take a StringView
Which flows on down into HTMLTokenizer::insert_input_at_insertion_point.
2023-09-13 07:26:35 +02:00
Shannon Booth
827170f6e6 LibWeb: Take a StringView in Document::get_elements_by_class_name
We only ever use the view of the DeprecatedFlyString anyway, so let's
just use a StringView.
2023-09-13 07:26:35 +02:00
Shannon Booth
ec39a5a41a LibWeb: Const qualify Document::number_of_things_delaying_the_load_event 2023-09-13 07:26:35 +02:00
Shannon Booth
e42bda5f19 LibWeb: Make Document::open functions take a StringView
One of these functions doesn't make any use of the arguments at all, and
the other defers to an open helper which already takes a StringView.
2023-09-13 07:26:35 +02:00
Shannon Booth
8ad05fff4a LibWeb: Make Document::set_cookie take a StringView
Enabled by also making the same change to ParsedCookie::parse_cookie :^)
2023-09-13 07:26:35 +02:00
Andrew Kaster
642802d339 LibWeb: Add {de}serialization steps for ArrayBuffers 2023-09-12 22:14:39 +02:00
Andrew Kaster
a527f55768 LibWeb: Create StructuredSerialize helpers for Bytes
Call them from the helpers for strings. We'll have other object classes
soon that need to serialize ByteBuffers, so let's take advantage of the
encoding scheme we are already using for Strings.
2023-09-12 22:14:39 +02:00
Andrew Kaster
56d0a0ac0f LibJS: Make CreateDataByteBlock AO publicly available
At the same time, make CopyDataBlockBytes const-correct.
2023-09-12 22:14:39 +02:00
Andrew Kaster
267074cd81 LibWeb: Add {de}serialization steps for RegExpObjects
We skip serializing any of the internal state of the Regex<ECMA262>
object, because that state is all computable from the input pattern
and flags. If it turns out that this is really, really slow, we can add
some optimizations to serialize more of the regex parse result.
2023-09-12 22:14:39 +02:00
Andrew Kaster
3a74bd2509 LibWeb: Don't try to deserialize past length of strings
If we serialize a string followed by some other object, the deserialize
helper would just happily keep appending bytes to the string until the
end of the serialization buffer. Avoid doing that by checking the string
length for figuring out when the string actually ends.
2023-09-12 22:14:39 +02:00
Cubic Love
842b2a01e6 Base: Add manpage for pkg 2023-09-12 20:03:12 +02:00
Aliaksandr Kalenik
63939445b1 LibWeb: Use fit-content width if button's computed width is "auto"
Implements following line from the spec:
"If the computed value of 'inline-size' is 'auto', then the used value
is the fit-content inline size."
2023-09-12 17:26:30 +02:00
Aliaksandr Kalenik
7eee3f6952 LibWeb: Add mutable_computed_values() for NodeWithStyle
This fixes the issue that we previously had to use a gross static_cast
whenever we wanted to mutate computed values outside of the Node
methods.
2023-09-12 17:26:30 +02:00
Andreas Kling
44b2735b9e LibJS: Make line-and-column resolution fast for large minified JS
Instead of caching start-of-line offsets, we now cache byte offsets
at regular intervals. This fixes an issue where we had terrible
performance on large minified JS, since that often means one very,
VERY long line (with no line endings to cache).

My machine was spending ~35ms per stack frame when throwing errors
on some heavy minified websites, and after this patch, we now spend
<1ms per stack frame.
2023-09-12 17:21:42 +02:00
Sam Atkins
ff02de4ad0 LibWeb: Serialize StringStyleValue with quotes
In order to access the string's contents, use the new
`StringStyleValue::string_value()` method.

I think I found all the existing places that relied on
`StringStyleValue::to_string()` returning an unquoted string, but it's
hard to know for sure until things break.
2023-09-12 14:29:21 +01:00
Sam Atkins
77ae510319 LibWeb: Parse each unquoted font-family name as a single CustomIdentSV
Previously we made StringStyleValues from these, but once we start
actually quoting StringStyleValues when serializing them, this will
break the font-family serialization.
2023-09-12 14:29:21 +01:00
Aliaksandr Kalenik
d1e542999c LibWeb: Ensure preceding offset is non-negative in float_box()
When calculating the edge offset of the next floating item based on the
offset of the preceding floating item, we need to ensure that the
preceding offset is always > 0. This isn't explicitly written in the
spec, but all other popular engines do that.

Fixes https://github.com/SerenityOS/serenity/issues/21023
2023-09-12 12:11:53 +02:00
Aliaksandr Kalenik
81ddad3fcf LibWeb: Allow block level boxes to be floated and have clearance
Before, we completely ignored clearance for block-level boxes if they
were floated. This was incorrect because it is valid for a block-level
box to be floated and still have clearance. However, unlike clearance
on normal flow boxes, clearance on floating boxes does not affect the
y-position of subsequent normal flow boxes. Instead, it pushes the
box's position to the very beginning of an edge.

Work towards https://github.com/SerenityOS/serenity/issues/21023
2023-09-12 12:11:53 +02:00
Jelle Raaijmakers
9240233378 Revert "AK: Refill a BufferedStream when it has less than the
...requested size"

This reverts commit 13573a6c4b.

Some clients of `BufferedStream` expect a non-blocking read by
`read_some` which the commit above made impossible by potentially
performing a blocking read. For example, the following command hangs:

    pro http://ipecho.net/plain

This is caused by the HTTP job expecting to read the body of the
response which is included in the active buffer, but since the buffered
data size is less than the buffer passed into `read_some`, another
blocking read is performed before anything is returned.

By reverting this commit, all tests still pass and `pro` no longer
hangs. Note that because of another bug related to `stdout` / `stderr`
mixing and the absence of a line ending, there is no output to the
command above except a progress update.
2023-09-11 21:38:24 -04:00
Sam Atkins
489f9c3151 LibWeb: Implement text-transform: math-auto
This is a simple mapping of some code-points to others.

I was going to use a ref test for this, but without knowing that the
font contains the code-points (which SerenitySans does not) we'd be
comparing a series of replacement characters to a series of replacement
characters, which doesn't tell you if they're the right code-points
underneath.
2023-09-11 17:03:22 +01:00
Sam Atkins
ce775ea701 LibWeb: Use a switch to handle TextTransform values
This makes it more obvious that we're missing some of these. (And makes
it easier to find this code when searching for a specific value.)
2023-09-11 17:03:22 +01:00
Sam Atkins
f7209fb9d4 LibWeb: Implement font-size: math
This is a MathML extension, basically a big hack to make parts of
equations smaller, such as sub/superscripts. The important thing is, it
works. :^)
2023-09-11 17:03:22 +01:00
Sam Atkins
6476dea898 LibWeb: Implement the math-depth CSS property
This one is a bit fun because it can be `add(<integer>)` or `auto-add`,
but children have to inherit the computed value not the specified one.
We also have to compute it before computing the font-size, because of
`font-size: math` which will be implemented later.
2023-09-11 17:03:22 +01:00
Sam Atkins
53f3ed026a LibWeb: Mark CalculatedStyleValue::resolve_integer() as const 2023-09-11 17:03:22 +01:00
Sam Atkins
6045143d39 LibWeb: Parse the math-shift and math-style CSS properties
Currently these have no effect, but they're simple, and `math-style`
influences `math-depth` which is coming next.
2023-09-11 17:03:22 +01:00
Sam Atkins
2ef5658f31 LibWeb: Add ComponentValue::is_function(name) and is_ident(name) helpers 2023-09-11 17:03:22 +01:00
Sam Atkins
f3124c492b LibWeb: Add display: math
This is a `<display-inside>` keyword added by the MathML spec, and has
the rough meaning of "display in the default way". It enables the
standard layout rules for each MathML element (and is ignored for
anything that isn't a MathML element).

I believe we'll need an actual MathML formatting context to do the
layout correctly, but we can at least support a couple of elements that
behave the same as HTML ones.
2023-09-11 17:03:22 +01:00
Sam Atkins
125d161b3f LibWeb: Move <display-foo> definitions into Enums.json
This eliminates a fair bit of boilerplate.
2023-09-11 17:03:22 +01:00
Sam Atkins
3b0980c89f LibWeb: Stop allowing invalid tokens in display values
Previously we were overly generous in what we accepted for `display`.
For example, we accepted:
- Multiple outside or inside identifiers
- Unrecognized identifiers
- Non-identifier tokens

Now, we reject all these cases. This makes us stop accepting the
`display: block math;` declaration in `MathML/Default.css`, and so the
one layout test we have containing MathML elements has changed to
reflect that.
2023-09-11 17:03:22 +01:00
Adam Harald Jørgensen
7bf842a974 Ladybird: Allow opening multiple URLs at once from the command line
Each URL is opened in a separate tab on startup, and the active tab is
the first URL supplied.
2023-09-11 17:01:17 +01:00
Aliaksandr Kalenik
40dea272d2 LibWeb: Add boxes for before/after pseudos post button layout tweak
When a button should use flex for alignment and also has ::before
and/or ::after, we previously did the following:
1. Prepended/appended the button's children with boxes for
   pseudo-elements.
2. Replaced the button's direct children with a flex container that
   contains its children.
As a result, the generated boxes for ::before/::after ended up as
children of the generated flex item, instead of being direct children
of the button layout box as they were supposed to be.

This change reverses these steps, ensuring that boxes for
pseudo-elements are generated only after modifications inside the
button layout are completed.
2023-09-11 15:19:56 +02:00
Aliaksandr Kalenik
0160d921e9 LibWeb: Set children of button layout box to be non-inline
When modifying the button layout during tree building to use flex for
vertical alignment, let's explicitly set the button box's children to
be non-inline. It doesn't make sense to layout the button as an IFC
when its only child is a flex container.
2023-09-11 15:19:56 +02:00
dependabot[bot]
38d9c4d19c CI: Bump actions/checkout from 3 to 4
Bumps [actions/checkout](https://github.com/actions/checkout) from 3 to 4.
- [Release notes](https://github.com/actions/checkout/releases)
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](https://github.com/actions/checkout/compare/v3...v4)

---
updated-dependencies:
- dependency-name: actions/checkout
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-09-11 09:11:27 -04:00
Shannon Booth
b738929195 LibDiff: Fix wrong index used when prepending context lines
`i` is used as the index for 'old lines' in diff generation, not 'new
lines'. Using the wrong index would mean that for certain diffs the
prefixed context information would have wrong content, and could even
result in a crash.

Fix this, and add a test for an input which was previously crashing.
2023-09-11 12:10:50 +01:00
Shannon Booth
4adbf1d041 LibWeb: Port DocumentFragment from DeprecatedString to String 2023-09-11 12:07:36 +01:00
Shannon Booth
bfc0773285 LibWeb: Add String versions for some functions in ParentNode
These functions are required in the porting of the DocumentFragment
interface from DeprecatedString to String. Unfortunately since
ParentNode is used by Document, we can't fully remove the deprecated
versions of these functions yet.
2023-09-11 12:07:36 +01:00
Shannon Booth
3e0849eb4f LibWeb: Add FlyString variants of get_element_by_id
Unfortunately we can't port these functions entirely over to FlyString
from DeprecatedString as Document includes NonElementParentNode and has
not yet been ported over to new AK string. In the mean time, this should
help up in porting over NonElementParentNode itself.
2023-09-11 12:07:36 +01:00
Shannon Booth
b2f3aa1c76 LibWeb: Use length() getter in CharacterData algorithms
Closer matching spec text, as well as pre-existing use in
CharacterData::substring_data. This helps in porting of this file over
to new String which has no length member function.
2023-09-11 12:07:36 +01:00
Timothy Flynn
e8f14f8cd0 Ladybird: Add an audio context menu to the AppKit chrome 2023-09-11 06:52:37 -04:00
Sam Atkins
2cb816ad69 LibWeb: Alphabetize property names in Properties.json
And add a check to make sure it stays that way!
2023-09-11 10:42:00 +01:00
Sam Atkins
9f4e057085 LibWeb: Fall back to computed values in ResolvedCSSStyleDeclaration
We only need special-case code to handle two kinds of properties:
- Those with special rules, many of which are listed here:
  https://www.w3.org/TR/cssom-1/#resolved-values
- Shorthands, because we only store longhand values.

In other cases, we can fall back to the computed values that we already
have, and these will be correct. So, we can remove them from here. :^)
2023-09-11 10:42:00 +01:00
Sam Atkins
088cddaca1 LibWeb: Serialize Display values as a "short display" where possible 2023-09-11 10:42:00 +01:00
Sam Atkins
b78b5e6297 LibWeb: Generate property_is_shorthand(PropertyID) function
Sometimes we want to know if a property is a shorthand, but don't care
what its longhands are.
2023-09-11 10:42:00 +01:00
Jelle Raaijmakers
ec416563a8 Maps: Zoom on doubleclick 2023-09-10 22:45:42 +02:00
Jelle Raaijmakers
0f330a4dcf Maps: Scale cached tiles from lower and higher zoom levels
When zooming in or out, if a tile is not yet cached, Maps now also
checks the lower and higher zoom levels for cached tiles and composites
a preview tile that is shown until the actual tile is loaded in.
2023-09-10 22:45:42 +02:00
Jelle Raaijmakers
cf898f08ab Maps: Limit parallel downloading of tiles
Previously we would bombard RequestServer with as many requests as it
would take, but when frantically zooming in and out, we would run out of
fd's causing the Maps application to hang.

This implements a tile download queue and limits the amount of parallel
downloads to 8. This fixes the hangs accompanied by this debug console
message:

    Peer endpoint error: recvfd: Too many open files (errno=24)

It does not fix other sporadic hangs caused by requests that are never
finished, however.
2023-09-10 22:45:42 +02:00
Bastiaan van der Plaat
494a8cb816 AK: Add to_radians and to_degrees math functions 2023-09-10 08:38:29 +01:00
Dan Klishch
9b7aa8f6b6 Meta: Do not spam "<compiler-name>: command not found"
In bd7d01e9, Meta/serenity.sh started checking cc and cxx if CC or CXX
respectively are not set in the environment. My machine does not have
cxx symlink in PATH, so every invocation of the script resulted in
the "cxx: command not found" message outputted to stderr, and that
became quite annoying.
2023-09-09 13:38:06 -06:00
Liav A
b49f2937f0 Kernel/TTY: Don't return NonnullLockRefPtr when creating MasterPTY
We can just return a normal NonnullRefPtr because nobody needs an actual
*LockRefPtrs here anymore.
2023-09-09 12:08:59 -06:00