Commit Graph

1283 Commits

Author SHA1 Message Date
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
Andreas Kling
cab9933834 GToolBar: Make buttons exclusive if action belongs to exclusive group
This was probably what I had originally intended when I first wrote the
GActionGroup stuff, but it seems to have been forgotten.
2019-11-10 22:49:02 +01:00
Andreas Kling
5951c7ca05 LibC: Add strtok_r() and make strtok() a wrapper around it 2019-11-10 21:19:08 +01:00
masi456
7e7451c427 WindowServer: Don't de-maximize windows immediately (#756)
At least 5 pixels of dragging in some direction needed until a window
gets de-maximized.
2019-11-10 18:28:01 +01:00
Andreas Kling
18348cebf1 Kernel+LibC: Implement the openat() syscall
POSIX's openat() is very similar to open(), except you also provide a
file descriptor referring to a directory from which relative paths
should be resolved.

Passing it the magical fd number AT_FDCWD means "resolve from current
directory" (which is indeed also what open() normally does.)

This fixes libarchive's bsdtar, since it was trying to do something
extremely wrong in the absence of openat() support. The issue has
recently been fixed upstream in libarchive:

https://github.com/libarchive/libarchive/issues/1239

However, we should have openat() support anyway, so I went ahead and
implemented it. :^)

Fixes #748.
2019-11-10 13:51:27 +01:00
Andreas Kling
4f27745136 LibC: Implement a very naive mbtowc()
This just copies the short char into the wide char without any decoding
whatsoever. A proper implementation should look at the current LC_CTYPE
and implement multi-byte decoding.
2019-11-10 13:46:52 +01:00
Andreas Kling
12e0fab580 LibC: iconv.h needs stddef.h for size_t 2019-11-10 13:07:51 +01:00
Andreas Kling
528e6b27f6 Terminal: Clip out the scrollbar when painting the terminal buffer
This avoids the terminal background color sometimes flashing through
the scrollbar for a brief moment.
2019-11-10 13:00:03 +01:00
Andreas Kling
3a01df9fb1 GWidget: Fix accidentally ignored set_relative_rect() with empty size
To protect the layout system from negative input values, we were using
an empty Rect() whenever an empty rect (width/height <= 0) was provided
to set_relative_rect().

This caused Terminal's scrollbar code to fail, since it relies on first
setting only the scrollbar width on startup, and then setting up the
proper geometry in response to the initial resize event.

Fixes #753.
2019-11-10 12:57:37 +01:00
Andreas Kling
ca538b6cee LibGUI: Add a simple GWidget class registry/factory
You can now register a GWidget subclass with REGISTER_GWIDGET(class)
and it will be available for factory construction through the new
GWidgetClassRegistration interface.

To obtain a GWidgetClassRegistration for a given class name, you call
GWidgetClassRegistration::find(class_name). You can also iterate over
all the registered classes using GWCR::for_each(callback).

This will be very useful for implementing a proper GUI designer, and
also in the future for things like script bindings.

NOTE: All of the registrations are done in GWidget.cpp at the moment
since I ran into trouble with the fricken linker pruning the global
constructors this mechanism relies on. :^)
2019-11-10 12:57:37 +01:00
Marcel Schneider
a353d16ff4 LibCore: Rename class Gzip -> CGZip 2019-11-10 12:52:23 +01:00
Marcel Schneider
c40935e79f LibCore: Add Content-Encoding handling to CHttpJob 2019-11-10 12:52:23 +01:00
Marcel Schneider
4fe5503b17 LibCore: Add a gzip implementation 2019-11-10 12:52:23 +01:00
Andreas Kling
bbc2f5205f LibC: Fix wrong syscall identifier for shm_unlink()
I renamed "shm_close" to "shm_unlink" since there's no such thing as
shm_close(), but forgot to update LibC, oops!
2019-11-09 22:42:54 +01:00
Andreas Kling
874ebbe4a5 LibC: shm_unlink() was making an unlink() syscall internally
I guess that tells us how well-tested the SHM implementation is.
2019-11-09 22:42:19 +01:00
Paweł Cholewa
c2a8c4cedd LibC: Minor changes to make nasm work
* Added some missing macros to headers
 * Stubbed strftime() time function to not assert
 * Added "rt" mode to fopen(), working just like "r" or "rb"
2019-11-09 20:52:34 +01:00
Andreas Kling
70a4678d77 LibHTML: Paint a magenta rectangle around the currently inspected node
Document now tracks one "inspected" node, set by set_inspected_node()
which is called by Browser's DOM inspector view on_selection callback.
2019-11-09 11:58:50 +01:00
Andreas Kling
7fcb21c935 LibHTML: Add document icon in DOMTreeModel and keep document alive 2019-11-09 11:58:20 +01:00
Andreas Kling
29b2117564 LibGUI: Make GTreeView fire the on_selection hook
GTreeView was forgetting to call to base in did_update_selection().
This prevented GAbstractView from firing the on_selection hook and we
ended up with only the on_selection_change hook firing.
2019-11-09 11:57:08 +01:00
Andreas Kling
ce9b9c129d LibGUI: Include internal_data() in GModelIndex LogStream output 2019-11-09 11:56:28 +01:00
Andreas Kling
e3d975e943 LibHTML+Browser: Add a simple DOM inspector popup window
LibHTML now provides a DOMTreeModel which can be used to view a given
Document's DOM tree. :^)
2019-11-09 11:31:03 +01:00
Rhin
503fe37eaa TextEditor: Enable/disable undo & redo buttons based on availability (#740) 2019-11-09 08:50:39 +01:00
Andreas Kling
e52fe07d2e GTableView: Paint with white background when model-less
This matches the behavior of GTreeView.
2019-11-09 00:41:00 +01:00
Andreas Kling
d22d9874f7 LibGUI: Allow overriding the button size when constructing GToolBar
This makes it easy to create a toolbar housing buttons of a size other
than 16x16.
2019-11-09 00:41:00 +01:00
Andreas Kling
0d2495e4e7 LibGUI: Allow construction of vertical GToolBars
There's currently a small paint glitch for vertical toolbars due to the
way StylePainter::paint_surface() draws a MidGray line at the bottom of
whatever a "surface" is supposed to be.
2019-11-09 00:41:00 +01:00
Andreas Kling
fa77a57257 GTextEditor: Allow moving the selected line(s) up/down in bulk
You can now press Ctrl+Shift+Up/Down in a GTextEditor and the currently
selected line(s) will all move together one step up/down.

If there is no selection, we move the line with the cursor on it. :^)
2019-11-08 20:14:42 +01:00
Andreas Kling
c16b1a515e GTextEditor: Add a way to flush any pending on_change notifications
Since on_change handlers can alter the text document we're working on,
we have to make sure they've been run before we try looking at spans.
This fixes some flakiness when a paint happened before HackStudio had
a chance to re-highlight some C++ while editing it.

The design where clients of GTextEditor perform syntax highlighting in
the "arbitrary code execution" on_change callback is not very good.
We should find a way to move highlighting closer to the editor.
2019-11-08 19:51:10 +01:00
Andreas Kling
8a024a3305 LibGUI: Rename GEventLoop.{cpp,h} => GWindowServerConnection
The GEventLoop class is long gone, and the only class in these files is
GWindowServerConnection, so let's update the file names. :^)
2019-11-08 11:40:25 +01:00
Andreas Kling
69883bea6f LibHTML: Update the removed node's siblings in TreeNode::remove_child()
Oops, we forgot to update the node's siblings' sibling pointers when
removing a node from the tree.

Thanks to Owlinated for pointing this out! :^)
2019-11-07 22:45:12 +01:00
rhin123
96c1e36ed3 TextEditor: Added redo functionality & proper stack manipulation
Added redo functionality & added m_undo_stack_index that moves back &
forth on the stack depending on the undo's & redo's.
2019-11-07 22:29:59 +01:00
Andreas Kling
0355146af9 LibHTML: Ignore case in <!DOCTYPE> tags :^) 2019-11-07 21:39:15 +01:00
Andreas Kling
71f249fd2c LibHTML: Draw box borders even if we don't have a border-color
In those cases we should fall back to currentColor, which is hackishly
implemented by falling back to "color" for now.
2019-11-07 21:36:32 +01:00
Andreas Kling
ee2cafc15c LibHTML: Fix the default style for <hr> elements
This was broken because we don't expand CSS shorthand properties (yet.)
2019-11-07 21:35:59 +01:00
Andreas Kling
56764a2db8 LibHTML: Don't swallow '}' as part of CSS property values 2019-11-07 21:20:18 +01:00
Andreas Kling
397acde846 LibHTML: Turn "&mdash;" into "-" in the parser for now
Ultimately we should deal with all the various HTML entitites.
2019-11-07 21:19:48 +01:00
Andreas Kling
b88ff97537 LibHTML: Make the CSS parser return RefPtr's
It should be possible for the CSS parser to fail, and we'll know it
failed if it returns nullptr. Returning RefPtr's makes it actually
possible to return nullptr. :^)
2019-11-07 17:58:54 +01:00
Andreas Kling
a377e8d3f5 LibHTML+IRCClient: Add an escape_html_entities() helper
This simple helper escapes '<', '>' and '&' so they can be used in HTML
text without interfering with the parser.

Use this in IRCClient to prevent incoming messages from messing with
the DOM :^)
2019-11-06 22:40:01 +01:00
Andreas Kling
ac2cc7d78f LibHTML: Make parse_html_document() return a RefPtr
Parsing might not always succeed, so let's have a way to signal errors.
2019-11-06 20:54:50 +01:00
Andreas Kling
794f2d5645 LibHTML: Rename parse_html() => parse_html_document() 2019-11-06 20:52:18 +01:00
Andreas Kling
f5cf8d4ad8 Revert "LibHTML: Rename parse_html() => parse_html_document()"
This reverts commit f6439789db.
Oops, I committed unrelated changes here, let me clean that up..
2019-11-06 20:51:07 +01:00
Andreas Kling
f6439789db LibHTML: Rename parse_html() => parse_html_document() 2019-11-06 20:31:56 +01:00
Andreas Kling
635717ed0f LibHTML: Add parse_html_fragment()
This function parses a partial DOM and returns it wrapped in a document
fragment node (DocumentFragment.)

There are now two entrances into the HTML parser, one for parsing full
documents, and one for parsing fragments. Internally the both wrap the
same parsing function.
2019-11-06 20:30:39 +01:00
Andreas Kling
f404a1dc16 LibHTML: Add DocumentFragment
Right now this is just a simple ParentNode subclass with its node type
being DOCUMENT_FRAGMENT_NODE.
2019-11-06 20:27:53 +01:00
Andreas Kling
26493a3039 LibHTML: Add TreeNode::remove_child()
This removes a child from the tree and returns it to the caller.
It optionally (but by default) calls removed_from(parent) on the child.
2019-11-06 20:26:17 +01:00
Andreas Kling
49635e62fa LibELF: Move AK/ELF/ into Libraries/LibELF/
Let's arrange things like this instead. It didn't feel right for all of
the ELF handling code to live in AK.
2019-11-06 13:42:38 +01:00
Andreas Kling
f3f0b08d43 LibHTML: Build some foundation for text selection
Add LayoutPosition and LayoutRange classes. The layout tree root node
now has a selection() LayoutRange. It's essentially a start and end
LayoutPosition.

A LayoutPosition is a LayoutNode, and an optional index into that node.
The index is only relevant for text nodes, where it's the character
index into the rendered text.

HtmlView now updates the selection start/end of the LayoutDocument when
clicking and dragging with the left mouse button.

We don't paint the selection yet, and there's no way to copy what's
selected. It only exists as a LayoutRange.
2019-11-05 22:13:26 +01:00
Andreas Kling
d3558b6137 LibCore+LibGUI: Allow inserting a CObject/GWidget before another
When adding a widget to a parent, you don't always want to append it to
the set of existing children, but instead insert it before one of them.

This patch makes that possible by adding CObject::insert_child_before()
which also produces a ChildAdded event with an additional before_child
pointer. This pointer is then used by GWidget to make sure that any
layout present maintains the correct order. (Without doing that, newly
added children would still be appended into the layout order, despite
having a different widget sibling order.)
2019-11-05 20:41:27 +01:00
Till Mayer
ac9907ee61 SoundPlayer: Changed some small cosmetic things
Renamed "Position" to "Elapsed". "channel/channels" automatically
changes now when more than one channel exist. The current file name
is now displayed in the window title.
2019-11-05 19:50:11 +01:00
Till Mayer
94a9649945 AWavLoader: Fixed incorrect computation of m_loaded_samples
m_loaded_samples was incremented with the value of the processed
buffer. This causes m_loaded_samples to be bigger at some point
than m_total_samples when downsampling, as the buffer would contain
more samples than actually loaded.
2019-11-05 19:50:11 +01:00
Andreas Kling
59ed235c85 Kernel: Implement O_DIRECT open() flag to bypass disk caches
Files opened with O_DIRECT will now bypass the disk cache in read/write
operations (though metadata operations will still hit the disk cache.)

This will allow us to test actual disk performance instead of testing
disk *cache* performance, if that's what we want. :^)

There's room for improvment here, we're very aggressively flushing any
dirty cache entries for the specific block before reading/writing that
block. This is done by walking the entire cache, which may be slow.
2019-11-05 19:35:12 +01:00
Andreas Kling
1466a7364c LibHTML: Add TreeNode::next_in_pre_order()
This function allows you to traverse in pre-order without recursing.
2019-11-05 18:36:06 +01:00
Till Mayer
2f13517a1a LibAudio: Added playback control features to audio server
LibAudio now supports pausing playback, clearing the buffer queue,
retrieving the played samples since the last clear and retrieving
the currently playing shared buffer id
2019-11-04 20:55:46 +01:00
Till Mayer
4c9fdad1bf LibGUI: Added getter for m_dragging 2019-11-04 20:55:46 +01:00
Andreas Kling
715d7a8532 LibHTML: Add a convenient way to get from any layout node to the root 2019-11-04 20:45:47 +01:00
Andreas Kling
43a6c70c2a LibCore: Make CTCPServer's local address/port getters return Optionals 2019-11-04 13:07:41 +01:00
Andreas Kling
50d937152a LibCore: Constify CTCPServer's local_address() and local_port() 2019-11-04 12:49:48 +01:00
Conrad Pankoff
fbe8569412 LibCore: Add local_{address,port} functions to CTCPServer 2019-11-04 12:49:15 +01:00
Andreas Kling
f5c2ae1192 GTextEditor: Move the cursor to column 0 after deleting a whole line 2019-11-04 12:36:10 +01:00
Jesse Buhagiar
70fb92fa0e LibC: Implemented atof()
`atof()` has now been implemented as part of the standard C library.
It supports scientific notation such as `1.2e-3` etc, ala the version
found as part of `glibc`.

It's a bit chunky, so there's probably room for optimisations here
and there, however, for now it works as intended (and allows Quake
to run).
2019-11-04 12:34:46 +01:00
Andreas Kling
ea4e02ed86 LibCore: Flush outgoing IPC messages before trying to send a new one
This ensures that messages are sent in order.
2019-11-04 10:52:01 +01:00
rhin123
9e608885d1 TextEditor: Added undo functionality
Created a stack where a vector of undo actions are stored.
2019-11-03 20:21:14 +01:00
Andreas Kling
53cfed7c8b LibCore: Put a limit on how many unsent messages an IPC server queues
This patch adds a limit of 200 unsent messages per client. If a client
does not handle its incoming messages and we manage to queue up 200
messages for it, we'll now disconnect that client. :^)
2019-11-03 12:40:57 +01:00
Andreas Kling
31c1b8ec3e LibCore: Have IPC server connections queue up unsendable messages
If an IPC client is giving us EAGAIN when trying to send him a message,
we now queue up the messages inside the CoreIPCServer::Connection and
will retry flushing them on next post/receive.

This prevents WindowServer from freezing up when one of its clients is
not taking care of its incoming messages.
2019-11-03 12:36:35 +01:00
Andreas Kling
4565b2d2d9 LibM: Add back ampsin() since it was still used by tan() 2019-11-03 09:59:44 +01:00
Andreas Kling
1282b778e7 LibGUI: Move GTextPosition and GTextRange LogStream<< to their headers 2019-11-03 09:57:14 +01:00
Jesse
bcf3a4457f LibM: Fixed sin() precision (#726)
The old implementation of sin() had a very unacceptable amount of
error that was causing a lot of texture perspective issues in Quake.
This has been remedied through the use of the hardware `fsin`
x87 instruction. As has been noted in #246, this instruction is both
very slow, and can become wildly inaccurate for more precise values,
however the current implementation made an incorrect assumption about
applications "will end up writing their own implemtnation anyways",
which is not the case for Quake in Software mode, which relies heavily
on a correct `sin()` and `cos()` function for `R_ScanEdges()`.

Realistically, we should be using something like the CORDIC algorithm
(https://en.wikipedia.org/wiki/CORDIC) or `Taylor Expansion`, however
for now these provides a somewhat accurate result that allows Quake to
run without any texture or geometry issues.
2019-11-03 09:56:39 +01:00
George Pickering
704f48d7f3 POSIX compliance: (most) shell scripts converted to generic shell
Ports/.port_include.sh, Toolchain/BuildIt.sh, Toolchain/UseIt.sh
have been left largely untouched due to use of Bash-exclusive
functions and variables such as $BASH_SOURCE, pushd and popd.
2019-11-03 09:26:22 +01:00