Commit graph

14390 commits

Author SHA1 Message Date
Linus Groh
48369194d2 LibJS: Forward receiver value to native property getters/setters
There's no reason why only (user-defined) accessors would have set the
receiver as this value for their getters/setters, this is an oversight.
2020-11-22 19:00:19 +01:00
Linus Groh
c52739ea4b LibJS: Make call_native_property_{g,s}etter() take a NativeProperty&
Passing in a plain Value and expecting it to be a native property is
error prone, let's use a more narrow type and pass a NativeProperty
reference directly.
2020-11-22 19:00:19 +01:00
Luke
773df8826d LibWeb: Add the submit event to HTMLFormElement
Also adds the ability to submit from JavaScript.
2020-11-22 18:20:56 +01:00
Luke
9950270808 LibWeb: Add HTML::EventNames and UIEvents::EventNames 2020-11-22 18:20:56 +01:00
Luke
e68348298f LibWeb: Add a test for the new event dispatcher 2020-11-22 18:20:56 +01:00
Luke
c5e15d9282 LibWeb: Expose ParentNode.{first,last}ElementChild
I needed these to write the event dispatcher test.
2020-11-22 18:20:56 +01:00
Luke
e8b3a65581 LibWeb: Make event dispatching spec-compliant
Specification: https://dom.spec.whatwg.org/#concept-event-dispatch

This also introduces shadow roots due to it being a requirement of
the event dispatcher.

However, it does not introduce the full shadow DOM, that can be
left for future work.

This changes some event dispatches which require certain attributes
to be initialised to a value.
2020-11-22 18:20:56 +01:00
Luke
819f099a8e AK: Add first_matching and last_matching to Vector
first_matching returns the first item in the vector that matches
the given condition.

last_matching returns the last item in the vector that matches
the given condition.
2020-11-22 18:20:56 +01:00
Andreas Kling
94ff04b536 Kernel: Make CLOCK_MONOTONIC respect the system tick frequency
The time returned by sys$clock_gettime() was not aligned with the delay
calculations in sys$clock_nanosleep(). This patch fixes that by taking
the system's ticks_per_second value into account in both functions.

This patch also removes the need for Thread::sleep_until() and uses
Thread::sleep() for both absolute and relative sleeps.

This was causing the nesalizer emulator port to sleep for a negative
amount of time at the end of each frame, making it run way too fast.
2020-11-22 17:20:58 +01:00
Andreas Kling
e07d14f4d9 LibWeb: Fix build with DEBUG_HIGHLIGHT_FOCUSED_FRAME 2020-11-22 16:07:53 +01:00
BenJilks
a27d118085 PixelPaint: Use UndoStack instead of History
This allows to share more code with other undo systems.
2020-11-22 16:07:00 +01:00
BenJilks
7707ebcd63 LibGUI: Fix undo stack
This would undo all commands at once instead of one at a time.
2020-11-22 16:07:00 +01:00
BenJilks
76aeb7cad8 PixelPaint: Applying filters should be an action
This allows you to undo filters
2020-11-22 16:07:00 +01:00
BenJilks
58c30959b1 PixelPaint: Export image as BMP
You can now export your masterpieces as fresh, crisp BMP files.
2020-11-22 16:07:00 +01:00
BenJilks
d8474d80f2 PixelPaint: Save and load to and from disk
Store a PixelPaint project in a .pp file (as there doesn't seem to
be any real standard on this). It's a very simple json file that
contains the bitmap as a base64 encoded bmp.
2020-11-22 16:07:00 +01:00
BenJilks
216385084b LibGfx: Add BMPWriter
This utility allows you to create a BMP file from a bitmap
2020-11-22 16:07:00 +01:00
BenJilks
91b2af34e1 base64: Fix not outputting all decoded data
It would use printf to output the data, so if it contains a null
terminator it'll stop.
2020-11-22 16:07:00 +01:00
BenJilks
29ada654b1 AK: Fix base64 decoding '/'
When creating the lookup table, it wouldn't add the last
character
2020-11-22 16:07:00 +01:00
BenJilks
1c27568ab0 PixelPaint: Undo and redo actions
The most used feature of any image editor, undo. Each tool now
notifies the ImageEditor that they completed an action, where
it'll take a snapshot if its current state.

For now, a snapshot is just a copy of the whole image and its
layers. There's a hard limit on the amount of actions it stores.
2020-11-22 16:07:00 +01:00
Andreas Kling
5aeab9878e LibWeb: Rename LayoutNode classes and move them into Layout namespace
Bring the names of various boxes closer to spec language. This should
hopefully make things easier to understand and hack on. :^)

Some notable changes:

- LayoutNode -> Layout::Node
- LayoutBox -> Layout::Box
- LayoutBlock -> Layout::BlockBox
- LayoutReplaced -> Layout::ReplacedBox
- LayoutDocument -> Layout::InitialContainingBlockBox
- LayoutText -> Layout::TextNode
- LayoutInline -> Layout::InlineNode

Note that this is not strictly a "box tree" as we also hang inline/text
nodes in the same tree, and they don't generate boxes. (Instead, they
contribute line box fragments to their containing block!)
2020-11-22 15:56:27 +01:00
Andreas Kling
f358f2255f LibWeb: Rename LayoutNode::node() => LayoutNode::dom_node() 2020-11-22 14:46:36 +01:00
Andreas Kling
85859544fa LibWeb: Run clang-format on FormattingContext.h 2020-11-22 14:40:55 +01:00
Andreas Kling
e1a24edfa9 LibWeb: Reorganize layout system in terms of formatting contexts
This is a first (huge) step towards modernizing the layout architecture
and bringing it closer to spec language.

Layout is now performed by a stack of formatting contexts, operating on
the box tree (or layout tree, if you will.)

There are currently three types of formatting context:

- BlockFormattingContext (BFC)
- InlineFormattingContext (IFC)
- TableFormattingContext (TFC)

Document::layout() creates the initial BlockFormattingContext (BFC)
which lays out the initial containing block (ICB), and then we recurse
through the tree, creating BFC, IFC or TFC as appropriate and handing
over control at the context boundaries.

The majority of this patch is just refactoring the old logic spread out
in LayoutBlock and LayoutTableRowGroup, and turning into these context
classes instead. A lot more cleanup will be needed.

There are many architectural wins here, the main one being that layout
is no longer performed by boxes themselves, which gives us much greater
flexibility in the outer/inner layout of a given box.
2020-11-22 14:36:56 +01:00
Andreas Kling
00aac65af5 Base: Unbreak the "images" HTML test page 2020-11-22 13:48:43 +01:00
Andreas Kling
1e92081546 LibWeb: Avoid some heap churn during text splitting
Use Vector capacity while splitting text into chunks (to avoid many
small heap allocations.)
2020-11-22 13:48:43 +01:00
Lenny Maiorani
7d8a9bdb1e AK: Cleanup missing includes and #ifdef evaluation
Problem:
- Several files have missing includes. This results in complaints from
  `clang-tidy`.
- `#ifdef` is followed by `#elif <value>` which evaluates to `0`.

Solution:
- Add missing includes.
- Change to `#elif defined(<value>)`.
2020-11-22 11:35:53 +01:00
Luke
bbc0487ced LibJS: Fix build with VM_DEBUG defined 2020-11-22 11:35:13 +01:00
Lenny Maiorani
840c3b501d NeverDestroyed: Add tests
Problem:
- It is difficult to refactor because there are no tests to bind the
functionality.
- Arguments are not forwarded correctly to the constructor.

Solution:
- Add tests.
- Change constructor to take forwarding references.
2020-11-22 10:54:33 +01:00
Simon Danner
bc5b8223b7 SoundPlayer: Add pledge for thread so file chooser doesn't crash
- Without thread pledge, SoundPlayer crashes when generating thumbnails
- Fixes #4121
2020-11-22 10:53:58 +01:00
Simon Danner
09b095e62a UserspaceEmulator: Add support for watch_file 2020-11-22 10:53:58 +01:00
Lenny Maiorani
178190ab52 MACAddress: Use all_of to implement is_zero
Problem:
- `is_zero()` is implemented by checking each value in the array by
  hand. This is error-prone and less expressive than using an
  algorithm.

Solution:
- Implement `is_zero()` in terms of `all_of`.
2020-11-21 19:25:14 +01:00
Lenny Maiorani
6e7e16a7ed AK: Implement generic all_of algorithm
Problem:
- Raw loops are often written to validate that all values in a
  container meet a predicate, but raw loops are not as expressive as
  functions implementing well-named algorithms and are error-prone.

Solution:
- Implement a very generic form of `all_of`.
2020-11-21 19:25:14 +01:00
Lenny Maiorani
446a19ba51
test-crypto: Remove foo.response file created by testing (#4110)
Problem:
- Test creates a file and leaves it in the source tree.

Solution:
- Remove the creation of the file since it is never checked.
2020-11-20 21:18:43 +01:00
Lenny Maiorani
bdf3baa8ac MACAddress: AK::Array as member variable instead of C-array
Problem:
- C-style arrays do not automatically provide bounds checking and are
  less type safe overall.
- `__builtin_memcmp` is not a constant expression in the current gcc.

Solution:
- Change private m_data to be AK::Array.
- Eliminate constructor from C-style array.
- Change users of the C-style array constructor to use the default
  constructor.
- Change `operator==()` to be a hand-written comparison loop and let
  the optimizer figure out to use `memcmp`.
2020-11-20 21:18:14 +01:00
Nico Weber
700fe315cf LibGfx: Make some GIFLoader magic numbers a bit less magic
No behavior change.
2020-11-20 21:17:58 +01:00
Nico Weber
967c82c1be LibGfx: Put GIFLoader logging behind GIF_DEBUG 2020-11-20 21:17:58 +01:00
Nico Weber
ebfc21509a LibGfx: De-constexpr Gamma.h
__builtin_sqrtf() isn't constexpr in clang.
2020-11-20 21:17:58 +01:00
Nico Weber
f13a38aa4d Lagom: Add a gif loader fuzzer 2020-11-20 21:17:58 +01:00
Andreas Kling
10b534849d LibWeb: Remove ancient HTML_DEBUG debug logging 2020-11-19 23:10:21 +01:00
Zac
6a569bbdd7 TextEditor: Change cursor behaviour when clicking empty space
When clicking empty space (beneath any used lines) in the TextEditor,
the cursor would jump to the start of the last line, rather than the
correct column, or the end of the line where appropriate. This was
because in the for_each_visual_line callback would return
IterationDecision::Continue if the clicked point wasn't in the line's
rect. Thus the callback would continue on each iteration and at the
end, would set the cursor to the default column of 0. To fix this I
added a bool to the callback's signature which tells the callback if
the for_each_visual_line method is on the last visual line. The
callback now does not return IterationDecision:Continue if
for_each_visual_line method is on the last line and the correct column
is then calculated with the line passed.
2020-11-19 21:59:13 +01:00
Andreas Kling
f72f4c5bca LibGUI: Remove AbstractTableView::doubleclick_event()
This work is already done (and more correctly) by the parent class
(AbstractView) if we just let it take care of the event instead.

Fixes the root cause of #4096.
2020-11-19 21:57:05 +01:00
Andreas Kling
da413a464a UserspaceEmulator: Inline some very hot functions
This improves the browser's load time on welcome.html by ~2%.
2020-11-19 21:46:01 +01:00
Sahan Fernando
1b9a85e4f1 LibGfx: Use gamma-corrected interpolation for color gradients
Switch over to gamma-aware interpolation. This causes color gradients
to not look so dark in the middle. SIMD optimized code is provided for
sse1 enabled builds.

Fixes #1342.
2020-11-19 21:24:20 +01:00
Nico Weber
7042490e41 LibGfx: Bounds check component indices before using them in JPGLoader
With this, I don't see any crashes in 10 min of fuzzing (but still
get OOMs).
2020-11-19 21:21:45 +01:00
Nico Weber
a8318b15a7 LibGfx: Check for read failures after every read in jpg loader
This doesn't fix all the issues found by the fuzzer, but it fixes
many of them. When running this

    Meta/Lagom/Fuzzers/FuzzJPGLoader -jobs=24 -workers=24 \
        ../Base/res/html/misc/jpgsuite_files/

for 10 minutes on my machine, the fuzzer foudn 2 crashers, but after
this change it finds just ... 2. But with different stacks!

This just fixes ASSERT()s, so it's not security critical, but
ASSERT()s still crash the programs decoding JPGs, and crashing
less is nice even if it's not a security concern.
2020-11-19 21:21:45 +01:00
Nico Weber
129a0666cb LibGfx: Put remaining jpg logging behind JPG_DEBUG
...except for one happy-case log line which is removed wholesale.
2020-11-19 21:21:45 +01:00
Nico Weber
3749e167b4 LibGfx: Move JPGLoader to a more regular JPG_DEBUG macro as used elsewhere 2020-11-19 21:21:45 +01:00
Nico Weber
812892ef86 Lagom: Add a jpg fuzzer 2020-11-19 21:21:45 +01:00
Nico Weber
3f3a7d128b Lagom: Make fuzzer cmake less repetitive 2020-11-19 21:21:45 +01:00
Nico Weber
f5967c4745 Lagom: Add a PPM fuzzer
It finds the problem fixed in 69518bd178 but nothing else.
2020-11-19 14:04:35 +01:00