mirror of
https://github.com/servo/servo.git
synced 2025-08-03 12:40:06 +01:00
Auto merge of #11394 - mbrubeck:stacking-context-id, r=pcwalton
Reduce the size of StackingContextId r? @pcwalton <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="35" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/11394) <!-- Reviewable:end -->
This commit is contained in:
commit
2acb257a82
2 changed files with 8 additions and 7 deletions
|
@ -1409,20 +1409,21 @@ pub enum FragmentType {
|
|||
/// A unique ID for every stacking context.
|
||||
#[derive(Clone, Copy, Debug, Deserialize, Eq, Hash, HeapSizeOf, PartialEq, RustcEncodable, Serialize)]
|
||||
pub struct StackingContextId(
|
||||
/// The type of the fragment for this StackingContext. This serves to differentiate
|
||||
/// StackingContexts that share fragments.
|
||||
FragmentType,
|
||||
/// The identifier for this StackingContexts, derived from the Flow's memory address.
|
||||
/// The identifier for this StackingContext, derived from the Flow's memory address
|
||||
/// and fragment type. As a space optimization, these are combined into a single word.
|
||||
usize
|
||||
);
|
||||
|
||||
impl StackingContextId {
|
||||
#[inline(always)]
|
||||
pub fn new(id: usize) -> StackingContextId {
|
||||
StackingContextId(FragmentType::FragmentBody, id)
|
||||
StackingContextId::new_of_type(id, FragmentType::FragmentBody)
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
pub fn new_of_type(id: usize, fragment_type: FragmentType) -> StackingContextId {
|
||||
StackingContextId(fragment_type, id)
|
||||
debug_assert_eq!(id & fragment_type as usize, 0);
|
||||
StackingContextId(id | fragment_type as usize)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue