Commit graph

14720 commits

Author SHA1 Message Date
Sam Atkins
7535398dbf FileOperation: Port to Core::Stream 2022-03-13 22:38:48 +01:00
Sam Atkins
1925bde3c0 FileManager: Use Core::Stream for FileOperationProgressWidget 2022-03-13 22:38:48 +01:00
Sam Atkins
dc5a318aa9 FileManager: Use TRY in run_file_operation()
The exception is `execvp()` since that has no Core::System wrapper yet.
2022-03-13 22:38:48 +01:00
Lenny Maiorani
6a23dfbc92 LibGfx: Use common class template for PBM/PGM/PPM image loaders
PBM, PGM, and PPM image loaders are mostly common. The only difference
is how the data is read and the associated magic numbers. The magic
numbers are already made common using the loading contexts. Now make
the implementations common via a class template which accepts the
context to disambiguate.
2022-03-13 22:35:20 +01:00
Lenny Maiorani
786b02730c LibGfx: Commonize P[BGP]M file loading contexts
Much of the code in PBM, PGM, and PPM image loaders is common. The
contexts are nearly identical. Instead of writing multiple contexts,
write 1 with a template argument to pass in the details of the given
format.
2022-03-13 22:35:20 +01:00
Lenny Maiorani
5c21f963ff Libraries: Use default constructors/destructors in LibX86
https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#cother-other-default-operation-rules

"The compiler is more likely to get the default semantics right and
you cannot implement these functions better than the compiler."
2022-03-13 22:34:38 +01:00
Lenny Maiorani
1a59cffb00 Libraries: Use default constructors/destructors in LibWebSocket
https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#cother-other-default-operation-rules

"The compiler is more likely to get the default semantics right and
you cannot implement these functions better than the compiler."
2022-03-13 22:34:38 +01:00
Lenny Maiorani
8b334248e4 Libraries: Use default constructors/destructors in LibVT
https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#cother-other-default-operation-rules

"The compiler is more likely to get the default semantics right and
you cannot implement these functions better than the compiler."
2022-03-13 22:34:38 +01:00
Lenny Maiorani
a53c00f1df Libraries: Use default constructors/destructors in LibThreading
https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#cother-other-default-operation-rules

"The compiler is more likely to get the default semantics right and
you cannot implement these functions better than the compiler."
2022-03-13 22:34:38 +01:00
Lenny Maiorani
7cc6ba16be Libraries: Use default constructors/destructors in LibSyntax
https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#cother-other-default-operation-rules

"The compiler is more likely to get the default semantics right and
you cannot implement these functions better than the compiler."
2022-03-13 22:34:38 +01:00
Lenny Maiorani
7abb782206 Libraries: Use default constructors/destructors in LibSQL
https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#cother-other-default-operation-rules

"The compiler is more likely to get the default semantics right and
you cannot implement these functions better than the compiler."
2022-03-13 22:34:38 +01:00
Lenny Maiorani
dd08e84664 Libraries: Use default constructors/destructors in LibMarkdown
https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#cother-other-default-operation-rules

"The compiler is more likely to get the default semantics right and
you cannot implement these functions better than the compiler."
2022-03-13 22:34:38 +01:00
Lenny Maiorani
103ce2f9e9 Libraries: Use default constructors/destructors in LibLine
https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#cother-other-default-operation-rules

"The compiler is more likely to get the default semantics right and
you cannot implement these functions better than the compiler."
2022-03-13 22:34:38 +01:00
Lenny Maiorani
dcdc62323d Libraries: Use default constructors/destructors in LibIPC
https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#cother-other-default-operation-rules

"The compiler is more likely to get the default semantics right and
you cannot implement these functions better than the compiler."
2022-03-13 22:34:38 +01:00
Lenny Maiorani
79aa49d04f Libraries: Use default constructors/destructors in LibHTTP
https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#cother-other-default-operation-rules

"The compiler is more likely to get the default semantics right and
you cannot implement these functions better than the compiler."
2022-03-13 22:34:38 +01:00
Lenny Maiorani
97fcbdd199 Libraries: Use default constructors/destructors in LibGemini
https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#cother-other-default-operation-rules

"The compiler is more likely to get the default semantics right and
you cannot implement these functions better than the compiler."
2022-03-13 22:34:38 +01:00
Andreas Kling
c1e6fc67a1 LibWeb: Add a Vector::ensure_capacity() in collect_matching_rules()
Avoid some incremental Vector growth by pre-allocating enough capacity
to cover the case where every single selector matches an element.
2022-03-13 19:55:08 +01:00
Andreas Kling
afc5fade05 LibWeb: Add some fast_is<T> helpers for hot classes on GitHub :^) 2022-03-13 18:09:43 +01:00
Andreas Kling
39389b5704 LibWeb: Don't make deep copy of custom properties for every element
Previously we were making a copy of the full set of custom properties
that applied to a DOM element. This was very costly and dominated the
profile when mousing around on GitHub.

Note that this may break custom properties on pseudo elements a little
bit, and that's something we'll have to look into.
2022-03-13 18:09:43 +01:00
Andreas Kling
f88d65d9cb LibWeb: Cache CSS::Selector's pseudo element at construction time
Computing the pseudo element of a CSS::Selector was very hot when
mousing around on GitHub in Browser. A profile had it at ~10%.
After these changes, it's totally gone from the profile. :^)
2022-03-13 18:09:43 +01:00
Andreas Kling
f5c2e87965 LibWeb: Sort stacking context tree once, after fully building it
Instead of calling quick_sort() every time a StackingContext child
is added to a parent, we now do a single pass of sorting work after the
full StackingContext tree has been built.

Before this change, the quick_sort() was ~13.5% of the profile while
hovering links on GitHub in the Browser. After the change, it's down to
~0.6%. Pretty good! :^)
2022-03-13 18:09:43 +01:00
Timothy Flynn
0dfb9714fe LibCore: Use altzone for the current time zone offset during DST
Also use the daylight global to determine the current time zone name,
i.e. tzname[0] is standard time, tzname[1] is daylight savings time.

Note that altzone isn't required to be defined on all systems, so we
have to #ifdef to check if it exists in order for Lagom to build.
2022-03-13 17:50:49 +01:00
Timothy Flynn
7fceb909a5 LibC: Use altzone for the current time zone offset during DST 2022-03-13 17:50:49 +01:00
Ali Mohammad Pur
2000251333 LibJS: Implement bytecode generation for WithStatement 2022-03-13 17:50:21 +01:00
Ali Mohammad Pur
57386ca839 LibJS: Initialize 'var' bindings to undefined on declaration
This is what CreateGlobalVarBinding does, so do the same thing in BC.
2022-03-13 17:50:21 +01:00
Ali Mohammad Pur
ba9c4959d6 LibJS: Leave the unwind context on break/continue/return in bytecode
Otherwise we'd keep the old unwind context, and end up never invoking
the other handlers up the stack.
2022-03-13 17:50:21 +01:00
Ali Mohammad Pur
41184c960d LibJS: Propagate abrupt completions in Bytecode::Op::Call
This was not handling the nullary call case correctly, remove the whole
nullary check as there's nothing particularly expensive in the catch-all
case anyway.
2022-03-13 17:50:21 +01:00
mjz19910
fd8a56cdde LibJS: Add some tests for TypedArray.prototype.set 2022-03-13 16:49:25 +01:00
Andreas Kling
13c253d2ee LibWeb: Fix serialization of selectors with universal subject (*)
For seletors whose subject is unversal (i.e selectors that end in "*")
we were not serializing the asterisk. Instead "foo bar *" came out as
"foo bar foo". This patch fixes that by correctly serializing the last
simple selector if it's universal.
2022-03-13 15:41:54 +01:00
MacDue
8fbe96af45 LibVT: Use coarse scrolling animation in TerminalWidget
The smooth scrolling looks slightly off in the terminal as the
scrollbar animation lasts longer than the actual scroll.

This behaviour is also consistent with other terminal emulators.
2022-03-13 11:45:07 +01:00
MacDue
91fff3f1ae LibGUI: Allow setting smooth/coarse scrolling animation on ScrollBar 2022-03-13 11:45:07 +01:00
MacDue
9ab3ab86cb LibGUI: Add m_ prefix to gutter_click_state in ScrollBar
Quick fix, this member did not seem to follow the conventions.
2022-03-13 11:45:07 +01:00
Andrew Smith
297e095755 PixelPaint: Correctly apply flip/rotate/crop to layers' alpha mask
-Layer now has methods for flip/rotate/crop, which are responsible
for handling the alpha mask.
-Fixed crash when the display image size is out of sync with
the content image size.
-Changed API for setting content and mask image in Layer. Now, both
must be set at the same time, and it can result in an error if
you provide mismatched dimensions.
2022-03-13 10:34:38 +01:00
Andreas Kling
ab9d9709b9 LibWeb: Give flex containers with percentage cross size some dimensions
Instead of making them zero-sized on the cross axis, just treat
percentage sizes like auto for now. Better to have *some* size than none
at all.
2022-03-13 00:04:51 +01:00
Andreas Kling
bd94f2c4c8 LibWeb: Add a debug helper to dump current state of an FFC 2022-03-13 00:04:51 +01:00
Andreas Kling
201afb50c7 LibWeb: Make Element::recompute_style() really compare properties
It's not enough to compare StyleProperties pointers to see if something
changed, we have to do a deep compare.
2022-03-13 00:04:51 +01:00
Andreas Kling
1223c88e68 LibWeb: Mark input elements for style update in set_checked()
When the checkedness changes, :checked selectors may yield different
results, so we have to update style.
2022-03-13 00:04:51 +01:00
Andreas Kling
630f2e0ee9 LibWeb: Make StyleProperties::operator==(StyleProperties) actually work
It was comparing against itself, oopsie!
2022-03-13 00:04:51 +01:00
Andreas Kling
ad8d65fd6e LibWeb: Fix calculation of hypothetical cross size in column flex layout
Simplify automatic cross sizing of items in flex-direction:column by
using the fit-content width directly.

There's obviously a lot more nuance to this, but for now this makes
flex items with both width:auto and height:auto actually get some height
in column flex layouts.
2022-03-13 00:04:51 +01:00
Andreas Kling
2f3d7a7c36 LibWeb: Swap min-content and max-content intrinsic sizes if needed
I'm a little confused about intrinsic heights *really* work, and I'm
struggling to extract that information from the spec. In the meantime,
let's ensure that min-content is always smaller than (or equal to)
max-content so that other math works as expected.
2022-03-13 00:04:51 +01:00
Andreas Kling
4a14c4dae8 LibWeb: Support the CSS 'unset' value
This works as 'inherit' for inherited properties and 'initial' for
everything else.
2022-03-13 00:04:51 +01:00
Andreas Kling
515db5fc1b LibWeb: Make Layout::FormattingState copies shallow
Previously, each NodeState in a FormattingState was shared with the
parent FormattingState, but the HashMap of NodeState had to be copied
when making FormattingState copies.

This patch makes copying instant by keeping a pointer to the parent
FormattingState instead. When fetching immutable state via get(), we may
now return a reference to a NodeState owned by a parent FormattingState.

get_mutable() will copy any NodeState found in the ancestor chain before
making a brand new one.
2022-03-13 00:04:51 +01:00
Andreas Kling
b6097cf724 LibWeb: Add fast_is<SVG::SVGSVGElement>() 2022-03-13 00:04:51 +01:00
Andreas Kling
8c91e8016c LibWeb: Handle many more cases with intrinsic/auto sizing in flex layout
The flexbox specification barely even handwaves about automatically
sized items, but there's actually a lot of work to do in order for them
to get the correct size.

This patch is messy, but does make significant progress on supporting
flex items with indefinite width and/or height.

There's a fair amount of nested layout going on here, but do note that
we'll be hitting the intrinsic sizes cache whenever possible.
2022-03-13 00:04:51 +01:00
Andreas Kling
3f2b17f602 LibWeb: Add functions for calculating intrinsic sizes of a Layout::Box
FormattingContext can now calculate the intrinsic sizes (min-content and
max-content in both axes) for a given Layout::Box.

This is a rather expensive operation, as it necessitates performing two
throwaway layouts of the subtree rooted at the box. Fortunately, we can
cache the results of these calculations, as intrinsic sizes don't change
based on other context around the box. They are intrinsic after all. :^)
2022-03-13 00:04:51 +01:00
Andreas Kling
aa969cc591 LibWeb: Make Layout::SVGBox a BlockContainer again
This wasn't worth the headache of trying to make SVG boxes work together
with BFC right now. Let's just make it a block container once again, and
have its corresponding SVGPaintable inherit from PaintableWithLines.

We'll have to revisit this as SVG support improves.
2022-03-13 00:04:51 +01:00
Andreas Kling
e4eb6d4f1f LibWeb: Add FFC helpers for resolving definite main/cross sizes
Although something has a definite size, we may still have to "resolve"
it, since FFC is quite liberal in what it considers to be definite.

Let's put that logic in a set of helper functions.
2022-03-13 00:04:51 +01:00
Andreas Kling
5c8e7217f7 LibWeb: Remove ad-hoc setup step from FFC layout algorithm
This step will not be necessary when we implement indefinite size
calculations more correctly.
2022-03-13 00:04:51 +01:00
Andreas Kling
12ac6861e3 LibWeb: Improve how layout nodes decide whether they have definite sizes
1. Make this decision *after* we've inserted the layout node into the
   layout tree. Otherwise, we can't reach its containing block!
2. Per css-sizing-3, consider auto-sized blocks whose sizes resolve
   solely against other definite sizes as definite themselves.

In particular, (2) makes us consider width:auto block children of a
definite-size containing block as having definite size. This becomes
very important in flex layout.
2022-03-13 00:04:51 +01:00
Andreas Kling
d201378750 LibWeb: Apply non-CSS presentational hints before author styles
According to css-cascade-4, we should apply presentational hints from
content attributes *before* author styles.
2022-03-13 00:04:51 +01:00