Commit Graph

8713 Commits

Author SHA1 Message Date
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
Karol Kosek
cf71805aa8 HackStudio: Reuse TextDocument::is_modified()
Previously, the modification tag in the editor file label was unset only
after a file was saved.

This commit will also unset the tag if you undo the stack (for example
by hitting Ctrl+Z) to the last saved state.
2021-09-10 00:00:53 +02: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
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
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