Skip to content

Commit

Permalink
Bug 1765746 - Tweak contain bitflag definition order to avoid static …
Browse files Browse the repository at this point in the history
…constructors. r=dshin

This has no behavior change otherwise. The STRICT definition depended on
SIZE, which was defined later. That's fine in Rust, but in C++ it causes
the initialization to be dynamic because it doesn't have the definition
of SIZE yet (ugh).

This is the fix for the regression, though the following patch turns on
constexpr support in cbindgen, which would've caught this at build-time,
and guarantees that we don't have extra static constructors.

Differential Revision: https://phabricator.services.mozilla.com/D144316
  • Loading branch information
emilio committed Apr 21, 2022
1 parent e25ca67 commit dc5309e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion layout/style/nsStyleStruct.h
Expand Up @@ -1676,7 +1676,7 @@ struct MOZ_NEEDS_MEMMOVABLE_MEMBERS nsStyleDisplay {
return mContain | StyleContain::LAYOUT | StyleContain::PAINT;
case StyleContentVisibility::Hidden:
return mContain | StyleContain::LAYOUT | StyleContain::PAINT |
StyleContain::INLINE_SIZE | StyleContain::BLOCK_SIZE;
StyleContain::SIZE;
}
MOZ_ASSERT_UNREACHABLE("Invalid content visibility.");
return mContain;
Expand Down
8 changes: 4 additions & 4 deletions servo/components/style/values/specified/box.rs
Expand Up @@ -1372,12 +1372,12 @@ bitflags! {
const LAYOUT = 1 << 2;
/// `paint` variant, turns on paint containment
const PAINT = 1 << 3;
/// `strict` variant, turns on all types of containment
const STRICT = 1 << 4 | Contain::LAYOUT.bits | Contain::PAINT.bits | Contain::SIZE.bits;
/// 'size' variant, turns on size containment
const SIZE = 1 << 4 | Contain::INLINE_SIZE.bits | Contain::BLOCK_SIZE.bits;
/// `content` variant, turns on layout and paint containment
const CONTENT = 1 << 5 | Contain::LAYOUT.bits | Contain::PAINT.bits;
/// 'size' variant, turns on size containment
const SIZE = 1 << 6 | Contain::INLINE_SIZE.bits | Contain::BLOCK_SIZE.bits;
/// `strict` variant, turns on all types of containment
const STRICT = 1 << 6 | Contain::LAYOUT.bits | Contain::PAINT.bits | Contain::SIZE.bits;
}
}

Expand Down

0 comments on commit dc5309e

Please sign in to comment.