mirror of
https://github.com/servo/servo.git
synced 2025-08-05 21:50:18 +01:00
Auto merge of #18484 - emilio:per-origin-sheets, r=SimonSapin
style: Store stylesheets per origin This is the first step that will allow us to cache UA sheets across documents. <!-- 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/18484) <!-- Reviewable:end -->
This commit is contained in:
commit
d461347adf
8 changed files with 221 additions and 101 deletions
|
@ -141,7 +141,7 @@ use style::selector_parser::{RestyleDamage, Snapshot};
|
|||
use style::shared_lock::{SharedRwLock as StyleSharedRwLock, SharedRwLockReadGuard};
|
||||
use style::str::{HTML_SPACE_CHARACTERS, split_html_space_chars, str_join};
|
||||
use style::stylesheet_set::StylesheetSet;
|
||||
use style::stylesheets::{Stylesheet, StylesheetContents, OriginSet};
|
||||
use style::stylesheets::{Stylesheet, StylesheetContents, Origin, OriginSet};
|
||||
use task_source::TaskSource;
|
||||
use time;
|
||||
use timers::OneshotTimerCallback;
|
||||
|
@ -2435,7 +2435,7 @@ impl Document {
|
|||
pub fn stylesheet_at(&self, index: usize) -> Option<Root<CSSStyleSheet>> {
|
||||
let stylesheets = self.stylesheets.borrow();
|
||||
|
||||
stylesheets.get(index).and_then(|s| {
|
||||
stylesheets.get(Origin::Author, index).and_then(|s| {
|
||||
s.owner.upcast::<Node>().get_cssom_stylesheet()
|
||||
})
|
||||
}
|
||||
|
|
|
@ -242,8 +242,8 @@ impl VirtualMethods for HTMLLinkElement {
|
|||
s.unbind_from_tree(context);
|
||||
}
|
||||
|
||||
if let Some(ref s) = *self.stylesheet.borrow() {
|
||||
document_from_node(self).remove_stylesheet(self.upcast(), s);
|
||||
if let Some(s) = self.stylesheet.borrow_mut().take() {
|
||||
document_from_node(self).remove_stylesheet(self.upcast(), &s);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -196,8 +196,8 @@ impl VirtualMethods for HTMLMetaElement {
|
|||
if context.tree_in_doc {
|
||||
self.process_referrer_attribute();
|
||||
|
||||
if let Some(ref s) = *self.stylesheet.borrow() {
|
||||
document_from_node(self).remove_stylesheet(self.upcast(), s);
|
||||
if let Some(s) = self.stylesheet.borrow_mut().take() {
|
||||
document_from_node(self).remove_stylesheet(self.upcast(), &s);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -190,9 +190,8 @@ impl VirtualMethods for HTMLStyleElement {
|
|||
}
|
||||
|
||||
if context.tree_in_doc {
|
||||
if let Some(ref s) = *self.stylesheet.borrow() {
|
||||
let doc = document_from_node(self);
|
||||
doc.remove_stylesheet(self.upcast(), s)
|
||||
if let Some(s) = self.stylesheet.borrow_mut().take() {
|
||||
document_from_node(self).remove_stylesheet(self.upcast(), &s)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue