Commit Graph

933 Commits

Author SHA1 Message Date
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