summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibWeb
AgeCommit message (Collapse)Author
2021-06-05LibWeb: Fix off-by-one error in SyntaxHighlighterMax Wipfli
This changes the HTML SyntaxHighlighter to conform to the now-fixed rendering of syntax highlighting spans in GUI::TextEditor. It also avoids emitting tokens if they have a zero or negative length. This fixes a bug where single-character tokens were not highlighted properly.
2021-06-05LibWeb: Be more forgiving when adding source positions in HTMLTokenizerMax Wipfli
This patch changes HTMLTokenizer::nth_last_position to not fail if the requested position is not available. Rather, it will just return (0-0). While this is not the correct solution, it prevents the tokenizer from crashing just because it cannot find a source position. This should only affect SyntaxHighlighter.
2021-06-05LibWeb: Add debugging statements in SyntaxHighlighterMax Wipfli
This also changes SyntaxHighlighter.{h,cpp} to use east const style.
2021-06-04LibWeb: Remove Utf8View usage and try avoiding StringBuilder in TextNodeMax Wipfli
This patch completely reworks TextNode::compute_text_for_rendering(). It removes the unnecessary usage of Utf8View to find spaces in a String. Furthermore, it adds a couple fast return paths for common but trivial cases such as empty, single-character and whitespace-less strings. For the HTML spec bookmarks, around two thirds of all function calls (which amounts to around 10'000) use the fast paths and thus avoid allocating a StringBuilder just to build a copy of the already present String.
2021-06-03AK: Do not VERIFY on invalid code point bytes in UTF8ViewDexesTTP
The previous behavior was to always VERIFY that the UTF-8 bytes were valid when iterating over the code points of an UTF8View. This change makes it so we instead output the 0xFFFD 'REPLACEMENT CHARACTER' code point when encountering invalid bytes, and keep iterating the view after skipping one byte. Leaving the decision to the consumer would break symmetry with the UTF32View API, which would in turn require heavy refactoring and/or code duplication in generic code such as the one found in Gfx::Painter and the Shell. To make it easier for the consumers to detect the original bytes, we provide a new method on the iterator that returns a Span over the data that has been decoded. This method is immediately used in the TextNode::compute_text_for_rendering method, which previously did this in a ad-hoc waay. This also add tests for the new behavior in TestUtf8.cpp, as well as reinforcements to the existing tests to check if the underlying bytes match up with their expected values.
2021-06-03Everywhere: Replace ctype.h to avoid narrowing conversionsMax Wipfli
This replaces ctype.h with CharacterType.h everywhere I could find issues with narrowing conversions. While using it will probably make sense almost everywhere in the future, the most critical places should have been addressed.
2021-06-02LibWasm: Implement reference instructions (ref.{null,func,is_null})Ali Mohammad Pur
2021-06-01LibWeb: Use correct percent encode set for form submissionsLuke
We currently only support application/x-www-form-urlencoded for form submissions, which uses a special percent encode set when percent encoding the body/query. However, we were not using this percent encode set. With the new URL implementation, we can now specify the percent encode set to be used, allowing us to use this special percent encode set. This is one of the fixes needed to make the Google cookie consent work.
2021-06-01AK+LibWeb: Remove URL::to_string_encoded()Max Wipfli
This replaces URL::to_string_encoded() with to_string() and removes the former, since they are now equivalent.
2021-06-01Everywhere: codepoint => code pointAndreas Kling
2021-06-01AK: Rename Utf8CodepointIterator => Utf8CodePointIteratorAndreas Kling
2021-06-01LibWeb: Remove usage of URL::set_path() in FrameLoaderMax Wipfli
This replaces a call to URL::set_path() with URL::set_paths(), as set_path() will be deprecated and removed.
2021-06-01AK: Remove URLParserMax Wipfli
This removes URLParser, because its two exposed functions, urlencode() and urldecode(), have been superseded by URL::percent_encode() and URL::percent_decode(). This is in preparation for the introduction of a new URL parser.
2021-06-01AK+Everywhere: Replace usages of URLParser::urlencode() and urldecode()Max Wipfli
This replaces all occurrences of those functions with the newly implemented functions URL::percent_encode() and URL::percent_decode(). The old functions will be removed in a further commit.
2021-05-31LibWeb/WrapperGenerator: Replace a fprintf() with warnln()Linus Groh
2021-05-31LibWeb: Rename "FrameHostElement" to "BrowsingContextContainer"Luke
With the renaming of "Frame" to "BrowsingContext", this changes "FrameHostElement" to "BrowsingContextContainer" to further match the spec. https://html.spec.whatwg.org/#browsing-context-container
2021-05-31LibWeb: Return null in Window.{top,parent} if browsing context is nullLuke
We were asserting that it exists, but the spec says to return null in this case. Top: https://html.spec.whatwg.org/multipage/browsers.html#dom-top Parent: https://html.spec.whatwg.org/multipage/browsers.html#dom-parent
2021-05-30LibWeb: Rename Web::Frame to Web::BrowsingContextAndreas Kling
Our "frame" concept very closely matches what the web specs call a "browsing context", so let's rename it to that. :^) The "main frame" becomes the "top-level browsing context", and "sub-frames" are now "nested browsing contexts".
2021-05-29LibWeb: Also call page_did_start_loading() for FrameLoader::Type::ReloadLinus Groh
Surprisingly this is not used by the browser's page reload functionality but only JS's location.reload() - that's probably why this hasn't been noticed yet. Make sure we notify the page client about the load start in that case as well. :^)
2021-05-29LibWeb: Call page_did_start_loading() before load_resource()Linus Groh
Otherwise we would sometimes (dependent on the load time, I believe) end up setting the document and eventually calling title change callbacks before communicating that the page started loading.
2021-05-29LibWeb: Improve performance of CSS custom property resolutionTobias Christiansen
By memoizing already resolved custom properties in the DOM::Element, we achieve a notable speed increase when loading SerenityOS on GitHub.
2021-05-29LibWeb: Avoid unnecessary String copy in parsing CSS custom propertiesTobias Christiansen
2021-05-28LibWeb: Resolve custom propertiesTobias Christiansen
The way to get the custom properties is pretty weird and this code is as far from optimized as it gets but somehow it works :^)
2021-05-28LibWeb: StyleResolver: Keep track of specificity of matched selectorTobias Christiansen
This way it gets easier to compare matches.
2021-05-28LibWeb: Add parsing for custom propertiesTobias Christiansen
This parses 'some-property: var(--some-name)' and stores its findings in a CustomStyleValue. It also parses the custom properties like '--some-name: some-value' and puts them into the StyleProperty.
2021-05-28LibWeb: Store custom properties in CSSStyleDeclarationTobias Christiansen
Keep them around when parsing and store them in the CSSStyleDeclaration when done.
2021-05-28LibWeb: Add CustomStyleValueTobias Christiansen
This extends StyleValue and can hold the identifier of the custom property.
2021-05-28LibWeb: Add PropertyID::Custom to code generatorTobias Christiansen
2021-05-26LibJS+LibWeb: Make Uint8ClampedArray use TypedArrayAli Mohammad Pur
Instead of being its own separate unrelated class. This automatically makes typed array properties available to it, as well as making it available to the runtime.
2021-05-26LibWasm+LibWeb: Partially resolve memory exportsAli Mohammad Pur
This allows the JS side to access the wasm memory, assuming it's exported by the module. This can be used to draw stuff on the wasm side and display them from the js side, for example :^)
2021-05-26LibWasm+LibWeb: Implement (a very basic version of) the JS link/importAli Mohammad Pur
This allows Wasm code to call javascript functions.
2021-05-26LibWeb: Implement a very basic WebAssembly JS APIAli Mohammad Pur
This impl is *extremely* simple, and is missing a lot of things, it's also not particularly spec-compliant in some places, but it's definitely a start :^)
2021-05-24LibWeb: Match the :not pseudoclassTobias Christiansen
When a Selector features a :not() pseudoclass we now check whether the current element matches with the given selector in the :not and act accordingly.
2021-05-24LibWeb: Add :not pseudoclass to the CSS parserTobias Christiansen
The selector given in the :not() is stored in the SimpleSelector as a String.
2021-05-24LibWeb: Don't try to load anything if src is empty in <img>Tobias Christiansen
Previously we tried to load "" if the src was present but empty and essentially only waited for RequestServer to time out.
2021-05-24AK+Everywhere: Consolidate String::index_of() and String::find()Andreas Kling
We had two functions for doing mostly the same thing. Combine both of them into String::find() and use that everywhere. Also add some tests to cover basic behavior.
2021-05-24LibWeb: Add support for more pseudoclassesTobias Christiansen
:disabled, :enabled and :checked are now parsed and matched. There surely are more nuances to consider.
2021-05-23LibIPC: Remove unnecessary IPC::ServerConnection::handshake()Andreas Kling
This is no longer used by any of our IPC pairs.
2021-05-23WebContent: Remove unnecessary greet() messageAndreas Kling
2021-05-21LibWeb: Improve Unicode compatibility of HTML contenteditableMax Wipfli
This patch updates the Page::keydown_event event handler to implement crude Unicode support. It implements new method in EditEventHandler to more easily handle deleting a single character after the cursor. Furthermore, it makes use of the previously implemented methods to increment and decrement the cursor position, which take into account that Unicode codepoint may be multiple bytes wide. This means it is now possible to mostly edit Unicode in editable DOM nodes without any crashes. :^)
2021-05-21LibWeb: Frame/Position: Implement cursor increment/decrement methodsMax Wipfli
This introduces methods to increment and decrement the cursor position. This is non-trivial as the cursor position is specified in bytes rather than codepoints. Thus, it sometimes needs to be incremented or decremented by more than one, depending on the codepoint to "jump over". Because the cursor blink cycle needs to be reset after moving the cursor, methods calling the ones in DOM::Position are implemented in Frame. Furthermore, this allows the cursor_position() getter to stay const. :^) Additionally, it adds a offset_is_at_end_of_node() method which checks if the current offset points to the end of the node.
2021-05-21LibWeb: Improving cursor behavior in editable DOM nodesMax Wipfli
This patch makes two modifications to improve the behavior of cursors in editable DOM nodes, such as HTML tags with the contenteditable attribute. When the cursor blink cycle is reset in an editable DOM node, a repaint should be initiated. For this, set_needs_display() needs to be called on the layout node. Previously, the cursor blink cycle would not reset properly and moving the cursor with the arrow keys did not feel intuitive. Furthermore, this modifies one of the conditions necessary to actually paint the cursor, which previously prevented it from being painted when at the end of a text node, after all the text present.
2021-05-21LibWeb: Do nothing when pressing modifier keys in HTML contenteditableMax Wipfli
Before this patch, pressing modifier keys such as Ctrl would insert whitespace into editable DOM nodes. This patch crudely fixes that behavior by checking if the codepoint associated with the event is non-zero.
2021-05-21LibWeb: Replace some TODO() calls with FIXME comments in EventHandlerMax Wipfli
This patch downgrades some TODO() calls when the cursor in an editable DOM node should move to the previous or next node. Previously, the process would crash, whereas now, the cursor will just stay where it was. This seems more sensible for now, as there is no reason to crash just because of this.
2021-05-21LibGfx+WindowServer: Have WindowServer broadcast system font settingsAndreas Kling
Instead of everybody getting their system fonts from Gfx::FontDatabase (where it's all hardcoded), they now get it from WindowServer. These are then plumbed into the usual Gfx::FontDatabase places so that the old default_font() and default_fixed_width_font() APIs keep working.
2021-05-21LibWeb: Ignore vendor-specific CSS propertiesTobias Christiansen
If we can't parse a property we previously a log-line was generated. However it is in our best interest to simply ignore vendor-specific properties (e.g -moz-something or -webkit-something) since they are not part of the spec. The vendor-specific-ness is determined by looking whether the property starts with '-'. If we want to support some vendor-specific stuff, this doesn't get in the way since this check takes place after the parser determined that the current property is invalid. This cuts down the log-noise of the parser.
2021-05-21LibWeb: Make tag names bold in syntax-highlighted HTML :^)Andreas Kling
2021-05-21Revert "Userland: static vs non-static constexpr variables"Linus Groh
This reverts commit 800ea8ea969835297dc7e7da345a45b9dc5e751a. Booting the system no longer worked after these changes.
2021-05-21Userland: static vs non-static constexpr variablesLenny Maiorani
Problem: - `static` variables consume memory and sometimes are less optimizable. - `static const` variables can be `constexpr`, usually. - `static` function-local variables require an initialization check every time the function is run. Solution: - If a global `static` variable is only used in a single function then move it into the function and make it non-`static` and `constexpr`. - Make all global `static` variables `constexpr` instead of `const`. - Change function-local `static const[expr]` variables to be just `constexpr`.
2021-05-21LibWeb: Fix invalid behaviour of HTMLTokenizer::skip() and restore_to()Ali Mohammad Pur
skip() is supposed to end up keeping the previous iterator only one index behind the current one, and restore_to() should actually do the restore instead of just removing the now-useless source positions. Fixes #7331.