Commit graph

15289 commits

Author SHA1 Message Date
Jelle Raaijmakers bec474d99b LibGfx: Calculate source rect once in do_draw_scaled_bitmap 2022-03-23 11:53:34 +01:00
Jelle Raaijmakers f790a69431 LibGfx: Draw last row and column of scaled bitmaps in Painter
There was an off-by-one bug in `Painter::do_draw_scaled_bitmap` where
the last column and row of the source bitmap would be skipped. This was
especially visible in PixelPaint when zooming in and out on smaller
images.

Instead of the top/left of the pixel, we now use the bottom/right side
of the pixel as a threshold to stop drawing.
2022-03-23 11:53:34 +01:00
Andreas Kling fd7a059e09 LibWeb: Make NodeIterator behave like other browser engines
If invoking a NodeFilter ends up deleting a node from the DOM, it's not
enough to only adjust the NodeIterator reference nodes in the
pre-removing steps. We must also adjust the current traversal pointer.

This is not in the spec, but it's how other engines behave, so let's do
the same.

I've encapsulated the Node + before-or-after-flag in a struct called
NodePointer so that we can use the same pre-removing steps for both the
traversal pointer and for the NodeIterator's reference node.

Note that when invoking the NodeFilter, we have to remember the node we
passed to the filter function, so that we can return it if accepted by
the filter.

This gets us another point on Acid3. :^)
2022-03-23 00:22:36 +01:00
Andreas Kling a0b0b29fa1 LibWeb: Minor cleanups in NodeIterator and TreeWalker
- Use TRY() when invoking the NodeFilter
- Say "nullptr" instead of "RefPtr<Node> {}"
2022-03-23 00:19:57 +01:00
Sam Atkins ccee8953d0 LibWeb: Expose SVGEllipseElement attributes to JS 2022-03-22 22:33:17 +01:00
Sam Atkins 1a3d6c68ef LibWeb: Expose SVGCircleElement attributes to JS 2022-03-22 22:33:17 +01:00
Sam Atkins b51ea3a67c LibWeb: Expose SVGLineElement attributes to JS 2022-03-22 22:33:17 +01:00
Liav A b5ef900ccd Kernel: Don't assume paths of TTYs and pseudo terminals anymore
The obsolete ttyname and ptsname syscalls are removed.
LibC doesn't rely on these anymore, and it helps simplifying the Kernel
in many places, so it's an overall an improvement.

In addition to that, /proc/PID/tty node is removed too as it is not
needed anymore by userspace to get the attached TTY of a process, as
/dev/tty (which is already a character device) represents that as well.
2022-03-22 20:26:05 +01:00
Liav A de7566c2c4 LibC: Don't rely on ptsname and ttyname syscalls
Instead, to determine these values (both the pts name and tty name), use
other methods. For determining the new name of the allocated psuedo
terminal, use ioctl on a file descriptor we got after opening /dev/ptmx
with the TIOCGPTN option.
For determining the name of TTY, we enumerate both /dev/pts and /dev
directories to find matching inode number and matching device mode.
2022-03-22 20:26:05 +01:00
Liav A 5ffe2f117c Kernel/TTY: Implement TIOCGPTN ioctl for MasterPTY
This ioctl operation will allow userspace to determine the index number
of a MasterPTY after opening /dev/ptmx and actually getting an internal
file descriptor of MasterPTY.
2022-03-22 20:26:05 +01:00
Liav A e508073168 SystemServer: Create /dev/tty as a character device instead of a symlink
The new device has major number 5, minor number 0, and is represented by
the SelfTTYDevice class in the Kernel.
2022-03-22 20:26:05 +01:00
Andreas Kling 2fb9eb5257 LibWeb: Implement Range.deleteContents()
And here's another point on Acid3. :^)
2022-03-22 20:17:52 +01:00
Andreas Kling e1c71b3f91 LibWeb: Implement Range.cloneContents() 2022-03-22 20:03:09 +01:00
Andreas Kling de6f7f0029 LibWeb: Support CSS floats in inline flow
CSS floats are now emitted by the InlineLevelIterator. When this
happens, IFC coordinates with the parent BFC to float the box to the
side, using the current LineBuilder state for vertical placement.

This makes the "instructions" text on Acid3 render as a single
contiguous flow of inline content.
2022-03-22 19:26:51 +01:00
Andreas Kling fa64a7f6cc LibWeb: Relax "all children must be either inline or block" invariant
This was implemented too rigidly, which made it impossible to place
floats correctly when they occurred in inline flow.

The new invariant is "all in-flow children must be either inline or
block". Out-of-flow children like floating and absolutely positioned
boxes are ignored when deciding when to generate anonymous boxes.
2022-03-22 19:26:51 +01:00
Andreas Kling 74927fd218 LibWeb: Move Layout::Box::is_out_of_flow() to Layout::Node
I want to use this function in inline layout, where we're not just
dealing with boxes.
2022-03-22 19:26:51 +01:00
Linus Groh cd6896d343 LibWeb: Convert URL to use TRY for error propagation 2022-03-22 18:05:25 +00:00
Linus Groh 2219eef250 LibWeb: Convert Text to use TRY for error propagation 2022-03-22 18:05:25 +00:00
Linus Groh 46bb547dd6 LibWeb: Convert ShadowRoot to use TRY for error propagation 2022-03-22 18:05:25 +00:00
Linus Groh a68d31debd LibWeb: Convert ParentNode to use TRY for error propagation 2022-03-22 18:05:25 +00:00
Linus Groh 8d20fb1e94 LibWeb: Convert NodeOperations to use TRY for error propagation 2022-03-22 18:05:25 +00:00
Linus Groh 3861396fe4 LibWeb: Convert Node to use TRY for error propagation 2022-03-22 18:05:25 +00:00
Linus Groh 07a2c58da0 LibWeb: Convert InnerHTML to use TRY for error propagation 2022-03-22 18:05:25 +00:00
Linus Groh 3cb7c463a7 LibWeb: Convert Element to use TRY for error propagation 2022-03-22 18:05:25 +00:00
Linus Groh b6f09aaef2 LibWeb: Convert DOMTokenList to use TRY for error propagation 2022-03-22 18:05:25 +00:00
Linus Groh 91d0088a5b LibWeb: Convert DOMImplementation to use TRY for error propagation 2022-03-22 18:05:25 +00:00
Linus Groh e758bd303f LibWeb: Convert Document to use TRY for error propagation 2022-03-22 18:05:25 +00:00
Linus Groh ab0a354bb4 LibWeb: Convert ChildNode to use TRY for error propagation 2022-03-22 18:05:25 +00:00
Linus Groh 9ca10c9347 LibWeb: Convert CRC2D to use TRY for error propagation 2022-03-22 18:05:25 +00:00
Timothy Flynn 859a75fd4c LibWeb: Handle input element value setting & getting closer to the spec
We should not set the 'value' attribute when an input element's value is
changed (by the user or programmatically). Instead, we should track the
value internally and mark it with a dirty flag when it is changed.
2022-03-22 16:06:38 +01:00
Sam Atkins 31b24c2b29 LibWeb: Remove now-unused null values from Selector enums
Now that we use a Variant for the SimpleSelector's data, we don't need
to instantiate empty structs or variables for the types that aren't
used, and so we can remove `PseudoElement::None`,
`PsuedoClass::Type::None` and `Attribute::MatchType::None`.

Also, we now always initialize a SimpleSelector with a type, so
`SimpleSelector::Type::Invalid` can go too.
2022-03-22 15:47:36 +01:00
Sam Atkins cbe2eaebab LibWeb: Tidy up CSS::Token::to_debug_string()
The ifs below the switch no longer functioned, so let's move everything
into the switch cases. This also means we can replace the StringBuilder
usage with String::formatted().
2022-03-22 15:47:36 +01:00
Sam Atkins 13e1232d79 LibWeb: Remove separate Token::m_unit field
Dimension tokens don't make use of the m_value string for anything else,
so we can sneak the unit string in there.

- Token goes from 72 to 64 bytes
- StyleComponentValueRule goes from 80 to 72 bytes
2022-03-22 15:47:36 +01:00
Sam Atkins c0d3f1a5e4 LibWeb: Use CSS::Number for CalculatedStyleValue numbers 2022-03-22 15:47:36 +01:00
Sam Atkins fe372cd073 LibWeb: Use CSS::Number for Token numeric values 2022-03-22 15:47:36 +01:00
Sam Atkins e8ab2dab11 LibWeb: Implement a CSS::Number class
We have the same "number and is-integer flag" structure in several
places, so let's put that in a class.
2022-03-22 15:47:36 +01:00
Sam Atkins 0795b9f7bb LibWeb: Use floats instead of doubles for CSS numbers
Using doubles isn't necessary, and they make things slightly bigger and
slower, so let's use floats instead.
2022-03-22 15:47:36 +01:00
Sam Atkins 1f5b5d3f99 LibWeb: Use intermediate ints when converting strings to numbers in CSS
These three are all integers - we just repeatedly multiply them by 10
and then add a digit - so using an integer here is both faster and more
accurate. :^)
2022-03-22 15:47:36 +01:00
Sam Atkins 404a7cb63a LibGfx+LibWeb: Use floats not doubles to create HSL colors
There's really no reason to use doubles here, except at the time I
wanted to use doubles everywhere in CSS. I now realize that is
excessive, so everything can be floats instead.
2022-03-22 15:47:36 +01:00
Sam Atkins 75ec960495 LibWeb: Initialize PseudoClass/PseudoElement selectors in one go
There was no real benefit to creating the SimpleSelector early and then
modifying it, and doing so made this code harder to follow than it
needs to be.
2022-03-22 15:47:36 +01:00
Sam Atkins c0db19f63c LibWeb: Use a Variant for SimpleSelector's contents
This reduces SimpleSelector's size from 112 bytes to 80 bytes. :^)
2022-03-22 15:47:36 +01:00
Sam Atkins 218a9af6b3 LibWeb: Make StyleComponentValueRule use a Variant
This shrinks its size from 96 bytes to 80. It's now limited by the size
of Token.
2022-03-22 15:47:36 +01:00
Sam Atkins ca1b855d99 LibWeb: Allow percentages in word/letter-spacing properties
This is a change to CSS-TEXT-4, listed here:
https://www.w3.org/TR/2022/WD-css-text-4-20220318/#changes

We don't actually support these properties yet, but it doesn't hurt to
keep them up to date for when they get implemented in the future. :^)
2022-03-22 15:45:46 +01:00
Linus Groh 701d437205 LibWeb: Explicitly ignore [[nodiscard]] values returned from TRY(), pt 2 2022-03-22 13:36:44 +00:00
Linus Groh 70b1f18e58 LibWeb: Explicitly ignore [[nodiscard]] values returned from TRY()
This broke the clang build.
2022-03-22 13:20:06 +00:00
Timothy Flynn c3f9cd6dbd LibWeb: Convert Range to use TRY for error propagation 2022-03-22 12:09:27 +00:00
Timothy Flynn f9cc5d1071 LibWeb: Convert HTMLOptionsCollection to use TRY for error propagation 2022-03-22 12:09:27 +00:00
Timothy Flynn 2d34216628 LibWeb: Make DOM::ExceptionOr compatible with the TRY macro
This will help reduce the quite repetitive pattern of:

    auto result_or_error = dom_node->do_something();
    if (result_or_error.is_exception())
        return result_or_error.exception();
    auto result = result_or_error.release_value();

Similar to LibJS completions, this adds an alias to the error accessors.
This also removes the requirement on release_value() for ValueType to
not be Empty, which we also had to do for TRY compatibility in LibJS.
2022-03-22 12:09:27 +00:00
Linus Groh f36f9c106b LibCrypto: Fix grammar in a couple of comments 2022-03-22 11:26:29 +00:00
Nícolas F. R. A. Prado 2c44c7fc89 KeyboardSettings: Allow changing and applying active keymap
Previously only the list of allowed keymaps could be modified and
applied to the system.

Add a new button to activate the selected keymap from the list. When
applying the changes to the system, also apply the active keymap.
2022-03-22 12:21:21 +01:00
Nícolas F. R. A. Prado a48d7d6adc KeyboardSettings: Rename m_current_applied_keymap
Rename it to m_initial_active_keymap to denote that it's the keymap that
was active when the application started up.
2022-03-22 12:21:21 +01:00
int16 3f391d80c4 SystemMonitor: Recognise wxallowed mount flag 2022-03-22 12:20:19 +01:00
int16 a4d96c159c Mount: Implement wxallowed mount option 2022-03-22 12:20:19 +01:00
Rok Povsic 5bb5967259 Browser: Append .com when pressing CTRL+Enter in the URL text editor
This is the behavior in Firefox / Chrome.
2022-03-22 12:17:48 +01:00
Rok Povsic 7da0d94d03 LibGUI: Add CTRL+Enter callback to TextEditor 2022-03-22 12:17:48 +01:00
Jelle Raaijmakers d195972ec2 Applications: Do not crash if decoded bitmap is null
ImageViewer and PixelPaint would crash when the ImageDecoderClient
returns a frame without a bitmap. This can happen with `.ico` files
with an unsupported BPP, for example.
2022-03-22 12:14:09 +01:00
Nicholas Cellino 1db7c423db disk_benchmark: Port to LibMain 2022-03-22 11:51:32 +01:00
Brian Gianforcaro 0a9e84aff0 readelf: Port to LibMain 2022-03-22 11:39:20 +01:00
Brian Gianforcaro 575fcc42c3 purge: Port to LibMain 2022-03-22 11:39:20 +01:00
Brian Gianforcaro fbceebb717 ping: Utilize TRY + Core::System wrappers 2022-03-22 11:39:20 +01:00
Brian Gianforcaro 08d65e8c38 traceroute: Port to LibMain 2022-03-22 11:39:20 +01:00
Brian Gianforcaro 6eebd69b70 LibCore: Add Core::System::drop_privileges()
In a few places we intentionally drop privileges to reduce the potential
security surface area of networked program, with the pattern of:

```
if (setgid(getgid()) || setuid(getuid()) {
    return 1;
}
```

We can make this a bit nicer to use by creating a wrapper.
2022-03-22 11:39:20 +01:00
Brian Gianforcaro 7403342387 true: Port to LibMain 2022-03-22 11:39:20 +01:00
Brian Gianforcaro 544609b40f printf: Port to LibMain 2022-03-22 11:39:20 +01:00
Brian Gianforcaro dba23c55dd matroska: Port to LibMain 2022-03-22 11:39:20 +01:00
Jamie Mansfield 9b9d32dfb2 LibWeb: Fix crash when removing event listeners 2022-03-22 02:35:07 +01:00
Timothy Flynn 27eb70cbba LibWeb: Implement HTMLSelectElement.add()
HTMLSelectElement simply defers to its HTMLOptionsCollection.
2022-03-22 02:08:15 +01:00
Timothy Flynn ff9856a214 LibWeb: Implement HTMLOptionsCollection.add() 2022-03-22 02:08:15 +01:00
Timothy Flynn 5133491714 LibWeb: Expose HTMLCollection's root element to its subclasses
For example, HTMLOptionsCollection will need to access its root
HTMLSelectElement.
2022-03-22 02:08:15 +01:00
Simon Wanner dc94879b83 LibWeb: Support transform: translate(...) by percentage 2022-03-22 02:06:21 +01:00
Simon Wanner 4f348f1733 LibGfx: Clip away coordinates outside the source bitmap
This prevents accessing the source pixels out of bounds.
2022-03-22 02:06:21 +01:00
Simon Wanner 145efbe07a LibWeb: Apply the CSS transform-origin property
We don't have transform-box yet, so this applies to the border-box
for now.

This also makes us pass a couple Web Platform Tests as well :^)
For example:
https://wpt.live/css/css-transforms/css3-transform-scale-002.html
2022-03-22 02:06:21 +01:00
Simon Wanner 63055ff5ad LibWeb: Parse the CSS transform-origin property
This is almost a PositionStyleValue, but it's serialized differently,
so let's use a StyleValueList with 2 length-percentage values.
2022-03-22 02:06:21 +01:00
Andreas Kling 8ab25f8d8c LibWeb: Implement Range.surroundContents(newParent)
Here goes another Acid3 point :^)
2022-03-21 23:28:46 +01:00
Karol Kosek 686507a38f LibWeb: Translate table cells by their top left border 2022-03-21 21:55:21 +01:00
Karol Kosek 20730c164c LibWeb: Include table cell border widths when calculating cell rects
Previously, table cells would overlap when they had CSS border or
padding properties defined.
2022-03-21 21:55:21 +01:00
Andreas Kling 68f3feb1d1 LibWeb: Fix two spec transcription mistakes in live range updating
This scores us another point on Acid3. :^)
2022-03-21 21:11:38 +01:00
Timothy Flynn 57296393ed LibWeb: Begin implementing SVGRectElement's SVGAnimatedLength attributes 2022-03-21 21:04:39 +01:00
Timothy Flynn 7a6b4e33ba LibWeb: Implement the SVGAnimatedLength type 2022-03-21 21:04:39 +01:00
Timothy Flynn ebf3829f1c LibWeb: Begin implementing the SVGLength type
There are a few unimplemented features for this type:

1. The value setter should throw a DOMException if it is invoked on an
   SVGLength that was declared readonly in another IDL file.

2. SVG::AttributeParser does not parse unit types when it parses lengths
   so all SVGLength will have an "unknown" unit for now.

3. Due to (2), methods which convert between units are unimplemented.
2022-03-21 21:04:39 +01:00
Andreas Kling 4d49c607f8 LibWeb: Fix spec transcription mistake in Range.extractContents()
The spec text and code didn't match up.

Thanks to Tim for spotting this! :^)
2022-03-21 21:01:47 +01:00
Andreas Kling ac8a8459d0 LibWeb: Don't allow setting Range start/end to document being destroyed 2022-03-21 20:37:49 +01:00
Andreas Kling 3b6323340a LibWeb: Update live ranges on Node insertion and removal
Taking care of some old FIXMEs :^)
2022-03-21 20:26:35 +01:00
Andreas Kling 1254758b00 LibWeb: Update live DOM ranges on Text and CharacterData mutations
Taking care of the FIXMEs I added in earlier patches. :^)
2022-03-21 20:06:59 +01:00
Andreas Kling c74b1b6d65 LibWeb: Implement Range.insertNode(node) 2022-03-21 19:14:50 +01:00
Andreas Kling d2f9f8bd4f LibWeb: Implement Text.splitText(offset)
With FIXMEs about updating live ranges, but still.
2022-03-21 19:14:50 +01:00
Andreas Kling 8bc3f4c186 LibWeb: Fix logic mistakes in Range stringification
We were passing the wrong length argument to substring() when
stringifying a range where start and end are the same text node.

Also, make sure we visit all the contained text nodes when appending
them to the output.

This was caught by an Acid3 subtest.
2022-03-21 19:14:50 +01:00
Andreas Kling 16f4c76da6 LibWeb: Implement Range.extractContents()
Another point on Acid3 coming through! :^)
2022-03-21 18:06:28 +01:00
Andreas Kling 24e25fe3d0 LibWeb: Add CharacterData.replaceData(offset, count, data)
Note that we don't queue mutation records or update live ranges yet,
I've left those as FIXMEs.
2022-03-21 18:05:20 +01:00
Andreas Kling e50c7de1b2 LibWeb: Add CharacterData.substringData(offset, count) 2022-03-21 17:20:42 +01:00
Andreas Kling 394cd77467 LibWeb: Implement stringifier for DOM Range :^) 2022-03-21 16:29:19 +01:00
Andreas Kling c8bdac8736 LibWeb: Implement HTMLTableRowElement.{rowIndex,sectionRowIndex}
Another point on Acid3. :^)
2022-03-21 16:15:33 +01:00
Andreas Kling 1206dd2215 LibWeb: Make parse_html_length() accept floating point numbers
This makes stuff like <img width="12.5"> work. This code is not great,
so I've left a FIXME about improving it.
2022-03-21 15:58:21 +01:00
Andreas Kling 196a3eb239 LibWeb: Ignore invisible boxes and stacking contexts during hit testing 2022-03-21 15:43:37 +01:00
Andreas Kling df8ef03957 LibWeb: Pick up the CSS "visibility" property an honor it when painting 2022-03-21 15:42:57 +01:00
Andreas Kling 01662b2320 LibWeb: Remove now-unused PaintableBox::for_each_child_in_paint_order() 2022-03-21 14:57:00 +01:00
Andreas Kling a779ace6a1 LibWeb: Don't compute fragment absolute rect twice while hit testing 2022-03-21 13:03:33 +01:00
Andreas Kling 996f3228a2 LibWeb: Fix O(n^2) traversal in hit testing
We already walk the entire paint tree within each stacking context in
the main hit testing function (StackingContext::hit_test()), so there's
no need for each individual paintable to walk its own children again.

By not doing that, we remove a source of O(n^2) traversal which made hit
testing on deeply nested web pages unbearably slow.
2022-03-21 13:03:33 +01:00
Andreas Kling f7cfd47b48 LibWeb: Add Paintable::dom_node() convenience accessor 2022-03-21 13:03:33 +01:00
Andreas Kling b64b5fa8bd LibWeb: Add Painting::HitTestResult::dom_node()
This is a convenience accessor to avoid having to say this everywhere:

    result.paintable->layout_node().dom_node()

Instead, you can now do:

    result.dom_node()
2022-03-21 13:03:33 +01:00
Andreas Kling 0ba785894c LibWeb: Make hit testing functions return Optional<HitTestResult>
Using "HitTestResult with null paintable" as a way to signal misses was
unnecessarily confusing. Let's use Optional instead. :^)
2022-03-21 13:03:33 +01:00
Andreas Kling 8c88ee1165 LibWeb: Only invalidate stacking context tree for opacity/z-index change
I came across some websites that change an elements CSS "opacity" in
their :hover selectors. That caused us to relayout on hover, which we'd
like to avoid.

With this patch, we now check if a property only affects the stacking
context tree, and if nothing layout-affecting has changed, we only
invalidate the stacking context tree, causing it to be rebuilt on next
paint or hit test.

This makes :hover { opacity: ... } rules much faster. :^)
2022-03-21 13:03:33 +01:00
Andreas Kling 59afdb959f LibWeb: Build stacking context tree lazily
There's no actual need to build the stacking context tree before
performing layout. Instead, make it lazy and build the tree when it's
actually needed for something.

This avoids a bunch of work in situations where multiple synchronous
layouts are forced (typically by JavaScript) without painting or hit
testing taking place in between.

It also opens up for style invalidations that only target the stacking
context tree.
2022-03-21 13:03:33 +01:00
Hendiadyoin1 89086c337c LibWeb: Fix constness of return type from StyleRule::block()
We want to return a view to a constant object, not a constant view,
which we can implicitly copy to get a mutable reference to the object.

Clang-Tidy helpfully pointed this out.
2022-03-21 12:49:00 +01:00
Hendiadyoin1 2f2efc4775 LibWeb: Use llround in CSS::Token::to_closest_integer
This should be equivalent, and much shorter than a clamp and static_cast
2022-03-21 12:49:00 +01:00
Hendiadyoin1 fff12847d5 LibWeb: Pull out larger parsing parts from Parser::parse_simple_selector
This lowers its cognitive complexity from 271 to under 100.
The new `parse_pseudo_simple_selector` still has a complexity of 114.
2022-03-21 12:49:00 +01:00
Hendiadyoin1 397d8b4aca LibWeb: Use a switch-statement on the delimiter for MatchType selection
... in Parser::parse_simple_selector
2022-03-21 12:49:00 +01:00
Hendiadyoin1 19cca57f8a LibWeb: Condense Delim checks in Parser::parse_simple_selector
This also removes some else-after-returns and adds some const qualifiers
2022-03-21 12:49:00 +01:00
Hendiadyoin1 3a162d2394 LibWeb: Add StyleComponentValueRule::is_token() helper 2022-03-21 12:49:00 +01:00
Hendiadyoin1 3f8347718c LibWeb: Use a u32 for a delim tokens value
The spec says:
> <delim-token> has a value composed of a single code point.

So using StringView is a bit overkill.
This also allows us to use switch statements in the future.
2022-03-21 12:49:00 +01:00
Hendiadyoin1 6119783027 LibWeb: Don't copy Tokens twice on StyleBlockRule initialization 2022-03-21 12:49:00 +01:00
Hendiadyoin1 6e921ae304 LibWeb: Move passed string in MimeType constructor
This was pointed out by Clang-Tidy and should avoid an allocation.
2022-03-21 10:48:17 +01:00
Hendiadyoin1 6a95df2526 LibTextCodec: Don't allocate Strings on encoding normalisation
This ripples down to LibWeb's HTML and XHR decoders, which therefore
become less allocation heavy.
2022-03-21 10:48:17 +01:00
Simon Wanner e154c2c2ca LibWeb: Implement "has element in select scope" per-spec
The HTML Specification is quite tricky in this case.
Usually "have a particular element in <x> scope" mentions
"consisting of the following element types:", but in this case it's
"consisting of all element types except the following:"

Thanks to @AtkinsSJ for spotting this difference
2022-03-21 10:47:46 +01:00
Simon Wanner 1d55437a76 LibWeb: Ignore invalid encodings in Content-Type headers 2022-03-21 10:47:46 +01:00
Simon Wanner 917d06fa30 LibGfx: Clamp coordinates for bilinear blending correctly
Clamp these coordinates based on the src_rect's top/right/bottom/left
instead of assuming src_rect is positioned at 0,0
2022-03-21 01:48:21 +01:00
Andreas Kling 8f1a3f7878 LibWeb: Tweak our User-Agent string
- Switch from "Mozilla/4.0" to "Mozilla/5.0" to match other browsers.
- Remove references to KHTML and Gecko.
- Identify ourselves as "LibWeb+LibJS/1.0 Browser/1.0"

New UA: "Mozilla/5.0 (SerenityOS; x86_64) LibWeb+LibJS/1.0 Browser/1.0"
2022-03-20 23:16:22 +01:00
Brian Gianforcaro 16bee0ba79 Everywhere: Move js/web/wasm tests under /home/anon/Tests 2022-03-20 22:20:59 +01:00
Brian Gianforcaro 67fc81a65a Everywhere: Move cpp-tests under /home/anon/Tests 2022-03-20 22:20:59 +01:00
Andreas Kling d7492927e9 LibWeb: Avoid some layouts in getComputedStyle() property getter
For CSS properties that are known to not affect layout, we can avoid
doing a layout before returning their current resolved value.

It should be enough to only update style for the target element here,
but we don't currently have a mechanism for that.
2022-03-20 22:07:59 +01:00
Brian Gianforcaro 0998074230 LIbVT: Fix copy paste regression I introduced in #13102
I accidentally inverted this behavior in commit 2042d909972

Previously it read:
```cpp
constexpr bool is_untouched() const { return !(flags & Touched); }
```
2022-03-20 21:50:58 +01:00
thankyouverycool b8cc18896f LibGUI+FontEditor: Add context menu for editor actions
GlyphMapWidget now reports context menu requests when secondary
clicking the map. This also adds a new Select All action and updates
the Copy Character action to work on multi-glyph selections. Glyph
navigation actions have been moved to a separate Go menu, as is
common in other apps.
2022-03-20 20:00:25 +01:00
thankyouverycool 42284a1550 FontEditor: Change flip action shortcuts to Ctrl+Shift+{Q,W}
To not interfere with the command palette.
2022-03-20 20:00:25 +01:00
thankyouverycool cdd1bc64f6 FontEditor: Set width on copy only if source glyph is present
Fixes empty glyphs copying as present in fixed-width fonts.
2022-03-20 20:00:25 +01:00
thankyouverycool 212817ea20 FontEditor: Restore selections on undo/redo actions
This makes navigating undo history a lot easier to follow.
Individual glyph alterations now reset selection size if necessary
to save space.
2022-03-20 20:00:25 +01:00
thankyouverycool df443863bd LibGUI: Add set_selection() convenience helper to GlyphMapWidget 2022-03-20 20:00:25 +01:00
thankyouverycool 5c6326ae23 LibGUI: Add automatic scrolling to GlyphMapWidget
Similar to TextEditor, GlyphMapWidget now automatically scrolls
when dragging a selection outside its boundaries.
2022-03-20 20:00:25 +01:00
thankyouverycool a26e71a137 LibGUI: Use system theme when painting GlyphMapWidget focus outline 2022-03-20 20:00:25 +01:00
thankyouverycool cf13cf7225 LibGUI: Reset GlyphMapWidget only if clicking a new active glyph
Fixes an edge case in which mousing down on the active glyph within
a larger selection would reset the selection but fail to update the
glyph map. Now we can grow or shrink the selection by dragging the
active glyph even after an initial selection is made.
2022-03-20 20:00:25 +01:00
thankyouverycool 4f7b37de9c LibGUI: Use nicer API for contrained positions in GlyphMapWidget
Forgot about this little guy. Functionally the same here, but more
robust if scrollbars change.
2022-03-20 20:00:25 +01:00
thankyouverycool 54634fc2df LibGUI: Remove unnecessary MouseEvent calls in GlyphMapWidget
And pass KeyEvents directly to the relevant predecessor.
2022-03-20 20:00:25 +01:00
Simon Wanner dc8ac83f77 Browser: Size the content box in "Box Model" based on its text 2022-03-20 19:57:09 +01:00
Simon Wanner 69fc7009bf LibWeb: Grey out invisible nodes in the DOM inspector
This makes it easier to navigate large DOM trees where
some nodes have display: none
2022-03-20 19:57:09 +01:00
Tim Schumacher a128d4931d Base: Install symlinks instead of aliasing rgrep and egrep 2022-03-20 11:50:47 -07:00
Tim Schumacher 4a5d1db7f6 grep: Recognize mode based on the program name 2022-03-20 11:50:47 -07:00
Andreas Kling 8cc757b92b LibWeb: Always call Layout::Box::did_set_rect()
Since paintables have a default content size of 0x0, we were neglecting
to notify the corresponding layout node about size changes, if the used
content size came out to 0x0.

This fixes an issue where resizing an iframe to 0x0 didn't take effect.
2022-03-20 19:03:43 +01:00
Andreas Kling 07a4d590dd LibWeb: Layout browsing context parent before its children
When updating layout inside a nested browsing context, try first to
perform layout in the parent document (the nested browsing context's
container's document).

This ensures that nested browsing contexts have the right viewport
dimensions in case the parent layout changes them somehow.
2022-03-20 19:03:43 +01:00
Andreas Kling 6ac3bf2982 LibWeb: Don't crash in BrowsingContextContainer::content_document()
Instead of choking on the VERIFY(document), let's just return null if
there's no active document for now. This is incorrect, but sidesteps
a frequent crash that happens on content with iframes.

I've left a FIXME about removing the hack once it's no longer needed.
2022-03-20 19:03:43 +01:00
Andreas Kling d03680a9e7 LibWeb: Always defer callbacks in ResourceClient::set_resource()
Previously, we'd invoke the load/fail callbacks synchronously for
resources that were already loaded and cached.

This patch uses deferred_invoke() in the already-loaded case to ensure
that we always invoke these callbacks in a consistent manner.

This isn't to fix a specific issue, but rather because I kept seeing
these callbacks being invoked synchronously on top of an already-tall
call stack, and it was hard to reason about what was going on.
2022-03-20 19:03:43 +01:00
Sam Atkins d60b3be29a LibWeb: Implement the :focus-within selector
This matches if it has focus, or any nodes inside it do.
2022-03-20 17:35:31 +00:00
Andreas Kling 02497888a6 LibWeb: Ignore linked stylesheets with MIME types other than text/css
This makes the "Acid3" text on ACID3 not show up in red. :^)
2022-03-20 17:20:59 +01:00
Andreas Kling 2b7775118d LibWeb: Clear element.style when the "style" attribute is removed
We were hanging on to element inline style, even after the style
attribute was removed. This made inline style sticky and impossible to
remove. This patch fixes that. :^)
2022-03-20 16:31:40 +01:00
Andreas Kling 485ef276bd LibWeb: Invalidate style & layout inside iframes when they change size 2022-03-20 16:25:54 +01:00
Andreas Kling 618b857457 LibWeb: Evaluate @media CSS rules when updating style
In case we have new @media rules, we need to make sure we've evaluated
them before actually recomputing styles for the document.
2022-03-20 16:19:47 +01:00
Andreas Kling 80ed2ab557 LibWeb: Implement HTMLOptionElement.selected 2022-03-20 16:19:47 +01:00
Andreas Kling a606345576 LibWeb: Implement HTMLSelectElement.selectedIndex 2022-03-20 16:19:47 +01:00
Ali Mohammad Pur 5dc0855489 Spreadsheet: Use the correct top-center alignment when set to Top+Center 2022-03-20 13:20:33 +00:00
Ali Mohammad Pur 292e459901 Spreadsheet: Allow the user to format Identity cells via JS expressions
Also add some hints as to what the format field expects as it would be
very confusing otherwise.
2022-03-20 13:20:33 +00:00
Ali Mohammad Pur 8919e4b2b6 Spreadsheet: Only update the selection on primary mousedown
Otherwise we'd end up clearing the selected rect before doing anything
with it if the user right-clicks on it.
2022-03-20 13:20:33 +00:00
Ali Mohammad Pur 0d302516d5 Spreadsheet: Skip over "invalid" saved cell values
These can be generated by saving something that's not serialisable (e.g.
functions), skip over them and let the load logic reevaluate them when
needed.
2022-03-20 13:20:33 +00:00
safarp b0b8d14a2c LibC: Automatically append null terminator in vswprintf 2022-03-20 08:40:36 -04:00
Andreas Kling 96db8d64f6 LibWeb: Include entire border box when painting stacking context layer
For stacking contexts that have opacity between 0 and 1, and also
contexts with a 2D transform, we first paint them into a temporary layer
buffer. Then we blend that buffer with the contents in one go.

Before this patch, we were only drawing the content box of the stacking
context into this layer buffer, which led to padding and borders missing
from elements painted this way.
2022-03-20 13:36:45 +01:00
Andreas Kling 159d4d772a LibWeb: Assign the used top/bottom border widths to inline-block boxes
We were forgetting to update these values, which led to missing top and
bottom borders for elements with display:inline-block.
2022-03-20 13:36:45 +01:00
Andreas Kling bdd42c9b0e LibWeb: Add basic support for :lang() CSS selector
This doesn't have parsing support for multiple languages in the same
selector. Support for language subcodes is not great either. But it
does do the basics.
2022-03-20 13:36:45 +01:00
Andreas Kling 5d672717aa LibWeb: Add a barebones SVGTextContentElement with getNumberOfChars() 2022-03-20 13:36:45 +01:00
sin-ack e212514bbf LookupServer: Return with failure result when lookup fails
This was missed in 4ca0669d1e and the
error condition would still fall through to an ErrorOr unwrapping which
caused a crash.
2022-03-20 12:09:31 +03:30
Ali Mohammad Pur 82a515a748 LibWasm: Increase the arbitrary local value count per type limit
It was arbitrary, it's still arbitrary, but now it's funny too :^)
2022-03-20 10:44:32 +03:30
Ali Mohammad Pur a6c4b6848b LibWasm: Use some template magic to greatly simplify stack validation
This also auto-fixes a few bugs that were present before as we were
manually checking the stack.
2022-03-20 10:44:32 +03:30
Ali Mohammad Pur 18c5b0f1cc LibWasm: Allow Limits max value to be equal to 2^k-1
That value fits in k bits, so we should allow it.
2022-03-20 10:44:32 +03:30
Ali Mohammad Pur a5958b5f45 LibJS: Allow 'expect().fail("some random string")' in test-js
Previously fail() wanted the fail object to be a callable, allow it to
be a string also.
2022-03-20 10:44:32 +03:30
Simon Wanner 1d95745901 LibWeb: Implement the rest of the Adoption Agency Algorithm
This gets us 2 points on html5test.com :^)
- Before: https://html5te.st/4cf57659bc08272e (208)
- After: https://html5te.st/fb8a9259bda1c115 (210)
2022-03-20 02:52:37 +01:00
Florent Castelli e165ae5b60 LibHTTP+LibTLS: Better HTTPS Socket EOF detection
When the server doesn't signal the Content-Length or use a chunked mode,
it may just terminate the connection after sending the data.
The TLS sockets would then get stuck in a state with no data to read and
not reach the disconnected state, making some requests hang.

We know double check the EOF status of HTTP jobs after reading the
payload to resolve requests properly and also mark the TLS sockets as
EOF after processing all the data and the underlying TCP socket reaches
EOF.

Fixes #12866.
2022-03-20 01:01:40 +01:00
Andreas Kling 166cd8e881 Browser: Turn on content filtering by default :^) 2022-03-20 01:01:14 +01:00
Andreas Kling 6b5f0d11ce LibGfx: Fix draw_anti_aliased_line() for steep lines with "OnlyEnds"
Regression from ab794a199b.
2022-03-19 22:32:38 +01:00
Michiel Visser e07ec02470 LibCrypto: Move all elliptic curve private methods into .cpp
All the elliptic curve implementations had a long list of private
methods which were all stored in a single .cpp file. Now we simply use
static methods instead.
2022-03-20 00:51:50 +03:30
Michiel Visser 66d99c83d9 LibCrypto+LibTLS: Add SECP256r1 support to LibTLS
Add the required methods to SECP256r1 to conform to the EllipticCurve
virtual base class. Using this updated version of SECP256r1, support in
LibTLS is implemented.
2022-03-20 00:51:50 +03:30
Michiel Visser c1b041e761 LibCrypto+LibTLS: Generalize the elliptic curve interface
These changes generalize the interface with an elliptic curve
implementation. This allows LibTLS to support elliptic curves generally
without needing the specifics of elliptic curve implementations.

This should allow for easier addition of other elliptic curves.
2022-03-20 00:51:50 +03:30
Tim Schumacher 21bbff0349 grep: Properly update match state when handling files 2022-03-19 22:05:40 +01:00
Tim Schumacher c1004b095e grep: Adapt maximum line size depending on file size
Otherwise, we would never stop trying to fetch new lines if the next
newline is found beyond a range that the (default sized) buffer can
hold.
2022-03-19 22:05:40 +01:00
Andreas Kling ab794a199b LibGfx: Transcribe "Xiaolin Wu's line algorithm" more accurately
This improves the appearance of anti-aliased lines significantly.
2022-03-19 22:04:43 +01:00
Andreas Kling d09e8978c2 LibGfx: Be more aggressive when splitting bezier curves
Significantly reduce the tolerance when splitting bezier curves. This
gives a smoother final appearance at the cost of drawing more lines.
2022-03-19 22:04:43 +01:00
Andreas Kling 0b861e0c9d LibWeb: Make document-level style invalidation fast
Add a flag to DOM::Document that means the whole document needs a style
update. This saves us the trouble of traversing the entire DOM to mark
all nodes as needing a style update.
2022-03-19 22:04:43 +01:00
Andreas Kling f87edd4c14 LibWeb: Don't crash when detached document tries to use system palette
If the current Document is not attached to a Web::Page for whatever
reason, but we're trying to look up a color from the system palette,
let's just fail the lookup instead of crashing the process.
2022-03-19 22:04:43 +01:00
Andreas Kling aa45cdf71d LibWeb: Give StyleComputer a helper for getting the current viewport 2022-03-19 22:04:43 +01:00
Ali Mohammad Pur 3c1815a0d9 pro: Simplify the progress report logic a bit
The previous progress report changed far too fast to be meaningful,
limit the report time to 100ms, and avoid spamming the terminal with
report data that's not even readable.
Also remove some dbgln()'s.
2022-03-19 22:04:35 +01:00
Ali Mohammad Pur 6386554cd9 LibProtocol: Don't block indefinitely in stream_into's on_ready_to_read
Blocking there will lead to blocking the entire event loop, so just try
to read until something has been read or we hit EOF, this allows the
event loop to continue to deliver other events while a long download is
happening.
2022-03-19 22:04:35 +01:00
Ali Mohammad Pur dff8344336 RequestServer: Keep the EnsureConnection job alive until it finishes
Fixes #12906.
2022-03-19 22:04:35 +01:00
Ali Mohammad Pur adff9a96a6 pro: Optionally follow 3xx responses with a Location header
This is not enabled by default, and can be enabled by passing `-l`.
Fixes #12714.
2022-03-19 22:04:35 +01:00
Maciej b172bf4f84 LibCore: Add text/css mime type
Firefox throws out css files with MIME type not being "text/css", so
let's add it to make attached CSS working on WebServer. :^)
2022-03-19 22:03:51 +01:00
Maciej 273b69f947 LibCore: Add some extensions that are text/plain
C++ source/header files, GML, IPC, CMake and various Serenity config
files.
2022-03-19 22:03:51 +01:00
Maciej 933a717f3b LibCore: Make application/octet-stream the default guessed MIME type
This MIME type can be associated with every file, text/plain only with
plaintext files.

This makes browsers (e.g Firefox) properly displaying download progress
when downloading files in WebServer :^)
2022-03-19 22:03:51 +01:00
Maciej c1ca009939 WebServer: Add Content-Length header to HTTP responses
This makes the browser know how much data it should expect.
2022-03-19 22:03:51 +01:00
Itamar fc10bc3cb2 HackStudio: Search for libraries definitions in Userland/
Previously, the ProjectBuilder searched for serenity library definitions
under Userland/Libraries.

However, not all libraries are defined there. For example, LibShell is
under Userland/Shell.
2022-03-19 22:02:44 +01:00
Luke Wilde 096d2bb772 LibJS/Bytecode: Make construct Call throw if callee isn't a constructor 2022-03-19 22:01:52 +01:00
Luke Wilde eac5534ce4 LibJS/Bytecode: Add support for new.target 2022-03-19 22:01:52 +01:00
Karol Kosek fd235d8a06 LibWeb: Don't put a backslash after escape sequences in text-like tokens
Previously, a string token like '\41' would be tokenized to 'A\'. This
could be seen on Wikipedia headlines.
2022-03-19 13:10:00 -07:00
Linus Groh ff3256792d LibJS: Change nanoseconds_to_days() argument from a JS to Crypto BigInt
This is an editorial change in the Temporal spec.

See: https://github.com/tc39/proposal-temporal/commit/0b1346c
2022-03-19 19:28:49 +00:00
Linus Groh 039cb9f189 LibJS: Change nanoseconds_to_days() result from a JS to Crypto BigInt
Similar to the preceding commit(s).
2022-03-19 19:28:49 +00:00
Linus Groh 360c65e92b LibJS: Change balance_duration() nanoseconds from a JS to Crypto BigInt
Similar to the preceding commit.
2022-03-19 19:28:49 +00:00
Linus Groh 48856498f0 LibJS: Change total_duration_nanoseconds() from JS to Crypto BigInts
This removes a bunch of silly wrapping and unwrapping of Crypto
SignedBigInteger values in JS BigInt objects, which isn't even intended
by the spec - it just wants us to take an integer value, not a BigInt
specifically. Nice opportunity to remove a couple of allocations. :^)
2022-03-19 19:28:49 +00:00
Sam Atkins 1ba6974b60 cmp: Implement cmp(1) 2022-03-19 11:01:49 -07:00
Sam Atkins 25c2a76d10 LibMain: Add the ability to configure the exit code on error
Some POSIX utilities are specified to return a specific value on error,
which is not 1. `Main::set_return_code_for_errors()` lets you set it to
that value.
2022-03-19 11:01:49 -07:00
Tim Schumacher 13ef8469da Utilities: Add support for setting permissions to install 2022-03-19 10:26:33 -07:00
Tim Schumacher 9de742e321 Utilities: Add support for multiple sources to install 2022-03-19 10:26:33 -07:00
Tim Schumacher 62f0fa818d LibCore: Add File::ensure_directories() 2022-03-19 10:26:33 -07:00
Tim Schumacher f44cd168b0 Utilities: Add the -c option to install 2022-03-19 10:26:33 -07:00
Andreas Kling cbd343dced LibWeb: Only delay "load" event for script elements that load something
We shouldn't delay the load event for scripts that we're completely
refusing to run anyway. Also, for scripts that have inline text content,
we don't need to delay them either, as they will become ready before
returning from "prepare script".

This makes the "load" event finally fire on lots of websites, including
Wikipedia. :^)
2022-03-19 16:11:36 +01:00
Andreas Kling c1f0d21bbe LibWeb: Rename the LayoutMode enum values and explain them
The old mode names, while mechanically accurate, didn't really reflect
their relationship to the CSS specifications.

This patch renames them as follows:

    Default => Normal
    AllPossibleLineBreaks => MinContent
    OnlyRequiredLineBreaks => MaxContent

There's also now an explainer comment with the LayoutMode enum about the
specific implications of layout in each mode.
2022-03-19 15:46:15 +01:00
Andreas Kling ceb055a75e LibWeb: Don't delay document "load" event for non-loading link elements
If we try loading a link element but it's reject for whatever reason
(broken URL, content filtering, etc.) make sure we don't mark that link
element as delaying the document load event.
2022-03-19 15:04:48 +01:00
Andreas Kling 2c9dfadb21 LibWeb: Don't delay document "load" event for unclosed script tags
We previously had a bug where markup with unclosed script tags caused
the document load event to be delayed indefinitely. Fix this by only
marking script elements as delaying the load event once we encounter
the script end tag.
2022-03-19 15:04:48 +01:00