Commit graph

27155 commits

Author SHA1 Message Date
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
Andreas Kling
dd82f68326 Kernel: Use KString all the way in sys$execve()
This patch converts all the usage of AK::String around sys$execve() to
using KString instead, allowing us to catch and propagate OOM errors.

It also required changing the kernel CommandLine helper class to return
a vector of KString for the userspace init program arguments.
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
Rodrigo Tobar
430e5d27aa Ports: Fix compilation of python3 socket module 2021-09-09 17:51:15 +01:00
Mustafa Quraish
d9832f8d0b PixelPaint: Add Fit Image To View action
This is a feature I missed from Photoshop: it sets the scale and
position so that the image fits (it's longest dimension) into
the editor view. There's a 5% border left around the image to
provide context. This is just arbitrary seemed like the right
amount after some trial and error.
2021-09-09 11:35:50 +02:00
Mustafa Quraish
111ef19114 PixelPaint: Add "Brush Mode" to EraseTool :^)
Previously EraseTool would only let you have hard lines, similar
to PenTool. After inheriting from BrushTool in previous commits,
making the eraser (optionally) behave like a brush is much easier.

We only need to change how the colors are handled for the hardness,
which is why the `draw_point()` call is a bit more involved. Just
blending the colors doesn't work here since we actually want to
replace the previous color, unlike in BrushTool where we are just
layering the color on top.
2021-09-09 11:35:50 +02:00
Mustafa Quraish
ec73247e90 PixelPaint: Make EraseTool inherit from BrushTool
This removes all the code to handle events that was essentially
duplicated from BrushTool anyway :^)

I've also renamed "thickness"->"size" to have consistent
terminology.
2021-09-09 11:35:50 +02:00
Mustafa Quraish
160bd33874 PixelPaint: Make PenTool inherit from BrushTool
Most of the logic implemented in PenTool was the same as BrushTool
anyway, with the only difference being how the actual lines were
drawn at the end. We now just override the `draw_line()` and
`draw_point()` methods instead.

We don't strictly need to override `draw_line()` here, but that
would just result in repeated calls to `draw_point()`, which is
wasteful.

Also renamed "thickness"->"size" to have consistent terminology.
2021-09-09 11:35:50 +02:00
Mustafa Quraish
fbfa6543ab PixelPaint: Reoriganize drawing in BrushTool to allow more code reuse
The BrushTool is very cool, but it doesn't allow us to re-use any
of the code in other classes. Many of the other tools have duplicated
code for handling mouse events / keeping track of previous location,
etc.

This commit sets up BrushTool so that other tools can inherit from
it and override some virtual functions to allow similar behavior
without re-writing the code to keep track of mouse positions, etc.
In particular, we add public setters/getters for `size` and
`hardness` properties, and make `draw_point()` and `draw_line()`
virtual so that derived classes can override them.

Note: We still pass in `color` as a parameter for `draw_line()` and
`draw_point()` instead of using `color_for()` directly because it
doesn't really make sense to be constantly asking the ImageEditor
for the color when it's not really changing (for instance along all
the points of a line)
2021-09-09 11:35:50 +02:00
Mustafa Quraish
30df74b015 PixelPaint: Allow drawing line between 2 points with BrushTool
Sometimes you want to draw a straight line between 2 points, but
using the nice-looking brush we have instead of the hard line we
would get using the LineTool.

This patch adds the ability to click somewhere with the brush, and
then Shift+click somewhere else to draw a line between the two
points using the brush stroke. Seems like an obvious addition
considering we already have a helper function to draw lines :^)
2021-09-09 11:35:50 +02:00
Rodrigo Tobar
a0ac5c5fc2 Kernel: Define INADDR_BROADCAST constant
This is required by some programs, notably python's socket module, which
fails to compile without this definition.
2021-09-09 11:33:45 +02:00
Ralf Donau
ec03f29fd1 Kernel/VFS: Restrict special unveil rule for Loader.so 2021-09-09 11:32:16 +02:00
Mustafa Quraish
3bf204fd03 PixelPaint: Fix BucketTool out of memory crashes
The BFS implementation for BucketTool's flood-fill had sitations
which could result in infinite loop, causing OOM crashes due to
the queue growing unbounded. The way to fix this is to keep track
of the pixels we have already visited in the flood-fill algorithm
and ignore those if we ever encounter them again.

This also fixes the crashing issue from #9003. We still need a
better way to account for transparency, but that is beyond the scope
of this commit, and this issue still exists without any transparent
pixels.
2021-09-09 11:27:48 +02: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
1c78ff1b9f 3DFileViewer: Use unveil and FileSystemAccessServer
This will restrict 3DFileViewer's access to the file system.

3DFileViewer loads a texture based on the path of the model loaded, this
will request access to the texture file before loading.
2021-09-09 02:34:29 +02: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
Karol Kosek
eb5320023a HackStudio: Preserve the untitled filename text on file modification
Previously, the title of an unnamed file would just disappear from
the editor label if you started typing.
2021-09-09 02:33:18 +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
Ben Wiederhake
9c3da7a3e3 Pong: Switch to global tracking
When I play Pong, I don't really pay attention to whether my mouse is in
the Pong window. That means that sometimes, annoyingly, the window loses
my mouse, and I lose control of the paddle. Gasp! D:

This commit teaches Pong the wonders of global mouse tracking, thus
enabling the player to focus solely on the game.
2021-09-08 23:59:08 +02: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
32a2a02489 LibUnicode: Fix typo in listPatterns.json parsing method 2021-09-08 21:08:48 +01:00