Hi,
`|RefPtr|`, `|nsCOMPtr|`, `|mozilla::OwningNonNull|`,
`|mozilla::StaticAutoPtr|` and `|mozilla::StaticRefPtr|` become
formattable with {fmt}, i.e., `|fmt::format|` and `|MOZ_LOG_FMT|`. So,
you can now write as:
```cpp
RefPtr<Foo> bar = MakeRefPtr<Foo>();
NS_WARNING(fmt::format("{}", bar);
```
So, you don't need to use `|mozilla::ToString|`.
The format is, if it's non-null, redirect to the formatter or
`|operator<<|` of the type and prints an at-mark and the pointer's
address, the result is the same as the traditional `|RefPtr|`, but now
prints the instance prettier if the class is formattable but there is no
`operator<<` overload for the class.
Additionally, I improved `|nsINode|`'s printing code.
First, `|nsINode|` is now formattable, i.e., you don't need to use
`|mozilla::ToString|` for printing its reference.
Next, there are some additional information.
Previously, it prints its path in the subtree if it's not connected to
the document. The new code will print all ancestors with crossing the
shadow DOM boundaries.
Next, if the node is an unassigned node to any |<slot>| even though it's
an slottable node (i.e., a child of a shadow host element), then, when
printing the parent shadow host element, the new code will print the
element has a shadow.
And also if the node is a `|CharacterData|` like a `|Text|` or
`|Comment|`, it will print the data at most 8 characters. However, for
the privacy concern, the data is not printed if the node is in the UA
shadow of a text control element like an |<input type="text">| or
|<textarea>|.
Finally, I tried to make `|mozilla::Maybe|` formattable, but oddly,
{fmt} does not treat it as formattable even if I define `|format_as|`
explicitly. Therefore, you're welcome to fix this issue in bug 2047496
<https://bugzilla.mozilla.org/show_bug.cgi?id=2047496> 😉
* Bug 2045592 - Make a friend `format_as` of `RefPtr`, `nsCOMPtr`,
`OwningNonNull` <https://bugzilla.mozilla.org/show_bug.cgi?id=2045592>
* Bug 2045219 - Improve the dump result of `nsINode`
<https://bugzilla.mozilla.org/show_bug.cgi?id=2045219>
* Bug 2047496 - Make `mozilla::Maybe` formattable
<https://bugzilla.mozilla.org/show_bug.cgi?id=2047496>
Thank you!
--
Masayuki Nakano<[email protected]>
Working on DOM, Events, editor and IME handling for Gecko
--
You received this message because you are subscribed to the Google Groups
"[email protected]" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion visit
https://groups.google.com/a/mozilla.org/d/msgid/dev-platform/5fa12dd1-39fa-405b-992e-439fd3f0a1ed%40d-toybox.com.