1
0
mirror of https://github.com/php/php-src.git synced 2026-03-24 16:22:37 +01:00

17 Commits

Author SHA1 Message Date
Niels Dossche
c7c6a79bd0 Add support for ParentNode::$children (#18908)
ParentNode::$children returns a HTMLCollection of all directly
descendant child elements of a container.

I had to move around some properties such that the ParentNode property
offsets are always at a fixed offset, to simplify the code.
This also adds the necessary code to deal with GC cycles in
HTMLCollections.
Furthermore, we also disable cloning a HTMLCollection as that never
worked and furthermore it also conflicts with the [[SameObject]] WebIDL
requirement of $children.
2025-06-27 09:03:50 +02:00
Niels Dossche
479e9be45d Store hash table entry directly in dom_nnodemap_object
Splits the purpose of the baseobj_zv: now no longer either is an array
or an object. Stores the hash table pointer directly, if used.
2025-06-22 12:30:50 +02:00
Niels Dossche
8526de84a5 Move common obj_map API functions to obj_map.c 2025-06-22 12:30:50 +02:00
Niels Dossche
ff0a2cff05 Refactor implementation of DOM nodelists, named maps, and iterators
The code was really messy with lots of checks and inconsistencies.
This splits everything up into different functions and now everything is
relayed to a handler vtable.
2025-06-21 22:17:33 +02:00
Máté Kocsis
7f59fccd52 Create separate lexbor extension (#18538)
An always enabled lexbor extension is added, containing the lexbor library that was separated from ext/dom extension in preparation of https://wiki.php.net/rfc/url_parsing_api. While at it, the lexbor library is upgraded to 2.5.0.

Co-authored-by: Niels Dossche <7771979+nielsdos@users.noreply.github.com>
Co-authored-by: Gina Peter Banyard <girgias@php.net>
2025-05-25 14:12:44 +02:00
Niels Dossche
7be3649016 Cleanup iterator instantiation code (#17358)
Just using object_init_ex() directly makes the code a bit simpler and
avoids unnecessary indirections.
2025-01-04 16:48:41 +01:00
Niels Dossche
7f5a888bdb Change dom_node_is_read_only() to return bool (#16757)
Returning int or zend_result doesn't make sense, it's a yes/no question.
2024-11-11 20:57:52 +01:00
Niels Dossche
65fbf47472 Fix static analysis warning
The condition is already checked at the start of the function, mark this
code properly as unreachable.
2024-10-30 20:55:50 +01:00
Niels Dossche
947e319b76 Fix GH-16594: Assertion failure in DOM -> before
The invalid parent condition can actually happen because PHP's DOM is
allows to get children of e.g. attributes; something normally not
possible.

Closes GH-16597.
2024-10-28 19:32:20 +01:00
Niels Dossche
97546746d0 Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3:
  Fix GH-16039: Segmentation fault (access null pointer) in ext/dom/parentnode/tree.c
2024-09-25 19:39:49 +02:00
Peter Kokot
7ebdd7d05a Trim trailing whitespace (#15649)
[skip ci]
2024-08-30 01:20:56 +02:00
Niels Dossche
9435f4d55b Throw instead of silently failing when creating a too long text node
Lower branches suffer from this as well but we cannot change the
behaviour there.
We also add NULL checks to check for allocation failure.

Closes GH-15014.
2024-07-21 17:08:06 +02:00
Niels Dossche
d5faf44e90 Remove bogus tree setting code from parentnode/tree.c (#15044)
I don't know why this code was here in the first place, it is present
since the initial implementation. It doesn't make sense because:
1. It would require updating the refcounts if the document wasn't
   actually already set.
2. We enforce that the document is the same as the target document by
   this point, so setting the tree is pointless.
2024-07-21 13:53:12 +02:00
Niels Dossche
29466223d0 Move stricterror fetch to dom_child_removal_preconditions() body 2024-07-20 20:01:55 +02:00
Niels Dossche
74116a4ade Remove impossible condition
The parent's child must exist because otherwise this node could not have
a parent node.
2024-07-20 20:01:55 +02:00
Niels Dossche
80a4783d25 Deduplicate NULL checks in ext/dom (#15015)
This introduces a new helper php_dom_create_nullable_object() that does
the NULL check and puts NULL in return_value. Otherwise it runs
php_dom_create_object(). This deduplicates a bit of code.
2024-07-18 21:20:03 +02:00
Niels Dossche
88da914910 Implement CSS selectors 2024-06-29 13:00:26 -07:00