Currently, `operator<<(std::ostram&, const nsINode&)` prints the path
of the node with some attribute information of each node. However, there
are some issues:
1. It's unclear if the reached root is a `DocumentFragment` or
`ShadowRoot` due to the same node name, `#document-fragment`.
2. Do not print the host's path.
3. Cannot print only in a specific node such as a `contenteditable`.
4. It's hard to consider which `Text` if a node has multiple `Text`
nodes.
5. No information about the assigned `<slot>`.
6. No information about `EditContext`.
This patch appends these information to each node. Additionally, adding
`format_as()` for avoiding to use `mozilla::ToString` for `fmt::format`
and `MOZ_LOG_FMT`.
Finally, to test the new data, this makes `Selection` and `SelectionAPI`
log use `MOZ_LOG_FMT`.
Differential Revision: https://phabricator.services.mozilla.com/D304964
This will make being more granular with cloning easier, and we don't
need it after the previous patch.
This leaves DeclarationBlock only for the style attribute for now, we
need it for the AttrStyles stuff. But I plan to move that to
MiscContainer instead or so.
Differential Revision: https://phabricator.services.mozilla.com/D300052
Currently Element has the SHADOW_ROOT_IS_DETAILS_SHADOW_TREE flag, which
determines if the element is a Details element and allows branching for specific
shadow root operations, such as getting the slot names, and handlers for slot
changed and unslotted.
This change refactors this to be more generic: switching this branching for
virtual methods instead, while dropping the flag. It also then co-locates the
Details specific shadow root operations into HTMLDetailsElement.cpp.
This will allow us to introduce more element specific Shadow Root behaviours,
such as those for the `<select>` element.
Differential Revision: https://phabricator.services.mozilla.com/D295337
Clone built-in stylesheets that aren't node associated: this fixes
select.css not applying which is what fixes the bug as reported.
Clone pseudo-element type (this fixes the dropmarker not showing up in
appearance: auto mode.
Differential Revision: https://phabricator.services.mozilla.com/D289935
Clone built-in stylesheets that aren't node associated: this fixes
select.css not applying which is what fixes the bug as reported.
Clone pseudo-element type (this fixes the dropmarker not showing up in
appearance: auto mode.
Differential Revision: https://phabricator.services.mozilla.com/D289935
This reverts commit 88008cd8ca.
Revert "Bug 2012637 - part 8: Make `nsContentUtils::ComparePoints` handle `TreeKind::Flat` and `TreeKind::FlatForSelection` correctly r=smaug,dom-core"
This reverts commit 73e6f6587b.
Revert "Bug 2012637 - part 7: Make `RangeUtils::CompareNodeToRangeBoundaries()` use `nsContentUtils::ComparePoints` with valid point in the tree r=smaug"
This reverts commit 6985d5e80f.
Revert "Bug 2012637 - part 6: Make `nsRange::CutContents()` convert the range boundaries to the ones in the DOM before comparing r=smaug"
This reverts commit 73b585af3d.
Revert "Bug 2012637 - part 5: Delete the default template parameter of `nsContentUtils::ComparePoints` and relatives r=smaug,dom-core"
This reverts commit 1a7f24e5b5.
Revert "Bug 2012637 - part 4: Make `nsContentUtils` use `nsIContent` for taking a child node as a parameter r=smaug"
This reverts commit a6ea8d6824.
Revert "Bug 2012637 - part 3: Add template `nsINode` API which can switch to call API from `TreeKind` r=smaug,dom-core,webidl"
This reverts commit a4211e9df0.
Revert "Bug 2012637 - part 2: Add `TreeKind::FlatForSelection` and change the template parameter of `ChildIteratorBase` to `TreeKind` r=smaug,dom-core"
This reverts commit 0241749ee7.
Revert "Bug 2012637 - part 1: Make `ChildIterBase` template class to re-implement `FlattenedChildIterator` for DOM, Flat and FlatForSelection TreeKind r=smaug,dom-core,layout-reviewers,emilio"
This reverts commit 9e71cb77fb.
`FlattenedChildIterator` is a non-template class and work only for the
flattened tree (i.e., in the `TreeKind::Flat` mode).
To centralize the implementation to access children from a parent node
in the various kinds of tree except `ShadowIncludingDOM`, this patch
makes it a template class and support the simple DOM (for
`TreeKind::DOM`), the flattened tree (for`TreeKind::Flat`) and also the
flattened tree for selection whose `TreeKind` will be added by the next
patch.
The reason why this patch does not support
`TreeKind::ShadowIncludingDOM` is, it is not clear that which children
should be handled when the parent is a shadow host, i.e., whether the
children of the host or the `ShadowRoot`. Therefore, the caller should
use `ShadowRoot` if the users want to list up the the children from a
host. Then, the code is really clear about what it does.
Differential Revision: https://phabricator.services.mozilla.com/D281303
This stops penalizing shadow DOM contents by forcing extended slots into
everything inside a shadow tree, but grows nodes by a pointer.
It has an additional benefit of making forgetting a null-check in
GetPrimaryFrame() not cause a type confusion, and is a speedometer 3
progression, specially on the webcomponents-heavy bits, but even more
now that we use Shadow DOM a bit more internally.
Differential Revision: https://phabricator.services.mozilla.com/D283477
Now that stuff is a bit more complex and that we're adding media lazy
loading, factor the observer management down to Element.
Make UnbindContext more parallel to BindContext while at it. This
allows the new calls to work regardless of whether they get called
before or after the base class's Bind/UnbindFromTree, which is nice.
Differential Revision: https://phabricator.services.mozilla.com/D282723
This makes significant changes to RelatedAccIterator, nsLabelsNodeList and nsContentList:
- RelatedAccIterator is now able to walk up shadow roots where appropriate.
- HTMLLabelsIterator now eagerly constructs a TreeOrderedArray of related elements, walking up shadow roots while the shadow root's reference target is either mAcc's content or a host of one of its ancestor shadow roots.
- nsLabelsNodeList now has an array of roots as well as mRootNode in the superclass nsContentList. This list is reset under certain conditions, adding each shadow root found by walking up from the labeled element until one is found which doesn't have either the labeled element or the host of one of its ancestor shadow roots as a reference target. The last element in this list is set as mRootNode in the superclass, and is either the containing document, or the subtree root of either the labeled element or the host element whose containing shadow root doesn't have it as a reference target. Each root has a mutation observer added to ensure that the list is marked dirty when necessary, and also that roots are removed from `mRoots` when they are destroyed.
- In order to enable nsLabelsNodeList to be a mutation observer for each root, nsContentList now inherits from nsStubMultiMutationObserver instead of nsStubMutationObserver.
This change also moves the ReferenceTargetChangeObserver-related methods from DocumentOrShadowRoot on to Element, and the related data structures on to nsExtendedDOMSlots.
It also introduces a distinction between GetControlForBindings, which returns an element in the same scope as the label element it's called on, and GetLabeledElementInternal, which returns the element which actually has the label element as its label.
Differential Revision: https://phabricator.services.mozilla.com/D261368
This change adds attr-associated element observers, which observe changes in the element associated with a single-element attribute.
For example, if an element has an attribute |attr| with a value |value|, and an AttrTargetObserver has been added for |attr| on that element, the observer would fire if an element with an ID matching |value| was added to the element's document or shadow root.
Attr-associated element observers are tracked in mAttrElementObserverMap in an element's nsExtendedDOMSlots.
An attr-associated element can change in multiple ways:
- The attribute value changes;
- An element matching the content attribute value is added or removed from the element's document or shadow root;
- The explicitly-set attr element is added or removed from the element's document or shadow root;
- The resolved reference target for the explicitly set attr-element or the element whose ID matches the string value of the attribute changes.
The resolved reference target can likewise change in multiple ways:
- The referenceTarget property of the element's shadow root is added, changed or removed;
- An element whose ID matches the element's shadow root's referenceTarget value is added or removed from the shadow root;
- The resolved reference target of the element whose ID matches the shadow root's referenceTarget value changes.
These changes are tracked via reference target change observers, which observe changes to an element's resolved reference target.
Reference target change observers are added on the host element's document or shadow root, and fired when one of the above circumstances occurs.
Differential Revision: https://phabricator.services.mozilla.com/D261367
This reverts commit d46abe6d76.
Revert "Bug 1981346 - Add referenceTarget support for the form attribute. r=credential-management-reviewers,webidl,dimi,Jamie,smaug"
This reverts commit df11a4666d.
Revert "Bug 1981345 - Implement referenceTarget support for multiple element attributes. r=dom-core,Jamie,smaug"
This reverts commit 89cc779f5e.
Revert "Bug 1984685 - Refactor: consistently return Maybe<nsTArray<RefPtr<Element>>> when getting attr-associated elements, and key AttrRelProviders on nsAtom rather than nsString. r=dom-core,morgan,Jamie,smaug"
This reverts commit 33130e712d.
Revert "Bug 1981344 - Implement referenceTarget support for single-element attributes. r=dom-core,credential-management-reviewers,webidl,layout-reviewers,emilio,keithamus,smaug,mtigley"
This reverts commit d6440c4cae.
Revert "Bug 1983766 - Split single element attribute getters into bindings/internals versions. r=dom-core,credential-management-reviewers,webidl,layout-reviewers,smaug,keithamus,jwatt,mtigley"
This reverts commit 83b70e0645.
Revert "Bug 1989323 - Make `referenceTarget` IDL attributes on ShadowRoot, HTMLTemplateElement and ShadowRootInit nullable. r=dom-core,webidl,saschanaz,smaug"
This reverts commit 3a0b29121e.
This makes significant changes to RelatedAccIterator, nsLabelsNodeList and nsContentList:
- RelatedAccIterator now eagerly constructs a TreeOrderedArray of related elements, walking up shadow roots from mDependentContent while the shadow root's reference target is either mDependentContent or a host of one of its ancestor shadow roots.
- nsLabelsNodeList now has an array of roots as well as mRootNode in the superclass nsContentList. This list is reset under certain conditions, adding each shadow root found by walking up from the labeled element until one is found which doesn't have either the labeled element or the host of one of its ancestor shadow roots as a reference target. The last element in this list is set as mRootNode in the superclass, and is either the containing document, or the subtree root of either the labeled element or the host element whose containing shadow root doesn't have it as a reference target. Each root has a mutation observer added to ensure that the list is marked dirty when necessary, and also that roots are removed from `mRoots` when they are destroyed.
- In order to enable nsLabelsNodeList to be a mutation observer for each root, nsContentList now inherits from nsStubMultiMutationObserver instead of nsStubMutationObserver.
This change also moves the ReferenceTargetChangeObserver-related methods from DocumentOrShadowRoot on to Element, and the related data structures on to nsExtendedDOMSlots.
It also introduces a distinction between GetControlForBindings, which returns an element in the same scope as the label element it's called on, and GetLabeledElementInternal, which returns the element which actually has the label element as its label.
Differential Revision: https://phabricator.services.mozilla.com/D261368
This change adds attr-associated element observers, which observe changes in the element associated with a single-element attribute.
For example, if an element has an attribute |attr| with a value |value|, and an AttrTargetObserver has been added for |attr| on that element, the observer would fire if an element with an ID matching |value| was added to the element's document or shadow root.
Attr-associated element observers are tracked in mAttrElementObserverMap in an element's nsExtendedDOMSlots.
An attr-associated element can change in multiple ways:
- The attribute value changes;
- An element matching the content attribute value is added or removed from the element's document or shadow root;
- The explicitly-set attr element is added or removed from the element's document or shadow root;
- The resolved reference target for the explicitly set attr-element or the element whose ID matches the string value of the attribute changes.
The resolved reference target can likewise change in multiple ways:
- The referenceTarget property of the element's shadow root is added, changed or removed;
- An element whose ID matches the element's shadow root's referenceTarget value is added or removed from the shadow root;
- The resolved reference target of the element whose ID matches the shadow root's referenceTarget value changes.
These changes are tracked via reference target change observers, which observe changes to an element's resolved reference target.
Reference target change observers are added on the host element's document or shadow root, and fired when one of the above circumstances occurs.
Differential Revision: https://phabricator.services.mozilla.com/D261367
This reverts commit 1b5cf4cdf8.
Revert "Bug 1981346 - Add referenceTarget support for the form attribute. r=credential-management-reviewers,webidl,dimi,Jamie,smaug"
This reverts commit 2394d9205a.
Revert "Bug 1981345 - Implement referenceTarget support for multiple element attributes. r=dom-core,Jamie,smaug"
This reverts commit 571a17ff82.
Revert "Bug 1984685 - Refactor: consistently return Maybe<nsTArray<RefPtr<Element>>> when getting attr-associated elements, and key AttrRelProviders on nsAtom rather than nsString. r=dom-core,morgan,Jamie,smaug"
This reverts commit 3b389fdd62.
Revert "Bug 1981344 - Implement referenceTarget support for single-element attributes. r=dom-core,credential-management-reviewers,webidl,layout-reviewers,emilio,keithamus,smaug,mtigley"
This reverts commit 5cc2a12756.
Revert "Bug 1983766 - Split single element attribute getters into bindings/internals versions. r=dom-core,credential-management-reviewers,webidl,layout-reviewers,smaug,keithamus,jwatt,mtigley"
This reverts commit 68e2d26aa9.
Revert "Bug 1989323 - Make `referenceTarget` IDL attributes on ShadowRoot, HTMLTemplateElement and ShadowRootInit nullable. r=dom-core,webidl,saschanaz,smaug"
This reverts commit 1234b31599.
This makes significant changes to RelatedAccIterator, nsLabelsNodeList and nsContentList:
- RelatedAccIterator now eagerly constructs a TreeOrderedArray of related elements, walking up shadow roots from mDependentContent while the shadow root's reference target is either mDependentContent or a host of one of its ancestor shadow roots.
- nsLabelsNodeList now has an array of roots as well as mRootNode in the superclass nsContentList. This list is reset under certain conditions, adding each shadow root found by walking up from the labeled element until one is found which doesn't have either the labeled element or the host of one of its ancestor shadow roots as a reference target. The last element in this list is set as mRootNode in the superclass, and is either the containing document, or the subtree root of either the labeled element or the host element whose containing shadow root doesn't have it as a reference target. Each root has a mutation observer added to ensure that the list is marked dirty when necessary, and also that roots are removed from `mRoots` when they are destroyed.
- In order to enable nsLabelsNodeList to be a mutation observer for each root, nsContentList now inherits from nsStubMultiMutationObserver instead of nsStubMutationObserver.
This change also moves the ReferenceTargetChangeObserver-related methods from DocumentOrShadowRoot on to Element, and the related data structures on to nsExtendedDOMSlots.
It also introduces a distinction between GetControlForBindings, which returns an element in the same scope as the label element it's called on, and GetLabeledElementInternal, which returns the element which actually has the label element as its label.
Differential Revision: https://phabricator.services.mozilla.com/D261368
This change adds attr-associated element observers, which observe changes in the element associated with a single-element attribute.
For example, if an element has an attribute |attr| with a value |value|, and an AttrTargetObserver has been added for |attr| on that element, the observer would fire if an element with an ID matching |value| was added to the element's document or shadow root.
Attr-associated element observers are tracked in mAttrElementObserverMap in an element's nsExtendedDOMSlots.
An attr-associated element can change in multiple ways:
- The attribute value changes;
- An element matching the content attribute value is added or removed from the element's document or shadow root;
- The explicitly-set attr element is added or removed from the element's document or shadow root;
- The resolved reference target for the explicitly set attr-element or the element whose ID matches the string value of the attribute changes.
The resolved reference target can likewise change in multiple ways:
- The referenceTarget property of the element's shadow root is added, changed or removed;
- An element whose ID matches the element's shadow root's referenceTarget value is added or removed from the shadow root;
- The resolved reference target of the element whose ID matches the shadow root's referenceTarget value changes.
These changes are tracked via reference target change observers, which observe changes to an element's resolved reference target.
Reference target change observers are added on the host element's document or shadow root, and fired when one of the above circumstances occurs.
Differential Revision: https://phabricator.services.mozilla.com/D261367
The previous approach wasn't quite sound, because it makes the frame
constructor receive the WillBeRemoved after the flat tree has already
changed.
Instead, what do you think about something like this? This creates a
very simple wrapper over an array, but special-cases removals from the
front, and uses it for TreeOrderedArray and also AssignedNodes...
It could be polished (in particular there are a few places where an
Span::IndexOf operator could be beneficial and so).
Differential Revision: https://phabricator.services.mozilla.com/D277301
The previous approach wasn't quite sound, because it makes the frame
constructor receive the WillBeRemoved after the flat tree has already
changed.
Instead, what do you think about something like this? This creates a
very simple wrapper over an array, but special-cases removals from the
front, and uses it for TreeOrderedArray and also AssignedNodes...
It could be polished (in particular there are a few places where an
Span::IndexOf operator could be beneficial and so).
Differential Revision: https://phabricator.services.mozilla.com/D277301
This shows up in bug 2000414, where the front-end clears all the
menuitems of a <menupopup> at once, and they are all slotted, and
clearing the assigned node list from the front is more expensive than
necessary. See the profile in: https://share.firefox.dev/493zcYj
Of course, it'd be better to remove back to front, but that would be
observable, and it seems we can improve our batch removal machinery to
deal with this case quite easily, since if all the host kids are going
away, we know we will end up with no assigned nodes at all.
Differential Revision: https://phabricator.services.mozilla.com/D276828
This reverts commit 42f606b166.
Revert "Bug 2006613 - Plumb batch removal state through unbind, and use it to optimize Shadow DOM removal. r=smaug"
This reverts commit 264c0f0437.
This shows up in bug 2000414, where the front-end clears all the
menuitems of a <menupopup> at once, and they are all slotted, and
clearing the assigned node list from the front is more expensive than
necessary. See the profile in: https://share.firefox.dev/493zcYj
Of course, it'd be better to remove back to front, but that would be
observable, and it seems we can improve our batch removal machinery to
deal with this case quite easily, since if all the host kids are going
away, we know we will end up with no assigned nodes at all.
Differential Revision: https://phabricator.services.mozilla.com/D276828
Bug 1933473 missed the shadow root style rule map, this is the
equivalent fix.
The test in D268698 covers this (now it shows the bug but it should be
adapted to expect the right behavior).
Co-authored-by: Nicolas Chevobbe <[email protected]>
Differential Revision: https://phabricator.services.mozilla.com/D268744
Allows setting referenceTarget when creating shadow roots declaratively or programatically, and also getting the referenceTarget value for a shadow root.
Differential Revision: https://phabricator.services.mozilla.com/D260140
Most changes are automated. Relevant bit is dom/.clang-format. I had to
manually disable clang-format in a few places where importing external
files and so on that aren't self-contained, and fix a couple includes /
forward declarations.
Differential Revision: https://phabricator.services.mozilla.com/D256800
iframe tests neeeded tweak because the changes for about:blank haven't landed quite yet.
Render blocking and such aren't supported, so the .ini files are still there.
Selection test seemed to be very chromium specific.
Differential Revision: https://phabricator.services.mozilla.com/D255463
iframe tests neeeded tweak because the changes for about:blank haven't landed quite yet.
Render blocking and such aren't supported, so the .ini files are still there.
Selection test seemed to be very chromium specific.
Differential Revision: https://phabricator.services.mozilla.com/D255463
... This preserves the link between the node and its stylesheet, enabling
implicit scope to continue working for the static document (e.g. For printing).
Differential Revision: https://phabricator.services.mozilla.com/D229531
std::unique_ptr's subtleties are hard for bindgen to cope with.
Bug 1973598 was going to make this workaround even uglier by having to figure
out the specific path for std::unique_ptr in the standard library.
Rather than assuming that all usage bindgen sees is simple, explicitly opt in
the few pointers that we need via a new BindgenUniquePtr, and make opaque the
rest.
Differential Revision: https://phabricator.services.mozilla.com/D255568