mirror of
https://github.com/servo/servo.git
synced 2025-08-03 04:30:10 +01:00
Move more bindings types to script_bindings (#35620)
* Move weak references implementation to script_bindings. Signed-off-by: Josh Matthews <josh@joshmatthews.net> * Move maplike/setlike definitions to script_bindings. Signed-off-by: Josh Matthews <josh@joshmatthews.net> * Move base error types to script_bindings. Signed-off-by: Josh Matthews <josh@joshmatthews.net> * Formatting. Signed-off-by: Josh Matthews <josh@joshmatthews.net> --------- Signed-off-by: Josh Matthews <josh@joshmatthews.net>
This commit is contained in:
parent
0383ba9a5b
commit
381e168877
21 changed files with 435 additions and 391 deletions
|
@ -12,6 +12,7 @@ use style::stylesheets::{
|
|||
RulesMutateError, StylesheetLoader as StyleStylesheetLoader,
|
||||
};
|
||||
|
||||
use crate::conversions::Convert;
|
||||
use crate::dom::bindings::cell::DomRefCell;
|
||||
use crate::dom::bindings::codegen::Bindings::CSSRuleListBinding::CSSRuleListMethods;
|
||||
use crate::dom::bindings::error::{Error, ErrorResult, Fallible};
|
||||
|
@ -27,9 +28,9 @@ use crate::stylesheet_loader::StylesheetLoader;
|
|||
|
||||
unsafe_no_jsmanaged_fields!(RulesSource);
|
||||
|
||||
impl From<RulesMutateError> for Error {
|
||||
fn from(other: RulesMutateError) -> Self {
|
||||
match other {
|
||||
impl Convert<Error> for RulesMutateError {
|
||||
fn convert(self) -> Error {
|
||||
match self {
|
||||
RulesMutateError::Syntax => Error::Syntax,
|
||||
RulesMutateError::IndexSize => Error::IndexSize,
|
||||
RulesMutateError::HierarchyRequest => Error::HierarchyRequest,
|
||||
|
@ -124,16 +125,18 @@ impl CSSRuleList {
|
|||
let loader = owner
|
||||
.as_ref()
|
||||
.map(|element| StylesheetLoader::for_element(element));
|
||||
let new_rule = css_rules.insert_rule(
|
||||
&parent_stylesheet.shared_lock,
|
||||
rule,
|
||||
&parent_stylesheet.contents,
|
||||
index,
|
||||
containing_rule_types,
|
||||
parse_relative_rule_type,
|
||||
loader.as_ref().map(|l| l as &dyn StyleStylesheetLoader),
|
||||
AllowImportRules::Yes,
|
||||
)?;
|
||||
let new_rule = css_rules
|
||||
.insert_rule(
|
||||
&parent_stylesheet.shared_lock,
|
||||
rule,
|
||||
&parent_stylesheet.contents,
|
||||
index,
|
||||
containing_rule_types,
|
||||
parse_relative_rule_type,
|
||||
loader.as_ref().map(|l| l as &dyn StyleStylesheetLoader),
|
||||
AllowImportRules::Yes,
|
||||
)
|
||||
.map_err(Convert::convert)?;
|
||||
|
||||
let parent_stylesheet = &*self.parent_stylesheet;
|
||||
let dom_rule = CSSRule::new_specific(window, parent_stylesheet, new_rule, can_gc);
|
||||
|
@ -150,7 +153,10 @@ impl CSSRuleList {
|
|||
|
||||
match self.rules {
|
||||
RulesSource::Rules(ref css_rules) => {
|
||||
css_rules.write_with(&mut guard).remove_rule(index)?;
|
||||
css_rules
|
||||
.write_with(&mut guard)
|
||||
.remove_rule(index)
|
||||
.map_err(Convert::convert)?;
|
||||
let mut dom_rules = self.dom_rules.borrow_mut();
|
||||
if let Some(r) = dom_rules[index].get() {
|
||||
r.detach()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue