Commit graph

14569 commits

Author SHA1 Message Date
Ben Wiederhake
52a8062084 LibCore: Offer to display a general description 2020-12-06 00:06:53 +01:00
Linus Groh
886b43e999 LibLine: Don't make Editor::load_history() cut off a character per line
For some reason we were not considering the last *two* characters from
the line's ByteBuffer, with the comment next to it talking about \n and
\0. However the buffer doesn't contain a null-byte, so we were
effectively removing the newline and the last character from each
history line!
2020-12-06 00:06:46 +01:00
Ben Wiederhake
ecb16f421d LibGfx: Handle OOM slightly better
When create_with_shared_buffer() is called in the next line, the
RefPtr::operator* asserts that the RefPtr is not null. That can happen when
we're low-ish on memory, and the image is huge.
2020-12-06 00:06:05 +01:00
Andreas Kling
31a3ed70f0 LibWeb: Hit test floats using the top of lines, not middle
I don't know why basing the available space between floats on the y
coordinate in the middle of each line seemed like a good idea. It just
creates situations with a few pixels of floats overlapping text!
2020-12-05 23:54:07 +01:00
Linus Groh
a70aacd7c3 LibJS: Add Float{32,64}Array 2020-12-05 23:52:17 +01:00
Linus Groh
4dcd23c2be AK: Pull Is{Integral,FloatingPoint} into the global namespace 2020-12-05 23:52:17 +01:00
Andreas Kling
04e1827864 LibWeb: Run clang-format on ReplacedBox.cpp 2020-12-05 23:41:07 +01:00
Andreas Kling
66a053da77 LibWeb: Don't subtract dubious "line spacing" from line y offsets
I'm not sure what this was trying to achieve, but it was moving all
line fragments upwards and a lot of things look a lot better if we
just stop doing that.
2020-12-05 23:17:23 +01:00
Andreas Kling
65e430eee5 LibWeb: Floating boxes follow normal containing block rules
I had guessed that floating boxes should somehow be hoisted up to the
nearest block ancestor that creates a block formatting context, but
that's just wrong. They move up to the nearest block ancestor like any
other box that's not absolutely (or fixed) positioned. :^)
2020-12-05 23:12:29 +01:00
Andreas Kling
2f38d94c70 LibWeb: Fix off-by-one when computing available space between floats
Whoops, this explains why things were not lining up correctly. :^)
2020-12-05 22:51:03 +01:00
Andreas Kling
2e5e4be212 Base: Add a simple HTML test page for CSS floats 2020-12-05 22:51:03 +01:00
Andreas Kling
615a4d4f71 LibWeb: First slightly naive implementation of CSS floats :^)
Boxes can now be floated left or right, which makes text within the
same block formatting context flow around them.

We were creating way too many block formatting contexts. As it turns
out, we don't need one for every new block, but rather there's a set
of rules that determines whether a given block creates a new block
formatting context.

Each BFC keeps track of the floating boxes within it, and IFC's can
then query it to find the available space for line boxes.

There's a huge hack in here where we assume all lines are the exact
line-height. Making this work with vertically non-uniform lines will
require some architectural changes.
2020-12-05 22:51:03 +01:00
Andreas Kling
11256de366 LibWeb: Add Layout::Node::is_root_element()
This returns true if the layout node corresponds to the <html> element.
2020-12-05 22:51:03 +01:00
Andreas Kling
cc14b5a6d7 LibJS: Implement a very hackish "arguments" object
We now lazily create an "arguments" array inside functions when code
tries to access it.

This doesn't follow the spec at all but still covers a lot of the
basic uses of arguments, i.e "arguments.length" and "arguments[n]"
2020-12-05 16:41:41 +01:00
Andreas Kling
e6dadd9e5b LibJS: Implement parseInt()
Here's a reasonably faithful implementation of ECMAScript 2021 18.2.5.
Some corner cases are not covered, I've left them as FIXME's in the
included unit test.

Also I had to tweak JS::Value::to_i32() to always convert infinity to
zero, which is in accordance with ToInt32 AFAICT.
2020-12-05 13:55:55 +01:00
Daniel Lemos
4ae0de9a37
Browser: Add DuckDuckGo to bookmarks (#4288) 2020-12-05 13:39:30 +01:00
Julian Offenhäuser
980acd0db7 AudioServer: Fix issue when adding a BufferQueue to Mixer
Previously, the Mixer class would only check for an added BufferQueue
if the list of active queues was empty. If more than one client
connected to AudioServer, its queue would never be added to the list of
active queues.

This fix adds a flag that, when set, will cause the sound thread to wait
for a new BufferQueue.
2020-12-05 10:10:27 +01:00
Linus Groh
745801e109 js: Improve pretty-printing of various objects
For many object types we only ever used the regular print_object() in
the js REPL - resulting in a useless "{  }".

This patch adds more individual representations for the following types:
- Boolean/Number/String object: print wrapped value
- ArrayBuffer: print byteLength and hex-formatted bytes in chunks of 16
- TypedArray: print length, byteLength, buffer pointer and values
- Proxy: print target and handler

Also improve the existing pretty-printing output:
- More consistency, most objects now follow the format "[Type] ..."
- Some coloring tweaks
- No two spaces in empty arrays & objects

Possible future improvements:
- Add line breaks between elements of long arrays & objects

Closes #4310.
2020-12-05 10:05:28 +01:00
Linus Groh
909f430612 LibJS: Move is_script_function() to Object
Every Object should be able to tell us if it is a ScriptFunction, not
only Function objects!
2020-12-05 10:05:28 +01:00
Andreas Kling
157896cc0b LibWeb: Block layout should account for vertical border space
We were not accounting for space occupied by borders when computing
the vertical (y) position of blocks. This meant that blocks with wide
top/bottom borders could bleed into each other incorrectly.

Fix this by using the combined padding+border geometry instead of just
the padding when placing blocks on the y axis.
2020-12-04 21:24:35 +01:00
Andreas Kling
c39e29d186 LibWeb: Block layout should resolve relative lengths against each box
We were incorrectly resolving relative length units (ex, em, etc.)
against the containing block in many cases. Fix this to resolve them
against the descendant box we're currently processing.
2020-12-04 21:22:49 +01:00
Andreas Kling
90b12a41c8 LibWeb: Make LineBox take incoming fragment size as floats 2020-12-04 21:06:27 +01:00
Andreas Kling
52d993cfa8 LibWeb: Expose Document.getElementsByName() to JavaScript 2020-12-04 20:47:37 +01:00
Andreas Kling
3eb07d289e LibWeb: Move border painting from Layout::Box to a free function
This will allow us to share some code between inline and non-inline
border painting.
2020-12-04 18:02:21 +01:00
Andreas Kling
c01070df1b Base: Add a hover color link to the links on the welcome page 2020-12-04 16:30:07 +01:00
Andreas Kling
169a9150cb LibWeb: Rename LayoutNode::is_root() => is_initial_containing_block()
Let's use spec language for this. :^)
2020-12-04 16:27:07 +01:00
Andreas Kling
e0809f78a9 LibWeb: Call the correct base class in InlineNode::split_into_lines() 2020-12-04 16:21:21 +01:00
Andreas Kling
2cbbab8f73 LibWeb: Compute the final border-style property before painting
Instead of doing a CSS property lookup for the line style of each
border edge during paint, we now cache the final CSS::LineStyle to use
in the Layout::BorderData.
2020-12-04 16:11:55 +01:00
Andreas Kling
88ca932fac LibWeb: Make LineBoxFragment store non-const Layout::Node&
This is more honest, since we actually const_cast these layout nodes
during inline layout anyway.
2020-12-04 15:46:58 +01:00
Julian Offenhäuser
6a83475ec5 LibVT: Auto-scroll the terminal
TerminalWidget will now automatically scroll up or down when the user
drags the mouse out of its bounds while selecting text. This happens
at a fixed speed.
2020-12-04 14:29:39 +01:00
Linus Groh
1fab67ea52 test-js: Use new format functions 2020-12-03 21:55:02 +01:00
Linus Groh
7cbdf465ba test-js: Set test root correctly when specified as positional arg
When a test root path was given to test-js it was never used, causing
test-js to always fail.
2020-12-03 21:55:02 +01:00
Sahan Fernando
4062add8ed LibGUI: Optimize GUI::Variant move constructor 2020-12-03 21:53:29 +01:00
Julian Offenhäuser
d0812e9019 LibAudio: Fix parsing of WAV files from memory
The WavLoaderPlugin now loads the file header correctly when reading
from a ByteBuffer.
2020-12-03 21:52:10 +01:00
Julian Offenhäuser
228fa1c51d SoundPlayer: Accept drop events
Files can now be dragged into the window and loading errors will be
handled more gracefully.
2020-12-03 21:52:10 +01:00
Andreas Kling
017490aa7f Base: Add a little web test page for inline elements with CSS padding 2020-12-03 21:46:04 +01:00
Andreas Kling
f35b406dfb LibWeb: Virtualize Layout::Node::paint_fragment()
LineBoxFragment no longer needs to care what type of layout node a
fragment refers to during paint, it can just call paint_fragment(). :^)
2020-12-03 21:46:01 +01:00
Andreas Kling
c189897e29 LibWeb: Fix wrong forward declaration of LineBox & LineBoxFragment 2020-12-03 21:45:55 +01:00
Andreas Kling
d59ec3ab85 LibWeb: Create "empty" line box fragments for inline elements
In order for inline elements (e.g <span>) to contribute padding etc.
to line boxes, we now create special "leading" and "trailing" fragments
for Layout::InlineNode and size them according to the horizontal
padding values.

The height of these fragments is taken from the tallest fragment on the
line. (Perhaps we should stop having per-fragment heights and just keep
a single height per line box, but that's a separate issue.)

In order to make things look nice, we now also adjust the height of all
fragments on a line so that nobody is shorter than the CSS line-height.
2020-12-03 21:45:51 +01:00
Andreas Kling
311e1039b5 LibWeb: Paint line box fragments during all paint phases
Fragment painting was very limited by only being called during the
foreground paint phase. We now paint fragments as part of every phase
(and the phase is passed to paint_fragment() of course!)
2020-12-03 21:45:46 +01:00
Andreas Kling
d129e68da8 LibWeb: Move PaintPhase enum out of Layout::Node
Now it's just Layout::PaintPhase instead of Layout::Node::PaintPhase.
2020-12-03 21:45:41 +01:00
Andreas Kling
d6c2a61fa1 LibWeb: Add type casting helpers for Layout::InlineNode 2020-12-03 21:45:38 +01:00
Andreas Kling
17e9a5e0c5 LibWeb: Hoist an early return in Layout::BlockBox::paint() 2020-12-03 17:17:11 +01:00
Andreas Kling
194d7d3471 LibWeb: Hack the CSS parser to handle integer values (like z-index)
We were rejecting perfectly valid z-index values like '1000' since we
were passing all CSS values through the length parser and unit-less
lengths are not valid in this context.

It's yet another hack for the ad-hoc CSS parser (its days are numbered)
but this makes the top header links on google.com actually work. :^)
2020-12-03 11:46:10 +01:00
AnotherTest
62bd1adb06 Shell: Replace one more user-controlled assert with a syntax error
test-case: https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=28114&q=label%3AProj-serenity
2020-12-03 10:51:56 +01:00
AnotherTest
9d9347cd5a Shell: Fix bad cast to BarewordLiteral
As found by oss-fuzz: https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=28109&q=label%3AProj-serenity
2020-12-03 10:51:56 +01:00
AnotherTest
c1c5225b72 LibRegex: Fix assertion when parsing '(?'
Found by oss-fuzz: https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=28186&q=label%3AProj-serenity
2020-12-03 10:51:56 +01:00
Andreas Kling
4fe987ba00 LibWeb: Don't layout twice for every InProcessWebView resize event
Calling Frame::set_size() already triggered a relayout, so calling
layout() again right after meant we did all the work one more time.

Not being dumb like this makes resizing significantly smoother. :^)
2020-12-02 23:50:19 +01:00
Andreas Kling
15e35b0d71 LibWeb: Layout viewport rect was lagging behind when resizing
Layout was using an outdated viewport rect that we set *after* doing
a layout due to resize. That meant that layout-in-response-to-resize
was always lagging behind the current size of the view.

The root of this problem was how Frame kept both a viewport rect
(with both scroll offset and size) and a frame size. To fix this,
only store the viewport scroll offset, and always use the frame size.
This way they can't get out of sync and the problem goes away. :^)

Fixes #4250.
2020-12-02 23:50:19 +01:00
Tom
766db673c1 Kernel: Flush TLBs concurrently
Instead of flushing the TLB on the current processor first and then
notifying the other processors to do the same, notify the others
first, and while waiting on the others flush our own.
2020-12-02 23:49:52 +01:00