mirror of
https://github.com/servo/servo.git
synced 2025-08-06 14:10:11 +01:00
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:
parent
66695d2f7e
commit
9acb25521e
32 changed files with 425 additions and 274 deletions
|
@ -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)
|
||||
},
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue