Commit Graph

12237 Commits

Author SHA1 Message Date
Ben Wiederhake
a99cd09891 Libraries: Add missing includes, add namespace qualifiers
This remained undetected for a long time as HeaderCheck is disabled by
default. This commit makes the following file compile again:

    // file: compile_me.cpp
    #include <LibDNS/Question.h>
    // That's it, this was enough to cause a compilation error.

Likewise for most other files touched by this commit.
2022-09-18 13:27:24 -04:00
Ben Wiederhake
48d8aff436 LibJS: Add missing includes
This remained undetected for a long time as HeaderCheck is disabled by
default. This commit makes the following file compile again:

    // file: compile_me.cpp
    #include <LibJS/Runtime/StringPrototype.h>
    // That's it, this was enough to cause a compilation error.

Likewise for most other files touched by this commit.
2022-09-18 13:27:24 -04:00
Ben Wiederhake
d073a31c21 LibWeb: Add missing includes
This remained undetected for a long time as HeaderCheck is disabled by
default. This commit makes the following file compile again:

    // file: compile_me.cpp
    #include <LibWeb/HTML/CrossOrigin/CrossOriginOpenerPolicy.h>
    // That's it, this was enough to cause a compilation error.

Likewise for most other files touched by this commit.
2022-09-18 13:27:24 -04:00
sin-ack
e9d5d2f74b LibWeb: Remove the flex item size cache
This was overly permissive as the FIXME stated and was causing layout
issues.
2022-09-18 18:55:06 +02:00
Andreas Kling
97b5230413 LibWeb: Subtract border & padding when using flex line size as item size
The flex line cross size includes the margin boxes of items, so when
we're taking the flex line's cross size to use as an item cross size,
we have to subtract the margin, border padding from both sides.

Previous we only subtracted the cross margins, which led to oversized
items in some cases.
2022-09-18 18:34:42 +02:00
Andreas Kling
7bf3b40867 LibWeb: Remove bogus main space restriction in wrapping flex layouts 2022-09-18 18:34:42 +02:00
Timothy Flynn
887dac0929 LibJS: Handle NumberFormat's [[UseGrouping]] option for "true" / "false"
This is a normative change to the Intl NumberFormat V3 spec. See:
https://github.com/tc39/proposal-intl-numberformat-v3/commit/4751da5
2022-09-18 09:45:40 -04:00
Andreas Kling
0ca1b4b123 LibWeb: Don't replace existing Content-Type header in outgoing XHRs
This fixes an issue where Twitter was HTTP 400'ing some of our XHRs.
2022-09-18 12:53:06 +02:00
Andreas Kling
575e3bf37d LibWeb: Check document fully active status in "element cannot navigate"
This resolves a FIXME and brings us closer to spec.
2022-09-18 12:53:06 +02:00
Andreas Kling
e6ef366859 LibWeb: Implement basic support for Document.all
The finer details are missing here, but the basic API is up.
2022-09-18 02:17:29 +02:00
Andreas Kling
3df9861814 LibWeb: Capture self as a WeakPtr in ResourceClient::set_resource()
It's not safe to capture `this` as a raw pointer here, since nothing
is guaranteed to keep the ResourceClient alive (even if the Resource
stays alive.)
2022-09-18 02:15:01 +02:00
Andreas Kling
fa2dd4cbe3 LibWeb: Make Document vend the same HTMLCollections every time 2022-09-18 02:08:01 +02:00
Andreas Kling
1903dff365 LibWeb: Support getting and setting Attr.textContent 2022-09-18 02:08:01 +02:00
Andreas Kling
530675993b LibWeb: Rename Attribute to Attr
This name is not very good, but it's what the specification calls it.
2022-09-18 02:08:01 +02:00
Andreas Kling
3c3ae3a768 LibWeb: Only uppercase qualified names in HTML documents
This takes care of an old FIXME now that we can distinguish between HTML
and non-HTML documents.
2022-09-18 00:53:26 +02:00
Andreas Kling
dc6e625680 LibWeb: Make ParentNode.children vend the same HTMLCollection every time
Instead of creating a new HTMLCollection every time you access
.children, we now follow the spec and vend the same object.

This was annoyingly difficult before, and trivial now that the DOM is
garbage-collected. :^)
2022-09-18 00:42:33 +02:00
Andreas Kling
6b3293a74b LibWeb: Support getElementsByTagName() properly in non-HTML documents 2022-09-18 00:39:42 +02:00
Andreas Kling
bd0648a492 LibWeb: Simplify getElementsByTagName{,NS}() filters
Everything below the collection root is a descendant of the collection
root, so there's no need to check is_descendant_of() :^)
2022-09-18 00:37:24 +02:00
Andreas Kling
e72896e35e LibWeb: Get default fonts via Platform::FontPlugin
Instead of asking Gfx::FontDatabase for the "default font" and the
"default fixed-width font", we now proxy those requests out via
the Platform::FontPlugin. This will allow Ladybird to use other default
fonts as fallback.
2022-09-17 21:27:32 +02:00
Sam Atkins
ebc29842c8 LibWeb: Start implementing the IDL Overload Resolution Algorithm :^)
There are a *lot* of FIXME's here. :yakoverflow:
2022-09-17 21:27:17 +02:00
Sam Atkins
0d2d5ba02c LibIDL: Implement EffectiveOverloadSet
This requires a little explanation. The overload resolution algorithm,
where this is used, repeatedly has steps like this:

> Otherwise: if V is a platform object, and there is an entry in S that
> has one of the following types at position i of its type list,
>  - an interface type that V implements
>  - object
>  - a nullable version of any of the above types
>  - an annotated type whose inner type is one of the above types
>  - a union type, nullable union type, or annotated union type that has
>    one of the above types in its flattened member types
> then remove from S all other entries.

So, the API here tries to match that. We save the matching entry when
checking through them and then use that in `remove_all_other_entries()`.

Removing all those entries when all we actually care about is looking at
that one matching entry feels silly, but sticking to the spec is more
important while things are still half-implemented. :^)
2022-09-17 21:27:17 +02:00
Sam Atkins
8b4cc07a54 LibIDL+WrapperGenerator: Implement Type::is_distinguishable_from()
As part of this, I've moved a couple of methods for checking for
null/undefined from UnionType to Type, and filled in more of their
steps.

This now detects more, and so causes us to hit a `TODO()` which is too
big for me to go after right now, so I've replaced that assertion with
a log message.
2022-09-17 21:27:17 +02:00
Sam Atkins
7c8ef79898 LibIDL+WrapperGenerator: Make it easier to work with IDL::Type classes
Track the kind of Type it is, and use that to provide some convenient
`is_foo()` / `as_foo()` methods. While I was at it, made these all
classes instead of structs and made their data private.
2022-09-17 21:27:17 +02:00
Sam Atkins
c4668053d1 LibIDL+WrapperGenerator: Move IDL code into a library
IDL function overload resolution requires knowing each IDL function's
parameters and their types at runtime. The simplest way to do that is
just to make the types the generator uses available to the runtime.

Parsing has moved to LibIDL, but code generation has not, since that is
very specific to WrapperGenerator.
2022-09-17 21:27:17 +02:00
Jelle Raaijmakers
6c87c98ed0 LibGL: Remove GL::present_context
No need for a static method if all it does is invoke the object method.
2022-09-17 19:38:30 +02:00
Andreas Kling
83c69fa62e LibWeb: Handle JavaScript source code with non-UTF-8 encoding
When fetching scripts in HTMLScriptElement's "prepare a script"
algorithm, we now re-encode the script sources to UTF-8.
2022-09-17 18:53:26 +02:00
Andreas Kling
da451467b1 LibWeb: Implement basic "scroll" events at the document level 2022-09-17 18:53:26 +02:00
Andreas Kling
07c4bf03b5 LibWeb: Add "scripts to execute in order as soon as possible"
Previously, we had accidentally conflated this set with the
similar-but-distinct "scripts to execute as soon as possible".
2022-09-17 18:53:26 +02:00
Andreas Kling
df7e64d103 LibWeb: Handle multiple class names in getElementsByClassName()
The input string is actually a space-separated list of class names,
not a single class name.
2022-09-17 18:53:26 +02:00
Andreas Kling
2371446952 LibWeb: Update layout in HTMLElement.offset{Top,Left}
We can't report layout-dependent metrics without first ensuring that
layout is up-to-date.
2022-09-17 18:53:26 +02:00
Andreas Kling
9e274d9501 LibWeb: Make Document.createElement() lowercase HTML local names
Bring createElement() a little bit closer to spec-compliance.
2022-09-17 18:53:26 +02:00
davidot
03c468fb7d LibJS: Parse date strings like "9/17/2022" 2022-09-17 18:53:14 +02:00
Jelle Raaijmakers
f6dfd77268 LibGL: Prevent segfault due to texture destruction
Destruction of `GL::GLContext` resulted in the destruction of
`GPU::Driver` _before_ the destruction of the allocated textures, which
in turn point to `GPU::Image` objects. Since the destruction of
`GPU::Driver` unloads the shared library, we were trying to invoke
non-existing code.

Fix this by moving `m_driver` up in `GLContext` so that it's last in
line for destruction.
2022-09-17 09:21:52 +00:00
Julian Offenhäuser
77f5f7a6f4 LibPDF: Support parsing page tree nodes that are in object streams
conditionally_parse_page_tree_node used to assume that the xref table
contained a byte offset, even for compressed objects. It now uses the
common facilities for parsing objects, at the expense of some
performance.
2022-09-17 10:07:14 +01:00
Julian Offenhäuser
6225c03256 LibPDF: Rename argument for the latin character set enumeration macro
The previous name "V" collided with one of the entries.
2022-09-17 10:07:14 +01:00
Julian Offenhäuser
633e1632d0 LibPDF: Allow whitespace other than EOL after an object marker 2022-09-17 10:07:14 +01:00
Julian Offenhäuser
65e83bed53 LibPDF: Disallow parsing indirect values as operands
An operation like 0 0 0 RG would have been confused for [ 0, 0 0 R ] G
2022-09-17 10:07:14 +01:00
Julian Offenhäuser
04cb00dc9a LibPDF: Fix handling of differences array in custom encodings
When looking up differences in the specified encoding, we previously
didn't recognize a lot of characters, namely those that are referred to
by a string in the PDF itself, like "/germandbls".

We now create a mapping of those characters to the code points they are
referring to, and correctly look them up when needed.
2022-09-17 10:07:14 +01:00
Julian Offenhäuser
36828f1385 LibPDF: Don't expect glyph width arrays to contain integers
They might also contain floats, in which case we convert them to int
before use.
2022-09-17 10:07:14 +01:00
Julian Offenhäuser
97ed4106e5 LibPDF: Fix text positioning with operator TJ
As per spec, the positioning (or kerning) parameter of this operator
should translate the text matrix before the next showing of text.
Previously, this calculation was slightly wrong and also only applied
after the text was already shown.
2022-09-17 10:07:14 +01:00
Julian Offenhäuser
563d91b6c4 LibPDF: Implement loading compressed objects from object streams
Now, whenever the xref table points to a compressed object,
parse_object_with_index will look it up in the corresponding object
stream as if it were a regular object.

With this, our parser gains the bare minimum support for xref streams.
2022-09-17 10:07:14 +01:00
Julian Offenhäuser
f9beff7b5e LibPDF: Initial work on parsing xref streams
Since PDF version 1.5, a document may omit the xref table in favor of
a new kind of xref stream object. This is used to reference so-called
"compressed" objects that are part of an object stream.

With this patch we are able to parse this new kind of xref object, but
we'll have to implement object streams to use them correctly.
2022-09-17 10:07:14 +01:00
Julian Offenhäuser
4887aacec7 LibPDF: Move document-specific parsing functionality into its own class
The Parser class is now a generic PDF object parser, of which the new
DocumentParser class derives. DocumentParser now takes over all
functions relating to linearization, pages, xref and trailer handling.

This allows the use of multiple parsers in the same document's
context, which will be needed in order to handle PDF object streams.
2022-09-17 10:07:14 +01:00
Julian Offenhäuser
9f4659cc63 LibPDF: Move consume and match helper functions to the Reader class 2022-09-17 10:07:14 +01:00
Ben Wiederhake
8de7a91571 LibCompress+Tests: Demonstrate and fix faulty metadata length
The test-case is heavily inspired by:
https://github.com/google/brotli/blob/master/tests/testdata/x.compressed.01
Or in words: A metadata meta-block containing `Y` (which should be
ignored), and then the actual data (a single `Z`). The bug used to skip
one metadata byte too few, and thus read garbage.
2022-09-17 04:10:11 +00:00
Ben Wiederhake
fe48fed4fa LibWeb: Break inclusion cycle by removing unnecessary include 2022-09-17 04:00:54 +00:00
Ben Wiederhake
e909231d78 LibWeb: Break inclusion cycle through forward-declaration 2022-09-17 04:00:54 +00:00
Ben Wiederhake
4cd382c621 LibJS: Break another inclusion cycle by removing unnecessary include 2022-09-17 04:00:54 +00:00
Ben Wiederhake
6a4e2efa65 LibJS: Break inclusion cycle by removing unnecessary include 2022-09-17 04:00:54 +00:00
Ben Wiederhake
ff96747e17 LibPDF: Break inclusion cycle by removing unnecessary include 2022-09-17 04:00:54 +00:00