summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibWeb/DOM/Node.h
AgeCommit message (Collapse)Author
2021-09-06LibWeb: Make Node.textContent more spec compliantLuke Wilde
The current implementation felt a bit ad-hoc and notably allowed textContent to operate on all node types. It also only returned the child text content of the Node instead of the descendant text content.
2021-09-06LibWeb: Implement the (string) replace all operations for NodeLuke Wilde
2021-09-02LibWeb: Make Node::root return a referenceLuke Wilde
The root of a node can never be null, as "the root of an object is itself, if its parent is null, or else it is the root of its parent." https://dom.spec.whatwg.org/#concept-tree-root
2021-09-02LibWeb: Give each Node a unique IDSam Atkins
We maintain a directory of ID -> Node. Nodes add themselves to this directory when they are created, receiving a random ID. When a Node is destroyed, it removes itself from this directory. Anyone can request a Node from the directory by its ID using `Node::from_id()`. We reserve the `0` ID to mean "none". These IDs allow different processes to communicate about a given Node over IPC, for example the DOM Inspector.
2021-09-02LibWeb: Add shadow including ancestor/descendant checksLuke Wilde
2021-08-05LibWeb: Ignore svg elements outside of <svg> when building layout treeK-Adam
An svg layout element without a `SVGSVGElement` ancestor caused a failed assertion before, because the svg context does not exist when `paint()` is called
2021-07-05LibWeb: Implement Node.containsLuke
Used by Web Components Polyfills.
2021-07-05LibWeb: Make adopted_from no longer take a const Document referenceLuke
Nodes implementing the adoption steps can modify the passed in document, for example HTMLTemplateElement does so to adopt it's contents into the new document.
2021-07-05LibWeb: Add the cloning steps in clone_nodeLuke
This will be used in HTMLTemplateElement later to clone template contents. This makes the clone functions non-const in the process, as the cloning steps can have side effects.
2021-07-05LibWeb: Check if scripting is disabled before running scriptLuke
This is not a full check, it's just enough to prevent script execution in DOMParser.
2021-06-29LibWeb: Add JSON serialization method to DOM::NodeAdam Hodgen
This method builds a JSON object representing the full state of the DOM tree. The JSON that is built will be used for building the DOM Inspector widget for the OutOfProcessWebView.
2021-05-07LibWeb: Implement Node.replaceChildLuke
The `if (child->parent())` check seems to be redundant, but I'm keeping it just to match the spec.
2021-05-02LibWeb: Expose Node.ownerDocumentLuke
Required by jQuery.
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-14LibWeb: Implement Node.cloneNode()Linus Groh
With this we can now successfully run a Vue.js 2 hello world! :^)
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 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-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: 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-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-06LibWeb: Add a couple child node operations to Node and add node typesLuke
2021-02-10LibWeb: Add DOM::Node::parent_or_shadow_host()Andreas Kling
This is useful when you want to traverse across shadow boundaries.
2021-01-28LibWeb: Add simple implementation of Node.removeChild()Andreas Kling
2021-01-28LibWeb: Remove accidentally committed changes from ↵Andreas Kling
b72f067f0daac88ebe66e3f714e517b995b48e7b
2021-01-28Kernel+Userland: Remove unused "effective priority" from threadsAndreas Kling
This has been merged with the regular Thread::priority field after the recent changes to the scheduler.
2021-01-18LibWeb: Make the Window object "inherit" from EventTarget :^)Andreas Kling
Since Web::Bindings::WindowObject inherits from JS::GlobalObject, it cannot also inherit from Web::Bindings::EventTargetWrapper. However, that's not actually necessary. Instead, we simply set the Window object's prototype to the EventTargetPrototype, and add a little extra branch in the impl_from() function that turns the JS "this" value into a DOM::EventTarget*. With this, you can now call window.addEventListener()! Very cool :^) Fixes #4758.
2021-01-17LibWeb: Add fast_is<T>() for some DOM and layout node subclassesAndreas Kling
The generic is<T>() uses dynamic_cast which is fine in the majority of cases, but when one of them shows up in profiles, we can make it faster by answering the is-a question manually.
2021-01-12Libraries: Move to Userland/Libraries/Andreas Kling