Age | Commit message (Collapse) | Author |
|
This changes Web::Bindings::throw_dom_exception_if_needed() to return a
JS::ThrowCompletionOr instead of an Optional. This allows callers to
wrap the invocation with a TRY() macro instead of making a follow-up
call to should_return_empty(). Further, this removes all invocations to
vm.exception() in the generated bindings.
|
|
|
|
|
|
This method will eventually be removed once all native functions are
converted to ThrowCompletionOr
|
|
The old versions were renamed to JS_DECLARE_OLD_NATIVE_FUNCTION and
JS_DEFINE_OLD_NATIVE_FUNCTION, and will be eventually removed once all
native functions were converted to the new format.
|
|
These macros are equivalent to JS_{DECLARE, DEFINE}_NATIVE_FUNCTION and
were only sometimes used, so let's just get rid of them altogether.
|
|
|
|
|
|
|
|
Also update get_function_name() to use ThrowCompletionOr, but this is
not a standard AO and should be refactored out of existence eventually.
|
|
Web IDL is now a WHATWG standard and the specification was moved
accordingly: https://twitter.com/annevk/status/1445311275026821120
The old URLs now redirect, but let's use canonical ones.
|
|
This patch establishes scaffolding for the Selection API.
|
|
This is the `CSS` namespace defined in IDL here:
https://www.w3.org/TR/cssom-1/#namespacedef-css , not to be confused
with our `Web::CSS` namespace. Words are hard.
`CSS.escape()` lets you escape identifiers that can then be used to
create a CSS string.
I've also stubbed out the `CSS.supports()` function.
|
|
This was incorrectly calling DOM::Window::clear_timeout(). In practice,
these functions are interchangeable, but let's have things looking
correct regardless.
|
|
Instead of passing a function it is also possible to pass a string,
which is then evaluated as a classic script.
|
|
Instead of passing a function it is also possible to pass a string,
which is then evaluated as a classic script.
This means we now support the following example from the "timer
initialization steps", step 16 - except that it runs the timers in
reverse order, so the `log` result is `"TWO ONE "`.
https://html.spec.whatwg.org/multipage/timers-and-user-prompts.html#timer-initialisation-steps
var log = '';
function logger(s) { log += s + ' '; }
setTimeout({ toString: function () {
setTimeout("logger('ONE')", 100);
return "logger('TWO')";
} }, 100);
|
|
|
|
To no one's surprise, this patch is pretty big - this is possibly the
most used AO of all of them. Definitely worth it though.
|
|
|
|
Since we don't support IDL typedefs or unions yet, the responsibility
of verifying the type of the argument is temporarily moved from the
generated Wrapper to the implementation.
|
|
|
|
Some sites query these properties for whatever reason, so let's support
them. (But let's always pretend the screen coordinates are (0, 0))
|
|
This always returns 1 for now. I've added a FIXME about returning 2 in
HiDPI mode.
|
|
While I was implementing IDL special operations, I noticed that for
global platform objects (e.g. WindowObject), the IDL spec makes their
prototype immutable.
https://heycam.github.io/webidl/#platform-object-setprototypeof
|
|
This API allows authors to schedule a serialized JS callback that will
get invoked at the next spec-allowed opportunity.
|
|
The less we do in WindowObject, the easier it will be to eventually
auto-generate the entire thing.
|
|
|
|
We now expose all the `onfoo` event handler attributes on the window
object. This makes `window.onload = ...` actually work. :^)
|
|
|
|
Both Window.location and Document.location use the same instance of the
Location object. Some sites use it via Window, some via Document.
|
|
This is the result of debugging React DOM, which would throw a TypeError
when assigning to window.event in strict mode and then not complete
rendering - here:
https://github.com/facebook/react/blob/cae6350/packages/shared/invokeGuardedCallbackImpl.js#L134
With this change, the following minimal React example now works!
<div id="app"></div>
<script src="react.development.js"></script>
<script src="react-dom.development.js"></script>
<script>
ReactDOM.render(
React.createElement("h1", null, "Hello World"),
document.getElementById("app")
);
</script>
|
|
The spec allows us to optionally return from these for any reason.
Our reason is that we don't have all the infrastructure in place yet to
implement them.
|
|
|
|
... and `Window.scrollTo()`, which is an alias for `scroll()`.
There is still work that needs to be done here, regarding bringing the
scroll position calculation in line with the spec. Currently we get the
viewport rect from outside, and treat it as if it was the result of
calculating steps 5-9 of the `scroll()` method. But it works. :^)
|
|
...and pageXOffset/pageYOffset too, since those are just aliases for the
same thing.
|
|
This just returns an empty CSSStyleDeclaration for now. The real thing
needs to be a live object that provides a view onto the computed style
of a given element. This is far from that, but it's something. :^)
|
|
Match the spec nomenclature.
|
|
This better matches the spec nomenclature. Note that we don't yet
*retrieve* the active document according to spec.
|
|
We treat all NativeFunctions as strict mode and thus window function
which were called in a global context (i.e. `setTimeout(f, 0)`) got a
null this_value. But we really need to treat all functions not defined
by the ECMAScript specification as non-strict. In most cases this won't
matter however since Window is also the global_object we have an extra
bit of logic.
To fix this more correctly we would need to track the strictness of
NativeFunctions.
|
|
These are usually incorrect, and people sometimes forget to add the
correct values as a result of them being optional, so they should just
be specified explicitly.
|
|
This removes all usages of the non-standard define_property helper
method and replaces all it's usages with the specification required
alternative or with define_direct_property where appropriate.
|
|
This is required by the WebIDL specification.
|
|
This is a huge patch, I know. In hindsight this perhaps could've been
done slightly more incremental, but I started and then fixed everything
until it worked, and here we are. I tried splitting of some completely
unrelated changes into separate commits, however. Anyway.
This is a rewrite of most of Object, and by extension large parts of
Array, Proxy, Reflect, String, TypedArray, and some other things.
What we already had worked fine for about 90% of things, but getting the
last 10% right proved to be increasingly difficult with the current code
that sort of grew organically and is only very loosely based on the
spec - this became especially obvious when we started fixing a large
number of test262 failures.
Key changes include:
- 1:1 matching function names and parameters of all object-related
functions, to avoid ambiguity. Previously we had things like put(),
which the spec doesn't have - as a result it wasn't always clear which
need to be used.
- Better separation between object abstract operations and internal
methods - the former are always the same, the latter can be overridden
(and are therefore virtual). The internal methods (i.e. [[Foo]] in the
spec) are now prefixed with 'internal_' for clarity - again, it was
previously not always clear which AO a certain method represents,
get() could've been both Get and [[Get]] (I don't know which one it
was closer to right now).
Note that some of the old names have been kept until all code relying
on them is updated, but they are now simple wrappers around the
closest matching standard abstract operation.
- Simplifications of the storage layer: functions that write values to
storage are now prefixed with 'storage_' to make their purpose clear,
and as they are not part of the spec they should not contain any steps
specified by it. Much functionality is now covered by the layers above
it and was removed (e.g. handling of accessors, attribute checks).
- PropertyAttributes has been greatly simplified, and is being replaced
by PropertyDescriptor - a concept similar to the current
implementation, but more aligned with the actual spec. See the commit
message of the previous commit where it was introduced for details.
- As a bonus, and since I had to look at the spec a whole lot anyway, I
introduced more inline comments with the exact steps from the spec -
this makes it super easy to verify correctness.
- East-const all the things.
As a result of all of this, things are much more correct but a bit
slower now. Retaining speed wasn't a consideration at all, I have done
no profiling of the new code - there might be low hanging fruits, which
we can then harvest separately.
Special thanks to Idan for helping me with this by tracking down bugs,
updating everything outside of LibJS to work with these changes (LibWeb,
Spreadsheet, HackStudio), as well as providing countless patches to fix
regressions I introduced - there still are very few (we got it down to
5), but we also get many new passing test262 tests in return. :^)
Co-authored-by: Idan Horowitz <idan.horowitz@gmail.com>
|
|
|
|
|
|
We were asserting that it exists, but the spec says to return null in
this case.
Top: https://html.spec.whatwg.org/multipage/browsers.html#dom-top
Parent: https://html.spec.whatwg.org/multipage/browsers.html#dom-parent
|
|
Our "frame" concept very closely matches what the web specs call a
"browsing context", so let's rename it to that. :^)
The "main frame" becomes the "top-level browsing context",
and "sub-frames" are now "nested browsing contexts".
|
|
This impl is *extremely* simple, and is missing a lot of things, it's
also not particularly spec-compliant in some places, but it's definitely
a start :^)
|
|
SPDX License Identifiers are a more compact / standardized
way of representing file license information.
See: https://spdx.dev/resources/use/#identifiers
This was done with the `ambr` search and replace tool.
ambr --no-parent-ignore --key-from-file --rep-from-file key.txt rep.txt *
|
|
This returns the parent frame of the current frame. If it's the
main frame, it returns itself.
Also fixes the attributes of Window.top, as they were accidentally
being passed in as the setter.
Required by Web Platform Tests.
|