Commit Graph

31869 Commits

Author SHA1 Message Date
Timothy Flynn
c4295edc81 LibWeb: Add ImageBox to forwarding header 2024-02-19 11:07:30 +01:00
Tim Ledbetter
02c2b1e67e LibWeb: Implement document.createCDATASection() 2024-02-19 10:42:56 +01:00
Tim Ledbetter
ee6b0e144a LibWeb: Make the default XML namespace an empty Optional
Previously, when constructing an XML document, the default namespace
was the empty string. This led to XML documents having empty xmlns
attributes when serialized.
2024-02-19 10:42:56 +01:00
Tim Ledbetter
1a249f9d85 LibWeb: Add ad-hoc method for serializing CDATASection nodes to string
Previously, CDATASection nodes were being serialized as if they were
text, which meant they were missing their start and end delimiters.
Occurrences of the '&', '<' and '>' characters were also being replaced
with their entity names.
2024-02-19 10:42:56 +01:00
Tim Ledbetter
70b9cddc48 LibWeb: Align Document::document_type() default with the specification
The DOM specification states that: "Unless stated otherwise, a
document’s [...] type is 'xml'".

Previously, calls to `Document::document_type()` were returning the
incorrect value for non-HTML documents.
2024-02-19 10:42:56 +01:00
Tim Ledbetter
f18ea096e0 LibWeb: Set correct document type when parsing XML with DOMParser 2024-02-19 10:42:56 +01:00
Nico Weber
27e369cd19 LibGfx/ICC: Add a one-element cache for CLUT conversions
Our current CLUT code is pretty slow. A one-element cache can make
it quite a bit faster for images that have long runs of a single
color, such as illustrations.

It also seems to help with photos some (in `0000711.pdf` page 1) --
I suppose even them have enough repeating pixels for it to be worth
it.

Some numbers, with `pdf --render-bench`:

`0000711.pdf --page 1` (high-res photo)
before: 2.9s
after: 2.43s

`0000277.pdf --page 19` (my nemesis PDF, large-ish illustration)
before: 2.17s
after: 0.58s (!)

`0000502.pdf --page 2` (wat hoe dat)
before: 0.66s
after: 0.27s

`0000521.pdf --page 10 ` (japanese)
before: 0.52s
after: 0.29s

`0000364.pdf --page 1` (4 min test case)
before: 0.48s
after: 0.19s

Thanks to that last one, reduces the time for
`time Meta/test_pdf.py ~/Downloads/0000` from 4m22s to 1m28s.

Helps quite a bit with #23157 (but high-res photos are still too
slow).
2024-02-19 07:16:05 +00:00
Nico Weber
6a8e418e40 pdf: Add a --render-bench option
It's similar to `--render <filename>.png`, but skips the "save to
file" step. Useful for benchmarking, in part because our png codec
is so slow.
2024-02-19 07:16:05 +00:00
Lucas CHOLLET
be9ec591e7 LibGfx/CCITT: Add support for Group3 2D
The two test images were created with:
tiffcp ccit3.tiff -c g3:2d ccit3_2d.tiff
tiffcp ccit3.tiff -c g3:2d:fill ccit3_2d_fill.tiff
2024-02-19 01:40:04 +01:00
Lucas CHOLLET
9116cc3f45 LibGfx/CCITT: Put the code to read the run length in its own function
This is already nice to do for the sole purpose of the readability but
that will also become handy for the 2D decoder.
2024-02-19 01:40:04 +01:00
Lucas CHOLLET
3d63dd5c53 LibGfx/CCITT: Make get_code_from_table take a generic Array 2024-02-19 01:40:04 +01:00
Lucas CHOLLET
d54dbdae5e LibGfx/CCITT: Introduce the invert helper
This function turns Black into White and White into Black.
2024-02-19 01:40:04 +01:00
Lucas CHOLLET
ce0ac70416 LibGfx/CCITT: Declare reference colors as static variables 2024-02-19 01:40:04 +01:00
Lucas CHOLLET
45b37010b5 Revert "LibGfx/CCITT: Don't overrun the image width"
This reverts commit a4b2e5b27b.

This was just plain wrong, I remember it making sense and fixing
something but that was probably due to local changes. It should never
have landed on master, my bad.
2024-02-19 01:40:04 +01:00
Hugh Davenport
8740a8c056 FlappyBug: Allow shortcuts for quitting and help
As the menus show that ALT-F4 quit and F1 brings up help, we should
make the application do that instead of just undocumented ESC
2024-02-19 00:09:34 +01:00
Ollrogge
37e595a96c Utilities: Add xxd utility 2024-02-18 23:56:37 +01:00
Ali Mohammad Pur
56ba869c57 LibWasm: Implement all remaining comparison SIMD instructions 2024-02-18 23:50:50 +01:00
Ali Mohammad Pur
b7a8081b0f wasm: Make --arg use a more useful value format
This allows the user to pass very specific values instead of a u64 value
that is later cast to the underlying type.
The change also adds support for passing v128 values:
- v(i64.const 4) (splat 4)
- v128.const 0x4 (just a few bits specificed, everything else = 0)
2024-02-18 23:50:50 +01:00
Ali Mohammad Pur
82b7368de1 LibWasm: Implement 15 more SIMD instructions 2024-02-18 23:50:50 +01:00
Fabian Dellwing
e8bdb7e5f8 tail: Support skip from start mode
This commit adds the possibility to skip the first NUM lines of a
file by calling `tail -n +NUM filename`.
2024-02-18 23:46:46 +01:00
Fabian Dellwing
7beabc8e91 tail: Use File::seek() to determine seekability
Some change in the past made `File::tell()` not return an error if
a file is not seekable. So instead do a real seek to check.
2024-02-18 23:46:46 +01:00
Lucas CHOLLET
d375b5c2a5 LibGfx/TIFF: Also cache the result of alpha_channel_index()
This function was called over and over in `manage_extra_channels()`,
even if the result depends only on the metadata. Instead, we now call it
once and store the result.
2024-02-18 21:53:27 +01:00
Lucas CHOLLET
a637a02de8 LibGfx/TIFF: Cache metadata values that are used in the hot path
The ExifMetadata class is handy as it handles any Exif tag, but the
performance price is non-negligible. So, let's cache important values.
2024-02-18 21:53:27 +01:00
Tim Ledbetter
ea9bc8ed6b LibWeb: Set cursor: default for button and select elements
This prevents an IBeam cursor being shown when these elements are
moused over.
2024-02-18 15:44:49 -05:00
Nico Weber
012f6d46e7 LibPDF: Implement stream CIDToGIDMaps for Type0 CIDFontType2 fonts
Of my 1000 test files, 73 have stream Type0 truetype fonts with stream
CIDToGIDMaps. This makes that work.

(With this patch, the number of files in my 1000 test files complaining
"Font is missing Name" increases from 41 to 75, so a bit under half of
the fonts using stream CIDToGIDMaps also have no 'name' table. So that's
next.)

Increases files without issues from 652 to 681.
2024-02-18 15:43:33 -05:00
Jakub Pyszczak
ac49617183 2048: Ensure that correct font is requested
Previously, during the start of the game BoardView component tried to
get the font from the database passing empty string as a parameter.
It caused a debug message informing user that the lookup failed.
2024-02-18 21:34:38 +01:00
Aliaksandr Kalenik
cb97eef2cf LibWeb+WebContent: Remove "Painting" prefix from command executor names
Painting command executors are defined within the "Painting" namespace,
allowing us to remove this prefix from their names.

This commit performs the following renamings:

- Painting::PaintingCommandExecutor to Painting::CommandExecutor
- Painting::PaintingCommandExecutorCPU to Painting::CommandExecutorCPU
- Painting::PaintingCommandExecutorGPU to Painting::CommandExecutorGPU
2024-02-18 18:45:25 +01:00
Aliaksandr Kalenik
11d746a67f LibWeb+WebContent: Separate painting command list from RecordingPainter
Separating the recorder list from the painter will allow us to save it
for later execution without carrying along the painter's state. This
will be useful once we have a separate thread for executing painting
commands, to which we will have to transfer commands from the main
thread.

Preparation for https://github.com/SerenityOS/serenity/pull/23108
2024-02-18 18:45:25 +01:00
Timothy Flynn
ce9ad3a236 LibWeb: Fully implement the HTMLInputElement value setter and getter
The setter was missing an implementation for the default and default/on
value attribute modes. This patch adds a method to get the current value
attribute mode, and implements the value setter and getter based on that
mode according to the spec.
2024-02-18 18:44:45 +01:00
MacDue
cfb9c5bb0e LibWeb: Fix checks for elements in XMLDocumentBuilder
Previously, this just checked the tag names. For elements that exist in
different namespaces (like HTMLScriptElement vs SVGScriptElement) this
could lead to invalid casts, as the namespace was not checked.

This switches to using the safer helpers on the DOM::Node.
2024-02-18 18:33:11 +01:00
MacDue
4843100650 LibWeb: Run scripts in XML SVG documents
This will be needed to add a hit testing test for #22305.
2024-02-18 18:33:11 +01:00
MacDue
2ede299b4a headless-browser: Run .svg dump tests
Previously, the check for `.html` meant that `.svg` tests were excluded.
This led to a few `.svg` with missing or bit-rotted expectations, which
have now been added/updated.
2024-02-18 18:33:11 +01:00
MacDue
012cb7f71e headless-browser: Fix loaded URL about:blank check
This check was meant to let about:blank through, but it checked the URL
from the file path, not the `loaded_url`, so still crashed on
about:blank.
2024-02-18 18:33:11 +01:00
MacDue
957c20b676 LibWeb: Avoid infinite recursion when hit testing SVGs
Previously, step 5 of the stacking context hit testing would just call
`hit_test()` on the stacking context's paintable box. Which (at least
for SVGs) is just indirect infinite recursion (it'll end up right back
where it started after going through a few functions).

This now explicitly hit tests the descendants, which seems more correct,
and avoids the crash for SVGs, but nothing really seems to depend on
this step. Another solution (which I've done for a while working on
SVGs) is just to delete step 5 entirely, and nothing seems to break.

Fixes #22305
2024-02-18 18:33:11 +01:00
Nico Weber
dde11e1757 LibPDF: Ignore unknown CFF operators
https://adobe-type-tools.github.io/font-tech-notes/pdfs/5177.Type2.pdf
says "The behavior of undefined operators is unspecified." but
https://learn.microsoft.com/en-us/typography/opentype/spec/cff2
says "When an unrecognized operator is encountered, it is ignored and
the stack is cleared."

Some type 0 CIDFontType0C fonts (i.e. CID-keyed non-OpenType CFF fonts)
depend on the latter, even though they're governed by the former spec.

Fixes rendering of text in 0000521.pdf (e.g. page 10 or 5). The font
there has a bunch of 0 opcodes for some reason.
2024-02-18 08:40:04 +00:00
Idan Horowitz
9f50ad9208 LibGfx/ICC: Stop allocating a vector on each call to lerp_nd
While all callers of lerp_nd created a Vector with inline_capacity of 4
to ensure no heap allocation will take place for most inputs, lerp_nd
requested a reference to a Vector with 0 inline_capacity, which meant a
new vector was allocated on each call.
2024-02-17 15:39:46 -05:00
Idan Horowitz
5129c8b766 LibGfx/ICC: Stop using VectorN::length() as the vector size
VectorN::length() returns the vector length (aka the square root of the
dot product of the vector with itself), not the count of components.

This is seemingly both wrong and slow.
2024-02-17 15:39:46 -05:00
Nico Weber
05f382fc6e LibPDF: Add CIDFontType2::set_font_size()
See #20084 commit 4. This does the same for truetye-based type0 fonts.

Fixes font sizes on e.g. 1800-2017.pdf.
2024-02-17 16:08:48 +01:00
Nico Weber
f4a59246f5 LibPDF: Implement initial support for Type0 truetype fonts
Disclaimers, similar to what's on #23202 (and most of the
prerequisites mentioned there are needed for this too):

* Only supports the `Identity-H` type0 cmap at the moment
* Doesn't support vertical text yet
* Only supports the `Identity` CIDToGIDMap at the moment
  (this one is a truetype-only thing)
2024-02-17 16:08:48 +01:00
Nico Weber
76a439124d LibGfx/OpenType: Make it possible to provide an external cmap
If this is passed in, we don't use the cmap table from the font,
but use the external lookup object instead.

This conveniently happens to create a place where we can put all the
Cmap configuration logic that was a bit spread out before.

No behavior change yet.
2024-02-17 16:08:48 +01:00
Andrew Kaster
dd6f47e696 Meta: Don't search for both Python and Python3 in CMake
CMake will cache the result here, so there's no need to look for both.
2024-02-16 23:14:49 -07:00
Andrew Kaster
5d2a36f244 LibWeb: Stub out all the functions from the execCommand spec
Per the specification, it's ok if we say that nothing is supported.

It's not ok if we say something is supported but do nothing, apparently.
2024-02-16 19:31:54 -05:00
Tim Ledbetter
816d24f647 LibWeb: Implement HTMLFormElement.requestSubmit()
This can be used to submit a form using a specific submit button.
2024-02-16 17:21:48 -05:00
Andrew Kaster
94149db073 LibWeb: Implement Document named properties with light caching
We now cache potentially named elements on the Document when elements
are inserted and removed. This allows us to do lookup of what names are
supported much faster than if we had to iterate the tree every time.

This first cut doesn't implement the rules for 'exposed' object and
embed elements.
2024-02-16 16:18:31 -05:00
Matthew Olsson
faaf5b9652 LibWeb: Add the AnimationEvent IDL objects 2024-02-16 12:02:11 -07:00
Matthew Olsson
3a87c000c4 LibWeb: Add the CSSAnimation IDL object 2024-02-16 12:02:11 -07:00
Matthew Olsson
3721a1a81c LibWeb: Run update_finished_state when setting AnimationEffect's timing
This will need to a necessary style invalidation
2024-02-16 12:02:11 -07:00
Matthew Olsson
6d25bf3aac LibWeb: Invalidate element when setting AnimationEffect's animation 2024-02-16 12:02:11 -07:00
Matthew Olsson
ce99636cd0 LibWeb: Fix check for missing argument in Animation constructor
Receiving a null argument has a different result than not passing an
argument at all.
2024-02-16 12:02:11 -07:00
Nico Weber
bd74447dba LibPDF: Initial support for drawing CFF-based Type0 fonts
Together with the already-merged #23122, #23128, #23135, #23136, #23162,
and #23167, #23179, #23190, #23194 this adds initial support for
rendering some CFF-based Type0 fonts :^)

There's a long list of things that still need improving after this:

* A small number of CFF programs contain the charstring command 0,
  which is invalid. Currently, this makes us reject the whole font.

* Type1FontProgram::rasterize_glyph() is name-based. For CID-based
  fonts, we want a version that takes CIDs (character IDs) instead.
  For now, I'm printing the CID to a string and using that, yuck.
  (I looked into doing this nicely. I do want to do that, but I
  need to read up on how the `seac` type1 charstring command uses
  character names to identify parts of an accented character.
  Also, it looks like `seac`'s accented character handling moved
  over to `endchar` in type2 charstring commands (i.e. in CFF data),
  and it looks like we don't implement that at all. So I need to do
  more reading first, and I didn't want to block this on that.)

* The name for the first string in name-based CFF fonts looks wrong;
  added a FIXME for that for now.

* This supports the named Identity-H cmap only for now. Identity-H
  maps UTF16-BE values to glyph IDs with the idenity function, and
  assumes it's horizontal text. Other named cmaps in my test files are
  UniJIS-UCS2-H, UniCNS-UCS2-H, Identity-V, UniGB-UCS2-H, UniKS-UCS2-H.
  (There are also 2 files using the stream-based cmaps instead of the
  name-based ones.)

  * In particular, we can't draw vertical text (`-V`) yet

* Passing in the encoding to CFF::create() is awkward (it's nullptr
  for CID-keyed fonts), and it's also not necessary since
  `Type1Font::draw_glyph()` already does the "take encoding from PDF,
  and only from font if the PDF doesn't store one" dance.

* This doesn't cache glyphs but re-rasterizes them each time. Easy
  to add, but maybe I want to look at rotation first. And things
  don't feel glacial as-is.

* Type0Font::draw_glyph() is pretty similar to second half of
  Type1Font::draw_glyph()
2024-02-16 12:41:10 -05:00
Nico Weber
c9d48bbca4 LibPDF/CFF: Add a comment to CFF::parse_charset() 2024-02-16 12:41:10 -05:00
Nico Weber
5c8778a161 LibPDF/CFF: Compute per-glyph glyph width in CID-keyed fonts
Make TopDict's defaultWidthX and nominalWidthX Optional<>s so that
we can check if they're set per fdselect-selected font dict, and
if so use the value from there in CID-keyed fonts. Otherwise, keep
using the value in the top dict.
2024-02-16 12:41:10 -05:00
Shannon Booth
4348b484c6 LibJS: Verify valid Duraton is made in DifferenceTemporalPlainDate
It shouldn't be possible to create an invalid duration here, so follow
the spec and verify that this succeeds.
2024-02-16 12:27:23 -05:00
Shannon Booth
bb8dad5bb0 LibJS: Begin using CalendarMethodsRecord for AOs
This begins the process of aligning our implementation with the spec
with regard to using CalendarMethodsRecord. The main intent here is to
make it much easier to make normative changes to AOs which have been
updated to CalendarMethodsRecord.

While this does resolve various FIXMEs, many others above need to be
added in order to be able to pass through a CalendarMethodsRecord. The
use here aligns with what I can gather from the spec of what the
arguments to CreateCalendarMethodsRecord should be, but various AOs have
been updated so much with other changes it's not completely obvious.
Other AOs do not even exist in the latest version of the spec, but we
still rely on them.

As part of these updates, this commit coincidentally also fixes two
PlainDate roundingmode issues seen in test262 - a test of which is also
added in test-js. This issue boiled down to what appears to be an
observable optimization in the spec, where it can avoid calling
dateUntil in certain situations (roundingGranularityIsNoop).

However, the main goal here is to make it much easier to fix many more
issues in the future :^)

since/calendar-dateuntil-called-with-singular-largestunit.js  -> 
until/calendar-dateuntil-called-with-singular-largestunit.js  -> 
2024-02-16 12:27:23 -05:00
Shannon Booth
6d4eda0028 LibJS: Make CreateTemporalDuration return a NonnullGCPtr
Since it can't return null.

This also results in a bunch of fallout from callers who were
expecting a raw pointer.
2024-02-16 12:27:23 -05:00
Shannon Booth
fdfe06bb44 LibJS: Begin implementing Temporal's CalendarMethodsRecord
This is part of a large refactor made as part of the temporal spec.
Most AOs using the calendar now pass through this record. There will
need to be a long process of going through updating AOs to use this
record.
2024-02-16 12:27:23 -05:00
Ali Mohammad Pur
971e466521 LibIDL: Emit an error when two decls of the same function are present
Duplicates can show up when copy-pasting IDL snippets into existing IDL
files, and the resulting error is extremely useless and misleading.
This commit makes it so the parser catches these cases, and emits a more
helpful error like "Overload set 'instantiate' contains multiple
identical declarations".
2024-02-16 15:26:43 +01:00
Ali Mohammad Pur
bc301b6f40 AK+LibXML+JSSpecCompiler: Move LineTrackingLexer to AK
This is a simple extension of GenericLexer, and is used in more than
just LibXML, so let's move it into AK.
The move also resolves a FIXME, which is removed in this commit.
2024-02-16 15:26:43 +01:00
Tommy van der Vorst
08c02ad888 LibWeb: Only dump layout and text tree for the desired URL
Before this change, the rebaseline script would generate reference
based on 'about:blank' (at least running it on my macOS system).
This commit allows 'about:blank' through the assertion and only dumps
the layout tree when theloaded URL matches the one we are interested
in.
2024-02-16 15:05:30 +01:00
Nico Weber
17b22250b6 LibGfx/OpenType: Replace a magic number with a calculation
Makes this code look like the corresponding code in the ScaledFont ctor.

Similar to the last commit on #20084.

No behavior change.
2024-02-15 22:53:24 -05:00
Nico Weber
073e2bffcb LibGfx: Move POINTS_PER_INCH, DEFAULT_DPI to VectorFont.h
...so we can use it in OpenType/Font.cpp.

No behavior change.
2024-02-15 22:53:24 -05:00
Tim Ledbetter
c24652bd2e LibWeb: Implement document.scrollingElement
This returns a reference to the element that scrolls the document. In
standards mode it is equivalent to `document.documentElement`.
2024-02-15 22:51:15 -05:00
Gurkirat Singh
fc8f6c07b4 Utilities/pkg: Integrate LibSemVer for update information
Along with this, Port.h is include which helps generalising common
information for the port package, like it's name and version. With
SemVer complaint versions, it is possible to show positive change
(upgrade) or negative change (downgrade) in the installed ports.

However, for some non-complaint versions (eg. using git commit hash),
non-equality (`!=`) is used to notify upgrade. Since there is no
algorithm (without git history) to check the order of commits, it is
not possible to inform whether it is an upgrade or downgrade.
2024-02-15 18:23:05 +01:00
Gurkirat Singh
ee639fa1df Libraries: Implement SemVer for version parsing and comparisons
Semantic Versioning (SemVer) is a versioning scheme for software that
uses MAJOR.MINOR.PATCH format. MAJOR for significant, possibly
breaking changes; MINOR for backward-compatible additions; PATCH for
bug fixes. It aids communication, compatibility prediction, and
dependency management. In apps dependent on specific library versions,
SemVer guides parsing and validates compatibility, ensuring apps use
appropriate dependencies.

    <valid semver> ::= <version core>
                     | <version core> "-" <pre-release>
                     | <version core> "+" <build>
                     | <version core> "-" <pre-release> "+" <build>
2024-02-15 18:23:05 +01:00
Matthew Olsson
14200de80b LibWeb: Set DocumentTimeline origin time to zero
The current time should be used to set the timeline's new current time,
not its origin time
2024-02-15 12:34:19 +01:00
Matthew Olsson
727a9a6472 LibWeb: Run pending play tasks when the timeline time changes
Note that the timeline time changes every animation frame when the
Document sends out animation events
2024-02-15 12:34:19 +01:00
Matthew Olsson
daaaaec2d0 LibWeb: Add the Animatable IDL object 2024-02-15 12:34:19 +01:00
Matthew Olsson
4792dc294b LibWeb: Implement Animation::play 2024-02-15 12:34:19 +01:00
Matthew Olsson
88518c29ca LibWeb: Combine "pending" and "ASAP" animation task states
It seems that the difference between pending and ASAP in the spec is
only to allow the implementation to perform implementation-defined
operations between the two states. We don't need to distinguish the two
states, so lets just combine them for now.
2024-02-15 12:34:19 +01:00
Nico Weber
1d1e406b3a LibPDF/CFF: Implement some special handling for CID-keyed fonts
* FDArray, FDSelect must be present
* Encoding must not be present
* Charset maps from GID (Glyph ID) to CID (Character ID),
  instead of to character name
2024-02-15 12:32:31 +01:00
Nico Weber
7494f24430 LibPDF/CFF: Store if a font program is CID-keyed
...and reject CID-keyed font programs for Type1 fonts.
2024-02-15 12:32:31 +01:00
Nico Weber
bb7d29d007 LibPDF/CFF: Read font dicts pointed to by the fdarray offset
The fdselect array (that we already read) maps eachs glyph ID
to an fdarray index. The font dict at that index then stores
information for that glyph.

In practice, this is used to assign different defaultWidthX /
nominalWidthX values to blocks of glyphs in CID-keyed fonts.

We don't do anything yet with the data, and we also don't send
data of CID-keyed CFFs into this parser either, so no behavior
change.
2024-02-15 12:32:31 +01:00
Nico Weber
524a4f6256 LibPDF/CFF: Make parse_top_dict() return all top dicts
This happens for CFFs that contain multiple fonts. This doesn't
happen in practice, but the same code will be used for fdarray
parsing, which will contain several dicts.

No behavior change.
2024-02-15 12:32:31 +01:00
Nico Weber
9f1cf8babc LibPDF/CFF: Extract parse_top_dict() function
Pure code move, no behavior change.
2024-02-15 12:32:31 +01:00
Lucas CHOLLET
1f62984301 LibAudio/Wav: Always use u32 for the sample rate 2024-02-14 22:21:44 -05:00
Lucas CHOLLET
901baf31ff LibAudio/Wav: Remove unused methods 2024-02-14 22:21:44 -05:00
Tim Ledbetter
0ecbdc4627 LibWeb: Add support for form submission method 'dialog' 2024-02-14 22:20:44 -05:00
Tim Ledbetter
151cd11b5b LibWeb: Implement HTMLDialogElement::show() 2024-02-14 22:20:44 -05:00
Tim Ledbetter
8042558805 LibWeb: Implement HTMLDialogElement::close() for non-modal dialogs 2024-02-14 22:20:44 -05:00
Tim Ledbetter
cfbd14b958 Userland: Use MUST() to unwrap String values 2024-02-14 17:46:06 -05:00
Tim Ledbetter
2331d2bafa Userland: Propagate errors with TRY() where possible 2024-02-14 17:46:06 -05:00
Tim Ledbetter
89c0e3541e Fuzzers: Add PAM fuzzer 2024-02-14 19:58:46 +01:00
Jelle Raaijmakers
2a749525e0 LibGL: Add API stubs
- glBlendEquation
- glGetShaderInfoLog
- glGetUniformLocation
- glUniform*

This gives us full API coverage for the SRB2 port.
2024-02-14 15:09:53 +01:00
Jelle Raaijmakers
e18bc2a748 LibGL: Combine glLightModel definitions
Create a single definition with two variants for `glLightModeli` and
`glLightModelf`.
2024-02-14 15:09:53 +01:00
Nico Weber
eb4632e08a LibPDF: Give CFF built-in encoding and charset arrays an underlying type
These arrays store SIDs ("String IDs"), so give them that type now
that we have to_array() and it's easy to do.

No behavior change.
2024-02-14 06:56:43 +01:00
Aliaksandr Kalenik
88ad871e2b LibWeb: Do paint-order traversal in Document::element_from_point()
Specify callback for hit-test function to identify closest DOM element,
excluding text nodes. Add a previously failing test case.
2024-02-14 06:56:22 +01:00
Aliaksandr Kalenik
9d2809146f LibWeb: Do paint-order traversal in Document::elements_from_point()
Elements are now collected according to paint order as spec says,
replacing the depth-first traversal of the paint tree with hit-testing
on each box.

This change resolves a FIXME in an existing test and adds a new
previously non-working test.
2024-02-14 06:56:22 +01:00
Aliaksandr Kalenik
9c99182b1e LibWeb: Change StackingContext::hit_test() to accept callback
This change modifies hit_test() to no longer return the first paintable
encountered at a specified position. Instead, this function accepts a
callback that is invoked for each paintable located at a position, in
hit-testing order.

This modification will allow us to reuse this call for
`Document.elementsFromPoint()` in upcoming changes.
2024-02-14 06:56:22 +01:00
Lucas CHOLLET
15d151ee66 LibGfx/ICO: Remove unused parameter 2024-02-14 06:56:03 +01:00
Tim Ledbetter
877641f626 LibWeb: Display an IBeam cursor by default when mousing over a text node
We now check the type of the layout node at the current mouse position
when determining which cursor to display during a mouse move event.
2024-02-13 19:47:39 +01:00
Nico Weber
ddbcd901d1 LibPDF: Separate Type0 CMap errors
No behavior change, just more granular "not implemented" diagnostics.
2024-02-13 19:46:31 +01:00
Nico Weber
8e50bbc9fb LibPDF: Add string drawing code for Type0Fonts
This is very similar to SimpleFont::draw_string() for now, but
it'll become a bit different when we add support for vertical
text.

CIDFontType now only needs to draw single glyphs. Neither of the
subclasses can do that yet, so no behavior change yet.
2024-02-13 19:46:18 +01:00
Andrew Kaster
9077fe15ac WebContent: Tolerate invalid page_ids in ConnectionFromClient
When a tab or nested traversable navigable is closed, there might be
messages still in the pipe from the UI process that we need to
gracefully drop, rather than crash trying to access an invalid pointer.
2024-02-13 19:46:10 +01:00
Andrew Kaster
3d6c515bae WebContent: Jump through less hoops to access top level traversable 2024-02-13 19:46:10 +01:00
Andrew Kaster
bc87a48e0b WebDriver: Mark current window handle as invalid after close_window() 2024-02-13 19:46:10 +01:00
Andrew Kaster
2b3bc2654f LibWeb: Mark Navigable as destroyed in destroy_top_level_traversable AO
Without this, a top level traversable might show up in settings we don't
want it to when accessing all_navigables, such as choose a navigable.
2024-02-13 19:46:10 +01:00
Andrew Kaster
a0e7af0cd9 LibWeb: Don't choose destroyed navigables in choose a navigable AO
There's a chance that we try to choose a navigable before a previously
destroyed navigable is fully destroyed and GC'd. Investigating why this
can happen is a separate endeavor, let's just not crash for now.
2024-02-13 19:46:10 +01:00
Nico Weber
eaa568210f LibPDF: Split CCITT errors by group 2024-02-13 19:45:47 +01:00
Nico Weber
c201825cc8 LibPDF: Read CCITT decode params
We don't do anything with them yet, so no behavior change.
2024-02-13 19:45:47 +01:00
Nico Weber
454a10774e LibPDF: Let Filter::handle_lzw_and_flate_parameters() read decode params
...instead of reading them in Filter::decode() for all filters and
then passing them around to only the LZW and flate filters.

(EarlyChange is LZWDecode-only, so that's read there instead.)

No behavior change.
2024-02-13 19:45:47 +01:00
Nico Weber
9875ce0c78 LibPDF: Reorder loops in SampledFunction::evaluate()
Previously, we'd loop over the index of the output coordinate,
for example for a CMYK->RGB function, we'd loop over RGB. For
every output index, we'd then sample the function at the CMYK
input point.

Now, we sample at CMYK once and return a span for all outputs,
since they're stored in contiguous memory. And we then loop
over the outputs only to do weighting and mapping to the target
range at the end.

Reduces the runtime of

      (cd Tests/LibPDF; \
          ../../Build/lagom/bin/BenchmarkPDF --benchmark_repetitions 5)

from 235.6±2.3ms to 103.2±3.3ms on my system, and makes
SampledFunction::evaluate() more similar to lerp_nd() in TagTypes.h.
2024-02-13 19:45:19 +01:00
Matthew Olsson
3c9c134d71 LibWeb: Implement KeyframeEffect::{get,set}_keyframes 2024-02-13 19:44:44 +01:00
Matthew Olsson
38c67ba17c LibWeb: Implement parsing a monolithic keyframes-like argument
See the last commit for a more in-depth explanation
2024-02-13 19:44:44 +01:00
Matthew Olsson
7d69fa0ccf LibWeb: Partially implement the "process a keyframes argument" procedure
Keyframes can be given in two separate forms:

- As an array of separate keyframe objects, where the keys of each
  keyframe represent CSS properties, and their values represents the
  values that those CSS properties should take

  e.x.:
  [{ color: 'red', offset: 0.3 }, { color: 'blue', offset: 0.7 }]

- As a single monolithic keyframe object, where the keys of each
  keyframe represent CSS properties, and their values are arrays of
  values, where each index k represents the value of the given
  property at the k'th frame.

  e.x.:
  { color: ['red', 'blue'], offset: [0.3, 0.7] }

This commit only implements the first option, as it is much simpler. See
the next commit for the implementation of the second option.
2024-02-13 19:44:44 +01:00
Matthew Olsson
9f404ed9c1 LibWeb: Implement the "compute missing keyframe offsets" procedure 2024-02-13 19:44:44 +01:00
Matthew Olsson
38153b47d6 LibWeb: Implement the "process a keyframe-like object" procedure 2024-02-13 19:44:44 +01:00
Matthew Olsson
212a139292 LibWeb: Add a way to test if a CSS::PropertyID is animatable 2024-02-13 19:44:44 +01:00
Aliaksandr Kalenik
edab67d5e8 LibWeb: Fix hit-testing for button element
Change 'dom_node_for_event_dispatch' to locate the closest layout node
with a DOM node instead of only checking the direct ancestor.

This fixes hit-testing for buttons because they are wrapped into
multiple anonymous layout nodes (internally we use flex formatting for
them).
2024-02-13 14:22:14 +01:00
Lucas CHOLLET
8e21bbf7bf LibGfx/TIFF: Add support for tiled images
A tile is basically a strip with a user-defined width. With that in
mind, adding support for them is quite straightforward. As a lot the
common code was named after 'strips', to avoid future confusion I
renamed everything that interact with either strips or tiles to a
global term: 'segment'.

Note that tiled images are supposed to always have a 'TileOffsets' tag
instead of 'StripOffset'. However, this doesn't seem to be enforced by
encoders, so we support having either of them indifferently.

The test case was generated with the following Python script:

import pyvips

img = pyvips.Image.new_from_file('deflate.tiff')
img.write_to_file('tiled.tiff',
                  compression=pyvips.ForeignTiffCompression.DEFLATE,
                  tile=True, tile_width=64, tile_height=64)
2024-02-13 10:13:11 +01:00
Lucas CHOLLET
a30515011a LibGfx/TIFF: Add support for TileOffset and TileByteCounts 2024-02-13 10:13:11 +01:00
Lucas CHOLLET
18871e23d7 LibGfx/TIFF: Make decoders take an IntSize
They will also need the width of the sub-image when we will add support
for tiles.
2024-02-13 10:13:11 +01:00
Lucas CHOLLET
7b510c3876 LibGfx/TIFF: Rename scanline => image_row
This variable stores the number of rows from the beginning of the image,
contrary to `row` that stores the number of rows relative to the start
of the current segment.
2024-02-13 10:13:11 +01:00
Lucas CHOLLET
e327d357d0 LibGfx/TIFF: Read Tile-related tags
-`TileWidth`
-`TileWidth`
-`TileOffsets`
-`TileByteCounts`
2024-02-13 10:13:11 +01:00
Lucas CHOLLET
c4e8e5c4a6 LibGfx/TIFF: Rename ImageHeight => ImageLength
This is the name used in the TIFF specification. No behavior change.
2024-02-13 10:13:11 +01:00
Lucas CHOLLET
f5e7ee8d4a LibGfx/CCITT: Don't be fooled by black-starting lines
The first marker is always white in CCITT streams, so lines starting
with a black pixel encodes a symbol meaning 0 white pixels. Then, the
decoding would proceed with a black symbol. We used to set the symbol's
color based on `column == 0`, which is wrong in this situation.
2024-02-13 00:37:06 +01:00
Lucas CHOLLET
a4b2e5b27b LibGfx/CCITT: Don't overrun the image width 2024-02-13 00:37:06 +01:00
Lucas CHOLLET
720187623b LibGfx/TIFF: Read and honor the FillOrder tag 2024-02-13 00:37:06 +01:00
Andrew Kaster
6a0fe08604 LibWeb: Implement document.elementsFromPoint
This API seems to be used by WPT for sending synthetic input events.

Implementing the naive translation of elementFromPoint to the spec steps
for this algorithm turns 4 'tests had errors unexpectedly' and 3 'tests
had timeouts unexpectedly' into 1 pass and 7 'tests had unexpected
subtest results' on the infrastructure/ subdirectory of WPT.
2024-02-12 11:43:22 -07:00
Andrew Kaster
e7daa02bf2 LibWeb: Unblock port 9000
This was blocked because it can be used for cross-protocol attacks on
some network printers. However, it's also used by the web platform
tests. One can argue that getting WPT working is more important than
theoretical attacks on poorly configured printers.
2024-02-12 11:43:22 -07:00
Andrew Kaster
deb11a669a LibWeb: Stub out WebDriver deserialize as a proxy capability AO
This prevents us from returning an 'unrecognized capability' error when
a WebDriver client sends us a proxy capability. We still don't actually
support setting or returning a non-empty proxy capability, though.

We just don't choke on the input capability request from the server.

This patch also doesn't actually validate the input proxy requests.
2024-02-12 11:43:22 -07:00
Nico Weber
751185cb76 LibPDF: Scale default glyph width by font size and x scale
This fixes rendering of commas in 0000941.pdf page 1. The commas
use the default width, and without this they show up very large,
covering the page.

Also, it's nice that the code now looks like the regular case 4 lines
further up.
2024-02-12 14:32:04 +00:00
Lucas CHOLLET
b9afac0a06 LibGfx/CCITT: Consider the UseFillBits option 2024-02-12 14:08:56 +01:00
Lucas CHOLLET
9ae17e3a7a LibGfx/CCITT: Align the output stream on byte-boundary after each line
This makes the CCITT decoder in line with what the TIFF decoder is
expecting.
2024-02-12 14:08:56 +01:00
Nico Weber
7ab4e53b99 LibPDF/CFF: Add code for fdselect parsing
This is one of the two top dict entries we need for CID-keyed fonts.
We don't send any CID-keyed font data into the CFF parser yet,
so no behavior change.
2024-02-12 14:05:16 +01:00
Nico Weber
6ebddab448 LibPDF/CFF: Add enum values for CID-keyed font top dict entries
No behavior change.
2024-02-12 14:05:16 +01:00
Nico Weber
6df0150671 LibPDF: Add some CIDFontType0C scaffolding
No real behavior change. We don't actually load the CFF data yet
(blocked on #23136 and some more), and we don't have drawing code
yet, and Type0Font::draw_string() doesn't do any drawing yet.

But it's a step in the right direction.
2024-02-12 13:59:00 +01:00
Aliaksandr Kalenik
95d91a37d2 LibWeb: Resolve outline CSS property before paint commands recording
Refactor to resolve paint-only properties before painting, aiming to
stop using layout nodes during recording of painting commands.

Also adds a test, as we have not had any for outlines yet.
2024-02-12 13:38:24 +01:00
MacDue
f19b17e089 LibWeb: Use paths for text in CRC2D (if possible)
This allows for:

  * Transformed text (e.g. rotated text)
  * Stroked text
  * Filling/stroking text with PaintStyles (e.g. gradients)
  * Squashed/condensed text (via maxWidth parameter)

Fixes part of #22817
2024-02-12 13:38:10 +01:00
Tim Ledbetter
774119bb57 LibWeb: Implement document.designMode
Setting this attribute to "on" makes the entire document editable.
2024-02-12 07:35:14 +01:00
Sam Atkins
c9fb3e07d2 BrickGame: Make action shortcuts work when the game is paused
We previously never called event.ignore(), so the keydown event for F2
or F11 etc would be consumed by the BrickGame widget instead of
bubbling up. Now you can start a new game, or escape fullscreen mode,
even if you've paused the game. :^)
2024-02-11 21:13:06 +00:00
Nico Weber
4409b33145 AK: Make IndexSequence use size_t
This makes it possible to use MakeIndexSequqnce in functions like:

    template<typename T, size_t N>
    constexpr auto foo(T (&a)[N])

This means AK/StdLibExtraDetails.h must now include AK/Types.h
for size_t, which means AK/Types.h can no longer include
AK/StdLibExtras.h (which arguably it shouldn't do anyways),
which requires rejiggering some things.

(IMHO Types.h shouldn't use AK::Details metaprogramming at all.
FlatPtr doesn't necessarily have to use Conditional<> and ssize_t could
maybe be in its own header or something. But since it's tangential to
this PR, going with the tried and true "lift things that cause the
cycle up to the top" approach.)
2024-02-11 18:53:00 +01:00
Tommy van der Vorst
1c7ec9c770 LibWeb: Ignore repeat(auto-fit/auto-fill, auto) as it is not allowed 2024-02-11 17:51:50 +01:00
Nico Weber
8e7cb11856 LibPDF/CFF: Add enum values for remaining PrivDictOperators
No behavior change, except that we now dbgln() if we see a
PrivDictOperator we don't know about. (I haven't seen this in
practice, but I found this useful while debugging things.)
2024-02-11 14:52:54 +01:00
ronak69
7833dc0f5a LibLine: Add internal functions to search character forwards & backwards 2024-02-11 08:50:51 +01:00
ronak69
ff33f00d16 LibVT: Ability to generate each of the 32 ASCII control characters
Before, it was only possible to generate 27 control characters (from ^A
to ^Z, and ^\) (with only one possible key combination).

Now, the remaining 5 (^@, ^[, ^], ^^, and ^_) can also be generated with
control plus key combinations. :^)

Also added are the legacy aliases supported by most terminals:

    Ctrl+{2, Space} -> ^@ (NUL)
    Ctrl+3 -> ^[ (ESC)
    Ctrl+4 -> ^\
    Ctrl+5 -> ^]
    Ctrl+6 -> ^^
    Ctrl+7 -> ^_
    Ctrl+8 -> ^? (DEL)
    Ctrl+/ -> ^_

Note that now, one extra key combination corresponding to a character
that shares the same least significant five bits with the original
character (used in caret notation) can also generate a control
character. For example, in the US English keyboard layout both Ctrl+[
and Ctrl+{ (same as Ctrl+Shift+[) will generate the Escape control
character (^[).
2024-02-11 08:50:51 +01:00
ronak69
cb02d52ac9 LibLine: Add internal function to erase consecutive spaces under cursor 2024-02-11 08:50:51 +01:00
Tim Ledbetter
7f2582fca9 LibWeb: Update the cursor position when an editable element is clicked
With this change, clicking on an editable element, such as an `input`
or `textarea` causes the cursor position to be updated to the current
mouse position.
2024-02-11 08:15:38 +01:00
Aliaksandr Kalenik
d4932196cc LibWeb: Account for all clipped border radii in containing block chain
With this change, instead of applying only the border-radius clipping
from the closest containing block with hidden overflow, we now collect
all boxes within the containing block chain and apply the clipping from
all of them.
2024-02-11 08:12:31 +01:00
Aliaksandr Kalenik
1ae416fa94 LibWeb: Add compute_combined_css_transform() for PaintableBox
This prepares for upcoming changes where the code that finds combined
CSS transform will be reused in `clear_clip_overflow_rect()`.
2024-02-11 08:12:31 +01:00
MacDue
080d9ec246 LibWeb: Invalidate layout after setting SVG transform attribute 2024-02-11 08:10:45 +01:00
MacDue
1d999fa780 LibWeb: Return milliseconds from unsafe_shared_current_time()
This was incorrectly changed to returning seconds in fc5cab5, which
meant the time passed to the callbacks of requestAnimationFrame() was
wrong.
2024-02-11 08:10:45 +01:00
MacDue
38855de829 LibWeb: Use 'now' from EventLoop for animation frame callbacks
Previously, 'now' was set to the time `requestAnimationFrame()` was
called, and the EventLoop's 'now' was ignored. This was a little odd and
meant the time was always in the past.
2024-02-11 08:10:45 +01:00
Tim Ledbetter
0577a664dd LibWeb: Use correct offset value when replacing character data
Previously, the range's end offset was being set using it's previous
value.
2024-02-10 11:18:51 +01:00
Aliaksandr Kalenik
40246adfb9 LibWeb: Add internals.wheel() to simulate mouse wheel events
This function allows us to write tests for scrolling scenarios where
the events are processed by the EventHandler.
2024-02-10 11:18:40 +01:00
Sam Atkins
c6e5581682 HexEditor: Include annotation text in the "Delete annotation?" dialog
It's helpful to have some description of what you're deleting. :^)

40 characters is chosen completely arbitrarily, but seems reasonable.
2024-02-09 17:00:15 +00:00
Sam Atkins
56eb45ccbc HexEditor: Add toolbar and context menus to the Annotations panel
The Annotations panel is the most obvious place to perform actions
related to annotations, so let's make that possible. :^)

The toolbar gets open/save/save-as actions for annotations, and one for
adding an annotation. The table itself gets a context menu for editing
or deleting the selected annotation.
2024-02-09 17:00:15 +00:00
Sam Atkins
a5d11c0a26 HexEditor: Convert panels to DynamicWidgetContainer
This lets the user swap them around and pop them out as separate windows
as desired. We do lose the ability to individually resize them though,
until DynamicWidgetContainer supports that.
2024-02-09 17:00:15 +00:00
Sam Atkins
6850ef9014 HexEditor: Respond to font changes 2024-02-09 16:59:02 +00:00
Sam Atkins
3318563ad9 HexEditor: Size the offset area based on the text width
This gets rid of the last use of the offset_margin_width() magic number.

I initially tried using `character_width() * 10` and found it was not
accurate enough with between-character spacing, so instead this measures
a specific string. All offset strings should be the same width in a
fixed-width font.
2024-02-09 16:59:02 +00:00
Sam Atkins
0fdbdc5084 HexEditor: Use glyph_fixed_width() for character width 2024-02-09 16:59:02 +00:00
Sam Atkins
d3012f2df1 HexEditor: Share the code for updating the content size
And make setting the bytes_per_row a no-op if it's the same value.
2024-02-09 16:59:02 +00:00
Sam Atkins
db23d0f464 HexEditor: Save and reuse horizontal positions when painting 2024-02-09 16:59:02 +00:00
Sam Atkins
60f52aa0ef HexEditor: Save and reuse vertical positions when painting rows
Rather than repeatedly calculating the same y offset over and over,
calculate it once per row, and re-use that result.
2024-02-09 16:59:02 +00:00
Sam Atkins
4af565362c HexEditor: Remove redundant checks in offset_at()
Neither of these is possible based on the if statement above them.
2024-02-09 16:59:02 +00:00
Sam Atkins
ca3f21f273 HexEditor: Account for padding in offset_at()
Compare the x position with the start of the hex characters, which is
m_padding pixels to the right of hex_start_x. (And the same for the
text characters.) If the position is within the padding area, clamp it
so it's on the nearest character.

This was previously covered-up somewhat by using the buggy
m_address_bar_width value to calculate the start and end x positions of
these areas. Fixing that in the previous commit made this more obvious.
2024-02-09 16:59:02 +00:00
Sam Atkins
c4dc150ed7 HexEditor: Extract some content-width calculations
We repeat the same calculations a lot, and it's easy to make mistakes.

m_address_bar_width and offset_margin_width() have basically the same
purpose, but both are a little wrong. This removes the former, but
we'll get to the latter soon.
2024-02-09 16:59:02 +00:00
Sam Atkins
4dc3816853 HexEditor: Combine row-iteration loops 2024-02-09 16:59:02 +00:00
Sam Atkins
8b5d2c710b HexEditor: Make border of offset area straight down
Subtracting 1 from both axes causes a kink in the line, because the
start point isn't also translated. The clip rect prevents us from
painting too far down, so we can just remove the translated() call.
2024-02-09 16:59:02 +00:00
Sam Atkins
f57d9789f8 HexEditor: Paint byte characters with correct width 2024-02-09 16:59:02 +00:00
Sam Atkins
e2f927a7a7 HexEditor: Give i and j variables clearer names 2024-02-09 16:59:02 +00:00
Nico Weber
a91fecb17e Revert "LibPDF: Don't over-read in charset formats 1 and 2"
This reverts commit 52afa936c4.

No longer necessary after #23122 -- turns out things work
better when you do them right.

No behavior change.
2024-02-09 16:52:01 +00:00
Aliaksandr Kalenik
76d1536307 LibWeb: Optimize scroll offset and clip state recalculation
In this commit we have optimized the handling of scroll offsets and
clip rectangles to improve performance. Previously, the process
involved multiple full traversals of the paintable tree before each
repaint, which was highly inefficient, especially on pages with a
large number of paintables. The steps were:

1. Traverse the paintable tree to identify all boxes with scrollable or
   clipped overflow.
2. Gather the accumulated scroll offset or clip rectangle for each box.
3. Perform another traversal to apply the corresponding scroll offset
   and clip rectangle to each paintable.

To address this, we've adopted a new strategy that separates the
assignment of the scroll/clip frame from the refresh of accumulated
scroll offsets and clip rectangles, thus reducing the workload:

1. Post-relayout: Identify all boxes with overflow and link each
   paintable to the state of its containing scroll/clip frame.
2. Pre-repaint: Update the clip rectangle and scroll offset only in the
   previously identified boxes.

This adjustment ensures that the costly tree traversals are only
necessary after a relayout, substantially decreasing the amount of work
required before each repaint.
2024-02-09 16:45:44 +01:00
Aliaksandr Kalenik
fc40d35012 LibWeb: Move paint properties invalidation flag into Document
Move paint-only properties invalidation flag to Document for
consistency, as style and layout invalidation flags are already
managed there.
2024-02-09 16:45:44 +01:00
Nico Weber
9bccb8c8d7 LibPDF: Make CFF::parse_charset() return SIDs
...and do string expansion at the call site.

CID-keyed fonts treat the charset as CIDs instead of as SIDs,
so having access to the SIDs in numberic form will be useful
when we implement support for CID-keyed CFF fonts.

No behavior change.
2024-02-09 13:57:23 +01:00
Nico Weber
9750261921 LibPDF: Rename charset to charset_names in CFF parser
No behavior change.
2024-02-09 13:57:23 +01:00
Lucas CHOLLET
42f29b9670 LibGfx/TIFF: Also seek after reading the last tag
The `read_tag()` function is not mandated to keep the reading head at a
meaningful position, so we also need to align the pointer after the last
tag. This solves a bug where reading the last field of an IFD, which is
placed after the tags, was incorrect.
2024-02-08 09:03:46 -07:00
Lucas CHOLLET
a43793ee0d LibGfx/TIFF: Explore underlying Image File Directories
Every TIFF containers is composed of a main IFD. Some entries of this
one can be a pointer to a sub-IFD. We are now capable of exploring these
underlying structures. Note that we don't do anything with them yet.
2024-02-08 09:03:46 -07:00
Tim Ledbetter
4a7236cabf Everywhere: Prefer _string when constructing strings from literals 2024-02-08 11:01:10 -05:00
Andrew Kaster
bb9da0ed8d Ladybird: Plumb overriding root certificate paths through the chromes 2024-02-08 08:49:32 -07:00
Andrew Kaster
080aa567a5 RequestServer+LibTLS: Allow applications to specify multiple root certs 2024-02-08 08:49:32 -07:00
ronak69
49467c6ec2 LibVT: Write emoji to the pseudo-terminal master fd on emoji input
... instead of inserting it into the current output character stream
that the terminal widget is going to render.

This ensures that the emoji gets sent to the foreground process of the
terminal.
2024-02-08 16:23:25 +01:00
Sanil
433fe3dc26 Calendar: Add ability to view events 2024-02-08 08:13:04 -07:00
ronak69
05e53b5fd3 LibWeb: Use file's URL as document's URL when loading markdown files
A markdown file gets loaded as an inline content document by
`create_document_for_inline_content()`, for which the default document
URL is "about:error". That breaks the fragment links.

Overriding "about:error" URL by passing the URL of the just loaded
markdown file as an argument to `HTMLParser::run()` ensures that the URL
of the document is as expected.
2024-02-08 07:58:07 -07:00
Tim Ledbetter
6c31f2a68a LibJS: Don't crash when attempting to load from an invalid reference
Previously, attempting to load a value from an invalid reference would
cause a crash. We now return a CodeGenerationError rather than hitting
an assertion. This is not a complete solution, as ideally we would want
to return a ReferenceError, but this now matches the behavior we see
when we attempt to store something to an invalid reference.
2024-02-08 07:55:07 -07:00
Andrew Kaster
53273e2037 LibWeb: Don't navigate() to about:blank when making a fresh Traversable
This matches the behavior of the window open steps, and should probably
be a spec issue :yakplus:
2024-02-08 15:53:46 +01:00
Andrew Kaster
889b903e40 LibWeb: Call the_end() on Documents from window.open("about:blank") 2024-02-08 15:53:46 +01:00
Andrew Kaster
bc9c710904 LibWeb: Hide WebDriver::match_route debug behind its own flag
When enabling WEBDRIVER_DEBUG globally, this function's debug spam
overpowers the rest of the useful logs.
2024-02-08 15:53:46 +01:00
Nico Weber
d7f04c9aa1 LibGfx/JPEGLoader: Make byte_offset() return offset from start of stream
JPEGStream::byte_offset() now returns an offset relative to the start
of the stream, instead of relative to the buffered part.

No behavior change except if JPEG_DEBUG is set.
2024-02-08 07:45:34 -07:00
ronak69
113c6dc48b WindowServer: Show fixed aspect ratio in the resize overlay 2024-02-08 14:22:28 +00:00
ronak69
83028518a0 WindowServer: Don't show tile overlay for fixed aspect ratio windows
Windows with fixed aspect ratio cannot be tiled so the tile overlay
shouldn't be shown.
2024-02-08 14:22:28 +00:00
ronak69
8d16c7c9b9 WindowServer: Handle latching fix-aspect-ratio window to the screen edge
Double-clicking the edges of a window results in the edge being extended
until it latches to the screen edge. This used to violate the fixed
aspect ratio property of certain windows because of only extending the
window in one dimension.

This commit adds a special case to the latching logic that makes sure to
also extend the other dimension of the window such that the fixed aspect
ratio is maintained.
2024-02-08 14:22:28 +00:00
Kyle Lanmon
e09245badd cut: Add -c,--characters option 2024-02-08 07:20:50 -07:00
kleines Filmröllchen
5054f34b4a LibAudio: Automatically write a FLAC seektable
This contains a seekpoint every 2 seconds, allowing our own players to
work better.
2024-02-08 07:19:09 -07:00
Erick Howard
3e0d1becd4 cp: Add --interactive/-i flag
- Add interactive flag which tells `cp` to prompt before overwriting
  files
- Accept 'yes', 'no', 'n', and 'y' as input, all other inputs will
  result in the prompt being shown again
2024-02-08 07:11:44 -07:00
ronak69
90d68d43ce KeyboardMapper: Convert Utf-8 char in String to Utf-32 code point
Ensure that the Utf-8 encoded "mapping character" in String (from
InputBox) gets converted to Utf-32 code point. Before, only the first
byte of Utf-8 char sequence was used as a Utf-32 code point.

That used to result in incorrect characters getting written in the
keymap file for all the "non-ascii" characters used as the mapping
character.
2024-02-08 07:07:25 -07:00
Dan Klishch
dee4978d67 JSSpecCompiler+LibXML: Store location for tokens 2024-02-08 07:05:13 -07:00
Nico Weber
32f601f9a4 LibPDF: Fix small bug from #21452
I implemented CFF charset format 2 in 6f783929dd with the note
"I haven't seen this being used in the wild". Now that I have
seen it (0000658.pdf), I can say that this has never worked,
despite me claiming "it's easy to implement".

But now it works!
2024-02-08 13:48:56 +00:00
Nico Weber
93ee01041f LibGfx/OpenType: Validate we can read the active cmap subtable format
We now reject fonts where the active cmap subtable is in a format
we can't read yet, instead of silently drawing squares for all glyphs.

This doesn't fire at all for my 1000-file PDF test set, but seems
like a good thing to check.

(Instead of duplicating the switch, I first tried making a
glyph_id_for_code_point_or_else() that returns ErrorOr<u32> and then
make both glyph_id_for_code_point() and validate_format_can_be_read()
call that, but I liked less how that worked out -- felt too clever.)
2024-02-08 13:48:33 +00:00
Nico Weber
be8b5b794f LibGfx/OpenType: Error on fonts without a supported subtable
This would've saved me some debugging on #23103.

We now return an error instead of a font that draws squares for all
characters. That seems preferable since it makes these cases easy to
find. This fires for three files in my 1000-file PDF test set, so it's
not exceedingly common (...but I wasn't aware that three files were
rendering boxes for this reason, and now I am and can just make them
work in the future).
2024-02-08 13:48:33 +00:00
Sam Atkins
b177e0dd66 ClipboardHistory: Be more careful about the history limit
Previously, if the number of history items was already above the history
limit, then it would never trim old history items. This could happen if
the ClipboardHistory.json file was manually edited.

Prevent this by sorting and trimming the data that is read in. For good
measure, also guard against `> m_history_limit` in add_item().
2024-02-08 13:46:12 +00:00
Sam Atkins
0b9aee57e7 ClipboardHistory: Store clipboard history as valid JSON
Previously, the ClipboardHistory.json file contained a series of
individual JSON objects for history items, separated by newlines. This
is convenient for appending a single item, but makes the file itself
invalid JSON.

This commit changes that file to instead contain those objects in a
proper JSON array.
2024-02-08 13:46:12 +00:00
Aliaksandr Kalenik
ff3e454565 LibWeb: Invalidate paint-only property after relayout
Before this change, `set_needs_to_resolve_paint_only_properties()` was
only called after style invalidation. However, since relayout can be
triggered independently from style invalidation, we need to ensure that
paint-only properties are updated in that case too.
2024-02-08 13:08:10 +01:00
Tim Ledbetter
f961a0eb61 TerminalSettings: Ensure automark setting is reverted on cancel 2024-02-07 13:35:49 +01:00
Tim Ledbetter
fa37a220d6 Terminal: Propagate changes in automark settings to the terminal 2024-02-07 13:35:49 +01:00
Tim Ledbetter
0bdb222953 Terminal: Deduplicate bell mode parsing code 2024-02-07 13:35:49 +01:00
Tim Ledbetter
5c8962b8f1 LibVT+TerminalSettings: Move settings parsing functions to LibVT
This change moves the automark and bell settings parsing functions to
LibVT, so that they can be shared between Terminal and TerminalSettings.
2024-02-07 13:35:49 +01:00
Tim Ledbetter
2850bb881a TerminalSettings: Provide default values for terminal settings
The change ensures that functions that parse string values for terminal
settings fall back to a default value, if there is no value present or
the value is invalid.
2024-02-07 13:35:49 +01:00
Tim Ledbetter
1df31e426d TerminalSettings: Use correct name for the automark_off radio button
This was causing a segfault when opening the Terminal Settings window.
2024-02-07 13:35:49 +01:00
Nico Weber
d3c94d8436 LibGfx: Add a comment to Font::try_load_from_offset()
See #17189 -- this confused me for a bit.
2024-02-07 08:31:18 +00:00
Nico Weber
21ffb118af LibGfx/OpenType: Support cmaps with format Unicode
Some fonts only contain unicode tables. This makes them work.
2024-02-07 08:31:03 +00:00
Ali Mohammad Pur
54ab6fe5b9 LibVT+Everywhere: Introduce 'automarks' and 'clear previous command'
Automarks are similar to bookmarks placed by the terminal, allowing the
user to selectively remove a single command and its output from the
terminal scrollback.
This commit implements a single way to add marks: automatically placing
them when the shell becomes interactive.

To make sure the shell behaves correctly after its expected prompt
position changes, the terminal layer forces a resize event to be passed
to the shell on such (possibly) partial clears; this also has the nice
side effect of fixing the disappearing prompt on the preexisting "clear
including history" action: Fixes #4192.
2024-02-07 00:43:11 +01:00
Ali Mohammad Pur
cde528fdd9 LibLine: Fully redraw on resize when origin position changes 2024-02-07 00:43:11 +01:00
Ali Mohammad Pur
35abbafb7b Shell: Don't escape display/trailing texts when completing via programs
This matches the shell's own behaviour regarding completions.
2024-02-07 00:43:11 +01:00
Ali Mohammad Pur
8666b4fa87 Shell: Provide a valid ending position for POSIX immediate nodes
This allows the formatter to generate a correct immediate invocation
without a missing closing brace.
This commit also removes a useless code comment.
2024-02-07 00:43:11 +01:00
Gabriel Tassinari
946a4d6f0f Presenter: Add Manual link in help menu 2024-02-06 20:43:31 +00:00
mobounya
7326d00baa RequestServer: Avoid using gethostbyname
Replace gethostbyname with Core::Socket::resolve_host in
RequestServer::ConnectionFromClient::ensure_connection.

Resolved #22199.
2024-02-06 21:43:23 +01:00
Aliaksandr Kalenik
4a41a65ec5 LibWeb: Shift button paintable clip rectangle by scroll offset
Rectangles should be recorded using absolute coordinates, including
the scroll offset.
2024-02-06 13:06:16 +01:00
Aliaksandr Kalenik
d43dbe2842 LibWeb: Shift SVG paintable clip rectangle by scroll offset
Rectangles should be recorded using absolute coordinates, including
the scroll offset.
2024-02-06 13:06:16 +01:00
Dan Klishch
677bcea771 ntpquery: Use AK::convert_between_host_and_network_endian
Instead of polluting global namespace with definitions from
libkern/OSByteOrder.h and machine/endian.h on MacOS, just use AK
functions for conversions.
2024-02-06 04:37:47 -07:00
Shannon Booth
f5fd912d6d LibJS/Tests: Add a bunch of rounding mode tests 2024-02-06 08:45:34 +01:00
Shannon Booth
0ed352e44e LibJS: Update DifferenceInstant and its callers to latest spec
This is a bit tangled in that updating these functions involves a slew
of other spec changes.

However those spec updates fix a bunch of rounding issues, fixing 32
test cases.

Diff Tests:
    +32     -32 
2024-02-06 08:45:34 +01:00
Shannon Booth
c4f37c1bfa LibJS: Implement Temporal AO BalanceDuration 2024-02-06 08:45:34 +01:00
Shannon Booth
276930185a LibJS: Implement temporal AO BalancePossiblyInfiniteTimeDuration
This has the guts of the old temporal AO BalanceDuration with some
differences such as an extra precision of one unit. This appears to be
important for different rounding modes to act as a tiebreaker.

It also does not have any logic regarding a zoned date time 'relative
to' - the spec seems to have this factored in a way where callers are
expected to perform this logic if neccessary.
2024-02-06 08:45:34 +01:00
Shannon Booth
750ecc3f43 LibJS: Add a FIXME to remove use of old Temporal AO BalanceDuration
This is a bit too big of a yak to take on right now - leave a FIXME to
remove this as it seems easier to update callers of this function
piecemeal.
2024-02-06 08:45:34 +01:00
Shannon Booth
af586dde64 LibJS: Add a remainder() function to represent remainder(x, y)
This is just the same as calling x % y - or fmod, and is implemented
for symmetry with the 'modulo' function.
2024-02-06 08:45:34 +01:00
Nico Weber
cc083310a7 LibGfx/ICC: In lerp_nd(), use VLAs for coordinates
`x.size()` is 3 or 4 in practice and at most 15 in theory
(cf `number_of_components_in_color_space()` in Profile.cpp),
so using a VLA for these should be fine from a stack size PoV.

It's only accessed through a span, so there's no additional
security risk.

Takes

    Build/lagom/bin/image --no-output \
        --assign-color-profile \
            Build/lagom/Root/res/icc/Adobe/CMYK/USWebCoatedSWOP.icc \
        --convert-to-color-profile serenity-sRGB.icc \
        cmyk.jpg

from 2.74s to 2.66s on my machine, almost 3% faster.

(Don't do this in LibPDF's SampledFunction::evaluate() since there's
no bound on the dimension of the input function. Realistically,
size of the table puts a pretty low bound on that dimension though,
so we should probably enforce some bound in SampledFunction::create()
and do this there too.)
2024-02-06 08:44:53 +01:00
Nico Weber
9fc47345ce LibGfx+LibPDF: Make sample() functions take ReadonlySpan<>
...instead of Vector<>.

No behavior (or performance) change.
2024-02-06 08:44:53 +01:00
Nico Weber
a352099b05 LibGfx/ICC: In lerp_nd(), use VLAs for left_index, factor
`x.size()` is 3 or 4 in practice and at most 15 in theory
(cf `number_of_components_in_color_space()` in Profile.cpp),
so using a VLA for these should be fine from a stack size PoV.

They're accessed from two local loops iterating from 0 to
`x.size()`, so it's hopefully not too risky from a security
PoV either.

Takes

    Build/lagom/bin/image --no-output \
        --assign-color-profile \
            Build/lagom/Root/res/icc/Adobe/CMYK/USWebCoatedSWOP.icc \
        --convert-to-color-profile serenity-sRGB.icc \
        cmyk.jpg

from 2.81s to 2.74s on my machine, about 2.5% faster.
2024-02-06 08:44:53 +01:00
Tim Ledbetter
69df94ec5c LibWeb: Implement document.elementFromPoint()
This function uses our existing hit testing code to determine the
topmost element at the given coordinates relative to the viewport.
2024-02-06 08:43:03 +01:00
Matthew Olsson
c732e03ea0 LibWeb: Add missing implementation of method in AnimationTimeline 2024-02-06 08:42:07 +01:00
Matthew Olsson
df4be9a479 LibWeb: Add missing virtual destructor in AnimationEffect 2024-02-06 08:42:07 +01:00
Matthew Olsson
154b4d4196 LibWeb: Invalidate style of animation targets in update_finished_state 2024-02-06 08:42:07 +01:00
Matthew Olsson
a7727215a6 LibWeb: Implement missing members of AnimationEffect.getComputedTiming() 2024-02-06 08:42:07 +01:00
Matthew Olsson
360082544c LibWeb: Fix incorrect Animation active_time in the after phase 2024-02-06 08:42:07 +01:00
Matthew Olsson
16a21a503d LibWeb: Fix incorrect comparison in Animation::update_finished_state 2024-02-06 08:42:07 +01:00
Matthew Olsson
2e29b0d700 LibWeb: Rename confusing parameter in AnimationPlaybackEvent 2024-02-06 08:42:07 +01:00
Matthew Olsson
8c80d0ee02 LibWeb: Fix typo (original_relative_time -> origin_relative_time) 2024-02-06 08:42:07 +01:00
Matthew Olsson
a27dd03dcc LibWeb: Avoid slicing struct in KeyframeEffect::construct_impl 2024-02-06 08:42:07 +01:00
Aliaksandr Kalenik
7411f66fcf LibWeb/CSS: Resolve value of "height" in special way according to spec
Per spec value of height should be resolved to used value if "display"
property is not "none" or "contents".
2024-02-06 08:41:21 +01:00
Bastiaan van der Plaat
582bf1eaf3 Run: Fix bug where it would crash because uninitialized main widget
The set_main_widget<T>() function only calls the construct and not
`try_create()` that the GMLCompiler generates so all calls to
`find_descendant_of_type_named()` would result in null
pointers that would resolve in a crash.
2024-02-06 08:41:01 +01:00
Timothy Flynn
747fd86f26 LibWeb: Make WebDriver check if the BC's navigable has been destroyed
The spec steps to check if a browsing context is open have been updated
for navigables.
2024-02-06 08:40:27 +01:00
Aliaksandr Kalenik
623ad94582 LibWeb: Resolve effective overflow-x and overflow-y according to spec
Implements following rule from CSS Overflow Module Level 3:
"The visible/clip values of overflow compute to auto/hidden
(respectively) if one of overflow-x or overflow-y is neither visible
nor clip."
2024-02-06 08:39:06 +01:00
Shannon Booth
b6292a2d7d LibWeb: Use WebIDL integer typedefs in ProgressEvent 2024-02-06 08:35:53 +01:00
Shannon Booth
3e756da564 LibWeb: Use unsigned long long for ProgressEventInit
The IDL generator now supports this :^)
2024-02-06 08:35:53 +01:00
Nico Weber
92a628c07c LibPDF: Always treat /Subtype /Image as binary data when dumping
Sometimes, the "is mostly text" heuristic fails for images.

Before:

    Build/lagom/bin/pdf --render out.png ~/Downloads/0000/0000521.pdf \
        --page 10 --dump-contents 2>&1 | wc -l
       25709

After:

    Build/lagom/bin/pdf --render out.png ~/Downloads/0000/0000521.pdf \
         --page 10 --dump-contents 2>&1 | wc -l
       11376
2024-02-05 21:18:19 -05:00
Bastiaan van der Plaat
5a8e82e6ea Base: Create user default Music and Pictures directories 2024-02-05 16:30:52 +01:00
Bastiaan van der Plaat
c8dc77a552 LibCore: Add Music, Pictures and Videos user directory helpers 2024-02-05 16:30:52 +01:00
Bastiaan van der Plaat
f4d5ff9ed9 Welcome: Move tips.txt to /usr/share/Welcome because it's system wide 2024-02-05 16:30:52 +01:00
Andrew Kaster
813c66403d LibWeb: Catch null browsing context in destroy_top_level_traversable
When WebDriver asks to destroy a window, we can hit this case with no
active browsing context. This seems odd, but perhaps is a spec issue as
well. Just log to dbgln for now.
2024-02-05 08:05:48 -07:00
Andrew Kaster
d508a02f25 LibWeb: Ensure that load events are fired for window.open('about:blank') 2024-02-05 08:05:48 -07:00
Andrew Kaster
888e67992a LibWeb: Remove unused BrowsingContext functions and data members
This aligns it better with the current state of the spec.

There's still some functions and data members that need moved into
Navigable or TraversableNavigable, but we can leave those for the next
cleanup PR.
2024-02-05 08:05:48 -07:00
Andrew Kaster
9645daaf6c LibWeb: Remove RemoteBrowsingContext and AbstractBrowsingContext
With the transition to Navigables, and a working implementation of
window.open(), we no longer need this abstraction layer.
2024-02-05 08:05:48 -07:00
Andrew Kaster
6e75440d5a LibWeb: Bring Document::fallback_base_url closer to the spec 2024-02-05 08:05:48 -07:00
Andrew Kaster
5d9d0aa267 LibWeb: Replace check for BrowsingContext's about blank state with false
This check has been if (false && stuff) for quite a while, since the
transition to Navigables. No one updates the BrowsingContext's session
history, so the check for it having an about blank document and only an
about blank document is always false.
2024-02-05 08:05:48 -07:00
Andrew Kaster
b6fc29ca21 LibWeb: Always use Navigable to translate CSS positions to top-level 2024-02-05 08:05:48 -07:00
Andrew Kaster
3aee787539 LibWeb+WebContent: Convert WebDriver to choose a navigable AO
Also use the TraversableNavigable's window_handle instead of the
BrowsingContext's.
2024-02-05 08:05:48 -07:00
Dan Klishch
3e43d15440 Everywhere: Prefer VERIFY over assert() 2024-02-05 07:03:53 -05:00
Nico Weber
f562c470e2 LibGfx+LibPDF: Simpler and faster N-D linear sampling
Previously, if we wanted to to e.g. do linear interpolation in 2-D,
we'd get a sample point like (1.3, 4.4), then get 4 samples around
it at (1, 4), (2, 4), (1, 5), (2, 5), then reduce the 4 samples
to 2 samples by computing the combined samples
`0.3 * f(1, 4) + 0.7 * f(2, 4)` and `0.3 * f(1, 5) + 0.8 * f(2, 5)`,
and then 1-D linearly blending between these two samples with the
factor 0.4. In the end we'd multiply the first value by 0.3 * 0.4,
the second by 0.7 * 0.4, the third by 0.3 * 0.6, and the third by
0.7 * 0.6, and then sum them all up.

This requires computing and storing 2**N samples, followed by
another 2**N iterations to combine the 2**N sampls to a single value.
(N is in practice either 4 or 3, so 2**N isn't super huge.)

Instead, for every sample we can directly compute the product of
weights and sum them up directly. This lets us omit the second loop
and storing 2**N values, in exchange for doing an additional O(n)
work to compute the product.

Takes

    Build/lagom/bin/image --no-output --invert-cmyk \
        --assign-color-profile \
            Build/lagom/Root/res/icc/Adobe/CMYK/USWebCoatedSWOP.icc \
        --convert-to-color-profile serenity-sRGB.icc \
        cmyk.jpg

form 3.42s to 3.08s on my machine, almost 10% faster (and less code).

Here cmyk.jpg is a 2253x3080 cmyk jpeg, and USWebCoatedSWOP.icc is an
mft2 profile with input tables with 256 samples and a 9x9x9x9 CLUT.

The LibPDF change is covered by TEST_CASE(sampled) in LibPDF.cpp,
and the LibGfx change is basically the same change as the one in
LibPDF (where the test results don't change) and the output
subjectively looks identical. So hopefully this causes indeed no
behavior change :^)
2024-02-04 21:49:23 +01:00
Nico Weber
c4780f4ee1 image: Add an --invert-cmyk option
This is useful for working with CMYK jpegs extracted from PDFs
by mutool. CMYK channels for jpegs in PDFs are inverted compared to
CMYK channels in standalone jpegs (!), and mutool doesn't compensate
for that.

You can now do:

    mutool extract  ~/Downloads/0000/0000711.pdf 461

Followed by:

    Build/lagom/bin/image -o out.png \
        --invert-cmyk \
        --assign-color-profile \
            Build/lagom/Root/res/icc/Adobe/CMYK/USWebCoatedSWOP.icc \
        --convert-to-color-profile serenity-sRGB.icc \
        cmyk.jpg

Doesn't exactly roll off the keyboard, but at least it's possible.

(We should probably add an implicit default CMYK color profile if
the input file doesn't have one, and assume conversion to sRGB when
saving to a format that can only store RGB.)
2024-02-04 21:34:53 +01:00
Nico Weber
fa3fead7a4 image: Move ppm_ascii down a bit
It belongs close to `quality` since it needed at output time.

No behavior change (except for `--help` output order).
2024-02-04 21:34:53 +01:00
Andrew Kaster
36cd2fb7c5 Ladybird+WebContent: Update IPC calls to handle multiple traversables
The IPC layer between chromes and LibWeb now understands that multiple
top level traversables can live in each WebContent process.

This largely mechanical change adds a billion page_id/page_index
arguments to make sure that pages that end up opening new WebViews
through mechanisms like window.open() still work properly with those
extra windows.
2024-02-03 20:51:37 -05:00
Andrew Kaster
adb5c27331 LibWeb: Create a new WebView for window.open()'d top level traversables 2024-02-03 20:51:37 -05:00
Andrew Kaster
677bdc2a4f Ladybird: Add IPC call for creating a new child tab
This will be used for choosing a navigable that requires opening a new
tab or new window. Such as calls to window.open(), or specific WebDriver
calls.
2024-02-03 20:51:37 -05:00
Andrew Kaster
48ce8fb4e9 Ladybird: Add ability to create a tab without creating a new WebContent 2024-02-03 20:51:37 -05:00
Dan Klishch
506707cc2b LibCore: Allow listening for socket errors and hang-ups 2024-02-03 16:43:13 -07:00
Dan Klishch
6836091a21 LibCore: Switch from select(2) to poll(2) for the event loop 2024-02-03 16:43:13 -07:00
Dan Klishch
77e4f0d7d8 LibCore: Allow listening for multiple conditions using a single Notifier
While on it, implement currently unused Notifier::set_type correctly
(but not efficiently) by re-registering Notifier in the EventLoop.
2024-02-03 16:43:13 -07:00
Timothy Flynn
5d1657f57f LibWeb: Implement implicit submission of HTMLFormElement 2024-02-03 15:30:16 -07:00
Timothy Flynn
a17074422e LibWeb: Reset form association when any element with an ID changes
When an element with an ID is added to or removed from the DOM, or if
an ID is added, removed, or changed, then we must reset the form owner
of all form-associated elements who have a form attribute.

We do this in 2 steps, using the DOM document as the messenger to handle
these changes:

1. All form-associated elements with a form attribute are stored on the
   document. If the form attribute is removed, the element is removed
   from that list as well.

2. When a DOM element with an ID undergoes any of the aforementioned
   changes, it notifies the document of the change. The document then
   forwards that change to the stored form-associated elements.
2024-02-03 15:30:16 -07:00
Timothy Flynn
960dcf0e56 LibWeb: Reset form association when the element's form attribute changes 2024-02-03 15:30:16 -07:00
Timothy Flynn
23fb1209af LibWeb: Add FormAssociatedElement to the forwarding header 2024-02-03 15:30:16 -07:00
Timothy Flynn
fb270289a4 LibWeb: Store HTMLFormElement associated elements as nonnull GC pointers
We never store null elements in this list, so let's avoid confusion and
store the elements as NonnullGCPtr.
2024-02-03 15:30:16 -07:00
Timothy Flynn
c5f8f940f0 LibWeb: Convert some tabs to spaces in an HTMLFormElement comment block 2024-02-03 15:30:16 -07:00
Tim Ledbetter
d73979e0a8 LibWeb: Don't update input text if Ctrl or Alt are pressed
With this change, input elements ignore keypresses while Ctrl or Alt
are pressed. This matches the behavior of Chrome and Firefox
2024-02-03 14:07:37 -05:00
Timothy Flynn
0d3072bdac LibJS: Use IteratorStepValue in ECMA-402
This is an editorial change in the ECMA-402 spec. See:
https://github.com/tc39/ecma402/commit/e295500
2024-02-03 14:07:26 -05:00
Timothy Flynn
18847fca50 LibJS: Use IteratorStepValue in ECMA-262
This is an editorial change in the ECMA-262 spec. See:
https://github.com/tc39/ecma262/commit/12d3687

Note they have not yet updated all potential consumers to use this new
AO.
2024-02-03 14:07:26 -05:00
Timothy Flynn
2b96e732dd LibJS: Implement the IteratorStepValue AO
This is an editorial change in the ECMA-262 spec. See:
https://github.com/tc39/ecma262/commit/12d3687

This AO is meant to replace usages of IteratorNext followed by
IteratorValue with a single operation.
2024-02-03 14:07:26 -05:00
Timothy Flynn
3ca86cd044 LibJS: Allow creating the specialized Optional<Value> from OptionalNone
This allows, for example:

    ThrowCompletionOr<Optional<Value>> foo()
    {
        return OptionalNone {};
    }

The constructors and constraints here are lifted verbatim from
AK::Optional.
2024-02-03 14:07:26 -05:00
Aliaksandr Kalenik
36553d4566 LibWeb: Do not add CSS transforms into clip rect in PaintableWithLines
Painting command executor already accounts for CSS transforms so clip
rect only needs to be adjusted by scroll offset.
2024-02-03 20:05:09 +01:00
Aliaksandr Kalenik
7ad0767aa0 LibWeb: Remove BrowsingContext::scroll_to()
Let's use navigable directly instead of going through browsing context
to request a scroll.
2024-02-03 19:00:26 +01:00
Aliaksandr Kalenik
0c92c80544 LibWeb: Redirect wheel events to iframe if needed in EventHandler 2024-02-03 19:00:26 +01:00
Aliaksandr Kalenik
bf14de4118 LibWeb: Remove direct calls of page_did_request_scroll_to()
By replacing the `page_did_request_scroll_to()` calls with a request
to perform scrolling in the corresponding navigable, we ensure that
the scrolling of iframes will scroll within them instead of triggering
scroll of top level document.
2024-02-03 19:00:26 +01:00
Aliaksandr Kalenik
607e4cab0a LibWeb: Use associated navigable in scrollX and scrollY in Window
If these functions are invoked from inside an iframe, we should use
the navigable associated with the iframe to get the viewport.
2024-02-03 19:00:26 +01:00
Aliaksandr Kalenik
531025465a LibWeb: Remove list_of_descendant_browsing_contexts()
No longer used after migrating to navigables.
2024-02-03 14:54:55 +01:00
Aliaksandr Kalenik
2175c85cea LibWeb: Remove did_stop_being_active_document_in_browsing_context()
No longer used after migrating to navigables.
2024-02-03 14:54:55 +01:00
Kyle Lanmon
f757a7cfa8 LibJS: Support more weird date formats found on the web 2024-02-03 09:29:40 +01:00
Kyle Lanmon
05b30ece17 LibCore: Add DateTime parser for milliseconds 2024-02-03 09:29:40 +01:00
Kyle Lanmon
f7efbba32d LibCore: Add parser for time offset without a sign
There is already a parser for the time offset but it requires a positive
or negative sign. There are some weird formats on the web that do not
have the sign, so let's support that. I chose to implement this as a new
option instead of editing the old one to avoid any unknown breaking
changes.
2024-02-03 09:29:40 +01:00
Aliaksandr Kalenik
1af466babf LibWeb: Fix invalidation of CSS properties that do not affect layout
Recently, we moved the resolution of CSS properties that do not affect
layout to occur within LayoutState::commit(). This decision was a
mistake as it breaks invalidation. With this change, we now re-resolve
all properties that do not affect layout before each repaint.
2024-02-03 09:28:03 +01:00
Nico Weber
955d73657e LibPDF: Make pdf --dump-contents dump less binary data
For pages containing images or embedded fonts, --dump-contents
used to dump a ton of binary data. That isn't very useful, so
stop doing it.

Before:

    % time Build/lagom/bin/pdf --render out.png \
        ~/Downloads/0000/0000711.pdf --dump-contents | wc -l
      937972

Now:

    % time Build/lagom/bin/pdf --render out.png \
        ~/Downloads/0000/0000711.pdf --dump-contents | wc -l
        6566

Printing 7k lines is also much faster than printing 940k,
0.15s instead of 2s.
2024-02-03 08:26:29 +00:00
Aliaksandr Kalenik
5a29440bdf LibWeb: Create AccelGfx context only once in PageClient
Fixes silly bug when AccelGfx always was created twice.
2024-02-03 07:03:42 +01:00
Kemal Zebari
dbb3c07e56 LibWeb/HTML: Sniff text or binary resources in HTMLObjectElement 2024-02-02 14:34:17 -05:00
Kemal Zebari
8e5410347b LibWeb/MimeSniff: Add non-standard text or binary context sniffing
This is used in cases where the spec expects us to only run the
"rules for distinguishing if a resource is a text or binary" algo.
2024-02-02 14:34:17 -05:00
Sam Atkins
8a974ca91a SystemServer: Correct logic for services exiting successfully
WIFEXITED() returns a bool, so previously we were setting
exited_successfully to true when the service was terminated by a signal,
and false if it exited, regardless of the exit status. To test the exit
status, we have to use WEXITSTATUS() instead.

This causes us to correctly use the "3 tries then give up" logic for
services that crash, instead of infinitely attempting to respawn them.
2024-02-02 16:08:23 +00:00
Nico Weber
e269526020 LibGfx/PNM: Remove two fixmes
bab2113ec1 made read_whitespace() return ErrorOr, which makes this
easy to do.

(7cafd7d177, which added the fixmes, landed slightly after bab2113ec1,
so not quite sure why it wasn't like this immediately. Maybe commit
order got changed during review; both commits were in #17831.)

No behavior change.
2024-02-02 08:26:40 +00:00
Nico Weber
eeb0d6f52b image: Remove "do_" prefix on two function names
These were here due to the prefix-less name conflicting with a local
bool, but now that options are in a struct that's no longer a problem.

No behavior change.
2024-02-02 07:20:02 +01:00
Nico Weber
d575d4fb9b image: Extract option parsing to separate function
No behavior change.
2024-02-02 07:20:02 +01:00
Nico Weber
6dc5608d95 image: Allow saving CMYK jpegs
`image` can't transform from RGB to CMYK yet, so the only way to
do this is by having a CMYK input.

For example, this works now (and it does a full decode and re-encode):

    Build/lagom/bin/image -o out.jpg \
        Tests/LibGfx/test-inputs/jpg/buggie-cmyk.jpg

Using this to convert `.pam` files written by `mutool extract`
to jpegs is a somewhat convenient method of looking at these
.pam files.
2024-02-02 07:19:18 +01:00
Nico Weber
2298aac1d1 image: Only create output file for known extensions
Previously `image -o foo.asdf foo.png` would create a 0-byte foo.asdf
before complaining that it doesn't know how to write .asdf images.

(Lifetimes of temporaries are extended to the end of the full
expresion, so this is fine.)
2024-02-02 07:19:18 +01:00
Nico Weber
1dfd68c798 LibGfx/JPEGWriter: Make it possible to write CMYKBitmaps
We always store CMYK data as YCCK, for two reasons:

1. If we ever want to do subsampling, then doing 2111 or
   2112 makes sense with YCCK, while it doesn't make sense
   if we store CMYK directly.
2. It forces us to write a color transform header. With a color
   transform header, everyone agrees that the CMYK channels should
   be stored inverted, while without it behavior between decoders
   is inconsistent. (We could write an explicit  color transform header
   for CMYK too though, but with YCCK it's harder to forget since the
   output will look wrong everywhere without it.)

initialize_mcu() grows a full CMYKBitmap override. Some of the
macroblock traversal could probably shared with some kind of
for_all_macroblocks() type function in the future, but the color
conversion math is different enough that this should be a separate
function.

Other than that, we pass around a mode parameter and make a few fuctions
write 4 instead of 3 channels, and that's it.

We use the luminance quantization and huffman tables for the K
channel.
2024-02-02 07:19:18 +01:00
Nico Weber
e8788d4023 LibGfx/JPEGWriter: Move image data writing into new add_image() function
No behavior change.
2024-02-02 07:19:18 +01:00
Nico Weber
e449dba85b LibGfx/JPEGWriter: Move header writing into new add_headers() function
No behavior change.
2024-02-02 07:19:18 +01:00
Nico Weber
4e637fa1d2 LibGfx/JPEGWriter: Pass IntSize instead of Bitmap to add_frame_header()
No behavior change.
2024-02-02 07:19:18 +01:00
Nico Weber
38526414b0 LibGfx/JPEGWriter: Add a named constant in add_scan_header()
No behavior change.
2024-02-02 07:19:18 +01:00
Nico Weber
4a8e7f44dc LibGfx/JPEGWriter: Add a named constant in add_frame_header()
No behavior change.
2024-02-02 07:19:18 +01:00
Nico Weber
ad7d25f089 LibGfx/JPEGWriter: Make vertical_macroblocks a local
It's only used in one function.

No behavior change.
2024-02-02 07:19:18 +01:00
Nico Weber
8964a52fe0 LibGfx/JPEGWriter: Use ceil_div()
No behavior change.
2024-02-02 07:19:18 +01:00
Nico Weber
d60758a947 LibGfx: Remove now-unused Color::from_cmyk()
`CMYKBitmap::to_low_quality_rgb()` morally still does the same thing,
but it has a slightly more scary name, and it doesn't use this exact
function. So let's toss it :^)
2024-02-01 13:42:04 -07:00
Nico Weber
9c762b9650 LibPDF+Meta: Use a CMYK ICC profile to convert CMYK to RGB
CMYK data describes which inks a printer should use to print a color.
If a screen should display a color that's supposed to look similar
to what the printer produces, it results in a color very different
to what Color::from_cmyk() produces. (It's also printer-dependent.)

There are many ICC profiles describing printing processes. It doesn't
matter too much which one we use -- most of them look somewhat
similar, and they all look dramatically better than Color::from_cmyk().

This patch adds a function to download a zip file that Adobe offers
on their web site. They even have a page for redistribution:
https://www.adobe.com/support/downloads/iccprofiles/icc_eula_win_dist.html

(That one leads to a broken download though, so this downloads the
end-user version.)

In case we have to move off this download at some point, there are also
a whole bunch of profiles at https://www.color.org/registry/index.xalter
that "may be used, embedded, exchanged, and shared without restriction".

The adobe zip contains a whole bunch of other useful and fun profiles,
so I went with it.

For now, this only unzips the USWebCoatedSWOP.icc file though, and
installs it in ${CMAKE_BINARY_DIR}/Root/res/icc/Adobe/CMYK/. In
Serenity builds, this will make it to /res/icc/Adobe/CMYK in the
disk image. And in lagom build, after #23016 this is the
lagom res staging directory that tools can install via
Core::ResourceImplementation. `pdf` and `MacPDF` already do that,
`TestPDF` now does it too.

The final piece is that LibPDF then loads the profile from there
and uses it for DeviceCMYK color conversions.

(Doing file access from the bowels of a library is a bit weird,
especially in a system that has sandboxing built in. But LibGfx does
that in FontDatabase too already, and LibPDF uses that, so it's not a
new problem.)
2024-02-01 13:42:04 -07:00
Nico Weber
f840fb6b4e LibPDF: Make DeviceCMYKColorSpace::the() fallible
No behavior change.
2024-02-01 13:42:04 -07:00