Commit Graph

1249 Commits

Author SHA1 Message Date
Andreas Kling
9171aef724 LibGUI: Use SystemColor::Text in more places 2019-12-24 02:25:50 +01:00
Andreas Kling
a3590ca602 LibGUI: Paint GResizeCorner with SystemColor::Window background 2019-12-24 00:21:09 +01:00
Andreas Kling
411058b2a3 WindowServer+LibGUI: Implement basic color theming
Color themes are loaded from .ini files in /res/themes/
The theme can be switched from the "Themes" section in the system menu.

The basic mechanism is that WindowServer broadcasts a SharedBuffer with
all of the color values of the current theme. Clients receive this with
the response to their initial WindowServer::Greet handshake.

When the theme is changed, WindowServer tells everyone by sending out
an UpdateSystemTheme message with a new SharedBuffer to use.

This does feel somewhat bloated somehow, but I'm sure we can iterate on
it over time and improve things.

To get one of the theme colors, use the Color(SystemColor) constructor:

    painter.fill_rect(rect, SystemColor::HoverHighlight);

Some things don't work 100% right without a reboot. Specifically, when
constructing a GWidget, it will set its own background and foreground
colors based on the current SystemColor::Window and SystemColor::Text.
The widget is then stuck with these values, and they don't update on
system theme change, only on app restart.

All in all though, this is pretty cool. Merry Christmas! :^)
2019-12-23 20:33:01 +01:00
Shannon Booth
456a4bc108 LibDraw: Parse all CSS standardised color keywords 2019-12-23 10:56:59 +01:00
Andreas Kling
c1b4e8aef0 LibGUI: Activate GTreeView indexes when double clicking leaf nodes
This seems pretty sensible to me. I'm unsure if we should activate
nodes that have children, or just toggle them.
2019-12-23 10:55:34 +01:00
Andreas Kling
a12c2df43f LibPthread: Okay I'm dumb, let's convert mutex locks into Atomic<u32>& 2019-12-22 20:25:09 +01:00
Andreas Kling
9e3e13e410 LibPthread: Fix typo in pthread_mutex_lock()
We were casting the pthread_mutex_t* instead of pthread_mutex_t::lock
to an Atomic<u32>. This still worked fine, since "lock" is the first
member of pthread_mutex_t.
2019-12-22 17:25:55 +01:00
Andreas Kling
0c97380ee6 LibPthread+LibC: Support PTHREAD_MUTEX_RECURSIVE
This allows SDL to build against our native recursive mutex instead
of providing its own. Also it's just a nice feature to have. :^)
2019-12-22 14:25:41 +01:00
Andrew Kaster
150837e7e8 LibC: Prevent assertions in malloc/free at exit time
This is a bit sad, but, with the Allocators as static globals their
destructors were running before some user code. Which doesn't really
make much sense, as none of the members of (at least the basic one) do
any real heavy lifting or have many resources to RAII.

To avoid the problem, just mmap the memory for the global arrays of
Allocators in __malloc_init and let the Kernel collect the memory when
we're done with the process.
2019-12-22 10:47:39 +01:00
Andrew Kaster
7edfdca4b2 LibGUI: Don't assert in ~GWidgetClassRegistration
These guys are all declared as globals, and their ASSERT_NOT_REACHED
in the destructor doesn't play nice with __cxa_atexit. As in, every
application will assert in __cxa_finalize if this assert isn't removed.
2019-12-22 10:47:39 +01:00
Andrew Kaster
824bbc7462 LibC: Support exit time destructors per the Itanium C++ ABI
Implement __cxa_atexit and __cxa_finalize per the Itanium spec,
and convert stdlib's atexit and exit() to to call them instead of
a custom 'C-only' atexit implementation.
2019-12-22 10:47:39 +01:00
Andreas Kling
270beb5165 LibC: Always install as part of the default target
We always want to put crt0.o in the location where it can get picked
up by the i686-pc-serenity toolchain.

This feels a bit hackish but should get the build working again. :^)
2019-12-20 21:13:53 +01:00
Andreas Kling
842716a0b5 Kernel+LibC: Build with basic -fstack-protector support
Use simple stack cookies to try to provoke an assertion failure on
stack overflow.

This is far from perfect, since we use a constant cookie instead of
generating a random one on startup, but it can still help us catch
bugs, which is the primary concern right now. :^)
2019-12-20 21:03:32 +01:00
Andreas Kling
6ec46aad66 LibC: Make sure we build crt0.o 2019-12-20 20:36:53 +01:00
joshua stein
ac25438d54 Build: clean up build system, use one shared Makefile
Allow everything to be built from the top level directory with just
'make', cleaned with 'make clean', and installed with 'make
install'.  Also support these in any particular subdirectory.

Specifying 'make VERBOSE=1' will print each ld/g++/etc. command as
it runs.

Kernel and early host tools (IPCCompiler, etc.) are built as
object.host.o so that they don't conflict with other things built
with the cross-compiler.
2019-12-20 20:20:54 +01:00
Sergey Bugaev
d91c40de3b LibC: Make empty malloc blocks purgeable 2019-12-20 20:19:46 +01:00
Andreas Kling
cfcb38dff1 WindowServer+LibGUI: Add data_type and data fields to drag operations
These fields are intended to carry the real meat of a drag operation,
and the "text" is just for what we show on screen (alongside the cursor
during the actual drag.)

The data field is just a String for now, but in the future we should
make it something more flexible.
2019-12-20 20:07:10 +01:00
Andreas Kling
af7cb7ce1b LibGUI: GWidget::drop_event() should ignore the event by default
This will cause the event to bubble up the widget tree.
2019-12-20 20:07:10 +01:00
Andreas Kling
c0e81b26b6 LibHTML: Ignore layout repaints outside the visible viewport
Now that Frame knows the visible viewport rect, it can easily ignore
repaint requests from e.g <blink> elements that are not currently
scrolled into view. :^)
2019-12-18 22:16:27 +01:00
Andreas Kling
1aea8f116b LibHTML: Add TreeNode::for_each_in_subtree_of_type<T>()
This allows you to iterate a subtree and get a callback for every node
where is<T>(node) == true. This makes for quite pleasant DOM traversal.
2019-12-18 21:34:03 +01:00
Andreas Kling
54bd322881 LibHTML: Mark image bitmaps outside the visible viewport as volatile
When the visible viewport rect changes, we walk the layout tree and
check where each LayoutImage is in relation to the viewport rect.
Images outside have their bitmaps marked as volatile.

Note that the bitmaps are managed by ImageDecoder objects. If a bitmap
is purged by the kernel while volatile, we construct a new ImageDecoder
next time we need pixels for the image.
2019-12-18 21:19:04 +01:00
Andreas Kling
7e068565bc LibHTML: Push the visible viewport rect from HtmlView to Frame
This will allow various mechanisms and optimizations based on the
currently visible viewport rect.
2019-12-18 20:54:23 +01:00
Andreas Kling
85ac9705ba LibHTML: Add LayoutNode::is_image() and is<LayoutImage> helper 2019-12-18 20:52:36 +01:00
Andreas Kling
7cc4b90b16 LibDraw: Create purgeable GraphicsBitmap in the PNG decoder
Also add ImageDecoder APIs for controlling the volatile flag.
2019-12-18 20:50:58 +01:00
Andreas Kling
77ae98a9b6 LibDraw: Add GraphicsBitmap::create_purgeable()
This allows you to create a process-private purgeable GraphicsBitmap.
The volatile flag is controlled via set_volatile() / set_nonvolatile().
2019-12-18 20:50:05 +01:00
Andreas Kling
487f9b373b Kernel: Add MADV_GET_VOLATILE for checking the volatile flag
Sometimes you might want to know if a purgeable region is volatile.
2019-12-18 20:48:24 +01:00
Sergey Bugaev
1ad5568759 LibC: Store empty malloc blocks in an array instead of a linked list 2019-12-18 19:02:25 +01:00
Andreas Kling
0d6f186397 LibHTML: Insert a new linebox for every newline in "white-space: pre" 2019-12-18 12:44:16 +01:00
Andreas Kling
1fda417f4f LibHTML: Ignore case of presentation attribute names 2019-12-18 12:44:13 +01:00
Andreas Kling
4d81bc20d8 LibHTML: Don't insert line breaks between multiple <pre>'s on a line
When iterating lines for "white-space: pre", we should only break when
there is an actual line break character.
2019-12-18 12:44:09 +01:00
Andreas Kling
152c31c5c6 LibHTML: Let's display <basefont> as block-level elements for now 2019-12-18 12:44:06 +01:00
Andreas Kling
33daa80bf0 LibHTML: Use a fixed-width font for <pre> tags, duh! 2019-12-18 12:44:02 +01:00
Andreas Kling
7301db4f9a GTextEditor: Fix broken rendering of selection on wrapped lines
This logic broke when converting String::length() to return size_t.
2019-12-17 21:15:10 +01:00
Andreas Kling
91ba94fbd4 LibHTML: Support the :only-child pseudo class 2019-12-16 19:52:11 +01:00
Andreas Kling
085cafd80a LibHTML: Support the :empty pseudo class 2019-12-16 19:46:02 +01:00
Andreas Kling
a32cae4c3b LibDraw: Parse the color name "pink" to #ffc0cb 2019-12-16 19:45:21 +01:00
Andreas Kling
c1474e594e LibHTML: Support the :first-child and :last-child pseudo classes 2019-12-16 19:34:52 +01:00
Andreas Kling
870df4a8c6 LibGUI: Fix GTreeView crash on pressing Left/Right without selection 2019-12-16 18:26:26 +01:00
Andreas Kling
72bdf595cc LibIPC: Make sure we always process unhandled messages
A client that only ever does synchronous IPC calls from its side would
never actually process incoming asynchronous messages since they would
arrive while waiting for a synchronous response and then end up sitting
forever in the "unhandled messages" queue.

We now always handle unhandled messages using a deferred invocation.

This fixes the bug where Audio.MenuApplet didn't learn that the muted
state changed in response to its own request to change it. :^)
2019-12-16 17:45:57 +01:00
Andreas Kling
df129bbe0e WindowServer+CPUGraph: Make menu applets be "regular" windows
Instead of implementing menu applets as their own thing, they are now
WSWindows of WSWindowType::MenuApplet.

This makes it much easier to work with them on the client side, since
you can just create a GWindow with the right type and you're in the
menubar doing applet stuff :^)
2019-12-16 15:05:45 +01:00
Andreas Kling
77cf607cda Kernel+LibC: Publish a "kernel info page" and use it for gettimeofday()
This patch adds a single "kernel info page" that is mappable read-only
by any process and contains the current time of day.

This is then used to implement a version of gettimeofday() that doesn't
have to make a syscall.

To protect against race condition issues, the info page also has a
serial number which is incremented whenever the kernel updates the
contents of the page. Make sure to verify that the serial number is the
same before and after reading the information you want from the page.
2019-12-15 21:29:26 +01:00
Andreas Kling
5292f6e78f Kernel+FileManager: Disallow watch_file() in unsupported file systems
Currently only Ext2FS and TmpFS supports InodeWatchers. We now fail
with ENOTSUPP if watch_file() is called on e.g ProcFS.

This fixes an issue with FileManager chewing up all the CPU when /proc
was opened. Watchers don't keep the watched Inode open, and when they
close, the watcher FD will EOF.

Since nothing else kept /proc open in FileManager, the watchers created
for it would EOF immediately, causing a refresh over and over.

Fixes #879.
2019-12-15 19:33:39 +01:00
Andreas Kling
7fea25943d LibGUI: Fix GTreeView column headers incorrectly scrolling with content 2019-12-15 18:17:02 +01:00
Andreas Kling
d4a570d576 LibGUI: Fix GTreeView not showing the context menu
This logic is all taken care of by GAbstractColumnView now, so we can
simply delete GTreeView::context_menu_event(). :^)

Fixes an issue mentioned in #826
2019-12-15 17:02:44 +01:00
Andreas Kling
6b71250d1a LibCore: Silence some aggressive CSocket and CHttpJob debug spam 2019-12-14 11:30:18 +01:00
Andreas Kling
bcffe31d3a LibCore: Bump the CHttpJob receive buffer size from 4KB to 64KB
4KB gets pretty mmap/munmap heavy when downloading larger files,
so bump this a bit to reduce time spent in memory allocation.

This can be improved in various ways, but I'm not sure what the
best way forward is at the moment.
2019-12-14 10:01:20 +01:00
Andreas Kling
4d406d5c6d LibGUI: GAbstractColumnModel should never claim to hit a toggle box
Only GTreeView can hit a toggle box in index_at_event_position().
2019-12-14 00:21:51 +01:00
Andreas Kling
561718d88b LibGUI: Improve GTreeView column auto-sizing
Rerun the column auto-sizing algorithm when opening/closing nodes.
Also use the column name as the minimum column width for the tree
column as well.
2019-12-13 23:51:16 +01:00
Andreas Kling
0ac74d3778 LibGUI: Make GTreeView inherit from GAbstractColumnView
This makes GTreeView able to support multi-column models!

Only one column can be the "tree column", this is column 0 by default
but can be changed by overriding GModel::tree_column().
2019-12-13 23:36:36 +01:00
Andreas Kling
b909d991f1 LibDraw: Add a way to check for horizontal/vertical Rect intersections 2019-12-13 23:36:17 +01:00
Andreas Kling
2d39bce3f6 LibGUI: Add a GAbstractColumnView base class for GTableView
Almost everything in GTableView moves up to GAbstractColumnView.
This is in preparation for sharing a base class between GTableView
and GTreeView :^)
2019-12-13 20:54:40 +01:00
Tommy Nguyen
d8b7cd940f TreeView: Clear metadata after model update
When the filesystem model is updated, it is rebuilt. This means dangling
indexes inside the TreeView metadata table will have old information and random
directories will toggle open. Clearing the table alleviates this issue.
2019-12-12 22:41:28 +01:00
Tommy Nguyen
2bd640277e LibGUI: Add missing call to did_update() when updating GFileSystemModel 2019-12-12 22:41:28 +01:00
Andreas Kling
0f393148da Kernel: Separate out the symbol offsets in profile output
Instead of saying "main +39" and "main +57" etc, we now have a separate
field in /proc/profile for the offset-into-the-symbol.
2019-12-12 21:59:47 +01:00
Tommy Nguyen
f26548395e LibGUI: Add context_menu_event to GTreeView 2019-12-12 11:19:02 +01:00
Andreas Kling
b32e961a84 Kernel: Implement a simple process time profiler
The kernel now supports basic profiling of all the threads in a process
by calling profiling_enable(pid_t). You finish the profiling by calling
profiling_disable(pid_t).

This all works by recording thread stacks when the timer interrupt
fires and the current thread is in a process being profiled.
Note that symbolication is deferred until profiling_disable() to avoid
adding more noise than necessary to the profile.

A simple "/bin/profile" command is included here that can be used to
start/stop profiling like so:

    $ profile 10 on
    ... wait ...
    $ profile 10 off

After a profile has been recorded, it can be fetched in /proc/profile

There are various limits (or "bugs") on this mechanism at the moment:

- Only one process can be profiled at a time.
- We allocate 8MB for the samples, if you use more space, things will
  not work, and probably break a bit.
- Things will probably fall apart if the profiled process dies during
  profiling, or while extracing /proc/profile
2019-12-11 20:36:56 +01:00
Andreas Kling
adb1870628 LibHTML: Rename HTMLImageElement::m_image_data => m_encoded_data 2019-12-11 18:30:42 +01:00
Andreas Kling
150090c742 LibGUI: Add GTextDocument::range_for_entire_line() 2019-12-10 22:06:31 +01:00
Andreas Kling
40b7d814c3 LibCore: Make CHttpJob::response() return a CHttpResponse*
We know that the CNetworkResponse inside a CHttpJob is always going to
be a CHttpResponse, so we can return a casted pointer to be nice. :^)
2019-12-10 20:46:33 +01:00
Valtteri Koskivuori
fe1df9e9fb LibC: Implement strtod() 2019-12-10 16:24:47 +01:00
Valtteri Koskivuori
b8ac14a873 LibM: Implement pow() 2019-12-10 16:24:47 +01:00
remyabel
d8daa08359 GTreeView: Prevent doubleclick with right mouse button (#868)
This follows user expectations and prevents interference with context menu
handling.
2019-12-10 10:24:14 +01:00
Andreas Kling
f8ec8cc255 LibGUI: Mark the first GWindow back bitmap volatile immediately
We were previously waiting until the first bitmap buffer flip happened
before marking the back buffer volatile.
2019-12-09 21:33:39 +01:00
Andreas Kling
571c4d3fb8 LibGUI: Allow finding the source of a GAction activation
When a GAction is activated by a menu, or by a toolbar button, you can
now use GAction::activator() to get a pointer to whomever activated it.

This can be used to implement context-specific behaviors in situations
where the same action is exposed through multiple paths.

This addresses an issue that was brought up in #826.
2019-12-09 21:29:43 +01:00
Andreas Kling
fd5eb79d19 LibGUI: Make GMenu inherit from CObject
This is primarily to make it possible to pass a GMenu* where a CObject*
is expected.
2019-12-09 21:05:44 +01:00
Andreas Kling
dfd0daa157 LibGUI: Mark window back buffers as volatile while not painting
We now take advantage of SharedBuffers being purgeable memory by
setting the volatile flag on window back buffers while not painting
into them.

This means that one of the two backing stores used by each window
is purgeable+volatile most of the time, allowing the kernel to purge
it to recover memory if needed.

Note that this is only relevant when double-buffering is turned on,
but since that is the default, this does affect most apps. :^)
2019-12-09 20:08:44 +01:00
Andreas Kling
0317ca5ccc Kernel+LibC: Make all SharedBuffers purgeable (default: non-volatile)
This patch makes SharedBuffer use a PurgeableVMObject as its underlying
memory object.

A new syscall is added to control the volatile flag of a SharedBuffer.
2019-12-09 20:06:47 +01:00
Andreas Kling
92b46d9814 SystemMonitor: Show information about purgeable memory
This patch exposes some fields about purgeable memory regions.
We now also show total purgeable volatile and non-volatile memory in
the big process table.
2019-12-09 19:16:58 +01:00
Andreas Kling
dbb644f20c Kernel: Start implementing purgeable memory support
It's now possible to get purgeable memory by using mmap(MAP_PURGEABLE).
Purgeable memory has a "volatile" flag that can be set using madvise():

- madvise(..., MADV_SET_VOLATILE)
- madvise(..., MADV_SET_NONVOLATILE)

When in the "volatile" state, the kernel may take away the underlying
physical memory pages at any time, without notifying the owner.
This gives you a guilt discount when caching very large things. :^)

Setting a purgeable region to non-volatile will return whether or not
the memory has been taken away by the kernel while being volatile.
Basically, if madvise(..., MADV_SET_NONVOLATILE) returns 1, that means
the memory was purged while volatile, and whatever was in that piece
of memory needs to be reconstructed before use.
2019-12-09 19:12:38 +01:00
Andreas Kling
6f4c380d95 AK: Use size_t for the length of strings
Using int was a mistake. This patch changes String, StringImpl,
StringView and StringBuilder to use size_t instead of int for lengths.
Obviously a lot of code needs to change as a result of this.
2019-12-09 17:51:21 +01:00
Dan MacDonald
91fc6a056b LibC: Add PRIXPTR definition to inttypes.h 2019-12-09 16:33:14 +01:00
Andreas Kling
f5dfb29607 LibGUI+WindowServer: Allow specifying an optional drag bitmap
This bitmap is displayed alongside the dragged text underneath the
mouse cursor while dragging.

This will be a perfect fit for dragging e.g files around. :^)
2019-12-08 17:08:39 +01:00
Andreas Kling
183ee5847c LibDraw: Add GraphicsBitmap::to_shareable_bitmap()
This function returns the bitmap itself if it's already backed by a
SharedBuffer object, otherwise it creates a shareable copy of itself
and returns that.
2019-12-08 17:07:44 +01:00
Andreas Kling
a7f414bba7 LibGUI+WindowServer: Start fleshing out drag&drop functionality
This patch enables basic drag&drop between applications.
You initiate a drag by creating a GDragOperation object and calling
exec() on it. This creates a nested event loop in the calling program
that only returns once the drag operation has ended.

On the receiving side, you get a call to GWidget::drop_event() with
a GDropEvent containing information about the dropped data.

The only data passed right now is a piece of text that's also used
to visually indicate that a drag is happening (by showing the text in
a little box that follows the mouse cursor around.)

There are things to fix here, but we're off to a nice start. :^)
2019-12-08 16:50:23 +01:00
Andrew Kaster
e09a02ad3f SystemMonitor: Show thread name instead of process name
Add the thread name to CThreadStatistics and display it in the
system monitor's process model instead of the process name.
2019-12-08 14:09:29 +01:00
Andrew Kaster
0b38a553b1 LibThread: Allow setting thread name in constructor
Thread now has an optional thread_name parameter to the consturctor
that will call pthread_setname_np if given.
2019-12-08 14:09:29 +01:00
Andrew Kaster
baf7e247e3 LibPThread: Add pthread_set/getname_np
These wrappers call the set_thread_name and get_thread_name syscalls
respectively.
2019-12-08 14:09:29 +01:00
Andreas Kling
7c0fb91ca4 LibAudio: Install library and headers 2019-12-08 11:40:30 +01:00
Andreas Kling
1670ee5aba LibPthread: Condition variables should use CLOCK_MONOTONIC by default
It's the only clock we have at the moment, so it's a logical choice :^)
2019-12-07 16:07:48 +01:00
Andreas Kling
e7dfd40dc3 LibPthread: Mark the pthread_cond_t "waiting" flag as volatile
Oops, this is not gonna work if the compiler can optimize out all the
reads from this flag. :^)
2019-12-07 15:34:00 +01:00
Andreas Kling
96e8c8a4e5 LibPthread: Add stubs for pthread_{get,set}schedparam()
These should be the last thing needed to make SDL build with threads
support. I think we can survive just fine with stubs of these for now,
especially given that the kernel doesn't care super much about thread
priorities anyway.
2019-12-07 15:32:48 +01:00
Andreas Kling
615553be5f LibPthread: Implement simple thread-specific keys
This patch adds pthread_key_create() and pthread_{get,set}specific().
There's a maximum of 64 thread-specific keys for simplicity.

Key destructors are not invoked on thread exit.
2019-12-07 15:21:18 +01:00
Andreas Kling
2b45b7a45c LibPthread: Implement pthread_sigmask() 2019-12-07 14:52:27 +01:00
Andreas Kling
95b086f47f Kernel+LibPthread: Implement pthread_detach() 2019-12-07 14:52:27 +01:00
Andreas Kling
9ddfe694f2 LibPthread: Implement pthread_mutexattr_init() and _destroy() 2019-12-07 14:52:27 +01:00
Andreas Kling
eaab7f5672 LibPthread: Don't set errno in pthread functions
POSIX says that pthread API's don't set errno directly. If there is an
error, it should be the return value from the function instead.
2019-12-07 14:52:27 +01:00
Andreas Kling
babb726212 LibPthread: Implement pthread_mutex_trylock() 2019-12-07 14:52:27 +01:00
Andreas Kling
594c7f2d83 LibPthread: Implement pthread_self() 2019-12-07 14:52:27 +01:00
Andreas Kling
d08061103d LibPthread: Implement pthread_mutex_destroy() 2019-12-07 14:52:27 +01:00
Andreas Kling
cc1ef6dadb LibPthread: Implement condition variables
This feels like a pretty naive implementation, but I think it can work.
Basically each waiter creates an object on its stack that is then
added to a linked list inside by the pthread_cond_t.

Signalling is then done by walking the list and unsetting the "waiting"
flag on as many of the waiters as you like.
2019-12-07 14:52:27 +01:00
Andreas Kling
db2bfe14e9 LibIPC: Install libipc.a into /usr/lib 2019-12-07 14:52:27 +01:00
Andreas Kling
f93c0dc489 LibIPC: Get client/server PIDs using getsockopt(SO_PEERCRED)
Instead of passing the PIDs back and forth in a handshake "Greet"
message, just use getsockopt(SO_PEERCRED) on both sides to get the same
information from the kernel.

This is a nice little simplification of the IPC protocol, although it
does not get rid of the handshake since we still have to pass the
"client ID" from the server to each client so they know how to refer
to themselves. This might not be necessary and we might be able to get
rid of this later on.
2019-12-06 18:39:59 +01:00
Andreas Kling
23e802518d Kernel: Add getsockopt(SO_PEERCRED) for local sockets
This sockopt gives you a struct with the PID, UID and GID of a socket's
peer process.
2019-12-06 18:38:36 +01:00
Andreas Kling
2d18fc8052 LibGUI: Move tooltip window rects if they don't end up on screen
This makes the quick launch button tooltips actually readable. :^)
2019-12-05 17:59:06 +01:00
Sasan Hezarkhani
51262e7e2d GTextEditor: Clear current selection, if any, on set_document() 2019-12-03 12:51:27 +01:00
Sasan Hezarkhani
5c2ef01f7b LibGUI: Expose a function to clear GTextEditor selection 2019-12-03 12:51:27 +01:00
Andreas Kling
d422c46ebb LibC: Also mark empty-but-kept-around BigAllocationBlocks as PROT_NONE
This extends the opportunistic protection of empty-but-kept-around to
also cover BigAllocationBlocks. Since we only cache 4KB BAB's at the
moment, this sees limited use, but it does work.
2019-12-02 20:02:23 +01:00
Andreas Kling
ddd5411472 LibC: Protect empty-but-kept-around ChunkedBlocks with PROT_NONE
We now keep a separate queue of empty ChunkedBlocks in each allocator.
The underlying memory for each block is mprotect'ed with PROT_NONE to
provoke crashes on use-after-free.

This is not going to catch *all* use-after-frees, but if it catches
some, that's still pretty nice. :^)

The malloc memory region names are now updated to reflect their reuse
status: "malloc: ChunkedBlock(size) (free/reused)"
2019-12-02 18:54:12 +01:00
Andreas Kling
e91b2b8f1b WindowServer: Mark clients as misbehaving when they send invalid data
If a client sends an invalid window ID or similar to the WindowServer,
we'll now immediately mark them as misbehaving and disconnect them.

This might be too aggressive in some cases (window management, ...)
but it's just a place to start.
2019-12-02 15:55:14 +01:00
Andreas Kling
af9fd334f3 LibGUI: Don't show "Invalid" for menu items without a keyboard shortcut 2019-12-02 15:54:01 +01:00
Tommy Nguyen
2eb5793d55 LibMarkdown: Handle CRLF line endings
Previously, MDDocument only split on Unix-style line endings. This adds
a new function to StringView which handles LF, CR and CRLF.
2019-12-02 13:52:42 +01:00
Andreas Kling
8ae62c57ee LibIPC: Rename IMessage id/name to message_id/message_name
Hogging "id" and "name" makes it impossible to use these as message
parameter names, which seems silly. :^)
2019-12-02 11:11:05 +01:00
Andreas Kling
b780dcf353 LibDraw: Remove convenience functions for the old WindowServer IPC 2019-12-02 11:11:05 +01:00
Andreas Kling
86504f4461 LibIPC: Don't handle incoming messages right away when draining
When draining the socket in IServerConnection, we would previously
handle each incoming (local endpoint) message as it came in.

This would cause unexpected things to happen while blocked waiting
for a synchronous response. That's definitely not what we want,
so this patch puts all of the incoming messages in a queue and does
a separate pass over the queue to handle everything in order.
2019-12-02 11:11:05 +01:00
Andreas Kling
4a37bec27c LibIPC: Rename base classes to IClientConnection and IServerConnection
This matches what we're already calling the server-side subclasses
better, though we'll probably want to find some better names for the
client-side classes eventually.
2019-12-02 11:11:05 +01:00
Andreas Kling
5d4ee0f58a LibIPC: Move IPC client/server connection templates to LibIPC
Move over the CoreIPC::Server and CoreIPC::Client namespace stuff
into LibIPC where it will soon becomes LibIPC-style things.
2019-12-02 11:11:05 +01:00
Andreas Kling
272d65e3e2 WindowServer: Port to the new IPC system
This patch introduces code generation for the WindowServer IPC with
its clients. The client/server endpoints are defined by the two .ipc
files in Servers/WindowServer/: WindowServer.ipc and WindowClient.ipc

It now becomes significantly easier to add features and capabilities
to WindowServer since you don't have to know nearly as much about all
the intricate paths that IPC messages take between LibGUI and WSWindow.

The new system also uses significantly less IPC bandwidth since we're
now doing packed serialization instead of passing fixed-sized structs
of ~600 bytes for each message.

Some repaint coalescing optimizations are lost in this conversion and
we'll need to look at how to implement those in the new world.

The old CoreIPC::Client::Connection and CoreIPC::Server::Connection
classes are removed by this patch and replaced by use of ConnectionNG,
which will be renamed eventually.

Goodbye, old WindowServer IPC. You served us well :^)
2019-12-02 11:11:05 +01:00
Andreas Kling
5a45376180 Kernel+SystemMonitor: Log amounts of I/O per thread
This patch adds these I/O counters to each thread:

- (Inode) file read bytes
- (Inode) file write bytes
- Unix socket read bytes
- Unix socket write bytes
- IPv4 socket read bytes
- IPv4 socket write bytes

These are then exposed in /proc/all and seen in SystemMonitor.
2019-12-01 17:40:27 +01:00
Andreas Kling
2ece61fa1f LibCore: Improve logging of errors in safe_syscall() somewhat 2019-12-01 16:47:28 +01:00
Andreas Kling
cada332e95 LibPthread: Remove some duplicate declarations in pthread.h 2019-12-01 11:52:52 +01:00
Brandon Scott
fd15c7e8db LibC: Added _PC_VDISABLE option to fpathconf()
This was needed for vttest
2019-12-01 11:52:17 +01:00
Brandon Scott
194f85431f LibVT: Fixed some debugging code that didn't compile 2019-12-01 11:52:17 +01:00
Andreas Kling
d27e5a77e7 GTextEditor: Don't assert is_readonly() in did_change()
This callback will be invoked when calling set_text() to set the
initial contents of a GTextEditor, and that's okay.
2019-11-30 19:11:31 +01:00
Andreas Kling
6f70238a32 GTextEditor: Fire the on_change hook on GTextDocument change 2019-11-30 18:55:07 +01:00
Andreas Kling
a349e7dbda LibVT: Always use Painter::clear_rect() instead of Painter::fill_rect()
We never want to alpha blend when rendering the terminal buffer, so we
can just use clear_rect() and avoid trouble.

This fixes an issue with inconsistent translucency in the terminal app
when setting a custom background opacity.
2019-11-30 18:28:38 +01:00
Andreas Kling
32be9941f4 GTextEditor: Implement Shift+Delete using RemoveTextCommand 2019-11-30 17:19:35 +01:00
Andreas Kling
990042c8ec GTextEditor: Implement the Delete key using RemoveTextCommand 2019-11-30 16:58:07 +01:00
Andreas Kling
00a91bb02c LibGUI: Consolidate and simplify commands used for insertion/removal
This patch adds InsertTextCommand and RemoveTextCommand.
These two commands are used to ... insert and remove text :^)

The bulk of the logic is moved into GTextDocument, and we now use the
command's redo() virtual to perform the action. Or in other words, when
you type into the text editor, we create an InsertTextCommand, push it
onto the undo stack, and call redo() on it immediately. That's how the
text gets inserted.

This makes it quite easy to implement more commands, as there is no
distinction between a redo() and the initial application.
2019-11-30 16:54:05 +01:00
Andreas Kling
f430da1d45 LibGUI: Add GUndoStack and GCommand classes
This patch converts the undo stack from GTextDocument into GUndoStack,
and GTextDocumentUndoCommand now inherits from GCommand.

Let's turn this into a generic mechanism that can be used to implement
undo/redo in any application. :^)
2019-11-30 15:36:17 +01:00
Andreas Kling
ee8773c586 LibGUI: Move the undo stack from GTextEditor to GTextDocument
Since the same document can be edited by multiple editors, we need to
keep the undo stack with the document for coherency.
2019-11-30 13:05:17 +01:00
Andreas Kling
d6426e4af9 LibHTML: Allow resource loads to fail
It's perfectly normal for resource loads to fail sometimes. When they
do, we now simply pass a null buffer to the callback.
2019-11-30 11:58:47 +01:00
Andreas Kling
039fc0f2d1 LibHTML: Don't bother updating layout in frameless documents
Before/after the document is attached to a frame, there's no point in
doing any kind of layout, since we can't display the results anywhere.
2019-11-30 11:57:41 +01:00
Andreas Kling
f04394b9f3 LibDraw: Painter::draw_pixel() with thickness>1 was doubly translating
Callers of draw_pixel() are not expecting it to apply translation since
they will have already done that themselves.

This was causing draw_line() with thickness>1 to have an offset applied
in case the painter was already translated.
2019-11-29 22:31:45 +01:00
Andreas Kling
ea52fe528a LibGUI: Keep the (1, 1) text offset on GButton after it becomes checked
This makes the text offset "stick" after you click to select a window
in the taskbar, for example.
2019-11-29 15:46:38 +01:00
Andreas Kling
dd72608aed LibGUI: Align GButton text according to the specified text_alignment()
This makes the taskbar button labels align properly relative to their
icons instead of sometimes being too far right.
2019-11-29 15:41:53 +01:00
Andreas Kling
f75a6b9daa Kernel: Demangle kernel C++ symbols correctly again
I broke this while implementing module linking. Also move the actual
demangling work to AK, in AK::demangle(const char*)
2019-11-29 14:59:15 +01:00
Andreas Kling
422e5166f2 LibC: Tolerate stddef.h being included from the kernel
This can get pulled in by <cxxabi.h>, but we don't want it pulling in
more stuff from LibC.
2019-11-29 14:53:35 +01:00
William McPherson
680fd3999e LibC: Implement bsearch
Nothing fancy, just a simple implementation of bsearch(3).
2019-11-29 11:04:01 +01:00
Andreas Kling
1f34e16ec6 LibELF: Add ELFImage::Symbol::bind() 2019-11-28 21:29:57 +01:00
Andreas Kling
6b150c794a Kernel: Implement very simple kernel module loading
It's now possible to load a .o file into the kernel via a syscall.
The kernel will perform all the necessary ELF relocations, and then
call the "module_init" symbol in the loaded module.
2019-11-28 20:59:11 +01:00
Andreas Kling
c10a5ac4ad LibELF: Restore the relocation code from git history
This is going to be very useful for implementing kernel modules.
We'll also need it for dynamic linking later on.
2019-11-28 20:53:02 +01:00
Andreas Kling
0c4f29f71f LibHTML: Just swallow :not selectors for now 2019-11-28 15:01:32 +01:00
Andreas Kling
f0c94758f4 LibHTML: CSS parser should accept "foo>bar", not just "foo > bar"
If we peek a combinator at the start of a simple selector, we're seeing
the start of a new complex selector.
2019-11-28 14:48:51 +01:00
Andreas Kling
a42e477002 LibHTML: Update CSS parser with terminology from Selectors Level 4 2019-11-28 14:18:37 +01:00
Andreas Kling
70fadbad37 LibHTML: Respect "border-style: dotted"
Dotted borders are now painted correctly (as long as they are 1px wide)
which is yet another little improvement to my Apache2 default page :^)
2019-11-27 20:53:28 +01:00
Andreas Kling
478cfae7c8 LibDraw: Support dotted lines in Painter::draw_line()
Painter::draw_line() now has an optional "bool dotted" parameter that
causes it to only render every other pixel.

Note that this only works with horizontal and vertical lines at the
moment and we'll assert if called with dotted=true for a diagonal line.
2019-11-27 20:52:11 +01:00
Andreas Kling
5327de2df3 LibHTML: Add shorthand expansion for border-{style,width,color}
This is going to be quite boring to do by hand for every single CSS
property. We'll probably want to come up with a way to auto-generate
some/most of the shorthand expansion code.
2019-11-27 20:51:15 +01:00
Andreas Kling
d19d4da14a LibHTML: Implement compound selectors
This patch moves the Selector object model closer to the specification
objects in Selectors Level 4.

A "Selector" in LibHTML is now a { Vector<ComplexSelector> }, which is
a { Relation, CompoundSelector }. A CompoundSelector is really just
a Vector<SimpleSelector>, and SimpleSelector is "Component" renamed.

This makes a lot more selectors actually match on the Ubuntu Apache2
default homepage. :^)
2019-11-27 20:37:36 +01:00
Andreas Kling
449ebbddb6 LibGUI: Make GSortingProxyModel update the selection on resort again
After resorting, we now re-map every selected index so it matches the
new row mappings. This makes the process table view in SystemMonitor
behave normally again :^)
2019-11-27 19:04:35 +01:00
Andreas Kling
0adbacf59e Kernel: Demangle userspace ELF symbols in backtraces
Turns out we can use abi::__cxa_demangle() for this, and all we need to
provide is sprintf(), realloc() and free(), so this patch exposes them.

We now have fully demangled C++ backtraces :^)
2019-11-27 14:06:24 +01:00
Andreas Kling
5b8cf2ee23 Kernel: Make syscall counters and page fault counters per-thread
Now that we show individual threads in SystemMonitor and "top",
it's also very nice to have individual counters for the threads. :^)
2019-11-26 21:37:38 +01:00
Andreas Kling
712ae73581 Kernel: Expose per-thread information in /proc/all
Previously it was not possible to see what each thread in a process was
up to, or how much CPU it was consuming. This patch fixes that.

SystemMonitor and "top" now show threads instead of just processes.
"ps" is gonna need some more fixing, but it at least builds for now.

Fixes #66.
2019-11-26 21:37:30 +01:00
Sergey Bugaev
ab98969403 LookupServer: Port to socket takeover 2019-11-26 19:58:25 +01:00
Sergey Bugaev
9eaac26eda ProtocolServer: Port to socket takeover 2019-11-26 19:58:25 +01:00
Sergey Bugaev
bd55938985 AudioServer: Port to socket takeover 2019-11-26 19:58:25 +01:00
Sergey Bugaev
22a05621d5 WindowServer: Port to socket takeover 2019-11-26 19:58:25 +01:00
Sergey Bugaev
c9e21b2bcc SystemServer+LibCore: Implement socket takeover
SystemServer can now create sockets on behalf of services before spawning any
of them, and pass the open socket fd as fd 3. CLocalServer gains a method to
complete the takeover and listen on the passed fd.

This is not used by any services at the moment.
2019-11-26 19:58:25 +01:00
Sergey Bugaev
2f9be662ef LibCore: Assert instead of crashing in CEventLoop::current() 2019-11-26 19:58:25 +01:00
Sergey Bugaev
b64cee4589 LibC: Remove a leftover default_stream
Long ago, there was a fourth stdio default stream, stddbg, connected to the
debug console. It has since been replaced by the dbgputstr() and dbgputch()
syscalls.

3fce2fb205

Remove the last remains of stddbg, as fd 3 is soon going to be reused for socket
takeover.
2019-11-26 19:58:25 +01:00
Andreas Kling
aa49419173 LibCore: Make CFile::open() truncate when opening something "WriteOnly"
Unless we're also opening to append (and/or if the file is required to
be a new file), CFile::open(WriteOnly) will now truncate the file.
2019-11-26 14:32:59 +01:00
Andreas Kling
6d1c4ae5a9 LibHTML: Implement basic <form> and <input> element support
This patch adds "submit" inputs and default (text box) inputs, as well
as form elements that can be submitted.

Layout of input elements is implemented via a new LayoutWidget class
that allows you to put an arbitrary GWidget in the layout tree.
At the moment, the DOM node sets the initial size of the LayoutWidget,
and then the positioning is done by the normal layout algorithm.

We also now support submitting a <form method="GET">, which does a full
replacing load with a URL based on the form's action + a query string
built from the name/value of input elements within the submitted form.

This is pretty neat! :^)
2019-11-25 21:21:55 +01:00
Andreas Kling
8dc6f7cd4f LibHTML: Give Frame a (weak) back-pointer to the HtmlView
This will be the official path from DOM/layout code to the HtmlView
for now. Perhaps in the future we will have a fancier abstraction.
2019-11-25 21:19:21 +01:00
Andreas Kling
94bc46ee70 LibHTML: Improve CSS parser's handling of values somewhat
Now we just skip over url() and rgb() instead of crashing on them.
2019-11-25 20:04:04 +01:00
Andreas Kling
847b232680 LibHTML: Divide the "line spacing" evenly between lines of text
Before this patch, all of the excess spacing caused by line-height was
"padding" the line boxes below the text.

To fix this, we make line box fragments use the font height as their
height, and then let the inline layout algorithm adjust the Y positions
to distribute the vertical space.
2019-11-25 18:14:52 +01:00
Andreas Kling
320c79cb48 LibHTML: Join border edges nicely when painting boxes
Always paint border edges so they join nicely with their buddy edges.
This makes borders look nice even if all sides have different widths.

Also switch the border code to using floating point numbers since
otherwise things get very ugly very fast.
2019-11-25 14:37:04 +01:00
Andreas Kling
05b1ecf1b1 LibHTML: Draw each CSS border edge separately with their own style
The borders still look very wrong with any border-width other than 1,
but at least we can see that they have the right color, and end up in
mostly the right place :^)
2019-11-25 13:17:14 +01:00
Andreas Kling
e691d16f1c LibHTML: Decrement the pending loads counter when a load finishes
This ensures that the browser statusbar shows the correct number of
still pending resource loads.
2019-11-25 11:47:25 +01:00
Andreas Kling
7ef51293c7 LibVT: Unbreak semi-transparent terminal background painting
I broke semi-transparent terminals when I added support for alpha
blending to Painter::fill_rect().

When we fill the terminal widget background, we don't want blending to
take place, we're just looking to replace with an exact color, so now
we can use Painter::clear_rect() for that.
2019-11-25 11:35:52 +01:00
Andreas Kling
c645d9fe4a LibDraw: Add Painter::clear_rect() for filling a rect without blending
Sometimes you want to fill a rect with a specific color without alpha
blending it with whatever's already there.
2019-11-25 11:34:55 +01:00
Andreas Kling
5036b888ac LibHTML: Store the HTML parser input along with the created Document
This will allow us to "view source" later on, long after parsing has
finished and turned it into a DOM.
2019-11-25 00:27:41 +01:00
Andreas Kling
0d2659c0a2 LibHTML: Use LibProtocol for HTTP requests :^)
This moves all of the browser networking to ProtocolServer.
2019-11-24 14:24:59 +01:00
Andreas Kling
653e61d9cf LibProtocol: Add a Download object so users don't have to manage ID's
LibProtocol::Client::start_download() now gives you a Download object
with convenient hooks (on_finish & on_progress).

Also, the IPC handshake is snuck into the Client constructor, so you
don't need to perform it after instantiating a Client.

This makes using LibProtocol much more pleasant. :^)
2019-11-24 13:22:01 +01:00
Andreas Kling
35c26a06fc LibCore: Move puff() from LibDraw to LibCore
Since it's used both by CGzip and PNGLoader, it seems most appropriate
to keep this in LibCore.
2019-11-23 23:43:37 +01:00
Andreas Kling
eb85103271 ProtocolServer: Send the download payload to clients as a shared buffer
The DownloadFinished message from the server now includes a buffer ID
that can be mapped into the client program.

To avoid prematurely destroying the buffer, the server will hang on to
it until the client lets it know that they're all good. That's what the
ProtocolServer::DisownSharedBuffer message is about.

In the future it would be nice if the kernel had a mechanism to allow
passing ownership of a shared buffer along with an IPC message somehow.
2019-11-23 22:11:44 +01:00
Andreas Kling
fd4349a9f2 ProtocolServer+LibProtocol: Introduce a server for handling downloads
This patch adds ProtocolServer, a server that handles network requests
on behalf of its clients. The first protocol implemented is HTTP.

The idea here is to use a plug-in architecture where any number of
protocols can be added and implemented without having to mess around
with each client program that wants to use the protocol.

A simple client API is provided through LibProtocol::Client. :^)
2019-11-23 21:50:32 +01:00
Andreas Kling
20c957ef61 LibCore: Have CNetworkJob protect itself during the on_finish callback
Otherwise, the callback may trigger the destruction of the CNetworkJob
and make it difficult to continue execution correctly.
2019-11-23 21:42:02 +01:00
Andreas Kling
fc14bdd442 LibGUI: Don't recompute line-wrapping over and over during set_text()
This makes the TextEditor start up fast for large files again.
2019-11-23 17:41:14 +01:00
Andreas Kling
84cb91de38 AudioServer: Broadcast muted state changes to all clients 2019-11-23 17:21:12 +01:00
Andreas Kling
00ab9488ad LibDraw: Start work on a GIF decoder (not yet functional!)
Here comes the first part of a GIF decoder. It decodes up to the point
of gathering all the LZW-compressed data. The next step is to implement
decompression, and then turn the decompressed data into a bitmap using
the color maps, etc.
2019-11-23 16:50:21 +01:00
Andreas Kling
630d5b3ffd LibIPC+AudioServer: Allow unsolicited server-to-client IPC messages
Client-side connection objects must now provide both client and server
endpoint types. When a message is received from the server side, we try
to decode it using both endpoint types and then send it to the right
place for handling.

This now makes it possible for AudioServer to send unsolicited messages
to its clients. This opens up a ton of possibilities :^)
2019-11-23 16:50:21 +01:00
Andreas Kling
5a84944dc8 LibVT: Don't scroll to bottom for Ctrl/Alt/Shift
It's nice that we scroll the cursor into view when typing in a terminal
but it's not necessary when pressing only Ctrl, Alt of Shift.
2019-11-23 16:50:21 +01:00
Andreas Kling
107011f119 AudioServer: Allow muting the system audio
This patch adds muting to ASMixer, which works by substituting what we
would normally send to the sound card with zero-filled memory instead.
We do it this way to ensure that the queued sample buffers keep getting
played (silently.)

This is obviously not the perfect way of doing this, and in the future
we should improve on this, and also find a way to utilize any hardware
mixing functions in the sound card.
2019-11-22 21:44:02 +01:00
Andreas Kling
61ba19f031 LibHTML: Handle stand-alone attribute selectors
A selector like "[foo]" is now parsed as a universal selector component
with an attribute match type. Pretty neat :^)
2019-11-21 20:19:00 +01:00
Andreas Kling
c02f560f73 LibHTML: Parse <element attribute=value> correctly
We were not committing the attribute at all in this case.
2019-11-21 20:18:18 +01:00
Andreas Kling
8946e50986 LibHTML: Implement some attribute selector support
This patch adds a[foo] and a[foo=bar] attribute selectors.

Note that an attribute selector is an optional part of a selector
component, and not a component on its own.
2019-11-21 20:07:43 +01:00
Andreas Kling
54a6ae9201 LibHTML: Make the HTML parser handle <div attr> and <div attr="">
We were not producing the correct DOM attribute in either of those
cases. "<div attr>" would produce no attribute, and the other would
produce an attribute with null value (instead of an empty value.)
2019-11-21 20:06:10 +01:00
Andreas Kling
9f0ca1bfb0 LibHTML: Paint text background color before the underline decoration 2019-11-21 13:15:11 +01:00
Till Mayer
b0b523e973 FileManager: Added properties dialog
The user can rename files, change the permissions and view different
properties of the file.
2019-11-20 23:23:57 +01:00
Andreas Kling
e630ad5927 GTableView: Don't allow resizing columns to a negative width
This is definitely not perfect but better than letting you put the
GTableView into a weird state with negative column widths. :^)
2019-11-20 22:27:12 +01:00
Andreas Kling
e08d605f72 GTableView: Don't hover-highlight unsortable column headers
The hover highlight is meant to indicate that the button is pressable.
Non-sortable columns are not pressable.
2019-11-20 22:23:51 +01:00
Andreas Kling
16c290e8d5 GTableView: Highlight the hovered column header
This makes it feel even *more* like a proper button.
2019-11-20 22:19:30 +01:00
Andreas Kling
191535d626 LibGUI: Make the GTableView column headers behave like proper buttons
Previously they would resort based on the column immediately when you
mousedown on them. Now we track the click event and show the header
in a pressed state, etc. The usual button stuff :^)
2019-11-20 22:11:43 +01:00
Andreas Kling
0b0017bbbd LibGUI: Make the GTableView row background colors a little brighter
This has been bothering me for a long time.. :^)
2019-11-20 21:52:34 +01:00
Andreas Kling
386bf8b763 LibVT: Don't implicitly copy the selection on double-click or mouse-up 2019-11-20 21:47:12 +01:00
Andreas Kling
dabdd484f7 LibVT: Add a context menu to TerminalWidget
Starting with only the copy and paste actions. But I'm sure we can come
up with some more things to put here. :^)
2019-11-20 21:47:12 +01:00
Andreas Kling
dbf8d6bc1e Terminal+LibVT: Switch Terminal to using explicit copy/paste actions
Instead of implicitly copying whatever you select, and pasting when you
middle-click, let's have traditional copy and paste actions bound to
Ctrl+Shift+C and Ctrl+Shift+V respectively.
2019-11-20 21:47:12 +01:00
Andreas Kling
6fa26c73e2 LibVT: Use the middle mouse button for pasting (instead of right)
This will allow us to show a context menu when you right-click,
which will feels more consistent with the rest of the Serenity desktop.
2019-11-20 21:47:12 +01:00
Andreas Kling
9a6388f718 LibHTML: Render a background-color behind line box fragments if needed 2019-11-19 19:23:14 +01:00
Andreas Kling
5a04472470 LibHTML: Fix bug in removal of trailing whitespace from line boxes
This code was using the text from the DOM as a reference for how much
whitespace to remove from the end of a line box.

Since the DOM may contain uncollapsed whitespace, it would sometimes
be out of sync with the collapsed text used by the rest of the layout
system.
2019-11-19 19:21:47 +01:00
Andreas Kling
1fe2cca439 LibHTML: Use LayoutText::text_for_rendering() in layout tree dumps
This way the fragment offsets make a lot more sense, since they assume
whitespace has already been collapsed.
2019-11-19 18:36:33 +01:00
Andreas Kling
dce7646882 LibHTML: Failed font lookups should use a bold fallback when fitting
If we fail to find the font specified by a page, but we do have some
font-weight information, use a bold fallback font for bold weights.
2019-11-19 18:23:58 +01:00
Andreas Kling
1fd5869490 LibHTML: Tolerate empty CSS rules
A rule that contains nothing but whitespace is still a valid rule.
2019-11-19 18:23:18 +01:00
Andreas Kling
56dad2272c LibHTML: Implement the universal selector ("*") 2019-11-19 18:23:09 +01:00
Andreas Kling
516708aab2 LibHTML: Don't crash when stringifying an unknown CSS property
Instead, just log that it happened, and then we can track it down.
2019-11-19 18:21:12 +01:00
Andreas Kling
e87b9e2d7c LibHTML: Add the CSS "position" property to CSS/Properties.json 2019-11-19 18:20:54 +01:00
Andreas Kling
0405ab91aa LibHTML+AK: Move URL completion from Document to AK::URL
Completing a relative URL based on a base URL seems like generally
useful functionality.
2019-11-19 17:46:36 +01:00
Andreas Kling
0ddde627b1 Lagom: Fix build 2019-11-19 11:14:26 +01:00
Andreas Kling
a12292bd03 LibHTML: LayoutImage should not dereference a null bitmap
This was happening when trying to render a bitmap that we couldn't
decode properly.
2019-11-18 20:26:32 +01:00
Andreas Kling
89a0d873ba LibHTML: Update tree dumping code now that everything is floating point 2019-11-18 20:26:15 +01:00
Andreas Kling
c8e02e60a6 HackStudio+LibGUI: Implement matching curly brace highlighting
This works for C++ syntax highlighted text documents by caching the C++
token type in a new "arbitrary data" member of GTextDocumentSpan.

When the cursor is placed immediately before a '{' or immediately after
a '}', we highlight both of these brace buddies by changing their
corresponding spans to have a different background color.

..and spans can also now have a custom background color. :^)
2019-11-18 19:10:06 +01:00
Andreas Kling
5f7f97355e LibDraw: Add named colors "MidCyan" and "DarkCyan"
I need these for .. a thing. :^)
2019-11-18 19:02:10 +01:00
Andreas Kling
b7a840fd0d LibHTML: Respect the line-height property if set
It's now possible to override the line-height via CSS. It will still
default to 1.4 if not specified.
2019-11-18 16:54:20 +01:00
Andreas Kling
a14cc573b0 LibHTML: Implement some basic floating point CSS value parsing 2019-11-18 16:54:03 +01:00
Andreas Kling
c628ebda0f LibHTML: Use floating point numbers throughout the layout tree 2019-11-18 16:30:18 +01:00
Andreas Kling
da23864c8d LibHTML: Let's just build host-side tools in makeall.sh instead
Instead of trying to build the host-side code generator helpers right
before we need them in the LibHTML build process, just build them ahead
of time in makeall.sh, like we already do for {IPC,Form}Compiler.
2019-11-18 16:30:18 +01:00
Andreas Kling
85d7afb6df LibHTML: Make all .cpp files implicitly depend on the generated sources
Hopefully this will make Travis generate sources before building all
the other files.
2019-11-18 15:36:30 +01:00
Andreas Kling
a116a4a180 LibHTML: Get rid of dual Makefile setup
It's no longer possible to build LibHTML on the host machine since it
depends on LibGUI now. This patch gets rid of the dual Makefiles in
LibHTML since we only support Serenity builds anyway.

Also clean the code generator directory before building it.
2019-11-18 14:51:46 +01:00
Andreas Kling
1309c45cc6 LibHTML: Fix code generator dependencies for initial build
Fixes #796.
2019-11-18 13:09:33 +01:00
Andreas Kling
040fee370d LibHTML: Expand the "padding" shorthand property
This expands in the same way as "margin".
2019-11-18 12:34:52 +01:00
Andreas Kling
b08de46480 LibHTML: Implement basic 'max-width' and 'min-width' support
These CSS properties constrain the computed width of a block-level box
to a maximum, followed by a minimum value.

This makes the "better mother fricken website" look more like it's
intended to (which helps makes the author's point, I suppose.)
2019-11-18 12:26:08 +01:00
Andreas Kling
df16c9676b LibHTML: Tolerate "px" suffix on CSS lengths
We only support "px" units (and "auto") but we shouldn't choke just
because someone actually says "10px" instead of just "10"
2019-11-18 12:15:23 +01:00
Andreas Kling
00d171e4d6 LibHTML: Implement the "margin" shorthand property
This is a very bulky way of doing this, and doesn't seem sustainable to
implement every shorthand property this way, but it's a place to start.

The "margin" CSS property now expands into its four longhands as far as
my understanding of the specs.

Note that shorthand expansion happens when we *resolve* style, not when
we parse CSS. I'm not sure this is correct anymore, I think other UA's
may actually expand shorthands into the declaration directly at parse
these days. If so, we should do this at parsing as well.
2019-11-18 11:51:02 +01:00
Andreas Kling
e6e41e4fb8 LibHTML: Start building a simple code generator for CSS properties
Code for parsing and stringifying CSS properties is now generated based
on LibHTML/CSS/Properties.json

At the moment, the file tells us three things:

- The name of a property
- Its initial value
- Whether it's inherited

Also, for shorthand properties, it provides a list of all the longhand
properties it may expand too. This is not actually used in the engine
yet though.

This *finally* makes layout tree dumps show the names of CSS properties
in effect, instead of "CSS::PropertyID(32)" and such. :^)
2019-11-18 11:48:41 +01:00
Andrew Kaster
618aebdd8a Kernel+LibPthread: pthread_create handles pthread_attr_t
Add an initial implementation of pthread attributes for:
  * detach state (joinable, detached)
  * schedule params (just priority)
  * guard page size (as skeleton) (requires kernel support maybe?)
  * stack size and user-provided stack location (4 or 8 MB only, must be aligned)

Add some tests too, to the thread test program.

Also, LibC: Move pthread declarations to sys/types.h, where they belong.
2019-11-18 09:04:32 +01:00
Dan MacDonald
aae26a3a1e LibC: Add O_ACCMODE to fcntl.h 2019-11-18 08:55:45 +01:00
Andreas Kling
9c35feb14c LibC: jmp_buf and sigjmp_buf should be distinct types
This makes it possible to build 'vim' with more features enabled.
2019-11-17 21:01:26 +01:00
Andreas Kling
5eef2f78b0 LibC: isatty() should return 1 for success, 0 for error 2019-11-17 20:11:56 +01:00
Andreas Kling
3da6d89d1f Kernel+LibC: Remove the isatty() syscall
This can be implemented entirely in userspace by calling tcgetattr().
To avoid screwing up the syscall indexes, this patch also adds a
mechanism for removing a syscall without shifting the index of other
syscalls.

Note that ports will still have to be rebuilt after this change,
as their LibC code will try to make the isatty() syscall on startup.
2019-11-17 20:03:42 +01:00
Andreas Kling
e34ed04d1e Kernel+LibPthread+LibC: Create secondary thread stacks in userspace
Have pthread_create() allocate a stack and passing it to the kernel
instead of this work happening in the kernel. The more of this we can
do in userspace, the better.

This patch also unexposes the raw create_thread() and exit_thread()
syscalls since they are now only used by LibPthread anyway.
2019-11-17 17:29:20 +01:00
Andreas Kling
6685be36a0 LibDraw: Add Rect::from_two_points(Point, Point)
This returns the rectangle between two given Points. Thanks Owlinator
for suggesting this much easier way of doing it :^)
2019-11-17 16:37:42 +01:00
Andreas Kling
32ff660aa5 LibC: Oopsie, add the missing semicolons to __bswap32() and __bswap64()
Well that was a lot of flailing around.
2019-11-17 15:37:46 +01:00
Andreas Kling
31447d58fb LibC: Add back __bswap{16,32,64}() to endian.h 2019-11-17 14:34:40 +01:00
Andreas Kling
5f459ee929 LibC: Unbreak endian.h
There were some missing semicolons so this file didn't compile.
Also add some macro paranoia parentheses while we're here.
2019-11-17 12:53:50 +01:00
Andreas Kling
794758df3a Kernel: Implement some basic stack pointer validation
VM regions can now be marked as stack regions, which is then validated
on syscall, and on page fault.

If a thread is caught with its stack pointer pointing into anything
that's *not* a Region with its stack bit set, we'll crash the whole
process with SIGSTKFLT.

Userspace must now allocate custom stacks by using mmap() with the new
MAP_STACK flag. This mechanism was first introduced in OpenBSD, and now
we have it too, yay! :^)
2019-11-17 12:15:43 +01:00
Andreas Kling
89c0b158da LibDraw: Add support for colors with alpha in Painter::fill_rect()
This code is naive, but it works and looks okay. :^)
2019-11-16 19:26:17 +01:00
Andreas Kling
196b64c0ae LibC: Move realpath() to <stdlib.h> 2019-11-16 17:29:09 +01:00
Andreas Kling
fbcab844de LibC: Move the creat() and open() families to <fcntl.h>
Since POSIX says that's where they belong :^)
2019-11-16 17:29:09 +01:00
Ørjan Malde
84bedd5528 LibC: use GCC __builtin_bswap{16,32,64} to provide __bswap functions 2019-11-16 17:17:26 +01:00
Ørjan Malde
a55fb98d0a LibC: fix arpa/inet.h guards 2019-11-16 16:27:48 +01:00
Ørjan Malde
faff1361c3 LibC: properly populate endian.h 2019-11-16 16:27:48 +01:00
Brandon Scott
3069988a75 LibC: Implemented getc_unlocked, stubbed flockfile
Implemented getc_unlocked and stubbed out flockfile() and funlockfile().
2019-11-16 12:50:50 +01:00
Brandon Scott
bda36853c9 LibC: Implemented mkstemp in stdlib
Implemented mkstemp method in stdlib.
2019-11-16 12:50:50 +01:00
Brandon Scott
48b1c82d53 LibC: Added missing signal flags
Added missing signal flags to signal.h
2019-11-16 12:50:50 +01:00
Brandon Scott
f999e30afd LibC: Added execlp method and new pathconf setting
Added execlp method, and _PC_PIPE_BUF setting to pathconf method.
2019-11-16 12:50:50 +01:00
Brandon Scott
eb719aa726 LibC: Added some missing directory type constants
Added some missing directory type constants to dirent.h
2019-11-16 12:50:50 +01:00
Brandon Scott
57eb37160c LibC: Added additional fields to lconv struct
Added some additional fields to the lconv structure that were missing
and set all their defaults.
2019-11-16 12:50:50 +01:00
Andreas Kling
66a2b582c3 LibPthread: Implement a basic first pthread mutex
This patch adds these API's:

- pthread_mutex_init()
- pthread_mutex_lock()
- pthread_mutex_unlock()

No mutex attributes are supported yet, so we only do the simplest mutex
wihout recursive locking.
2019-11-16 12:23:36 +01:00
Rok Povsic
95df049071 Terminal: Add selecting whole line on triple click
The line is also added to clipboard
2019-11-15 23:58:06 +01:00
Andreas Kling
57f7009b9e GTextEditor: Allow GTextDocumentSpans to be "skippable"
Setting the is_skippable flag on a GTextDocumentSpan will now cause the
cursor to skip over that span when moving with Ctrl+Left/Right.
2019-11-15 21:03:15 +01:00
Andreas Kling
27a30fdc2a GTextEditor: Allow moving the cursor span-wise with Ctrl+Left/Right
This allows you to move token by token when using HackStudio to edit
a C++ file.

Fixes #767.
2019-11-15 21:02:24 +01:00
ctfloyd
a3520bfdfd GTextEditor: Alt+Shift+S alphabetically sorts selected lines 2019-11-15 21:01:12 +01:00
Andreas Kling
69efa3f630 Kernel+LibPthread: Implement pthread_join()
It's now possible to block until another thread in the same process has
exited. We can also retrieve its exit value, which is whatever value it
passed to pthread_exit(). :^)
2019-11-14 20:58:23 +01:00
Till Mayer
00e56cda0c LibC: open/openat: Make sure path is not a nullptr before dereferencing
open and openat both try to get the length of the path string. When
the path was a nullptr, strlen tried to dereference it, causing a
segfault.
2019-11-14 08:32:03 +01:00
Andreas Kling
69ca9cfd78 LibPthread: Start working on a POSIX threading library
This patch adds pthread_create() and pthread_exit(), which currently
simply wrap our existing create_thread() and exit_thread() syscalls.

LibThread is also ported to using LibPthread.
2019-11-13 21:49:24 +01:00
Andreas Kling
812ee330e6 GTreeView: Make it possible to multi-select with the Ctrl modifier 2019-11-11 22:20:02 +01:00
Andreas Kling
524da0ad01 LibGUI: Add "Vector<GWidget*> GWidget::child_widgets()"
This is quite inefficient since it constructs a new Vector each time.
2019-11-11 22:20:02 +01:00
Andreas Kling
3ef287eb9f GTreeView: Always repaint in response to did_update_model()
This could definitely be more efficient, but this is more correct than
doing nothing at all. :^)
2019-11-11 22:20:02 +01:00
Emanuel Sprung
e7affa24dc LibC, LibM: Add functions needed to compile python3 2019-11-11 22:04:16 +01:00
Andreas Kling
dd2900eda0 Launcher: Remove the Launcher app, and all hacks in support of it
The Launcher's functionality has been replaced by the app shortcuts in
the system menu.

There were various window management hacks to ensure that the launcher
stayed below all other windows while also being movable, etc.
2019-11-11 13:13:08 +01:00
Andreas Kling
37329f829b LibCore: Add CConfigFile::open() for opening an arbitrary INI file 2019-11-11 13:13:08 +01:00