summaryrefslogtreecommitdiff
path: root/Libraries
AgeCommit message (Collapse)Author
2020-11-10AK: Make RefPtr, NonnullRefPtr, WeakPtr thread safeTom
This makes most operations thread safe, especially so that they can safely be used in the Kernel. This includes obtaining a strong reference from a weak reference, which now requires an explicit call to WeakPtr::strong_ref(). Another major change is that Weakable::make_weak_ref() may require the explicit target type. Previously we used reinterpret_cast in WeakPtr, assuming that it can be properly converted. But WeakPtr does not necessarily have the knowledge to be able to do this. Instead, we now ask the class itself to deliver a WeakPtr to the type that we want. Also, WeakLink is no longer specific to a target type. The reason for this is that we want to be able to safely convert e.g. WeakPtr<T> to WeakPtr<U>, and before this we just reinterpret_cast the internal WeakLink<T> to WeakLink<U>, which is a bold assumption that it would actually produce the correct code. Instead, WeakLink now operates on just a raw pointer and we only make those constructors/operators available if we can verify that it can be safely cast. In order to guarantee thread safety, we now use the least significant bit in the pointer for locking purposes. This also means that only properly aligned pointers can be used.
2020-11-10Kernel+LibC: Add adjtime(2)Nico Weber
Most systems (Linux, OpenBSD) adjust 0.5 ms per second, or 0.5 us per 1 ms tick. That is, the clock is sped up or slowed down by at most 0.05%. This means adjusting the clock by 1 s takes 2000 s, and the clock an be adjusted by at most 1.8 s per hour. FreeBSD adjusts 5 ms per second if the remaining time adjustment is >= 1 s (0.5%) , else it adjusts by 0.5 ms as well. This allows adjusting by (almost) 18 s per hour. Since Serenity OS can lose more than 22 s per hour (#3429), this picks an adjustment rate up to 1% for now. This allows us to adjust up to 36s per hour, which should be sufficient to adjust the clock fast enough to keep up with how much time the clock currently loses. Once we have a fancier NTP implementation that can adjust tick rate in addition to offset, we can think about reducing this. adjtime is a bit old-school and most current POSIX-y OSs instead implement adjtimex/ntp_adjtime, but a) we have to start somewhere b) ntp_adjtime() is a fairly gnarly API. OpenBSD's adjfreq looks like it might provide similar functionality with a nicer API. But before worrying about all this, it's probably a good idea to get to a place where the kernel APIs are (barely) good enough so that we can write an ntp service, and once we have that we should write a way to automatically evaluate how well it keeps the time adjusted, and only then should we add improvements ot the adjustment mechanism.
2020-11-10LibC: Add POSIX1 minimum limits to limits.hBrendan Coles
2020-11-10LibVT: Add TerminalWidget::scroll_to_bottom() APIAndreas Kling
(And use this internally when scrolling to bottom on non-modifier keydown events.)
2020-11-10LibGUI: Limit the height of item text in IconViewAmusedNetwork
Set the max height of the text_rect to be the height difference between two icons. Calculate the number of text lines that can be displayed in this height, and display only that many.
2020-11-10TextEditor: Go-to-line now shows line in middle of view (#4008)Jack Byrne
2020-11-09AK: Rename new_out to out and new_warn to warn.asynts
2020-11-09LibWeb: Add support for reflected boolean valuesLuke
Also throw in some missing reflected DOMString values
2020-11-08LibDebug: Use move semantics when populating abbreviations mapAndreas Kling
2020-11-08LibDebug: Avoid copying AttributeSpecifications when iterating themAndreas Kling
2020-11-08LibDebug: Shrink some of the high-volume data structuresAndreas Kling
We quickly allocate a *ton* of these when loading large executables.
2020-11-08LibGUI: Prevent multiple drag initiations while drag messages are passedAnotherTest
2020-11-08LibGUI+WindowServer: Make DragOperation hold a MimeData instanceAnotherTest
...instead of maybe bitmap + a single mime type and its corresponding data. This allows drag&drop operations to hold multiple different kinds of data, and the views/applications to choose between those. For instance, Spreadsheet can keep the structure of the dragged cells, and still provide text-only data to be passed to different unrelated editors.
2020-11-08LibIPC: Add support for passing around ByteBuffers and HashMap<K, V>AnotherTest
It should be noted that using a shared buffer should still be preferred over passing a raw ByteBuffer over the wire.
2020-11-08LibGfx: Add methods to serialise and deserialise a BitmapAnotherTest
Unlike `to_shared_buffer()` and co, these methods do *not* require extra metadata about the bitmap.
2020-11-08LibGfx: remove debug printfs from GIFLoaderPeter Nelson
2020-11-08LibGfx: gracefully handle GIFs with frame decode errorsPeter Nelson
GIFLoader now tracks the state of errors during the decoding process and will fall back to displaying the first frame of the GIF if any of the subsequent frames fail to decode.
2020-11-08LibGUI: Limit ScrollableWidget::available_size() width/height to 0Linus Groh
The current implementation is lying, it returns negative values if the inner rect has a zero width or height but also a scrollbar - which doesn't mean there's a "negative size" available though; it's still "no size available", i.e. 0.
2020-11-08LibWeb: Don't attempt to create new bitmap for zero-size OOPWVLinus Groh
It's not possible to construct a Gfx::Bitmap with empty size. Let the client know the new viewport rect and return before even attempting to create new front and back bitmaps. Also consider that we might have to paint the widget but not have a front/back bitmap available (e.g. when only part of a scrollbar is visible, and the inner rect is empty).
2020-11-08LibJS: Throw RuntimeError when reaching the end of the stackLinus Groh
This prevents stack overflows when calling infinite/deep recursive functions, e.g.: const f = () => f(); f(); JSON.stringify({}, () => ({ foo: "bar" })); new Proxy({}, { get: (_, __, p) => p.foo }).foo; The VM caches a StackInfo object to not slow down function calls considerably. VM::push_call_frame() will throw an exception if necessary (plain Error with "RuntimeError" as its .name).
2020-11-08LibJS+AK: Move cross-platform stack bounds code from JS::Heap to AK::StackInfoLinus Groh
This will be useful for other things than the Heap, maybe even outside of LibJS.
2020-11-08LibWeb: Don't assume backing store allocation succeeds on OOPWV resizeAndreas Kling
Backing store allocation can fail if the requested size is too small, or too large. We should not crash when this happens. Fixes #3986.
2020-11-08UserspaceEmulator+LibC: Have UE notice realloc() and update accountingAndreas Kling
When a mallocation is shrunk/grown without moving, UE needs to update its precise metadata about the mallocation, since it tracks *exactly* how many bytes were allocated, not just the malloc chunk size.
2020-11-08LibWeb: Use the system theme's button text color for <input> buttonsAndreas Kling
2020-11-08LibC: Add two little assertions in malloc() and malloc_size()Andreas Kling
2020-11-08LibDebug: Handle the "set ISA" standard opcodeAndreas Kling
I don't know what to do with this information, but let's at least skip over the opcode instead of asserting.
2020-11-08LibDebug: Handle AttributeDataForm::SData (DW_FORM_sdata)Andreas Kling
This is a LEB128-encoded signed constant.
2020-11-07LibCore: Run clang-format on ArgsParser.cppAndreas Kling
2020-11-07LibCore: Add an ArgsParser::add_option() overload for doublesNico Weber
2020-11-07LibWeb: Restrict HTML form submissions to permitted URL protocolsBrendan Coles
Form submissions to file:// URLs are now permitted only if the submitting document is also a file:// URL and the form method is "get". Form submissions to URLs with a http(s):// URL protocol are permitted. Form submissions for all other URL protocols are rejected.
2020-11-07LibGfx: Remove debug spam about successful font lookupsAndreas Kling
2020-11-07LibJS: Use regular stack for VM call frames instead of Vector storageAndreas Kling
Keeping the VM call frames in a Vector could cause them to move around underneath us due to Vector resizing. Avoid this issue by allocating CallFrame objects on the stack and having the VM simply keep a list of pointers to each CallFrame, instead of the CallFrames themselves. Fixes #3830. Fixes #3951.
2020-11-07LibWeb: Reject iframing file:// URLs if document is not a file:// URLBrendan Coles
2020-11-07LibJS: Remove unused variable m_has_property_table in ShapeLuke
2020-11-07LibJS: Use pow instead of __bulitin_pow on clangLuke
__bulitin_pow doesn't seem to exist on clang, at least it didn't build with it.
2020-11-07LibJS: Use element index as key for array spread in objectLinus Groh
This fixes spreading of arrays with holes in object literals where the inserted keys are not consecutive numbers. Fixes #3967.
2020-11-07LibJS: Set prototype of GlobalObject to ObjectPrototypeLinus Groh
As the global object is constructed and initialized in a different way than most other objects we were not setting its prototype! This made things like "globalThis.toString()" fail unexpectedly.
2020-11-07LibJS: Don't create StringOrSymbol(String) if from_value() failsLinus Groh
If value.to_string() throws an exception and returns a null string we must create an invalid StringOrSymbol, not one from the null string (which ASSERT()s).
2020-11-07LibWeb: Load favicon.ico only for http/https URLsBrendan Coles
2020-11-07LibJS: Skip trailing empty values in IndexedPropertyIteratorLinus Groh
When we reach the end of the pre-computed indices vector we can just skip to the end (array-like size) as only empty values will follow. Fixes #3970.
2020-11-06LibGUI: Clip rubber band to IconView widget content areaJoseph Bywater
Add a clip rect for the rubber band painter of widget_inner_rect This ensures the rubber band is not drawn over the scrollbars. Fixes #3926
2020-11-06LibJS: Handle circular references in Array.prototype.toLocaleString()Linus Groh
Also use ArmedScopeGuard for removing seen objects to account for early returns. Fixes #3963.
2020-11-06LibGUI: Fix AbstractView selection after initial focusin eventJoseph Bywater
After moving the cursor to the home position, clear the selection. Fixes #3925.
2020-11-05LibJS: Use array-like size for IndexedProperties::is_empty()Linus Groh
Some things, like (the non-generic version of) Array.prototype.pop(), check is_empty() to determine whether an action, like removing elements, can be performed. We need to know the array-like size for that, not the size of the underlying storage, which can be different - and is not something IndexedProperties should expose so I removed its size(). Fixes #3948.
2020-11-05LibJS: Fix Object::delete_property() with numeric string propertyLinus Groh
- We have to check if the property name is a string before calling as_string() on it - We can't as_number() the same property name but have to use the parsed index number Fixes #3950.
2020-11-05LibJS: ASSERT(property_name.is_valid()) in more Object methodsLinus Groh
2020-11-04LibJS: Fix ProxyObject get/set with symbol property nameLinus Groh
We can't assume that property names can be converted to strings anymore, as we have symbols. Use name.to_value() instead. This makes something like this possible: new Proxy(Object, { get(t, p) { return t[p] } })[Symbol.hasInstance]
2020-11-04LibJS: Replace a bunch of vm() calls in ProxyObject with referenceLinus Groh
This was probably a result of search & replace, it's quite ridiculous in some places. Let use the existing pattern of getting a reference to the VM once at each function start consistently.
2020-11-04LibJS: Implement Object(value) constructorLinus Groh
Not sure why we didn't have this yet, it's super simple :^)
2020-11-04LibGfx: Load the system default fonts by nameAndreas Kling
Instead of loading them by absolute path, that is.