Commit graph

1382 commits

Author SHA1 Message Date
Andrew Kaster 247f12d7b0 LibWeb: Insert WindowProperties object into Window's prototype chain
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.
2023-09-22 19:55:59 -06:00
Shannon Booth e123492470 LibWeb: Allow ArrayBuffer attributes to be used in IDL
The FileReader IDL has the following entry:
```
readonly attribute (DOMString or ArrayBuffer)? result;
```

This change supports the use ArrayBuffer as a JS built-in in this
definition.
2023-09-17 16:37:31 -06:00
Dan Klishch 67e07fa4e2 JSSpecCompiler: Introduce ControlFlowOperator nodes 2023-09-17 16:04:42 -06:00
Dan Klishch 81519975c5 JSSpecCompiler: Add reference resolving pass
It replaces UnresolvedReference with Variable, FunctionPointer, or
SlotName nodes. Also, it gathers all variable names from their
declarations.
2023-09-17 16:04:42 -06:00
Dan Klishch 326bac19d9 JSSpecCompiler: Make nodes inherit from Statement or Expression
The distinction between them will become important during CFG building.
2023-09-17 16:04:42 -06:00
Dan Klishch ed5ef4da6d JSSpecCompiler: Make clang-tidy happier, no functional changes 2023-09-17 16:04:42 -06:00
nipos 2e0960a7ef Meta: Don't link LibCrypt to native libcrypt on Haiku 2023-09-17 13:38:12 -06:00
nipos 2691c079d4 Meta+Ladybird: Link to libnetwork on Haiku 2023-09-17 13:38:12 -06:00
nipos e345085329 Meta+Ladybird: Add some extra definitions for Haiku 2023-09-17 13:38:12 -06:00
implicitfield 1b3ad1c721 LibCrypto: Add support for BLAKE2b 2023-09-17 16:49:35 +03:30
Aliaksandr Kalenik da2c18d1f9 Meta: Update LibJSGCVerifier to build with llvm 16.0.6
Changes to fix LibJSGCVerifier build with llvm version used in
BuildClang.sh
2023-09-16 20:51:28 -06:00
Timothy Flynn 139c575cc9 LibUnicode: Update to Unicode version 15.1.0
https://unicode.org/versions/Unicode15.1.0/

This update includes a new set of code point properties, Indic Conjunct
Break. These may have the values Consonant, Linker, or Extend. These are
used in text segmentation to prevent breaking on some extended grapheme
cluster sequences.
2023-09-15 18:30:26 +02: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 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
Dan Klishch 4c4e1e1aed JSSpecCompiler: Add if branch merging pass
It merges standalone IfBranch/ElseIfBranch nodes into IfElseIfChain
nodes. This will ease CFG generation later.
2023-09-09 11:20:43 -06:00
Dan Klishch 092ed1cc8a JSSpecCompiler: Allow storing NullableTrees in nodes
And use this in ElseIfBranch node.
2023-09-09 11:20:43 -06:00
Dan Klishch 4eede5282c JSSpecCompiler: Allow storing error text in ErrorNode
This will be the main way to communicate errors from compilation passes.
2023-09-09 11:20:43 -06:00
Dan Klishch 72794e7843 JSSpecCompiler: Add function call canonicalization pass
It simplifies ladders of BinaryOperators nodes in the function call
arguments into nice and neat FunctionCall node. Ladders initially appear
since I do not want to complicate expression parser, so it interprets
`f(a, b, c, d)` as `f "function_call_operator" (a, (b, (c, d))))`.
2023-09-09 11:20:43 -06:00
Dan Klishch 1c4cd34320 JSSpecCompiler: Restrict usage of NodeSubtreePointer
This class stores a non-owning raw pointer to a member of `Node`, so
extra care is needed to ensure that referenced `Node`s will be alive
by the time `NodeSubtreePointer` is used. Since we only need to use this
class while traversing AST in `RecursiveASTVisitor`, access to class
methods can be restricted using `Badge<RecursiveASTVisitor>`.
2023-09-09 11:20:43 -06:00
Shannon Booth 41928c2902 LibWeb: Port DOMException interface from DeprecatedString to String 2023-09-06 11:44:45 -04:00
Shannon Booth 914fb90bbe LibWeb: Don't generate Optional<String> from IDL for non-null arguments
Previously if the IDL was something like:
```
constructor(optional DOMString data = "");
```

We were generating code that would be passing through to the constructor
an Optional<String> - even though for this situation it is not possible
for it to be null.

Instead, if we know if there is a default value that is non-null and the
type is not nullish, just generate the cpp code as a String.
2023-09-05 20:36:09 -04:00
Shannon Booth f991e40d7f LibWeb: Support [Reflect] on IDL String attributes that may return null
This change allows IDL interfaces to be compiled using new AK String
which have a attribute in the interface that may return null.

Without this change we would run into a compile error from code such as
the following example:

```
auto retval = impl->deprecated_attribute(HTML::AttributeNames::ref);

if (!retval.has_value()) {
    return JS::js_null();
 }
 return JS::PrimitiveString::create(vm, retval.release_value());
```

As `deprecated_attribute` returns a `DeprecatedString` instead of an
`Optional<String>`. Fix that by using the non-deprecated attribute
implementation, and falling back to the empty string for where we cannot
return null.

Also add a test here to cover a regression I almost introduced here
which was not previously covered by our test suite.

Ideally, all of this should actually just be calling
Element::get_attribute_value, but I'm not entirely sure at this stage
what the behavioral change would be to test for here. Since this
implementation preserves the previous behavior, stick with it, and add a
FIXME for now.
2023-09-05 20:36:09 -04:00
Shannon Booth 0f6782fae6 LibWeb: Rename Element::attribute to Element::deprecated_attribute
This should allow us to add a Element::attribute which returns an
Optional<String>. Eventually all callers should be ported to switch from
the DeprecatedString version, but in the meantime, this should allow us
to port some more IDL interfaces away from DeprecatedString.
2023-09-05 20:36:09 -04:00
Daniel Bertalan dac443fbff Meta: Link Lagom with LLD by default and allow configuring the linker
This ports over the `LADYBIRD_USE_LLD` option from the standalone
Ladybird build and generalizes it to work for mold as well: the
`LAGOM_USE_LINKER` variable can be set to the desired name of the
linker. If it's empty, we default to trying LLD and Mold on ELF
platforms (in this order).
2023-09-05 14:50:36 +02:00
Sam Atkins e9b58ff096 LibWeb: Move check for CSS-wide keywords to ValueID.h
This feels like a better home for it. The new name better reflects the
spec phrasing.
2023-09-05 14:27:23 +02:00
Timothy Flynn bb4eca2037 LibLocale: Remove compact currency patterns
These are no longer used by the Intl.NumberFormat implementation.
2023-09-04 18:22:28 +02:00
Shannon Booth d4a890080d LibWeb: Switch IDL from UseNewAKString to UseDeprecatedAKString
NewAKString is effectively the default for any new IDL interface, so
let's mark this as the default behavior. It also makes it much easier to
figure out whatever interfaces are still left to port over to new AK
String.
2023-09-02 19:23:41 +01:00
Dan Klishch 198591cc20 JSSpecCompiler: Add infrastructure to run compiler passes on AST 2023-09-02 19:57:06 +02:00
Dan Klishch cd8f4aaa7d JSSpecCompiler: Introduce Function and ExecutionContext classes
Currently, they are not extremely useful, but the plan is to store
all function-local state in JSSpecCompiler::Function and all
"translation unit" state in ExecutionContext.
2023-09-02 19:57:06 +02:00
Andrew Kaster 4641af7873 AK: Always use our assertion failure method, and add backtrace to it
On platforms that support it, enable using ``<execinfo.h>`` to get
backtrace(3) to dump a backtrace on assertion failure. This should make
debugging things like WebContent crashes in Lagom much easier.
2023-09-01 11:50:47 +02:00
Timothy Flynn f7adc3320d Meta: Replace Lagom's LibWebView setup with LibWebView's CMakeLists.txt
This lets us add new sources to LibWebView in a single location.
2023-08-31 06:33:04 -04:00
Dan Klishch 66f4cdba85 JSSpecCompiler: Make it compile and dump AST created from stdin input 2023-08-31 11:00:31 +02:00
Dan Klishch db0a03d1fb JSSpecCompiler: Add infrastructure to parse <emu-clause> into AST 2023-08-31 11:00:31 +02:00
Dan Klishch f70e39d501 JSSpecCompiler: Add TextParser for converting algorithm steps into AST 2023-08-31 11:00:31 +02:00
Dan Klishch 9f29e04897 JSSpecCompiler: Add functions for splitting node contents into tokens 2023-08-31 11:00:31 +02:00
Dan Klishch 8342361481 JSSpecCompiler: Add Token type 2023-08-31 11:00:31 +02:00
Dan Klishch 5846470a5f JSSpecCompiler: Add stubs for AST types 2023-08-31 11:00:31 +02:00
Timothy Flynn bf59e06d2a Ladybird+LibWebView: Extract common JS console functionality to a helper
This creates WebView::ConsoleClient to handle functionality that will be
common to the JS consoles of all Ladybird chromes. This will let each
chrome focus on just the UI.

Note that this includes the `console.group` functionality that only the
Serenity chrome previously had. This was a FIXME in the Qt chrome, and
it is implemented such that all chromes will receive this functionality
for free.
2023-08-30 09:24:59 +02:00
Timothy Flynn 1e1c3e5a34 LibWebView: Create a method to syntax-highlight page source with HTML
This tokenizes a page's source to produce HTML with syntax highlighting.
The first implementation here is rather simple; we do not yet implement
code folding, line numbers, etc.

The goal is for this to be used as the View Source implementation for
all Ladybird chromes.
2023-08-29 08:11:11 -04:00
Timothy Flynn 3f122b7335 LibWebView: Allow using native/user style sheets on Lagom
Move the methods to set the native/user style sheets to the base
ViewImplementation class. We must also generate the native style sheet
explicitly for now, as LibWebView on Lagom isn't able to include the
main LibWebView CMakeLists.txt file yet.
2023-08-26 15:32:36 -04:00
Andrew Kaster d1aea87889 LibWeb: Add NavigateEvent, the main event of the Navigation API
This event is the star of the show, and the main way that web content
can react to either programmatic or user-initiated navigation.

All of the fun algorithms will have to come later though.
2023-08-24 11:03:57 -06:00
Andrew Kaster 51c2835044 LibWeb: Add NavigationCurrentEntryChangeEvent, fired when navigating
This event will be fired by Navigation when changing the current
NavigationHistoryEntry.
2023-08-24 11:03:57 -06:00
Andrew Kaster cf0ffc12cc BindingsGenerator: Handle nullable enum properties
Add some checks to the statement wrapping code to make sure we properly
handle the expected pattern of returning ``Optional<Enum>`` from
nullable enum properties.
2023-08-24 11:03:57 -06:00
Bastiaan van der Plaat 43825acc79 Meta+BindingsGenerator: Add postfix to member_value_name to make unique 2023-08-23 12:11:21 +01:00
Tim Schumacher dbc25f18ec LibCompress: Let BrotliDecompressionStream take a MaybeOwned 2023-08-23 12:03:37 +01:00
Tim Schumacher 8a853278d0 LibCompress: Port ZlibDecompressor to AK::Stream 2023-08-23 12:03:37 +01:00
Timothy Flynn eb8f7b303c LibLocale+LibJS: Make relative time format APIs infallible
These APIs only perform small allocations, and are only used by LibJS.
Callers which could only have failed from these APIs are also made to
be infallible here.
2023-08-23 05:29:21 +02:00
Timothy Flynn 7536648498 LibLocale+LibJS+ClockSettings: Make date time format APIs infallible
These APIs only perform small allocations, and are only used by LibJS
and the time zone settings widget. Callers which could only have failed
from these APIs are also made to be infallible here.
2023-08-23 05:29:21 +02:00
Timothy Flynn 0914e86691 LibLocale+LibJS: Make number format APIs infallible
These APIs only perform small allocations, and are only used by LibJS.
Callers which could only have failed from these APIs are also made to
be infallible here.
2023-08-23 05:29:21 +02:00
Timothy Flynn cd526813e6 LibLocale+LibJS: Make locale data APIs infallible
These APIs only perform small allocations, and are only used by LibJS.
Callers which could only have failed from these APIs are also made to
be infallible here.
2023-08-23 05:29:21 +02:00