mirror of
https://github.com/servo/servo.git
synced 2025-08-05 21:50:18 +01:00
Auto merge of #14930 - zaynetro:remove-stylesheets, r=emilio
Implement support for removing stylesheets from their document <!-- Please describe your changes on the following line: --> This pull request implements removing styles from the document when * `<link>` element with associated styles is removed * `<style>` element is removed Additionally, it tests that when `<style>` element is changed. Styles are being reapplied correctly. --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: --> - [x] `./mach build -d` does not report any errors - [x] `./mach test-tidy` does not report any errors - [x] These changes fix #14886 (github issue number if applicable). <!-- Either: --> - [x] There are tests for these changes <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. --> <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/14930) <!-- Reviewable:end -->
This commit is contained in:
commit
f3c102d2fe
11 changed files with 180 additions and 24 deletions
|
@ -18,7 +18,7 @@ use dom::element::{AttributeMutation, Element, ElementCreator};
|
|||
use dom::element::{cors_setting_for_element, reflect_cross_origin_attribute, set_cross_origin_attribute};
|
||||
use dom::globalscope::GlobalScope;
|
||||
use dom::htmlelement::HTMLElement;
|
||||
use dom::node::{Node, document_from_node, window_from_node};
|
||||
use dom::node::{Node, UnbindContext, document_from_node, window_from_node};
|
||||
use dom::stylesheet::StyleSheet as DOMStyleSheet;
|
||||
use dom::virtualmethods::VirtualMethods;
|
||||
use html5ever_atoms::LocalName;
|
||||
|
@ -228,6 +228,15 @@ impl VirtualMethods for HTMLLinkElement {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn unbind_from_tree(&self, context: &UnbindContext) {
|
||||
if let Some(ref s) = self.super_type() {
|
||||
s.unbind_from_tree(context);
|
||||
}
|
||||
|
||||
let document = document_from_node(self);
|
||||
document.invalidate_stylesheets();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -15,7 +15,7 @@ use dom::document::Document;
|
|||
use dom::element::{Element, ElementCreator};
|
||||
use dom::eventtarget::EventTarget;
|
||||
use dom::htmlelement::HTMLElement;
|
||||
use dom::node::{ChildrenMutation, Node, document_from_node, window_from_node};
|
||||
use dom::node::{ChildrenMutation, Node, UnbindContext, document_from_node, window_from_node};
|
||||
use dom::stylesheet::StyleSheet as DOMStyleSheet;
|
||||
use dom::virtualmethods::VirtualMethods;
|
||||
use html5ever_atoms::LocalName;
|
||||
|
@ -161,6 +161,15 @@ impl VirtualMethods for HTMLStyleElement {
|
|||
self.parse_own_css();
|
||||
}
|
||||
}
|
||||
|
||||
fn unbind_from_tree(&self, context: &UnbindContext) {
|
||||
if let Some(ref s) = self.super_type() {
|
||||
s.unbind_from_tree(context);
|
||||
}
|
||||
|
||||
let doc = document_from_node(self);
|
||||
doc.invalidate_stylesheets();
|
||||
}
|
||||
}
|
||||
|
||||
impl StylesheetOwner for HTMLStyleElement {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue