Commit graph

53874 commits

Author SHA1 Message Date
Andreas Kling
b63e393cef LibWeb: Fix broken conversion of CSS <resolution> dpi/dpcm to dppx
Also add a basic test that documents how these media features currently
get serialized, even if they're not identical to other browsers yet.
2023-08-25 20:10:47 +02:00
Andreas Kling
b256e52586 AK: Make Formatter for NonnullOwnPtr<T> format the T
This mirrors the behavior of NonnullRefPtr<T>. If you want to format
the pointer address, call .ptr() on it.
2023-08-25 20:10:47 +02:00
Andrew Kaster
f8e5df7a99 LibWeb: Implement navigation.navigate()
The implementation is incomplete, because our Navigable::navigate
implementation is missing the navigationAPIState parameter. We also
don't have Navigables hooked up completely enough to guarantee that a
fully active document that is not being unloaded always has a Navigable.
2023-08-25 19:51:13 +02:00
Andrew Kaster
34ea470d4f LibWeb: Add AO for navigation_must_be_a_replace to Navigable
This is used by both Navigable and Navigation, so let's put it in
Navigable. Also add a missing AK/String include to make clangd happier
with the Navigable file.
2023-08-25 19:51:13 +02:00
Andrew Kaster
7ad45d9e71 LibWeb: Expose a getter for Document's unload_counter
We need to check this value from the Navigation APIs.
2023-08-25 19:51:13 +02:00
Andrew Kaster
268fd93352 LibWeb: Use correct dictionary semantics for NavigateEvent
Every property in an IDL dictionary is implied to be optional, unless it
is marked as required. If a dictionary is passed to a method with
optional, but it has at least one required or defaulted member, the
bindings will skip the optionality of the parameter and always pass a
struct with the required parameters filled in.
2023-08-25 19:51:13 +02:00
Aliaksandr Kalenik
d8cfe79a20 LibWeb: Call process_the_iframe_attributes if iframe attribute changed
Replaces `load_src()` with `process_the_iframe_attributes()`. Both load
document of iframe but the latter is defined in spec.
2023-08-25 19:50:53 +02:00
Timothy Flynn
5291d516c0 LibWeb: Ensure layout/text/ref tests run with the desired default theme
Without setting the --resources flag, headless-browser defaults to /res
for all resources it tries to find, including the theme. It will not
find this path on Lagom, so our attempt to load the default theme does
not accomplish anything.
2023-08-25 19:48:55 +02:00
Timothy Flynn
4fc88aa17b Kernel: Run clang-format on a couple of FileSystem sources
Fixes bad formatting in commit abcf05801a.
2023-08-25 08:34:21 -04:00
Zak-K-Abdi
abcf05801a Kernel: Allow Ext2FS::flush_writes() to return ErrorOr<void> 2023-08-25 11:36:57 +01:00
Torstennator
28cda85f1f PixelPaint: Editing mask optimization
This patch introduces a new function "Layer::editin_mask_bounding_rect"
that is used within the LevelsDialog, Luminosity and Colormasking to
process only the area where a mask was applied. Therefore we can
greatly reduce the amount of processed pixels if only a small portion
of the image was masked.
2023-08-25 11:14:03 +01:00
Torstennator
b3a6ccc45b PixelPaint: Optimize color masking performance
This patch adds a small performance tweak when accsessing pixels for
color-masking. Despite of that the most time is spent in
Color::to_hsv()
2023-08-25 11:14:03 +01:00
Torstennator
60b72b8033 PixelPaint: Calculate histogram and vectorscope data only when needed
With this patch the histogram and vectorscope data for the image is
only computed when the widgets are visible to the user and therefore
saves some processing time when this information is not required
to be computed.
2023-08-25 11:14:03 +01:00
Liav A
1c0aa51684 Kernel+Userland: Remove the {get,set}_thread_name syscalls
These syscalls are not necessary on their own, and they give the false
impression that a caller could set or get the thread name of any process
in the system, which is not true.

Therefore, move the functionality of these syscalls to be options in the
prctl syscall, which makes it abundantly clear that these operations
could only occur from a running thread in a process that sees other
threads in that process only.
2023-08-25 11:51:52 +02:00
Liav A
1458849850 Kernel: Remove FixedStringBuffer template argument in prctl.cpp
This template argument can be inferred automatically and is not needed.
2023-08-25 11:51:52 +02:00
Liav A
72231b405a AK+Kernel: Introduce StdLib function to copy FixedStringBuffer to user
This new Kernel StdLib function will be used to copy contents of a
FixedStringBuffer with a null character to a user process.

The first user of this new function is the prctl option of
PR_GET_PROCESS_NAME which would copy a process name including a null
character to a user provided buffer.
2023-08-25 11:51:52 +02:00
Liav A
6cb88e224e Kernel: Remove checks for signed numbers in the prctl syscall
When doing PR_{SET,GET}_PROCESS_NAME, it's not expected to pass a signed
integer for the buffer size (in arg2). Therefore, cast it immediately to
a size_t integer type, and let the FixedStringBuffer StdLib memory copy
functions in such cases to worry about possible overflows.
2023-08-25 11:51:52 +02:00
Andreas Kling
13e2ca6b59 LibWeb: Parse src: local(...) in CSS @font-face rules
Note that we don't load the local font as specified, but at least we no
longer reject such src properties in the CSS parser.

This makes the custom fonts used on http://apple.com/ actually load. :^)
2023-08-25 11:51:28 +02:00
Andreas Kling
e924ea002f LibWeb: Add Referer HTTP header to CSS font requests
If we don't do this, we just get 404 Not Found for all fonts used by
https://apple.com/
2023-08-25 11:51:28 +02:00
Tim Ledbetter
d730cd89f5 Ports/gnuplot: Update formatting to be consistent with other ports 2023-08-25 10:33:30 +02:00
Tim Ledbetter
2512544b6b Ports/gnuplot: Explicitly specify which optional dependencies to enable
This change explicitly enables support for `libgd` and the lua
terminal in `gnuplot`, while explicitly disabling `cairo` terminals,
which don't work with our `cairo` port. Adding `libgd` as a
dependency requires us to manually link against the dependencies of
`libgd`, as this is not done automatically by the configure script.

This fixes an issue where building `gnuplot` would fail if `libgd`
was already installed.
2023-08-25 10:33:30 +02:00
Tim Ledbetter
673d6bf2d2 Ports/gnuplot: Update to version 5.4.8
We also no longer build the tutorial, as that directory no longer
exists.
2023-08-25 10:33:30 +02:00
Timothy Flynn
5a2bf7fdd1 LibWeb: Set the correct end position of HTML attribute names
We were previously setting the end position of attribute names in self-
closing HTML tags to the end of the attribute value. To illustrate the
previous behavior, consider this tag and its attribute's start and end
positions (shown inclusively below):

    <meta charset="UTF-8" />
          ^ name start
                  ^ value start
                        ^ value end
                        ^ name end

Rather than setting the end position of the attribute name when we parse
the closing slash, ensure the end position is already set while we are
in the AttributeName state. We now have:

    <meta charset="UTF-8" />
          ^ name start
                ^ name end
                  ^ value start
                        ^ value end

The tokenizer unit test has been extended to test these positions.
2023-08-25 08:22:24 +02:00
Timothy Flynn
5b2bc90b50 LibWeb: Set consistent positions for the start and end of HTML tags
To illustrate the previous behavior, consider these tags and their start
and end positions (shown inclusively below):

    Start tag:    End tag:
    <span>        </span>
     ^ start       ^ start
         ^end           ^end

The start position of a tag is the first ASCII-alpha code point after
the opening brace. The start position of a close tag is the slash just
before the first ASCII-alpha code point. And the end position of both
is the closing brace. So the opening brace is not included in the
emitted tag, but the closing brace is. And the end tag including the
slash is an oddity that had to be worked around in its only use case
(syntax highlighting).

We now consistently exclude the braces from the emitted tag, and also
exclude the slash from the end tag, so that it does not need to be
accounted for in syntax highlighting. That is, we now have:

    Start tag:    End tag:
    <span>        </span>
     ^ start        ^ start
        ^end           ^end

The tokenizer unit test has been extended to test these positions.
2023-08-25 08:22:24 +02:00
Timothy Flynn
70a87795e4 LibWeb: Remove the Tests subfolder
These were used only by test-web, which was removed in commit 81aa60163.
2023-08-25 05:39:58 +02:00
Timothy Flynn
18bbbab78c Browser: Do not visualize trailing whitespace in the source viewer
Trailing whitespace in the source view is not actionable, so there's no
benefit to showing it.
2023-08-25 05:39:32 +02:00
Karol Kosek
6808b52c1b LibGUI: Use default button in PasswordInputDialog 2023-08-24 22:56:03 +01:00
Sam Atkins
565ed9b06c LibWeb: Comment out invalid display-outside rules from Default.css
This property was removed from the CSS specs, and efforts to correct the
HTML spec have stalled. For now, let's comment them out so that I don't
get spammed with the meaningless log warnings that they didn't parse,
every time I launch Ladybird. :^)
2023-08-24 22:51:11 +01:00
Jonatan Klemets
f0a772edef LibWeb: Improve table colspan and rowspan spec alignment
This patch improves the spec alignment [1] for the table `colspan` and
`rowspan` attributes by:
- Handling min and max for `colspan`.
- Handling max for `rowspan`.

[1] https://html.spec.whatwg.org/multipage/tables.html#algorithm-for-processing-rows
2023-08-24 22:26:53 +01:00
Jonatan Klemets
04bc9b14d0 LibWeb: Use parse_non_negative_integer for colspan and rowspan parsing
`DeprecatedString::to_int` calls `StringUtils::convert_to_int`
internally. However, the integer parsing is not done in an HTML
spec-compliant way. For example, `colspan="2;"` is valid according to
the spec. But, with the current implementation, we will fail to parse
"2;", and instead fall back to using 1 as the colspan value.

This patch changes the `HTMLTableCellElement::col_span` and
`HTMLTableCellElement::row_span` methods to use the
`Web::HTML::parse_non_negative_integer` function that will parse the
attribute value in an HTML spec-compliant way.
2023-08-24 22:26:53 +01:00
Jonatan Klemets
9812031a02 LibWeb: Implement spec-compliant integer parsing
We have code inside LibWeb that uses the
`AK::StringUtils::convert_to_uint`and `AK::StringUtils::convert_to_int`
methods for parsing integers. This works well for the most part, but
according to the spec, trailing characters are allowed and should be
ignored, but this is not how the `StringUtil` methods are implemented.

This patch adds two new methods named `parse_integer` and
`parse_non_negative_integer` inside the `Web::HTML` namespace that uses
`StringUtils` under the hood but adds a bit more logic to make it spec
compliant.
2023-08-24 22:26:53 +01:00
Niklas Poslovski
ebc5b33b77 LibCore: Don't include sys/sysctl.h on Solaris 2023-08-24 22:07:28 +01:00
Andreas Kling
418f9ceadd LibWeb: Invalidate font cache when web fonts are downloaded
In case we've looked up the family name before and cached the result of
font fallback, we now invalidate any cached entries with the same family
name so that the next lookup may consider the newly downloaded font.
2023-08-24 22:07:00 +01:00
Andreas Kling
c98829f7c9 LibWeb: Move FontCache into the Web namespace 2023-08-24 22:07:00 +01:00
Aliaksandr Kalenik
6267037a74 Tests/LibWeb: Split grid/positions-and-spans.html into smaller tests
This giant grid test has been a source of problems while iterating on
GFC for a long time. Let's split it into smaller tests to make it
easier to identify issues without needing further reductions on the
test.
2023-08-24 20:18:00 +02:00
Sam Atkins
29b2022303 LibWeb: When growing or shrinking a border-radius, ignore it if it's 0
This function is used to calculate a matching radius that goes inside or
outside of the border. For example, if the border-radius is 10px and we
are 5px further out, the radius needs to be 15px to look right.
However, if the radius is 0 it isn't rounded, and we want to keep the
same sharp corner no matter how far we go.

This makes our outline rendering better match Chrome and Firefox.
2023-08-24 20:17:45 +02:00
Andrew Kaster
d1aea87889 LibWeb: Add NavigateEvent, the main event of the Navigation API
This event is the star of the show, and the main way that web content
can react to either programmatic or user-initiated navigation.

All of the fun algorithms will have to come later though.
2023-08-24 11:03:57 -06:00
Andrew Kaster
5374fbfbcf LibWeb: Make Document::determine_the_indicated_part public
We need to call this from NavigateEvent as part of the Navigation API.
2023-08-24 11:03:57 -06:00
Andrew Kaster
3dd3b2019d LibWeb: Add NavigationTransition, a transient property of Navigation
This property is useful for web content to determine whether an ongoing
navigation has settled or not.
2023-08-24 11:03:57 -06:00
Andrew Kaster
4989375191 LibWeb: Add NavigationDestination, used for NavigateEvents
This class will be used in the algorithms for the navigate event firing
algorithms to populate the destination field of the NavigateEvent.
2023-08-24 11:03:57 -06:00
Andrew Kaster
8e03f8cb4a LibWeb: Use window.navigation in NavigationHistoryEntry::index 2023-08-24 11:03:57 -06:00
Andrew Kaster
7f043e3083 LibWeb: Add window.navigation property 2023-08-24 11:03:57 -06:00
Andrew Kaster
0c2f758067 LibWeb: Implement the start of the Navigation API
This API is how JavaScript can manipulate the new Navigable concepts
directly. We are still missing most of the interesting algorithms on
Navigation that do the actual navigation steps, and call into the
currently WIP navigable AOs.
2023-08-24 11:03:57 -06:00
Andrew Kaster
51c2835044 LibWeb: Add NavigationCurrentEntryChangeEvent, fired when navigating
This event will be fired by Navigation when changing the current
NavigationHistoryEntry.
2023-08-24 11:03:57 -06:00
Andrew Kaster
3c1d4eab24 LibWeb: Add NavigationHistoryEntry, a wrapper around SessionHistoryEntry 2023-08-24 11:03:57 -06:00
Andrew Kaster
daa9c4a650 LibWeb: Add NavigationType to prep for Navigation API platform objects
This enum is used in many Navigation API classes, so stick it in its own
IDL file. However, we have no way to ask the BindingsGenerator to create
just an enum class that's not defined in an IDL file without an
 ``interface`` class at the top level, so implement the expected enum
 and stringification method manually.
2023-08-24 11:03:57 -06:00
Andrew Kaster
6856634ebc LibWeb: Add fields to SessionHistoryEntry required by Navigation API 2023-08-24 11:03:57 -06:00
Andrew Kaster
cf0ffc12cc BindingsGenerator: Handle nullable enum properties
Add some checks to the statement wrapping code to make sure we properly
handle the expected pattern of returning ``Optional<Enum>`` from
nullable enum properties.
2023-08-24 11:03:57 -06:00
Andrew Kaster
d3a8ee6e4b LibWeb: Remove unused SessionHistoryEntry::serialized_state
We never implemented this for History::pushState/popState, and now that
we're working on the Navigable changes, we don't need this legacy entry
with its legacy name.
2023-08-24 11:03:57 -06:00
Andrew Kaster
ca233b5cf4 LibWeb: Implement more of the shared history push/replace state steps
Add the seralization and URL validation steps, but skip the actual
navigation for now. This might cause more pages to throw exceptions
when trying to push state that contains objects that we don't know how
to serialize.
2023-08-24 11:03:57 -06:00