Commit Graph

21 Commits

Author SHA1 Message Date
Andreas Kling
18c54d8d40 LibJS: Make Cell::initialize() return void
Stop worrying about tiny OOMs.

Work towards #20405
2023-08-08 07:39:11 +02:00
Kenneth Myhra
dcbe927b48 LibWeb: Make factory method of Selection::Selection fallible 2023-02-22 09:55:33 +01:00
Kenneth Myhra
0791195843 LibWeb: Make factory methods of DOM::Range fallible 2023-02-18 00:52:47 +01:00
Timothy Flynn
b75b7f0c0d LibJS+Everywhere: Propagate Cell::initialize errors from Heap::allocate
Callers that are already in a fallible context will now TRY to allocate
cells. Callers in infallible contexts get a FIXME.
2023-01-29 00:02:45 +00:00
Timothy Flynn
2692db8699 LibJS+Everywhere: Allow Cell::initialize overrides to throw OOM errors
Note that as of this commit, there aren't any such throwers, and the
call site in Heap::allocate will drop exceptions on the floor. This
commit only serves to change the declaration of the overrides, make sure
they return an empty value, and to propagate OOM errors frm their base
initialize invocations.
2023-01-29 00:02:45 +00:00
Andreas Kling
b79bc25a1f LibWeb: Use DOM Selection instead of ad-hoc layout tree selection
Before this patch, we were expressing the current selection as a range
between two points in the layout tree. This was a made-up concept I
called LayoutRange (2x LayoutPosition) and as it turns out, we don't
actually need it!

Instead, we can just use the Selection API from the Selection API spec.
This API expresses selection in terms of the DOM, and we already had
many of the building blocks implemented.

To ensure that selections get visually updated when the underlying Range
of an active Selection is programmatically manipulated, Range now has
an "associated Selection". If a range is updated while associated with
a selection, we recompute layout tree selection states and repaint the
page to make it user-visible.
2023-01-12 19:55:10 +01:00
Andreas Kling
3cabd17f9b LibWeb: Add convenient Selection::range() accessor
This is a lot smoother than calling the throwsy get_range_at() API,
especially since we know there at most 1 range in the selection.
2023-01-12 19:55:10 +01:00
Timothy Flynn
834202aeb9 LibWeb: Move setting of Web object prototypes to initialize()
This needs to happen before prototype/constructor intitialization can be
made lazy. Otherwise, GC could run during the C++ constructor and try to
collect the object currently being created.
2023-01-10 16:08:14 +01:00
Linus Groh
22089436ed LibJS: Convert Heap::allocate{,_without_realm}() to NonnullGCPtr 2022-12-15 06:56:37 -05:00
Rafał Babiarz
227d860d6b LibWeb: Implement Selection.collapse_to_end 2022-12-10 01:45:21 +01:00
Rafał Babiarz
bb5da1b4e2 LibWeb: Implement Selection.collapse_to_start 2022-12-10 01:45:21 +01:00
Rafał Babiarz
6d46ebfe8a LibWeb: Implement Selection.collapse 2022-12-10 01:45:21 +01:00
Luke Wilde
919aa45017 LibWeb: Implement Selection.setBaseAndExtent 2022-12-10 00:21:10 +00:00
Linus Groh
57dc179b1f Everywhere: Rename to_{string => deprecated_string}() where applicable
This will make it easier to support both string types at the same time
while we convert code, and tracking down remaining uses.

One big exception is Value::to_string() in LibJS, where the name is
dictated by the ToString AO.
2022-12-06 08:54:33 +01:00
Linus Groh
6e19ab2bbc AK+Everywhere: Rename String to DeprecatedString
We have a new, improved string type coming up in AK (OOM aware, no null
state), and while it's going to use UTF-8, the name UTF8String is a
mouthful - so let's free up the String name by renaming the existing
class.
Making the old one have an annoying name will hopefully also help with
quick adoption :^)
2022-12-06 08:54:33 +01:00
Linus Groh
acfb546048 LibWeb: Handle currently ignored WebIDL::ExceptionOr<T>s 2022-10-31 14:12:44 +00:00
Andreas Kling
e77798f5fd LibWeb: Implement a large chunk of the Selection API
This patch implements enough of the Selection API specification
that we stop hitting unimplemented functions when loading Twitter.
2022-10-11 21:49:48 +02:00
Andrew Kaster
4bb6345b2f LibWeb: Remove unecessary dependence on Window from assorted classes
These classes only needed Window to get at its realm. Pass a realm
directly to construct Crypto, Encoding, HRT, IntersectionObserver,
NavigationTiming, Page, RequestIdleCallback, Selection, Streams, URL,
and XML classes.
2022-10-01 21:05:32 +01:00
Andreas Kling
8f2a711132 LibWeb: Make Selection GC-allocated 2022-09-06 00:27:09 +02:00
Andreas Kling
bb547ce1c4 LibWeb: Make AbstractRange and subclasses GC-allocated 2022-09-06 00:27:09 +02:00
Andreas Kling
5c9ca5c2dc LibWeb: Stub out a basic Selection interface
This patch establishes scaffolding for the Selection API.
2021-10-11 00:32:19 +02:00