Commit graph

10041 commits

Author SHA1 Message Date
Luke Wilde 126d6d0838 LibWeb: Implement Event.composedPath
I originally implemented this as something to use the new sequence
wrapper, however, after having a look at uses with grep.app, it's used
often, for example:
- Bootstrap 5 Dropdowns
- Polymer
- Angular
- Closure
2021-10-17 01:34:02 +03:00
Felix Rauch 183a2ec8bd PixelPaint: Create an empty layer when the last layer is removed
Previously, when the last layer got deleted, the active layer was
set to nullptr, causing a crash.

Now, we create a new transparent background layer with the image
dimensions instead.
2021-10-16 18:10:11 +01:00
Sam Atkins 9f6a09837b LibWeb: Serialize selectors only in CSSStyleRule::selector_text()
Previously, this was returning the serialization for the whole style
rule, which isn't what we want.
2021-10-16 15:16:27 +01:00
Sam Atkins e72286c0ec LibWeb: Use the serialize_a_{identifier,string} algorithms for selectors
Also fixed that serializing an attribute selector never output the
value.
2021-10-16 15:16:27 +01:00
Sam Atkins d775212f19 LibWeb: Insert commas between serialized CSS selectors
For convenience, we create a Formatter for Selector, so we can use
`StringBuilder.join()`.
2021-10-16 15:16:27 +01:00
Sam Atkins e5d3a9d10b LibWeb: Fix pseudo-element selector serialization
We want to check the last SimpleSelector, not the first one. We don't
have to check that a SimpleSelector exists since a CompoundSelector
without one is invalid.
2021-10-16 15:16:27 +01:00
Sam Atkins 3deb58e4bc LibWeb: Fix CSS selector combinator serialization
Two bugs here:
- We were looking at the wrong CompoundSelector's combinator.
- We weren't adding a space after the combinator.
2021-10-16 15:16:27 +01:00
Sam Atkins ec51b40a4f LibWeb: Move CSS selector-serialization code to Selector.{h,cpp}
Also, renamed `builder` to `s` to match spec comments, and fixed a
find-and-replace typo where some pseudo-class names were
"last-of-pseudo_class" instead of "last-of-type".
2021-10-16 15:16:27 +01:00
Sam Atkins 75c9313d7d LibWeb: Implement more CSS serializers and make them more ergonomic
This implements these algorithms from the CSSOM-1 spec:
- serialize a string
- serialize a URL

Also, we now have two versions of each of the serialization functions:
One that returns a String as before, and the other that takes a
StringBuilder to write into. This saves creating extra StringBuilders
when they are not needed. :^)
2021-10-16 15:16:27 +01:00
Sam Atkins 5c1427f3e0 LibWeb: Remove old ANPlusB parsing code
This was left over from the old CSS parser, so we no longer need it. :^)
2021-10-16 15:16:27 +01:00
Luke Wilde 1ea3f34823 LibWeb: Implement Node.getRootNode 2021-10-16 10:51:23 +02:00
Rodrigo Tobar 1f4a6e7c22 SystemMonitor: Use a TableView to display the thread stack
Using a table display this information in a much more organised and
flexible way than than what can be achieved with a TextEditor.
2021-10-15 22:10:03 -07:00
Rodrigo Tobar 6a3b24db0a SystemMonitor: Remove unnecessary header inclusion 2021-10-15 22:10:03 -07:00
Rodrigo Tobar 9199f0836a LibSymbolication: Make Symbol comparable
All its members are comparable themselves, so this can be defaulted.
Making it comparable will allow us, among other things, to check if a
list of symbols (i.e., the result of calling the symbolicate functions)
is equal or not to another, which in turn will allow us to avoid
refreshing the SystemMonitor's Stack tab when successive symbolicated
stacks are the same.
2021-10-15 22:10:03 -07:00
Tim Schumacher 420bdccf0b LibC: Implement mbsrtowcs 2021-10-15 21:50:19 -07:00
Tim Schumacher b0babd062e LibC: Implement wcsrtombs 2021-10-15 21:50:19 -07:00
Daniel Bertalan c8367df746 LibC: Implement wcrtomb
This function converts a single wide character into its multibyte
representation (UTF-8 in our case). It is called from libc++'s
`std::basic_ostream<wchar_t>::flush`, which gets called at program exit
from a global destructor in order to flush `std::wcout`.
2021-10-15 21:50:19 -07:00
Tim Schumacher 9c29e6cde7 LibC: Partially implement wcwidth 2021-10-15 21:50:19 -07:00
Tim Schumacher a66c358c52 LibC: Stub out tdelete 2021-10-15 21:50:19 -07:00
Tim Schumacher 4b423a5ec7 LibC: Implement twalk 2021-10-15 21:50:19 -07:00
Tim Schumacher 7448626bae LibC: Implement tfind and tsearch 2021-10-15 21:50:19 -07:00
Tim Schumacher 20fc93410c LibC: Mark termcap symbols as weak
Otherwise, we may end up preferring those over the more accurate
implementation in ncurses (if available).
2021-10-15 14:47:41 -07:00
Sam Atkins 8b57e56d66 LibWeb: Parse "none" value for box-shadow property
Previously, `box-shadow: none` would fail to parse, meaning that in this
example:

```css
p {
  box-shadow: 20px 10px 5px magenta;
}

p.foo {
  box-shadow: none;
}
```

... a `<p class="foo">` would still have a box-shadow, when it should
not have one. Now, we handle the `none` value. :^)
2021-10-15 21:18:50 +01:00
Sam Atkins 7879b98f60 LibWeb: Use W3C urls for CSS-DISPLAY spec links 2021-10-15 21:05:35 +01:00
Sam Atkins d28eeeb207 LibWeb: Use W3C urls for CSS-VALUES-3 spec links 2021-10-15 21:05:35 +01:00
Sam Atkins 2d0c6bde01 LibWeb: Use W3C urls for CSS-CASCADE spec links 2021-10-15 21:05:35 +01:00
Sam Atkins e8d4236bbd LibWeb: Use W3C urls for CSSOM spec links
https://www.w3.org/TR/cssom/ is the more permanent home of the CSSOM
specification's latest version, and is up to date with the draft spec.

Also, https://drafts.csswg.org/ has been down multiple times recently
which made looking things up a pain.
2021-10-15 21:05:35 +01:00
Sam Atkins df85832f32 LibWeb: Implement CSSStyleRule::set_selector_text() 2021-10-15 18:12:20 +01:00
Sam Atkins 0f88a47e58 LibWeb: Add serialization code for CSS{Media,Supports}Rule
The `CSSMediaRule::serialized()` code is to spec. The
`CSSSupportsRule::serialized()` code has no spec right now, but I'm
fairly confident it will be almost identical to media's, so I copied
that for now.
2021-10-15 18:12:20 +01:00
Sam Atkins 46bba44f8b LibWeb: Move media-query-list serialization code to MediaQuery.{h,cpp}
It's not a complicated algorithm, but having it in one place instead of
2, and with spec comments, is nice. :^)
2021-10-15 18:12:20 +01:00
Sam Atkins caac0706c2 LibWeb: Accept a Block token as the body of a CSS At-Rule
I previously fixed this for `consume_a_qualified_rule()` and didn't
notice the same comment in `consume_an_at_rule()` until now.
2021-10-15 18:10:23 +01:00
davidot 7beccaf41b LibJS: Add comment clarifying the order of function properties 2021-10-15 17:47:27 +01:00
davidot 021691753d LibJS: Fix that proxy always said that it had a [[Construct]] slot 2021-10-15 10:27:16 +01:00
davidot 1c7c53e5a0 LibJS: Define length and name in function in correct order 2021-10-15 10:27:16 +01:00
davidot 9394cbcd24 LibJS: Do not save state for peeking at the next token from the lexer
This saves having to save and load the parser state.
This could give an incorrect token in some cases where the parser
communicates to the lexer. However this is not applicable in any of the
current usages and this would require one to parse the current token
as normal which is exactly what you don't want to do in that scenario.
2021-10-15 10:27:16 +01:00
davidot c3cb44ca8a LibJS: Remove ErrorType::FixmeAddAnErrorStringWithMessage 2021-10-15 10:27:16 +01:00
davidot 1fe6a422f1 LibJS: Fix null deref in ObjectProperty::dump() 2021-10-15 10:27:16 +01:00
davidot 10bf91a293 LibJS: Enable now working tests for duplicated variable declarations 2021-10-15 10:27:16 +01:00
Ben Wiederhake a8930997f0 LibGUI: Make Ctrl-Right at the end of a span work
There used to be the silly bug that when the cursor was already at the
end of a span (e.g. because the user just pressed Ctrl-Right), then
Ctrl-Right had no effect.

This bug does not appear with Ctrl-Left because due to the order in
which the spans are iterated, the effective result is always correct.

This patch also makes it more apparent that the algorithm is
unnecessarily inefficient.
2021-10-15 10:38:57 +02:00
Ben Wiederhake 3647001c93 LibGUI: Don't update selection twice after Ctrl-Right 2021-10-15 10:38:57 +02:00
Ben Wiederhake 68884eefc6 LibGUI: Make Ctrl-Shift-Home/-End work again
Previously, the initial call to update_selection() was missing, so if no
text was already selected, then Ctrl-Shift-End would only move the
cursor to the document end, but not select any text.
2021-10-15 10:38:57 +02:00
Ben Wiederhake 2f023acf78 LibGUI: Convert always-valid pointer to reference
The pointer is always assumed to be non-null, so let's change it to a
reference.
2021-10-15 10:38:57 +02:00
Linus Groh 5910a41adb LibJS: Implement ShadowRealm.prototype.importValue()
Well... sort of. This adds the function itself and all the scaffolding
from the ShadowRealm API (and basically completes its implementation).
However, we do not nearly have enough support for modules and imports,
so we currently pretend whatever was attempted to be imported failed -
once we have HostImportModuleDynamically it should be relatively easy to
complete the implementation.
2021-10-15 09:36:21 +01:00
Linus Groh 2ffb30a996 LibJS: Don't return empty value from PromiseReactionJob::call(), for now 2021-10-15 09:36:21 +01:00
Linus Groh fb85fd4867 LibJS/Tests: Test ShadowRealm.prototype.evaluate() this value type check 2021-10-15 09:36:21 +01:00
Luke Wilde 09536f5f48 LibJS: Fix typo in LHS Object and RHS BigInt loosely equals check
Step 12 was using `lhs.is_bigint()` instead of `rhs.is_bigint()`,
meaning you got:
```js
1n == Object(1n); // true
Object(1n) == 1n; // false
```

This also adds spec comments to is_loosely_equal.
2021-10-15 01:59:09 +01:00
Andreas Kling 07096b7765 LibWeb: Compute horizontal overflow for the initial containing block
This finally allows LibWeb to scroll pages horizontally instead of just
clipping things at the right edge.
2021-10-15 00:11:21 +02:00
Linus Groh 0241071ca2 LibJS: Use GlobalObject::associated_realm() for function object realms
As outlined in the previous commit, this should be more reliable than
Interpreter::realm(), as we don't always have access to an Interpreter.
2021-10-14 23:02:19 +01:00
Linus Groh cbbf4abb0d LibJS: Add a way to get from a GlobalObject to its associated Realm
This is just another workaround, but it should be much more reliable
than Interpreter::realm(), especially when allocating NativeFunctions
and ECMAScriptFunctionObjects: we're guaranteed to have a GlobalObject
at that point, and it likely was set as the GlobalObject of a Realm and
can lead us back to it. We're however not guaranteed that the VM can
give us an Interpreter, which is why functions in LibWeb can be a bit
crashy at the moment.

We use a WeakPtr<Realm> to properly handle the unlikely case where the
Realm goes away after associating a GlobalObject to it.

We'll always need _something_ of this sort if we want to support
OrdinaryFunctionCreate and CreateBuiltinFunction without the explicit
realm argument while no JS is running, because they want to use the
current Realm Record (always in the first and as fallback in the second
case).
2021-10-14 23:02:19 +01:00
Andreas Kling 2447b27d97 LibWeb: Implement position:fixed painting at the stacking context level
This makes everything within the stacking context stick show up in the
correct position.
2021-10-14 23:50:33 +02:00