Commit graph

18699 commits

Author SHA1 Message Date
Itamar 7165dbce5c LibGfx: Fix affine transformations in TrueType composite glyphs
This fixes an issue where, when looping over the components of a
composite glyph, we used to mutate the affine transformation of the
glyph itself when computing the transformations of its components.

(AffineTransform::multiply() is non-const).
2022-09-24 17:06:29 +02:00
Liav A 13e9947b4b WindowServer: Fallback to safe mode-setting in case of mapping overflow
In case of possible framebuffer mapping overflow, just fallback to the
safe mode-setting of the DisplayConnector, because in that state we know
for sure that we can map a usable framebuffer (otherwise it is a bug in
the Kernel, and not WindowServer).
2022-09-24 15:38:56 +01:00
Liav A d5b97eb41e Kernel+Userland: Provide bytes count for a DisplayConnector framebuffer
This value will be used later on by WindowServer to reject resolutions
that will request a mapping that will overflow the hardware framebuffer
max length.
2022-09-24 15:38:56 +01:00
Liav A 50ed50752f LibEDID: Remove head index when retrieving an EDID from DisplayConnector
We simply don't need that field anymore, as it was used when one
FramebufferDevice could contain multiple framebuffers within it, each
for a connected screen head.
2022-09-24 15:36:19 +01:00
Andreas Kling c04b107e26 LibWeb: Treat replaced % sizes as 0 if containing block is indefinite 2022-09-24 14:41:18 +02:00
Andreas Kling 416fa7bd4f LibWeb: Bring flex basis calculation a little closer to spec
This ends up having a big impact on performance, as we now correctly
treat a used flex-basis of `content` as `max-content` which means
we can use cacheable intrinsic sizes for flex items in the majority
of cases.
2022-09-24 14:09:56 +02:00
Andreas Kling f0ac687823 LibWeb: Remove awkward BFC::compute_theoretical_height() function
This was used by FFC to estimate the height of flex items after
performing layout inside them.

Now that we have automatic_content_height(), we no longer need this
awkward API and we can fold it into BFC's own height calculation.
2022-09-24 13:53:23 +02:00
MacDue 4d7e4e5da8 LibWeb: Avoid overflow and OOB indexing in get_buffer_source_copy()
Previously, this would overflow when both length and offset were
zero, leading to an OOB index into es_array_buffer. This would lead to
a crash on a few MDN pages.
2022-09-24 13:49:15 +02:00
Andreas Kling ba065faa54 LibWeb: Remove unused capture in queue_a_microtask() 2022-09-24 13:48:38 +02:00
Andreas Kling a8e1599ae1 LibWeb: Use automatic_content_height() in flex item internal layouts 2022-09-24 13:47:58 +02:00
Andreas Kling 5656173e00 LibWeb: Use automatic_content_height() when computing intrinsic heights 2022-09-24 13:47:17 +02:00
Andreas Kling 62974160da LibWeb: Add FormattingContext::automatic_content_height()
This function should return the automatic height of the formatting
context's root box.

Until now, we've been relying on some magical handshakes between parent
and child context, when negotiating the height of child context root
boxes. This is a step towards something more reasonable.
2022-09-24 13:41:08 +02:00
Andreas Kling b52165c5d7 LibWeb+LibGfx: Move the blit image through 2D transfrom to Gfx::Painter
Even though this code is obnoxiously slow, it still belongs in LibGfx
and should not be hidden away in LibWeb's CanvasRenderingContext2D.
2022-09-24 13:00:53 +02:00
Andreas Kling 37ea6de772 LibWeb: Remove now-unnecessary JS::Handles in microtask capture lists 2022-09-24 12:23:29 +02:00
Andreas Kling 874e64d664 LibWeb: Make queue_an_element_task() use JS::SafeFunction 2022-09-24 12:23:29 +02:00
Andreas Kling 2ccb9bef49 LibWeb: Remove now-unnecessary JS::Handles in HTML task capture lists
JS::SafeFunction will protect anything captures for HTML tasks now.
2022-09-24 12:23:29 +02:00
Andreas Kling d505192014 LibWeb: Use JS::SafeFunction in the HTML task queues
This means that HTML tasks automatically protect anything in their
capture lists, and we no longer need to jump through hoops with
JS::Handle etc.
2022-09-24 12:23:29 +02:00
Andreas Kling 131c3f50de LibJS: Add JS::SafeFunction, like Function but protects captures from GC
SafeFunction automatically registers its closure memory area in a place
where the JS garbage collector can find it.

This means that you can capture JS::Value and arbitrary pointers into
the GC heap in closures, as long as you're using a SafeFunction, and the
GC will not zap those values!

There's probably some performance impact from this, and there's a lot of
things that could be nicer/smarter about it, but let's build something
that ensures safety first, and we can worry about performance later. :^)
2022-09-24 12:23:29 +02:00
MacDue f5052e5017 LibWeb: Don't trigger page_did_layout() on non-active documents
PageHost assumes page_did_layout() to be called when the layout
of the active document changes, however, it seems that sometimes
the layout can change on another document before the layout of
the active document has been calculated. This leads to a VERIFY()
being hit.

This commit now makes it so page_did_layout() is only called when
the document is the active document.

Fixes #15328
2022-09-24 00:38:10 +02:00
Luke Wilde 7b8a6b8e7a LibWeb: Set HTMLParser::m_scripting_enabled as according to the spec
This allows <noscript> elements to display their content as proper HTML
instead of raw text when scripting is disabled.
2022-09-23 22:25:09 +01:00
Luke Wilde dfe57543a4 LibWeb: Keep message alive in postMessage task callback lambda
Tasks can run at any time in the future and GC can run in the time
between postMessage and running the task, meaning the message can be
reaped if we don't keep a handle to it.

Fixes Google Syndication ads crashing 100% of the time on rpcs3.net
2022-09-23 17:23:55 +01:00
Liav A 36f2e85823 WindowServer: Fix mapping the correct framebuffer size
If we don't support double buffering for a certain type of hardware,
don't try to map with size calculated with (pitch * height * 2), as it
will result in trying to map more memory than is available in the
framebuffer memory range.
2022-09-23 14:04:00 +01:00
Linus Groh 76ace3629a LibWeb: Make Fetch::Infrastructure::Body::stream() const 2022-09-22 21:01:13 +01:00
Linus Groh c7c6d7d9e1 LibWeb: Make FileAPI::Blob::create() buffer/type overload infallible 2022-09-22 21:01:13 +01:00
Linus Groh 54a987ad45 LibWeb: Update extract_body() to use BodyInit 2022-09-22 21:01:13 +01:00
Linus Groh 8f5620b5d9 LibWeb: Add BodyInit union type 2022-09-22 21:01:13 +01:00
Linus Groh 571f4e3ebb LibWeb: Move extract_body() into Fetch 2022-09-22 21:01:13 +01:00
Linus Groh f98ce156c4 LibWeb: Remove ReadableStreamDummy in favor of ReadableStream 2022-09-22 21:01:13 +01:00
Linus Groh 87654f5b51 LibWeb: Start fleshing out the ReadableStream interface
This is so we can just assume it exists in Fetch APIs (while still
skipping functionality that relies on a full implementation, of
course).
2022-09-22 21:01:13 +01:00
Linus Groh 1ace80235b LibWeb: Move XMLHttpRequestBodyInit into Fetch
https://fetch.spec.whatwg.org/#typedefdef-xmlhttprequestbodyinit
2022-09-22 21:01:13 +01:00
thankyouverycool 1bba8589fe LibGUI: Hide unnecessary Scrollbars in ComboBox windows
And simplify rect calculations using content size.
2022-09-22 21:37:26 +02:00
thankyouverycool 7858f885fe LibGUI: Update ListView content size on relevant layout changes
Fixes incorrect content sizing when unnecessary scrollbars are hidden.
2022-09-22 21:37:26 +02:00
thankyouverycool 8b4bf96db3 LibGUI: Apply horizontal padding evenly for ListView items 2022-09-22 21:37:26 +02:00
thankyouverycool 930e5c27df ClockSettings: Increase max visible items for time zone ComboBox 2022-09-22 21:37:26 +02:00
thankyouverycool f86c5b1fa7 LibGUI: Allow setting max visible items for ComboBoxes
This will govern the maximum number of items ComboBox windows display
before scrolling content.
2022-09-22 21:37:26 +02:00
thankyouverycool aa8e7aba42 LibGUI: Don't show empty ComboBox windows 2022-09-22 21:37:26 +02:00
thankyouverycool a0de3860cc LibGUI: Make ListView item_count() public 2022-09-22 21:37:26 +02:00
thankyouverycool 04a9562601 LibGUI: Don't open windows for editable ComboBoxes when typing
Fixes inability to type custom values into ComboBox editors.

CaptureInput preempts typing while the ListView window is open.
For now, searching can still be done by manually opening the window.
2022-09-22 21:37:26 +02:00
thankyouverycool 7c2edd232d LibGUI: Reset Windows as visible for timer purposes on show()
Fixes scrolling timers failing to fire if a ComboBox window
had previously become occluded.
2022-09-22 21:37:26 +02:00
thankyouverycool db2a1d3620 LibGUI: Always activate ComboBox ListView selections on MouseUp
Fixes having to doubleclick selected items to activate them if
the selection index hasn't changed since last activation.
2022-09-22 21:37:26 +02:00
thankyouverycool 7ac30f53a0 LibGUI: Block ComboBox windows from using CommandPalette 2022-09-22 21:37:26 +02:00
Andrew Kaster 8f38367d46 LibCore: Only include Account.h on Serenity in EventLoop and System
Core::Acount is only used within ``#ifdef __serenity__`` blocks in these
files, so guard the inclusion of Account.h in the same way.

This fixes the Android build of these files.
2022-09-22 11:07:21 -04:00
Andreas Kling a52d346839 LibWeb: Take coordinate spaces into account when clearing past floats
We were forgetting to convert to and from BFC root relative coordinates
when calculating how much clearance was needed to get past floats.

This fixes the last remaining issue on Acid1, which is now perfect. :^)
2022-09-22 17:06:49 +02:00
Andreas Kling 5efd63741f LibWeb: Perform horizontal inline alignment based on available space
Previously, we were using the full containing block width as a reference
for text-align values "right" and "center". This didn't take intruding
floats into account.
2022-09-22 17:06:48 +02:00
Andreas Kling d43ef27761 LibWeb: Only include containing blocks in coordinate space translation
Layout box offset coordinates are always relative to their containing
block. Therefore, the functions that convert between coordinate spaces
should only visit containing blocks and apply their offsets, not *every*
box in the parent chain.

This fixes an issue where some floating boxes were unexpectedly far away
from their containing block.
2022-09-22 16:54:12 +02:00
Andreas Kling 54fb5af9ee LibWeb: Use entire margin box of floats when testing for intrusions 2022-09-22 16:54:12 +02:00
Andreas Kling 389f47f6fe LibWeb: Check both top and bottom of float position when looking for fit
We have to check that there's enough space at both the top and bottom of
the float's margin box, otherwise we risk overlapping existing content.
2022-09-22 16:54:12 +02:00
Timothy Flynn 82e730eba1 LibJS: Change default time display options to "always" for digital style
This is a normative change in the Intl.DurationFormat proposal. See:
https://github.com/tc39/proposal-intl-duration-format/commit/d28076b
2022-09-22 14:39:24 +01:00
Timothy Flynn 73fcaaeda4 Taskbar: Add a context menu to open clock settings from the clock widget 2022-09-22 11:46:53 +01:00
Sam Atkins c64a5ccf29 LibWeb: Avoid unnecessary copies in CSS Parser 2022-09-22 02:04:23 +02:00
Sam Atkins a211c06e99 LibWeb: Use llroundf() when rounding floats 2022-09-22 02:04:23 +02:00
Sam Atkins 188d9f1326 LibWeb: Resolve some trivial clang-tidy warnings in the CSS Parser
Issues resolved:
- Unnecessary `move()`s
- `else` after `return`
- `auto&` that could be `auto const&`

Why yes, I did just get clang-tidy set up. :^)
2022-09-22 02:04:23 +02:00
Linus Groh edfef8e2f5 Everywhere: Rename WrapperGenerator to BindingsGenerator
This code generator no longer creates JS wrappers for platform objects
in the old sense, instead they're JS objects internally themselves.
Most of what we generate now are prototypes - which can be seen as
bindings for the internal C++ methods implementing getters, setters, and
methods - as well as object constructors, i.e. bindings for the internal
create_with_global_object() method.

Also tweak the naming of various CMake glue code existing around this.
2022-09-21 23:06:08 +01:00
Linus Groh 4270ede7c4 LibWeb: Remove WRAPPER_HACK() macro
We no longer access Bindings::FooWrapper anywhere for a Foo platform
object, so these can be removed :^)
2022-09-21 21:12:24 +01:00
Linus Groh 6055b0e850 LibWeb: Remove no-op impl() methods from the WEB_PLATFORM_OBJECT macro
These are leftovers from when wrapper objects still had an internal
implementation, which is no longer the case.
2022-09-21 21:12:24 +01:00
Linus Groh 38b3ce8f03 LibIDL+LibWeb: Remove stale references to "wrapper class" concept
There are no wrappers for the platform object types anymore :^)
2022-09-21 21:12:24 +01:00
Sam Atkins fb2e1c4611 headless-browser: Install EventLoop and Font plugins so it doesn't crash 2022-09-21 20:42:36 +01:00
Sam Atkins 6b2a916069 LibWeb+WebContent: Move Serenity EventLoop and Font plugins into LibWeb
These are exactly what's wanted by headless-browser too, so this saves
us some duplication. LibWeb already links LibCore so it should not
cause any issues for Ladybird.
2022-09-21 20:42:36 +01:00
Sam Atkins 69dd158f91 LibJS: Create Console using a Realm instead of a VM 2022-09-21 20:03:49 +01:00
Sam Atkins 7a2da4cabf Browser+WebContent+LibJS: Support %c specifiers in Console.log()
...and the other Console methods.

This lets you apply styling to a log message or any other text that
passes through the Console `Formatter` operation.

We store the CSS on the ConsoleClient instead of passing it along with
the rest of the message, since I couldn't figure out a nice way of
doing that, as Formatter has to return JS::Values. This way isn't nice,
and has a risk of forgetting to clear the style and having it apply to
subsequent messages, but it works.

This is only supported in the Browser for now. REPL support would
require parsing the CSS and figuring out the relevant ANSI codes. We
also don't filter this styling at all, so you can `position: absolute`
and `transform: translate(...)` all you want, which is less than
ideal.
2022-09-21 20:03:49 +01:00
Sam Atkins a875713f2e Browser: Ignore whitespace-only input in the JS console 2022-09-21 20:03:49 +01:00
Sam Atkins a1f1369775 LibJS: Implement Console Formatter operation
This matches the recent changes to `Formatter` and `Logger`.

`%s`, `%d`, `%i`, and `%f` are all implemented. `%o`, `%O`, and `%c`
will come later.
2022-09-21 20:03:49 +01:00
Andreas Kling 010be491a9 LibWeb: Fix e-mail address mishap 2022-09-21 18:42:09 +02:00
davidot 4912b22e3b LibWeb+WebContent: Setup the js console client earlier
This allows us to print messages in inline scripts. Also add an example
of this in the welcome page to test this.
2022-09-21 17:34:32 +01:00
davidot 446a10a1ac LibJS: Implement normative change in String.prototype.substr
And add spec comments while we're in the neighborhood.
2022-09-21 16:59:58 +01:00
Timothy Flynn 60a6bae53d LibJS: Change digital default style from "narrow" to "short"
This is a normative change in the Intl.DurationFormat proposal. See:
https://github.com/tc39/proposal-intl-duration-format/commit/4c24876
2022-09-21 16:09:38 +01:00
Andreas Kling a5bb30d2ba LibWeb: Make Node.childNodes vend the same NodeList every time 2022-09-21 13:51:58 +02:00
Andreas Kling 4814e1bd65 Browser: Ignore title updates when history has no current item
The Browser::History class is oblivious to the state of the browsing
context's session history over on the LibWeb side. We need to hook a lot
more thing up here, but for now just ignore updates when there's no
current history item. This fixes a VERIFY() error on startup.
2022-09-21 13:06:17 +02:00
Daniel Bertalan 2b69af2dfe AK+LibJS: Handle NaN-boxing pointers on AArch64
JS::Value stores 48 bit pointers to separately allocated objects in its
payload. On x86-64, canonical addresses have their top 16 bits set to
the same value as bit 47, effectively meaning that the value has to be
sign-extended to get the pointer. AArch64, however, expects the topmost
bits to be all zeros.

This commit gates sign extension behind `#if ARCH(X86_64)`, and adds an
`#error` for unsupported architectures, so that we do not forget to
think about pointer handling when porting to a new architecture.

Fixes #15290
Fixes SerenityOS/ladybird#56
2022-09-21 11:55:57 +02:00
Andreas Kling 62fed2a31d LibWeb: Add id field to Environment
This is a unique string that identifies the environment. We just use a
simple incrementing number for now.
2022-09-21 11:51:18 +02:00
Andreas Kling 1f95943274 LibWeb: Remove confusing NOTE in WindowEnvironmentSettingsObject
HTML::Window has absorbed what was formerly known as WindowObject.
2022-09-21 11:51:18 +02:00
Andreas Kling 66f4e2b3b0 LibWeb: Add two more scheme helpers to the Fetch infrastructure 2022-09-21 11:51:18 +02:00
Andreas Kling b02402e116 LibWeb: Fix null dereference in ResourceClient::set_resource()
If resource_did_load() results in the ResourceClient being destroyed,
we can't dereference the weak ResourceClient right after.
2022-09-21 11:51:18 +02:00
Andreas Kling 68d0f30368 LibWeb: Abort the active document when navigating a browsing context 2022-09-21 11:51:18 +02:00
Andreas Kling 51d7ea7ece LibWeb: Make WESO allow cross-origin isolated APIs for now
Instead of panicking in a TODO(), let's just allow them and leave the
FIXME's in this function.
2022-09-21 11:51:18 +02:00
Andreas Kling 6c33dea6a6 LibWeb: Implement the "close" algorithm for browsing contexts
This is used by window.close() programmatically, but of course the user
can also decide to close a top-level browsing context at any time by
closing the tab.
2022-09-21 11:51:18 +02:00
Andreas Kling 0c7ab663c1 LibWeb: Flesh out most of the "unload" algorithm for documents
Yet another small steps towards spec-compliant document lifecycles.
2022-09-21 11:51:18 +02:00
Andreas Kling 797d28adca LibWeb: Save begin/end timestamps for load and DOMContentLoaded events 2022-09-21 11:51:18 +02:00
Andreas Kling d4fc1367f6 LibWeb: Save document load timing when creating browsing context 2022-09-21 11:51:17 +02:00
Andreas Kling 270de12d59 LibWeb: Save document load timing when updating document readiness 2022-09-21 11:51:17 +02:00
Andreas Kling 67559b1279 LibWeb: Add load/unload timing structures to Document
We don't populate these with information just yet, but we will soon!
2022-09-21 11:51:17 +02:00
Jan Metzger 931458c337 LibWeb: Update visibility when Node was invisible before 2022-09-21 10:47:41 +01:00
Orel d8474805e8 SystemMonitor: Save configuration of columns
Save the columns configuration from the last run in the respective
config file, and add a function to check whether a column should be
visible by default.
2022-09-21 10:14:40 +01:00
Andreas Kling 92deba7197 LibWeb: Implement Document/BrowsingContext hookup according to spec
We now implement the browsing context's "set active document" algorithm
from the spec, as well as the "discard" algorithm for browsing contexts
and documents.
2022-09-20 23:44:59 +02:00
Andreas Kling ab8432783e LibWeb: Implement aborting the HTML parser
This is roughly on-spec, although I had to invent a simple "aborted"
state for the tokenizer.
2022-09-20 23:44:59 +02:00
Olivier De Cannière d3601aedc5 Calendar: Add Settings button to configure the Calendar 2022-09-20 13:12:00 -04:00
Olivier De Cannière 6f69f4bb5e Calendar: Update month view on first_day_of_week setting change
Now when the user changes their preferred first day of the week in the
Calendar Settings, the Calendar application and applet views are update
accordingly without needing to restart them.
2022-09-20 13:12:00 -04:00
Olivier De Cannière a1d98b825d Calendar: Add setting to choose default view
This commit adds an entry to the Calendar Settings to allow the user to
select between the month and year views as the startup default.
2022-09-20 13:12:00 -04:00
Olivier De Cannière 0eceed4fd7 Calendar: Add a Calendar settings dialog for the first day of the week
This commit adds a new settings dialog for the Calendar application and
applet. It allows the user to specify their preferred first day of the
week.
2022-09-20 13:12:00 -04:00
Olivier De Cannière 9414525d75 Calendar: Support preferred first day of the week 2022-09-20 13:12:00 -04:00
Andreas Kling aa4dd6c1bc LibWeb: Implement Element.insertAdjacentHTML() from DOM Parsing
One edge case is left as a TODO() for now, since I'm not entirely sure
how to construct an element to those specifications.

With this patch, we can now run the Speedometer benchmark! :^)
2022-09-20 18:28:41 +02:00
Andreas Kling ac76df3d47 LibWeb: Implement Window.frameElement 2022-09-20 14:48:07 +02:00
Andreas Kling e4fd042041 LibWeb: Flesh out the default "quirks mode" style sheet
Import all the quirks mode rules from the HTML spec. There's more to
quirks mode, of course, but it's nice that we can just copy these.
2022-09-20 14:48:07 +02:00
Andreas Kling 77d947b8ad LibWeb: Initialize document referrer from Fetch Request if available 2022-09-20 14:48:07 +02:00
Andreas Kling 9683da4470 LibWeb: Add referrer accessors to Fetch Request 2022-09-20 14:48:07 +02:00
Ali Mohammad Pur 578d73943a LibC+LibRegex: Move central regex definitions into LibC/bits
This decouples LibRegex from the serenity LibC.
Fixes #15251.
2022-09-20 12:57:21 +01:00
Sam Atkins 120e5aeca4 LibCore: Actually tell people to stop using Core::File in new code
Otherwise, we keep getting new code merged that uses it, which requires
fixing later.
2022-09-20 07:48:45 -04:00
Sam Atkins f640921371 MasterWord: Port to Core::Stream 2022-09-20 07:48:45 -04:00
Sam Atkins 68032d2724 Profiler: Port to Core::Stream 2022-09-20 07:48:45 -04:00
Sam Atkins 183b054695 SoundPlayer: Port M3UParser to Core::Stream
Also make the path parameter a StringView, since that's what gets passed
in.
2022-09-20 07:48:45 -04:00
Sam Atkins 2dea636f33 Run: Use Core::Stream API for command history file 2022-09-20 07:48:45 -04:00
Sam Atkins aee52a458b PixelPaint: Remove unused Image::write_to_file() method
This seems to be a remnant from before FileSystemAccessClient was used.
2022-09-20 07:48:45 -04:00
Timothy Flynn a203e714ec LibGUI: Use fuzzy matching when searching for emoji by name
This allows the user to have slight typos in their search query.
2022-09-20 11:08:54 +01:00
Andreas Kling d4acdac317 LibWeb+WebContent+Browser: Plumb visibility state from GUI to web pages
OOPWV now reacts to show/hide events and informs LibWeb about the state
change. This makes visibilitychange events fire when switching tabs. :^)
2022-09-20 10:32:14 +02:00
Andreas Kling 5908873b45 LibGUI: Fire Show/Hide events when adding/removing widget from tree
This ensures that widgets always get an initial show event.
2022-09-20 10:32:13 +02:00
Andreas Kling 4ee5dfbe4b LibWeb: Flesh out a chunk of the HTML spec's frame navigation algorithms 2022-09-20 10:32:13 +02:00
Andreas Kling e5f6d36616 LibWeb: Keep more of the navigation parameters in Document 2022-09-20 10:32:13 +02:00
Andreas Kling 42b8656db3 LibWeb: Flesh out "document visibility" state a bit more
We can now "update the visibility state", which also causes
`visibilitychange` events to fire on the document.

This still needs GUI integration work at the BrowsingContext level.
2022-09-20 10:32:13 +02:00
Andreas Kling 5a500827b8 LibWeb: Move HistoryHandlingBehavior enum to its own header
This avoids a header cycle in a subsequent patch.
2022-09-20 10:32:12 +02:00
Andreas Kling 03375a3dc9 LibWeb: Implement more spec-compliant iframe/frame attribute processing
We're still missing the lazy loading attribute handling, and once we hit
the navigation step, we fall back to totally ad-hoc behavior instead of
going all the way with a Fetch Request.
2022-09-20 10:32:12 +02:00
Andreas Kling 0810e77d77 LibWeb: Set the document "completely loaded time" when appropriate 2022-09-20 10:32:12 +02:00
Andreas Kling 954da8fde5 LibWeb: Only create iframe nested context if iframe document has context
We had glossed over a condition in the spec that said we should only run
the nested context creation steps when the iframe's own containing
document has a browsing context.
2022-09-20 10:32:12 +02:00
Andreas Kling 8ead228202 LibWeb: Implement "browsing context group" concept from the HTML spec 2022-09-20 10:32:12 +02:00
Andreas Kling e36750d591 LibWeb: Remove unused Layout::Node::did_insert_into_layout_tree() 2022-09-20 10:32:12 +02:00
Andreas Kling 77628289c6 LibWeb: Consolidate code for resolving vertical box model metrics in BFC
We already had a helper for this, but compute_height() wasn't using it.
Tweak it so that compute_height() can use it, and remove the duplicated
code that's now redundant.
2022-09-20 10:32:12 +02:00
ne0ndrag0n b16704d4db GamesSettings: Always ensure last card back selected is saved 2022-09-20 07:59:13 +01:00
Brian Gianforcaro 42865b8975 LibCpp: Add .clang-format to disable clang-format for the LibCpp Tests
We don't format these files, as they might have been intentionally
formatted differently from the normal serenity style for testing.

So ignore them from our global style, so clang-format
doesn't pick them up by accident.
2022-09-19 15:52:37 -07:00
Sam Atkins ef507720f0 Applets/ResourceGraph: Port to Core::Stream 2022-09-18 18:57:28 -07:00
Sam Atkins 474a38bd3c Applets/Network: Stop marking methods virtual unnecessarily
None of these are overridden, and NetworkWidget is a final class.
2022-09-18 18:57:28 -07:00
Sam Atkins eacf017112 Applets/Network: Remove include_loopback parameter
This is always false, so we can do without it and simplify things a
little.
2022-09-18 18:57:28 -07:00
Sam Atkins c8bfb07b41 Applets/Network: Port to Core::Stream 2022-09-18 18:57:28 -07:00
Ben Wiederhake 078e4bde32 LibC: Fix misplaced #include in limits.h
posix1_lim.h only defines macros that start with _POSIX_*, and don't
mention anything that might be defined in limits.h. Likewise, limits.h
uses none of the _POSIX_* macros. Thus, it is okay to change the order
of imports.
2022-09-18 18:30:05 -07:00
Ben Wiederhake c214d31c5e Everywhere: Fix order of includes and #pragma once 2022-09-18 18:30:05 -07:00
Ben Wiederhake 929e46f360 WindowServer: Add missing includes
This remained undetected for a long time as HeaderCheck is disabled by
default. This commit makes the following file compile again:

    // file: compile_me.cpp
    #include <WindowServer/SystemEffects.h>
    // That's it, this was enough to cause a compilation error.
2022-09-18 13:27:24 -04:00
Ben Wiederhake a99cd09891 Libraries: Add missing includes, add namespace qualifiers
This remained undetected for a long time as HeaderCheck is disabled by
default. This commit makes the following file compile again:

    // file: compile_me.cpp
    #include <LibDNS/Question.h>
    // That's it, this was enough to cause a compilation error.

Likewise for most other files touched by this commit.
2022-09-18 13:27:24 -04:00
Ben Wiederhake 48d8aff436 LibJS: Add missing includes
This remained undetected for a long time as HeaderCheck is disabled by
default. This commit makes the following file compile again:

    // file: compile_me.cpp
    #include <LibJS/Runtime/StringPrototype.h>
    // That's it, this was enough to cause a compilation error.

Likewise for most other files touched by this commit.
2022-09-18 13:27:24 -04:00
Ben Wiederhake d073a31c21 LibWeb: Add missing includes
This remained undetected for a long time as HeaderCheck is disabled by
default. This commit makes the following file compile again:

    // file: compile_me.cpp
    #include <LibWeb/HTML/CrossOrigin/CrossOriginOpenerPolicy.h>
    // That's it, this was enough to cause a compilation error.

Likewise for most other files touched by this commit.
2022-09-18 13:27:24 -04:00
sin-ack e9d5d2f74b LibWeb: Remove the flex item size cache
This was overly permissive as the FIXME stated and was causing layout
issues.
2022-09-18 18:55:06 +02:00
Andreas Kling 97b5230413 LibWeb: Subtract border & padding when using flex line size as item size
The flex line cross size includes the margin boxes of items, so when
we're taking the flex line's cross size to use as an item cross size,
we have to subtract the margin, border padding from both sides.

Previous we only subtracted the cross margins, which led to oversized
items in some cases.
2022-09-18 18:34:42 +02:00
Andreas Kling 7bf3b40867 LibWeb: Remove bogus main space restriction in wrapping flex layouts 2022-09-18 18:34:42 +02:00
Timothy Flynn 887dac0929 LibJS: Handle NumberFormat's [[UseGrouping]] option for "true" / "false"
This is a normative change to the Intl NumberFormat V3 spec. See:
https://github.com/tc39/proposal-intl-numberformat-v3/commit/4751da5
2022-09-18 09:45:40 -04:00
Andreas Kling 0ca1b4b123 LibWeb: Don't replace existing Content-Type header in outgoing XHRs
This fixes an issue where Twitter was HTTP 400'ing some of our XHRs.
2022-09-18 12:53:06 +02:00
Andreas Kling 575e3bf37d LibWeb: Check document fully active status in "element cannot navigate"
This resolves a FIXME and brings us closer to spec.
2022-09-18 12:53:06 +02:00
Andreas Kling e6ef366859 LibWeb: Implement basic support for Document.all
The finer details are missing here, but the basic API is up.
2022-09-18 02:17:29 +02:00
Andreas Kling 3df9861814 LibWeb: Capture self as a WeakPtr in ResourceClient::set_resource()
It's not safe to capture `this` as a raw pointer here, since nothing
is guaranteed to keep the ResourceClient alive (even if the Resource
stays alive.)
2022-09-18 02:15:01 +02:00
Andreas Kling fa2dd4cbe3 LibWeb: Make Document vend the same HTMLCollections every time 2022-09-18 02:08:01 +02:00
Andreas Kling 1903dff365 LibWeb: Support getting and setting Attr.textContent 2022-09-18 02:08:01 +02:00
Andreas Kling 530675993b LibWeb: Rename Attribute to Attr
This name is not very good, but it's what the specification calls it.
2022-09-18 02:08:01 +02:00
Andreas Kling 3c3ae3a768 LibWeb: Only uppercase qualified names in HTML documents
This takes care of an old FIXME now that we can distinguish between HTML
and non-HTML documents.
2022-09-18 00:53:26 +02:00
Andreas Kling dc6e625680 LibWeb: Make ParentNode.children vend the same HTMLCollection every time
Instead of creating a new HTMLCollection every time you access
.children, we now follow the spec and vend the same object.

This was annoyingly difficult before, and trivial now that the DOM is
garbage-collected. :^)
2022-09-18 00:42:33 +02:00
Andreas Kling 6b3293a74b LibWeb: Support getElementsByTagName() properly in non-HTML documents 2022-09-18 00:39:42 +02:00
Andreas Kling bd0648a492 LibWeb: Simplify getElementsByTagName{,NS}() filters
Everything below the collection root is a descendant of the collection
root, so there's no need to check is_descendant_of() :^)
2022-09-18 00:37:24 +02:00
Andreas Kling e72896e35e LibWeb: Get default fonts via Platform::FontPlugin
Instead of asking Gfx::FontDatabase for the "default font" and the
"default fixed-width font", we now proxy those requests out via
the Platform::FontPlugin. This will allow Ladybird to use other default
fonts as fallback.
2022-09-17 21:27:32 +02:00
Sam Atkins ebc29842c8 LibWeb: Start implementing the IDL Overload Resolution Algorithm :^)
There are a *lot* of FIXME's here. :yakoverflow:
2022-09-17 21:27:17 +02:00
Sam Atkins 0d2d5ba02c LibIDL: Implement EffectiveOverloadSet
This requires a little explanation. The overload resolution algorithm,
where this is used, repeatedly has steps like this:

> Otherwise: if V is a platform object, and there is an entry in S that
> has one of the following types at position i of its type list,
>  - an interface type that V implements
>  - object
>  - a nullable version of any of the above types
>  - an annotated type whose inner type is one of the above types
>  - a union type, nullable union type, or annotated union type that has
>    one of the above types in its flattened member types
> then remove from S all other entries.

So, the API here tries to match that. We save the matching entry when
checking through them and then use that in `remove_all_other_entries()`.

Removing all those entries when all we actually care about is looking at
that one matching entry feels silly, but sticking to the spec is more
important while things are still half-implemented. :^)
2022-09-17 21:27:17 +02:00
Sam Atkins 8b4cc07a54 LibIDL+WrapperGenerator: Implement Type::is_distinguishable_from()
As part of this, I've moved a couple of methods for checking for
null/undefined from UnionType to Type, and filled in more of their
steps.

This now detects more, and so causes us to hit a `TODO()` which is too
big for me to go after right now, so I've replaced that assertion with
a log message.
2022-09-17 21:27:17 +02:00
Sam Atkins 7c8ef79898 LibIDL+WrapperGenerator: Make it easier to work with IDL::Type classes
Track the kind of Type it is, and use that to provide some convenient
`is_foo()` / `as_foo()` methods. While I was at it, made these all
classes instead of structs and made their data private.
2022-09-17 21:27:17 +02:00
Sam Atkins c4668053d1 LibIDL+WrapperGenerator: Move IDL code into a library
IDL function overload resolution requires knowing each IDL function's
parameters and their types at runtime. The simplest way to do that is
just to make the types the generator uses available to the runtime.

Parsing has moved to LibIDL, but code generation has not, since that is
very specific to WrapperGenerator.
2022-09-17 21:27:17 +02:00
Jelle Raaijmakers 6c87c98ed0 LibGL: Remove GL::present_context
No need for a static method if all it does is invoke the object method.
2022-09-17 19:38:30 +02:00
Andreas Kling 83c69fa62e LibWeb: Handle JavaScript source code with non-UTF-8 encoding
When fetching scripts in HTMLScriptElement's "prepare a script"
algorithm, we now re-encode the script sources to UTF-8.
2022-09-17 18:53:26 +02:00
Andreas Kling da451467b1 LibWeb: Implement basic "scroll" events at the document level 2022-09-17 18:53:26 +02:00
Andreas Kling 07c4bf03b5 LibWeb: Add "scripts to execute in order as soon as possible"
Previously, we had accidentally conflated this set with the
similar-but-distinct "scripts to execute as soon as possible".
2022-09-17 18:53:26 +02:00
Andreas Kling df7e64d103 LibWeb: Handle multiple class names in getElementsByClassName()
The input string is actually a space-separated list of class names,
not a single class name.
2022-09-17 18:53:26 +02:00
Andreas Kling 2371446952 LibWeb: Update layout in HTMLElement.offset{Top,Left}
We can't report layout-dependent metrics without first ensuring that
layout is up-to-date.
2022-09-17 18:53:26 +02:00
Andreas Kling 9e274d9501 LibWeb: Make Document.createElement() lowercase HTML local names
Bring createElement() a little bit closer to spec-compliance.
2022-09-17 18:53:26 +02:00
davidot 03c468fb7d LibJS: Parse date strings like "9/17/2022" 2022-09-17 18:53:14 +02:00
Jelle Raaijmakers f6dfd77268 LibGL: Prevent segfault due to texture destruction
Destruction of `GL::GLContext` resulted in the destruction of
`GPU::Driver` _before_ the destruction of the allocated textures, which
in turn point to `GPU::Image` objects. Since the destruction of
`GPU::Driver` unloads the shared library, we were trying to invoke
non-existing code.

Fix this by moving `m_driver` up in `GLContext` so that it's last in
line for destruction.
2022-09-17 09:21:52 +00:00
Julian Offenhäuser 77f5f7a6f4 LibPDF: Support parsing page tree nodes that are in object streams
conditionally_parse_page_tree_node used to assume that the xref table
contained a byte offset, even for compressed objects. It now uses the
common facilities for parsing objects, at the expense of some
performance.
2022-09-17 10:07:14 +01:00
Julian Offenhäuser 6225c03256 LibPDF: Rename argument for the latin character set enumeration macro
The previous name "V" collided with one of the entries.
2022-09-17 10:07:14 +01:00
Julian Offenhäuser 633e1632d0 LibPDF: Allow whitespace other than EOL after an object marker 2022-09-17 10:07:14 +01:00
Julian Offenhäuser 65e83bed53 LibPDF: Disallow parsing indirect values as operands
An operation like 0 0 0 RG would have been confused for [ 0, 0 0 R ] G
2022-09-17 10:07:14 +01:00
Julian Offenhäuser 04cb00dc9a LibPDF: Fix handling of differences array in custom encodings
When looking up differences in the specified encoding, we previously
didn't recognize a lot of characters, namely those that are referred to
by a string in the PDF itself, like "/germandbls".

We now create a mapping of those characters to the code points they are
referring to, and correctly look them up when needed.
2022-09-17 10:07:14 +01:00
Julian Offenhäuser 36828f1385 LibPDF: Don't expect glyph width arrays to contain integers
They might also contain floats, in which case we convert them to int
before use.
2022-09-17 10:07:14 +01:00
Julian Offenhäuser 97ed4106e5 LibPDF: Fix text positioning with operator TJ
As per spec, the positioning (or kerning) parameter of this operator
should translate the text matrix before the next showing of text.
Previously, this calculation was slightly wrong and also only applied
after the text was already shown.
2022-09-17 10:07:14 +01:00
Julian Offenhäuser 563d91b6c4 LibPDF: Implement loading compressed objects from object streams
Now, whenever the xref table points to a compressed object,
parse_object_with_index will look it up in the corresponding object
stream as if it were a regular object.

With this, our parser gains the bare minimum support for xref streams.
2022-09-17 10:07:14 +01:00
Julian Offenhäuser f9beff7b5e LibPDF: Initial work on parsing xref streams
Since PDF version 1.5, a document may omit the xref table in favor of
a new kind of xref stream object. This is used to reference so-called
"compressed" objects that are part of an object stream.

With this patch we are able to parse this new kind of xref object, but
we'll have to implement object streams to use them correctly.
2022-09-17 10:07:14 +01:00
Julian Offenhäuser 4887aacec7 LibPDF: Move document-specific parsing functionality into its own class
The Parser class is now a generic PDF object parser, of which the new
DocumentParser class derives. DocumentParser now takes over all
functions relating to linearization, pages, xref and trailer handling.

This allows the use of multiple parsers in the same document's
context, which will be needed in order to handle PDF object streams.
2022-09-17 10:07:14 +01:00
Julian Offenhäuser 9f4659cc63 LibPDF: Move consume and match helper functions to the Reader class 2022-09-17 10:07:14 +01:00
Ben Wiederhake 8de7a91571 LibCompress+Tests: Demonstrate and fix faulty metadata length
The test-case is heavily inspired by:
https://github.com/google/brotli/blob/master/tests/testdata/x.compressed.01
Or in words: A metadata meta-block containing `Y` (which should be
ignored), and then the actual data (a single `Z`). The bug used to skip
one metadata byte too few, and thus read garbage.
2022-09-17 04:10:11 +00:00
Ben Wiederhake fe48fed4fa LibWeb: Break inclusion cycle by removing unnecessary include 2022-09-17 04:00:54 +00:00
Ben Wiederhake e909231d78 LibWeb: Break inclusion cycle through forward-declaration 2022-09-17 04:00:54 +00:00
Ben Wiederhake 4cd382c621 LibJS: Break another inclusion cycle by removing unnecessary include 2022-09-17 04:00:54 +00:00
Ben Wiederhake 6a4e2efa65 LibJS: Break inclusion cycle by removing unnecessary include 2022-09-17 04:00:54 +00:00
Ben Wiederhake ff96747e17 LibPDF: Break inclusion cycle by removing unnecessary include 2022-09-17 04:00:54 +00:00
Ben Wiederhake 75673319ad LibDebug: Break inclusion cycle through many forward-declarations 2022-09-17 04:00:54 +00:00
Ben Wiederhake 7c5e30daaa Everywhere: Fix badly-formatted includes 2022-09-17 04:00:54 +00:00
Tommaso Peduzzi f547b9be7b PixelPaint: Scale layer and preserve aspect ratio
This patch adds the ability to scale a layer and
preserve the aspect ratio.
When the Shift key is pressed, the aspect ratio is preserved.
2022-09-16 22:53:07 +02:00
Tommaso Peduzzi 293ab2cdc9 PixelPaint: Add scaling function to move tool
This patch adds scaling function to the move tool.
When the cursor is over the lower right corner of the layer, it changes.
This is to signify that the layer can be scaled by dragging the mouse.

There is currently no preview of the scaling.
Doing a resize every time the mouse moves leads to unexpected behavior.
2022-09-16 22:53:07 +02:00
Tim Schumacher ef9b543426 LibC: Remove the LibM interface target 2022-09-16 16:09:19 +00:00
Tim Schumacher 1b25c38b8b Everywhere: Fully remove the separate LibM directory 2022-09-16 16:09:19 +00:00
Tim Schumacher 81d46fa100 LibM: Move the math standard library to LibC 2022-09-16 16:09:19 +00:00
Andrew Kaster eef989f9ed LibGPU: Don't use relative paths for libsoftgpu in Lagom environments
We can count on the dynamic loader for each platform, and the RPATH of
our build infrastrucuture, to load the lib up automagically.
2022-09-16 15:32:38 +02:00
Andrew Kaster 8ed5ed3ec0 LibGL: Make GL::create_context fallible
Propagate errors in places that are already set up to handle them, like
WebGLRenderingContext and the Tubes demo, and convert other callers
to using MUST.
2022-09-16 15:32:38 +02:00
Timothy Flynn 7e5080ea53 LibGUI: Load emoji icons for EmojiInputDialog through Gfx::Emoji
No difference when cold-loading the emoji icons, but for a warm load,
this provides a per-process cache of the loaded icons.
2022-09-16 15:20:59 +02:00
Timothy Flynn 98f99a9f7e LibGfx: Change Emoji::emoji_for_code_points to accept const code points
Span<u32 const> is the type used when converting a constant Vector<u32>
to a Span.
2022-09-16 15:20:59 +02:00
Timothy Flynn 35b74ebbfc LibGUI: Defer loading emoji icons until their first paint event
The EmojiInputDialog re-uses emoji buttons to help with performance as
filters are applied / removed. The downside of pre-creating the buttons
is that it currently takes upwards of 600ms (on my machine) to load all
emoji icons from disk at once. This will only become worse over time as
more emoji are added.

To alleviate this, defer loading the icons until they are needed for
painting (i.e. come into view).
2022-09-16 15:20:59 +02:00
Andreas Kling cd7262ee56 LibWeb+LibWebView+WebContent: Add Web::Platform::ImageCodecPlugin
This replaces the previous Web::ImageDecoding::Decoder interface.
While we're doing this, also move the SerenityOS implementation of this
interface from LibWebView to WebContent. That means we no longer have to
link with LibImageDecoderClient in applications that use a web view.
2022-09-16 15:15:50 +02:00
Andreas Kling 412b2313f3 LibWeb: Improve inline flow around floating boxes
This patch combines a number of techniques to make inline content flow
more correctly around floats:

- During inline layout, BFC now lets LineBuilder decide the Y coordinate
  when inserting a new float. LineBuilder has more information about the
  currently accumulated line, and can make better breaking decisions.

- When inserting a float on one side, and the top of the newly inserted
  float is below the bottommost float on the opposite side, we now reset
  the opposite side back to the start of that edge. This improves
  breaking behavior between opposite-side floats.

- After inserting a float during inline layout, we now recalculate the
  available space on the line, but don't adjust X offsets of already
  existing fragments. This is handled by update_last_line() anyway,
  so it was pointless busywork.

- When measuring whether a line can fit at a given Y coordinate, we now
  consider both the top and bottom Y values of the line. This fixes an
  issue where the bottom part of a line would bleed over other content
  (since we had only checked that the top Y coordinate of that line
  would fit.)

There are some pretty brain-dead algorithms in here that we need to make
smarter, but I didn't want to complicate this any further so I've left
FIXMEs about them instead.
2022-09-16 15:15:50 +02:00
Andreas Kling 54e7359243 LibWeb: Repaint the page immediately when using the mouse to select
Otherwise we'd repaint the next time our "caret blink" timer would fire
(or something else caused a repaint). This made selection feel sluggish.
2022-09-16 15:15:50 +02:00
Enver Balalic 11a44ffb69 LibGfx: Recurse TrueType composite glyphs until a simple glyph is found
This fixes a bug in ladybird where it was crashing while rendering
characters like ščćž in the Noto Sans Regular font.

That font renders those characters as a composite where the caret
has numberOfContours = -1. When using the rasterize_impl simple path
for that, it would negatively overflow the offsets.
2022-09-16 14:52:03 +02:00
MacDue 011439d3e3 LibWeb: Paint backdrop-filter effects!
This implements all the filters other than `saturate()`,
`hue-rotate()`, and `drop-shadow()`.

There are still a lot of FIXMEs to handle in the actual implementation
though, particularly around supporting transforms, but this handles
the most common use cases :^)
2022-09-16 10:50:48 +01:00
MacDue 60356c8dde LibGfx: Support getting a bitmap for a region of painter
This will be needed so we can apply filter effects to the backdrop
of an element in LibWeb.

This now also allows getting a crop of a bitmap in a different format
than the source bitmap. This is for if the painter's bitmap does not
have an alpha channel, but you want to ensure the cropped bitmap does.
2022-09-16 10:50:48 +01:00
MacDue 978a70ddcc LibGfx: Add BrightnessFilter, ContrastFilter, and OpacityFilter
These filters are based off the ones defined in:
https://drafts.fxtf.org/filter-effects-1/#supported-filter-functions
2022-09-16 10:50:48 +01:00
MacDue 8f225acf58 LibGfx: Allow applying all color filters with an amount
This amount can be handled in the filter's implementation or if
not it will default to mixing between the new and previous pixel.

This behaviour is used for implementing CSS filters that allow stuff
like grayscale(70%).
2022-09-16 10:50:48 +01:00
MacDue 7bc0c66290 LibWeb+LibGfx: Move premultiplied alpha mixing to color.mixed_with()
This will be needed for mixing filters in LibGfx (and may be
generally useful elsewhere).
2022-09-16 10:50:48 +01:00
MacDue ec4de1e07d LibWeb: Plumb style/computed values for backdrop-filter 2022-09-16 10:50:48 +01:00
MacDue d1b99282d8 LibWeb+Meta: Parse the backdrop-filter CSS property
Note: The parsing and style value completely ignores the SVG filters
part of the spec for now... That's a yak for another day :^)
2022-09-16 10:50:48 +01:00
MacDue 980c92e9b5 LibWeb: Add FilterValueListStyleValue
This style value holds a list of CSS filter function calls e.g.

blur(10px) invert() grayscale()

It will be used to implement backdrop-filter, but the same style value
can be used for the image filter property.

(The name is a little awkward but it's referenced to as
filter-value-list in the spec too).
2022-09-16 10:50:48 +01:00
MacDue 776538a6c4 LibWeb: Add operator== to CSS::Number
This will be needed for the .equals() function of the backdrop-filter
style value.
2022-09-16 10:50:48 +01:00
MacDue 84d9a226e6 LibWeb: Add NumberPercentage CSS type
This type is used quite a bit in CSS filters.
2022-09-16 10:50:48 +01:00
MacDue b219931dfc LibWeb: Pass values by reference in style value operator== functions 2022-09-16 10:50:48 +01:00
Tim Schumacher 88ff01bb17 LibC: Remove _aligned_malloc and _aligned_free
We now have a proper aligned allocation implementation, and the
toolchain patch to make Clang use the intermediary implementation
has already been removed in an earlier iteration.
2022-09-16 05:39:28 +00:00
Tim Schumacher 388dc9cc5f LibJS: Supress an unused bind when wrapping float atomic operations 2022-09-16 05:39:28 +00:00
Tim Schumacher 8763dbcccc Everywhere: Remove a bunch of dead write-only variables
LLVM 15 now warns (and thus errors) about this, and there is really no
point in keeping them.
2022-09-16 05:39:28 +00:00
Ben Wiederhake 79ec6ed03d Shell: Fix 'Command:' output for built-in 'time' command 2022-09-16 05:38:09 +00:00
Andreas Kling d1dac8695c LibWeb: Don't set initial font+color on both HTML and BODY elements
It's enough to set it on the HTML element. That way, it doesn't get
reset in content that sets its own font on HTML but not on BODY.
2022-09-15 16:16:56 +02:00
Andreas Kling 1dd4e2dc87 LibWeb: Cache lowercased names in SimpleSelector
When matching selectors in HTML documents, we know that all the elements
have lowercase local names already (the parser makes sure of this.)

Style sheets still need to remember the original name strings, in case
we want to match against non-HTML content like XML/SVG. To make the
common HTML case faster, we now cache a lowercase version of the name
with each type/class/id SimpleSelector.

This makes tag type checks O(1) instead of O(n).
2022-09-15 16:16:56 +02:00
Andreas Kling d9c64ee876 LibWeb: Hoist case sensitivity check out of loop in Element::has_class() 2022-09-15 16:16:56 +02:00
Ben Wiederhake 8deced39a8 LibWeb: Resolve cyclic declaration/definitions involving Length
This remained undetected for a long time as HeaderCheck is disabled by
default. This commit makes the following file compile again:

    // file: compile_me.cpp
    #include <LibWeb/CSS/GridTrackSize.h>
    // That's it, this was enough to cause a compilation error.
2022-09-15 14:45:38 +01:00
Lucas CHOLLET 53eb35caba Calculator: Change internal representation to support perfect division
The purpose of this patch is to support addition, subtraction,
multiplication and division without using conversion to double. To this
end, we use the BigFraction class of LibCrypto. With this solution, we
can store values without any losses and forward rounding as the last
step before displaying.
2022-09-15 14:08:21 +01:00
Lucas CHOLLET 4ab8ad2ed2 LibCrypto: Fix -0 and 0 non-equality
SignedBigInteger::operator==(const UnsignedBigInteger&) was rejecting
all negative value before testing for equality. It now accepts negative
zero and test for a value equality with the UnsignedBigInteger.
2022-09-15 14:08:21 +01:00
Lucas CHOLLET 6a937312b3 LibCrypto: Add BigFraction
This new abstraction allows the user to store rational numbers with
infinite precision.
2022-09-15 14:08:21 +01:00
Lucas CHOLLET d589898f5b LibCrypto: Add SignedBigInteger::negated_value()
Return the negated value of the current number.
2022-09-15 14:08:21 +01:00
Andreas Kling a60c5166c6 LibWeb: Don't ignore data: URLs in @font-face src
Since data: URLs don't have a path, we shouldn't be checking for a TTF
or WOFF extension.

Thanks Timon for pointing this out! :^)
2022-09-15 12:45:00 +02:00
Andreas Kling 4910cc1879 LibGfx: Cache vector fonts by family name
Instead of just keeping them in an unsorted Vector, which led to
increasingly noticeable O(n) lookups, we now cache a list of Typefaces
per family name.
2022-09-15 12:45:00 +02:00
sin-ack a192095594 LibCore: Rewrite Core::Stream::read_all_impl
The previous version relied on manually setting the amount of data to
read for the next chunk and was overall unclear. The new version uses
the Bytes API to vastly improve readability, and fixes a bug where
reading from files where a single read that wasn't of equal size to the
block size would cause the byte buffer to be incorrectly resized causing
corrupted output.
2022-09-15 12:01:16 +02:00
sin-ack d3979b0bbd LibCore: Add documentation to Stream functions + make parameter clearer
file_size was not very clear about what it was being used for, so I
switched it to say expected_file_size to make it clear that it's just a
heuristic.
2022-09-15 12:01:16 +02:00
Luke Wilde 6a4934a030 LibWeb: Implement document.domain getter
The document.domain setter is currently stubbed as that is a doozy to
implement, given how much restrictions there are in place to try and
prevent use of it and potential multi-process implications.

This was the only thing preventing us from being able to start
displaying ads delivered via Google Syndication.
2022-09-15 09:46:04 +02:00
Timothy Flynn 85e313077a LibJS: Do not invoke Cell::vm in constructors before Cell is constructed
In a subclass of Cell, we cannot use Cell::vm() before the base Cell
object itself is constructed. Use the Realm's VM instead.

This was caught by UBSAN with vptr sanitation enabled.
2022-09-15 09:45:13 +02:00
Timothy Flynn 3efe611dbf LibJS: Do not assume that IsArray means the object type is an Array
IsArray returns true if the object is an Array *or* if it is a
ProxyObject whose target is an Array. Therefore, we cannot downcast to
an Array based on IsArray.

Luckily, we don't actually need an Array here; SerializeJSONArray only
needs an Object.

This was caught by UBSAN with vptr sanitation enabled.
2022-09-15 09:45:13 +02:00
Timothy Flynn 98a6f962a0 LibJS: Use correct include + object class for Function{Object,Prototype}
Not causing any real issue, just noticed while debugging vptr sanitation
errors.
2022-09-15 09:45:13 +02:00
Andreas Kling 1c0fc75cb6 LibWeb: Fix bogus condition when checking CSS font file extensions
Thanks Idan for pointing this out! :^)
2022-09-15 01:20:35 +02:00
Andreas Kling 6d92c1d231 LibWeb: Be slightly better at @font-face rules with multiple sources
This patch improves @font-face loading when there are multiple src
values in two ways:

- Invalid/empty URLs are ignored
- Fonts with unsupported file extensions are ignored

This makes us load and display the emblem font on modern Reddit,
which is pretty neat! :^)
2022-09-14 21:46:34 +02:00
Andreas Kling c5a19a4d55 LibWeb: Allow CSS at-rules to have an empty prelude
I don't see any indication in the spec that an empty prelude should be
disallowed. This fixes rules like `@font-face{...}` (note the absence
of whitespace before the `{`.)
2022-09-14 21:37:19 +02:00
Andreas Kling f64c175960 LibWeb: Invalidate layout whenever a CSS font is loaded
It's not enough to invalidate only the style, we have to do a full
layout invalidation since new fonts might mean new metrics, etc.
2022-09-14 21:24:31 +02:00
Andreas Kling df49a6ae9b LibWeb: Schedule a layout update in Document::invalidate_layout()
Otherwise, nothing will repaint until someone else decides to trigger
an update.
2022-09-14 21:23:39 +02:00
Andreas Kling 463355d1eb LibWeb: Allow data: URLs with font/ MIME type in @font-face CSS rules 2022-09-14 21:14:16 +02:00
Andreas Kling 34025442ff LibWeb: Account for float's container offsets in BFC root auto height
When calculating the automatic height of a BFC root, we stretch it to
contain the bottommost margin edge of floating boxes.

Before this change, we assumed that floating boxes had coordinates
relative to the BFC root, when they're actually relative to the floating
box's containing block. This may or may not be the BFC root, so we have
to use margin_box_in_ancestor_coordinate_space() to apply offsets from
all boxes in the containing block chain (up to the BFC root).
2022-09-14 20:18:49 +02:00
Jelle Raaijmakers 8ff7c52cf4 LibSoftGPU: Return a const& texel in Image to prevent copying
On every texel access, some floating point instructions involved in
copying 4 floats popped up. Let `Image::texel() const` return a
`FloatVector4 const&` to prevent these operations.

This results in a ~7% FPS increase in GLQuake on my machine.
2022-09-14 17:17:36 +02:00
Jelle Raaijmakers e9d2f9a95e LibSoftGPU: Use memcpy instead of a loop to blit the color buffer
Looking at `Tubes` before and after this change, comparing the original
loop to the one using `memcpy`, including the time for `memcpy` itself,
resulted in ~15% fewer samples in profiles on my machine.
2022-09-14 17:17:19 +02:00
Jelle Raaijmakers bfb4e08612 LibGfx: Use memcpy instead of fast_u32_copy for blitting
In some artificial full screen blitting profiling, I've seen `memcpy`
take up about 4% fewer samples each time I measure. It seems like
`fast_u32_copy` is not as fast as it'd like to believe.
2022-09-14 17:17:19 +02:00
Andreas Kling 57ad99ef16 LibWeb: Don't show pointer (hand) cursor over non-linked a elements
This is already handled by the :link and :visited style.
2022-09-14 15:05:10 +02:00
Andreas Kling 35a9a2fbb2 LibWeb: Account for containing block padding when placing abspos boxes
Unlike the other positioning schemes, absolute positioning is relative
to the *padding* edge of the containing block.
2022-09-14 14:43:17 +02:00
Andreas Kling d27136fcb0 LibWeb: Replace most of our default UA stylesheet with spec rules
The HTML spec provides a set of suitable default CSS rules for our UA
stylesheet, so let's use those instead of inventing our own. :^)

Note that I had to replace "foo-block-start" properties with "foo-top"
since we don't support the block/inline direction based properties yet.
2022-09-14 14:43:17 +02:00
Andreas Kling 4b9c5635b3 LibWeb: Make :link selector behave according to spec
It should match any `a` or `area` element that has an `href` attribute,
not any element *inside* an enclosing linked element.
2022-09-14 14:43:17 +02:00
Andreas Kling f25203f245 LibWeb: Don't re-resolve "auto" flex item sizes after definitizing them
This is rather subtle and points to our architecture around definite
sizes not being exactly right, but...

At some points during flexbox layout, the spec tells us that the sizes
of certain flex items are considered definite from this point on.
We implement this by marking each item's associated UsedValues as
"has-definite-width/height".

However, this breaks code that tries to resolve computed "auto" sizes
by taking the corresponding size from the containing block. The end
result was that the 1st sizing pass in flexbox would find the right size
for an "auto" sized item, but the 2nd pass would override the correct
size with the containing block's content size in that axis instead.

To work around the issue, FFC now remembers when it "definitizes" an
item, and future attempts to resolve an "auto" computed size for that
value will bypass the computed-auto-is-resolved-against-containing-block
step of the algorithm. It's not perfect, and we'll need to think more
about how to really represent these intermediate states relating to
box sizes being definite..
2022-09-14 14:43:17 +02:00
Andreas Kling b8aa6a4453 LibWeb: Use PercentageOr<T>::contains_percentage() in CSS layout
By asking if the value *contains* a percentage rather than whether it
*is* one, we cover many more cases where e.g `width: calc(100% - 10px)`
should be "treated as auto" etc.
2022-09-14 14:43:17 +02:00
Andreas Kling c4050fe675 LibWeb: Treat unimplemented grid-track-size syntax as "auto" for now
Note that there's a FIXME just above the previous case. That applies to
this workaround as well.
2022-09-14 14:43:17 +02:00
Andreas Kling 55ad9591df LibWeb: Add a way to ask if a PercentageOr<T> value contains percentages
Values that contain percentages require special treatment in various
parts of layout. Previously we had no way of peeking into calc() values
to see if their expression contains one or more percentages. That's the
bulk of what we're adding here.
2022-09-14 14:43:17 +02:00
electrikmilk fdd202259d LibWeb: Add partial serialization for CSSFontFaceRule
This partially adds serialization code for
`CSSFontFaceRule::serialized()` to spec. This is only partially
implemented as some parts of the `@font-face` rule are not implemented
yet.
2022-09-14 10:50:33 +01:00
Brian Gianforcaro d0a1775369 Everywhere: Fix a variety of typos
Spelling fixes found by `codespell`.
2022-09-14 04:46:49 +00:00
Andreas Kling 63c727a4a3 LibWeb: Don't clip to containing block when painting abspos descendants 2022-09-14 00:09:49 +02:00
Andreas Kling f941b7aefe LibWeb: Create stacking context for flex/grid items with z-index != auto 2022-09-14 00:09:49 +02:00
Andreas Kling fb5879fdcc LibWeb: Don't include abspos children in containing block's auto width 2022-09-14 00:09:49 +02:00
martinfalisse df22f38feb LibWeb: Inform the parent context of the grid's size 2022-09-14 00:09:14 +02:00
martinfalisse 214329b81c LibWeb: Layout grid items after calculation
Now that the positions of each grid item have been calculated, and the
sizes of the individual rows and columns ascertained, can actually
layout the different items.
2022-09-14 00:09:14 +02:00
martinfalisse 58078c1f40 LibWeb: Calculate sizes of Auto grid tracks 2022-09-14 00:09:14 +02:00
martinfalisse f558fd93b7 LibWeb: Calculate sizes of FlexibleLength grid tracks 2022-09-14 00:09:14 +02:00
martinfalisse fbe703e2bd LibWeb: Follow spec for calculating intrinsic track sizes 2022-09-14 00:09:14 +02:00
martinfalisse b7d053421e LibWeb: Calculate sizes of known grid track sizes
Calculate the sizes of grid tracks for which there is a clear size
(length or percentage has been specified).
2022-09-14 00:09:14 +02:00