Commit graph

22416 commits

Author SHA1 Message Date
Rodrigo Tobar
11a9bfd4b6 LibPDF: Turn Glyph into a class
Glyph was a simple structure, but even now it's become more complex that
it was initially. Turning it into a class hides some of that complexity,
and make sit easier to understand to external eyes.

While doing this I also decided to remove the float + bool combo for
keeping track of the glyph's width, and replaced it with an Optional
instead.
2023-02-08 19:47:15 +01:00
Rodrigo Tobar
c084943457 LibPDF: Index Type1 glyphs by name, not char code
Storing glyphs indexed by char code in a Type1 Font Program binds a Font
Program instance to the particular Encoding that was used at Font
Program construction time. This makes it difficult to reuse Font Program
instances against different Encodings, which would be otherwise
possible.

This commit changes how we store the glyphs on Type1 Font Programs.
Instead of storing them on a map indexed by char code, the map is now
indexed by glyph name. In turn, when rendering a glyph we use the
Encoding object to turn the char code into a glyph name, which in turn
is used to index into the map of glyphs.

This is the first step towards reusability of Type1 Font Programs. It
also unlocks the ability to render glyphs that are described via the
"seac" command (standard encoding accented character), which requires
accessing the base and accent glyphs by name.
2023-02-08 19:47:15 +01:00
Rodrigo Tobar
f99c9dc11a LibGfx: Add the ability to append a Path into another
This is useful in general (I'd imagine), but in particular having this
will allow us to implement accented PDF Type1 Font glyphs, which consist
of two separate glyphs that are composed into a single one.
2023-02-08 19:47:15 +01:00
Rodrigo Tobar
596119cf3e LibPDF: Add placeholders for *flex Type2 commands
These should be implemented properly in the future, but for now we are
adding the as placeholders to avoid crashes.
2023-02-08 19:47:15 +01:00
Rodrigo Tobar
64bbe431b5 LibPDF: Add char_code -> name mapping function
We already keep both mappings internally, now it's time to actually use
it.
2023-02-08 19:47:15 +01:00
Rodrigo Tobar
82bd854d6f LibPDF: Account for other endings of PS1 Encoding array 2023-02-08 19:47:15 +01:00
Rodrigo Tobar
a533ea7ae6 LibPDF: Improve stream parsing
When parsing streams we rely on a /Length item being defined in the
stream's dictionary to know how much data comprises the stream. Its
value is usually a direct value, but it can be indirect. There was
however a contradiction in the code: the condition that allowed it to
read and use the /Length value required it to be a direct value, but the
actual code using the value would have worked with indirect ones. This
meant that indirect /Length values triggered the fallback, "manual"
stream parsing code.

On the other hand, this latter code was also buggy, because it relied on
the "endstream" keyword to appear on a separate line, which isn't always
the case.

This commit both fixes the bug in the manual stream parsing scenario,
while also allowing for indirect /Length values to be used to parse
streams more directly and avoid the manual approach. The main caveat to
this second change is that for a brief period of time the Document is
not able to resolve references (i.e., before the xref table itself is
not parsed). Any parsing happening before that (e..g, the linearization
dictionary) must therefore use the manual stream parsing approach.
2023-02-08 19:47:15 +01:00
Timothy Flynn
8670526f2a LibJS+LibLocale: Propagate OOM from CLDR RelativeTime Vector operations 2023-02-08 18:32:37 +00:00
Timothy Flynn
340434ce09 LibLocale: Propagate OOM from CLDR DateTime Vector and String operations 2023-02-08 18:32:37 +00:00
Timothy Flynn
89da8de4ca LibJS+LibLocale: Propagate OOM from CLDR NumberFormat Vector operations 2023-02-08 18:32:37 +00:00
Timothy Flynn
858126d236 LibJS: Propagate OOM from remaining Intl Vector operations 2023-02-08 18:32:37 +00:00
Timothy Flynn
9af525bbb0 LibJS: Propagate OOM from Intl.RelativeTimeFormat Vector operations 2023-02-08 18:32:37 +00:00
Timothy Flynn
cb8b2209c1 LibJS: Propagate OOM from Intl.ListFormat Vector operations 2023-02-08 18:32:37 +00:00
Timothy Flynn
c1c54fad96 LibJS: Propagate OOM from Intl.DurationFormat Vector operations 2023-02-08 18:32:37 +00:00
Timothy Flynn
fb8fd757e6 LibJS: Propagate OOM from Intl.DateTimeFormat Vector operations 2023-02-08 18:32:37 +00:00
Timothy Flynn
822ee35f7a LibJS: Propagate OOM from Intl.NumberFormat Vector operations 2023-02-08 18:32:37 +00:00
Timothy Flynn
ea13f3e285 LibJS: Propagate OOM from PatternPartitionWithSource factory 2023-02-08 18:32:37 +00:00
Timothy Flynn
e86eafe65e LibJS: Replace remaining uses of StringBuilder in the Intl namespace 2023-02-08 18:32:37 +00:00
Itamar
951a8269f0 Debugger: Support attaching to a running process 2023-02-08 19:23:07 +01:00
Itamar
26250fe14a LibDebug: Add static attach() function
This function is similar to exec_and_attach(), but instead of spawning
a new process and debugging it, it attaches to an existing process.
2023-02-08 19:23:07 +01:00
Timon Kruiper
daf7f43135 LibELF: Add EM_AARCH64 as expected architecture for ELF validation 2023-02-08 18:19:48 +00:00
Tim Schumacher
4d68dcfca0 LibGfx: Port DDSLoader to AK::Stream
Functionality for checking image size in advance has been removed, as
this would require a SeekableStream and we now check for read errors
everywhere anyways.
2023-02-08 17:55:36 +00:00
Tim Schumacher
7d70f6d7c8 LibCrypto: Do a simple copy for buffered GHash bytes
Using a Stream to copy over a single span is kind of overkill.
2023-02-08 17:53:19 +00:00
Tim Schumacher
220fbcaa7e AK: Remove the fallible constructor from FixedMemoryStream 2023-02-08 17:44:32 +00:00
Tim Schumacher
8b2f23d016 AK: Remove the fallible constructor from LittleEndianOutputBitStream 2023-02-08 17:44:32 +00:00
Tim Schumacher
261d62438f AK: Remove the fallible constructor from LittleEndianInputBitStream 2023-02-08 17:44:32 +00:00
Tim Schumacher
fa09152e23 AK: Remove the fallible constructor from BigEndianInputBitStream 2023-02-08 17:44:32 +00:00
Nico Weber
839bec14af LibGfx: Validate type of cicpTag in ICC Profile
This should've really been part of e8bbb3d915.
2023-02-08 17:18:54 +00:00
Evan Smal
cb3216cb45 js: Remove DeprecatedString usage in load_json_impl() 2023-02-08 16:48:32 +00:00
Evan Smal
ff5a8a21e8 js: Use const where possible in parse_and_run() 2023-02-08 16:48:32 +00:00
Evan Smal
698bcf4b4e js: Convert s_history_path to String and propagate errors 2023-02-08 16:48:32 +00:00
Evan Smal
d18a7ca2dc js: Use Core::Stream::File in place of POSIX in write_to_file() 2023-02-08 16:48:32 +00:00
Evan Smal
f871dc097b js: Use String in prompt_for_level() and read_next_piece() 2023-02-08 16:48:32 +00:00
Nico Weber
e8bbb3d915 LibGfx+icc: Read cicpType
This is a very new tag used for HDR content. The only files I know that
use it are the jpegs on https://ccameron-chromium.github.io/hdr-jpeg/
But they have an invalid ICC creation date, so `icc` can't process them.
(Commenting out the check for that does allow to print them.)

If the CIPC tag is present, it takes precedence about the actual data
in the profile and from what I understand, the ICC profile is
basically ignored. See https://www.color.org/events/HDR_experts.xalter
for background, in particular
https://www.color.org/hdr/02-Luke_Wallis.pdf (but the other talks
are very interesting too).

(PNG also has a cICP chunk that's supposed to take precedence over
iCCP.)
2023-02-08 16:41:58 +00:00
Nico Weber
a434b89521 LibGfx: Add another profile ID to ICC quirk list 2023-02-08 16:37:47 +00:00
Nico Weber
21cc0c0cb2 LibGfx: Add ICC v2 tags to tag list 2023-02-08 16:36:31 +00:00
Nico Weber
8bd64f001c LibGfx+icc: Read signatureType
This isn't used by any mandatory tags, and it's not terribly useful.
But jpegs exported by Lightroom Classic write the 'tech' tag, and
it seems nice to be able to dump its contents.

signatureType stores a single u32 which for different tags with this
type means different things.

In each case, the value is one from a short table of valid values,
suggesting this should be a per-tag enum class instead of a
per-tag DistinctFourCC, per the comment at the top of DistincFourCC.h.
On the other hand, 3 of the 4 tables have an explicit "It is possible
that the ICC will define other signature values in the future" note,
which suggests the FourCC might actually be the way to go.

For now, just punt on that and manually dump the u32 in fourcc style
in icc.cpp and don't add any to_string() methods that return a readable
string based on the contents of these tables.
2023-02-08 16:35:57 +00:00
Nico Weber
cbcf8471a6 LibGfx+icc: Read namedColor2Type
This is the type of namedColor2Tag, which is a required tag in
NamedColor profiles.

The implementation is pretty basic for now and only exposes the
numbers stored in the file directly (after endian conversion).
2023-02-08 16:34:24 +00:00
Cubic Love
1ce34805f8 Settings: Improve default window size
Before, one icon was hidden out of sight and there was a scrollbar.
This small fix displays two neat rows of five icons.
2023-02-08 11:28:20 +01:00
Aliaksandr Kalenik
83b0613c68 LibWeb: Null check nearest_sibling in generate_missing_parents
Caught by AddressSanitizer.
2023-02-07 17:04:38 +01:00
Aliaksandr Kalenik
f43f4feb1e LibWeb: Table wrappers should not be ignored in auto height calculation
Though table wrappers are anonymous block containers (because
TableWrapper is inherited from BlockContainer) with no lines they
should not be skipped in block auto height calculation.
2023-02-07 17:04:38 +01:00
Andreas Kling
9e5fd95e44 SpaceAnalyzer: "Open Containing Folder" => "Reveal in File Manager"
Also "Open Folder" => "Open in File Manager".
2023-02-07 17:01:55 +01:00
Andreas Kling
f103f3af60 TextEditor: "Open Containing Folder" => "Reveal in File Manager" 2023-02-07 17:01:55 +01:00
Andreas Kling
2bc8cbfe8f LibGUI: Add 9 and 11 to the list of suggested sizes in FontPicker 2023-02-07 17:01:55 +01:00
Zaggy1024
3a1efbb9e4 SoundPlayer: Remove AutoSlider for the seek bar in favor of Slider 2023-02-07 14:36:58 +00:00
Zaggy1024
9e61e48b31 VideoPlayer: Pause while the user is dragging the seek bar 2023-02-07 14:36:58 +00:00
Zaggy1024
d9a73bbc96 LibGUI: Add callbacks for Slider drags starting and ending 2023-02-07 14:36:58 +00:00
Zaggy1024
fa98c43c0d LibGUI: Make sliders start a drag when jumping to the cursor
This allows users to seek to any position in VideoPlayer, then continue
adjusting the playback timestamp while holding left mouse.
2023-02-07 14:36:58 +00:00
Sam Atkins
89b8d346fe LibGUI+About: Make AboutDialog creation fallible 2023-02-07 10:43:15 +00:00
Sam Atkins
65c8dfe923 LibGUI: Convert AboutDialog layout to GML 2023-02-07 10:43:15 +00:00
Sam Atkins
c2082b45ee Browser: Use GUI::CommonActions::make_about_action()
Browser had bespoke code for showing the exact same AboutDialog, in a
more convoluted way.
2023-02-07 10:43:15 +00:00
Nico Weber
ce78394ae8 LibGfx: Add table size validation for ICC lut16Type 2023-02-06 11:53:50 -05:00
Lucas CHOLLET
597faaff5f LibChess: Factorize the returned StringView for a draw 2023-02-06 10:18:16 +00:00
Lucas CHOLLET
55c5639004 Chess+LibChess: Avoid using DeprecatedString whenever possible 2023-02-06 10:18:16 +00:00
Lucas CHOLLET
e7377c6d60 Chess: Move ChessWidget to the create pattern 2023-02-06 10:18:16 +00:00
Nico Weber
5ccfd0e49d LibGfx: Fix comment typo in ICC code 2023-02-05 23:20:36 +00:00
MacDue
ab5bdc598d Revert "SQLServer: Unveil /etc/passwd"
This reverts commit c3bd841d50.
2023-02-05 16:40:51 +01:00
MacDue
808f0c6837 Revert "ConfigServer: Unveil "/etc/passwd""
This reverts commit cd0b7656fa.
2023-02-05 16:40:51 +01:00
MacDue
83f41d1491 SystemServer: Revert back to inheriting environments again
This reverts the SystemServer exec() logic to how it was before
81bd91c, but now with some extra TRY()s. This allows the HOME var
to always be propagated from LoginServer which prevents needing
to unveil() /etc/passwd everywhere.
2023-02-05 16:40:51 +01:00
MacDue
b16ec1880c LibC+LibCore: Remove serenity_setenv()
This was called from LibCore and passed raw StringView data that may
not be null terminated, then incorrectly passed those strings to
getenv() and also tried printing them with just the %s format
specifier.
2023-02-05 16:40:51 +01:00
MacDue
eea4dc5bfe LibCore+LibC: Add putenv() wrapper
This is made safe with a special serenity_putenv() function in LibC.
2023-02-05 16:40:51 +01:00
MacDue
f4236e61bf LibCore: Add const qualifier to exec() argument spans 2023-02-05 16:40:51 +01:00
Nico Weber
1668d0da27 LibGfx: Extract a variable in ICC TextDescriptionTagData 2023-02-05 16:39:52 +01:00
Karol Kosek
675713ad8e LibSQL: Actually print an error message after failing to launch a server
We were shadowing the 'result' variable, which made an exec error
message along with the search paths never being printed.
2023-02-05 07:13:31 -07:00
Arda Cinar
1ef410eb79 LibGUI: Handle utf-8 search strings in find
Similar to LibVT, we were iterating over needle bytes instead of code
points. This patch allows finding unicode substrings in a text document.
2023-02-05 13:50:38 +01:00
Arda Cinar
25f1e81d62 LibVT: Handle utf-8 search strings in find
Instead of iterating through the needle being searched one byte at a
time (like an ascii string), we calculate its unicode code points first
and then iterate through those.
2023-02-05 13:50:38 +01:00
Samuel Eisenhandler
c5360b1a5f Calculator: Treat constants and pasted numbers as input
Constants and pasted numbers leave Keypad in the External
state which causes subsequent operations to be performed
without an argument.
2023-02-05 08:07:45 +00:00
Aliaksandr Kalenik
f58668031d LibWeb: Respect font-stretch in StyleComputer::compute_font 2023-02-05 08:06:06 +00:00
Aliaksandr Kalenik
1f4106842d LibGfx: Pass font width to FontDatabase::get()
Width need to be passed to `FontDatabase::get()` to resolve font name
unambiguously.
2023-02-05 08:06:06 +00:00
Lucas CHOLLET
79006c03b4 AK: Check the return type in IsCallableWithArguments
Template argument are checked to ensure that the `Out` type is equal or
convertible to the type returned by the invokee.

Compilation now fails on:
`Function<void()> f = []() -> int { return 0; };`

But this is allowed:
`Function<ErrorOr<int>()> f = []() -> int { return 0; };`
2023-02-04 18:47:02 -07:00
Karol Baraniecki
71f5bbab42 LibGUI: Verify NonemptyText InputBox doesn't result in an empty string 2023-02-04 18:46:39 -07:00
Karol Baraniecki
506c26acce LibGUI+Userland: Switch order of parameters for InputBox::show
Because usage of the input_type parameter is now higher than of the
placeholder parameter, this makes for a cleaner API.
2023-02-04 18:46:39 -07:00
Karol Baraniecki
8095d9276b Userland: Replace manual checking by using GUI::InputType::NonemptyText
Do this where we were already checking if the input was empty after the
InputBox was submitted. Those places gain interactive input validation.

:^)
2023-02-04 18:46:39 -07:00
Karol Baraniecki
55dbfd24c0 LibGUI: Allow the InputBox to be of NonemptyText type
It seems like a lot (most?) places where InputBoxes are used check if
the retrieved string isn't empty anyway - make this be reflected in
the user interface, by disabling (graying out) the "OK" button when
nothing is entered, so empty input isn't a viable option at all.
2023-02-04 18:46:39 -07:00
Tim Schumacher
47531a42a9 AK: Make LEB128 decoding work with read_value 2023-02-04 18:41:27 -07:00
Tim Schumacher
787f4d639a AK: Port LEB128 to the new AK::Stream 2023-02-04 18:41:27 -07:00
Tim Schumacher
371c51f934 AK: Make SeekableStream::truncate() take a size_t
Similar to the return values earlier, a signed value doesn't really make
sense here. Relying on the much more standard `size_t` makes it easier
to use Stream in all contexts.
2023-02-04 18:41:27 -07:00
Karol Kosek
e7cc426e05 LibGfx: Port ICOLoader to the new AK::Stream 2023-02-04 18:02:03 -07:00
Karol Kosek
492d5d7cb2 LibGfx: Return ErrorOr<> in ICOLoader internal functions 2023-02-04 18:02:03 -07:00
Lucas CHOLLET
3f932081ae HexEditor: Create a function to initialize a HexDocumentFile
This function is made from what composed `set_file()` (which now calls
the new function). It allows to create a `HexDocumentFile` without
calling the hackish `set_file(move(m_file))`.
2023-02-04 17:20:31 -07:00
Lucas CHOLLET
689b3c2c26 HexEditor: Propagate errors from HexDocumentFile::set_title() 2023-02-04 17:20:31 -07:00
Lucas CHOLLET
a2dca2b762 HexEditor: Propagate errors when using "Save" 2023-02-04 17:20:31 -07:00
Lucas CHOLLET
2bba743c24 HexEditor: Propagate errors when using "Save as" 2023-02-04 17:20:31 -07:00
Lucas CHOLLET
3d914247cc HexEditor: Port to Core::Stream 2023-02-04 17:20:31 -07:00
Lucas CHOLLET
b1d8404c92 HexEditor: Use the constructor pattern 2023-02-04 17:20:31 -07:00
Lucas CHOLLET
a621b5f015 HexEditor: Add a default move constructor to HexDocumentFile 2023-02-04 17:20:31 -07:00
Karol Kosek
039bb4e22d Utilities: Rename special target binaries only if they exist
Before 6490529ef7, all programs in the
SPECIAL_TARGETS list were built because they didn't have an
EXCLUDE_FROM_ALL property set.

That commit set the property for all targets, but because of this, the
minimal "Required" build configuration no longer built, as CMake failed
to rename every special target. Even the not built ones.

This commit makes the rename action run only if the executable exists,
which makes us build Serenity without the `install` utility, and also
by using the minimal configuration set. :^) :^)
2023-02-04 15:53:07 -07:00
Liav A
ed67a877a3 Kernel+SystemServer+Base: Introduce the RAMFS filesystem
This filesystem is based on the code of the long-lived TmpFS. It differs
from that filesystem in one keypoint - its root inode doesn't have a
sticky bit on it.

Therefore, we mount it on /dev, to ensure only root can modify files on
that directory. In addition to that, /tmp is mounted directly in the
SystemServer main (start) code, so it's no longer specified in the fstab
file. We ensure that /tmp has a sticky bit and has the value 0777 for
root directory permissions, which is certainly a special case when using
RAM-backed (and in general other) filesystems.

Because of these 2 changes, it's no longer needed to maintain the TmpFS
filesystem, hence it's removed (renamed to RAMFS), because the RAMFS
represents the purpose of this filesystem in a much better way - it
relies on being backed by RAM "storage", and therefore it's easy to
conclude it's temporary and volatile, so its content is gone on either
system shutdown or unmounting of the filesystem.
2023-02-04 15:32:45 -07:00
Rodrigo Tobar
82bac7e665 LibPDF: Fix clipping of painting operations
While the clipping logic was correct (current v/s new clipping path),
the clipping path contents weren't. This commit fixed that.

We calculate the clipping path in two places: when we set it to be the
whole page at graphics state creation time, and when we perform clipping
path intersection to calculate a new clipping path. The clipping path is
then used to limit painting by passing it to the painter (more
precisely, but passing its bounding box to the painter, as the latter
doesn't support arbitrary path clipping). For this last point the
clipping path must be in device coordinates.

There was however a mix of coordinate systems involved in the creation,
update and usage of the clipping path:

 * The initial values of the path (i.e., the whole page) were in user
   coordinates.
 * Clipping path intersection was performed against m_current_path,
   which is in device coordinates.
 * To perform the clipping operation, the current clipping path was
   assumed to be in user coordinates.

This mix resulted in the clipping not working correctly depending on the
zoom level at which one visualised a page.

This commit fixes the issue by always keeping track of the clipping path
in device coordinates. This means that the initial full-page contents
are now converted to device coordinates before putting them in the
graphics state, and that no mapping is performed when applied the
clipping to the painter.
2023-02-04 12:29:57 +01:00
Sam Atkins
0f2936d8cd Chess+GamesSettings: Give chess pieces some breathing room
Draw pieces around 80% of the size of a square, instead of 100%, so that
there is a nice gap around them. This feels more comfy, and makes it
actually possible to read the coordinates while a piece is on their
square.
2023-02-04 12:29:03 +01:00
Sam Atkins
7e4186de63 Chess+GamesSettings: Use the correct term for chess squares
"Square" is the technical term, so let's use it. :^)

Also, stop using size_t for pixel sizes, that's not what that means.
2023-02-04 12:29:03 +01:00
Sam Atkins
f7aead8086 SpaceAnalyzer: Rename widget variables to match code style 2023-02-04 12:27:10 +01:00
Sam Atkins
534039fdf5 SpaceAnalyzer: Stop treating selecting a node as a path change
This served no obvious purpose, but did make the breadcrumb bar change
confusingly.
2023-02-04 12:27:10 +01:00
Sam Atkins
ad92b16887 SpaceAnalyzer: Rename TreeMapWidget::m_path -> m_path_segments
This is clearer to me at least.
2023-02-04 12:27:10 +01:00
Sam Atkins
87f4c9e580 SpaceAnalyzer: Give the Analyze action an icon and F5 shortcut
This action is basically equivalent to "Refresh", so let's use the
common shortcut for that.
2023-02-04 12:27:10 +01:00
Sam Atkins
1ec59cc52a SpaceAnalyzer: Make TreeMapWidget responsible for filesystem analysis
Also, the Tree object was only ever used by the TreeMapWidget, so its
creation can happen inside `analyze()`, fixing the memory leak issue.
Plus, it doesn't have to be RefCounted.
2023-02-04 12:27:10 +01:00
Sam Atkins
98e9ee07e3 SpaceAnalyzer: Propagate more errors 2023-02-04 12:27:10 +01:00
Sam Atkins
16bbdc812d SpaceAnalyzer: Extract ProgressWindow into its own class 2023-02-04 12:27:10 +01:00
MacDue
f74e2da875 LibWeb: Implement CanvasRenderingContext2D.createPattern()
This is a first pass at implementing CRC2D.createPattern() and the
associated CanvasPattern object. This implementation only works for a
few of the required image sources [like CRC2D.drawImage()], and does
not yet support transforms. Other than that it supports everything
else (which is mainly the various repeat modes).
2023-02-03 20:36:21 +01:00
MacDue
b106fd640b LibWeb: Fix typo and use auto where possible 2023-02-03 20:36:21 +01:00