summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibWeb/DOM
AgeCommit message (Collapse)Author
2021-04-24LibJS+LibWeb: Move exception logging and remove should_log_exceptionsLinus Groh
LibWeb is now responsible for logging unhandled exceptions itself, which means set_should_log_exceptions() is no longer used and can be removed. It turned out to be not the best option for web page exception logging, as we would have no indication regarding whether the exception was later handled of not.
2021-04-24LibJS: Add VM::on_call_stack_emptied callbackLinus Groh
Instead of having to run queued promise jobs in LibWeb in various places, this allows us to consolidate that into one function - this is very close to how the spec describes it as well ("at some future point in time, when there is no running execution context and the execution context stack is empty, the implementation must [...]"). Eventually this will also be used to log unhandled exceptions, and possibly other actions that require JS execution to have ended.
2021-04-23AK: Rename adopt() to adopt_ref()Andreas Kling
This makes it more symmetrical with adopt_own() (which is used to create a NonnullOwnPtr from the result of a naked new.)
2021-04-22LibWeb+HackStudio: Use lukew@serenityos.org for my copyright headersLuke
2021-04-22Everywhere: Use linusg@serenityos.org for my copyright headersLinus Groh
2021-04-22LibWeb: Implement document.anchorsAndreas Kling
This returns an HTMLCollection of all <a> elements in the document that have a "name" attribute.
2021-04-22LibWeb: Implement document.appletsAndreas Kling
This is a legacy interface that returns an always-empty HTMLCollection.
2021-04-22LibWeb: Implement a slow but functional HTMLCollection :^)Andreas Kling
HTMLCollection is an awkward legacy interface from the DOM spec. It provides a live view of a DOM subtree, with some kind of filtering that determines which elements are part of the collection. We now return HTMLCollection objects from these APIs: - getElementsByClassName() - getElementsByName() - getElementsByTagName() This initial implementation does not do any kind of caching, since that is quite a tricky problem, and there will be plenty of time for tricky problems later on when the engine is more mature.
2021-04-22Everything: Move to SPDX license identifiers in all files.Brian Gianforcaro
SPDX License Identifiers are a more compact / standardized way of representing file license information. See: https://spdx.dev/resources/use/#identifiers This was done with the `ambr` search and replace tool. ambr --no-parent-ignore --key-from-file --rep-from-file key.txt rep.txt *
2021-04-16Browser+LibWeb+WebContent: Parse cookies in the OOP tabTimothy Flynn
To protect the main Browser process against nefarious cookies, parse the cookies out-of-process and then send the parsed result over IPC to the main process. This way, if the cookie parser blows up, only that tab will be affected.
2021-04-15LibWeb: Expose the MouseEvent::{clientX, clientY} attributesIdan Horowitz
These provide the cursor coordinate within the viewport at which the event occurred (as opposed to the page relative coordinates exposed via offsetX, offsetY).
2021-04-14Browser+LibWeb+WebContent: Track the source of document.cookie requestsTimothy Flynn
To implement the HttpOnly attribute, the CookieJar needs to know where a request originated from. Namely, it needs to distinguish between HTTP / non-HTTP (i.e. JavaScript) requests. When the HttpOnly attribute is set, requests from JavaScript are to be blocked.
2021-04-14LibWeb: Implement Node.cloneNode()Linus Groh
With this we can now successfully run a Vue.js 2 hello world! :^)
2021-04-14LibWeb: Add Element::prefix()Linus Groh
Just a getter for m_qualified_name.prefix(), just like local_name() and namespace_().
2021-04-13LibWeb: Fix some FIXMEs related to ExceptionOr<T>AnotherTest
This fixes a few FIXMEs mentioned in 5beacf08a2d578d0eb36d6320255d0f4634a1085, which depended on #6075 being fixed.
2021-04-11LibWeb: Move element_child_count to ParentNode and add its IDL attributeLuke
I initially had it in Node just because, but then saw it was part of ParentNode in the spec.
2021-04-11LibWeb: Add Event.initEventLuke
Used by YouTube after creating an event with Document.createEvent
2021-04-11LibWeb: Add support for optional default values and optional bools in IDLLuke
Fixed the DOMException constructor as it had the default value version commented out.
2021-04-11LibWeb+WebContent: Hook document.cookie to the backend cookie storageTimothy Flynn
2021-04-11LibWeb: Add implementation of Node.compareDocumentPosition()Brian Gianforcaro
While looking into getting Duck Duck Go loading further in the Browser, I noticed that it was complaining about the missing method Node.compareDocumentPosition. This change implements as much of the DOM spec as possible with the current implementation of the DOM to date. The implementation is validated by new tests in the Node.js.
2021-04-11LibWeb: Connect existing implementation of Node::is_connected to JS.Brian Gianforcaro
I was looking at implementing something else, and saw this was low hanging fruit, that brings the browser closer to standards conformance. Add a basic test as well to validate it's implementation.
2021-04-10LibWeb: Add a basic implementation of Document.createEvent()Linus Groh
This is a legacy function providing a way of constructing events without using their constructors exposed on the global object. We don't have many of the events it supports yet, nor can we throw a DOMException from it, so that's two FIXMEs for later.
2021-04-10LibWeb: Support nullable EventListener parameters in WrapperGeneratorLinus Groh
The internal C++ function will now receive a RefPtr<EventListener> for 'EventListener?' and a NonnullRefPtr<EventListener> for 'EventListener'. Examples of this are addEventListener() and removeEventListener(), which both have nullable callback parameters.
2021-04-06LibWeb: Make the node mutation algorithms more spec compliantLuke
The mutation algorithms now more closely follow the spec and fixes some assertion failures in tests such as Acid3 and Dromaeo. The main thing that is missing right now is passing exceptions to the bindings layer. This is because of issue #6075. I spent a while trying to work it out and got so frustrated I just left it as a FIXME. Besides that, the algorithms bail at the appropriate points. This also makes the adopting steps in the document more spec compliant as it's needed by the insertion algorithm. While I was at it, I added the adoptNode IDL binding. This adds a bunch of ancestor/descendant checks to TreeNode as well. I moved the "remove_all_children" function to Node as it needs to use the full remove algorithm instead of simply removing it from the child list.
2021-04-06LibWeb: Rename "for_each_in_subtree(_of_type)" to ↵Luke
"for_each_in_inclusive_subtree(_of_type)" This is because it includes the initial node that the function was called on, which makes it "inclusive" as according to the spec. This is important as there are non-inclusive variants, particularly used in the node mutation algorithms.
2021-04-06LibWeb: Make the node mutation event functions spec compliantLuke
This particularly affects the insertion steps and the removed steps. The insertion steps no longer take into the parent that the node was inserted to, as per the spec. Due to this, I have renamed the function from "inserted_into" to simply "inserted". None of the users of the insertion steps was using it anyway. The removed steps now take a pointer to the old parent instead of a reference. This is because it is optional according to the spec and old parent is null when running the removal steps for the descendants of a node that just got removed. This commit does not affect HTMLScriptElement as there is a bit more to that, which is better suited for a separate commit. Also adds in the adopted steps as they will be used later.
2021-04-06LibWeb: Add ProcessingInstruction nodeLuke
Not particuarly useful right now, but is used in ensure_pre_insertion_validity. I'm not totally sure on the constructor arguments.
2021-04-06LibWeb: Remove nodes from their old parent in appendChild/insertBeforeAndreas Kling
2021-04-05LibWeb: Support two-value background-repeatTimothy Flynn
The background-repeat value may be specified as either one- or two-value identifiers (to be interpreted as horizontal and vertical repeat). This adds two pseudo-properties, background-repeat-x and background-repeat-y, to handle this. One-value identifiers are mapped to two-value in accordance with the spec.
2021-04-04LibWeb: Implement the Screen interfaceLinus Groh
https://drafts.csswg.org/cssom-view/#the-screen-interface
2021-04-03LibWeb: Support rendering background images with 'background-repeat'Timothy Flynn
Update the painting of background images for both <body> nodes and other non-initial nodes. Currently, only the following values are supported: repeat, repeat-x, repeat-y, no-repeat This also doesn't support the two-value syntax which allows for setting horizontal and vertical repetition separately.
2021-04-02LibWeb: Run queued promise jobs after callbacksLinus Groh
We now run queued promise jobs after calling event handler, timer, and requestAnimationFrame() callbacks - this is a bit ad-hoc, but I don't want to switch LibWeb to use an event loop right now - this works just fine, too. We might want to revisit this at a later point and do tasks and microtasks properly.
2021-03-30LibWeb: Get the first DOM node with a 'title' attribute for tooltip areaTimothy Flynn
Rather than expecting the first parent to have a 'title' attribute, search all ancestors.
2021-03-26LibWeb: Call requestAnimationFrame() callback with undefined this valueLinus Groh
We were leaking an empty value via the callback's this value: requestAnimationFrame(function () { this; // <-- empty value });
2021-03-21LibWeb: Only call page_did_change_title() from main frameLinus Groh
Otherwise an embedded iframe will override the page title in the browser, for example.
2021-03-16LibWeb: Invalidate element style after setting Element.style.fooAndreas Kling
This makes us recompute style for the element so the change actually takes effect. :^)
2021-03-16LibWeb: Add Window.innerWidth and Window.innerHeightAndreas Kling
2021-03-16LibJS: Make Interpreter::run() a void functionLinus Groh
With one small exception, this is how we've been using this API already, and it makes sense: a Program is just a ScopeNode with any number of statements, which are executed one by one. There's no explicit return value at the end, only a completion value of the last value-producing statement, which we then access using VM::last_value() if needed (e.g. in the REPL).
2021-03-15LibWeb: Stub out Document.cookieAndreas Kling
We don't get/set anything, but at least scripts that access document cookies can now progress further. :^)
2021-03-13LibWeb: Expose barebones CSSStyleDeclaration to JavaScriptAndreas Kling
You can now access an element's inline style via Element.style. The interface is not very capable yet though. :^)
2021-03-13LibWeb: Rename StyleDeclaration => CSSStyleDeclaration to match CSSOMAndreas Kling
2021-03-09LibWeb: Rename CSSParser => DeprecatedCSSParserAndreas Kling
2021-03-08LibWeb: Start exposing CSS style sheets to JavaScript :^)Andreas Kling
This patch adds bindings for the following objects: - StyleSheet - StyleSheetList - CSSStyleSheet You can get to a document's style sheets via Document.styleSheets and iterate through them using StyleSheetList's item() and length(). That's it in terms of functionality at this point, but still neat. :^)
2021-03-07LibWeb: Split CSS::StyleSheet into StyleSheet and CSSStyleSheetAndreas Kling
This is a little convoluted but matches the CSSOM specification.
2021-03-06LibWeb: Add a couple child node operations to Node and add node typesLuke
2021-03-01LibWeb: Provide file name to JavaScript interpreterJean-Baptiste Boric
2021-02-23Everywhere: Rename ASSERT => VERIFYAndreas Kling
(...and ASSERT_NOT_REACHED => VERIFY_NOT_REACHED) Since all of these checks are done in release builds as well, let's rename them to VERIFY to prevent confusion, as everyone is used to assertions being compiled out in release. We can introduce a new ASSERT macro that is specifically for debug checks, but I'm doing this wholesale conversion first since we've accumulated thousands of these already, and it's not immediately obvious which ones are suitable for ASSERT.
2021-02-22LibWeb: Support assigning to document.body when it is nullAndreas Kling
2021-02-21LibWeb: Add Document.createRange()Andreas Kling
Also tidy up DOM::Range a little bit while we're here, and unify the way we create them to use a delegating constructors.
2021-02-21LibWeb: Expose the Window object as Document.defaultViewAndreas Kling
This should really be a WindowProxy? but since we don't have anything representing that concept yet, let's just expose the Window object directly so document.defaultView.foo works. :^)