Commit graph

63485 commits

Author SHA1 Message Date
Timothy Flynn
35d8e7e63f AK: Add a public helper to count the decoded length of a Base64 string 2024-09-03 17:43:03 +02:00
Timothy Flynn
41e14e3fc3 AK: Add an option to the base64 encoder to omit padding
Will be used by an upcoming JS prototype
2024-09-03 17:43:03 +02:00
HolonProduction
94230acf28 LibWeb: Update Selection.collapse algorithm 2024-09-03 17:42:13 +02:00
Andreas Kling
8a6c8a1c27 LibWeb: Propagate text-decoration-* properties to anonymous wrappers
Fixes an issue where old prices were not displayed with strike-through
text on the PlayStation store. :^)
2024-09-03 17:41:05 +02:00
Aliaksandr Kalenik
415ea4ec0c LibWeb: Resolve "position: sticky" insets relative to scrollport
Some checks are pending
CI / Lagom (false, NO_FUZZ, macos-14, macOS, Clang) (push) Waiting to run
CI / Lagom (false, FUZZ, ubuntu-22.04, Linux, Clang) (push) Waiting to run
CI / Lagom (false, NO_FUZZ, ubuntu-22.04, Linux, GNU) (push) Waiting to run
CI / Lagom (true, NO_FUZZ, ubuntu-22.04, Linux, Clang) (push) Waiting to run
Package the js repl as a binary artifact / build-and-package (macos-14, macOS, macOS-universal2) (push) Waiting to run
Package the js repl as a binary artifact / build-and-package (ubuntu-22.04, Linux, Linux-x86_64) (push) Waiting to run
Run test262 and test-wasm / run_and_update_results (push) Waiting to run
Lint Code / lint (push) Waiting to run
Push notes / build (push) Waiting to run
Reading of https://drafts.csswg.org/css-position revealed I was wrong
assuming sticky insets need to be resolved relative to containing block.
2024-09-03 11:34:31 +02:00
Tim Ledbetter
dcbb073b3e LibWeb: Relayout document when SVG image is successfully loaded 2024-09-03 10:30:22 +01:00
Colin Reeder
45e4ab69d6 LibWeb: Add background color to input fields 2024-09-03 10:16:13 +01:00
Sam Atkins
da171c3230 Inspector: Add a basic style sheet inspector
Choosing options from the `<select>` will load and display that style
sheet's source text, with some checks to make sure that the text that
just loaded is the one we currently want.

The UI is a little goofy when scrolling, as it uses `position: sticky`
which we don't implement yet. But that's just more motivation to
implement it! :^)
2024-09-03 10:12:07 +01:00
Sam Atkins
49b2eb5f51 LibWeb: Add Document::get_style_sheet_source()
This returns the source text of the specified style sheet. StyleComputer
now exposes user agent style sheets so that these can also be requested.
2024-09-03 10:12:07 +01:00
Sam Atkins
51a426cc05 LibWeb: Add method for listing all style sheets on a page
This will be used by the inspector, for showing style sheet contents.

Identifying a specific style sheet is a bit tricky. Depending on where
it came from, a style sheet may have a URL, it might be associated with
a DOM element, both, or neither. This varied information is wrapped in
a new StyleSheetIdentifier struct.
2024-09-03 10:12:07 +01:00
Sam Atkins
dd3b011f15 LibWeb: Keep track of each CSSStyleSheet's CSSImportRules
This will be used to gather up a list of all loaded style sheets for the
inspector.
2024-09-03 10:12:07 +01:00
Sam Atkins
b00137df38 LibWeb/CSS: Store the style sheet's source text on the CSSStyleSheet
This is to enable the inspector to show this source.

There's a fairly hefty FIXME here because duplicating the source text is
a significant waste of memory. But I don't want to get too sidetracked.
2024-09-03 10:12:07 +01:00
Sam Atkins
8cbc211616 Meta: Make embed_as_string_view.py produce Strings instead
This is only used for CSS style sheets. One case wants it as a String,
and the others don't care, but will in future also want to have the
source as a String.
2024-09-03 10:12:07 +01:00
Sam Atkins
fd49562f50 LibWeb: Add helper for accessing Inspector's PageClient
This is a bit easier to understand.
2024-09-03 10:12:07 +01:00
Sam Atkins
240b58e90f LibWeb/CSS: Set @import as the owner rule of their loaded style sheet 2024-09-03 10:12:07 +01:00
Sam Atkins
4e18fce3a5 LibWeb: Set the location URL for @import-ed/<link>-ed style sheets
The spec text had changed for the value of `<link>`'s location, so I've
updated that.
2024-09-03 10:12:07 +01:00
Sam Atkins
c29f4f69ef LibWeb: Rename Document::for_each_css_style_sheet for clarity
This only iterates style sheets that are in use, so make this clear by
renaming it to `for_each_active_css_style_sheet()`.
2024-09-03 10:12:07 +01:00
Sam Atkins
421fb6309f UI/Qt: Assign dropdown handler for select in WebContentView, not Tab
This makes `<select>` elements also work outside of Tab content, for
example in the Inspector.

Co-authored-by: Tim Flynn <trflynn89@serenityos.org>
2024-09-03 10:12:07 +01:00
Sam Atkins
ced7b6de5e Inspector: Remove border-radius for tab areas
This wasn't visible, until I tried adding a top toolbar to a tab area,
which made it look silly.
2024-09-03 10:12:07 +01:00
Olekoop
873e576da2 LibGfx: Use a diffrent way for finding libjxl on Android
When trying to use pkgconfig for finding libjxl, the build fails
trying to link the cross-compiler's libc++.
Using this way libjxl also requires hwy library.

Findlibjxl.cmake was taken from SDL_image and altered to include its license.
2024-09-03 00:17:49 -06:00
Olekoop
a7a136f30a LibGfx: Use Android functions when compiling for Android in TypefaceSkia 2024-09-03 00:17:49 -06:00
Olekoop
bf84a681a5 Android: Use LibWebView for command line flags
On Android there's really no real way to provide command line flags.
We are using a dummy Main::Argument that only contains "ladybird"
as a name of the program.
The strings of Main::Argument cannot be empty, otherwise the program
throws an error. However the argc and argv can be set to 0 and nullptr
2024-09-03 00:17:49 -06:00
Olekoop
7cee53fad6 Android: Write prototypes to satisfy compiler 2024-09-03 00:17:49 -06:00
Olekoop
8fe2c9e43d LibAudio: Override onAudioReady in PlaybackStreamOboe 2024-09-03 00:17:49 -06:00
Olekoop
4e6e23c242 LibAudio: Replace Duration with AK::Duration in PlaybackStreamOboe
AK::Duration isn't exported into global namespace since commit bf600c8
It basically does the same job as commit 6772d44
2024-09-03 00:17:49 -06:00
sideshowbarker
1975640e31 LibWeb: Make “create an event” set the event’s isTrusted to true
This change ensures that when then the code corresponding to the “create
an event” operation at https://dom.spec.whatwg.org/#concept-event-create
is called, the event’s isTrusted is set to true — as the spec requires.

That causes the failures for the following WPT tests to pass:

- https://wpt.fyi/results/html/semantics/forms/the-input-element/checkbox.html?run_id=5080423051034624
- https://wpt.fyi/results/html/semantics/interactive-elements/the-dialog-element/dialog-close.html?run_id=5080423051034624

…and there are likely a number of similar WPT tests that hit this same
code path which this commit will cause to be changed to passes.

Otherwise, without this change, the “create event” implementation
doesn’t conform to the spec requirements – nor behave interoperably with
other existing engines — and those WPT test would continue to fail.

This change also ensures that isTrusted continues to be set to false for
synthetic events.
2024-09-03 00:14:31 -06:00
Tim Ledbetter
5800b7e884 LibWeb: Invalidate the display list when calling set_needs_display()
Some checks are pending
CI / Lagom (false, FUZZ, ubuntu-22.04, Linux, Clang) (push) Waiting to run
CI / Lagom (false, NO_FUZZ, macos-14, macOS, Clang) (push) Waiting to run
CI / Lagom (false, NO_FUZZ, ubuntu-22.04, Linux, GNU) (push) Waiting to run
CI / Lagom (true, NO_FUZZ, ubuntu-22.04, Linux, Clang) (push) Waiting to run
Package the js repl as a binary artifact / build-and-package (macos-14, macOS, macOS-universal2) (push) Waiting to run
Package the js repl as a binary artifact / build-and-package (ubuntu-22.04, Linux, Linux-x86_64) (push) Waiting to run
Run test262 and test-wasm / run_and_update_results (push) Waiting to run
Lint Code / lint (push) Waiting to run
Push notes / build (push) Waiting to run
Calls to `Document::set_needs_display()` and
`Paintable::set_needs_display()` now invalidate the display list by
default. This behavior can be changed by passing
`InvalidateDisplayList::No` to the function where invalidating the
display list is not necessary.
2024-09-02 20:12:08 +02:00
BenJilks
46649fbe1b LibWeb: Add support for flex-wrap: wrap-reverse
Reverse the order of flex lines, when the `flex-wrap` property is set to
`wrap-reverse`. This will also swap the cross-start and cross-end
directions.
2024-09-02 17:42:11 +02:00
BenJilks
e2c1fe7255 LibWeb: Only reverse each line of a reverse flex-direction
When a flex container with a reverse `flex-direction` is wrapped. Only
each line should be reversed, not all items.
2024-09-02 17:42:11 +02:00
Andreas Kling
0f9444fa06 LibJS: Fix mix-up when re-exporting an imported symbol with a new name
This makes https://cling.com/ load, and more of the animated elements
on https://shopify.com/ start appearing.
2024-09-02 17:14:21 +02:00
Aliaksandr Kalenik
427e6cec7b LibWeb: Use border box to position sticky elements
Fixes https://github.com/LadybirdBrowser/ladybird/issues/1245
2024-09-02 15:23:04 +02:00
Andreas Kling
2e06d26ddb LibJS: Remember arrow function parsing failures by offset
We don't need to remember these by (line, column, offset). Just the
offset should be enough.
2024-09-02 15:22:51 +02:00
Andreas Kling
d5a0bb9159 LibJS: Remove unused field Token::m_filename 2024-09-02 15:22:51 +02:00
Andreas Kling
93a4d7395f LibJS: Make JS lexer handle 2 and 3 character tokens faster
By checking the lengths and then looking directly at the bytes, the
generated code becomes a lot nicer.

This gives a 1.23x speedup when parsing the JS from x.com
2024-09-02 15:22:51 +02:00
Jamie Mansfield
3440d2b843 LibWeb: Implement AbstractWorker
This effectively implements Worker.onerror, and in future
SharedWorker.onerror.
2024-09-02 13:10:44 +02:00
Aliaksandr Kalenik
20f68106a7 LibWeb: Fix getBoundingClientRect() for elements with "position: sticky"
Use offset from ScrollFrame which is an actual value a box is shifted by
while painting.

Also change `update_paint_and_hit_testing_properties_if_needed()` to
refresh scroll frames state, because `getBoundingClientRect()` now
depends on them.

Fixes wrong file tree sidebar location and excessive layout
invalidations caused by some miscalculation on JS-side when wrong
bounding client rect is provided on Github PR pages like
https://github.com/LadybirdBrowser/ladybird/pull/1232/files
2024-09-02 13:10:22 +02:00
Khaled Lakehal
d1bea9c2a4 LibWeb: Add scope attribute to HTMLTableCellElement 2024-09-02 13:09:41 +02:00
Sam Atkins
9f9ec45a31 Tests/LibWeb: Correct typo in "overflow: visible"
The test happened to pass anyway because `visible` is the default value.
2024-09-02 13:09:22 +02:00
sideshowbarker
55aad12fe3 Documentation: Explain how to use the rebaseline-libweb-test script
Some checks are pending
CI / Lagom (false, FUZZ, ubuntu-22.04, Linux, Clang) (push) Waiting to run
CI / Lagom (false, NO_FUZZ, macos-14, macOS, Clang) (push) Waiting to run
CI / Lagom (false, NO_FUZZ, ubuntu-22.04, Linux, GNU) (push) Waiting to run
CI / Lagom (true, NO_FUZZ, ubuntu-22.04, Linux, Clang) (push) Waiting to run
Package the js repl as a binary artifact / build-and-package (macos-14, macOS, macOS-universal2) (push) Waiting to run
Package the js repl as a binary artifact / build-and-package (ubuntu-22.04, Linux, Linux-x86_64) (push) Waiting to run
Run test262 and test-wasm / run_and_update_results (push) Waiting to run
Lint Code / lint (push) Waiting to run
Push notes / build (push) Waiting to run
This change adds documentation on using the rebaseline-libweb-test
script to regenerate the expectations file for a LibWeb/Text/input test.
2024-09-01 14:15:37 +02:00
Aliaksandr Kalenik
59f2b4fefc LibWeb: Account for fixed position in nearest scrollable ancestor lookup
Scroll offset of body does not affect position of fixed elements, so
nearest scrollable lookup should early return from ancestor scrollable
lookup loop once "position: fixed" box is encountered.

Fixes regression introduced in 866608532a
2024-09-01 12:42:36 +02:00
Timothy Flynn
7fff00972d LibWebView: Auto-select subtext when editing DOM nodes/attributes
Some checks are pending
CI / Lagom (false, FUZZ, ubuntu-22.04, Linux, Clang) (push) Waiting to run
CI / Lagom (false, NO_FUZZ, macos-14, macOS, Clang) (push) Waiting to run
CI / Lagom (false, NO_FUZZ, ubuntu-22.04, Linux, GNU) (push) Waiting to run
CI / Lagom (true, NO_FUZZ, ubuntu-22.04, Linux, Clang) (push) Waiting to run
Package the js repl as a binary artifact / build-and-package (macos-14, macOS, macOS-universal2) (push) Waiting to run
Package the js repl as a binary artifact / build-and-package (ubuntu-22.04, Linux, Linux-x86_64) (push) Waiting to run
Run test262 and test-wasm / run_and_update_results (push) Waiting to run
Lint Code / lint (push) Waiting to run
Push notes / build (push) Waiting to run
This adds the following behavior for the DOM node/attribute editor in
the Inspector:

* If the user double clicks on an attribute name, the name is selected.
* If the user double clicks on an attribute value, the value text (sans
  the surrounding quotes) is selected.
* Otherwise, double clicks select the entire text range.
2024-08-31 15:51:08 +02:00
Timothy Flynn
8fb2cc2be1 LibWeb: Do not assume the shadow root has a host when updating selection
For example, if the shadow root was detached from the document in some
manner, its host will be null.
2024-08-31 15:51:08 +02:00
Timothy Flynn
59fe7ca830 LibWeb: Convert internal test event coordinates to device pixels
This allows for coming up with coordinates that work on macOS with a DPR
of 2 more easily.
2024-08-31 15:51:08 +02:00
Timothy Flynn
96ad310643 LibWeb: Remove range-count filter from selection change handlers
The implementation of setBaseAndExtent will create a new range.
2024-08-31 15:51:08 +02:00
Timothy Flynn
fd289deb44 LibWeb: Update the document cursor position when the selection changes
Otherwise, it looks a bit awkward where the cursor position does not
update while the selection is elsewhere.

Note that this requires passing along the raw selection positions from
`set the selection range` to the elements. Otherwise, consider what will
happen if we set the selection start and end to the same value. By going
through the API accessor, we hit the case where the start and end are
the same value, and return the document cursor position. This would mean
the cursor position would not be updated.

The test changes here more closely match what Firefox produces now. It
is not a 100% match; the `select event fired` test case isn't right. The
problem is the event fires for the input element, but we most recently
focused the textarea element. Thus, when we retrieve the selection from
the input element, we return the document's cursor position, which is
actually in the textarea element. The fix will ultimately be to fully
implement the following:

https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#concept-textarea/input-cursor

That is, each input / textarea element should separately track its own
text cursor position.
2024-08-31 15:51:08 +02:00
Timothy Flynn
430c9d3e3f LibWeb: Use a Unicode text segmenter to select words on double-click
We currently use a naive word segmentation, looking for ASCII spaces to
mark a word boundary. Use LibUnicode's complete implementation instead.
2024-08-31 15:51:08 +02:00
BenJilks
11e7d72686 LibWeb: Layout text chunks based on their Unicode direction
Some checks are pending
CI / Lagom (false, FUZZ, ubuntu-22.04, Linux, Clang) (push) Waiting to run
CI / Lagom (false, NO_FUZZ, macos-14, macOS, Clang) (push) Waiting to run
CI / Lagom (false, NO_FUZZ, ubuntu-22.04, Linux, GNU) (push) Waiting to run
CI / Lagom (true, NO_FUZZ, ubuntu-22.04, Linux, Clang) (push) Waiting to run
Package the js repl as a binary artifact / build-and-package (macos-14, macOS, macOS-universal2) (push) Waiting to run
Package the js repl as a binary artifact / build-and-package (ubuntu-22.04, Linux, Linux-x86_64) (push) Waiting to run
Run test262 and test-wasm / run_and_update_results (push) Waiting to run
Lint Code / lint (push) Waiting to run
Push notes / build (push) Waiting to run
Append text chunks to either the start or end of the text fragment,
depending on the text direction. The direction is determined by what
script its code points are from.
2024-08-31 11:49:47 +02:00
Tim Ledbetter
2f5b070716 LibWeb: Implement setRangeText for input and textarea elements
This method replaces range of text in its respective element with a new
string
2024-08-31 07:47:54 +02:00
Tim Ledbetter
206262cd55 LibWeb: Subclass FormAssociatedElement text selection methods
These are only relevant to HTMLInputElement and HTMLTextArea elements.
2024-08-31 07:47:54 +02:00
Aliaksandr Kalenik
7b2042571b LibWeb: Implement missing step in GFC fr size calculation
Implements:
"If the product of the hypothetical fr size and a flexible track’s flex
factor is less than the track’s base size, restart this algorithm
treating all such tracks as inflexible."

Fixes https://github.com/LadybirdBrowser/ladybird/issues/1211
2024-08-31 07:47:20 +02:00