mirror of
https://github.com/pjh456/OxideJS.git
synced 2026-10-23 18:21:13 +08:00
fix: 修复了空布局属性哨兵值产生的冲突问题
This commit is contained in:
@@ -6,6 +6,7 @@ pub type ShapeId = u32;
|
|||||||
pub type StringIndex = u32;
|
pub type StringIndex = u32;
|
||||||
|
|
||||||
pub const EMPTY_SHAPE_ID: ShapeId = 1;
|
pub const EMPTY_SHAPE_ID: ShapeId = 1;
|
||||||
|
const EMPTY_SENTINEL: StringIndex = u32::MAX;
|
||||||
|
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
pub struct Shape {
|
pub struct Shape {
|
||||||
@@ -35,7 +36,7 @@ impl ShapeStore {
|
|||||||
fn create_empty_shape(&mut self) {
|
fn create_empty_shape(&mut self) {
|
||||||
let empty = Arc::new(Shape {
|
let empty = Arc::new(Shape {
|
||||||
id: EMPTY_SHAPE_ID,
|
id: EMPTY_SHAPE_ID,
|
||||||
property_name: 0,
|
property_name: EMPTY_SENTINEL,
|
||||||
property_offset: 0,
|
property_offset: 0,
|
||||||
parent: None,
|
parent: None,
|
||||||
});
|
});
|
||||||
@@ -80,7 +81,7 @@ impl ShapeStore {
|
|||||||
while let Some(id) = cursor {
|
while let Some(id) = cursor {
|
||||||
match self.get_shape(id) {
|
match self.get_shape(id) {
|
||||||
Some(s) => {
|
Some(s) => {
|
||||||
if s.property_name != 0 {
|
if s.property_name != EMPTY_SENTINEL {
|
||||||
count += 1;
|
count += 1;
|
||||||
}
|
}
|
||||||
cursor = s.parent;
|
cursor = s.parent;
|
||||||
@@ -96,7 +97,7 @@ impl ShapeStore {
|
|||||||
while let Some(id) = cursor {
|
while let Some(id) = cursor {
|
||||||
match self.get_shape(id) {
|
match self.get_shape(id) {
|
||||||
Some(s) => {
|
Some(s) => {
|
||||||
if s.property_name == prop_name {
|
if s.property_name == prop_name && s.property_name != EMPTY_SENTINEL {
|
||||||
return Some(s.property_offset);
|
return Some(s.property_offset);
|
||||||
}
|
}
|
||||||
cursor = s.parent;
|
cursor = s.parent;
|
||||||
@@ -113,7 +114,7 @@ impl ShapeStore {
|
|||||||
while let Some(id) = cursor {
|
while let Some(id) = cursor {
|
||||||
match self.get_shape(id) {
|
match self.get_shape(id) {
|
||||||
Some(s) => {
|
Some(s) => {
|
||||||
if s.property_name != 0 {
|
if s.property_name != EMPTY_SENTINEL {
|
||||||
count += 1;
|
count += 1;
|
||||||
}
|
}
|
||||||
cursor = s.parent;
|
cursor = s.parent;
|
||||||
|
|||||||
Reference in New Issue
Block a user