Commit Graph

5060 Commits

Author SHA1 Message Date
Callum Walker
fd3735199b LibCore: Fix link_file inverting src and dst paths on duplicate names
File::link_file takes the dst_path then the src_path so on duplicate
names we tried to create a link at the original file location, which
then flipped the parameters back round again and we ended up with a
broken link from "dst_path (1)" to "src_path (1)".
2021-09-12 04:58:22 +00:00
Andreas Kling
19de6bb1cc LibWeb+Browser: Add Debug menu action for toggling Same-Origin Policy
Sometimes it's useful to turn off the SOP for testing purposes.
Let's make that easy by having a Debug menu item for it. :^)
2021-09-12 02:13:28 +02:00
Luke Wilde
1927600852 LibWeb: Add the History object and stub pushState and replaceState
The spec allows us to optionally return from these for any reason.
Our reason is that we don't have all the infrastructure in place yet to
implement them.
2021-09-12 01:41:44 +02:00
Luke Wilde
3eca8cb243 LibWeb: Add Document::is_fully_active
This is used in a bunch of places in the HTML spec. The current use
case for this is History.
2021-09-12 01:41:44 +02:00
Timothy Flynn
f5c988b3ce LibJS: Convert MapIterator.prototype to be a PrototypeObject 2021-09-12 01:40:56 +02:00
Timothy Flynn
77efecadf7 LibJS: Convert Map.prototype to be a PrototypeObject 2021-09-12 01:40:56 +02:00
Timothy Flynn
9e57ea71af LibJS: Convert GeneratorObject.prototype to be a PrototypeObject
The added #include in GeneratorObject.h is to resolve usage of
Bytecode::RegisterWindow.
2021-09-12 01:40:56 +02:00
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
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
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
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