Commit Graph

730 Commits

Author SHA1 Message Date
Karol Kosek
620e4fd0d2 WebContent: Pass an empty bitmap object if the pointer is null
Prior this commit we were always dereferencing the image bitmap pointer,
even if it was null, which resulted in a crash when trying to open
the context menu when an image wasn't loaded.

Closes: #10178
2021-09-22 22:10:11 +02:00
Andreas Kling
4f224b15ed CrashDaemon+CrashReporter: Streamline crash reporting a little bit
Before this patch, this is what would happen after something crashed:

1. CrashDaemon finds a new coredump in /tmp
2. CrashDaemon compresses the new coredump (gzip)
3. CrashDaemon parses the uncompressed coredump and prints a backtrace
4. CrashDaemon launches CrashReporter
5. CrashReporter parses the uncompressed coredump (again)
6. CrashReporter unlinks the uncompressed coredump
7. CrashReporter displays a GUI

This was taking quite a long time when dealing with large programs
crashing (like Browser's WebContent processes.)

The new flow:

1. CrashDaemon finds a new coredump in /tmp
2. CrashDaemon mmap()'s the (uncompressed) coredump
3. CrashDaemon launches CrashReporter
4. CrashDaemon goes to sleep for 3 seconds (hack alert!)
5. CrashReporter parses the (uncompressed) coredump
6. CrashReporter unlinks the (uncompressed) coredump
7. CrashReporter displays a GUI
8. CrashDaemon wakes up (after step 4)
9. CrashDaemon compresses the coredump (gzip)

TL;DR: we no longer parse the coredumps twice, and we also prioritize
launching the CrashReporter GUI immediately when a new coredump shows
up, instead of compressing and parsing it in CrashDaemon first.

The net effect of this is that you get a backtrace on screen much
sooner. That's pretty nice. :^)
2021-09-21 20:52:29 +02:00
David Isaksson
f261b68408 WindowServer: Apply screen scaling when getting bitmap around cursor
This fixes an issue for the magnifier that when the screen scaling is
increased to 2 the magnifier doesn't center around the cursor.

Since booting Serenity with multiple displays doesn't work at the moment
the rescaling is only added for the one display case.
2021-09-20 22:25:24 +02:00
Ali Mohammad Pur
81a0301d4d LibCore+RequestServer: Ignore callbacks for cancelled network jobs
Also cancel the jobs when they're destroyed.
This makes sure that jobs whose owners have discarded don't end up
crashing because of a did_fail().
2021-09-19 21:10:23 +04:30
Ali Mohammad Pur
65f7e45a75 RequestServer+LibHTTP+LibGemini: Cache connections to the same host
This makes connections (particularly TLS-based ones) do the handshaking
stuff only once.
Currently the cache is configured to keep at most two connections evenly
balanced in queue size, and with a grace period of 10s after the last
queued job has finished (after which the connection will be dropped).
2021-09-19 21:10:23 +04:30
Brian Gianforcaro
4a53c66b7f FileSystemAccessServer: Only compute basename when prompting
pvs-studio flagged this as a potential performance optimization,
we only need to compute the basename when it's used.
2021-09-16 17:17:13 +02:00
Tetsui Ohkubo
eb326db028 FileOperation: Deduplicate destination file names on copy
When there is a file with the same name in the destination directory,
FileManager overwrites that file without any warning. With this change,
such a file will be automatically renamed to "emoji-2.txt", for example.

Also, currently there is a check in FileManager that makes copy and
paste of a file in the same directory no-op. This change removes that
check, because it is no longer a problem.
2021-09-13 18:08:34 +04:30
kleines Filmröllchen
3f067f8457 AudioServer: Fix deadlock when playing two audio streams
Previously, AudioServer would deadlock when trying to play another audio
stream, i.e. creating a queue. The m_pending_cond condition was used
improperly, and the condition wait now happens independently of querying
the pending queue for new clients if the mixer is running.

To make the mixer's concurrency-safety code more readable, the use of
raw POSIX mutex and condition syscalls is replaced with Threading::Mutex
and Threading::ConditionVariable.
2021-09-12 23:38:57 +02:00
kleines Filmröllchen
bd17da9f9e Audio: Add per-client volume
Note: While ClientAudioStream has had a volume property, it is only now
used in the mixer.
2021-09-12 23:38:57 +02:00
kleines Filmröllchen
5300c9e6b4 AudioServer: Rename BufferQueue to ClientAudioStream
Although the old name is more technically correct, it doesn't reflect
what the class is actually doing in the context of the audio server
logic.
2021-09-12 23:38:57 +02:00
kleines Filmröllchen
152ec28da0 Audio: Change how volume works
Across the entire audio system, audio now works in 0-1 terms instead of
0-100 as before. Therefore, volume is now a double instead of an int.
The master volume of the AudioServer changes smoothly through a
FadingProperty, preventing clicks. Finally, volume computations are done
with logarithmic scaling, which is more natural for the human ear.

Note that this could be 4-5 different commits, but as they change each
other's code all the time, it makes no sense to split them up.
2021-09-12 23:38:57 +02:00
Brian Gianforcaro
8476ad2e18 ChessEngine: Use ElapsedTimer::start_new() 2021-09-12 17:24:44 +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
Timothy Flynn
1139aa45b6 WebContent: Use ErrorType::NotAnObjectOfType instead of NotA 2021-09-12 00:16:39 +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
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
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
7684e4f726 WindowServer: Fix 'sticky' mouse after resize
This fixes #9933 and some dead code I accidentally left over.
Thanks, @Maato!
2021-09-10 22:09:23 +02:00
Mustafa Quraish
2a968e92f0 FileSystemAccessServer: Allow read-only access without prompting
This commit adds a new request to the FileSystemAccessServer
endpoint, allowing the clients to get read-only access to a file
without getting a Dialog-box prompting the user for access.

This is only meant to be used in cases where the user has asked
specifically to open a file through the command-line arguments.
In those cases, I believe it makes sense for the read-only access
to be implicit. Always prompting the user gets a bit annoying,
especially if you just quickly want to open a file through the CLI.

The new request name has been made extremely specific to make sure
that it's only used when appropriate.
2021-09-10 20:46:50 +04:30
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
Andreas Kling
90cdeebfb3 LibWeb: Rename DOM::Window::document() => associated_document()
Match the spec nomenclature.
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
e91edcaa28 LibWeb: Rename InitialContainingBlockBox => InitialContainingBlock
The "Box" suffix added nothing here.
2021-09-08 11:27:46 +02:00
Andreas Kling
9d9500989a LibWeb: Remove unused PageClient::is_multi_process() 2021-09-08 11:07:14 +02:00
Andreas Kling
9d03ea6f74 LibWeb+WebContent: Port DumpLayoutTree to OutOfProcessWebView
This required adding a simple OOPWV::dump_layout_tree() API that
synchronously requests a dump of the layout tree from the WebContent
process.
2021-09-08 11:07:14 +02:00
Ben Wiederhake
c6e56612f5 LibGUI+WindowServer: Remove now-obsolete cursor tracking feature
This feature was problematic for several reasons:
- Tracking *all* the user activity seems like a privacy nightmare.
- LibGUI actually only supports one globally tracking widget per window,
  even if no window is necessary, or if multiple callbacks are desired.
- Widgets can easily get confused whether an event is actually directed
  at it, or is actually just the result of global tracking.

The third item caused an issue where right-clicking CatDog opened two
context menus instead of one.
2021-09-08 10:53:49 +02:00
Ben Wiederhake
45126655cd LibGUI+WindowServer: Introduce new mouse tracking mechanism 2021-09-08 10:53:49 +02:00
Liav A
74c4c864bd Kernel+SystemServer: Simplify the DevTmpFS design
We are no longer have a separate Inode object class for the pts
directory. With a small exception to this, all chmod and chown code
is now at one place.
It's now possible to create any name of a sub-directory in the
filesystem.
2021-09-08 00:42:20 +02:00
Liav A
a7cb2ca1bf SystemServer: Don't rely on fstab to specify where to mount the ProcFS
For now, just hardcode the mounting in SystemServer code.
2021-09-08 00:42:20 +02:00
Liav A
f52d102270 SystemServer: Traverse sub-directories in /sys/dev
While traversing in both /sys/dev/char and /sys/dev/block, SystemServer
populates the DevFS (mounted normally in /dev) with the corresponding
device nodes.

This is a very crude implementation of populating DevFS device nodes,
before we have a full-fledged udev-like daemon to take care of this
task. Also, we don't populate DiskPartition device nodes yet, because
that requires more sophisticated mechanism to figure out which
DiskPartition is related to which StorageDevice.
2021-09-08 00:42:20 +02:00
Liav A
e0d712c6f7 Kernel+SystemServer: Defer creation of device nodes to userspace
Don't create these device nodes in the Kernel, so we essentially enforce
userspace (SystemServer) to take control of this operation and to decide
how to create these device nodes.

This makes the DevFS to resemble linux devtmpfs, and allows us to remove
a bunch of unneeded overriding implementations of device name creation
in the Kernel.
2021-09-08 00:42:20 +02:00
Sam Atkins
e255b5dd31 LibWeb+WebContent: Remove old console-logging IPC calls
This patch removes the following WebContent IPC calls, which are no
longer used:

- `Server::js_console_initialize()`
- `Client::did_js_console_output()`
2021-09-06 18:20:26 +02:00
Sam Atkins
95aa6562db Browser+WebContent: Initialize WebContentConsoleClient earlier
With this patch, we now initialize the `WebContentConsoleClient` as soon
as the Page has loaded, instead of waiting for the Console Window to be
shown. This finally lets us see log messages that happened before the
window was opened! :^)

However, it is not perfect. Waiting until the page has loaded means we
lose any messages that happen *during* page load. Ideally we would
initialize the WCCC when the page *starts* loading instead, but it
requires that the page has a document and interpreter assigned and
accessible. As far as I can tell with my limited knowledge, this is not
the case until the page has completed loading.
2021-09-06 18:20:26 +02:00
Sam Atkins
f6a927fa20 WebContent: Store messages in WebContentConsoleClient
The `WebContentConsoleClient` now keeps a list of console messages it
has received, so these are not lost if the ConsoleWidget has not been
initialized yet.

This change does break JS console output, but only until the next
commit. :^)
2021-09-06 18:20:26 +02:00
Sam Atkins
c619a57cf8 LibWeb+WebContent: Add new console-message IPC calls
This patch introduces three new IPC calls for WebContent:

- `Client::did_output_js_console_message(index)`:
  Notifies the client that a new console message was logged.

- `Server::js_console_request_messages(start_index)`:
  Ask the server for console messages starting at the given index.

- `Client::did_get_js_console_messages(start_index, types, messages)`:
  Send the client the messages they requested.

This mechanism will replace the current
`Client::did_js_console_output()` call in the next few commits. This
will allow us to display messages in the console that happened before
the console was opened.
2021-09-06 18:20:26 +02:00
Sam Atkins
5220d6d2e5 WebContent: Implement $0 special variable in Browser JS Console
`$0` is a helpful variable in other browsers' JS consoles, which points
to whichever DOM Node is currently selected in the DOM Inspector. And
now we have it too! :^)
2021-09-06 18:20:26 +02:00
Sam Atkins
7838eab341 WebContent: Implement ConsoleGlobalObject which proxies to WindowObject
ConsoleGlobalObject is used as the global object when running javascript
from the Browser console. This lets us implement console-only functions
and variables (like `$0`) without exposing them to webpage content. It
passes other calls over to the usual WindowObject so any code that would
have worked in the webpage will still work in the console. :^)
2021-09-06 18:20:26 +02:00
Ali Mohammad Pur
97e97bccab Everywhere: Make ByteBuffer::{create_*,copy}() OOM-safe 2021-09-06 01:53:26 +02:00
Ali Mohammad Pur
3a9f00c59b Everywhere: Use OOM-safe ByteBuffer APIs where possible
If we can easily communicate failure, let's avoid asserting and report
failure instead.
2021-09-06 01:53:26 +02:00
Brian Gianforcaro
5905d2e9e9 RequestServer: Exit early to avoid executing protocol destructors
I broke this when I made the protocol objects be wrapped by smart
pointers to appease static analysis.

The Protocol base class currently VERIFY's that it's never called.
So to have the best of both worlds until someone actually fixes
the code to do proper de-registration, just call `exit(..)` so the
smart pointers never go out of scope.
2021-09-05 20:12:09 +02:00
Andreas Kling
363c78e5d2 LookupServer: Use HashMap::ensure() in load_etc_hosts() 2021-09-04 20:30:56 +02:00
Mustafa Quraish
30e91ecff6 Cursors: Add new Magnifying glass cursor
There are a few places in the system where this could be useful,
such as PixelPaint and the MandelBrot demo. It seems general enough
that it is probably useful to have it as a system-wide cursor rather
than loading it manually each time.
2021-09-04 03:35:23 +02:00
Mustafa Quraish
30ce1d8562 Cursors: Add new Eyedropper cursor
This can be used immediately in PixelPaint (separate commit), but
I am adding this as a system-wide cursor since it may also be useful
for other applications that want to use it.
2021-09-04 03:35:23 +02:00
Sam Atkins
e2c32a6c65 Everywhere: Use my shiny new serenityos.org email :^) 2021-09-03 12:22:36 +02:00
Sam Atkins
1ccf10789e LibWeb+WebContent: Add query for hovered DOM node to OOPWV
This is needed for the "Inspect Element" context menu action.
2021-09-02 22:16:41 +02:00
Sam Atkins
3b07f49d48 LibWeb+WebContent: Implement asynchronous DOM Node properties call
This lets us "push" a new style-properties list to the DOM Inspector,
for example when JS changes the style of the inspected node.
2021-09-02 22:16:41 +02:00
Sam Atkins
f381f8d63e LibWeb+WebContent: Add inspect_dom_node() IPC call
This is the IPC version of `Document::set_inspected_node()`, using a
node ID.

We return the inspected node's style properties as JSON, so that the DOM
Inspector can immediately display them.
2021-09-02 22:16:41 +02:00
sin-ack
8ea22121ac Userland: Migrate to argument-less deferred_invoke
Only one place used this argument and it was to hold on to a strong ref
for the object. Since we already do that now, there's no need to keep
this argument around since this can be easily captured.

This commit contains no changes.
2021-09-02 03:47:47 +04:30