aboutsummaryrefslogtreecommitdiffstats
path: root/components/style
diff options
context:
space:
mode:
authorXidorn Quan <me@upsuper.org>2017-06-13 10:07:06 +1000
committerXidorn Quan <me@upsuper.org>2017-06-13 10:07:06 +1000
commitcdc537f23e1da29b98e203c5ad7176b49df5450b (patch)
treef1cec1a27dd118d32628ebbb886bb2d14582716c /components/style
parent1b077303237d5ecb8307f866e9172d0d8e6b132d (diff)
downloadservo-cdc537f23e1da29b98e203c5ad7176b49df5450b.tar.gz
servo-cdc537f23e1da29b98e203c5ad7176b49df5450b.zip
Bug 1331291 part 1 - Set stylesheet url_data correctly for import rule.
Diffstat (limited to 'components/style')
-rw-r--r--components/style/encoding_support.rs2
-rw-r--r--components/style/stylesheets/keyframes_rule.rs3
-rw-r--r--components/style/stylesheets/mod.rs3
-rw-r--r--components/style/stylesheets/rule_parser.rs2
-rw-r--r--components/style/stylesheets/stylesheet.rs13
5 files changed, 12 insertions, 11 deletions
diff --git a/components/style/encoding_support.rs b/components/style/encoding_support.rs
index af37e20889a..4f6365ffeae 100644
--- a/components/style/encoding_support.rs
+++ b/components/style/encoding_support.rs
@@ -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(
diff --git a/components/style/stylesheets/keyframes_rule.rs b/components/style/stylesheets/keyframes_rule.rs
index 2f63ec5ad1a..c87477a617b 100644
--- a/components/style/stylesheets/keyframes_rule.rs
+++ b/components/style/stylesheets/keyframes_rule.rs
@@ -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,
diff --git a/components/style/stylesheets/mod.rs b/components/style/stylesheets/mod.rs
index df1bd2ae3c2..67354889b93 100644
--- a/components/style/stylesheets/mod.rs
+++ b/components/style/stylesheets/mod.rs
@@ -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,
diff --git a/components/style/stylesheets/rule_parser.rs b/components/style/stylesheets/rule_parser.rs
index dd39070c977..34db0c1d69f 100644
--- a/components/style/stylesheets/rule_parser.rs
+++ b/components/style/stylesheets/rule_parser.rs
@@ -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),
diff --git a/components/style/stylesheets/stylesheet.rs b/components/style/stylesheets/stylesheet.rs
index aefcb0ff926..db49e109687 100644
--- a/components/style/stylesheets/stylesheet.rs
+++ b/components/style/stylesheets/stylesheet.rs
@@ -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(