Commit graph

27027 commits

Author SHA1 Message Date
Karol Kosek
759d6df87d LibGUI: Add Gfx::ColorRole to Variant
For Theme Editor. :^)
2021-09-06 14:05:10 +04:30
Mustafa Quraish
c1ede97543 FontEditor: Don't loop over all glyphs to find selected one
Previously we would loop over all glyphs in the GlyphMap, compute
their rects, and then test to see if the mouse click position was
inside that rect. This is silly since each element in the glyph
map for a particular font is the same size, and we can just do
some coordinate manipulation to get the index directly.
2021-09-06 14:01:24 +04:30
Ali Mohammad Pur
63523d3836 Tests/LibRegex: Decrease the size of the fork chain test 2021-09-06 13:51:30 +04:30
Ali Mohammad Pur
abbe9da255 LibRegex: Make infinite repetitions short-circuit on empty matches
This makes (addmittedly weird) patterns like `(a*)*` work correctly
without going into an infinite fork loop.
2021-09-06 13:51:30 +04:30
Mustafa Quraish
f8570bd773 PixelPaint: Allow opening of files dropped onto application :^)
We can now drag-and-drop files onto PixelPaint to be able to open
them. Each dropped file opens in a separate editor (which is the
default behavior of Photoshop).
2021-09-06 10:36:08 +02:00
Mustafa Quraish
5a8c6b95e6 PixelPaint: Refactor main.cpp into MainWidget
Previously, all the UI setup was done in `main.cpp`, with a whole
bunch of lambdas,, and actions etc just being stored in the main
function. This is probably an artifact from back when it was first
created.

Most other applications now have a "MainWidget" class of some sort
which handles setting up all the UI/menubars, etc. More importantly,,
it also lets us handle application-wide events which we were
previously not able to do directly, since the main widget was just
a default GUI::Widget.

This patch moves all the core functionality of the PixelPaint
application into PixelPaint::MainWidget, which is then instantiated
by the main function. There is likely some more refactoring that
would help, but this commit is big enough as it is doing mostly
a direct port.
2021-09-06 10:36:08 +02:00
davidot
bbddfeef4b LibJS: Clean up token constructor and use method instead for identifiers
Having two large constructor with just one parameter difference in the
middle seems quite dangerous so just do it with a method.
2021-09-06 08:43:38 +01:00
davidot
3fee7b0d0b LibJS: Fix that windows style line endings were not ignored or converted
These are tested by test262 but the current test262-runner reads the
files in python which automatically converts \r\n to \n.
This meant that we passed the tests while we should not have.
2021-09-06 08:43:38 +01:00
Andreas Kling
f2512071f2 Kernel: Use TRY() in sys$getrandom() 2021-09-06 02:36:21 +02:00
Andreas Kling
a8516681b7 Kernel: Tidy up TmpFS and TmpFSInode construction
- Use KResultOr<NonnullRefPtr<T>>
- Propagate errors
- Use TRY() at call sites
2021-09-06 02:36:21 +02:00
Luke Wilde
5e61382849 LibWeb: Make Node.textContent more spec compliant
The current implementation felt a bit ad-hoc and notably allowed
textContent to operate on all node types. It also only returned the
child text content of the Node instead of the descendant text content.
2021-09-06 02:36:04 +02:00
Luke Wilde
d36838d050 LibWeb: Implement the (string) replace all operations for Node 2021-09-06 02:36:04 +02:00
Luke Wilde
67c73ddd59 LibWeb: Add [LegacyNullToEmptyString] to CharacterData.data
See https://dom.spec.whatwg.org/#characterdata
2021-09-06 02:18:53 +02:00
Luke Wilde
6e80458515 LibWeb: Add constructors for Text, DocumentFragment and Comment
These three nodes are the only nodes in the DOM spec with constructors.
2021-09-06 02:18:41 +02:00
Andreas Kling
398f8e7c96 Kernel: Use TRY() more in process-specific ProcFS code 2021-09-06 02:14:22 +02:00
Andreas Kling
f4a6b60570 Kernel: Use TRY() in Graphics::VirtIOGPU::FrameBufferDevice 2021-09-06 02:11:46 +02:00
Andreas Kling
17a12c8a30 Kernel: Use TRY() in FramebufferDevice 2021-09-06 02:10:01 +02:00
Andreas Kling
7a8061ba0c Kernel: Use TRY() in ISO9660FileSystem 2021-09-06 02:06:49 +02:00
Andreas Kling
a994f11f10 Kernel: Make AddressSpace::add_region() return KResultOr<Region*>
This allows us to use TRY() in a few places.
2021-09-06 02:02:06 +02:00
Andreas Kling
062cc804e7 Kernel: Use TRY() some more in Memory::AddressSpace 2021-09-06 01:59:30 +02:00
Andreas Kling
75564b4a5f Kernel: Make kernel region allocators return KResultOr<NOP<Region>>
This expands the reach of error propagation greatly throughout the
kernel. Sadly, it also exposes the fact that we're allocating (and
doing other fallible things) in constructors all over the place.

This patch doesn't attempt to address that of course. That's work for
our future selves.
2021-09-06 01:55:27 +02:00
Andreas Kling
cb71a73708 Kernel/USB: Tidy up UHCIDescriptorPool construction
- Use KResultOr<NonnullRefPtr<UHCIDescriptorPool<T>>
- Make the constructor private
- Use TRY() at call sites
2021-09-06 01:55:27 +02:00
Andreas Kling
91fe6b6552 Kernel/KCOV: Bring closer to typical SerenityOS coding style
- Remove a bunch of redundant `this->`
- Make class data members private and provide accessors instead
2021-09-06 01:55:27 +02:00
Andreas Kling
79fbad6df9 Kernel/USB: Tidy up USB::Transfer construction 2021-09-06 01:55:27 +02:00
Andreas Kling
f4a9a0d561 Kernel: Make VirtualRangeAllocator return KResultOr<VirtualRange>
This achieves two things:
- The allocator can report more specific errors
- Callers can (and now do) use TRY() :^)
2021-09-06 01:55:27 +02:00
Andreas Kling
21f7932ae2 Kernel: Use TRY() and adopt_nonnull_ref_or_enomem() in AnonymousVMObject 2021-09-06 01:55:27 +02:00
Andreas Kling
52cbbe1dc5 Kernel: Actually share committed CoW pages
Due to a double-move mistake, we were always clearing the shared
committed CoW pages in the parent when forking.
2021-09-06 01:55:27 +02:00
Andreas Kling
2f790cf78f Kernel: Make MM.commit_user_physical_pages() return KResultOr
..and use TRY() at call sites. :^)
2021-09-06 01:55:27 +02:00
Andreas Kling
98dc08fe56 Kernel: Use KResultOr better in ProcessGroup construction
This allows us to use TRY() more.
2021-09-06 01:55:27 +02:00
Andreas Kling
540d62d3b2 Kernel: Simplify WatchDescription::create() 2021-09-06 01:55:27 +02:00
Andreas Kling
5e2bae700d Kernel: Use TRY() in PTYMultiplexer::open() 2021-09-06 01:55:27 +02:00
Andreas Kling
4d961387c1 Kernel: Use TRY() some more in USB::Hub 2021-09-06 01:55:27 +02:00
Andreas Kling
8ceff65161 Kernel: Use TRY() some more in FileDescription 2021-09-06 01:55:27 +02:00
Andreas Kling
5516592748 Kernel: Use TRY() in BlockBasedFileSystem 2021-09-06 01:55:27 +02:00
Andrew Kaster
fe701052ea LibC: Expand region for global destructors when it reaches capacity
In 553361d we started mprotecting the atexit handlers when they are not
being modified or executed. As part of that commit, we unintentionally
changed the max number of global destructors from 1024 to 256 (on x86,
only 128 on x86_64). This patch expands the initial size of the global
destructors page to 2 pages from 1, and allows the pool to be expanded
at runtime by mapping a new set of pages and copying the AtExitEntries
over.
2021-09-06 01:55:14 +02:00
Ali Mohammad Pur
7589cc2494 LibJS: Handle possible allocation failure in ArrayBuffer(size_t)
...by replacing it with a ctor that takes the buffer instead, and
handling the allocation failure in ArrayBuffer::create(size_t) by
throwing a RangeError as specified by the spec.
2021-09-06 01:53:26 +02:00
Ali Mohammad Pur
d20fc922c5 Meta: Correct misuse of ByteBuffer::resize() as grow() in FuzziliJS 2021-09-06 01:53:26 +02:00
Ali Mohammad Pur
97e97bccab Everywhere: Make ByteBuffer::{create_*,copy}() OOM-safe 2021-09-06 01:53:26 +02:00
Ali Mohammad Pur
3a9f00c59b Everywhere: Use OOM-safe ByteBuffer APIs where possible
If we can easily communicate failure, let's avoid asserting and report
failure instead.
2021-09-06 01:53:26 +02:00
Ali Mohammad Pur
6606993432 AK: Add OOM-safe ByteBuffer::try_{resize,append,ensure_capacity}() APIs 2021-09-06 01:53:26 +02:00
Linus Groh
6ffc8f389e LibJS: Use different stack space limit values for with and without ASAN
Instead of having a single limit here, which we had to increase once to
work with ASAN enabled, check whether HAS_ADDRESS_SANITIZER is defined
and use 32 KiB, and 16 KiB otherwise (which is what we used previously).

This idea is shamelessly stolen from V8:
https://github.com/v8/v8/blob/b2b44af/src/execution/isolate.cc#L1381-L1387
2021-09-05 22:17:09 +01:00
Linus Groh
941ff0cf60 LibJS: Prevent stack overflow if Proxy handler's __proto__ is the Proxy
Fixes #9322.
2021-09-05 22:17:09 +01:00
Linus Groh
9998a2c91e LibJS: Add ErrorType::CallStackSizeExceeded
I'm about to add another use of this, so let's add an ErrorType for it
instead of hardcoding the message for a third time.
2021-09-05 22:17:09 +01:00
Brian Gianforcaro
782e7834c3 Tests: Reduce the execution time of the LibC TestQSort test
Executing 100 times vs 10 times doesn't increase test coverage
substantial, this API is stable and more iterations is just a
waste of time.

Without KVM this test is a clear outlier in runtime during CI:

```
START  LibC/TestQsort (106/172)
PASS   LibC/TestQsort (41.233692s)
```
2021-09-05 22:17:28 +02:00
Brian Gianforcaro
bb58a4d943 Kernel: Make all Spinlocks use u8 for storage, remove template
The default template argument is only used in one place, and it
looks like it was probably just an oversight. The rest of the Kernel
code all uses u8 as the type. So lets make that the default and remove
the unused template argument, as there doesn't seem to be a reason to
allow the size to be customizable.
2021-09-05 20:46:02 +02:00
Brian Gianforcaro
5905d2e9e9 RequestServer: Exit early to avoid executing protocol destructors
I broke this when I made the protocol objects be wrapped by smart
pointers to appease static analysis.

The Protocol base class currently VERIFY's that it's never called.
So to have the best of both worlds until someone actually fixes
the code to do proper de-registration, just call `exit(..)` so the
smart pointers never go out of scope.
2021-09-05 20:12:09 +02:00
Brian Gianforcaro
293e7ccfc7 Documentation: Add Patterns.md
The purpose of this document is to track and describe the various
patterns used through the SerenityOS code base.
2021-09-05 20:08:57 +02:00
Brian Gianforcaro
3e45c3ed90 Userland: Switch static_assert of type sizes to AK::AssertSize 2021-09-05 20:08:57 +02:00
Brian Gianforcaro
472454cded Kernel: Switch static_asserts of a type size to AK::AssertSize
This will provide better debug ability when the size comparison fails.
2021-09-05 20:08:57 +02:00
Brian Gianforcaro
112de58fe0 AK: Add AssertSize utility template to provide rich type size assertions
This type is useful, as the sizes will be visible in the compiler error
messages, as they will be part of the template parameters. This is not
possible with a normal static_assert of the sizeof a type.
2021-09-05 20:08:57 +02:00