mirror of
https://github.com/slint-ui/slint.git
synced 2025-08-04 18:58:36 +00:00
Janitor: Remove BuiltinElement::reserved_properties
It was added when support for `font-metrics` was added, but there is no reason why this can't simply be in the `properties` hash.
This commit is contained in:
parent
6da0f55b05
commit
b44172be4f
3 changed files with 14 additions and 22 deletions
|
@ -412,11 +412,7 @@ impl ElementType {
|
|||
} else {
|
||||
Cow::Borrowed(name)
|
||||
};
|
||||
match b
|
||||
.properties
|
||||
.get(resolved_name.as_ref())
|
||||
.or_else(|| b.reserved_properties.get(resolved_name.as_ref()))
|
||||
{
|
||||
match b.properties.get(resolved_name.as_ref()) {
|
||||
None => {
|
||||
if b.is_non_item_type {
|
||||
PropertyLookupResult {
|
||||
|
@ -483,12 +479,9 @@ impl ElementType {
|
|||
);
|
||||
r
|
||||
}
|
||||
Self::Builtin(b) => b
|
||||
.properties
|
||||
.iter()
|
||||
.chain(b.reserved_properties.iter())
|
||||
.map(|(k, t)| (k.clone(), t.ty.clone()))
|
||||
.collect(),
|
||||
Self::Builtin(b) => {
|
||||
b.properties.iter().map(|(k, t)| (k.clone(), t.ty.clone())).collect()
|
||||
}
|
||||
Self::Native(n) => {
|
||||
n.properties.iter().map(|(k, t)| (k.clone(), t.ty.clone())).collect()
|
||||
}
|
||||
|
@ -733,7 +726,6 @@ pub struct BuiltinElement {
|
|||
pub name: SmolStr,
|
||||
pub native_class: Rc<NativeClass>,
|
||||
pub properties: BTreeMap<SmolStr, BuiltinPropertyInfo>,
|
||||
pub reserved_properties: BTreeMap<SmolStr, BuiltinPropertyInfo>,
|
||||
pub additional_accepted_child_types: HashMap<SmolStr, ElementType>,
|
||||
pub disallow_global_types_as_child_elements: bool,
|
||||
/// Non-item type do not have reserved properties (x/width/rowspan/...) added to them (eg: PropertyAnimation)
|
||||
|
|
|
@ -95,10 +95,14 @@ fn should_materialize(
|
|||
let has_declared_property = match base_type {
|
||||
ElementType::Component(c) => has_declared_property(&c.root_element.borrow(), prop),
|
||||
ElementType::Builtin(b) => {
|
||||
if let Some(info) = b.reserved_properties.get(prop) {
|
||||
return Some(info.ty.clone());
|
||||
if let Some(p) = b.properties.get(prop) {
|
||||
if b.native_class.lookup_property(prop).is_none() {
|
||||
return Some(p.ty.clone());
|
||||
}
|
||||
true
|
||||
} else {
|
||||
false
|
||||
}
|
||||
b.properties.contains_key(prop)
|
||||
}
|
||||
ElementType::Native(n) => {
|
||||
n.lookup_property(prop).map_or(false, |prop_type| prop_type.is_property_type())
|
||||
|
@ -140,9 +144,7 @@ fn has_declared_property(elem: &Element, prop: &str) -> bool {
|
|||
/// Initialize a sensible default binding for the now materialized property
|
||||
pub fn initialize(elem: &ElementRc, name: &str) -> Option<Expression> {
|
||||
if let ElementType::Builtin(b) = &elem.borrow().base_type {
|
||||
if let Some(expr) =
|
||||
b.reserved_properties.get(name).and_then(|prop| prop.default_value.expr(elem))
|
||||
{
|
||||
if let Some(expr) = b.properties.get(name).and_then(|prop| prop.default_value.expr(elem)) {
|
||||
return Some(expr);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -491,9 +491,7 @@ impl TypeRegister {
|
|||
text_input
|
||||
.member_functions
|
||||
.insert("set-selection-offsets".into(), BuiltinFunction::SetSelectionOffsets);
|
||||
text_input
|
||||
.reserved_properties
|
||||
.insert("font-metrics".into(), font_metrics_prop.clone());
|
||||
text_input.properties.insert("font-metrics".into(), font_metrics_prop.clone());
|
||||
}
|
||||
|
||||
_ => unreachable!(),
|
||||
|
@ -502,7 +500,7 @@ impl TypeRegister {
|
|||
match &mut register.elements.get_mut("Text").unwrap() {
|
||||
ElementType::Builtin(ref mut b) => {
|
||||
let text = Rc::get_mut(b).unwrap();
|
||||
text.reserved_properties.insert("font-metrics".into(), font_metrics_prop);
|
||||
text.properties.insert("font-metrics".into(), font_metrics_prop);
|
||||
}
|
||||
|
||||
_ => unreachable!(),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue