summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibWeb/DOM/Node.cpp
AgeCommit message (Collapse)Author
2021-09-08LibWeb: Rename InitialContainingBlockBox => InitialContainingBlockAndreas Kling
The "Box" suffix added nothing here.
2021-09-07LibWeb: Add preceding and following Node cases in tree constraintsLuke Wilde
This also does some east-const changes in TreeNode.
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: Include DOM Node ID in serialized JSONSam Atkins
This will be used in the DOM Inspector to communicate which node is being inspected.
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: Remove commented-out dbglnSam Atkins
This is unrelated to the PR I'm working on, but keeps getting reformatted because clang-format wants comments to start with a space.
2021-09-02LibWeb: Add shadow including ancestor/descendant checksLuke Wilde
2021-07-05LibWeb: Implement Node.containsLuke
Used by Web Components Polyfills.
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: Use the element factory in clone_nodeLuke
It was directly creating a new Element object instead of creating the appropriate element. For example, document.body.cloneNode(true) would return an Element instead of an HTMLBodyElement.
2021-07-05LibWeb: Make clone_node capable of cloning document fragmentsLuke
Used by Web Components Polyfills.
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-07-01LibWeb: Do not encode "internal_id" in DOM JSONTimothy Flynn
This is now unused.
2021-06-29LibWeb: Fix build breakage after merging the oldish DOM inspector PRAndreas Kling
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-06-27LibJS: Rename Function => FunctionObjectAndreas Kling
2021-06-27LibWeb: Make ExceptionOr capable of holding all error types in the specAli Mohammad Pur
The WebIDL spec specifies a few "simple" exception types in addition to the DOMException type, let's support all of those. This allows functions returning ExceptionOr<T> to throw regular javascript exceptions (as limited by the webidl spec) by returning a `DOM::SimpleException { DOM::SimpleExceptionType::T, "error message" }` which is pretty damn cool :^)
2021-06-24AK: Rename downcast<T> => verify_cast<T>Andreas Kling
This makes it much clearer what this cast actually does: it will VERIFY that the thing we're casting is a T (using is<T>()).
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-03LibWeb: Use node_to_insert instead of node in Node::insert_beforeLuke
It was using the passed in node instead of the node from the vector. Fixes a crash I found while testing jQuery.
2021-05-02LibWeb: Expose Node.ownerDocumentLuke
Required by jQuery.
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-22Everywhere: Use linusg@serenityos.org for my copyright headersLinus Groh
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: 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: Remove nodes from their old parent in appendChild/insertBeforeAndreas Kling
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-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-10LibWeb: Add DOM::Node::parent_or_shadow_host()Andreas Kling
This is useful when you want to traverse across shadow boundaries.
2021-02-10LibWeb: Remove a whole bunch of unnecessary #includesAndreas Kling
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-25Everywhere: Remove unnecessary debug comments.asynts
It would be tempting to uncomment these statements, but that won't work with the new changes. This was done with the following commands: find . \( -name '*.cpp' -o -name '*.h' -o -name '*.in' \) -not -path './Toolchain/*' -not -path './Build/*' -exec awk -i inplace '$0 !~ /\/\/#define/ { if (!toggle) { print; } else { toggle = !toggle } } ; $0 ~/\/\/#define/ { toggle = 1 }' {} \; find . \( -name '*.cpp' -o -name '*.h' -o -name '*.in' \) -not -path './Toolchain/*' -not -path './Build/*' -exec awk -i inplace '$0 !~ /\/\/ #define/ { if (!toggle) { print; } else { toggle = !toggle } } ; $0 ~/\/\/ #define/ { toggle = 1 }' {} \;
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-12Libraries: Move to Userland/Libraries/Andreas Kling