mirror of
https://github.com/servo/servo.git
synced 2025-06-06 16:45:39 +00:00
cangc fixes in node.rs (#33984)
Signed-off-by: L Ashwin B <lashwinib@gmail.com>
This commit is contained in:
parent
3ed778150f
commit
bb4932026c
97 changed files with 1038 additions and 534 deletions
|
@ -57,7 +57,7 @@ pub enum CSSStyleOwner {
|
|||
impl CSSStyleOwner {
|
||||
// Mutate the declaration block associated to this style owner, and
|
||||
// optionally indicate if it has changed (assumed to be true).
|
||||
fn mutate_associated_block<F, R>(&self, f: F) -> R
|
||||
fn mutate_associated_block<F, R>(&self, f: F, can_gc: CanGc) -> R
|
||||
where
|
||||
F: FnOnce(&mut PropertyDeclarationBlock, &mut bool) -> R,
|
||||
{
|
||||
|
@ -103,6 +103,7 @@ impl CSSStyleOwner {
|
|||
el.set_attribute(
|
||||
&local_name!("style"),
|
||||
AttrValue::Declaration(serialization, pdb),
|
||||
can_gc,
|
||||
);
|
||||
}
|
||||
} else {
|
||||
|
@ -287,61 +288,64 @@ impl CSSStyleDeclaration {
|
|||
return Ok(());
|
||||
}
|
||||
|
||||
self.owner.mutate_associated_block(|pdb, changed| {
|
||||
if value.is_empty() {
|
||||
// Step 3
|
||||
*changed = remove_property(pdb, &id);
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
// Step 4
|
||||
let importance = match &*priority {
|
||||
"" => Importance::Normal,
|
||||
p if p.eq_ignore_ascii_case("important") => Importance::Important,
|
||||
_ => {
|
||||
*changed = false;
|
||||
self.owner.mutate_associated_block(
|
||||
|pdb, changed| {
|
||||
if value.is_empty() {
|
||||
// Step 3
|
||||
*changed = remove_property(pdb, &id);
|
||||
return Ok(());
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
// Step 5
|
||||
let window = self.owner.window();
|
||||
let quirks_mode = window.Document().quirks_mode();
|
||||
let mut declarations = SourcePropertyDeclaration::default();
|
||||
let result = parse_one_declaration_into(
|
||||
&mut declarations,
|
||||
id,
|
||||
&value,
|
||||
Origin::Author,
|
||||
&UrlExtraData(self.owner.base_url().get_arc()),
|
||||
window.css_error_reporter(),
|
||||
ParsingMode::DEFAULT,
|
||||
quirks_mode,
|
||||
CssRuleType::Style,
|
||||
);
|
||||
// Step 4
|
||||
let importance = match &*priority {
|
||||
"" => Importance::Normal,
|
||||
p if p.eq_ignore_ascii_case("important") => Importance::Important,
|
||||
_ => {
|
||||
*changed = false;
|
||||
return Ok(());
|
||||
},
|
||||
};
|
||||
|
||||
// Step 6
|
||||
match result {
|
||||
Ok(()) => {},
|
||||
Err(_) => {
|
||||
*changed = false;
|
||||
// Step 5
|
||||
let window = self.owner.window();
|
||||
let quirks_mode = window.Document().quirks_mode();
|
||||
let mut declarations = SourcePropertyDeclaration::default();
|
||||
let result = parse_one_declaration_into(
|
||||
&mut declarations,
|
||||
id,
|
||||
&value,
|
||||
Origin::Author,
|
||||
&UrlExtraData(self.owner.base_url().get_arc()),
|
||||
window.css_error_reporter(),
|
||||
ParsingMode::DEFAULT,
|
||||
quirks_mode,
|
||||
CssRuleType::Style,
|
||||
);
|
||||
|
||||
// Step 6
|
||||
match result {
|
||||
Ok(()) => {},
|
||||
Err(_) => {
|
||||
*changed = false;
|
||||
return Ok(());
|
||||
},
|
||||
}
|
||||
|
||||
let mut updates = Default::default();
|
||||
*changed = pdb.prepare_for_update(&declarations, importance, &mut updates);
|
||||
|
||||
if !*changed {
|
||||
return Ok(());
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
let mut updates = Default::default();
|
||||
*changed = pdb.prepare_for_update(&declarations, importance, &mut updates);
|
||||
// Step 7
|
||||
// Step 8
|
||||
pdb.update(declarations.drain(), importance, &mut updates);
|
||||
|
||||
if !*changed {
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
// Step 7
|
||||
// Step 8
|
||||
pdb.update(declarations.drain(), importance, &mut updates);
|
||||
|
||||
Ok(())
|
||||
})
|
||||
Ok(())
|
||||
},
|
||||
CanGc::note(),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -435,7 +439,7 @@ impl CSSStyleDeclarationMethods for CSSStyleDeclaration {
|
|||
}
|
||||
|
||||
// https://dev.w3.org/csswg/cssom/#dom-cssstyledeclaration-removeproperty
|
||||
fn RemoveProperty(&self, property: DOMString) -> Fallible<DOMString> {
|
||||
fn RemoveProperty(&self, property: DOMString, can_gc: CanGc) -> Fallible<DOMString> {
|
||||
// Step 1
|
||||
if self.readonly {
|
||||
return Err(Error::NoModificationAllowed);
|
||||
|
@ -447,10 +451,13 @@ impl CSSStyleDeclarationMethods for CSSStyleDeclaration {
|
|||
};
|
||||
|
||||
let mut string = String::new();
|
||||
self.owner.mutate_associated_block(|pdb, changed| {
|
||||
pdb.property_value_to_css(&id, &mut string).unwrap();
|
||||
*changed = remove_property(pdb, &id);
|
||||
});
|
||||
self.owner.mutate_associated_block(
|
||||
|pdb, changed| {
|
||||
pdb.property_value_to_css(&id, &mut string).unwrap();
|
||||
*changed = remove_property(pdb, &id);
|
||||
},
|
||||
can_gc,
|
||||
);
|
||||
|
||||
// Step 6
|
||||
Ok(DOMString::from(string))
|
||||
|
@ -498,7 +505,7 @@ impl CSSStyleDeclarationMethods for CSSStyleDeclaration {
|
|||
}
|
||||
|
||||
// https://drafts.csswg.org/cssom/#dom-cssstyledeclaration-csstext
|
||||
fn SetCssText(&self, value: DOMString) -> ErrorResult {
|
||||
fn SetCssText(&self, value: DOMString, can_gc: CanGc) -> ErrorResult {
|
||||
let window = self.owner.window();
|
||||
|
||||
// Step 1
|
||||
|
@ -507,16 +514,19 @@ impl CSSStyleDeclarationMethods for CSSStyleDeclaration {
|
|||
}
|
||||
|
||||
let quirks_mode = window.Document().quirks_mode();
|
||||
self.owner.mutate_associated_block(|pdb, _changed| {
|
||||
// Step 3
|
||||
*pdb = parse_style_attribute(
|
||||
&value,
|
||||
&UrlExtraData(self.owner.base_url().get_arc()),
|
||||
window.css_error_reporter(),
|
||||
quirks_mode,
|
||||
CssRuleType::Style,
|
||||
);
|
||||
});
|
||||
self.owner.mutate_associated_block(
|
||||
|pdb, _changed| {
|
||||
// Step 3
|
||||
*pdb = parse_style_attribute(
|
||||
&value,
|
||||
&UrlExtraData(self.owner.base_url().get_arc()),
|
||||
window.css_error_reporter(),
|
||||
quirks_mode,
|
||||
CssRuleType::Style,
|
||||
);
|
||||
},
|
||||
can_gc,
|
||||
);
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue