summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibWeb/TreeNode.h
AgeCommit message (Collapse)Author
2023-01-29LibJS+LibWeb: Move headers around to allow including Value from CellTimothy Flynn
The goal here is to allow Cell::initialize to return a ThrowCompletion, to handle OOM for example. Cell.h will then need to include Completion.h which must include Value.h. This currently can't happen because Value.h includes BigInt.h, which in turn includes Cell.h. So we would have an include cycle. This removes BigInt.h from Value.h, as it is forward-declarable (it is only referred to with a reference or pointer). Then the Value overload for Cell::Visitor::visit is moved to Cell.h, and missing BigInt.h includes as peppered as needed.
2022-10-20LibWeb: Make the layout tree GC-allocatedAndreas Kling
This removes a set of complex reference cycles between DOM, layout tree and browsing context. It also makes lifetimes much easier to reason about, as the DOM and layout trees are now free to keep each other alive.
2022-04-01Everywhere: Run clang-formatIdan Horowitz
2022-02-26LibWeb: Make Range.setStart and Range.setEnd spec compliantLuke Wilde
These functions are way more involved than simply setting their respective boundary points :^)
2022-02-26LibWeb: Make TreeNode::child_count return size_t instead of intLuke Wilde
The primary benefit of this is that it's unsigned, as you can't have a negative amount of children. Plus, all the users of child_count expect it to be size_t.
2022-01-23LibWeb: Add TreeNode<T>::next_in_pre_order(T* stay_within) variantAndreas Kling
This is a scoped variant of the pre-order traversal helper that aborts when attempting to leave the `stay_within` node.
2021-10-03LibWeb: Allow Document::ref() when ref-count is zeroAndreas Kling
DOM::Document has some special lifetime rules to support the DOM lifetime semantics expected on the web. Any DOM node will keep its document alive as well, even after the document's ref-count has reached zero. This is achieved by the Document::m_referencing_node_count counter. Because of this mechanism, we can't VERIFY(m_ref_count) in TreeNode where T may be a DOM::Document.
2021-09-16LibWeb: Use default instead of an empty constructor/destructorBrian Gianforcaro
Default implementations allow for more optimizations. See: https://pvs-studio.com/en/docs/warnings/v832/
2021-09-14LibWeb: Implement ParentNode.childrenLuke Wilde
Required by Web Platform Tests for the innerHTML/outerHTML tests.
2021-09-07LibWeb: Add preceding and following Node cases in tree constraintsLuke Wilde
This also does some east-const changes in TreeNode.
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-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-20LibWeb: Add capabilities to find the index of a child in its parent.Tobias Christiansen
For Elements depending on the index they are inside their parent. Most notably the <ol> element. Also added a typed version to only count children of a certain type. This patch is work towards #2059
2021-04-10AK+Everywhere: Make StdLibExtras templates less wrapper-yAnotherTest
This commit makes the user-facing StdLibExtras templates and utilities arguably more nice-looking by removing the need to reach into the wrapper structs generated by them to get the value/type needed. The C++ standard library had to invent `_v` and `_t` variants (likely because of backwards compat), but we don't need to cater to any codebase except our own, so might as well have good things for free. :^)
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: Add non-inclusive variants of subtree traversalLuke
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: Strip out the mutation event logic from TreeNodeLuke
This will instead be done by Node, as they need to occur at precise steps of the mutation algorithms. Additionally, some of the events may need to be run multiple times. For example, the removal steps is run for all the shadow-including descendants of the node that just got removed.
2021-04-06LibWeb: Sever parent/child connections in ~TreeNode()Andreas Kling
Also make sure to unref the children if there are any. Without this it was very easy to leak TreeNodes.
2021-04-06LibWeb: Remove duplicated code in TreeNode::remove_child()Andreas Kling
We were assigning to m_first_child twice.
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-01-12Libraries: Move to Userland/Libraries/Andreas Kling