Bug 1834960 - [css-properties-values-api] Remove Locked<> from CssRule::Property arc r=emilio

Depends on D179038

Differential Revision: https://phabricator.services.mozilla.com/D179039
This commit is contained in:
Zach Hoffman 2023-05-25 15:13:06 +00:00
parent 3a80433ff0
commit fc43687c95
11 changed files with 36 additions and 43 deletions

View File

@ -12,7 +12,7 @@ namespace mozilla::dom {
bool CSSPropertyRule::IsCCLeaf() const { return Rule::IsCCLeaf(); }
void CSSPropertyRule::SetRawAfterClone(RefPtr<StyleLockedPropertyRule> aRaw) {
void CSSPropertyRule::SetRawAfterClone(RefPtr<StylePropertyRule> aRaw) {
mRawRule = std::move(aRaw);
}

View File

@ -12,13 +12,13 @@
#include "nsICSSDeclaration.h"
struct StyleLockedPropertyRule;
struct StylePropertyRule;
namespace mozilla::dom {
class CSSPropertyRule final : public css::Rule {
public:
CSSPropertyRule(already_AddRefed<StyleLockedPropertyRule> aRawRule,
CSSPropertyRule(already_AddRefed<StylePropertyRule> aRawRule,
StyleSheet* aSheet, css::Rule* aParentRule, uint32_t aLine,
uint32_t aColumn)
: css::Rule(aSheet, aParentRule, aLine, aColumn),
@ -26,8 +26,8 @@ class CSSPropertyRule final : public css::Rule {
bool IsCCLeaf() const final;
StyleLockedPropertyRule* Raw() const { return mRawRule; }
void SetRawAfterClone(RefPtr<StyleLockedPropertyRule> aRaw);
StylePropertyRule* Raw() const { return mRawRule; }
void SetRawAfterClone(RefPtr<StylePropertyRule> aRaw);
JSObject* WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) final;
@ -53,7 +53,7 @@ class CSSPropertyRule final : public css::Rule {
private:
~CSSPropertyRule() = default;
RefPtr<StyleLockedPropertyRule> mRawRule;
RefPtr<StylePropertyRule> mRawRule;
};
} // namespace mozilla::dom

View File

@ -81,6 +81,7 @@ struct PropertyValuePair;
struct StyleAnimation;
struct StyleCssUrlData;
struct StyleAnimationValue;
struct StylePropertyRule;
struct StyleStylesheetContents;
struct URLExtraData;
using ComputedKeyframeValues = nsTArray<PropertyStyleAnimationValuePair>;
@ -113,6 +114,7 @@ class Element;
SERVO_ARC_TYPE(name_, mozilla::Style##style_prefix_##name_)
#define SERVO_LOCKED_ARC_TYPE(name_) SERVO_ARC_TYPE_WITH_PREFIX(name_, Locked)
#include "mozilla/ServoLockedArcTypeList.h"
SERVO_ARC_TYPE_WITH_PREFIX(PropertyRule, )
SERVO_ARC_TYPE(AnimationValue, mozilla::StyleAnimationValue)
SERVO_ARC_TYPE(ComputedStyle, mozilla::ComputedStyle)
SERVO_ARC_TYPE(CssUrlData, mozilla::StyleCssUrlData)

View File

@ -69,7 +69,7 @@ GROUP_RULE_FUNCS(Media)
GROUP_RULE_FUNCS(Document)
BASIC_RULE_FUNCS(Namespace)
BASIC_RULE_FUNCS(Page)
BASIC_RULE_FUNCS(Property)
BASIC_RULE_FUNCS_WITH_PREFIX(Property, )
GROUP_RULE_FUNCS(Supports)
GROUP_RULE_FUNCS(LayerBlock)
BASIC_RULE_FUNCS(LayerStatement)

View File

@ -85,7 +85,7 @@ css::Rule* ServoCSSRuleList::GetRule(uint32_t aIndex) {
CASE_RULE(Media, Media)
CASE_RULE(Namespace, Namespace)
CASE_RULE(Page, Page)
CASE_RULE(Property, Property)
CASE_RULE_WITH_PREFIX(Property, , Property)
CASE_RULE(Supports, Supports)
CASE_RULE(Document, MozDocument)
CASE_RULE(Import, Import)
@ -258,7 +258,7 @@ void ServoCSSRuleList::SetRawContents(RefPtr<StyleLockedCssRules> aNewRules,
CASE_FOR(Media, Media)
CASE_FOR(Namespace, Namespace)
CASE_FOR(Page, Page)
CASE_FOR(Property, Property)
CASE_FOR_WITH_PREFIX(Property, , Property)
CASE_FOR(Supports, Supports)
CASE_FOR(Document, MozDocument)
CASE_FOR(Import, Import)

View File

@ -27,7 +27,6 @@ SERVO_LOCKED_ARC_TYPE(NamespaceRule)
SERVO_LOCKED_ARC_TYPE(SupportsRule)
SERVO_LOCKED_ARC_TYPE(DocumentRule)
SERVO_LOCKED_ARC_TYPE(PageRule)
SERVO_LOCKED_ARC_TYPE(PropertyRule)
SERVO_LOCKED_ARC_TYPE(ContainerRule)
SERVO_LOCKED_ARC_TYPE(FontFeatureValuesRule)
SERVO_LOCKED_ARC_TYPE(FontPaletteValuesRule)

View File

@ -46,7 +46,7 @@ template struct StyleStrong<StyleLockedMediaRule>;
template struct StyleStrong<StyleLockedDocumentRule>;
template struct StyleStrong<StyleLockedNamespaceRule>;
template struct StyleStrong<StyleLockedPageRule>;
template struct StyleStrong<StyleLockedPropertyRule>;
template struct StyleStrong<StylePropertyRule>;
template struct StyleStrong<StyleLockedSupportsRule>;
template struct StyleStrong<StyleLockedFontFeatureValuesRule>;
template struct StyleStrong<StyleLockedFontPaletteValuesRule>;

View File

@ -114,9 +114,8 @@ impl_locked_arc_ffi!(
Servo_PageRule_AddRef,
Servo_PageRule_Release
);
impl_locked_arc_ffi!(
impl_simple_arc_ffi!(
PropertyRule,
LockedPropertyRule,
Servo_PropertyRule_AddRef,
Servo_PropertyRule_Release
);

View File

@ -263,7 +263,7 @@ pub enum CssRule {
Keyframes(Arc<Locked<KeyframesRule>>),
Supports(Arc<Locked<SupportsRule>>),
Page(Arc<Locked<PageRule>>),
Property(Arc<Locked<PropertyRule>>),
Property(Arc<PropertyRule>),
Document(Arc<Locked<DocumentRule>>),
LayerBlock(Arc<Locked<LayerBlockRule>>),
LayerStatement(Arc<Locked<LayerStatementRule>>),
@ -309,9 +309,7 @@ impl CssRule {
lock.unconditional_shallow_size_of(ops) + lock.read_with(guard).size_of(guard, ops)
},
CssRule::Property(ref lock) => {
lock.unconditional_shallow_size_of(ops) + lock.read_with(guard).size_of(guard, ops)
},
CssRule::Property(ref rule) => rule.size_of(guard, ops),
CssRule::Document(ref lock) => {
lock.unconditional_shallow_size_of(ops) + lock.read_with(guard).size_of(guard, ops)
@ -598,7 +596,7 @@ impl ToCssWithGuard for CssRule {
CssRule::Media(ref lock) => lock.read_with(guard).to_css(guard, dest),
CssRule::Supports(ref lock) => lock.read_with(guard).to_css(guard, dest),
CssRule::Page(ref lock) => lock.read_with(guard).to_css(guard, dest),
CssRule::Property(ref lock) => lock.read_with(guard).to_css(guard, dest),
CssRule::Property(ref rule) => rule.to_css(guard, dest),
CssRule::Document(ref lock) => lock.read_with(guard).to_css(guard, dest),
CssRule::LayerBlock(ref lock) => lock.read_with(guard).to_css(guard, dest),
CssRule::LayerStatement(ref lock) => lock.read_with(guard).to_css(guard, dest),

View File

@ -702,8 +702,11 @@ impl<'a, 'b, 'i> AtRuleParser<'i> for NestedRuleParser<'a, 'b, 'i> {
})))
},
AtRulePrelude::Property(name) => self.nest_for_rule(CssRuleType::Property, |p| {
CssRule::Property(Arc::new(p.shared_lock.wrap(
parse_property_block(&p.context, input, name, start.source_location()),
CssRule::Property(Arc::new(parse_property_block(
&p.context,
input,
name,
start.source_location(),
)))
}),
AtRulePrelude::Document(condition) => {

View File

@ -34,7 +34,7 @@ use style::gecko::arc_types::{
LockedDocumentRule, LockedFontFaceRule, LockedFontFeatureValuesRule,
LockedFontPaletteValuesRule, LockedImportRule, LockedKeyframe, LockedKeyframesRule,
LockedLayerBlockRule, LockedLayerStatementRule, LockedMediaList, LockedMediaRule,
LockedNamespaceRule, LockedPageRule, LockedPropertyRule, LockedStyleRule, LockedSupportsRule,
LockedNamespaceRule, LockedPageRule, LockedStyleRule, LockedSupportsRule,
};
use style::gecko::data::{
AuthorStyles, GeckoStyleSheet, PerDocumentStyleData, PerDocumentStyleDataImpl,
@ -2354,7 +2354,7 @@ impl_basic_rule_funcs! { (Page, PageRule),
changed: Servo_StyleSet_PageRuleChanged,
}
impl_basic_rule_funcs! { (Property, PropertyRule),
impl_basic_rule_funcs_without_lock! { (Property, PropertyRule),
getter: Servo_CssRules_GetPropertyRuleAt,
debug: Servo_PropertyRule_Debug,
to_css: Servo_PropertyRule_GetCssText,
@ -2925,39 +2925,31 @@ pub extern "C" fn Servo_PageRule_SetSelectorText(
}
#[no_mangle]
pub extern "C" fn Servo_PropertyRule_GetName(rule: &LockedPropertyRule, result: &mut nsACString) {
read_locked_arc(rule, |rule: &PropertyRule| {
rule.name.to_css(&mut CssWriter::new(result)).unwrap()
})
pub extern "C" fn Servo_PropertyRule_GetName(rule: &PropertyRule, result: &mut nsACString) {
rule.name.to_css(&mut CssWriter::new(result)).unwrap()
}
#[no_mangle]
pub extern "C" fn Servo_PropertyRule_GetSyntax(rule: &LockedPropertyRule, result: &mut nsACString) {
read_locked_arc(rule, |rule: &PropertyRule| {
if let Some(ref syntax) = rule.syntax {
CssWriter::new(result).write_str(syntax.as_str()).unwrap()
}
})
pub extern "C" fn Servo_PropertyRule_GetSyntax(rule: &PropertyRule, result: &mut nsACString) {
if let Some(ref syntax) = rule.syntax {
CssWriter::new(result).write_str(syntax.as_str()).unwrap()
}
}
#[no_mangle]
pub extern "C" fn Servo_PropertyRule_GetInherits(rule: &LockedPropertyRule) -> bool {
read_locked_arc(rule, |rule: &PropertyRule| {
matches!(rule.inherits, Some(PropertyInherits::True))
})
pub extern "C" fn Servo_PropertyRule_GetInherits(rule: &PropertyRule) -> bool {
matches!(rule.inherits, Some(PropertyInherits::True))
}
#[no_mangle]
pub extern "C" fn Servo_PropertyRule_GetInitialValue(
rule: &LockedPropertyRule,
rule: &PropertyRule,
result: &mut nsACString,
) -> bool {
read_locked_arc(rule, |rule: &PropertyRule| {
rule.initial_value
.to_css(&mut CssWriter::new(result))
.unwrap();
rule.initial_value.is_some()
})
rule.initial_value
.to_css(&mut CssWriter::new(result))
.unwrap();
rule.initial_value.is_some()
}
#[no_mangle]