Skip to content

Commit

Permalink
up
Browse files Browse the repository at this point in the history
  • Loading branch information
jaytaph committed Sep 16, 2024
1 parent c4adcc8 commit 76a5c49
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 10 deletions.
2 changes: 1 addition & 1 deletion crates/gosub_html5/src/document/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ impl DocumentBuilder {
context_node.location().clone(),
);
let fragment_doc = D::new(DocumentType::HTML, None, Some(&fragment_root_node));
let fragment_handle = DocumentHandle::create(fragment_doc);
let mut fragment_handle = DocumentHandle::create(fragment_doc);

let context_doc_handle = context_node.handle();
match context_doc_handle.get().quirks_mode() {
Expand Down
5 changes: 4 additions & 1 deletion crates/gosub_html5/src/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4362,7 +4362,10 @@ impl<'chars, D: Document> Html5Parser<'chars, D>
if let Some(stylesheet) = self.load_external_stylesheet(CssOrigin::Author, css_url)
{
println!("success: loaded external stylesheet");
self.document.get_mut().stylesheets_mut().push(stylesheet);
let s = self.document.get().get_stylesheets();
s.push(stylesheet);
let mut mut_handle = self.document.clone();
mut_handle.get_mut().set_stylesheets(s);
} else {
println!("failed loading stylesheet")
}
Expand Down
18 changes: 12 additions & 6 deletions crates/gosub_html5/src/parser/helper.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,11 +89,13 @@ where
let node = get_node_by_id!(handle, node_id);
let parent_node = get_node_by_id!(handle, parent);
let position = parent_node.children().iter().position(|&x| x == before);
handle.get_mut().register_node_at(&node, parent, position);
let mut_handle = &mut handle.clone();
mut_handle.get_mut().register_node_at(&node, parent, position);
}
InsertionPositionMode::LastChild { handle, parent } => {
let node = get_node_by_id!(handle, node_id);
handle.get_mut().register_node_at(&node, parent, None);
let mut_handle = &mut handle.clone();
mut_handle.get_mut().register_node_at(&node, parent, None);
}
}
}
Expand All @@ -110,7 +112,8 @@ where
match position {
None | Some(0) => {
let node = self.create_node(token, HTML_NAMESPACE);
handle.get_mut().register_node_at(&node, parent, position);
let mut_handle = &mut handle.clone();
mut_handle.get_mut().register_node_at(&node, parent, position);
}
Some(index) => {
let last_node_id = parent_node.children()[index - 1];
Expand All @@ -124,7 +127,8 @@ where
}

let node = self.create_node(token, HTML_NAMESPACE);
handle.get_mut().register_node_at(&node, parent, Some(index));
let mut_handle = &mut handle.clone();
mut_handle.get_mut().register_node_at(&node, parent, Some(index));
}
}
}
Expand All @@ -141,12 +145,14 @@ where
};

let node = self.create_node(token, HTML_NAMESPACE);
handle.get_mut().register_node_at(&node, parent, None);
let mut_handle = &mut handle.clone();
mut_handle.get_mut().register_node_at(&node, parent, None);
return;
}

let node = self.create_node(token, HTML_NAMESPACE);
handle.get_mut().register_node_at(&node, parent, None);
let mut_handle = &mut handle.clone();
mut_handle.get_mut().register_node_at(&node, parent, None);
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions crates/gosub_shared/src/document.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use std::cell::{Ref, RefCell, RefMut};
use std::fmt::Debug;
use std::rc::{Rc, Weak};
use std::rc::Rc;
use crate::traits::document::Document;

pub struct DocumentHandle<D: Document>(pub Rc<RefCell<D>>);
Expand All @@ -18,7 +18,7 @@ impl<D: Document> DocumentHandle<D> {
}

/// Returns a
pub fn get_mut(&self) -> RefMut<D> {
pub fn get_mut(&mut self) -> RefMut<D> {
self.0.borrow_mut()
}
}
Expand Down

0 comments on commit 76a5c49

Please sign in to comment.