Commit Graph

27515 Commits

Author SHA1 Message Date
Timothy Flynn
43e4cec3e2 LibJS: Convert FinalizationRegistry.prototype to be a PrototypeObject 2021-09-12 01:40:56 +02:00
Timothy Flynn
94f076a774 LibJS: Convert Date.prototype to be a PrototypeObject 2021-09-12 01:40:56 +02:00
Timothy Flynn
8bfb665b72 LibJS: Convert DataView.prototype to be a PrototypeObject 2021-09-12 01:40:56 +02:00
Timothy Flynn
4d1d0f05a9 LibJS: Convert ArrayIterator.prototype to be a PrototypeObject 2021-09-12 01:40:56 +02:00
Timothy Flynn
bd4c116d08 LibJS: Convert ArrayBuffer.prototype to be a PrototypeObject 2021-09-12 01:40:56 +02:00
Timothy Flynn
696967d7b6 LibJS: Convert WeakSet.prototype to be a PrototypeObject 2021-09-12 01:40:56 +02:00
Timothy Flynn
777ae53615 LibJS: Convert WeakRef.prototype to be a PrototypeObject 2021-09-12 01:40:56 +02:00
Timothy Flynn
966f4faae4 LibJS: Convert WeakMap.prototype to be a PrototypeObject 2021-09-12 01:40:56 +02:00
Timothy Flynn
be0880fb2c LibJS: Convert StringIterator.prototype to be a PrototypeObject 2021-09-12 01:40:56 +02:00
Timothy Flynn
f195cb41a8 LibJS: Convert SetIterator.prototype to be a PrototypeObject 2021-09-12 01:40:56 +02:00
Timothy Flynn
75d5c17aec LibJS: Convert Set.prototype to be a PrototypeObject 2021-09-12 01:40:56 +02:00
Timothy Flynn
a41d0d23f9 LibJS: Convert Promise.prototype to be a PrototypeObject 2021-09-12 01:40:56 +02:00
Timothy Flynn
b749194e70 LibJS: Convert RegExpStringIterator.prototype to be a PrototypeObject 2021-09-12 01:40:56 +02:00
Timothy Flynn
65b0c26c44 LibJS: Convert RegExp.prototype to be a PrototypeObject 2021-09-12 01:40:56 +02:00
Timothy Flynn
1078d5e58a LibJS: Create a class to provide common methods for object prototypes
Almost every JS prototype class defines a static "typed_this" helper to
return the current "this" value as the analogous object type. This adds
a PrototypeObject class to be inserted between the prototype object and
the base Object class to define these methods on the prototype's behalf.

Note that the generated "display_name" method must be defined static
because the callers of typed_this are also static.
2021-09-12 01:40:56 +02:00
Mustafa Quraish
d38d03ce28 PixelPaint: Fit image to view when opened
When opening a file, make it fit on the screen. I think this is
sensible default behaviour.
2021-09-12 00:17:04 +02:00
Mustafa Quraish
f890f8529a PixelPaint: Make Fit Image To View account for rulers
Because of the way rulers are implemented in the ImageEditor
currently, the `Fit Image To View` action doesn't work correctly
with them enabled. This patch makes them adjust to the effective
viewport area and account for the rulers.

This is a bit of a hack, but the correct way to deal with this would
be to put the rulers in a new widget so they don't interfere with
the actual viewport rect (which is being used all over).
2021-09-12 00:17:04 +02:00
Mustafa Quraish
1e1e5bb5f7 PixelPaint: Remove unused methods to access files directly
After transitioning to FileSystemAccessServer, some of the methods
in `MainWidget` and `ProjectLoader` for opening files directly with
a filename as opposed to with a file descriptor are unused. This
commit removes them.
2021-09-12 00:17:04 +02:00
Mustafa Quraish
f337580191 PixelPaint: Use FileSystemAccessServer exclusively, remove unveil
Use the newly added API in FileSystemAccessServer to get read-only
access to a file specified on the commandline. We no longer need to
unveil any image / .pp files on the filesystem :^)
2021-09-12 00:17:04 +02:00
Mustafa Quraish
3141d51164 PixelPaint: Use LibConfig to allow custom pixel grid threshold
Depending on the size / scaling of the UI, someone might want to
change what the threshold is to show the pixel grid. For instance
if you are working on a 50x50 image, and want to see the grid while
still fitting the whole image in the editor.

Since there's no UI for settings in PixelPaint right now, this
commit just uses LibConfig to read the following entry:
    ("PixelPaint", "PixelGrid", "Threshold")
which is then used when drawing the grid.
2021-09-12 00:17:04 +02:00
Mustafa Quraish
451cba8b47 PixelPaint: Don't draw pixel grid outside image bounds
Fixes #9971
2021-09-12 00:17:04 +02:00
Timothy Flynn
6d55e0572d LibJS: Remove ErrorType::NotA and ErrorType::NotAn 2021-09-12 00:16:39 +02:00
Timothy Flynn
470262c8ab LibJS: Use ErrorType::NotAnObjectOfType instead of NotA 2021-09-12 00:16:39 +02:00
Timothy Flynn
9def17d4cb Spreadsheet: Use ErrorType::NotAnObjectOfType instead of NotA 2021-09-12 00:16:39 +02:00
Timothy Flynn
1139aa45b6 WebContent: Use ErrorType::NotAnObjectOfType instead of NotA 2021-09-12 00:16:39 +02:00
Timothy Flynn
c59b97043e LibWeb: Use ErrorType::NotAnObjectOfType instead of NotA 2021-09-12 00:16:39 +02:00
Timothy Flynn
fd8ec1fffa LibJS: Add a variant of ErrorType::NotA named NotAnObjectOfType
This is a clearer name. Subsequent commits will convert files to use the
new name, then the old name will be deleted.
2021-09-12 00:16:39 +02:00
Timothy Flynn
76589d6728 LibJS: Change wording of ErrorType::NotA to be independent of context
Currently, we have NotA and NotAn, to be used dependent on whether the
following word begins with a vowel or not. To avoid this, change the
wording on NotA to be independent of this context.
2021-09-12 00:16:39 +02:00
Andreas Kling
0398089275 LibWeb: Throw SyntaxError on bogus querySelector{,All} input selector 2021-09-11 22:54:26 +02:00
Andreas Kling
935075c26e LibJS: Specify right base for PromiseResolvingElementFunction subclasses 2021-09-11 22:26:53 +02:00
Andreas Kling
971dc44ed3 LibJS: Don't use MarkedValueList in PromiseValueList
Instead, override visit_edges() and mark the values like any other Cell
subclass would.

This makes PromiseValueList play nice with zombification.
2021-09-11 22:16:30 +02:00
Andreas Kling
2253235a0f LibWeb: Revoke outstanding WeakPtrs on wrapper zombification
This fixes an issue with false positives in the GC zombie debugger.
2021-09-11 20:38:45 +02:00
Andreas Kling
0d2c3f62d3 LibJS: Use move semantics more when creating Reference objects
Turns a bunch of FlyString copies into moves.
2021-09-11 20:38:45 +02:00
Idan Horowitz
6704961c82 AK: Replace the mutable String::replace API with an immutable version
This removes the awkward String::replace API which was the only String
API which mutated the String and replaces it with a new immutable
version that returns a new String with the replacements applied. This
also fixes a couple of UAFs that were caused by the use of this API.

As an optimization an equivalent StringView::replace API was also added
to remove an unnecessary String allocations in the format of:
`String { view }.replace(...);`
2021-09-11 20:36:43 +03:00
Idan Horowitz
aba4c9579f Browser: Use String::count instead of String::replace(X, X, true)
There's no need to create a new String just to count the amount of
occurrences of a substring.
2021-09-11 20:36:43 +03:00
Idan Horowitz
6d2b003b6e AK: Make String::count not use strstr and take a StringView
This was needlessly copying StringView arguments, and was also using
strstr internally, which meant it was doing a bunch of unnecessary
strlen calls on it. This also moves the implementation to StringUtils
to allow API consistency between String and StringView.
2021-09-11 20:36:43 +03:00
thankyouverycool
4e40eaf34c TextEditor: Remove wordiness and a separator in View menu
In many cases we can lean on the name of a menu to reduce verbosity.
"View"->"Visualize/Show/Turn on/etc" is a bit redundant and clutters
the menu. It's a little thing, but it makes the system feel more
tightly integrated if we stick to the same word patterns across apps.
2021-09-11 19:22:14 +02:00
thankyouverycool
9a5a9fbee0 LibGUI+TextEditor: Allow cursor line highlighting to be toggled 2021-09-11 19:22:14 +02:00
David Isaksson
a5ff941c86 PixelPaint: Add mouse indicators to the rulers 2021-09-11 19:16:29 +02:00
David Isaksson
242acfcbae LibGfx: Apply translation and scale to Painter::draw_triangle() 2021-09-11 19:16:29 +02:00
David Isaksson
e56764bd74 PixelPaint: Add rulers 2021-09-11 19:16:29 +02:00
David Isaksson
9bc8707cda PixelPaint: Draw guide lines and selections above the pixel grid 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
Mustafa Quraish
69d708fb21 WindowServer: Add IPC endpoint to get the color under cursor
This allows any client to ask the WindowServer to give it the color
of the screen bitmap under the cursor.

There's currently no way to get the screen bitmap *without* the
cursor already drawn on it, so for now we just take a pixel
beside the actual cursor position to avoid just getting the cursors
color.
2021-09-11 19:05:46 +02:00
Mustafa Quraish
3da4fdd0eb Compositor: Add API to get the color of a pixel
This just returns the color of a given pixel position from the
front bitmap of the corresponding screen.
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