Skip to main content

StyleMemo

Struct StyleMemo 

Source
pub struct StyleMemo {
Show 13 fields global: (u64, u64), entries: BTreeMap<(u64, u64), MemoEntry>, features_states: BTreeMap<(u64, u64), u8>, subtrees: BTreeMap<(u64, u64), CachedSubtreeEntry>, generation: u32, pub(crate) enabled: bool, pub verify: bool, pub(crate) hits: u32, pub(crate) misses: u32, pub(crate) mismatches: u32, pub(crate) subtree_hits: u32, pub(crate) subtree_misses: u32, pub(crate) skips: [u32; 4],
}
Expand description

使い回しの表。WebEngine が持ち、再レイアウトのたびに style_tree_with_memo へ渡す。

Fields§

§global: (u64, u64)

表を作ったときの全体の条件(スタイルシート・画面の大きさ・:target・言語など)。変われば表を捨てる。

§entries: BTreeMap<(u64, u64), MemoEntry>§features_states: BTreeMap<(u64, u64), u8>

要素特徴ハッシュ (node.features_hash) → ルール索引の state_bits キャッシュ(STATE_HOVER 等 / STATE_INVALID)。 同じタグ・id・class・属性の組では RuleIndex の状態ビットが不変であることを利用し、 メモヒット時の candidates_into_with_attrs + Vec 確保をゼロにする(TODO P5a)。

§subtrees: BTreeMap<(u64, u64), CachedSubtreeEntry>

部分木全体の算出スタイルキャッシュ(TODO P5a)。

§generation: u32§enabled: bool

この回で表を使えるか(:focus-within の対象があるときなどは使わない)。

§verify: bool

確かめる版: 表に当たっても計算し直し、結果を比べる(使うのは計算した値)。

§hits: u32§misses: u32§mismatches: u32§subtree_hits: u32§subtree_misses: u32§skips: [u32; 4]

使い回さなかった理由の数(診断): [表が無効, カウンタ, :has(), 候補が取れない]。

Implementations§

Source§

impl StyleMemo

Source

const MAX_ENTRIES: usize = 24576

Source

const MAX_SUBTREES: usize = 12288

Source

const MAX_FEATURE_STATES: usize = 16384

Source

pub(crate) const MAX_SUBTREE_ELEMENTS: u32 = 16384

Source

pub(crate) fn begin(&mut self, sheet_id: usize)

1 回のスタイル計算の始め。sheet_id はスタイルシート(規則の索引)の番地。

Source

pub fn clear(&mut self)

表を捨てる(規則の索引を作り直したとき。番地が使い回されて別のスタイルシートと取り違えないように)。

Source

pub(crate) fn end(&mut self)

1 回のスタイル計算の終わり。数世代使われなかった結果を回収する。

Source

pub(crate) fn get(&mut self, k: &(u64, u64)) -> Option<MemoEntry>

Source

pub(crate) fn put(&mut self, k: (u64, u64), e: MemoEntry)

Source

pub(crate) fn get_state_bits(&self, features_hash: &(u64, u64)) -> Option<u8>

Source

pub(crate) fn put_state_bits(&mut self, features_hash: (u64, u64), bits: u8)

Source

pub(crate) fn get_subtree( &mut self, k: &(u64, u64), ) -> Option<Rc<CachedElementSubtree>>

Source

pub(crate) fn put_subtree( &mut self, k: (u64, u64), tree: Rc<CachedElementSubtree>, )

Source

pub fn stats(&self) -> (u32, u32, u32, usize, [u32; 4], bool)

Source

pub fn subtree_stats(&self) -> (u32, u32, usize)

部分木スタイルメモの診断統計 (subtree_hits, subtree_misses, cached_subtrees) を返す。

Trait Implementations§

Source§

impl Default for StyleMemo

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.