Ideally we'd just do this when we need it, but the ostream derivation will be controlled by both global config and per-structure config, so it's hard to know exactly when we need it and when we don't.
62 lines
2.0 KiB
C++
62 lines
2.0 KiB
C++
#include <cstdarg>
|
|
#include <cstdint>
|
|
#include <cstdlib>
|
|
#include <ostream>
|
|
#include <new>
|
|
|
|
/// Constants shared by multiple CSS Box Alignment properties
|
|
///
|
|
/// These constants match Gecko's `NS_STYLE_ALIGN_*` constants.
|
|
struct StyleAlignFlags {
|
|
uint8_t bits;
|
|
|
|
explicit operator bool() const {
|
|
return !!bits;
|
|
}
|
|
StyleAlignFlags operator~() const {
|
|
return {static_cast<decltype(bits)>(~bits)};
|
|
}
|
|
StyleAlignFlags operator|(const StyleAlignFlags& other) const {
|
|
return {static_cast<decltype(bits)>(this->bits | other.bits)};
|
|
}
|
|
StyleAlignFlags& operator|=(const StyleAlignFlags& other) {
|
|
*this = (*this | other);
|
|
return *this;
|
|
}
|
|
StyleAlignFlags operator&(const StyleAlignFlags& other) const {
|
|
return {static_cast<decltype(bits)>(this->bits & other.bits)};
|
|
}
|
|
StyleAlignFlags& operator&=(const StyleAlignFlags& other) {
|
|
*this = (*this & other);
|
|
return *this;
|
|
}
|
|
StyleAlignFlags operator^(const StyleAlignFlags& other) const {
|
|
return {static_cast<decltype(bits)>(this->bits ^ other.bits)};
|
|
}
|
|
StyleAlignFlags& operator^=(const StyleAlignFlags& other) {
|
|
*this = (*this ^ other);
|
|
return *this;
|
|
}
|
|
static const StyleAlignFlags AUTO;
|
|
static const StyleAlignFlags NORMAL;
|
|
static const StyleAlignFlags START;
|
|
static const StyleAlignFlags END;
|
|
static const StyleAlignFlags FLEX_START;
|
|
};
|
|
/// 'auto'
|
|
inline const StyleAlignFlags StyleAlignFlags::AUTO = StyleAlignFlags{ /* .bits = */ (uint8_t)0 };
|
|
/// 'normal'
|
|
inline const StyleAlignFlags StyleAlignFlags::NORMAL = StyleAlignFlags{ /* .bits = */ (uint8_t)1 };
|
|
/// 'start'
|
|
inline const StyleAlignFlags StyleAlignFlags::START = StyleAlignFlags{ /* .bits = */ (uint8_t)(1 << 1) };
|
|
/// 'end'
|
|
inline const StyleAlignFlags StyleAlignFlags::END = StyleAlignFlags{ /* .bits = */ (uint8_t)(1 << 2) };
|
|
/// 'flex-start'
|
|
inline const StyleAlignFlags StyleAlignFlags::FLEX_START = StyleAlignFlags{ /* .bits = */ (uint8_t)(1 << 3) };
|
|
|
|
extern "C" {
|
|
|
|
void root(StyleAlignFlags flags);
|
|
|
|
} // extern "C"
|