summaryrefslogtreecommitdiff
path: root/Userland/Libraries
AgeCommit message (Collapse)Author
2022-02-12LibTextCodec: Add decoder function that overrides given decoder on BOMLuke Wilde
This functions takes a user-provided decoder and will only use it if no BOM is in the input. If there is a BOM, it will ignore the given decoder and instead decode the input with the appropriate Unicode decoder for the detected BOM. This is only to be used where it's specifically needed, for example XHR uses this for compatibility with deployed content. As such, it has an obnoxious name to discourage usage.
2022-02-12LibTextCodec: Add BOM snifferLuke Wilde
This takes the input and sniffs it for a BOM. If it has the UTF-8 or UTF-16BE BOM, it will return their respective decoder. Currently we don't have a UTF-16LE decoder, so it will assert TODO if it detects a UTF-16LE BOM. If there is no recognisable BOM, it will return no decoder.
2022-02-12LibWeb: Implement XMLHttpRequest.overrideMimeTypeLuke Wilde
This allows you to ignore the Content-Type returned by the server and always parse the content as if it's the given MIME type. This will currently be used for allowing you to override the charset of text responses.
2022-02-12LibWeb: Implement spec-compliant MIME type struct and parserLuke Wilde
This will be used by XHR to extract the Content-Type MIME type to retrieve the charset.
2022-02-12LibC: Stub out fmemopen()Ali Mohammad Pur
2022-02-12LibPthread: Add PTHREAD_CANCELEDAli Mohammad Pur
This is just the expected return value of pthread_join() when it fails.
2022-02-12LibWeb: Add support for 'arraybuffer' message types on WebSocketsserenitydev
2022-02-12LibWeb: Ignore malformed at-rules in CSS parserGuilherme Gonçalves
Fixes #12405.
2022-02-12LibWebSocket: Don't try to send empty payload inside of frameDerpyCrabs
According to RFC 6455 sections 5.5.2-5.5.3 Ping and Pong frames can have empty "Application data" that means payload can be of size 0. This change fixes failed "buffer.size()" assertion inside of Core::Stream::write_or_error by not trying to send empty payload in WebSocket::send_frame.
2022-02-12LibHTTP: Make reason phrase of HTTP response's status line optionalDerpyCrabs
According to rfc2616 section 6.1 the text of reason phrase is not defined and can be replaced by server. Some servers (for example http://linux.org.ru) leave it empty. This change fixes parsing of HTTP responses with empty reason phrase.
2022-02-12LibHTTP: Remove redundant can_read_without_blocking callWesley Moore
When entering the InBody state LibHTTP performs a can_read_without_blocking check, which is duplicated immediately afterwards. This initial call is removed.
2022-02-12LibHTTP: Remove attempt to read extra line after response headersWesley Moore
When LibHTTP encountered the blank line between the headers and the body in a HTTP response it made a call the m_socket->can_read_line(). This ultimately tried to find a newline in the stream. If the response body was small and did not contain a new line then the request would hang. The call to m_socket->can_read_line() is removed so that the code is able to progress into the body reading loop.
2022-02-11LibWeb: Rename Layout::Box absolute rect helpersAndreas Kling
- padded_rect() -> absolute_padding_box_rect() - bordered_rect() -> absolute_border_box_rect()
2022-02-11LibWeb: Remove unused functions from Layout::BoxAndreas Kling
2022-02-11LibWeb: Clear the path of a SVGPathElement if the attribute changesSam Atkins
Otherwise, modifying the `d` attribute would not cause any visual changes to the path.
2022-02-11LibWeb: Make SVG AttributeParser::parse_path_data() staticSam Atkins
This is mostly a style thing, but it matches the other APIs.
2022-02-11LibWeb: Use StringView instead of String in SVG::AttributeParserSam Atkins
This saves copying the string data, since the AttributeParser is always temporary.
2022-02-11LibWeb: Add SVG `<polygon>` element and test case :^)Sam Atkins
2022-02-11LibWeb: Add SVG `<polyline>` element and test case :^)Sam Atkins
2022-02-11LibWeb: Add SVG `<line>` element and test case :^)Sam Atkins
2022-02-11LibWeb: Add SVG `<ellipse>` element and test case :^)Sam Atkins
2022-02-11LibWeb: Add SVG `<circle>` element and test case :^)Sam Atkins
2022-02-11LibWeb: Add SVG `<rect>` element and test case :^)Sam Atkins
2022-02-11LibGfx: Add Path::[horizontal,vertical]_path_to()Sam Atkins
The SVG spec describes some path operations using these, so we might as well have them. :^)
2022-02-11LibWeb: Expose SVG length/coordinate parsing methodsSam Atkins
This is all still quite ad-hoc. Eventually these will both need to support units (like with CSS Lengths) but for now we can continue only using numbers.
2022-02-11LibWeb: Move SVG::PathDataParser into its own file and rename itSam Atkins
I've chosen the name `AttributeParser` since it parses data from attributes. Rather than duplicate the parsing of numbers and other basic types, let's make use of this existing parsing code for parsing the data for `<line>`, `<polyline>`, etc.
2022-02-11LibWeb: Rename SVGPathBox -> SVGGeometryBoxSam Atkins
This fits better since it's now used by all SVGGeometryElements.
2022-02-11LibWeb: Move SVGPathElement methods into SVGGeometryElementSam Atkins
From the spec: > Interface SVGGeometryElement represents SVG elements whose rendering > is defined by geometry with an equivalent path, and which can be > filled and stroked. This includes paths and the basic shapes. - https://svgwg.org/svg2-draft/types.html#InterfaceSVGGeometryElement Making them all create an SVGPathBox, and return a Path from get_path(), means we can implement the "basic shapes" using the path system we already have. :^)
2022-02-11LibWeb: Add const versions of SVGBox::dom_node() and friendsSam Atkins
2022-02-11LibHTTP: Don't copy payload slices in flush_received_buffers()Andreas Kling
Instead of using ByteBuffer::slice() to carve off the remaining part of the payload every time we flush a part of it, we now keep a sliding span (ReadonlyBytes) over it.
2022-02-11LibELF: Implement support for DT_RELR relative relocationsDaniel Bertalan
The DT_RELR relocation is a relatively new relocation encoding designed to achieve space-efficient relative relocations in PIE programs. The description of the format is available here: https://groups.google.com/g/generic-abi/c/bX460iggiKg/m/Pi9aSwwABgAJ It works by using a bitmap to store the offsets which need to be relocated. Even entries are *address* entries: they contain an address (relative to the base of the executable) which needs to be relocated. Subsequent even entries are *bitmap* entries: "1" bits encode offsets (in word size increments) relative to the last address entry which need to be relocated. This is in contrast to the REL/RELA format, where each entry takes up 2/3 machine words. Certain kinds of relocations store useful data in that space (like the name of the referenced symbol), so not everything can be encoded in this format. But as position-independent executables and shared libraries tend to have a lot of relative relocations, a specialized encoding for them absolutely makes sense. The authors of the format suggest an overall 5-20% reduction in the file size of various programs. Due to our extensive use of dynamic linking and us not stripping debug info, relative relocations don't make up such a large portion of the binary's size, so the measurements will tend to skew to the lower side of the spectrum. The following measurements were made with the x86-64 Clang toolchain: - The kernel contains 290989 relocations. Enabling RELR decreased its size from 30 MiB to 23 MiB. - LibUnicodeData contains 190262 relocations, almost all of them relative. Its file size changed from 17 MiB to 13 MiB. - /bin/WebContent contains 1300 relocations, 66% of which are relative relocations. With RELR, its size changed from 832 KiB to 812 KiB. This change was inspired by the following blog post: https://maskray.me/blog/2021-10-31-relative-relocations-and-relr
2022-02-11LibConfig: Rename pledge_domains(String) => pledge_domain(String)Vitaly Dyachkov
pledge_domains() that takes only one String argument was specifically added as a shortcut for pledging a single domain. So, it makes sense to use singular here.
2022-02-11LibWeb: Remove CascadeOrigin::Any enum valueAndreas Kling
Looks like I removed all uses of this value, but not the value itself! Thanks to Idan for pointing that out. :^)
2022-02-11LibWeb: Remove unused CascadeOrigin::AnyAndreas Kling
This was an ad-hoc concept from before we implemented the CSS cascade.
2022-02-10LibSQL: Return unimplemented errors from unimplemented MATCH expressionsTimothy Flynn
A bit friendlier than crashing the entire SQLService process.
2022-02-10LibSQL: Remove the now-unused ExecutionContext::result objectTimothy Flynn
The INSERT and SELECT statements set up this object for any expression evaluation to indicate errors. This is no longer needed.
2022-02-10LibSQL: Convert SQL expression evaluation to use ResultOrTimothy Flynn
Instead of setting an error in the execution context, we can directly return that error or the successful value. This lets all callers, who were already TRY-capable, simply TRY the expression evaluation.
2022-02-10LibSQL+SQLServer: Introduce and use ResultOr<ValueType>Timothy Flynn
The result of a SQL statement execution is either: 1. An error. 2. The list of rows inserted, deleted, selected, etc. (2) is currently represented by a combination of the Result class and the ResultSet list it holds. This worked okay, but issues start to arise when trying to use Result in non-statement contexts (for example, when introducing Result to SQL expression execution). What we really need is for Result to be a thin wrapper that represents both (1) and (2), and to not have any explicit members like a ResultSet. So this commit removes ResultSet from Result, and introduces ResultOr, which is just an alias for AK::ErrorOrr. Statement execution now returns ResultOr<ResultSet> instead of Result. This further opens the door for expression execution to return ResultOr<Value> in the future. Lastly, this moves some other context held by Result over to ResultSet. This includes the row count (which is really just the size of ResultSet) and the command for which the result is for.
2022-02-10LibCore: Convert AnonymousBuffer to use System::anon_createkleines Filmröllchen
2022-02-10LibCore/System: Add anon_create syscall wrapperkleines Filmröllchen
This wrapper is particularly helpful as we use a combination of similar syscalls on Linux to simulate the behavior of the Serenity-exclusive anon_create syscall. Users therefore won't have to worry about the platform anymore :^)
2022-02-10LibWeb: Make :root selector match <html> element onlyAndreas Kling
We were matching every HTML element, instead of just the root (<html>)
2022-02-10LibWeb: Add "tag name" buckets to StyleComputer::RuleCacheAndreas Kling
We can skip rules that require a specific tag name when matching against any element with a different tag name. :^)
2022-02-10LibWeb: Add "ID" buckets to StyleComputer::RuleCacheAndreas Kling
We can skip rules that require a specific ID when matching against any element that doesn't have that ID.
2022-02-10LibWeb: Cache CSS rules in buckets to reduce number of rules checkedAndreas Kling
This patch introduces the StyleComputer::RuleCache, which divides all of our (author) CSS rules into buckets. Currently, there are two buckets: - Rules where a specific class must be present. - All other rules. This allows us to check a significantly smaller set of rules for each element, since we can skip over any rule that requires a class attribute not present on the element. This takes the typical numer of rules tested per element on Discord from ~16000 to ~550. :^) We can definitely improve the cache invalidation. It currently happens too often due to media queries. And we also need to make sure we invalidate when mutating style through CSSOM APIs.
2022-02-10LibWeb: Perform CSS custom property cascade once instead of per-propertyAndreas Kling
Previously we would re-run the entire CSS selector machinery for each property resolved. Instead of doing that, we now resolve a final set of custom property key/value pairs at the start of the cascade.
2022-02-10LibWeb: Fix a bunch of trivial clang-tidy warnings in StyleComputerAndreas Kling
- Replace "auto" with "auto const" where appropriate. - Remove an unused struct. - Make sort_matching_rules() a file-local static function. - Remove some unnecessary includes.
2022-02-10LibWeb: Rename a CascadeOrigin parameter in StyleComputerAndreas Kling
2022-02-10LibJS: Do not refer to moved-from completions / valuesTimothy Flynn
In the ThrowCompletionOr constructors, the VERIFY statements are using moved-from objects. We should not rely on those objects still being valid after being moved.
2022-02-10LibJS: Add tests for Set.prototype.keys which is an alias for valuesdavidot
2022-02-10LibJS: Fix Map Iterators when elements are deleted during iterationdavidot
Before this would assume that the element found in operator++ was still valid when dereferencing it in operator*. Since any code can have been run since that increment this is not always valid. To further simplify the logic of the iterator we no longer store the index in an optional.