Commit Graph

4689 Commits

Author SHA1 Message Date
Timothy Flynn
29f76ef7c8 LibUnicode: Parse locale extensions of the other extension form 2021-08-30 19:42:40 +01:00
Timothy Flynn
d2d304fcf8 LibUnicode: Parse locale extensions of the transformed extension form 2021-08-30 19:42:40 +01:00
Timothy Flynn
eda92d15e4 LibUnicode: Parse locale extensions of the Unicode locale extension form 2021-08-30 19:42:40 +01:00
Timothy Flynn
dd89901b07 LibUnicode: Use GenericLexer to parse Unicode language IDs
This is preparatory work to read locale extensions. The parser currently
enforces that the entire string is consumed. But to parse extensions,
parse_unicode_locale_id() will need parse_unicode_language_id() to just
stop parsing on the first segment that does not match the language ID
grammar. It will also need to know where the parsing stopped. Both of
these needs are fulfilled by GenericLexer.

The caveat is that we can no longer simply split the parsed string on
separator characters. So parse_unicode_language_id() now operates as a
small state machine.
2021-08-30 19:42:40 +01:00
Ali Mohammad Pur
206bc01f81 LibRegex: Allow null bytes in pattern
That check was rather pointless as the input is a StringView which knows
its own bounds.
Fixes #9686.
2021-08-30 18:43:09 +02:00
Andreas Kling
eaf904000f LibJS: Always use AK::get_random() in Math.random()
Let AK deal with the underlying platform instead of having __serenity__
specific code in LibJS.
2021-08-30 18:35:36 +02:00
Brian Gianforcaro
619200774b CMake: Add custom target to build only the generated sources
This is needed so all headers and files exist on disk, so that
the sonar cloud analyzer can find them when executing the compilation
commands contained in compile_commands.json, without actually building.

Co-authored-by: Andrew Kaster <akaster@serenityos.org>
2021-08-30 16:44:16 +02:00
sin-ack
d9900ece2f LibWeb: Preprocess the CSS stream in the Tokenizer
This commit implements the input preprocessing algorithm that CSS Syntax
Module Level 3 defines.
2021-08-30 00:08:40 +02:00
sin-ack
e6818388e4 LibTextCodec: Add "process" API for allocation-free code point iteration
This commit adds a new process method to all Decoder subclasses which
do what to_utf8 used to do, and allows callers to customize the handling
of individiual UTF-8 code points through a callback. Decoder::to_utf8
now uses this API to generate a string via StringBuilder, preserving the
original behavior.
2021-08-30 00:08:40 +02:00
sin-ack
fa4eeca0ac LibWeb: Properly handle newlines at the end of LineBoxes
This always subtracted the glyph width of a space, despite isspace
also accepting newlines and a few other characters. It now also uses
AK/CharacterTypes.h. :^)
2021-08-29 01:43:09 +02:00
sin-ack
b08bb0bdc3 LibGfx: Return 0 width for non-printable ASCII characters
Non-printable characters should always have a width of 0. This is not
true for some characters like tab, but those can be exempted as the need
arises. Doing this here saves us from a bunch of checks in any place
that needs to figure out glyph widths for text which can contain
non-printable characters.
2021-08-29 01:43:09 +02:00
sin-ack
27c5eb66f1 LibWeb: Rename wrap_breaks to respect_linebreaks
This more clearly expresses the purpose of this flag. Since only
CSS::WhiteSpace::Nowrap sets this value to false and it does not respect
linebreaks, this made the most sense as a flag name.
2021-08-29 01:43:09 +02:00
sin-ack
0342fe4e0c LibWeb: Refactor TextNode::ChunkIterator
This commit refactors the text chunking algorithm used in
TextNode::ChunkIterator. The m_start_of_chunk member parameter has been
replaced with a local variable that's anchored to the current iterator
at the start of every next() call, and the algorithm is made a little
more clear by explicitly separating what can and cannot peek into the
next character during iteration.
2021-08-29 01:43:09 +02:00
Linus Groh
31bc9565f8 LibJS: Avoid transitions for name/length of native functions/accessors 2021-08-28 23:17:01 +01:00
Linus Groh
8bcda353a2 LibJS: Avoid transitions for more object properties in global object 2021-08-28 23:17:01 +01:00
Linus Groh
45eef97906 LibJS: Avoid transitions in GlobalObject::initialize_constructor()
We don't need transitions for either of these:

- Adding the 'name' property to a constructor object
- Adding the 'constructor' property to its prototype object
2021-08-28 23:17:01 +01:00
Linus Groh
47ab84ffd9 LibJS: Add define_direct_{property,accessor}_without_transition() 2021-08-28 23:17:01 +01:00
Linus Groh
222e518a53 LibJS: Avoid pointless transitions and metadata lookups in storage_set()
- Replace the misleading abuse of the m_transitions_enabled flag for the
  fast path without lookup with a new m_initialized boolean that's set
  either by Heap::allocate() after calling the Object's initialize(), or
  by the GlobalObject in its special initialize_global_object(). This
  makes it work regardless of the shape's uniqueness.
- When we're adding a new property past the initialization phase,
  there's no need to do a second metadata lookup to retrieve the storage
  value offset - it's known to always be the shape's property count
  minus one. Also, instead of doing manual storage resizing and
  assignment via indexing, just use Vector::append().
- When we didn't add a new property but are overwriting an existing one,
  the property count and therefore storage value offset doesn't change,
  so we don't have to retrieve it either.

As a result, Object::set_shape() is now solely responsible for updating
the m_shape pointer and is not resizing storage anymore, so I moved it
into the header.
2021-08-28 23:17:01 +01:00
Andrew Kaster
d6de0613f5 LibCore: Store ObjectRegistration names as StringViews
We don't need to be allocating Strings for these names during static
initialization. The C-string literals will be stored in the .rodata ELF
section, so they're not going anywhere. We can just wrap the .rodata
storage for the class names in StringViews and use those in Object
registration and lookup APIs.
2021-08-28 23:34:30 +02:00
Brian Gianforcaro
2038d2c49e LibELF: Apply some minor optimizations to symbol lookup
Optimizations:

- Make sure `DT_SYMTAB` is a string view literal, instead of string.

- DynamicObject::HashSection::lookup_sysv_symbol should be using
  raw_name() from symbol comparison to avoid needlessly calling
  `strlen`, when the StrinView::operator= walks the cstring without
  calling `strlen` first.

- DynamicObject::HashSection::lookup_gnu_symbol shouldn't create a
  symbol unless we know the hashes match first.

In order to test these changes I enabled Undefined behavior sanitizer
which creates a huge amount of relocations, and then ran the browser
with the help argument 100 times. The browser is a fairly big app with
a few different libraries being loaded, so it seemed liked a good
target.

Command: `time -n 100 br --help`

Before:
```
Timing report:
==============
Command:         br --help
Average time:    3897.679931 ms
Excluding first: 3901.242431 ms
```

After:
```
Timing report:
==============
Command:         br --help
Average time:    3612.860107 ms
Excluding first: 3613.54541 ms
```
2021-08-28 20:03:08 +02:00
Nico Weber
bbad4758b2 CMake: Let Meta/serenity.sh run aarch64 make it past cmake
This adds just enough scaffolding to make cmake succeed.
The build falls over immediately.
2021-08-28 14:43:07 +01:00
Nico Weber
a43ad0e706 LibELF: Reindent .S files to be consistent with other .S files
Most .S files don't indent directives, so don't indent them here either.
Also, one file had tabs instead of spaces, `:retab` that file.
2021-08-28 14:43:07 +01:00
Nico Weber
7052f403c8 Toolchain: Enough to make rebuild-toolchain aarch64 work
The gcc patch might not be completely correct, but at least the
toolchain completes building.
2021-08-28 14:43:07 +01:00
Andrew Kaster
63956b36d0 Everywhere: Move all host tools into the Lagom/Tools subdirectory
This allows us to remove all the add_subdirectory calls from the top
level CMakeLists.txt that referred to targets linking LagomCore.

Segregating the host tools and Serenity targets helps us get to a place
where the main Serenity build can simply use a CMake toolchain file
rather than swapping all the compiler/sysroot variables after building
host libraries and tools.
2021-08-28 08:44:17 +01:00
Andrew Kaster
cdfd0bad1f LibWeb: Use foreach to generate wrapper targets and tidy up CMakeLists
Gather the custom commands for each of the 6 bindings generated targets
for libjs_js_wrapper invocations into some lists so that we can foreach
over the lists instead of having 6 copy pasted commands with one or two
things modified for each one.

Additional refactoring, use target_sources command to inform CMake about
additional source files for LibWeb, but only after it's been declared as
a library via add_library. Also avoid use of the write_if_different
script and use cmake -E copy_if_different instead. This lets us express
the actions in rules that CMake understands without going to an external
source file. It exposes a few optimization opportunities for the code
generators to accept an output filename instead of always going to
stdout.
2021-08-28 08:44:17 +01:00
Andrew Kaster
e88761b2b9 Meta+LibUnicode: Move unicode_data helper to Meta/CMake
Moving this helper CMake file to the centralized Meta/CMake folder helps
to get a better grasp on what extra files are required for the build,
and what files are generated.

While we're at it, don't use add_compile_definitions for
ENABLE_UNICODE_DATA, which only needs to be seen by LibUnicode sources.
2021-08-28 08:44:17 +01:00
Simon Danner
16830a60ec LibGUI: Select common location on Filepicker startup 2021-08-28 08:17:00 +01:00
Robert Syring
4f2dc8db26 LibUnicode: Change unzip commands to also extract subdirectories
Changed unzip commands from * to ** in order to also extract subdirectories from cldr.zip.
2021-08-28 08:13:32 +01:00
Linus Groh
a8329272cc LibJS: Implement Temporal.ZonedDateTime.prototype.eraYear 2021-08-27 23:36:52 +01:00
Linus Groh
b59e9260db LibJS: Implement Temporal.ZonedDateTime.prototype.era 2021-08-27 23:36:52 +01:00
Linus Groh
f59e4d6738 LibJS: Implement Temporal.PlainYearMonth.prototype.eraYear 2021-08-27 23:36:52 +01:00
Linus Groh
b11ea98648 LibJS: Implement Temporal.PlainYearMonth.prototype.era 2021-08-27 23:36:52 +01:00
Linus Groh
f2f671f340 LibJS: Implement Temporal.PlainDateTime.prototype.eraYear 2021-08-27 23:36:52 +01:00
Linus Groh
276d3f5089 LibJS: Implement Temporal.PlainDateTime.prototype.era 2021-08-27 23:36:52 +01:00
Linus Groh
418c22f9b3 LibJS: Implement Temporal.PlainDate.prototype.eraYear 2021-08-27 23:36:52 +01:00
Linus Groh
6f7d6d917e LibJS: Implement Temporal.PlainDate.prototype.era 2021-08-27 23:36:52 +01:00
Linus Groh
c3e0d78ba6 LibJS: Implement Temporal.Calendar.prototype.eraYear() 2021-08-27 23:36:52 +01:00
Linus Groh
f746850d1c LibJS: Implement Temporal.Calendar.prototype.era() 2021-08-27 23:36:52 +01:00
Mustafa Quraish
75a706b6eb Everywhere: Use the Optional<T>::operator==(T) operator
In general, I think `opt == x` looks much nicer than
`opt.has_value() && opt.value() == x`, so I'm updating
the remaining few instances I could find with some regex
magic in my search.
2021-08-27 23:13:51 +02:00
kleines Filmröllchen
d049626f40 Userland+LibAudio: Make audio applications support dynamic sample rate
All audio applications (aplay, Piano, Sound Player) respect the ability
of the system to have theoretically any sample rate. Therefore, they
resample their own audio into the system sample rate.

LibAudio previously had its loaders resample their own audio, even
though they expose their sample rate. This is now changed. The loaders
output audio data in their file's sample rate, which the user has to
query and resample appropriately. Resampling code from Buffer, WavLoader
and FlacLoader is removed.

Note that these applications only check the sample rate at startup,
which is reasonable (the user has to restart applications when changing
the sample rate). Fully dynamic adaptation could both lead to errors and
will require another IPC interface. This seems to be enough for now.
2021-08-27 23:35:27 +04:30
kleines Filmröllchen
d0ceaa24a6 Kernel: Implement ioctl for the SB16 to change sample rate
Two new ioctl requests are used to get and set the sample rate of the
sound card. The SB16 device keeps track of the sample rate separately,
because I don't want to figure out how to read the sample rate from the
device; it's easier that way.

The soundcard write doesn't set the sample rate to 44100 Hz every time
anymore, as we want to change it externally.
2021-08-27 23:35:27 +04:30
Idan Horowitz
24dbf18936 LibJS: Implement Temporal.PlainDateTime.prototype.withPlainTime() 2021-08-27 19:01:30 +01:00
Idan Horowitz
0f464f38d3 LibJS: Implement Temporal.PlainTime.prototype.equals() 2021-08-27 19:01:30 +01:00
Idan Horowitz
684e62476b LibJS: Implement Temporal.PlainTime.compare() 2021-08-27 19:01:30 +01:00
Idan Horowitz
a77cdc5f92 LibJS: Implement Temporal.PlainTime.from() 2021-08-27 19:01:30 +01:00
Idan Horowitz
bb857330d2 LibJS: Implement Temporal.PlainDate.prototype.toPlainDateTime() 2021-08-27 19:01:30 +01:00
Idan Horowitz
f6370fe3f7 LibJS: Add the ToTemporalTime AO and stub the ParseTemporalTimeString AO
This AO is required for a bunch of PlainTime related methods.

As part of this change the `TemporalTime` record was renamed to
`UnregulatedTemporalTime` and a new `TemporalTime` record that matches
the other Temporal parse result records was added. This also has the
added benefit of getting rid of a would be round-trip cast from integer
to double and back in `ParseTemporalTimeString`.
2021-08-27 19:01:30 +01:00
Idan Horowitz
32fc81c186 LibJS: Implement Temporal.PlainDateTime.prototype.equals() 2021-08-27 16:40:16 +01:00
Idan Horowitz
9ed877e8e7 LibJS: Implement Temporal.PlainDateTime.compare() 2021-08-27 16:40:16 +01:00
Idan Horowitz
28fa4d1568 LibJS: Add the CompareTemporalTime & CompareISODateTime AOs
These are required for implementing comparisons between `PlainTime`s and
`PlainDateTime`s.
2021-08-27 16:40:16 +01:00