Commit Graph

4860 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
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
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
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
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
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
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
3e45c3ed90 Userland: Switch static_assert of type sizes to AK::AssertSize 2021-09-05 20:08:57 +02:00
Ali Mohammad Pur
09dd397160 LibWeb+LibWasm: Implement the WebAssembly.Table object 2021-09-05 15:42:50 +04:30
Ali Mohammad Pur
d52a26de3f LibWasm: Move the vector size limit to Constants.h and increase it a bit 2021-09-05 15:42:50 +04:30
Brian Gianforcaro
d8de352ead LibJS: Declare type aliases with "using" instead of "typedef" 2021-09-05 09:48:43 +01:00
luiz
964249a5b0 LibGUI: Fixes modified indicator behavior after saving
Pior to this change when the user added text after having saved the file
the Text Editor wouldn't enable the modified flag, unless this new text
was a new line.

This happened because the UndoStack was merging the Command added by
the new text with the old text one, and when is_current_modified()
was called, the m_stack_index would not have been incremented, and
it would return false.

In this change was added a condition to verify if the modified tag is
active, and the merge is only done if the document is already modified.
2021-09-04 21:04:33 +02:00
Idan Horowitz
e8f6840471 AK+LibRegex: Disable construction of views from temporary Strings 2021-09-04 21:01:15 +02:00
Andreas Kling
24ef8b118a LibSymbolication: Unbreak symbolication with -z separate-code linking
We were incorrectly assuming that the mapped .text segment for an ELF
image was always at the base of the image mapping. Now that we have
.rodata mappings as well, it's possible for one of them to come before
the .text.
2021-09-04 20:30:56 +02:00
Andreas Kling
b7ee0191ea LibELF: Name non-executable map regions ".rodata" instead of ".text" 2021-09-04 20:30:56 +02:00
Andreas Kling
e40e91b9df LibDebug: Use HashMap::ensure() in DebugInfo::prepare_lines() 2021-09-04 20:30:56 +02:00
Andreas Kling
500067d3a6 LibGfx: Make FontDatabase cache store fonts in NonnullRefPtr
We don't cache failed font lookups, so there's no need for nullity here.
2021-09-04 20:30:56 +02:00
Linus Groh
0094259d72 LibJS: Implement Intl.DisplayNames.supportedLocalesOf() 2021-09-04 19:08:18 +01:00
Linus Groh
8f3a5ba5d8 LibJS: Add Array::create_from() for generic Vector<T>
It relies on a mapper function to convert each T& to a JS::Value. This
allows us to avoid awkward Vector<T> to MarkedValueList conversion at
the call site.
2021-09-04 19:08:18 +01:00
sin-ack
1999b66f38 LibGfx: Intersect the bounding box with the main rect in draw_text
Without this, the bounding rect for the text as generated by TextLayout
can go beyond the bounds of the user-supplied drawing rect and cause the
text to overlap because of the line_rect.intersect(rect) a few lines
below.
2021-09-04 16:48:27 +02:00
Idan Horowitz
1a19d2c2df LibGfx: Stop using a Utf8View that points to a temporary String 2021-09-04 16:13:30 +02:00
Idan Horowitz
72b21343ad LibGfx: Convert line text into a Utf8View before finding its direction
We were accidentally calling TextDirection::get_text_direction with a
String instead of a UtfView, which meant each byte was treated as a
codepoint, resulting in incorrect identification of text direction.
2021-09-04 16:13:30 +02:00
Ben Wiederhake
7224308358 LibGfx: Reject GIFs with ridiculously large symbols
This also prevents exploitation by malicious GIFs.
Found by OSS Fuzz, long-standing issue
(since 259f8541fc)
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=29034
2021-09-04 16:00:25 +02:00
Ben Wiederhake
39c09cec88 LibGfx: Elide predictable reallocations in GIF loader 2021-09-04 16:00:25 +02:00
Timothy Flynn
90971673c7 LibJS: Implement Intl.Locale.prototype.minimize 2021-09-04 13:51:40 +01:00
Timothy Flynn
a77f323dfb LibUnicode: Implement the Remove Likely Subtags method
Unlike Add Likely Subtags, this method doesn't require generated data.
Instead, it is defined in terms of Add Likely Subtags.
2021-09-04 13:51:40 +01:00
Timothy Flynn
0b1f5118d5 LibJS: Implement Intl.Locale.prototype.maximize 2021-09-04 13:51:40 +01:00
Timothy Flynn
03d7f01e0c LibJS: Add a constructor to create an Intl.Locale object from a LocaleID 2021-09-04 13:51:40 +01:00
Timothy Flynn
3abfe7f7db LibJS: Add missing Intl.Locale initializer for plain boolean type 2021-09-04 13:51:40 +01:00
Timothy Flynn
e6a2ab1202 LibUnicode: Generate an implementation of the Add Likely Subtags method 2021-09-04 13:51:40 +01:00
Timothy Flynn
ca90231794 LibUnicode: Define is_unicode_*_subtag helpers inline in their header
The UnicodeLocale generator will need to parse canonicalized locale
strings, and will require using these methods. However, the generator
cannot depend on LibUnicode because Locale.cpp within LibUnicode already
depends on the generated file. Instead, defining the methods that the
generator needs inline allows the generator to use them without linking
against LibUnicode.
2021-09-04 13:51:40 +01:00
Mustafa Quraish
30e91ecff6 Cursors: Add new Magnifying glass cursor
There are a few places in the system where this could be useful,
such as PixelPaint and the MandelBrot demo. It seems general enough
that it is probably useful to have it as a system-wide cursor rather
than loading it manually each time.
2021-09-04 03:35:23 +02:00
Mustafa Quraish
30ce1d8562 Cursors: Add new Eyedropper cursor
This can be used immediately in PixelPaint (separate commit), but
I am adding this as a system-wide cursor since it may also be useful
for other applications that want to use it.
2021-09-04 03:35:23 +02:00
Musab Kılıç
81326ac8c7 PixelPaint: Add invert filter 2021-09-04 03:35:17 +02:00
Mustafa Quraish
9ed32582e2 LibGfx/Painter: Add draw_rect_with_thickness method
Previously there was no way to draw rectangles with any specific
thickness, like we can do with ellises, for instance. This method
is just a simple wrapper around `draw_line()` several times. At
least for now, we don't need to do anything sophisticated since
this will only be used by PixelPaint.`
2021-09-04 03:30:03 +02:00
Daniel Bertalan
d7b6cc6421 Everywhere: Prevent risky implicit casts of (Nonnull)RefPtr
Our existing implementation did not check the element type of the other
pointer in the constructors and move assignment operators. This meant
that some operations that would require explicit casting on raw pointers
were done implicitly, such as:
- downcasting a base class to a derived class (e.g. `Kernel::Inode` =>
  `Kernel::ProcFSDirectoryInode` in Kernel/ProcFS.cpp),
- casting to an unrelated type (e.g. `Promise<bool>` => `Promise<Empty>`
  in LibIMAP/Client.cpp)

This, of course, allows gross violations of the type system, and makes
the need to type-check less obvious before downcasting. Luckily, while
adding the `static_ptr_cast`s, only two truly incorrect usages were
found; in the other instances, our casts just needed to be made
explicit.
2021-09-03 23:20:23 +02:00
Luke Wilde
2f426765a6 LibWeb: Add support HTMLScriptElement.supports
See 33ff054a6c
2021-09-03 23:11:58 +02:00
Andreas Kling
7df8483379 LibIPC: Convert Encoder class to east-const style 2021-09-03 15:36:51 +02:00
Andreas Kling
2ef1cd8d12 LibSQL: Replace Optional<NonnullRefPtr<T>> with RefPtr<T>
We generally don't use Optional with nullable types, since they already
have an empty state, and having multiple empty states is confusing.
2021-09-03 15:36:51 +02:00
Sam Atkins
e2c32a6c65 Everywhere: Use my shiny new serenityos.org email :^) 2021-09-03 12:22:36 +02:00
Mustafa Quraish
4961fa4715 LibSyntax: Fix bug in matching cursor highlighting
Fixes #9760.
2021-09-03 11:45:50 +02:00
Andreas Kling
eaf88cc78a AK: Rename create<T> => make_ref_counted<T>
And also try_create<T> => try_make_ref_counted<T>.

A global "create" was a bit much. The new name matches make<T> better,
which we've used for making single-owner objects since forever.
2021-09-03 02:36:09 +02:00