mirror of
https://github.com/servo/servo.git
synced 2025-06-06 16:45:39 +00:00
Bug 1331291 part 1 - Set stylesheet url_data correctly for import rule.
This commit is contained in:
parent
1b07730323
commit
cdc537f23e
10 changed files with 18 additions and 16 deletions
|
@ -147,7 +147,7 @@ impl CSSStyleOwner {
|
|||
match *self {
|
||||
CSSStyleOwner::Element(ref el) => window_from_node(&**el).Document().base_url(),
|
||||
CSSStyleOwner::CSSRule(ref rule, _) => {
|
||||
rule.parent_stylesheet().style_stylesheet().url_data.clone()
|
||||
(*rule.parent_stylesheet().style_stylesheet().url_data.read()).clone()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,6 +19,7 @@ use dom::node::{Node, UnbindContext, document_from_node, window_from_node};
|
|||
use dom::virtualmethods::VirtualMethods;
|
||||
use dom_struct::dom_struct;
|
||||
use html5ever::{LocalName, Prefix};
|
||||
use parking_lot::RwLock;
|
||||
use servo_config::prefs::PREFS;
|
||||
use std::ascii::AsciiExt;
|
||||
use std::sync::atomic::AtomicBool;
|
||||
|
@ -105,7 +106,7 @@ impl HTMLMetaElement {
|
|||
rules: CssRules::new(vec![rule], shared_lock),
|
||||
origin: Origin::Author,
|
||||
shared_lock: shared_lock.clone(),
|
||||
url_data: window_from_node(self).get_url(),
|
||||
url_data: RwLock::new(window_from_node(self).get_url()),
|
||||
namespaces: Default::default(),
|
||||
media: Arc::new(shared_lock.wrap(MediaList::empty())),
|
||||
// Viewport constraints are always recomputed on resize; they don't need to
|
||||
|
|
|
@ -160,7 +160,7 @@ impl FetchResponseListener for StylesheetContext {
|
|||
&data,
|
||||
protocol_encoding_label,
|
||||
Some(environment_encoding),
|
||||
&final_url,
|
||||
final_url,
|
||||
Some(&loader),
|
||||
win.css_error_reporter());
|
||||
}
|
||||
|
|
|
@ -79,7 +79,7 @@ impl Stylesheet {
|
|||
bytes: &[u8],
|
||||
protocol_encoding_label: Option<&str>,
|
||||
environment_encoding: Option<EncodingRef>,
|
||||
url_data: &UrlExtraData,
|
||||
url_data: UrlExtraData,
|
||||
stylesheet_loader: Option<&StylesheetLoader>,
|
||||
error_reporter: &ParseErrorReporter) {
|
||||
let (string, _) = decode_stylesheet_bytes(
|
||||
|
|
|
@ -205,9 +205,10 @@ impl Keyframe {
|
|||
/// Parse a CSS keyframe.
|
||||
pub fn parse<'i>(css: &'i str, parent_stylesheet: &Stylesheet)
|
||||
-> Result<Arc<Locked<Self>>, ParseError<'i>> {
|
||||
let url_data = parent_stylesheet.url_data.read();
|
||||
let error_reporter = NullReporter;
|
||||
let context = ParserContext::new(parent_stylesheet.origin,
|
||||
&parent_stylesheet.url_data,
|
||||
&url_data,
|
||||
&error_reporter,
|
||||
Some(CssRuleType::Keyframe),
|
||||
PARSING_MODE_DEFAULT,
|
||||
|
|
|
@ -224,10 +224,11 @@ impl CssRule {
|
|||
state: Option<State>,
|
||||
loader: Option<&StylesheetLoader>
|
||||
) -> Result<(Self, State), SingleRuleParseError> {
|
||||
let url_data = parent_stylesheet.url_data.read();
|
||||
let error_reporter = NullReporter;
|
||||
let context = ParserContext::new(
|
||||
parent_stylesheet.origin,
|
||||
&parent_stylesheet.url_data,
|
||||
&url_data,
|
||||
&error_reporter,
|
||||
None,
|
||||
PARSING_MODE_DEFAULT,
|
||||
|
|
|
@ -180,7 +180,7 @@ impl<'a, 'i> AtRuleParser<'i> for TopLevelRuleParser<'a> {
|
|||
media: media,
|
||||
shared_lock: self.shared_lock.clone(),
|
||||
origin: self.context.stylesheet_origin,
|
||||
url_data: self.context.url_data.clone(),
|
||||
url_data: RwLock::new(self.context.url_data.clone()),
|
||||
namespaces: RwLock::new(Namespaces::default()),
|
||||
dirty_on_viewport_size_change: AtomicBool::new(false),
|
||||
disabled: AtomicBool::new(false),
|
||||
|
|
|
@ -52,7 +52,7 @@ pub struct Stylesheet {
|
|||
/// The origin of this stylesheet.
|
||||
pub origin: Origin,
|
||||
/// The url data this stylesheet should use.
|
||||
pub url_data: UrlExtraData,
|
||||
pub url_data: RwLock<UrlExtraData>,
|
||||
/// The lock used for objects inside this stylesheet
|
||||
pub shared_lock: SharedRwLock,
|
||||
/// The namespaces that apply to this stylesheet.
|
||||
|
@ -69,17 +69,15 @@ impl Stylesheet {
|
|||
/// Updates an empty stylesheet from a given string of text.
|
||||
pub fn update_from_str(existing: &Stylesheet,
|
||||
css: &str,
|
||||
url_data: &UrlExtraData,
|
||||
url_data: UrlExtraData,
|
||||
stylesheet_loader: Option<&StylesheetLoader>,
|
||||
error_reporter: &ParseErrorReporter,
|
||||
line_number_offset: u64) {
|
||||
let namespaces = RwLock::new(Namespaces::default());
|
||||
// FIXME: we really should update existing.url_data with the given url_data,
|
||||
// otherwise newly inserted rule may not have the right base url.
|
||||
let (rules, dirty_on_viewport_size_change) =
|
||||
Stylesheet::parse_rules(
|
||||
css,
|
||||
url_data,
|
||||
&url_data,
|
||||
existing.origin,
|
||||
&mut *namespaces.write(),
|
||||
&existing.shared_lock,
|
||||
|
@ -89,6 +87,7 @@ impl Stylesheet {
|
|||
line_number_offset
|
||||
);
|
||||
|
||||
*existing.url_data.write() = url_data;
|
||||
mem::swap(&mut *existing.namespaces.write(), &mut *namespaces.write());
|
||||
existing.dirty_on_viewport_size_change
|
||||
.store(dirty_on_viewport_size_change, Ordering::Release);
|
||||
|
@ -184,7 +183,7 @@ impl Stylesheet {
|
|||
|
||||
Stylesheet {
|
||||
origin: origin,
|
||||
url_data: url_data,
|
||||
url_data: RwLock::new(url_data),
|
||||
namespaces: namespaces,
|
||||
rules: CssRules::new(rules, &shared_lock),
|
||||
media: media,
|
||||
|
@ -287,7 +286,7 @@ impl Clone for Stylesheet {
|
|||
rules: Arc::new(lock.wrap(cloned_rules)),
|
||||
media: Arc::new(lock.wrap(cloned_media)),
|
||||
origin: self.origin,
|
||||
url_data: self.url_data.clone(),
|
||||
url_data: RwLock::new((*self.url_data.read()).clone()),
|
||||
shared_lock: lock,
|
||||
namespaces: RwLock::new((*self.namespaces.read()).clone()),
|
||||
dirty_on_viewport_size_change: AtomicBool::new(
|
||||
|
|
|
@ -801,7 +801,7 @@ pub extern "C" fn Servo_StyleSheet_ClearAndUpdate(stylesheet: RawServoStyleSheet
|
|||
};
|
||||
|
||||
let sheet = Stylesheet::as_arc(&stylesheet);
|
||||
Stylesheet::update_from_str(&sheet, input, url_data, loader,
|
||||
Stylesheet::update_from_str(&sheet, input, url_data.clone(), loader,
|
||||
&RustLogReporter, line_number_offset as u64);
|
||||
}
|
||||
|
||||
|
|
|
@ -76,7 +76,7 @@ fn test_parse_stylesheet() {
|
|||
media: Arc::new(stylesheet.shared_lock.wrap(MediaList::empty())),
|
||||
shared_lock: stylesheet.shared_lock.clone(),
|
||||
namespaces: RwLock::new(namespaces),
|
||||
url_data: url,
|
||||
url_data: RwLock::new(url),
|
||||
dirty_on_viewport_size_change: AtomicBool::new(false),
|
||||
disabled: AtomicBool::new(false),
|
||||
quirks_mode: QuirksMode::NoQuirks,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue