Commit Graph

31595 Commits

Author SHA1 Message Date
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