зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1914449 - Fix stylesheet cloning in presence of both @layer and @import. r=zrhoffman,firefox-style-system-reviewers
Hopefully the test for bug 1912996 would catch this. Differential Revision: https://phabricator.services.mozilla.com/D220083
This commit is contained in:
Родитель
01124ea9cc
Коммит
baba6ff61c
|
@ -415,21 +415,13 @@ const StyleLockedDeclarationBlock* Gecko_GetUnvisitedLinkAttrDeclarationBlock(
|
|||
return attrStyles->GetServoUnvisitedLinkDecl();
|
||||
}
|
||||
|
||||
StyleSheet* Gecko_StyleSheet_Clone(const StyleSheet* aSheet,
|
||||
const StyleSheet* aNewParentSheet) {
|
||||
StyleSheet* Gecko_StyleSheet_Clone(const StyleSheet* aSheet) {
|
||||
MOZ_ASSERT(aSheet);
|
||||
MOZ_ASSERT(aSheet->GetParentSheet(), "Should only be used for @import");
|
||||
MOZ_ASSERT(aNewParentSheet, "Wat");
|
||||
|
||||
RefPtr<StyleSheet> newSheet =
|
||||
aSheet->Clone(const_cast<StyleSheet*>(aNewParentSheet), nullptr);
|
||||
|
||||
// NOTE(emilio): This code runs in the StylesheetInner constructor, which
|
||||
// means that the inner pointer of `aNewParentSheet` still points to the old
|
||||
// one.
|
||||
//
|
||||
// So we _don't_ update neither the parent pointer of the stylesheet, nor the
|
||||
// child list (yet). This is fixed up in that same constructor.
|
||||
// NOTE(emilio): We don't pass either the parent pointer of the stylesheet,
|
||||
// nor fix up the child list (yet). This is fixed up in the StylesheetInner
|
||||
// constructor.
|
||||
RefPtr<StyleSheet> newSheet = aSheet->Clone(nullptr, nullptr);
|
||||
return static_cast<StyleSheet*>(newSheet.forget().take());
|
||||
}
|
||||
|
||||
|
|
|
@ -476,9 +476,7 @@ GeckoFontMetrics Gecko_GetFontMetrics(const nsPresContext*, bool is_vertical,
|
|||
bool use_user_font_set,
|
||||
bool retrieve_math_scales);
|
||||
|
||||
mozilla::StyleSheet* Gecko_StyleSheet_Clone(
|
||||
const mozilla::StyleSheet* aSheet,
|
||||
const mozilla::StyleSheet* aNewParentSheet);
|
||||
mozilla::StyleSheet* Gecko_StyleSheet_Clone(const mozilla::StyleSheet* aSheet);
|
||||
|
||||
void Gecko_StyleSheet_AddRef(const mozilla::StyleSheet* aSheet);
|
||||
void Gecko_StyleSheet_Release(const mozilla::StyleSheet* aSheet);
|
||||
|
|
|
@ -408,8 +408,7 @@ StyleSheetInfo::StyleSheetInfo(StyleSheetInfo& aCopy, StyleSheet* aPrimarySheet)
|
|||
// We don't rebuild the child because we're making a copy without
|
||||
// children.
|
||||
mSourceMapURL(aCopy.mSourceMapURL),
|
||||
mContents(Servo_StyleSheet_Clone(aCopy.mContents.get(), aPrimarySheet)
|
||||
.Consume()),
|
||||
mContents(Servo_StyleSheet_Clone(aCopy.mContents.get()).Consume()),
|
||||
mURLData(aCopy.mURLData)
|
||||
#ifdef DEBUG
|
||||
,
|
||||
|
@ -1139,21 +1138,38 @@ void StyleSheet::FixUpAfterInnerClone() {
|
|||
|
||||
RefPtr<StyleLockedCssRules> rules =
|
||||
Servo_StyleSheet_GetRules(Inner().mContents.get()).Consume();
|
||||
uint32_t index = 0;
|
||||
while (true) {
|
||||
uint32_t line, column; // Actually unused.
|
||||
RefPtr<StyleLockedImportRule> import =
|
||||
Servo_CssRules_GetImportRuleAt(rules, index, &line, &column).Consume();
|
||||
if (!import) {
|
||||
// Note that only @charset rules come before @import rules, and @charset
|
||||
// rules are parsed but skipped, so we can stop iterating as soon as we
|
||||
// find something that isn't an @import rule.
|
||||
size_t len = Servo_CssRules_GetRuleCount(rules.get());
|
||||
bool reachedBody = false;
|
||||
for (size_t i = 0; i < len; ++i) {
|
||||
switch (Servo_CssRules_GetRuleTypeAt(rules, i)) {
|
||||
case StyleCssRuleType::Import: {
|
||||
MOZ_ASSERT(!reachedBody);
|
||||
uint32_t line, column; // Actually unused.
|
||||
RefPtr<StyleLockedImportRule> import =
|
||||
Servo_CssRules_GetImportRuleAt(rules, i, &line, &column).Consume();
|
||||
MOZ_ASSERT(import);
|
||||
auto* sheet =
|
||||
const_cast<StyleSheet*>(Servo_ImportRule_GetSheet(import));
|
||||
MOZ_ASSERT(sheet);
|
||||
AppendStyleSheetSilently(*sheet);
|
||||
break;
|
||||
}
|
||||
case StyleCssRuleType::LayerStatement:
|
||||
break;
|
||||
default:
|
||||
// Note that only @charset and @layer statements can come before
|
||||
// @import. @charset rules are parsed but skipped, so we can stop
|
||||
// iterating as soon as we find the stylesheet body.
|
||||
reachedBody = true;
|
||||
break;
|
||||
}
|
||||
#ifndef DEBUG
|
||||
// Keep iterating in debug builds so that we can assert that we really have
|
||||
// no more @import rules.
|
||||
if (reachedBody) {
|
||||
break;
|
||||
}
|
||||
auto* sheet = const_cast<StyleSheet*>(Servo_ImportRule_GetSheet(import));
|
||||
MOZ_ASSERT(sheet);
|
||||
AppendStyleSheetSilently(*sheet);
|
||||
index++;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -322,17 +322,6 @@ pub trait ToCssWithGuard {
|
|||
}
|
||||
}
|
||||
|
||||
/// Parameters needed for deep clones.
|
||||
#[cfg(feature = "gecko")]
|
||||
pub struct DeepCloneParams {
|
||||
/// The new sheet we're cloning rules into.
|
||||
pub reference_sheet: *const crate::gecko_bindings::structs::StyleSheet,
|
||||
}
|
||||
|
||||
/// Parameters needed for deep clones.
|
||||
#[cfg(feature = "servo")]
|
||||
pub struct DeepCloneParams;
|
||||
|
||||
/// A trait to do a deep clone of a given CSS type. Gets a lock and a read
|
||||
/// guard, in order to be able to read and clone nested structures.
|
||||
pub trait DeepCloneWithLock: Sized {
|
||||
|
@ -341,7 +330,6 @@ pub trait DeepCloneWithLock: Sized {
|
|||
&self,
|
||||
lock: &SharedRwLock,
|
||||
guard: &SharedRwLockReadGuard,
|
||||
params: &DeepCloneParams,
|
||||
) -> Self;
|
||||
}
|
||||
|
||||
|
|
|
@ -15,7 +15,7 @@ use crate::queries::feature::{AllowsRanges, Evaluator, FeatureFlags, QueryFeatur
|
|||
use crate::queries::values::Orientation;
|
||||
use crate::queries::{FeatureType, QueryCondition};
|
||||
use crate::shared_lock::{
|
||||
DeepCloneParams, DeepCloneWithLock, Locked, SharedRwLock, SharedRwLockReadGuard, ToCssWithGuard,
|
||||
DeepCloneWithLock, Locked, SharedRwLock, SharedRwLockReadGuard, ToCssWithGuard,
|
||||
};
|
||||
use crate::str::CssStringWriter;
|
||||
use crate::stylesheets::CssRules;
|
||||
|
@ -68,12 +68,11 @@ impl DeepCloneWithLock for ContainerRule {
|
|||
&self,
|
||||
lock: &SharedRwLock,
|
||||
guard: &SharedRwLockReadGuard,
|
||||
params: &DeepCloneParams,
|
||||
) -> Self {
|
||||
let rules = self.rules.read_with(guard);
|
||||
Self {
|
||||
condition: self.condition.clone(),
|
||||
rules: Arc::new(lock.wrap(rules.deep_clone_with_lock(lock, guard, params))),
|
||||
rules: Arc::new(lock.wrap(rules.deep_clone_with_lock(lock, guard))),
|
||||
source_location: self.source_location.clone(),
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
|
||||
use crate::media_queries::Device;
|
||||
use crate::parser::{Parse, ParserContext};
|
||||
use crate::shared_lock::{DeepCloneParams, DeepCloneWithLock, Locked};
|
||||
use crate::shared_lock::{DeepCloneWithLock, Locked};
|
||||
use crate::shared_lock::{SharedRwLock, SharedRwLockReadGuard, ToCssWithGuard};
|
||||
use crate::str::CssStringWriter;
|
||||
use crate::stylesheets::CssRules;
|
||||
|
@ -60,12 +60,11 @@ impl DeepCloneWithLock for DocumentRule {
|
|||
&self,
|
||||
lock: &SharedRwLock,
|
||||
guard: &SharedRwLockReadGuard,
|
||||
params: &DeepCloneParams,
|
||||
) -> Self {
|
||||
let rules = self.rules.read_with(guard);
|
||||
DocumentRule {
|
||||
condition: self.condition.clone(),
|
||||
rules: Arc::new(lock.wrap(rules.deep_clone_with_lock(lock, guard, params))),
|
||||
rules: Arc::new(lock.wrap(rules.deep_clone_with_lock(lock, guard))),
|
||||
source_location: self.source_location.clone(),
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
use crate::media_queries::MediaList;
|
||||
use crate::parser::{Parse, ParserContext};
|
||||
use crate::shared_lock::{
|
||||
DeepCloneParams, DeepCloneWithLock, SharedRwLock, SharedRwLockReadGuard, ToCssWithGuard,
|
||||
DeepCloneWithLock, SharedRwLock, SharedRwLockReadGuard, ToCssWithGuard,
|
||||
};
|
||||
use crate::str::CssStringWriter;
|
||||
use crate::stylesheets::{
|
||||
|
@ -89,14 +89,13 @@ impl DeepCloneWithLock for ImportSheet {
|
|||
&self,
|
||||
_lock: &SharedRwLock,
|
||||
_guard: &SharedRwLockReadGuard,
|
||||
params: &DeepCloneParams,
|
||||
) -> Self {
|
||||
use crate::gecko::data::GeckoStyleSheet;
|
||||
use crate::gecko_bindings::bindings;
|
||||
match *self {
|
||||
ImportSheet::Sheet(ref s) => {
|
||||
let clone = unsafe {
|
||||
bindings::Gecko_StyleSheet_Clone(s.raw() as *const _, params.reference_sheet)
|
||||
bindings::Gecko_StyleSheet_Clone(s.raw() as *const _)
|
||||
};
|
||||
ImportSheet::Sheet(unsafe { GeckoStyleSheet::from_addrefed(clone) })
|
||||
},
|
||||
|
@ -130,10 +129,8 @@ impl DeepCloneWithLock for ImportSheet {
|
|||
&self,
|
||||
_lock: &SharedRwLock,
|
||||
_guard: &SharedRwLockReadGuard,
|
||||
_params: &DeepCloneParams,
|
||||
) -> Self {
|
||||
use servo_arc::Arc;
|
||||
|
||||
ImportSheet(Arc::new((&*self.0).clone()))
|
||||
}
|
||||
}
|
||||
|
@ -261,11 +258,10 @@ impl DeepCloneWithLock for ImportRule {
|
|||
&self,
|
||||
lock: &SharedRwLock,
|
||||
guard: &SharedRwLockReadGuard,
|
||||
params: &DeepCloneParams,
|
||||
) -> Self {
|
||||
ImportRule {
|
||||
url: self.url.clone(),
|
||||
stylesheet: self.stylesheet.deep_clone_with_lock(lock, guard, params),
|
||||
stylesheet: self.stylesheet.deep_clone_with_lock(lock, guard),
|
||||
supports: self.supports.clone(),
|
||||
layer: self.layer.clone(),
|
||||
source_location: self.source_location.clone(),
|
||||
|
|
|
@ -14,7 +14,7 @@ use crate::properties::{
|
|||
parse_property_declaration_list, LonghandId, PropertyDeclaration, PropertyDeclarationBlock,
|
||||
PropertyDeclarationId, PropertyDeclarationIdSet,
|
||||
};
|
||||
use crate::shared_lock::{DeepCloneParams, DeepCloneWithLock, SharedRwLock, SharedRwLockReadGuard};
|
||||
use crate::shared_lock::{DeepCloneWithLock, SharedRwLock, SharedRwLockReadGuard};
|
||||
use crate::shared_lock::{Locked, ToCssWithGuard};
|
||||
use crate::str::CssStringWriter;
|
||||
use crate::stylesheets::rule_parser::VendorPrefix;
|
||||
|
@ -84,7 +84,6 @@ impl DeepCloneWithLock for KeyframesRule {
|
|||
&self,
|
||||
lock: &SharedRwLock,
|
||||
guard: &SharedRwLockReadGuard,
|
||||
params: &DeepCloneParams,
|
||||
) -> Self {
|
||||
KeyframesRule {
|
||||
name: self.name.clone(),
|
||||
|
@ -93,7 +92,7 @@ impl DeepCloneWithLock for KeyframesRule {
|
|||
.iter()
|
||||
.map(|x| {
|
||||
Arc::new(
|
||||
lock.wrap(x.read_with(guard).deep_clone_with_lock(lock, guard, params)),
|
||||
lock.wrap(x.read_with(guard).deep_clone_with_lock(lock, guard)),
|
||||
)
|
||||
})
|
||||
.collect(),
|
||||
|
@ -241,7 +240,6 @@ impl DeepCloneWithLock for Keyframe {
|
|||
&self,
|
||||
lock: &SharedRwLock,
|
||||
guard: &SharedRwLockReadGuard,
|
||||
_params: &DeepCloneParams,
|
||||
) -> Keyframe {
|
||||
Keyframe {
|
||||
selector: self.selector.clone(),
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
//! [layer]: https://drafts.csswg.org/css-cascade-5/#layering
|
||||
|
||||
use crate::parser::{Parse, ParserContext};
|
||||
use crate::shared_lock::{DeepCloneParams, DeepCloneWithLock, Locked};
|
||||
use crate::shared_lock::{DeepCloneWithLock, Locked};
|
||||
use crate::shared_lock::{SharedRwLock, SharedRwLockReadGuard, ToCssWithGuard};
|
||||
use crate::values::AtomIdent;
|
||||
|
||||
|
@ -180,7 +180,6 @@ impl DeepCloneWithLock for LayerBlockRule {
|
|||
&self,
|
||||
lock: &SharedRwLock,
|
||||
guard: &SharedRwLockReadGuard,
|
||||
params: &DeepCloneParams,
|
||||
) -> Self {
|
||||
Self {
|
||||
name: self.name.clone(),
|
||||
|
@ -188,7 +187,7 @@ impl DeepCloneWithLock for LayerBlockRule {
|
|||
lock.wrap(
|
||||
self.rules
|
||||
.read_with(guard)
|
||||
.deep_clone_with_lock(lock, guard, params),
|
||||
.deep_clone_with_lock(lock, guard),
|
||||
),
|
||||
),
|
||||
source_location: self.source_location.clone(),
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
//! [margin]: https://drafts.csswg.org/css-page-3/#margin-boxes
|
||||
|
||||
use crate::properties::PropertyDeclarationBlock;
|
||||
use crate::shared_lock::{DeepCloneParams, DeepCloneWithLock, Locked};
|
||||
use crate::shared_lock::{DeepCloneWithLock, Locked};
|
||||
use crate::shared_lock::{SharedRwLock, SharedRwLockReadGuard, ToCssWithGuard};
|
||||
use crate::str::CssStringWriter;
|
||||
use cssparser::SourceLocation;
|
||||
|
@ -183,7 +183,6 @@ impl DeepCloneWithLock for MarginRule {
|
|||
&self,
|
||||
lock: &SharedRwLock,
|
||||
guard: &SharedRwLockReadGuard,
|
||||
_params: &DeepCloneParams,
|
||||
) -> Self {
|
||||
MarginRule {
|
||||
rule_type: self.rule_type,
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
//! [media]: https://drafts.csswg.org/css-conditional/#at-ruledef-media
|
||||
|
||||
use crate::media_queries::MediaList;
|
||||
use crate::shared_lock::{DeepCloneParams, DeepCloneWithLock, Locked};
|
||||
use crate::shared_lock::{DeepCloneWithLock, Locked};
|
||||
use crate::shared_lock::{SharedRwLock, SharedRwLockReadGuard, ToCssWithGuard};
|
||||
use crate::str::CssStringWriter;
|
||||
use crate::stylesheets::CssRules;
|
||||
|
@ -58,13 +58,12 @@ impl DeepCloneWithLock for MediaRule {
|
|||
&self,
|
||||
lock: &SharedRwLock,
|
||||
guard: &SharedRwLockReadGuard,
|
||||
params: &DeepCloneParams,
|
||||
) -> Self {
|
||||
let media_queries = self.media_queries.read_with(guard);
|
||||
let rules = self.rules.read_with(guard);
|
||||
MediaRule {
|
||||
media_queries: Arc::new(lock.wrap(media_queries.clone())),
|
||||
rules: Arc::new(lock.wrap(rules.deep_clone_with_lock(lock, guard, params))),
|
||||
rules: Arc::new(lock.wrap(rules.deep_clone_with_lock(lock, guard))),
|
||||
source_location: self.source_location.clone(),
|
||||
}
|
||||
}
|
||||
|
|
|
@ -36,7 +36,7 @@ use crate::gecko_bindings::sugar::refptr::RefCounted;
|
|||
use crate::gecko_bindings::{bindings, structs};
|
||||
use crate::parser::{NestingContext, ParserContext};
|
||||
use crate::properties::PropertyDeclarationBlock;
|
||||
use crate::shared_lock::{DeepCloneParams, DeepCloneWithLock, Locked};
|
||||
use crate::shared_lock::{DeepCloneWithLock, Locked};
|
||||
use crate::shared_lock::{SharedRwLock, SharedRwLockReadGuard, ToCssWithGuard};
|
||||
use crate::str::CssStringWriter;
|
||||
use cssparser::{parse_one_rule, Parser, ParserInput};
|
||||
|
@ -610,27 +610,26 @@ impl DeepCloneWithLock for CssRule {
|
|||
&self,
|
||||
lock: &SharedRwLock,
|
||||
guard: &SharedRwLockReadGuard,
|
||||
params: &DeepCloneParams,
|
||||
) -> CssRule {
|
||||
match *self {
|
||||
CssRule::Namespace(ref arc) => CssRule::Namespace(arc.clone()),
|
||||
CssRule::Import(ref arc) => {
|
||||
let rule = arc
|
||||
.read_with(guard)
|
||||
.deep_clone_with_lock(lock, guard, params);
|
||||
.deep_clone_with_lock(lock, guard);
|
||||
CssRule::Import(Arc::new(lock.wrap(rule)))
|
||||
},
|
||||
CssRule::Style(ref arc) => {
|
||||
let rule = arc.read_with(guard);
|
||||
CssRule::Style(Arc::new(
|
||||
lock.wrap(rule.deep_clone_with_lock(lock, guard, params)),
|
||||
lock.wrap(rule.deep_clone_with_lock(lock, guard)),
|
||||
))
|
||||
},
|
||||
CssRule::Container(ref arc) => {
|
||||
CssRule::Container(Arc::new(arc.deep_clone_with_lock(lock, guard, params)))
|
||||
CssRule::Container(Arc::new(arc.deep_clone_with_lock(lock, guard)))
|
||||
},
|
||||
CssRule::Media(ref arc) => {
|
||||
CssRule::Media(Arc::new(arc.deep_clone_with_lock(lock, guard, params)))
|
||||
CssRule::Media(Arc::new(arc.deep_clone_with_lock(lock, guard)))
|
||||
},
|
||||
CssRule::FontFace(ref arc) => {
|
||||
let rule = arc.read_with(guard);
|
||||
|
@ -645,19 +644,19 @@ impl DeepCloneWithLock for CssRule {
|
|||
CssRule::Keyframes(ref arc) => {
|
||||
let rule = arc.read_with(guard);
|
||||
CssRule::Keyframes(Arc::new(
|
||||
lock.wrap(rule.deep_clone_with_lock(lock, guard, params)),
|
||||
lock.wrap(rule.deep_clone_with_lock(lock, guard)),
|
||||
))
|
||||
},
|
||||
CssRule::Margin(ref arc) => {
|
||||
CssRule::Margin(Arc::new(arc.deep_clone_with_lock(lock, guard, params)))
|
||||
CssRule::Margin(Arc::new(arc.deep_clone_with_lock(lock, guard)))
|
||||
},
|
||||
CssRule::Supports(ref arc) => {
|
||||
CssRule::Supports(Arc::new(arc.deep_clone_with_lock(lock, guard, params)))
|
||||
CssRule::Supports(Arc::new(arc.deep_clone_with_lock(lock, guard)))
|
||||
},
|
||||
CssRule::Page(ref arc) => {
|
||||
let rule = arc.read_with(guard);
|
||||
CssRule::Page(Arc::new(
|
||||
lock.wrap(rule.deep_clone_with_lock(lock, guard, params)),
|
||||
lock.wrap(rule.deep_clone_with_lock(lock, guard)),
|
||||
))
|
||||
},
|
||||
CssRule::Property(ref arc) => {
|
||||
|
@ -666,22 +665,22 @@ impl DeepCloneWithLock for CssRule {
|
|||
CssRule::Property(arc.clone())
|
||||
},
|
||||
CssRule::Document(ref arc) => {
|
||||
CssRule::Document(Arc::new(arc.deep_clone_with_lock(lock, guard, params)))
|
||||
CssRule::Document(Arc::new(arc.deep_clone_with_lock(lock, guard)))
|
||||
},
|
||||
CssRule::LayerStatement(ref arc) => CssRule::LayerStatement(arc.clone()),
|
||||
CssRule::LayerBlock(ref arc) => {
|
||||
CssRule::LayerBlock(Arc::new(arc.deep_clone_with_lock(lock, guard, params)))
|
||||
CssRule::LayerBlock(Arc::new(arc.deep_clone_with_lock(lock, guard)))
|
||||
},
|
||||
CssRule::Scope(ref arc) => {
|
||||
CssRule::Scope(Arc::new(arc.deep_clone_with_lock(lock, guard, params)))
|
||||
CssRule::Scope(Arc::new(arc.deep_clone_with_lock(lock, guard)))
|
||||
},
|
||||
CssRule::StartingStyle(ref arc) => {
|
||||
CssRule::StartingStyle(Arc::new(arc.deep_clone_with_lock(lock, guard, params)))
|
||||
CssRule::StartingStyle(Arc::new(arc.deep_clone_with_lock(lock, guard)))
|
||||
},
|
||||
CssRule::PositionTry(ref arc) => {
|
||||
let rule = arc.read_with(guard);
|
||||
CssRule::PositionTry(Arc::new(
|
||||
lock.wrap(rule.deep_clone_with_lock(lock, guard, params)),
|
||||
lock.wrap(rule.deep_clone_with_lock(lock, guard)),
|
||||
))
|
||||
},
|
||||
}
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
use crate::parser::{Parse, ParserContext};
|
||||
use crate::properties::PropertyDeclarationBlock;
|
||||
use crate::shared_lock::{
|
||||
DeepCloneParams, DeepCloneWithLock, Locked, SharedRwLock, SharedRwLockReadGuard, ToCssWithGuard,
|
||||
DeepCloneWithLock, Locked, SharedRwLock, SharedRwLockReadGuard, ToCssWithGuard,
|
||||
};
|
||||
use crate::str::CssStringWriter;
|
||||
use crate::stylesheets::{CssRules, style_or_page_rule_to_css};
|
||||
|
@ -357,13 +357,12 @@ impl DeepCloneWithLock for PageRule {
|
|||
&self,
|
||||
lock: &SharedRwLock,
|
||||
guard: &SharedRwLockReadGuard,
|
||||
params: &DeepCloneParams,
|
||||
) -> Self {
|
||||
let rules = self.rules.read_with(&guard);
|
||||
PageRule {
|
||||
selectors: self.selectors.clone(),
|
||||
block: Arc::new(lock.wrap(self.block.read_with(&guard).clone())),
|
||||
rules: Arc::new(lock.wrap(rules.deep_clone_with_lock(lock, guard, params))),
|
||||
rules: Arc::new(lock.wrap(rules.deep_clone_with_lock(lock, guard))),
|
||||
source_location: self.source_location.clone(),
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,7 +10,7 @@ use std::fmt::Write;
|
|||
|
||||
use crate::properties::PropertyDeclarationBlock;
|
||||
use crate::shared_lock::{
|
||||
DeepCloneParams, DeepCloneWithLock, Locked, SharedRwLock, SharedRwLockReadGuard, ToCssWithGuard,
|
||||
DeepCloneWithLock, Locked, SharedRwLock, SharedRwLockReadGuard, ToCssWithGuard,
|
||||
};
|
||||
use crate::str::CssStringWriter;
|
||||
use crate::values::DashedIdent;
|
||||
|
@ -43,7 +43,6 @@ impl DeepCloneWithLock for PositionTryRule {
|
|||
&self,
|
||||
lock: &SharedRwLock,
|
||||
guard: &SharedRwLockReadGuard,
|
||||
_: &DeepCloneParams,
|
||||
) -> Self {
|
||||
PositionTryRule {
|
||||
name: self.name.clone(),
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
//! A list of CSS rules.
|
||||
|
||||
use crate::shared_lock::{DeepCloneParams, DeepCloneWithLock, Locked};
|
||||
use crate::shared_lock::{DeepCloneWithLock, Locked};
|
||||
use crate::shared_lock::{SharedRwLock, SharedRwLockReadGuard, ToCssWithGuard};
|
||||
use crate::str::CssStringWriter;
|
||||
use crate::stylesheets::loader::StylesheetLoader;
|
||||
|
@ -34,12 +34,11 @@ impl DeepCloneWithLock for CssRules {
|
|||
&self,
|
||||
lock: &SharedRwLock,
|
||||
guard: &SharedRwLockReadGuard,
|
||||
params: &DeepCloneParams,
|
||||
) -> Self {
|
||||
CssRules(
|
||||
self.0
|
||||
.iter()
|
||||
.map(|x| x.deep_clone_with_lock(lock, guard, params))
|
||||
.map(|x| x.deep_clone_with_lock(lock, guard))
|
||||
.collect(),
|
||||
)
|
||||
}
|
||||
|
|
|
@ -11,7 +11,7 @@ use crate::dom::TElement;
|
|||
use crate::parser::ParserContext;
|
||||
use crate::selector_parser::{SelectorImpl, SelectorParser};
|
||||
use crate::shared_lock::{
|
||||
DeepCloneParams, DeepCloneWithLock, Locked, SharedRwLock, SharedRwLockReadGuard, ToCssWithGuard,
|
||||
DeepCloneWithLock, Locked, SharedRwLock, SharedRwLockReadGuard, ToCssWithGuard,
|
||||
};
|
||||
use crate::str::CssStringWriter;
|
||||
use crate::stylesheets::CssRules;
|
||||
|
@ -45,12 +45,11 @@ impl DeepCloneWithLock for ScopeRule {
|
|||
&self,
|
||||
lock: &SharedRwLock,
|
||||
guard: &SharedRwLockReadGuard,
|
||||
params: &DeepCloneParams,
|
||||
) -> Self {
|
||||
let rules = self.rules.read_with(guard);
|
||||
Self {
|
||||
bounds: self.bounds.clone(),
|
||||
rules: Arc::new(lock.wrap(rules.deep_clone_with_lock(lock, guard, params))),
|
||||
rules: Arc::new(lock.wrap(rules.deep_clone_with_lock(lock, guard))),
|
||||
source_location: self.source_location.clone(),
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
//! before-change style: the `@starting-style` rules.
|
||||
//! https://drafts.csswg.org/css-transitions-2/#defining-before-change-style
|
||||
|
||||
use crate::shared_lock::{DeepCloneParams, DeepCloneWithLock, Locked};
|
||||
use crate::shared_lock::{DeepCloneWithLock, Locked};
|
||||
use crate::shared_lock::{SharedRwLock, SharedRwLockReadGuard, ToCssWithGuard};
|
||||
use crate::str::CssStringWriter;
|
||||
use crate::stylesheets::CssRules;
|
||||
|
@ -47,11 +47,10 @@ impl DeepCloneWithLock for StartingStyleRule {
|
|||
&self,
|
||||
lock: &SharedRwLock,
|
||||
guard: &SharedRwLockReadGuard,
|
||||
params: &DeepCloneParams,
|
||||
) -> Self {
|
||||
let rules = self.rules.read_with(guard);
|
||||
StartingStyleRule {
|
||||
rules: Arc::new(lock.wrap(rules.deep_clone_with_lock(lock, guard, params))),
|
||||
rules: Arc::new(lock.wrap(rules.deep_clone_with_lock(lock, guard))),
|
||||
source_location: self.source_location.clone(),
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
use crate::properties::PropertyDeclarationBlock;
|
||||
use crate::selector_parser::SelectorImpl;
|
||||
use crate::shared_lock::{
|
||||
DeepCloneParams, DeepCloneWithLock, Locked, SharedRwLock, SharedRwLockReadGuard, ToCssWithGuard,
|
||||
DeepCloneWithLock, Locked, SharedRwLock, SharedRwLockReadGuard, ToCssWithGuard,
|
||||
};
|
||||
use crate::str::CssStringWriter;
|
||||
use crate::stylesheets::{CssRules, style_or_page_rule_to_css};
|
||||
|
@ -39,14 +39,13 @@ impl DeepCloneWithLock for StyleRule {
|
|||
&self,
|
||||
lock: &SharedRwLock,
|
||||
guard: &SharedRwLockReadGuard,
|
||||
params: &DeepCloneParams,
|
||||
) -> StyleRule {
|
||||
StyleRule {
|
||||
selectors: self.selectors.clone(),
|
||||
block: Arc::new(lock.wrap(self.block.read_with(guard).clone())),
|
||||
rules: self.rules.as_ref().map(|rules| {
|
||||
let rules = rules.read_with(guard);
|
||||
Arc::new(lock.wrap(rules.deep_clone_with_lock(lock, guard, params)))
|
||||
Arc::new(lock.wrap(rules.deep_clone_with_lock(lock, guard)))
|
||||
}),
|
||||
source_location: self.source_location.clone(),
|
||||
}
|
||||
|
|
|
@ -6,7 +6,7 @@ use crate::context::QuirksMode;
|
|||
use crate::error_reporting::{ContextualParseError, ParseErrorReporter};
|
||||
use crate::media_queries::{Device, MediaList};
|
||||
use crate::parser::ParserContext;
|
||||
use crate::shared_lock::{DeepCloneParams, DeepCloneWithLock, Locked};
|
||||
use crate::shared_lock::{DeepCloneWithLock, Locked};
|
||||
use crate::shared_lock::{SharedRwLock, SharedRwLockReadGuard};
|
||||
use crate::stylesheets::loader::StylesheetLoader;
|
||||
use crate::stylesheets::rule_parser::{State, TopLevelRuleParser};
|
||||
|
@ -164,13 +164,12 @@ impl DeepCloneWithLock for StylesheetContents {
|
|||
&self,
|
||||
lock: &SharedRwLock,
|
||||
guard: &SharedRwLockReadGuard,
|
||||
params: &DeepCloneParams,
|
||||
) -> Self {
|
||||
// Make a deep clone of the rules, using the new lock.
|
||||
let rules = self
|
||||
.rules
|
||||
.read_with(guard)
|
||||
.deep_clone_with_lock(lock, guard, params);
|
||||
.deep_clone_with_lock(lock, guard);
|
||||
|
||||
Self {
|
||||
rules: Arc::new(lock.wrap(rules)),
|
||||
|
@ -570,11 +569,7 @@ impl Clone for Stylesheet {
|
|||
// Make a deep clone of the media, using the new lock.
|
||||
let media = self.media.read_with(&guard).clone();
|
||||
let media = Arc::new(lock.wrap(media));
|
||||
let contents = Arc::new(self.contents.deep_clone_with_lock(
|
||||
&lock,
|
||||
&guard,
|
||||
&DeepCloneParams,
|
||||
));
|
||||
let contents = Arc::new(self.contents.deep_clone_with_lock(&lock, &guard));
|
||||
|
||||
Stylesheet {
|
||||
contents,
|
||||
|
|
|
@ -8,7 +8,7 @@ use crate::font_face::{FontFaceSourceFormatKeyword, FontFaceSourceTechFlags};
|
|||
use crate::parser::ParserContext;
|
||||
use crate::properties::{PropertyDeclaration, PropertyId, SourcePropertyDeclaration};
|
||||
use crate::selector_parser::{SelectorImpl, SelectorParser};
|
||||
use crate::shared_lock::{DeepCloneParams, DeepCloneWithLock, Locked};
|
||||
use crate::shared_lock::{DeepCloneWithLock, Locked};
|
||||
use crate::shared_lock::{SharedRwLock, SharedRwLockReadGuard, ToCssWithGuard};
|
||||
use crate::str::CssStringWriter;
|
||||
use crate::stylesheets::{CssRuleType, CssRules};
|
||||
|
@ -61,12 +61,11 @@ impl DeepCloneWithLock for SupportsRule {
|
|||
&self,
|
||||
lock: &SharedRwLock,
|
||||
guard: &SharedRwLockReadGuard,
|
||||
params: &DeepCloneParams,
|
||||
) -> Self {
|
||||
let rules = self.rules.read_with(guard);
|
||||
SupportsRule {
|
||||
condition: self.condition.clone(),
|
||||
rules: Arc::new(lock.wrap(rules.deep_clone_with_lock(lock, guard, params))),
|
||||
rules: Arc::new(lock.wrap(rules.deep_clone_with_lock(lock, guard))),
|
||||
enabled: self.enabled,
|
||||
source_location: self.source_location.clone(),
|
||||
}
|
||||
|
|
|
@ -2089,16 +2089,11 @@ pub extern "C" fn Servo_StyleSheet_GetRules(sheet: &StylesheetContents) -> Stron
|
|||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn Servo_StyleSheet_Clone(
|
||||
contents: &StylesheetContents,
|
||||
reference_sheet: *const DomStyleSheet,
|
||||
) -> Strong<StylesheetContents> {
|
||||
use style::shared_lock::{DeepCloneParams, DeepCloneWithLock};
|
||||
pub extern "C" fn Servo_StyleSheet_Clone(contents: &StylesheetContents) -> Strong<StylesheetContents> {
|
||||
use style::shared_lock::DeepCloneWithLock;
|
||||
let global_style_data = &*GLOBAL_STYLE_DATA;
|
||||
let guard = global_style_data.shared_lock.read();
|
||||
let params = DeepCloneParams { reference_sheet };
|
||||
|
||||
Arc::new(contents.deep_clone_with_lock(&global_style_data.shared_lock, &guard, ¶ms)).into()
|
||||
Arc::new(contents.deep_clone_with_lock(&global_style_data.shared_lock, &guard)).into()
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
|
@ -2212,6 +2207,16 @@ where
|
|||
})
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn Servo_CssRules_GetRuleCount(rules: &LockedCssRules) -> usize {
|
||||
read_locked_arc(rules, |rules| rules.0.len())
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn Servo_CssRules_GetRuleTypeAt(rules: &LockedCssRules, index: usize) -> CssRuleType {
|
||||
read_locked_arc(rules, |rules| rules.0[index].rule_type())
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn Servo_CssRules_ListTypes(rules: &LockedCssRules, result: &mut nsTArray<usize>) {
|
||||
read_locked_arc(rules, |rules: &CssRules| {
|
||||
|
|
Загрузка…
Ссылка в новой задаче