Introduce BindContext with in_doc and connected flags

Fix some is_in_doc -> is_connected mistakes
This commit is contained in:
Fernando Jiménez Moreno 2019-03-05 18:01:59 +01:00
parent 740aae06ba
commit 813b242419
21 changed files with 105 additions and 84 deletions

View file

@ -13,8 +13,8 @@ use crate::dom::document::Document;
use crate::dom::element::{Element, ElementCreator};
use crate::dom::htmlelement::HTMLElement;
use crate::dom::node::{
document_from_node, stylesheets_owner_from_node, window_from_node, ChildrenMutation, Node,
UnbindContext,
document_from_node, stylesheets_owner_from_node, window_from_node, BindContext,
ChildrenMutation, Node, UnbindContext,
};
use crate::dom::stylesheet::StyleSheet as DOMStyleSheet;
use crate::dom::virtualmethods::VirtualMethods;
@ -187,14 +187,14 @@ impl VirtualMethods for HTMLStyleElement {
}
}
fn bind_to_tree(&self, tree_connected: bool) {
self.super_type().unwrap().bind_to_tree(tree_connected);
fn bind_to_tree(&self, context: &BindContext) {
self.super_type().unwrap().bind_to_tree(context);
// https://html.spec.whatwg.org/multipage/#update-a-style-block
// Handles the case when:
// "The element is not on the stack of open elements of an HTML parser or XML parser,
// and it becomes connected or disconnected."
if tree_connected && !self.in_stack_of_open_elements.get() {
if context.tree_connected && !self.in_stack_of_open_elements.get() {
self.parse_own_css();
}
}