summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibWeb/HTML
AgeCommit message (Collapse)Author
2022-02-15LibWeb: Rename element_before() => element_immediately_above()Andreas Kling
This matches the spec terminology around the "stack of open elements".
2022-02-15LibWeb: Add spec comments to find_appropriate_place_for_inserting_node()Andreas Kling
2022-02-15LibWeb: Remove non-standard ReturnNullIfCrossOrigin IDL attributeLinus Groh
This is no longer needed as BrowsingContextContainer::content_document() now does the right thing, and HTMLIFrameElement.contentDocument is the only user of this attribute. Let's not invent our own mechanisms for things that are important to get right, like same origin comparisons.
2022-02-15LibWeb: Implement BCC's "content document" concept according to specLinus Groh
2022-02-15LibWeb: Rename Origin::is_same() to Origin::is_same_origin()Linus Groh
The HTML Origin spec has two similar but slightly different concepts of origin equality: "same origin" and "same origin-domain". Let's be explicit with the naming here :^) Also add spec comments.
2022-02-14LibWeb: Don't emit current token on EOF in HTML TokenizerKarol Kosek
Emitting tokens on EOF caused an infinite loop, freezing the app, which could be a bit annoying when writing an HTML comment at the end of the file in Text Editor. :^)
2022-02-14LibWeb: Fix highlighting HTML commentsKarol Kosek
Commit b193351a99 caused the HTML comments to flash when changing the text cursor. Also, when double-clicking on a comment, the selection started from the beginning of the file instead. The following message was displaying when `TOKENIZER_TRACE_DEBUG` was enabled: (Tokenizer::nth_last_position) Invalid position requested: 4th-last of 4. Returning (0-0). Changing the `nth_last_position` to 3 fixes this. I'm guessing that's because the parser is at that moment on the second hyphen of the `<!--` string, so it has to go back only by three characters.
2022-02-13LibWeb: Fix off-by-one in HTMLTokenizer::restore_to()MacDue
The difference should be between m_utf8_iterator and the the new position, if m_prev_utf8_iterator is used one fewer source position is popped than required. This issue was not apparent on most pages since restore_to used for tokens such <!doctype> that are normally followed by a newline that resets the column to zero, but it can be seen on pages with minified HTML.
2022-02-12LibWeb: Add support for 'arraybuffer' message types on WebSocketsserenitydev
2022-02-09LibWeb: Add initial implementation for WorkerGlobalScopeAndrew Kaster
This initial implementation stubs out the WorkerGlobalScope, WorkerLocation and WorkerNavigator classes. It doesn't take into account all the things that actually need passed into the constructors for these objects, nor the extra abstract operations that need to be performed on them by the rest of the Browser infrastructure. However, it does create bindings that compile and link :^)
2022-02-09LibWeb: Do not set Content-Length headers twice for POST requestsBrian Gianforcaro
While trying to get http://lite.duckduckgo.com to work in the Browser I noticed that we kept on getting 400 (Bad Request) errors when you click the "Search" button for a request. After turning on `JOB_DEBUG` to see what headers we were sending it turned out that we were actually setting `Content-Length` twice once in LibWeb, and again when the request is handled by LibHTTP. Since LibHTTP transparently handles this now, we can avoid it in LibWeb.
2022-02-08Browser+LibWeb: Add "Dump Local Storage" item to Browser's Debug menuAndreas Kling
2022-02-08LibWeb: Add Storage interface and window.localStorageAndreas Kling
This is a naive-but-somewhat-functional initial implementation of HTML Storage. Note that there is no persistence yet, everything is in-process only, and one local Storage object per origin.
2022-02-08LibWeb: Implement the JS host hooks for promises, job callbacks and moreLuke Wilde
This overrides the JS host hooks to follow the spec for queuing promises, making/calling job callbacks, unhandled promise rejection handling and FinalizationRegistry queuing. This also allows us to drop the on_call_stack_emptied hook in Document::interpreter().
2022-02-08LibWeb: Rewrite EventTarget to more closely match the specLuke Wilde
This isn't perfect (especially the global object situation in activate_event_handler), but I believe it's in a much more complete state now :^) This fixes the issue of crashing in prepare_for_ordinary_call with the `i < m_size` crash, as it now uses the IDL callback functions which requires the Environment Settings Object. The environment settings object for the callback is fetched at the time the callback is created, for example, WrapperGenerator gets the incumbent settings object for the callback at the time of wrapping. This allows us to remove passing in ScriptExecutionContext into EventTarget's constructor. With this, we can now drop ScriptExecutionContext.
2022-02-08LibWeb: Make FormAssociatedElement inherit from HTMLElementLuke Wilde
The new event target implementation requires us to downcast an EventTarget to a FormAssociatedElement to check if the current Element EventTarget has a form owner to setup a with scope for the form owner. This also makes all form associated elements inherit from FormAssociatedElement where it was previously missing. https://html.spec.whatwg.org/#form-associated-element
2022-02-08LibWeb: Introduce the Environment Settings ObjectLuke Wilde
The environment settings object is effectively the context a piece of script is running under, for example, it contains the origin, responsible document, realm, global object and event loop for the current context. This effectively replaces ScriptExecutionContext, but it cannot be removed in this commit as EventTarget still depends on it. https://html.spec.whatwg.org/multipage/webappapis.html#environment-settings-object
2022-02-08LibWeb: Support passing more parameter types to HTML::report_exception()Andreas Kling
We now allow any JS::ThrowCompletion<T>, as well as JS::Completion directly (although we'll VERIFY() that it's a throw completion.)
2022-02-08LibJS+Everywhere: Remove VM::exception() and most related functionsdavidot
This commit removes all exception related code: Remove VM::exception(), VM::throw_exception() etc. Any leftover throw_exception calls are moved to throw_completion. The one method left is clear_exception() which is now a no-op. Most of these calls are just to clear whatever exception might have been thrown when handling a Completion. So to have a cleaner commit this will be removed in a next commit. It also removes the actual Exception and TemporaryClearException classes since these are no longer used. In any spot where the exception was actually used an attempt was made to preserve that behavior. However since it is no longer tracked by the VM we cannot access exceptions which were thrown in previous calls. There are two such cases which might have different behavior: - In Web::DOM::Document::interpreter() the on_call_stack_emptied hook used to print any uncaught exception but this is now no longer possible as the VM does not store uncaught exceptions. - In js the code used to be interruptable by throwing an exception on the VM. This is no longer possible but was already somewhat fragile before as you could happen to throw an exception just before a VERIFY.
2022-02-08LibJS: Convert ArrayBuffer construction to ThrowCompletionOrdavidot
This also allows us to create TypedArrays with an existing buffer thus clearing up an additional FIXME in TextEncoder.
2022-02-07LibWeb: Rename "result" => "evaluation_status" in ClassicScript::run()Andreas Kling
This matches the variable name used in the spec.
2022-02-07LibWeb: Remove outdated FIXME from ClassicScript::run()Andreas Kling
Interpreter::run() *does* now return a Completion. :^)
2022-02-07LibWeb: Implement ErrorEventLuke Wilde
This will be used by the new EventTarget to check if it needs to do special error event handling. Currently it isn't used for anything else.
2022-02-07LibWeb: Fix broken step 4.3 implementation in run_focus_update_steps()Andreas Kling
Some over-eager copy-pasting led to incorrect code for the new chain.
2022-02-07LibWeb: Use NonnullRefPtrVector<DOM::Node> for focus chainsAndreas Kling
Let's just use reference-counting pointers for this, even if it seems safe not to.
2022-02-07LibWeb: Improve step 3 of "focus chain" from the HTML specAndreas Kling
This function was unnecessarily nested, which created a scenario where we could get stuck in an infinite loop without advancing the current_object pointer up the browsing context container chain.
2022-02-07LibWeb: Fix inverted null check in run_focusing_steps()Andreas Kling
Thanks to U9G for catching this! :^)
2022-02-07LibWeb: Add a proper FocusEvent interface for "focus" and "blur" eventsAndreas Kling
2022-02-06LibWeb: Make HTMLInputElement move cursor into text node when focusedAndreas Kling
This mechanism feels rather awkward, but it's better than nothing.
2022-02-06LibWeb: Implement (most of) HTMLElement.focus()Andreas Kling
The main deviation from the spec is that we don't have a straightforward representation of the spec's "focusable area" concept. I've left a bunch of FIXME's around for our future selves. :^)
2022-02-06LibWeb: Implement BrowsingContext::currently_focused_area()Andreas Kling
This is "currently focused area of a top level browsing context" from the HTML spec.
2022-02-06LibWeb: Rename "frame" to "browsing_context" in various placesAndreas Kling
We renamed the Frame class to BrowsingContext a while back, but forgot to update some variable names.
2022-02-05LibWeb: Put ClassicScript debug spam behind HTML_SCRIPT_DEBUGAndreas Kling
2022-02-05LibWeb: Implement CanvasGradient.addColorStop() according to specAndreas Kling
The object is still not usable for anything, but at least now it behaves correctly with regards to throwing exceptions.
2022-02-05LibWeb: Compute element style in Layout::TreeBuilderAndreas Kling
Instead of making each Layout::Node compute style for itself, we now compute it in TreeBuilder before even calling create_layout_node(). For non-element DOM nodes, we create the style and layout tree node in TreeBuilder. This allows us to move create_layout_node() from DOM::Node to DOM::Element.
2022-02-03LibWeb: Forward CanvasRenderingContext.strokeText() to fillText()Andreas Kling
This is a hack until we get an actual text stroking implementation.
2022-02-03LibWeb: Add barebones CanvasGradient objectAndreas Kling
Also add the CanvasRenderingContext2D APIs to go along with it. Note that it can't be used for anything yet.
2022-02-03LibWeb: Add CanvasRenderingContext2D.bezierCurveTo()Andreas Kling
2022-01-22LibJS: Refactor interpreter to use Script and Source Text ModulesLuke Wilde
This also refactors interpreter creation to follow InitializeHostDefinedRealm, but I couldn't fit it in the title :^) This allows us to follow the spec much more closely rather than being completely ad-hoc with just the parse node instead of having all the surrounding data such as the realm of the parse node. The interpreter creation refactor creates the global execution context once and doesn't take it off the stack. This allows LibWeb to take the global execution context and manually handle it, following the HTML spec. The HTML spec calls this the "realm execution context" of the environment settings object. It also allows us to specify the globalThis type, as it can be different from the global object type. For example, on the web, Window global objects use a WindowProxy global this value to enforce the same origin policy on operations like [[GetOwnProperty]]. Finally, it allows us to directly call Program::execute in perform_eval and perform_shadow_realm_eval as this moves global_declaration_instantiation into Interpreter::run (ScriptEvaluation) as per the spec. Note that this doesn't evalulate Source Text Modules yet or refactor the bytecode interpreter, that's work for future us :^) This patch was originally build by Luke for the environment settings object change but was also needed for modules. So I (davidot) have modified it with the new completion changes and setup for that. Co-authored-by: davidot <davidot@serenityos.org>
2022-01-15LibCore+LibIPC+Everywhere: Return Stream::LocalSocket from LocalServersin-ack
This change unfortunately cannot be atomically made without a single commit changing everything. Most of the important changes are in LibIPC/Connection.cpp, LibIPC/ServerConnection.cpp and LibCore/LocalServer.cpp. The notable changes are: - IPCCompiler now generates the decode and decode_message functions such that they take a Core::Stream::LocalSocket instead of the socket fd. - IPC::Decoder now uses the receive_fd method of LocalSocket instead of doing system calls directly on the fd. - IPC::ConnectionBase and related classes now use the Stream API functions. - IPC::ServerConnection no longer constructs the socket itself; instead, a convenience macro, IPC_CLIENT_CONNECTION, is used in place of C_OBJECT and will generate a static try_create factory function for the ServerConnection subclass. The subclass is now responsible for passing the socket constructed in this function to its ServerConnection base; the socket is passed as the first argument to the constructor (as a NonnullOwnPtr<Core::Stream::LocalServer>) before any other arguments. - The functionality regarding taking over sockets from SystemServer has been moved to LibIPC/SystemServerTakeover.cpp. The Core::LocalSocket implementation of this functionality hasn't been deleted due to my intention of removing this class in the near future and to reduce noise on this (already quite noisy) PR.
2022-01-08LibJS: Convert Interpreter::run() to ThrowCompletionOr<Value>Linus Groh
Instead of making it a void function, checking for an exception, and then receiving the relevant result via VM::last_value(), we can consolidate all of this by using completions. This allows us to remove more uses of VM::exception(), and all uses of VM::last_value().
2022-01-04LibWeb: Implement CanvasRenderingContext2D.measureTextsin-ack
This requires an implementation of the "text preparation algorithm" as specified here: html.spec.whatwg.org/multipage/canvas.html#text-preparation-algorithm However, we're missing a lot of things such as the CanvasTextDrawingStyles interface, so most of the algorithm was not implemented. Additionally, we also are not able to use a LineBox like the algorithm suggests, because our layouting infra is not up to the task yet. The prepare_text function does nothing other than figuring out the width of the given text and return glyphs with offsets at the moment.
2021-12-27LibWeb: Implement CanvasRenderingContext2D.isContextLost()Linus Groh
Note that we don't implement the "context lost steps" yet, so this will always return the initial value (false).
2021-12-27LibWeb: Implement CanvasRenderingContext2D.reset()Linus Groh
2021-12-27LibWeb: Implement CanvasRenderingContext2D.restore()Linus Groh
2021-12-27LibWeb: Implement CanvasRenderingContext2D.save()Linus Groh
2021-12-27LibWeb: Encapsulate canvas drawing state in a structLinus Groh
This will allow us to easily add copies of the relevant canvas drawing state to a stack, and likewise replace the current drawing state with an entry from that stack.
2021-12-27LibWeb: Let canvas {fill,stroke}Style default to black, not transparentLinus Groh
I don't know if the original author simply missed this or thought the default color of Gfx::Color is black, but this meant that drawing on a canvas without explicitly setting a fillStyle or strokeStyle first would be drawn in transparent color and therefore be invisible. In the spec this is indicated by a small comment in the IDL definition: attribute ... strokeStyle; // (default black) attribute ... fillStyle; // (default black) I'm starting to question whether Gfx::Color actually *should* have a default constructor.
2021-12-27LibWeb: Fix copy/paste typo in CanvasRenderingContext2D::stroke_style()Linus Groh
This returned the fill style, not the stroke style!
2021-12-21LibWeb: Fix null-deref in <table> delete_row with index = -1 and no rowsLuke Wilde
This wasn't quite following what the spec says for step 2: "If index is −1, then remove the last element in the rows collection from its parent, or do nothing if the rows collection is empty." It was behaving like: "If index is −1 and the rows collection is not empty, then remove the last element in the rows collection from its parent." Which is not the same, as it will fall into the "Otherwise" if `index == -1` and the rows collection is empty and try and get the -2nd element of the rows. Found with Domato.