Commit Graph

3013 Commits

Author SHA1 Message Date
Rhin
1d39310d01 Userland: Added flags to id command (#253)
Fixes #158.
2019-06-29 21:47:38 +02:00
Andreas Kling
7eef69ad4b LibHTML: Refactor to go from DOM -> styled tree -> layout tree.
Frame::layout() drives everything now, it takes the DOM contained in the
frame and puts it through the tree transformations.
2019-06-29 21:42:07 +02:00
Andreas Kling
6e95b11395 AK: Allow HashMap to be used with non-default-constructible values.
Solve this by adding find() overloads to HashTable and SinglyLinkedList
that take a templated functor for comparing the values.

This allows HashMap to call HashTable::find() without having to create
a temporary Entry for use as the table key. :^)
2019-06-29 21:09:40 +02:00
Andreas Kling
d5bb98acbc AK: Defer to Traits<T> for equality comparison in container templates.
This is prep work for supporting HashMap with NonnullRefPtr<T> as values.
It's currently not possible because many HashTable functions require being
able to default-construct the value type.
2019-06-29 19:14:03 +02:00
Andreas Kling
9a7dc06567 LibHTML: Add Selector::specificity(), which returns a Specificity object. 2019-06-29 17:32:32 +02:00
Andreas Kling
b729b5fc64 VisualBuilder: Support loading a saved form from JSON.
The form to load is specified on the command line, e.g "vb test.frm".
2019-06-29 12:07:46 +02:00
Andreas Kling
57a589a6e7 LibGUI: Make it easy to construct a GVariant from a JsonValue. 2019-06-29 12:07:46 +02:00
Andreas Kling
2735ff4687 ProcFS: Remove unused StringBuilder in procfs$all(). 2019-06-29 12:07:46 +02:00
Andreas Kling
293946c960 JsonValue: Add is_bool() and various as_foo() helpers. 2019-06-29 12:07:46 +02:00
Andreas Kling
7f224ade60 JsonValue: No need to null-check StringImpls if type is Type::String.
If you try to create a JsonValue from a null String(), it will become a
null JsonValue anyway.
2019-06-29 12:07:46 +02:00
Andreas Kling
50677a58d4 StringView: Make it easy to construct from a ByteBuffer. 2019-06-29 12:07:46 +02:00
Andreas Kling
53479f9356 HashTable: Don't use move assignment in set(const T&). 2019-06-29 12:07:46 +02:00
Andreas Kling
b1d113e32a AK: Make a tiny JSON unit test based on a saved VisualBuilder form. 2019-06-29 12:07:42 +02:00
Andreas Kling
c9826bb429 LibCore: Port CProcessStatisticsReader to the JSON formatted /proc/all. 2019-06-29 10:12:40 +02:00
Andreas Kling
14b51253c0 WindowServer: Allow changing window opacity with Logo+MouseWheel.
This is just a silly little feature that I thought was a bit neat. :^)
2019-06-29 09:27:55 +02:00
Andreas Kling
2bd8118843 Kernel: Change the format of /proc/all to JSON.
Update ProcessManager, top and WSCPUMonitor to handle the new format.

Since the kernel is not allowed to use floating-point math, we now compile
the JSON classes in AK without JsonValue::Type::Double support.
To accomodate large unsigned ints, I added a JsonValue::Type::UnsignedInt.
2019-06-29 09:04:45 +02:00
Andreas Kling
561bfd3ed6 Terminal: Make it so typing resets the cursor blink timer.
Patch contributed by "pd"
2019-06-28 21:46:23 +02:00
Andreas Kling
96ca8bea6c Terminal: Don't write erroneous characters to PTY when modifiers pressed.
Additionally the Alt modifier now generates the correct characters, as do
Insert/Delete/PgUp/PgDown.

Patch contributed by "pd"
2019-06-28 21:46:05 +02:00
Andreas Kling
274b41e47c Terminal: Changex internal opacity representation to byte instead of float.
This lets us avoid some math during paint events.
Patch contributed by "pd"
2019-06-28 21:42:15 +02:00
Andreas Kling
ffcbe8f0de LibHTML: Start building the style tree.
Walk the DOM and construct a parallel style tree that points back to the DOM
and has the relevant CSS property values hanging off of them.

The values are picked based on naive selector matching. There's no cascade
or specificity taken into account yet.
2019-06-28 21:25:44 +02:00
Andreas Kling
3af59dfed1 AK: We can't use std::initializer_list in LibC builds.
The LibC build is a bit complicated, since the toolchain depends on it.
During the toolchain bootstrap, after we've built parts of GCC, we have
to stop and build Serenity's LibC, so that the rest of GCC can use it.

This means that during that specific LibC build, we don't yet have access
to things like std::initializer_list.

For now we solve this by defining SERENITY_LIBC_BUILD during the LibC
build and excluding the Vector/initializer_list support inside LibC.
2019-06-28 20:58:41 +02:00
Andreas Kling
872cccb8f7 WindowServer: Make use of the new Vector(initializer_list). 2019-06-28 20:21:28 +02:00
Andreas Kling
4c285f9e1a AK: Add Vector(std::initializer_list<T>) constructor.
This allows us to construct a Vector from an initializer list like so:

Vector<Object> objects = { object1, object2, object3 };
2019-06-28 20:21:23 +02:00
Robin Burchell
933cd3848f PaintBrush: Add size context menu to SprayTool 2019-06-28 15:27:23 +02:00
Robin Burchell
24ada6bd1f PaintBrush: Add an erase tool 2019-06-28 15:27:23 +02:00
Andreas Kling
e971f5604c LibHTML: Implement some very simple selector matching.
We walk the entire DOM and check all selectors against all elements. Only
id, class and tag name are checked right now. There's no ancestor stack
or compound selectors. All in good time :^)
2019-06-27 20:40:21 +02:00
Andreas Kling
2b4eea5a50 LibHTML: Start fleshing out a StyleResolver class.
This will be responsible for matching selectors and creating LayoutStyle
objects for the document and its elements.
2019-06-27 17:47:59 +02:00
Andreas Kling
2282e89d3f AK: Use a SinglyLinkedList<T> as HashTable's bucket chain storage.
We were using a DoublyLinkedList<T> simply because it supported remove().
This patch consolidates the SinglyLinkedList iterators and adds remove().
2019-06-27 16:36:31 +02:00
Andreas Kling
7f613c79cd AK: Oops, fix typo in RemoveVolatile<T> helper. 2019-06-27 16:01:24 +02:00
Andreas Kling
516d736afe AK: Consolidate iterators for HashTable and DoublyLinkedList respectively.
Get rid of the ConstIterator classes for these containers and use templated
FooIterator<T, ...> and FooIterator<const T, ...> helpers.

This makes the HashTable class a lot easier to read.
2019-06-27 15:57:49 +02:00
Andreas Kling
50700c107f AK: Get rid of ConstVectorIterator.
We can achieve the same with just a VectorIterator<const Vector, const T>.
2019-06-27 14:52:12 +02:00
Andreas Kling
ebe108efa6 AK: Simplify HashMap a bit. 2019-06-27 14:27:26 +02:00
Andreas Kling
65e470c90a VisualBuilder: Use NonnullRefPtrVector. 2019-06-27 13:49:26 +02:00
Andreas Kling
d403e56494 Snake: Use NonnullRefPtrVector. 2019-06-27 13:46:31 +02:00
Andreas Kling
75a24c3a1f Kernel: More use of NonnullRefPtrVector in the kernel. 2019-06-27 13:44:26 +02:00
Andreas Kling
3bd47a2e09 AK: NonnullRefPtrVector should use Vector<T, inline_capacity> as its base.
We were forgetting to plumb through the inline capacity in the Base typedef.
2019-06-27 13:39:09 +02:00
Andreas Kling
601b0a8c68 Kernel: Use NonnullRefPtrVector in parts of the kernel. 2019-06-27 13:35:02 +02:00
Andreas Kling
e2b8a2315e LibHTML: Use NonnullRefPtrVector in the CSS and HTML parsers. 2019-06-27 13:23:22 +02:00
Andreas Kling
9ab3718266 AK: Allow constructing an empty NonnullRefPtrVector. 2019-06-27 13:23:10 +02:00
Andreas Kling
7cc9ce8380 LibHTML: Use NonnullRefPtrVector in LibHTML. 2019-06-27 12:16:20 +02:00
Andreas Kling
48108ec474 AK: Support range-for iteration over a NonnullRefPtrVector<T>.
This means you can now do this:

void harmonize(NonnullRefPtrVector<Voice>& voices)
{
    for (auto& voice : voices) {
        voice.sing(); // Look, no "->"!
    }
}

Pretty dang cool :^)
2019-06-27 12:11:58 +02:00
Andreas Kling
25a1bf0c90 AK: Add NonnullRefPtrVector<T>.
This is a slot-in convenience replacement for Vector<NonnullRefPtr<T>> that
makes accessors return T& instead of NonnullRefPtr<T>&.
Since NonnullRefPtr guarantees non-nullness, this allows you to access these
vector elements using dot (.) rather than arrow (->). :^)
2019-06-27 12:04:27 +02:00
Andreas Kling
f83263a72b Kernel: Use a raw VM region for sorting ELF symbols instead of a Vector.
This avoids putting pressure on kmalloc() during backtrace symbolication.
Since we dump backtrace for every process that exits, this is actually a
decent performance improvement for things like GCC that chain a lot of
processes together.
2019-06-27 10:49:49 +02:00
Andreas Kling
7a3f59ae3f LibHTML: Add a StyledNode class.
I'd like to try doing DOM -> style tree -> layout tree. I'm not exactly sure
how it's gonna work, but we'll figure it out as we go.
2019-06-27 08:37:47 +02:00
Andreas Kling
8f3f5ac8ce Kernel: Automatically populate page tables with lazy kernel regions.
If we get an NP page fault in a process, and the fault address is in the
kernel address range (anywhere above 0xc0000000), we probably just need
to copy the page table info over from the kernel page directory.

The kernel doesn't allocate address space until it's needed, and when it
does allocate some, it only puts the info in the kernel page directory,
and any *new* page directories created from that point on. Existing page
directories need to be updated, and that's what this patch fixes.
2019-06-26 22:27:41 +02:00
Andreas Kling
183205d51c Kernel: Make the x86 paging code slightly less insane.
Instead of PDE's and PTE's being weird wrappers around dword*, just have
MemoryManager::ensure_pte() return a PageDirectoryEntry&, which in turn has
a PageTableEntry* entries().

I've been trying to understand how things ended up this way, and I suspect
it was because I inadvertently invoked the PageDirectoryEntry copy ctor in
the original work on this, which must have made me very confused..

Anyways, now things are a bit saner and we can move forward towards a better
future, etc. :^)
2019-06-26 21:45:56 +02:00
Andreas Kling
0538adbabd LibC: Uhm, htonl() shouldn't byte-swap on big endian machines. 2019-06-26 21:10:56 +02:00
Andreas Kling
3c4497aa2d LibC: Clean up htonl() and ntohl() families.
Use __builtin_bswap() intrinsics for the byte swapping. Also don't swap on
systems where BYTE_ORDER != LITTLE_ENDIAN. This doesn't really affect us
at the moment since Serenity only targets x86, but I figured it doesn't hurt
to do things right. :^)
2019-06-26 20:05:04 +02:00
Andreas Kling
eb129bd730 AK: Use __builtin_bswap() in NetworkOrdered. 2019-06-26 20:01:48 +02:00
Andreas Kling
a2e5b821b4 AK: Simplify NetworkOrdered somewhat. 2019-06-26 16:26:59 +02:00