summaryrefslogtreecommitdiff
path: root/Libraries
AgeCommit message (Collapse)Author
2020-09-15LibVT+LibLine: Use `1;mods` CSI parameters for ctrl/alt/shift-arrow keysNico Weber
xterms send a bitmask (+ 1) in the 2nd CSI parameter if "special" keys (arrow keys, pgup/down, etc) are sent with modifiers held down. Serenity's Terminal used to send ^[[O, which is a nonexistent escape sequence and a misread of VT100's ^[O (ie the '[' is replaced by 'O'). Since the xterm scheme also supports shift and alt modifiers, switch to that. More flexible, and makes ctrl-left/right and alt-left/right work in SerenityOS's bash port. Also do this for page up/down. No behavior change for SerenityOS's Shell.
2020-09-15LibLine: Parse CSI parameters and immediatesNico Weber
No behavior change, but it makes it easy to handle page up and page down if we wanted to make them do something in libline.
2020-09-14AK: Lower the requirements for InputStream::eof and rename it.asynts
Consider the following snippet: void foo(InputStream& stream) { if(!stream.eof()) { u8 byte; stream >> byte; } } There is a very subtle bug in this snippet, for some input streams eof() might return false even if no more data can be read. In this case an error flag would be set on the stream. Until now I've always ensured that this is not the case, but this made the implementation of eof() unnecessarily complicated. InputFileStream::eof had to keep a ByteBuffer around just to make this possible. That meant a ton of unnecessary copies just to get a reliable eof(). In most cases it isn't actually necessary to have a reliable eof() implementation. In most other cases a reliable eof() is avaliable anyways because in some cases like InputMemoryStream it is very easy to implement.
2020-09-14LibGUI: Minor consistency cleanup in AbstractView::set_cursor() (#3478)pkotzbach
2020-09-14LibGfx+LibGUI: Allow setting tab text alignment with set_property()Andreas Kling
2020-09-14LibGUI: Add TabWidget::set_property() and handle some propertiesAndreas Kling
2020-09-14LibGUI: Add registration for GUI::TabWidgetAndreas Kling
2020-09-14LibGUI: Use Core::Object::set_property() to handle JSON GUI propertiesAndreas Kling
Piggyback on the existing mechanism to set individual properties. This doesn't cover layouts or child widgets, but the per-widget own properties can be set this way. Any property can now be set in JSON GUI, all you need to do is handle it in the relevant Core::Object::set_property() override. :^)
2020-09-14LibGUI: Allow setting widget visibility from JSON GUI specAndreas Kling
2020-09-14LibGUI: Complain about malformed "layout" values in JSON GUIAndreas Kling
2020-09-14LibCore: Include object names in Object::dump_tree() outputAndreas Kling
2020-09-14LibGUI: Start building a way to instantiate GUI from JSONAndreas Kling
My original idea for GUI building tools was to have the "VisualBuilder" app generate C++ code which in turn programmatically instantiated UI. That never really materialized in any useful way beyond static UIs. This is a fresh, new approach: using JSON to declare the UI and parsing and constructing this UI at runtime. This will allow for way more dynamic and flexible approaches to GUI development (I think.) The basic idea is that you pass a JSON string to Widget::load_from_json and it takes care of the rest. This first version supports basic box layouts and instantiation of arbitrary widgets, as long as those widgets have been registered. This code has some pretty rough edges right now as it's evolving and we need to figure out a lot of things about how it should work. Nevertheless, it feels pretty cool. :^)
2020-09-14LibWeb: Register the InProcessWebView widgetAndreas Kling
2020-09-14LibGUI: Improve widget registration mechanism a bitAndreas Kling
Allow registering widgets from namespaces other than GUI. :^) Also add a few widgets.
2020-09-13LibGfx: Remove unused file FloatPoint.hAndreas Kling
2020-09-13LibGUI: Make some GUI event getters return const referencesAndreas Kling
There's no good reason to return rects/sizes/positions by value.
2020-09-13Kernel: Make copy_to/from_user safe and remove unnecessary checksTom
Since the CPU already does almost all necessary validation steps for us, we don't really need to attempt to do this. Doing it ourselves doesn't really work very reliably, because we'd have to account for other processors modifying virtual memory, and we'd have to account for e.g. pages not being able to be allocated due to insufficient resources. So change the copy_to/from_user (and associated helper functions) to use the new safe_memcpy, which will return whether it succeeded or not. The only manual validation step needed (which the CPU can't perform for us) is making sure the pointers provided by user mode aren't pointing to kernel mappings. To make it easier to read/write from/to either kernel or user mode data add the UserOrKernelBuffer helper class, which will internally either use copy_from/to_user or directly memcpy, or pass the data through directly using a temporary buffer on the stack. Last but not least we need to keep syscall params trivial as we need to copy them from/to user mode using copy_from/to_user.
2020-09-13Terminal: Make sure empty hrefs set a null string on AttributeNico Weber
Else, we store an empty but allocated string for each Attribute after a href was emitted (since it's ended by a non-null empty string), which makes Line objects very expensive to destroy and to modify. Reduces `disasm /bin/id` from 414ms to 380ms (min-of-5). There's a lot more perf wins to be had with better href handling (most lines don't have any hrefs, so instead of storing a string per Attr, maybe we could have a vector of hrefs per line and int offsets into that in each Attr for example), but this is a simple, obvious, and effective improvement, so let's start with this.
2020-09-12LibGfx: restructure Bitmap ctor to expect an alloc'd backing storePeter Nelson
Moves Bitmap backing store creation to the static create() methods. This backing store is then passed into the Bitmap constructor. This allows us correctly return nullptr from create() in the event that memory allocation fails.
2020-09-12LibGfx: return clone from frame() instead of underlying framebufferPeter Nelson
This prevents frame() from modifying the contents of the same bitmap that was returned from previous calls to frame()
2020-09-12LibWeb: cache in-process decoded images in ImageResourcePeter Nelson
Otherwise cloned Bitmaps returned by the decoder will be prematurely freed
2020-09-12LibGfx: add Bitmap::clone() methodPeter Nelson
2020-09-12LibWeb: Fix layout of replaced with width:auto + no intrinsic ratioAndreas Kling
We can't compute width based on the intrinsic ratio if we have no intrinsic ratio! The comment was correct, the code was not.
2020-09-12LibWeb: Implement <input type=submit> without using LibGUIAndreas Kling
Following in the footsteps of <input type=checkbox>, this patch adds LayoutButton which implements a basic push button using LibGfx styling primitives.
2020-09-12LibWeb: Two mouse event handling fixesAndreas Kling
- After letting a LayoutNode handle a mouseup, re-do the hit test since things may have changed. - Make sure we always update the document's hovered node.
2020-09-12LibWeb: Do not handle mouse events on disabled checkboxesredoste
2020-09-12LibIPC: Remove unused DisconnectedEvent mechanismAndreas Kling
This was previously used to defer handling disconnections until the next event loop iteration. We now achieve the same with simple use of deferred_invoke(). :^)
2020-09-12LibIPC: Move notifier handling entirely to IPC::Connection base classAndreas Kling
2020-09-12LibIPC: Remove debug spam on disconnectionAndreas Kling
2020-09-12LibWeb: Support window.alert() in multi-process contextAndreas Kling
Alerts are now delegated to the embedding GUI process.
2020-09-12LibIPC: Share most of the code between {Client,Server}ConnectionAndreas Kling
This patch introduces IPC::Connection which becomes the new base class of ClientConnection and ServerConnection. Most of the functionality has been hoisted up to the base class since almost all of it is useful on both sides. This gives us the ability to send synchronous messages in both directions, which is needed for the WebContent server process. Unlike other servers, WebContent does not mind blocking on a response from its client.
2020-09-12LibC: Avoid write-back of unused valueBen Wiederhake
This might make sleep() faster by up to pi nanoseconds, or less. It's more about avoiding a senseless write than about optimization.
2020-09-12LibC: Don't advertise wrong functionsBen Wiederhake
str{,n}casecmp is supposed to be *only* declared by strings.h, note the trailing 's' in the filename. We don't have any implementation for strlcat; using any strcat variants is a bad idea anyway, given our implementation of AK::String. TODO: Find a way to lint for declared-but-nowhere-defined functions.
2020-09-12Kernel: Fix various forward declarationsBen Wiederhake
I decided to modify MappedROM.h because all other entried in Forward.h are also classes, and this is visually more pleasing. Other than that, it just doesn't make any difference which way we resolve the conflicts.
2020-09-12LibMarkdown: Make warning messages conditionalBen Wiederhake
This is especially a problem during fuzzing.
2020-09-12LibGUI: Use new Bitmap::minimum_pitch methodBen Wiederhake
Also, make sure that the painter actually draws on a RGB(A) bitmap. Closes #3460.
2020-09-12LibJS: Check validity of computed_property_name() result before using itLinus Groh
This fixes two cases obj[expr] and obj[expr]() (MemberExpression and CallExpression respectively) when expr throws an exception and results in an empty value, causing a crash by passing the invalid PropertyName created by computed_property_name() to Object::get() without checking it first. Fixes #3459.
2020-09-12LibJS: Stop unwinding and reset exception for TryStatement finalizerLinus Groh
This fixes two issues with running a TryStatement finalizer: - Temporarily store and clear the exception, if any, so we can run the finalizer block statement without it getting in our way, which could have unexpected side effects otherwise (and will likely return early somewhere). - Stop unwinding so more than one child node of the finalizer BlockStatement is executed if an exception has been thrown previously (which would have called unwind(ScopeType::Try)). Re-throwing as described above ensures we still unwind after the finalizer, if necessary. Also add some tests specifically for try/catch/finally blocks, we didn't have any!
2020-09-12LibJS: Extract most of Interpreter's run() into execute_statement()Linus Groh
Interpreter::run() was so far being used both as the "public API entry point" for running a JS::Program as well as internally to execute JS::Statement|s of all kinds - this is now more distinctly separated. A program as returned by the parser is still going through run(), which is responsible for creating the initial global call frame, but all other statements are executed via execute_statement() directly. Fixes #3437, a regression introduced by adding ASSERT(!exception()) to run() without considering the effects that would have on internal usage.
2020-09-12LibGfx: Validate size of incoming shared bitmapBen Wiederhake
Errors like this became more likely due to the 'optimized' memory usage. Also, this prevents the WindowServer from being killed by a goofy program sharing an incomplete bitmap, and likely some other scenarios.
2020-09-12LibGfx: Saner memory usage of indexed bitmapsBen Wiederhake
Indexed bitmaps used to allocate four times the required amount of memory. Also, we should acknowledge that the underlying data is not always RGBA32, and instead cast it only when the true type is known.
2020-09-12LibGfx: Remove redundant bits() methodBen Wiederhake
In all circumstances, this returned exactly the same thing as scanline_u8(), so let's just remove the silly detour. This does not add any new dependency on Bitmap-internals, because that already existed.
2020-09-12LibGfx: Don't blindly trust file-internal offsetBen Wiederhake
This also touches the return type of dib_size(), because kjdsfg
2020-09-12LibGfx: Nicer error reporting for bitmap allocationBen Wiederhake
2020-09-12LibGfx: Protect against over-large bitmapsBen Wiederhake
2020-09-12LibJS: Fix start position of multi-line tokensBen Wiederhake
This broke in case of unterminated regular expressions, causing goofy location numbers, and 'source_location_hint' to eat up all memory: Unexpected token UnterminatedRegexLiteral. Expected statement (line: 2, column: 4294967292)
2020-09-11LibWeb: Protect LayoutCheckBox against crashes after event dispatchAndreas Kling
After dispatching a "change" event due to the checked state being modified, we may have been removed from the layout tree. Make LayoutCheckBox protect itself to prevent this from crashing. Also, add a little test page for checkboxes. :^)
2020-09-11LibWeb: Dispatch a "change" event when <input> checked state changesAndreas Kling
2020-09-11LibWeb: Add basic support for <input type=checkbox>Andreas Kling
This is implemented entirely inside LibWeb, there is no GUI::CheckBox widget instantiated, unlike other input types. All input types should be moved to this new style of implementation.
2020-09-11LibWeb: Allow layout nodes to receive and track mouse eventsAndreas Kling
To implement form controls internally in LibWeb (necessary for multi process forms), we'll need the ability to handle events since we can't rely on LibGUI widgets anymore. A LayoutNode can now override wants_mouse_events() and if it returns true, it will now receive mousedown, mousemove and mouseup events. :^)