Commit graph

2983 commits

Author SHA1 Message Date
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
Lawrence Manning
f0a6b42066 Move common Application build steps into their own Makefile.common
Further consolidation is of course possible, eg the Games/ programs
follow the same rules more or less.
2019-06-25 21:35:50 +02:00
Andreas Kling
8247dad540 PaintBrush: Allow RGBA32 to use the bucket and spray tools.
Eventually I'd like to do some kind of bitmap layers, and we definitely want
alpha channel support then, so let's just not paint ourselves into an
uncomfortable corner early on. :^)
2019-06-25 20:33:44 +02:00
Andreas Kling
5cb324ee02 GraphicsBitmap: Add bpp(), returns the number of bits per pixel. 2019-06-25 20:33:24 +02:00
Andreas Kling
b529b4a3e6 PaintBrush: Add support for opening files.
Obviously this only supports whatever PNG files that load_png() can decode
at the moment.
2019-06-25 20:27:32 +02:00
Andreas Kling
8adae51b35 LibHTML: Add a simple TreeNode<T> template for making trees.
We'll be making a lot of trees here, so let's share code during bootstrap.
Eventually some of these classes are gonna want custom trees but for now
we can just fit them all into the same clothes.
2019-06-25 19:46:01 +02:00
Andreas Kling
e9b619c4aa JsonParser: Support basic escaped string characters.
I didn't implement \uXXXX-style escape in this patch. That's a FIXME.
2019-06-25 16:58:30 +02:00
Andreas Kling
6469d7f043 LibHTML: Flesh out the code to dump a StyleSheet object graph. 2019-06-25 06:31:47 +02:00
Andreas Kling
048705e1c2 Kernel: Share code between all the exceptions that cause process crash. 2019-06-25 05:55:18 +02:00
Andreas Kling
583606a2b1 StringImpl: Fix possible uninitialized access in StringImpl::create().
If the provided length is 0, there's no need to dereference the const char*.
2019-06-24 14:38:44 +02:00
Andreas Kling
643a43f278 AK: Add JsonValue::to_string(default_value = {}). 2019-06-24 14:25:45 +02:00
Andreas Kling
266fed8c00 AK: Let's put the JSON parsing in a separate class. 2019-06-24 13:39:45 +02:00
Andreas Kling
8392c549a3 JsonValue: Add as_array() and as_object(). 2019-06-24 12:03:31 +02:00
Andreas Kling
dd36f797d5 JsonObject: Let the compiler generate a copy constructor.
This was only needed while HashMap was noncopyable. :^)
2019-06-24 12:03:11 +02:00
Andreas Kling
15003245cd JsonArray: Add for_each() helper. 2019-06-24 12:02:31 +02:00
Andreas Kling
2c1c4ab116 AK: Make it possible to move and copy HashMap and HashTable.
Previously it was only possible to move them, but we should allow copying
as well, since it's gonna be useful for many things.
2019-06-24 11:57:54 +02:00
Andreas Kling
009b9bfd10 AK: Implement a naive JSON parser.
This parser assumes that the JSON is well-formed and will choke horribly
on invalid input.

Since we're primarily interested in parsing our own output right now, this
is less of a problem. Longer-term we're gonna need something better. :^)
2019-06-24 11:28:24 +02:00
Andreas Kling
bad8ab697b NonnullRefPtr: Simplify copy constructors. 2019-06-24 10:23:59 +02:00
Andreas Kling
2dd54f062a AK: Mark some helper things constexpr. 2019-06-24 10:13:28 +02:00
Andreas Kling
bf97b9589d NonnullRefPtr: Some improvements.
- Delete the default constructor instead of just making it private.
  It's never valid to create an empty NonnullRefPtr.

- Add copy assignment operators. I originally omitted these to force use
  of .copy_ref() at call sites, but the hassle/gain ratio is minuscule.

- Allow calling all the assignment operators in all consumable states.
  This codifies that it's okay to overwrite a moved-from NonnullRefPtr.
2019-06-24 09:58:21 +02:00
faissaloo
25e8498dcc LibM: Switch sin() for fast sin() 2019-06-23 22:13:29 +02:00
CallumAttryde
e38c3bce15 add ~/.history file for Shell, stores entire command log and loads recent commands into history buffer 2019-06-23 22:08:12 +02:00
Andreas Kling
eedb4f6b2f QuickShow: Allow panning and zooming the image instead of stretching it.
This needs more work and polish, but it's a step in a more pleasant and
useful direction.

Also turn QuickShow into a fully-fledged "application". (By that, I really
just mean giving it its own Applications/ subdirectory.)
2019-06-23 16:35:43 +02:00
Andreas Kling
cf0d05d54a Terminal: Don't compute buffer positions outside the possible area. 2019-06-23 15:34:36 +02:00
Andreas Kling
5aefd7f828 PaintBrush: Implement a thickness setting for the pen tool.
Painter gains the ability to draw lines with arbitrary thickness.
It's basically implemented by drawing filled rects for thickness>1.

In PaintBrush, Tool classes can now override on_contextmenu() to
provide a context menu for the toolbox button. :^)
2019-06-23 10:00:02 +02:00
Andreas Kling
08c04f0a41 Terminal: Add basic mouse selection with copy and paste.
Left mouse button selects (and copies the selection on mouse up).
The right mouse button then pastes whatever's on the clipboard. I always
liked this behavior in PuTTY, so now we have it here as well :^)
2019-06-23 09:18:17 +02:00
Andreas Kling
2cebf78fad GTextEditor: Add assertion that did_change() isn't called in readonly mode. 2019-06-23 08:23:37 +02:00
Andreas Kling
6a0011dcea LibGUI+VisualBuilder: Support custom editing widgets for property values.
Implemented this by letting GAbstractViews provide a GModelEditingDelegate
for a given index, which then knows how to create and setup a custom widget
appropriate for the data type being edited.
2019-06-23 08:18:28 +02:00
Andreas Kling
1d0ada32cc GComboBox: Add set_text() and on_return_pressed hook.
Also give focus back to the editor when closing the list popup window.
2019-06-23 07:55:28 +02:00
Andreas Kling
0af61e9123 GVariant: Add to_string(GVariant::Type) helper. 2019-06-23 07:54:46 +02:00
Andreas Kling
0e18201b7e GTextEditor: Don't replace selection on enter press in single-line editor. 2019-06-23 07:53:58 +02:00