Commit Graph

5227 Commits

Author SHA1 Message Date
thankyouverycool
9a5a9fbee0 LibGUI+TextEditor: Allow cursor line highlighting to be toggled 2021-09-11 19:22:14 +02:00
David Isaksson
242acfcbae LibGfx: Apply translation and scale to Painter::draw_triangle() 2021-09-11 19:16:29 +02:00
Mustafa Quraish
253eb5c6d7 ColorPicker: Add ability to select a color on the screen
This commit adds a `ColorSelectOverlay` class, and uses it to
allow the user to pick a color from the screen. The API for
`ColorSelectOverlay` is inspired from the `SelectableOverlay`
in `Utilities/shot.cpp`. In particular, it opens up it's own
window, so that we can have control over the cursor over the
whole screen.

There's one thing notably different: In addition to returning the
final selected color from the `exec()` function, it also provides
an `on_color_changed()` hook, which can be used to (optionally)
get live updated as the mouse is moving around.

This is a bit odd, but allows us to use the preview widget of the
color picker to see the current color under the mouse (which will
be selected upon clicking). When trying to select the color from
text / other small elements, this is very useful.
2021-09-11 19:05:46 +02:00
Liav A
04ba31b8c5 Kernel+Userland: Remove loadable kernel moduless
These interfaces are broken for about 9 months, maybe longer than that.
At this point, this is just a dead code nobody tests or tries to use, so
let's remove it instead of keeping a stale code just for the sake of
keeping it and hoping someone will fix it.

To better justify this, I read that OpenBSD removed loadable kernel
modules in 5.7 release (2014), mainly for the same reason we do -
nobody used it so they had no good reason to maintain it.
Still, OpenBSD had LKMs being effectively working, which is not the
current state in our project for a long time.
An arguably better approach to minimize the Kernel image size is to
allow dropping drivers and features while compiling a new image.
2021-09-11 19:05:00 +02:00
Idan Horowitz
b92871f7ef LibJS: Visit WeakMap's values as long as their keys were not collected
While the WeakMap only holds a weak reference to its keys, their
accompanying values should be kept alive as long as they're accessible.
2021-09-11 18:27:56 +02:00
Idan Horowitz
073a1dec16 LibJS: Visit OrdinaryFunctionObject's owning realm 2021-09-11 18:27:56 +02:00
Idan Horowitz
59982ef582 LibJS: Visit GeneratorObject's previous value if it's any kind of Cell
Not just if it's an Object (which is one kind of Cell).
2021-09-11 18:27:56 +02:00
Andreas Kling
b9eb8d00ca LibJS: Revoke any outstanding WeakPtr<Shape> when zombifying shapes
The forward transition cache in Shape uses WeakPtr<Shape> to learn when
a cached transition has been garbage collected.

When running in zombification mode, we have to explicitly revoke any
outstanding WeakPtrs to a Shape when it becomes a zombie. That ensures
that it gets pruned from transition caches.
2021-09-11 17:01:45 +02:00
Andreas Kling
cd7dbe3e97 LibJS: Include source locations in VM::dump_backtrace() output 2021-09-11 17:01:19 +02:00
Andreas Kling
ca940d7240 LibJS: Fix ASAN poisoning range in new HeapBlocks
When poisoning HeapBlock::m_storage, we have to compute the storage size
by excluding the HeapBlock header.
2021-09-11 17:00:07 +02:00
Andreas Kling
c364520c24 LibJS+js+test-js: Add GC debug mode that keeps cells "alive" as zombies
This patch adds a `-z` option to js and test-js. When run in this mode,
garbage cells are never actually destroyed. We instead keep them around
in a special zombie state.

This allows us to validate that zombies don't get marked in future GC
scans (since there were not supposed to be any more references!) :^)

Cells get notified when they become a zombie (via did_become_zombie())
and this is used by WeakContainer cells to deregister themselves from
the heap.
2021-09-11 16:52:03 +02:00
Sam Atkins
57371f7608 LibWeb: Implement Window.scroll() and Window.scrollBy() JS methods
... 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. :^)
2021-09-11 15:51:05 +01:00
Sam Atkins
9588a377ec LibWeb: Implement Window.scroll{X,Y} JS properties
...and pageXOffset/pageYOffset too, since those are just aliases for the
same thing.
2021-09-11 15:51:05 +01:00
Sam Atkins
83414af9f3 LibWeb+WebContent: Add WebContentClient::did_request_scroll_to() call
This call sets the absolute scroll position for the window.
2021-09-11 15:51:05 +01:00
Sam Atkins
a09219159c LibWeb+WebContent: Modify did_request_scroll() IPC to take x&y deltas
This is in preparation for implementing JS scrolling functions, which
specify both x and y scrolling deltas. The visible behavior has not
changed.

Also, moved the "mouse wheel delta * 20" calculation to the
`EventHandler` since the JS calls will want to work directly in pixels.
2021-09-11 15:51:05 +01:00
Ben Wiederhake
2e4ec891da Everywhere: Fix format-vulnerabilities
Command used:
grep -Pirn '(out|warn)ln\((?!["\)]|format,|stderr,|stdout,|output, ")' \
     AK Kernel/ Tests/ Userland/
(Plus some manual reviewing.)

Let's pick ArgsParser as an example:
    outln(file, m_general_help);
This will fail at runtime if the general help happens to contain braces.

Even if this transformation turns out to be unnecessary in a place or
two, this way the code is "more obviously" correct.
2021-09-11 15:16:26 +01:00
Andreas Kling
89f0e501a0 LibJS: Mark the global object in Environment::visit_edges() 2021-09-11 14:10:11 +02:00
Andreas Kling
d42d655853 LibJS+LibWeb+Spreadsheet: Upcall visit_edges() via Base typedef
Let's use Base::visit_edges() when calling the base class, to prevent
accidentally skipping over anyone in the inheritance chain.
2021-09-11 14:10:11 +02:00
Andreas Kling
19ee5e01ad LibJS: Use Span<Cell*> instead of Vector<Cell*> in more places 2021-09-11 14:10:11 +02:00
Andreas Kling
466649c1e8 LibJS: Mark instance field names in FunctionObject::visit_edges() 2021-09-11 14:10:11 +02:00
Andreas Kling
5c905acf1d LibWeb: Add naive support for the Document.referrer attribute
It always returns the empty string for now.
2021-09-11 14:10:11 +02:00
Ben Wiederhake
6c8eea6f5e LibWasm: Avoid making StringView of temporary ByteBuffer 2021-09-11 13:22:51 +03:00
Andreas Kling
470c99a2a6 LibJS: Tweak the WeakContainer::remove_swept_cells() API a little bit
Make this API take a Span<Cell*> instead of a Vector<Cell*>&.
This is behavior neutral, but stops the API looking like it wants to
do mutable things to the Vector.
2021-09-11 12:09:55 +02:00
Timothy Flynn
9b5696fee7 LibJS: Implement Intl.NumberFormat.prototype.resolvedOptions 2021-09-11 11:05:50 +01:00
Timothy Flynn
071e193d92 LibJS: Implement Intl.NumberFormat.supportedLocalesOf 2021-09-11 11:05:50 +01:00
Timothy Flynn
e42ba7f748 LibJS: Implement the Intl.NumberFormat constructor 2021-09-11 11:05:50 +01:00
Timothy Flynn
07f12b108b LibJS: Implement a nearly empty Intl.NumberFormat object
This adds plumbing for the Intl.NumberFormat object, constructor, and
prototype.
2021-09-11 11:05:50 +01:00
Timothy Flynn
a1954262f8 LibJS: Handle Unicode locale extensions in the ResolveLocale operation
Currently, all callers of ResolveLocale invoke the operation with an
empty [[RelevantExtensionKeys]] slot, so the block of the method that
deals with those keys was unimplemented. This implements that block now
to prepare for Intl.NumberFormat which has a [[RelevantExtensionKeys]].

Note that the find_key_in_value() method is a simple VERIFY_NOT_REACHED
in just this commit until the Intl.NumberFormat's keys are handled in
its implementation.
2021-09-11 11:05:50 +01:00
Timothy Flynn
e6334cb856 LibUnicode: Add some data related to currency codes
This data is published under ISO-4217 as an XML file. Since we can't
parse XML files yet, and the data isn't very large, it was translated to
C++ manually here.
2021-09-11 11:05:50 +01:00
Timothy Flynn
3ae4ff109f LibUnicode: Extract canonicalization of Unicode extension values
LibJS will need to canonicalize Unicode extension values, so extract the
lambda that was doing this work to its own function. This also changes
the helpers it invokes to take the provided key as a StringView because
we don't need (and won't always have) full String objects here.
2021-09-11 11:05:50 +01:00
Timothy Flynn
b1d4bcf364 LibUnicode: Generate numeric keyword values for each locale
This is needed for Intl.NumberFormat's usage of the ResolveLocale AO,
where the [[RelevantExtensionKeys]] internal slot will be "nu".
2021-09-11 11:05:50 +01:00
Andreas Kling
5514f41f25 LibWeb: Ignore keydown events when there is no layout tree 2021-09-11 02:13:06 +02:00
Andreas Kling
d69133e4ac LibWeb: Stub out a dummy window.getComputedStyle()
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. :^)
2021-09-11 00:36:37 +02:00
Andreas Kling
1484980f8f LibWeb+LibJS: Remember source filenames when using HTML::Script
It's a lot easier to debug JavaScript problems if you can see which file
the errors are in. :^)
2021-09-11 00:36:37 +02:00
Luke Wilde
3548b08de2 LibJS: Implement Temporal.PlainMonthDay.prototype.equals 2021-09-10 23:10:18 +01:00
Luke Wilde
2d5b15295a LibJS: Implement Temporal.PlainMonthDay.from 2021-09-10 23:10:18 +01:00
Luke Wilde
d9d1e25db3 LibJS: Implement ToTemporalMonthDay AO 2021-09-10 23:10:18 +01:00
Tobias Christiansen
de0791b0a1 LibGfx: Increase bit-width of variables used in do_draw_scaled_bitmap
To avoid expensive floating point operations the values are put in the
upper half of an integer which is then used for calculations.
When the src_rect is sufficiently large (when, say, PixelPaint is zoomed
in x100), the precision provided by this strategy with regular
32-bit-long ints  is no longer enough.
This patch changes the used types to i64, which are 64 bits wide and the
shifting is increased to 32 bits.
On the 32-bit-arch a i64 doesn't fit in a single register anymore but
it's probably okay to trust the compiler to do clever stuff around this
issue.
2021-09-11 00:09:33 +02:00
Andreas Kling
d7578ddebb LibJS: Share "parsed identifiers" between copied JS::Lexer instances
When we save/load state in the parser, we preserve the lexer state by
simply making a copy of it. This was made extremely heavy by the lexer
keeping a cache of all parsed identifiers.

It keeps the cache to ensure that StringViews into parsed Unicode escape
sequences don't become dangling views when the Token goes out of scope.

This patch solves the problem by replacing the Vector<FlyString> which
was used to cache the identifiers with a ref-counted
HashTable<FlyString> instead.

Since the purpose of the cache is just to keep FlyStrings alive, it's
fine for all Lexer instances to share the cache. And as a bonus, using a
HashTable instead of a Vector replaces the O(n) accesses with O(1) ones.

This makes a 1.9 MiB JavaScript file parse in 0.6s instead of 24s. :^)
2021-09-10 23:18:00 +02:00
Mustafa Quraish
ecb3f882a3 LibFileSystemAccessClient: Convert request paths to absolute if needed
FileSystemAccessServer requires all paths to be absolute, and will
just crash if this is not the case. Instead of expecting the user to
always provide an absolute path, the client just checks to see if
the path provided was absolute, and if not makes a request with the
absolute path instead.
2021-09-10 20:46:50 +04:30
Mustafa Quraish
2a968e92f0 FileSystemAccessServer: Allow read-only access without prompting
This commit adds a new request to the FileSystemAccessServer
endpoint, allowing the clients to get read-only access to a file
without getting a Dialog-box prompting the user for access.

This is only meant to be used in cases where the user has asked
specifically to open a file through the command-line arguments.
In those cases, I believe it makes sense for the read-only access
to be implicit. Always prompting the user gets a bit annoying,
especially if you just quickly want to open a file through the CLI.

The new request name has been made extremely specific to make sure
that it's only used when appropriate.
2021-09-10 20:46:50 +04:30
Ali Mohammad Pur
5a0cdb15b0 AK+Everywhere: Reduce the number of template parameters of IntrusiveList
This makes the user-facing type only take the node member pointer, and
lets the compiler figure out the other needed types from that.
2021-09-10 18:05:46 +03:00
Itamar
c78838c2d2 LibDebug: Use the first memory segment of a library as the ELF's base
When parsing the libraries of the debugee process, we previously
assumed that the region that's called `<library name>: .text` was also
the base of the ELF file.

However, since we started linking with `-z separate-code`, this is no
longer the case - our executables have a read-only segment before the
.text segment, and that segment is actually at the base of the ELF.

This broke inserting breakpoints with the debugger since they were
inserted at a wrong offset.

To fix that, we now use the address of the first segment in the memory
map for the ELF's base address (The memory map is sorted by address).
2021-09-10 13:57:34 +00:00
Andreas Kling
8fabaaa2a8 LibWeb: Make "top-level browsing context" concept more spec-compliant
Any browsing context that doesn't have a parent browsing context is now
considered a top-level browsing context. This matches the HTML spec.

This means we no longer keep a pointer to the top-level context, since
we can simply walk the parent chain until we find the topmost ancestor.
2021-09-10 03:02:55 +02:00
Linus Groh
4e5becf36e LibJS: Make default_merge_fields() {additional_,}fields Object a const&
This only calls Object::{get,enumerable_own_property_names}() on the
fields and additional_fields Objects, both of which are const-qualified.
2021-09-09 23:46:45 +01:00
Linus Groh
4bba61fd59 LibJS: Make resolve_iso_month() fields Object a const&
This only calls Object::get() on the fields Object, which is
const-qualified.
2021-09-09 23:46:45 +01:00
Linus Groh
1f99538185 LibJS: Make Temporal foo_from_fields() AO field/options Object a const*
This is a bit of a lie as the Value(Object const*) ctor will const_cast
them in invoke(), but at least it ensures that nothing else in the
function relies on getting non-const Objects.
Perhaps we can have an actual Object const* Value in the future as well.
2021-09-09 23:46:45 +01:00
Linus Groh
4be2aeca00 LibJS: Make prepare_temporal_fields() fields Object a const&
This only calls Object::get() on the fields Object, which is
const-qualified.
2021-09-09 23:46:45 +01:00
Linus Groh
c9951ad26b LibJS: Make to_temporal_time_record() time like Object a const&
This only calls Object::get() on the temporal_time_like Object, which is
const-qualified.
2021-09-09 23:46:45 +01:00
Linus Groh
77a18392ff LibJS: Make to_temporal_duration_record() time like Object a const&
This only calls Object::get() or some Duration getters on the
temporal_duration_like Object, both of which are const-qualified.
2021-09-09 23:46:45 +01:00
Linus Groh
1d24699ca8 LibJS: Make Temporal to_foo() AO normalized_options Object a const&
These only pass the normalized_options Object directly or indirectly to
get_option(), which now takes a const reference.
2021-09-09 23:46:45 +01:00
Linus Groh
a422ea8792 LibJS: Make get_string_or_number_option() options Object a const&
This only passes the options Object to get_option(), which now takes a
const reference.
2021-09-09 23:46:45 +01:00
Linus Groh
c099b1b8a5 LibJS: Make get_option() options Object a const&
This only calls Object::get() on the options Object, which is
const-qualified.
2021-09-09 23:46:45 +01:00
Linus Groh
5ae6ad8557 LibJS: Store Instant's and ZonedDateTime's m_nanoseconds as a const&
There's no need for these to be non-const. Suggested by @IdanHo in
https://github.com/SerenityOS/serenity/pull/9904#discussion_r704960184.

Perhaps we can make more internal slots of these and other objects const
references as well, but that's a bit more involved as they are used by
various functions expecting non-const references.
2021-09-09 23:46:45 +01:00
Linus Groh
e4c07c5b8f LibJS: Make new_target parameter of all Temporal AOs a const*
These are passed to ordinary_create_from_constructor() in each case,
which takes the parameter as a const&, so these can also be const.
2021-09-09 23:46:45 +01:00
Rodrigo Tobar
2c22ff94b4 LibC: Define RLIM_NLIMITS constant
This is required by programs that want to either iterate over all
resources, or check that a resource identifier is valid before passing
it down.
2021-09-10 00:00:03 +02:00
Andreas Kling
c93687c15e LibC: Make remove() propagate non-EISDIR unlink() errors
Regressed in 16105091ba.
2021-09-09 21:49:49 +02:00
Andreas Kling
1864b2b828 LibWeb: Make HTMLScriptElement create and run ClassicScripts
Before this patch, HTMLScriptElement would cache the full script source
text in a String member, and parse that just-in-time via Document's
run_javascript() helpers.

We now follow the spec more closely and turn the incoming source text
into a ClassicScript object ("the script's script" in the spec.)
2021-09-09 21:25:10 +02:00
Andreas Kling
73be7e227b LibWeb: Implement the "create" and "run" methods of ClassicScript
These correspond to "create a classic script" and "run a classic script"
from the HTML specification. :^)
2021-09-09 21:25:10 +02:00
Andreas Kling
d823d7da54 LibJS: Implement the ParseScript AO (as JS::Script::parse()) 2021-09-09 21:25:10 +02:00
Andreas Kling
35c4a1ebcb LibWeb: Annotate HTMLScriptElement::execute_script() with spec comments 2021-09-09 21:25:10 +02:00
Andreas Kling
bc12921d43 LibWeb: Rename HTMLScriptElement::m_script_source => m_source_text 2021-09-09 21:25:10 +02:00
Andreas Kling
e1fb8bef09 LibWeb: Rename Document::complete_url() => parse_url()
This better matches the spec nomenclature.
2021-09-09 21:25:10 +02:00
Andreas Kling
0839442da5 LibWeb: Start working on spec-aligned HTML scripting semantics
This patch adds HTML::Script and HTML::ClassicScript (subclass of the
former.)
2021-09-09 21:25:10 +02:00
Andreas Kling
612a23d6fc LibJS: Start adding a JS::Script class (spec's "Script Record") 2021-09-09 21:25:10 +02:00
Andreas Kling
16105091ba LibC: Remove a bunch of pointless rc temporaries in stdio.cpp 2021-09-09 21:25:10 +02:00
Andreas Kling
f1ce43bdbf LibWeb: Make DOM::Window store its associated document in a WeakPtr
Let's err on the side of caution and use a WeakPtr instead of a
DOM::Document&. Even if the object lifetimes involved here should be
well-defined, they are fairly complicated.
2021-09-09 21:25:10 +02:00
Andreas Kling
90cdeebfb3 LibWeb: Rename DOM::Window::document() => associated_document()
Match the spec nomenclature.
2021-09-09 21:25:10 +02:00
Andreas Kling
8f72729f0e LibWeb: Convert DOM::Window to east-const style 2021-09-09 21:25:10 +02:00
Andreas Kling
d392349b6e LibWeb: Add DOM::Window::page()
This helps us to get from a Window to the containing Page, without
clients having to go through Document.
2021-09-09 21:25:10 +02:00
Andreas Kling
84fcf879f9 LibWeb: Rename BrowsingContext::document() => active_document()
This better matches the spec nomenclature. Note that we don't yet
*retrieve* the active document according to spec.
2021-09-09 21:25:10 +02:00
Linus Groh
92363a4ef8 LibJS: Mark TemporalTimeToString as infallible
This is an editorial change in the Temporal spec.

See: https://github.com/tc39/proposal-temporal/commit/899cc24
2021-09-09 18:24:18 +01:00
Mustafa Quraish
522f0841fd LibGfx/Point: Add hash trait for Point<T> 2021-09-09 11:27:48 +02:00
Luke Wilde
90ada407db LibJS: Implement Temporal.PlainYearMonth.compare 2021-09-09 09:06:23 +01:00
Luke Wilde
092ec0cecf LibJS: Implement Temporal.PlainYearMonth.from 2021-09-09 09:06:23 +01:00
Luke Wilde
58e2597dc2 LibJS: Implement Temporal.PlainYearMonth.prototype.equals 2021-09-09 09:06:23 +01:00
Luke Wilde
ff0b01a505 LibJS: Implement ToTemporalYearMonth AO 2021-09-09 09:06:23 +01:00
Linus Groh
d3fcf5a570 LibJS: Implement Temporal.Instant.prototype.toZonedDateTimeISO() 2021-09-09 08:52:48 +01:00
Linus Groh
6607d1dfb1 LibJS: Implement Temporal.Instant.prototype.toZonedDateTime() 2021-09-09 08:52:48 +01:00
Timothy
b953588e0e LibGfx: Add method to load bitmap from fd 2021-09-09 02:34:29 +02:00
Timothy
c966c32571 LibGfx: Move common loader functionality to load from memory functions
This will share functionality between the load from path and load from
memory functions.
2021-09-09 02:34:29 +02:00
John Diamond
c1063e3219 LibGUI: Disable Open/Save button in FilePicker when nothing is selected
The existing behaviour is that filename_textbox is cleared if a node of
the wrong type is selected. Here we reflect that state update in the
state of the ok_button.

This change helps the user to avoid confirming (and seeing an alert) if
they press "Open" after clicking on an invalid node.
2021-09-09 02:32:29 +02:00
Andreas Kling
882c7b1295 LibWeb: Spin the event loop in HTML parser until scripts can run
Call HTML::EventLoop::spin_until() from the HTML parser when deciding
whether we can run a script yet.

Note that spin_until() actually doesn't do any work yet.
2021-09-09 02:30:54 +02:00
Andreas Kling
c759055c08 LibWeb: Implement "Document has a style sheet that is blocking scripts"
This will be used by the HTML parser to determine whether it's okay to
start running a script.

Note that we don't actually count the script-blocking style sheets yet.
This patch only adds a the checking mechanism for the parser.
2021-09-09 02:30:54 +02:00
Andreas Kling
71d7c8a353 LibWeb: Add BrowsingContext::container_document()
This is the "browsing context container document" from the spec.
2021-09-09 02:30:54 +02:00
Andreas Kling
d1100dd6bc LibWeb: Add BrowsingContext::container() to align with the spec
We already have a base class for frame elements that we call
BrowsingContextContainer. This patch makes BrowsingContext::container()
actually return one of those.

This makes us match the spec names, and also solves a FIXME about having
a shared base for <frame> and <iframe>. (We already had the shared base,
but the pointer we had there wasn't tightly typed enough.)
2021-09-09 02:30:54 +02:00
Andreas Kling
5356de1c58 LibWeb: Use the task queue to fire "error" events on scripts 2021-09-09 02:30:54 +02:00
Andreas Kling
33f67e4c0f LibWeb: Use the task queue to fire "load" and "error" events on images 2021-09-09 02:30:53 +02:00
Andreas Kling
aa3ba629ba LibWeb: Add DOM::Element::queue_an_element_task(source, steps)
This roughly models the "queue an element task" algorithm from the spec.
For safety, this captures a strong reference to the element, and then
bundles that with a callback into a HTML::Task (that we then queue up.)
2021-09-09 02:30:53 +02:00
Andreas Kling
909e522cf7 LibWeb: Schedule HTML::EventLoop processing when there are queued tasks
Since we can't simply give HTML::EventLoop control of the whole program,
we have to integrate with Core::EventLoop.

We do this by having a single-shot 0ms Core::Timer that we start when
a task is added to the queue, and restart after processing the queue and
there are still tasks in the queue.
2021-09-09 02:30:53 +02:00
Andreas Kling
e0c7f8dafa LibWeb: Give HTML::EventLoop a pointer to the JS::VM
This will be required for event loop processing.
2021-09-09 02:18:31 +02:00
Andreas Kling
7bcde2bcfb LibWeb: Let HTML::EventLoop know its type
There are three types of event loop: window, worker and worklet.
For now, we only have window event loops.
2021-09-09 02:18:31 +02:00
Andreas Kling
0554d96a2e LibWeb: Stub out HTML::EventLoop::process() with spec FIXME's 2021-09-09 02:18:31 +02:00
Andreas Kling
c8c9112652 LibWeb: Give HTML::EventLoop a "currently running task" 2021-09-09 02:18:31 +02:00
Andreas Kling
bc3a432cb2 LibWeb: Add HTML::Task::Source to model "generic task sources" 2021-09-09 02:18:31 +02:00
Andreas Kling
462120d900 LibWeb: Stub out HTML::EventLoop::spin_until() with spec FIXME's 2021-09-09 02:18:31 +02:00
Andreas Kling
ecb72f3b57 LibWeb: Add a bare-bones HTML event loop with a task queue
This patch attaches a HTML::EventLoop to the main thread JS::VM used
for JavaScript bindings in the web engine.

The goal here is to model the various task scheduling mechanisms of the
HTML specification.
2021-09-09 02:18:31 +02:00
Andreas Kling
b76456f0ed LibJS: Add a way to attach custom data to a JS::VM instance
This will be used by LibWeb to attach web engine specific stuff that
LibJS doesn't need to know about.
2021-09-09 02:18:31 +02:00
Linus Groh
9661d15fe2 LibJS: Implement Temporal.PlainTime.prototype.toJSON() 2021-09-08 23:42:26 +01:00
Linus Groh
6987e326d8 LibJS: Implement Temporal.PlainTime.prototype.toLocaleString() 2021-09-08 23:42:26 +01:00
Linus Groh
9f78a957d5 LibJS: Implement Temporal.PlainTime.prototype.toString() 2021-09-08 23:42:26 +01:00
Linus Groh
81aaa9ccd5 LibJS: Replace String const& with StringView in various Temporal AOs
This is especially helpful where we already pass StringView literals
and only compare them with others, e.g. overflow and largest/smallest
unit, in which case there's no need to actually allocate a string.
2021-09-08 23:42:26 +01:00
Timothy Flynn
4f2bcebe74 LibUnicode+LibJS: Store locale keyword values as a single string
Previously, LibUnicode would store the values of a keyword as a Vector.
For example, the locale "en-u-ca-abc-def" would have its keyword "ca"
stored as {"abc, "def"}. Then, canonicalization would occur on each of
the elements in that Vector.

This is incorrect because, for example, the keyword value "true" should
only be dropped if that is the entire value. That is, the canonical form
of "en-u-kb-true" is "en-u-kb", but "en-u-kb-abc-true" does not change
for canonicalization. However, we would canonicalize that locale as
"en-u-kb-abc".
2021-09-08 21:08:48 +01:00
Timothy Flynn
75657b79c6 LibUnicode: Update comment with link to related upstream issue
LibUnicode has to hard-code some aliases because the related data is not
available in the JSON export of CLDR. Turns out there is a ticket to add
this data in an upcoming CLDR release. Add a link to that ticket for
reference.
2021-09-08 21:08:48 +01:00
Timothy Flynn
2ebafe000a LibJS: Fix typos in Intl.ListFormat comments 2021-09-08 21:08:48 +01:00
davidot
db0a48d34c LibJS: Restore the environment if an exception is thrown in 'with' block 2021-09-08 20:37:39 +01:00
Luke Wilde
d943b8f100 LibJS: Implement Temporal.PlainTime.prototype.with
Ticks off one box in #8982 and fixes one test262 case.
2021-09-08 19:57:29 +01:00
Andreas Kling
b8d683c5fb LibWeb: Tweak for/event whitespace stripping in <script> to match spec
This is not a functional change, it merely reorders operations so that
we match spec language better.
2021-09-08 20:16:00 +02:00
Andreas Kling
917725ce67 LibWeb: Annotate HTMLScriptElement::prepare_script() with spec comments 2021-09-08 20:16:00 +02:00
Dawid Wolosowicz
484b9c1ba3 LibGUI: West Const to East Const refactor 2021-09-08 15:48:02 +04:30
Dawid Wolosowicz
2d91ba2737 LibGUI: Remove an unnecessarily specific inline capacity 2021-09-08 15:48:02 +04:30
Dawid Wolosowicz
8419eef85e LibGUI: Sync the highlighting after each model update
Without this, the highlighting would stay on the initial index even if
the matching row is no longer there.
2021-09-08 15:48:02 +04:30
Dawid Wolosowicz
d0e44993a1 LibGUI: Refactor AbstractView::do_search() into two standalone steps
This change splits the do_search() into find_next_search_match() and
highlight_search() to allow the given index be independently highlighted
when needed.
2021-09-08 15:48:02 +04:30
Dawid Wolosowicz
cc93736f21 LibGUI: Remove barely used AbstractView::is_searching() 2021-09-08 15:48:02 +04:30
Dawid Wolosowicz
b775b1c199 LibGUI: Unify naming of searching timer related members 2021-09-08 15:48:02 +04:30
Dawid Wolosowicz
9225b45c2d LibGUI: Rename AbstractView::m_searching => m_highlighted_search 2021-09-08 15:48:02 +04:30
Dawid Wolosowicz
aeffd9024e LibGUI: Remove barely used AbstractView::is_highlighting_searching() 2021-09-08 15:48:02 +04:30
Dawid Wolosowicz
0cbc222c17 LibGUI: Remove barely used AbstractView::searching() 2021-09-08 15:48:02 +04:30
Dawid Wolosowicz
e96081ef8f LibGUI: Make AbstractView::is_searching protected 2021-09-08 15:48:02 +04:30
Andreas Kling
52ed43d139 LibWeb: Scroll viewport to (0, 0) after loading a new document
This fixes a long-standing bug where the view wouldn't update when
navigating to a new page after looking at the ACID2 test. This happened
because ACID2 actually scrolls the viewport far down. We didn't reset
the scroll position upon navigation, and so the new page thought that
we were still scrolled very far down, and this broke the invalidation
rect calculations.
2021-09-08 11:56:50 +02:00
Andreas Kling
e91edcaa28 LibWeb: Rename InitialContainingBlockBox => InitialContainingBlock
The "Box" suffix added nothing here.
2021-09-08 11:27:46 +02:00
Andreas Kling
e90ccf6a20 LibWeb: Make BrowsingContext::m_top_level_browsing_context a WeakPtr
At the moment, nested browsing contexts expect that there's always a
top-level browsing context at some higher level. That's okay, but let's
keep the top-level pointer in a WeakPtr to make it easier to catch
mistakes (as this turns UAF into a null dereference.)
2021-09-08 11:19:27 +02:00
Andreas Kling
ef371596a4 LibWeb: Remove unnecessary DOM::Position destructor 2021-09-08 11:14:29 +02:00
Andreas Kling
3a7e26ef28 LibWeb: Rename frame_did_set_viewport_rect() => browsing_context_*()
Names are still catching up after the Frame => BrowsingContext rename.
2021-09-08 11:12:22 +02:00
Andreas Kling
9d9500989a LibWeb: Remove unused PageClient::is_multi_process() 2021-09-08 11:07:14 +02:00
Andreas Kling
a38aefed0b LibWeb: Remove bogus forward declaration for Web::StackingContext
The real class is Web::Layout::StackingContext.
2021-09-08 11:07:14 +02:00
Andreas Kling
76b0253b6b LibWeb: Convert BrowsingContext to east-const style 2021-09-08 11:07:14 +02:00
Andreas Kling
57fbeff925 LibWeb: Use delegating constructors in BrowsingContext
This avoids having two nearly-identical initializer lists and and an
awkward setup() function that every constructor must call.
2021-09-08 11:07:14 +02:00
Andreas Kling
9d03ea6f74 LibWeb+WebContent: Port DumpLayoutTree to OutOfProcessWebView
This required adding a simple OOPWV::dump_layout_tree() API that
synchronously requests a dump of the layout tree from the WebContent
process.
2021-09-08 11:07:14 +02:00
Ben Wiederhake
c6e56612f5 LibGUI+WindowServer: Remove now-obsolete cursor tracking feature
This feature was problematic for several reasons:
- Tracking *all* the user activity seems like a privacy nightmare.
- LibGUI actually only supports one globally tracking widget per window,
  even if no window is necessary, or if multiple callbacks are desired.
- Widgets can easily get confused whether an event is actually directed
  at it, or is actually just the result of global tracking.

The third item caused an issue where right-clicking CatDog opened two
context menus instead of one.
2021-09-08 10:53:49 +02:00
Ben Wiederhake
45126655cd LibGUI+WindowServer: Introduce new mouse tracking mechanism 2021-09-08 10:53:49 +02:00
davidot
43b17f27a3 test-js: Add a mark_as_garbage method to force GC to collect that object
This should fix the flaky tests of test-js.
It also fixes the tests when running with the -g flag since the values
will not be garbage collected too soon.
2021-09-08 08:53:02 +01:00
Luke Wilde
7788a7e744 LibJS: Fix Temporal.PlainTime.prototype.equals test
The two plain times weren't being compared to each other.
2021-09-08 08:48:13 +01:00
Linus Groh
33f76f88bb LibJS: Add and use the CreateNegatedTemporalDuration AO
This is a normative change in the Temporal spec.

See: https://github.com/tc39/proposal-temporal/commit/6178ed3
2021-09-08 00:07:18 +01:00
Linus Groh
f046a4a75d LibJS: Make implementation-defined language more concise
This is a normative change in the Temporal spec. No behavioral change,
just a clarification.

See: https://github.com/tc39/proposal-temporal/commit/42c964e
2021-09-08 00:07:18 +01:00
Linus Groh
86a7c795f6 LibJS: Use the newly added remainder operation in GetISOPartsFromEpoch
This is a normative change in the Temporal spec. No behavioral change,
just a clarification.

See: https://github.com/tc39/proposal-temporal/commit/b7bdc65
2021-09-08 00:07:18 +01:00
Linus Groh
97cc8f4613 LibJS: Validate Calendar.prototype.fields() values more strictly
This is a normative change in the Temporal spec.

See:

- https://github.com/tc39/proposal-temporal/commit/75b66d8
- https://github.com/tc39/proposal-temporal/commit/9c2262b
2021-09-08 00:07:18 +01:00
Luke Wilde
1a28fc3cb5 LibWeb: Add preceding and following Node cases in tree constraints
This also does some east-const changes in TreeNode.
2021-09-07 22:06:39 +02:00
Ali Mohammad Pur
7fefb8148b LibRegex: Use the correct capture group index in ERE bytecode generation
Otherwise the left and right capture instructions wouldn't point to the
same capture group if there was another nested group there.
2021-09-07 20:01:58 +02:00
Luke Wilde
44b8afdbc4 LibWeb: Don't trim whitespace when checking for "module" type on scripts
No major engine allows whitespace in the type when checking for
"module".

This was also reflected in the relevant web platform test, but not in
the spec.

The spec has been changed to match this behaviour: 23c723e3e9
2021-09-07 17:22:24 +02:00
Andreas Kling
226383f45b LibELF: Use StringView to carry temporary strings in auxiliary vector
Let's not force clients to provide a String.
2021-09-07 13:53:14 +02:00
Andreas Kling
6ad427993a Everywhere: Behaviour => Behavior 2021-09-07 13:53:14 +02:00
Timothy Flynn
ef94c73a01 LibJS: Implement Intl.ListFormat.prototype.resolvedOptions 2021-09-06 23:49:56 +01:00
Timothy Flynn
5c06a91dfa LibJS: Implement Intl.ListFormat.prototype.formatToParts 2021-09-06 23:49:56 +01:00
Timothy Flynn
cdba40f7ea LibJS: Implement Intl.ListFormat.prototype.format 2021-09-06 23:49:56 +01:00
Timothy Flynn
3b410742ab LibJS: Implement Intl.ListFormat.supportedLocalesOf 2021-09-06 23:49:56 +01:00
Timothy Flynn
eacc8bef47 LibJS: Implement the Intl.ListFormat constructor 2021-09-06 23:49:56 +01:00
Timothy Flynn
8e75e5fabb LibJS: Implement a nearly empty Intl.ListFormat object
This adds plumbing for the Intl.ListFormat object, constructor, and
prototype.
2021-09-06 23:49:56 +01:00
Timothy Flynn
3f64a14e06 LibUnicode: Parse and generate the Unicode locale list patterns dataset
This data informs consumers how to join lists of values. For example,
in en-US, the list ["a", "b", "c"] formatted to a string should become
"a, b, and c".
2021-09-06 23:49:56 +01:00
Idan Horowitz
456938add0 LibJS: Use StringViews in Round{NumberToIncrement, TemporalInstant} 2021-09-06 22:15:39 +01:00
Idan Horowitz
4b5aa2102c LibJS: Implement Temporal.Instant.prototype.since 2021-09-06 22:15:39 +01:00
Idan Horowitz
470499b2a8 LibJS: Implement Temporal.Instant.prototype.until 2021-09-06 22:15:39 +01:00
Idan Horowitz
24b78fff7d LibJS: Add a bunch of Temporal Abstract Operations
These will allow us to (partially) implement
Temporal.Instant.prototype.{until, since}
2021-09-06 22:15:39 +01:00
Idan Horowitz
bcdad57670 LibCrypto: Add naive implementation of {Un,}SignedBigInteger::to_double 2021-09-06 22:15:39 +01:00
Sam Atkins
e255b5dd31 LibWeb+WebContent: Remove old console-logging IPC calls
This patch removes the following WebContent IPC calls, which are no
longer used:

- `Server::js_console_initialize()`
- `Client::did_js_console_output()`
2021-09-06 18:20:26 +02:00
Sam Atkins
c619a57cf8 LibWeb+WebContent: Add new console-message IPC calls
This patch introduces three new IPC calls for WebContent:

- `Client::did_output_js_console_message(index)`:
  Notifies the client that a new console message was logged.

- `Server::js_console_request_messages(start_index)`:
  Ask the server for console messages starting at the given index.

- `Client::did_get_js_console_messages(start_index, types, messages)`:
  Send the client the messages they requested.

This mechanism will replace the current
`Client::did_js_console_output()` call in the next few commits. This
will allow us to display messages in the console that happened before
the console was opened.
2021-09-06 18:20:26 +02:00
Marcus Nilsson
0583f75926 LibGUI: Dynamically resize editing content rect in IconView
This makes IconView aware of the text width of the
ModelEditingDelegate widget when editing an index and allows us to
resize the content rect as needed.

This also removes the border from the textbox since it could collide
with the icon in ColumnsView. While editing we also skip painting the
inactive selection rect since it would otherwise show when the content
rect gets smaller.
2021-09-06 17:38:26 +02:00
Timothy Flynn
207319ecf1 LibJS: Implement ECMA-402 String.prototype.toLocale{Lower,Upper}Case 2021-09-06 15:24:27 +01:00
Timothy Flynn
14086c69e7 LibJS: Only remove Unicode locale extensions during the LookupMatcher AO
This was one of the first AOs used for Intl, and I misinterpreted the
spec. Rather than removing all extensions, we must only remove Unicode
locale extensions.

Also use LocaleID::to_string() here instead of the heavier canonical
string method, because the locale is already canonical.
2021-09-06 15:24:27 +01:00
Timothy Flynn
40ea659282 LibUnicode+LibJS: Return removed extensions from remove_extension_type
Some callers will need to hold onto the removed extensions.
2021-09-06 15:24:27 +01:00
Timothy Flynn
50158abaf1 LibUnicode: Implement locale-aware BEFORE_DOT special casing
Note that the algorithm in the Unicode spec is for checking that a code
point precedes U+0307, but the special casing condition NotBeforeDot is
interested in the inverse of this rule.
2021-09-06 15:24:27 +01:00
Timothy Flynn
436faf9fd9 LibUnicode: Implement locale-aware MORE_ABOVE special casing 2021-09-06 15:24:27 +01:00
Timothy Flynn
1427ebc622 LibUnicode: Implement locale-aware AFTER_SOFT_DOTTED special casing 2021-09-06 15:24:27 +01:00
Timothy Flynn
0053d48c41 LibUnicode: Implement locale-aware AFTER_I special casing 2021-09-06 15:24:27 +01:00
Timothy Flynn
68b2680040 LibUnicode: Ensure case conversion methods increment the current index
There was one branch in these methods (the branch where a special casing
was found) that neglected to update the current index.
2021-09-06 15:24:27 +01:00
Timothy Flynn
12ae0a44d7 LibUnicode: Add public wrapper for the generated locale_from_string 2021-09-06 15:24:27 +01:00
Ali Mohammad Pur
88d148b46a LibRegex: Avoid keeping track of checkpoints across forks
Doing so would increase memory consumption by quite a bit, since many
useless copies of the checkpoints hashmap would be created and later
thrown away.
2021-09-06 18:21:13 +04:30
Karol Kosek
759d6df87d LibGUI: Add Gfx::ColorRole to Variant
For Theme Editor. :^)
2021-09-06 14:05:10 +04:30
Ali Mohammad Pur
abbe9da255 LibRegex: Make infinite repetitions short-circuit on empty matches
This makes (addmittedly weird) patterns like `(a*)*` work correctly
without going into an infinite fork loop.
2021-09-06 13:51:30 +04:30
davidot
bbddfeef4b LibJS: Clean up token constructor and use method instead for identifiers
Having two large constructor with just one parameter difference in the
middle seems quite dangerous so just do it with a method.
2021-09-06 08:43:38 +01:00
davidot
3fee7b0d0b LibJS: Fix that windows style line endings were not ignored or converted
These are tested by test262 but the current test262-runner reads the
files in python which automatically converts \r\n to \n.
This meant that we passed the tests while we should not have.
2021-09-06 08:43:38 +01:00
Luke Wilde
5e61382849 LibWeb: Make Node.textContent more spec compliant
The current implementation felt a bit ad-hoc and notably allowed
textContent to operate on all node types. It also only returned the
child text content of the Node instead of the descendant text content.
2021-09-06 02:36:04 +02:00
Luke Wilde
d36838d050 LibWeb: Implement the (string) replace all operations for Node 2021-09-06 02:36:04 +02:00
Luke Wilde
67c73ddd59 LibWeb: Add [LegacyNullToEmptyString] to CharacterData.data
See https://dom.spec.whatwg.org/#characterdata
2021-09-06 02:18:53 +02:00
Luke Wilde
6e80458515 LibWeb: Add constructors for Text, DocumentFragment and Comment
These three nodes are the only nodes in the DOM spec with constructors.
2021-09-06 02:18:41 +02:00
Andrew Kaster
fe701052ea LibC: Expand region for global destructors when it reaches capacity
In 553361d we started mprotecting the atexit handlers when they are not
being modified or executed. As part of that commit, we unintentionally
changed the max number of global destructors from 1024 to 256 (on x86,
only 128 on x86_64). This patch expands the initial size of the global
destructors page to 2 pages from 1, and allows the pool to be expanded
at runtime by mapping a new set of pages and copying the AtExitEntries
over.
2021-09-06 01:55:14 +02:00
Ali Mohammad Pur
7589cc2494 LibJS: Handle possible allocation failure in ArrayBuffer(size_t)
...by replacing it with a ctor that takes the buffer instead, and
handling the allocation failure in ArrayBuffer::create(size_t) by
throwing a RangeError as specified by the spec.
2021-09-06 01:53:26 +02:00
Ali Mohammad Pur
97e97bccab Everywhere: Make ByteBuffer::{create_*,copy}() OOM-safe 2021-09-06 01:53:26 +02:00
Ali Mohammad Pur
3a9f00c59b Everywhere: Use OOM-safe ByteBuffer APIs where possible
If we can easily communicate failure, let's avoid asserting and report
failure instead.
2021-09-06 01:53:26 +02:00
Linus Groh
6ffc8f389e LibJS: Use different stack space limit values for with and without ASAN
Instead of having a single limit here, which we had to increase once to
work with ASAN enabled, check whether HAS_ADDRESS_SANITIZER is defined
and use 32 KiB, and 16 KiB otherwise (which is what we used previously).

This idea is shamelessly stolen from V8:
https://github.com/v8/v8/blob/b2b44af/src/execution/isolate.cc#L1381-L1387
2021-09-05 22:17:09 +01:00
Linus Groh
941ff0cf60 LibJS: Prevent stack overflow if Proxy handler's __proto__ is the Proxy
Fixes #9322.
2021-09-05 22:17:09 +01:00
Linus Groh
9998a2c91e LibJS: Add ErrorType::CallStackSizeExceeded
I'm about to add another use of this, so let's add an ErrorType for it
instead of hardcoding the message for a third time.
2021-09-05 22:17:09 +01:00
Brian Gianforcaro
3e45c3ed90 Userland: Switch static_assert of type sizes to AK::AssertSize 2021-09-05 20:08:57 +02:00
Ali Mohammad Pur
09dd397160 LibWeb+LibWasm: Implement the WebAssembly.Table object 2021-09-05 15:42:50 +04:30
Ali Mohammad Pur
d52a26de3f LibWasm: Move the vector size limit to Constants.h and increase it a bit 2021-09-05 15:42:50 +04:30
Brian Gianforcaro
d8de352ead LibJS: Declare type aliases with "using" instead of "typedef" 2021-09-05 09:48:43 +01:00
luiz
964249a5b0 LibGUI: Fixes modified indicator behavior after saving
Pior to this change when the user added text after having saved the file
the Text Editor wouldn't enable the modified flag, unless this new text
was a new line.

This happened because the UndoStack was merging the Command added by
the new text with the old text one, and when is_current_modified()
was called, the m_stack_index would not have been incremented, and
it would return false.

In this change was added a condition to verify if the modified tag is
active, and the merge is only done if the document is already modified.
2021-09-04 21:04:33 +02:00
Idan Horowitz
e8f6840471 AK+LibRegex: Disable construction of views from temporary Strings 2021-09-04 21:01:15 +02:00
Andreas Kling
24ef8b118a LibSymbolication: Unbreak symbolication with -z separate-code linking
We were incorrectly assuming that the mapped .text segment for an ELF
image was always at the base of the image mapping. Now that we have
.rodata mappings as well, it's possible for one of them to come before
the .text.
2021-09-04 20:30:56 +02:00
Andreas Kling
b7ee0191ea LibELF: Name non-executable map regions ".rodata" instead of ".text" 2021-09-04 20:30:56 +02:00
Andreas Kling
e40e91b9df LibDebug: Use HashMap::ensure() in DebugInfo::prepare_lines() 2021-09-04 20:30:56 +02:00
Andreas Kling
500067d3a6 LibGfx: Make FontDatabase cache store fonts in NonnullRefPtr
We don't cache failed font lookups, so there's no need for nullity here.
2021-09-04 20:30:56 +02:00
Linus Groh
0094259d72 LibJS: Implement Intl.DisplayNames.supportedLocalesOf() 2021-09-04 19:08:18 +01:00
Linus Groh
8f3a5ba5d8 LibJS: Add Array::create_from() for generic Vector<T>
It relies on a mapper function to convert each T& to a JS::Value. This
allows us to avoid awkward Vector<T> to MarkedValueList conversion at
the call site.
2021-09-04 19:08:18 +01:00
sin-ack
1999b66f38 LibGfx: Intersect the bounding box with the main rect in draw_text
Without this, the bounding rect for the text as generated by TextLayout
can go beyond the bounds of the user-supplied drawing rect and cause the
text to overlap because of the line_rect.intersect(rect) a few lines
below.
2021-09-04 16:48:27 +02:00
Idan Horowitz
1a19d2c2df LibGfx: Stop using a Utf8View that points to a temporary String 2021-09-04 16:13:30 +02:00
Idan Horowitz
72b21343ad LibGfx: Convert line text into a Utf8View before finding its direction
We were accidentally calling TextDirection::get_text_direction with a
String instead of a UtfView, which meant each byte was treated as a
codepoint, resulting in incorrect identification of text direction.
2021-09-04 16:13:30 +02:00
Ben Wiederhake
7224308358 LibGfx: Reject GIFs with ridiculously large symbols
This also prevents exploitation by malicious GIFs.
Found by OSS Fuzz, long-standing issue
(since 259f8541fc)
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=29034
2021-09-04 16:00:25 +02:00
Ben Wiederhake
39c09cec88 LibGfx: Elide predictable reallocations in GIF loader 2021-09-04 16:00:25 +02:00
Timothy Flynn
90971673c7 LibJS: Implement Intl.Locale.prototype.minimize 2021-09-04 13:51:40 +01:00
Timothy Flynn
a77f323dfb LibUnicode: Implement the Remove Likely Subtags method
Unlike Add Likely Subtags, this method doesn't require generated data.
Instead, it is defined in terms of Add Likely Subtags.
2021-09-04 13:51:40 +01:00
Timothy Flynn
0b1f5118d5 LibJS: Implement Intl.Locale.prototype.maximize 2021-09-04 13:51:40 +01:00
Timothy Flynn
03d7f01e0c LibJS: Add a constructor to create an Intl.Locale object from a LocaleID 2021-09-04 13:51:40 +01:00
Timothy Flynn
3abfe7f7db LibJS: Add missing Intl.Locale initializer for plain boolean type 2021-09-04 13:51:40 +01:00
Timothy Flynn
e6a2ab1202 LibUnicode: Generate an implementation of the Add Likely Subtags method 2021-09-04 13:51:40 +01:00
Timothy Flynn
ca90231794 LibUnicode: Define is_unicode_*_subtag helpers inline in their header
The UnicodeLocale generator will need to parse canonicalized locale
strings, and will require using these methods. However, the generator
cannot depend on LibUnicode because Locale.cpp within LibUnicode already
depends on the generated file. Instead, defining the methods that the
generator needs inline allows the generator to use them without linking
against LibUnicode.
2021-09-04 13:51:40 +01:00
Mustafa Quraish
30e91ecff6 Cursors: Add new Magnifying glass cursor
There are a few places in the system where this could be useful,
such as PixelPaint and the MandelBrot demo. It seems general enough
that it is probably useful to have it as a system-wide cursor rather
than loading it manually each time.
2021-09-04 03:35:23 +02:00
Mustafa Quraish
30ce1d8562 Cursors: Add new Eyedropper cursor
This can be used immediately in PixelPaint (separate commit), but
I am adding this as a system-wide cursor since it may also be useful
for other applications that want to use it.
2021-09-04 03:35:23 +02:00
Musab Kılıç
81326ac8c7 PixelPaint: Add invert filter 2021-09-04 03:35:17 +02:00
Mustafa Quraish
9ed32582e2 LibGfx/Painter: Add draw_rect_with_thickness method
Previously there was no way to draw rectangles with any specific
thickness, like we can do with ellises, for instance. This method
is just a simple wrapper around `draw_line()` several times. At
least for now, we don't need to do anything sophisticated since
this will only be used by PixelPaint.`
2021-09-04 03:30:03 +02:00
Daniel Bertalan
d7b6cc6421 Everywhere: Prevent risky implicit casts of (Nonnull)RefPtr
Our existing implementation did not check the element type of the other
pointer in the constructors and move assignment operators. This meant
that some operations that would require explicit casting on raw pointers
were done implicitly, such as:
- downcasting a base class to a derived class (e.g. `Kernel::Inode` =>
  `Kernel::ProcFSDirectoryInode` in Kernel/ProcFS.cpp),
- casting to an unrelated type (e.g. `Promise<bool>` => `Promise<Empty>`
  in LibIMAP/Client.cpp)

This, of course, allows gross violations of the type system, and makes
the need to type-check less obvious before downcasting. Luckily, while
adding the `static_ptr_cast`s, only two truly incorrect usages were
found; in the other instances, our casts just needed to be made
explicit.
2021-09-03 23:20:23 +02:00
Luke Wilde
2f426765a6 LibWeb: Add support HTMLScriptElement.supports
See 33ff054a6c
2021-09-03 23:11:58 +02:00
Andreas Kling
7df8483379 LibIPC: Convert Encoder class to east-const style 2021-09-03 15:36:51 +02:00
Andreas Kling
2ef1cd8d12 LibSQL: Replace Optional<NonnullRefPtr<T>> with RefPtr<T>
We generally don't use Optional with nullable types, since they already
have an empty state, and having multiple empty states is confusing.
2021-09-03 15:36:51 +02:00
Sam Atkins
e2c32a6c65 Everywhere: Use my shiny new serenityos.org email :^) 2021-09-03 12:22:36 +02:00
Mustafa Quraish
4961fa4715 LibSyntax: Fix bug in matching cursor highlighting
Fixes #9760.
2021-09-03 11:45:50 +02:00
Andreas Kling
eaf88cc78a AK: Rename create<T> => make_ref_counted<T>
And also try_create<T> => try_make_ref_counted<T>.

A global "create" was a bit much. The new name matches make<T> better,
which we've used for making single-owner objects since forever.
2021-09-03 02:36:09 +02:00
Karol Kosek
43a800a838 LibGUI: Set correct value on click with set jump_to_cursor() in Slider
Prior this change, clicking on a slider with set jump_to_cursor() flag
didn't exactly match the knob to the mouse position, and therefore
the slider values were a bit off in the corners.
The calculation used the whole widget size to set new values, which
isn't correct as the track slider has margins on both ends.

I noticed this while seeking in the Sound Player.
2021-09-03 02:32:43 +02:00
Karol Kosek
dabbe4ee27 LibGUI: Add track_margin() to Sliders
Less magic numbers! :^)
2021-09-03 02:32:43 +02:00
Mustafa Quraish
1cbab1c7e6 LibGfx/Color: Add suggested_foreground_color() method
This allows you to ask the color to recommend either white/black
as a contrasting text color if you were using the color as the
background. This uses the previously added luminosity() method.
2021-09-03 01:51:05 +02:00
Mustafa Quraish
882d57326c LibGfx/Color: Use luminosity to compute grayscale value
Issue #9758 discusses this.
2021-09-03 01:51:05 +02:00
Luke Wilde
b275b8c87a LibWeb: Check target's root instead of target itself in EventDispatcher
This was accidentally missing ".root()": "or parent is a node and
target’s _root_ is a shadow-including inclusive ancestor of parent"

https://dom.spec.whatwg.org/#concept-event-dispatch Step 5.9.6
2021-09-02 22:53:19 +02:00
Luke Wilde
f7f37eaa0f LibWeb: Make Node::root return a reference
The root of a node can never be null, as "the root of an object is
itself, if its parent is null, or else it is the root of its parent."

https://dom.spec.whatwg.org/#concept-tree-root
2021-09-02 22:53:19 +02:00
Musab Kılıç
7f46022e66 LibVT: Execute DragOperation after resetting active hyperlink 2021-09-02 22:48:10 +02:00
Sam Atkins
1ccf10789e LibWeb+WebContent: Add query for hovered DOM node to OOPWV
This is needed for the "Inspect Element" context menu action.
2021-09-02 22:16:41 +02:00
Sam Atkins
3b07f49d48 LibWeb+WebContent: Implement asynchronous DOM Node properties call
This lets us "push" a new style-properties list to the DOM Inspector,
for example when JS changes the style of the inspected node.
2021-09-02 22:16:41 +02:00
Sam Atkins
f381f8d63e LibWeb+WebContent: Add inspect_dom_node() IPC call
This is the IPC version of `Document::set_inspected_node()`, using a
node ID.

We return the inspected node's style properties as JSON, so that the DOM
Inspector can immediately display them.
2021-09-02 22:16:41 +02:00
Sam Atkins
e824454ab4 LibWeb: Implement DOMTreeModel::index_for_node()
This will be used to find the index to select when the DOM Inspector is
told to inspect a specific node.
2021-09-02 22:16:41 +02:00
Sam Atkins
fe820f6d5a LibWeb: Replace unused DOMTreeModel with DOMTreeJSONModel
The direct-Document-access DOMTreeModel is no longer used, since the DOM
Inspector has to access the Document remotely over IPC. This commit
removes it, and renames DOMTreeJSONModel to take its place, since it no
longer has to differentiate itself from the non-JSON one.

In case that didn't make sense:
- Delete DOMTreeModel
- Rename DOMTreeJSONModel -> DOMTreeModel
2021-09-02 22:16:41 +02:00
Sam Atkins
57ee7b3d56 LibWeb: Modify StylePropertiesModel to work with JSON
Now that the DOM Inspector communicates remotely with the web content,
we can't read the `StyleProperties` object from a `Node` directly, but
will receive JSON over IPC. This updates the model to match.
2021-09-02 22:16:41 +02:00
Sam Atkins
1159eefff3 LibWeb: Include DOM Node ID in serialized JSON
This will be used in the DOM Inspector to communicate which node is
being inspected.
2021-09-02 22:16:41 +02:00
Sam Atkins
d7485df928 LibWeb: Give each Node a unique ID
We maintain a directory of ID -> Node. Nodes add themselves to this
directory when they are created, receiving a random ID. When a Node is
destroyed, it removes itself from this directory. Anyone can request a
Node from the directory by its ID using `Node::from_id()`.

We reserve the `0` ID to mean "none".

These IDs allow different processes to communicate about a given Node
over IPC, for example the DOM Inspector.
2021-09-02 22:16:41 +02:00
Sam Atkins
48a2239f60 LibWeb: Remove commented-out dbgln
This is unrelated to the PR I'm working on, but keeps getting
reformatted because clang-format wants comments to start with a space.
2021-09-02 22:16:41 +02:00
Linus Groh
3492fbf9cf LibJS: Account for negative numbers in ToTemporalDurationRecord
This is a normative change in the Temporal spec.

See: https://github.com/tc39/proposal-temporal/commit/fa9d547
2021-09-02 20:16:44 +01:00
Linus Groh
0e6d503317 LibJS: Throw RangeError for non-integral values in ToPartialDuration
This is a normative change in the Temporal spec.

See: https://github.com/tc39/proposal-temporal/commit/895c8e5
2021-09-02 20:16:44 +01:00
Linus Groh
7acd174c85 LibJS: Reflect normative changes in ParseTemporalInstantString
Most of it doesn't affect us yet as the parsing code and additional AOs
are not implemented yet.

See: https://github.com/tc39/proposal-temporal/commit/f6ac475
2021-09-02 20:16:44 +01:00
Luke Wilde
c20669328d LibJS: Handle +Infinity, -Infinity, +0 and -0 in modulo operator
Fixes 11 test262 cases.
2021-09-02 18:26:42 +01:00
Timothy Flynn
32825107de LibJS: Implement Intl.Locale.prototype.region 2021-09-02 17:56:42 +01:00
Timothy Flynn
349fd06b86 LibJS: Implement Intl.Locale.prototype.script 2021-09-02 17:56:42 +01:00
Timothy Flynn
c3b6f43641 LibJS: Implement Intl.Locale.prototype.language 2021-09-02 17:56:42 +01:00
Timothy Flynn
bdf36575c8 LibJS: Implement Intl.Locale.prototype.numeric 2021-09-02 17:56:42 +01:00
Timothy Flynn
d7825f3680 LibJS: Implement most Intl.Locale.Prototype.<<keyword>> properties
The keyword accessors all have the same function body in the spec,
except for the Intl.Locale method they invoke. This generates those
properties in the same manner as RegExp.prototype.

    Intl.Locale.prototype.calendar
    Intl.Locale.prototype.caseFirst
    Intl.Locale.prototype.collation
    Intl.Locale.prototype.hourCycle
    Intl.Locale.prototype.numberingSystem

The exception is Intl.Locale.prototype.numeric, which will be defined
separately because it is a boolean value.
2021-09-02 17:56:42 +01:00
Timothy Flynn
21b3c5edba LibJS: Implement Intl.Locale.prototype.baseName 2021-09-02 17:56:42 +01:00
Timothy Flynn
27fc3cfe75 LibJS: Handle existing Intl.Locale objects in CanonicalizeLocaleList 2021-09-02 17:56:42 +01:00
Timothy Flynn
4de05faa8a LibJS: Add test cases for Intl.Locale.prototype.toString
Intl.Locale.prototype.toString wasn't testable before the constructor
was implemented.
2021-09-02 17:56:42 +01:00
Timothy Flynn
17639a42ae LibJS: Implement the Intl.Locale constructor 2021-09-02 17:56:42 +01:00
Timothy Flynn
990dd037d2 LibJS: Implement Intl.Locale.prototype.toString()
This isn't particularly testable yet without the Intl.Locale constructor
but having this defined will make testing the constructor possible. So
more specific tests for this prototype will come later.
2021-09-02 17:56:42 +01:00
Timothy Flynn
940c023e09 LibJS: Compare Unicode locale variants using case-insensitive matching
In the IsStructurallyValidLanguageTag AO, we of course cannot assume the
variants are canonicalized to lower-case yet, because canonicalization
hasn't happened yet.
2021-09-02 17:56:42 +01:00
Timothy Flynn
fdedb3ab33 LibJS: Remove duplicated error message from ErrorTypes.h
ErrorType::IntlInvalidCode has almost exactly the same message as
ErrorType::OptionIsNotValidValue. Remove it, as all uses of the former
are semantically interchangeable with the latter.
2021-09-02 17:56:42 +01:00
Timothy Flynn
21c4922ac0 LibUnicode: Add helper methods to LocaleID and LanguageID for LibJS
Add a method to remove an extension type from the locale's extension set
and methods to convert a locale and language to a string without
canonicalization. Each of these will be used by LibJS.
2021-09-02 17:56:42 +01:00