CanGc changes from fontfaceset.rs (#33920)

* CanGc changes from fontfaceset.rs

Signed-off-by: L Ashwin B <lashwinib@gmail.com>

* Update components/script/dom/bindings/codegen/Bindings.conf

Co-authored-by: Josh Matthews <josh@joshmatthews.net>
Signed-off-by: chickenleaf <lashwinib@gmail.com>

---------

Signed-off-by: L Ashwin B <lashwinib@gmail.com>
Signed-off-by: chickenleaf <lashwinib@gmail.com>
Co-authored-by: Josh Matthews <josh@joshmatthews.net>
This commit is contained in:
chickenleaf 2024-10-21 17:58:56 +05:30 committed by GitHub
parent 66695d2f7e
commit 9acb25521e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
32 changed files with 425 additions and 274 deletions

View file

@ -75,10 +75,11 @@ impl ResizeObserver {
&self,
depth: &ResizeObservationDepth,
has_active: &mut bool,
can_gc: CanGc,
) {
for (observation, target) in self.observation_targets.borrow_mut().iter_mut() {
observation.state = Default::default();
if let Some(size) = observation.is_active(target) {
if let Some(size) = observation.is_active(target, can_gc) {
let target_depth = calculate_depth_for_node(target);
if target_depth > *depth {
observation.state = ObservationState::Active(size).into();
@ -251,9 +252,9 @@ impl ResizeObservation {
/// <https://drafts.csswg.org/resize-observer/#dom-resizeobservation-isactive>
/// Returning an optional calculated size, instead of a boolean,
/// to avoid recalculating the size in the subsequent broadcast.
fn is_active(&self, target: &Element) -> Option<Rect<Au>> {
fn is_active(&self, target: &Element, can_gc: CanGc) -> Option<Rect<Au>> {
let last_reported_size = self.last_reported_sizes.borrow()[0];
let box_size = calculate_box_size(target, &self.observed_box.borrow());
let box_size = calculate_box_size(target, &self.observed_box.borrow(), can_gc);
let is_active = box_size.width().to_f64_px() != last_reported_size.inline_size() ||
box_size.height().to_f64_px() != last_reported_size.block_size();
if is_active {
@ -272,14 +273,18 @@ fn calculate_depth_for_node(target: &Element) -> ResizeObservationDepth {
}
/// <https://drafts.csswg.org/resize-observer/#calculate-box-size>
fn calculate_box_size(target: &Element, observed_box: &ResizeObserverBoxOptions) -> Rect<Au> {
fn calculate_box_size(
target: &Element,
observed_box: &ResizeObserverBoxOptions,
can_gc: CanGc,
) -> Rect<Au> {
match observed_box {
ResizeObserverBoxOptions::Content_box => {
// Note: only taking first fragment,
// but the spec will expand to cover all fragments.
target
.upcast::<Node>()
.content_boxes()
.content_boxes(can_gc)
.pop()
.unwrap_or_else(Rect::zero)
},