Backed out changeset 3a3f2d5937c4 (bug 1844195) for causing mass failures. CLOSED TREE

This commit is contained in:
Iulian Moraru 2023-07-25 23:07:30 +03:00
parent 6b4fedfbf5
commit da43d00caa
13 changed files with 252 additions and 194 deletions

View File

@ -3185,13 +3185,13 @@ void nsRange::GetInnerTextNoFlush(DOMString& aValue, ErrorResult& aError,
if (currentNode->IsHTMLElement(nsGkAtoms::br)) {
result.Append('\n');
}
switch (f->StyleDisplay()->DisplayInside()) {
case StyleDisplayInside::TableCell:
switch (f->StyleDisplay()->mDisplay) {
case StyleDisplay::TableCell:
if (!IsLastCellOfRow(f)) {
result.Append('\t');
}
break;
case StyleDisplayInside::TableRow:
case StyleDisplay::TableRow:
if (!IsLastRowOfRowGroup(f) ||
!IsLastNonemptyRowGroupOfTable(f->GetParent())) {
result.Append('\n');

View File

@ -1314,7 +1314,7 @@ void nsGenericHTMLElement::MapCommonAttributesInto(
MapCommonAttributesIntoExceptHidden(aBuilder);
if (!aBuilder.PropertyIsSet(eCSSProperty_display)) {
if (aBuilder.GetAttr(nsGkAtoms::hidden)) {
aBuilder.SetKeywordValue(eCSSProperty_display, StyleDisplay::None._0);
aBuilder.SetKeywordValue(eCSSProperty_display, StyleDisplay::None);
}
}
}

View File

@ -5277,7 +5277,7 @@ nsCSSFrameConstructor::FindElementData(const Element& aElement,
bool isRootElement = false;
uint16_t rawDisplayValue =
Servo_ComputedValues_BlockifiedDisplay(&aStyle, isRootElement);
display.mDisplay = StyleDisplay{rawDisplayValue};
display.mDisplay = StyleDisplay(rawDisplayValue);
return FindDisplayData(display, aElement);
}
@ -8808,7 +8808,8 @@ void nsCSSFrameConstructor::CreateNeededAnonFlexOrGridItems(
/* static */ nsCSSFrameConstructor::RubyWhitespaceType
nsCSSFrameConstructor::ComputeRubyWhitespaceType(StyleDisplay aPrevDisplay,
StyleDisplay aNextDisplay) {
MOZ_ASSERT(aPrevDisplay.IsRuby() && aNextDisplay.IsRuby());
MOZ_ASSERT(nsStyleDisplay::IsRubyDisplayType(aPrevDisplay) &&
nsStyleDisplay::IsRubyDisplayType(aNextDisplay));
if (aPrevDisplay == aNextDisplay &&
(aPrevDisplay == StyleDisplay::RubyBase ||
aPrevDisplay == StyleDisplay::RubyText)) {
@ -9253,9 +9254,10 @@ void nsCSSFrameConstructor::WrapItemsInPseudoParent(
pseudoType);
}
// Use the content of our parent frame
auto* newItem = new (this) FrameConstructionItem(
&pseudoData.mFCData, aParentContent, wrapperStyle.forget(), true);
FrameConstructionItem* newItem = new (this)
FrameConstructionItem(&pseudoData.mFCData,
// Use the content of our parent frame
aParentContent, wrapperStyle.forget(), true);
const nsStyleDisplay* disp = newItem->mComputedStyle->StyleDisplay();
// Here we're cheating a tad... technically, table-internal items should be

View File

@ -1217,7 +1217,8 @@ static bool IsLineClampRoot(const nsBlockFrame* aFrame) {
}
return aFrame->StyleDisplay()->mOriginalDisplay;
}();
return origDisplay.Inside() == StyleDisplayInside::WebkitBox;
return nsStyleDisplay::DisplayInside(origDisplay) ==
StyleDisplayInside::WebkitBox;
}
bool nsBlockFrame::IsInLineClampContext() const {

View File

@ -518,18 +518,19 @@ static bool IsFontSizeInflationContainer(nsIFrame* aFrame,
LayoutFrameType frameType = aFrame->Type();
bool isInline =
aFrame->GetDisplay().IsInlineFlow() || RubyUtils::IsRubyBox(frameType) ||
(aStyleDisplay->IsFloatingStyle() &&
frameType == LayoutFrameType::Letter) ||
// Given multiple frames for the same node, only the
// outer one should be considered a container.
// (Important, e.g., for nsSelectsAreaFrame.)
(aFrame->GetParent()->GetContent() == content) ||
(content &&
// Form controls shouldn't become inflation containers.
(content->IsAnyOfHTMLElements(nsGkAtoms::option, nsGkAtoms::optgroup,
nsGkAtoms::select, nsGkAtoms::input,
nsGkAtoms::button, nsGkAtoms::textarea)));
(nsStyleDisplay::IsInlineFlow(aFrame->GetDisplay()) ||
RubyUtils::IsRubyBox(frameType) ||
(aStyleDisplay->IsFloatingStyle() &&
frameType == LayoutFrameType::Letter) ||
// Given multiple frames for the same node, only the
// outer one should be considered a container.
// (Important, e.g., for nsSelectsAreaFrame.)
(aFrame->GetParent()->GetContent() == content) ||
(content &&
// Form controls shouldn't become inflation containers.
(content->IsAnyOfHTMLElements(
nsGkAtoms::option, nsGkAtoms::optgroup, nsGkAtoms::select,
nsGkAtoms::input, nsGkAtoms::button, nsGkAtoms::textarea))));
NS_ASSERTION(!aFrame->IsFrameOfType(nsIFrame::eLineParticipant) || isInline ||
// br frames and mathml frames report being line
// participants even when their position or display is
@ -2416,9 +2417,10 @@ static inline bool IsIntrinsicKeyword(const SizeOrMaxSize& aSize) {
}
bool nsIFrame::CanBeDynamicReflowRoot() const {
const auto& display = *StyleDisplay();
if (IsFrameOfType(nsIFrame::eLineParticipant) || display.mDisplay.IsRuby() ||
display.IsInnerTableStyle() ||
auto& display = *StyleDisplay();
if (IsFrameOfType(nsIFrame::eLineParticipant) ||
nsStyleDisplay::IsRubyDisplayType(display.mDisplay) ||
display.DisplayOutside() == StyleDisplayOutside::InternalTable ||
display.DisplayInside() == StyleDisplayInside::Table) {
// We have a display type where 'width' and 'height' don't actually set the
// width or height (i.e., the size depends on content).
@ -2455,7 +2457,7 @@ bool nsIFrame::CanBeDynamicReflowRoot() const {
//
// FIXME: For display:block, we should probably optimize inline-size: auto.
// FIXME: Other flex and grid cases?
const auto& pos = *StylePosition();
auto& pos = *StylePosition();
const auto& width = pos.mWidth;
const auto& height = pos.mHeight;
if (!width.IsLengthPercentage() || width.HasPercent() ||

View File

@ -4735,10 +4735,10 @@ void nsTextFrame::GetTextDecorations(
// If we're on a ruby frame other than ruby text container, we
// should continue.
mozilla::StyleDisplay display = f->GetDisplay();
if (!display.IsInlineFlow() &&
(!display.IsRuby() ||
if (!nsStyleDisplay::IsInlineFlow(display) &&
(!nsStyleDisplay::IsRubyDisplayType(display) ||
display == mozilla::StyleDisplay::RubyTextContainer) &&
display.IsInlineOutside()) {
nsStyleDisplay::IsDisplayTypeInlineOutside(display)) {
break;
}

View File

@ -1085,45 +1085,6 @@ inline StyleViewTimelineInset::StyleGenericViewTimelineInset()
: start(LengthPercentageOrAuto::Auto()),
end(LengthPercentageOrAuto::Auto()) {}
inline StyleDisplayOutside StyleDisplay::Outside() const {
return StyleDisplayOutside((_0 & OUTSIDE_MASK) >> OUTSIDE_SHIFT);
}
inline StyleDisplayInside StyleDisplay::Inside() const {
return StyleDisplayInside(_0 & INSIDE_MASK);
}
inline bool StyleDisplay::IsListItem() const { return _0 & LIST_ITEM_MASK; }
inline bool StyleDisplay::IsInternalTable() const {
return Outside() == StyleDisplayOutside::InternalTable;
}
inline bool StyleDisplay::IsInternalTableExceptCell() const {
return IsInternalTable() && *this != TableCell;
}
inline bool StyleDisplay::IsInternalRuby() const {
return Outside() == StyleDisplayOutside::InternalRuby;
}
inline bool StyleDisplay::IsRuby() const {
return Inside() == StyleDisplayInside::Ruby || IsInternalRuby();
}
inline bool StyleDisplay::IsInlineFlow() const {
return Outside() == StyleDisplayOutside::Inline &&
Inside() == StyleDisplayInside::Flow;
}
inline bool StyleDisplay::IsInlineInside() const {
return IsInlineFlow() || IsRuby();
}
inline bool StyleDisplay::IsInlineOutside() const {
return Outside() == StyleDisplayOutside::Inline || IsInternalRuby();
}
} // namespace mozilla
#endif

View File

@ -20,6 +20,78 @@
namespace mozilla {
static constexpr uint16_t STYLE_DISPLAY_LIST_ITEM_BIT = 0x8000;
static constexpr uint8_t STYLE_DISPLAY_OUTSIDE_BITS = 7;
static constexpr uint8_t STYLE_DISPLAY_INSIDE_BITS = 8;
// The `display` longhand.
uint16_t constexpr StyleDisplayFrom(StyleDisplayOutside aOuter,
StyleDisplayInside aInner) {
return uint16_t(uint16_t(aOuter) << STYLE_DISPLAY_INSIDE_BITS) |
uint16_t(aInner);
}
enum class StyleDisplay : uint16_t {
// These MUST be in sync with the Rust enum values in
// servo/components/style/values/specified/box.rs
/// https://drafts.csswg.org/css-display/#the-display-properties
None = StyleDisplayFrom(StyleDisplayOutside::None, StyleDisplayInside::None),
Contents =
StyleDisplayFrom(StyleDisplayOutside::None, StyleDisplayInside::Contents),
Inline =
StyleDisplayFrom(StyleDisplayOutside::Inline, StyleDisplayInside::Flow),
Block =
StyleDisplayFrom(StyleDisplayOutside::Block, StyleDisplayInside::Flow),
FlowRoot = StyleDisplayFrom(StyleDisplayOutside::Block,
StyleDisplayInside::FlowRoot),
Flex = StyleDisplayFrom(StyleDisplayOutside::Block, StyleDisplayInside::Flex),
Grid = StyleDisplayFrom(StyleDisplayOutside::Block, StyleDisplayInside::Grid),
Table =
StyleDisplayFrom(StyleDisplayOutside::Block, StyleDisplayInside::Table),
InlineTable =
StyleDisplayFrom(StyleDisplayOutside::Inline, StyleDisplayInside::Table),
TableCaption = StyleDisplayFrom(StyleDisplayOutside::TableCaption,
StyleDisplayInside::Flow),
Ruby =
StyleDisplayFrom(StyleDisplayOutside::Inline, StyleDisplayInside::Ruby),
WebkitBox = StyleDisplayFrom(StyleDisplayOutside::Block,
StyleDisplayInside::WebkitBox),
WebkitInlineBox = StyleDisplayFrom(StyleDisplayOutside::Inline,
StyleDisplayInside::WebkitBox),
ListItem = Block | STYLE_DISPLAY_LIST_ITEM_BIT,
/// Internal table boxes.
TableRowGroup = StyleDisplayFrom(StyleDisplayOutside::InternalTable,
StyleDisplayInside::TableRowGroup),
TableHeaderGroup = StyleDisplayFrom(StyleDisplayOutside::InternalTable,
StyleDisplayInside::TableHeaderGroup),
TableFooterGroup = StyleDisplayFrom(StyleDisplayOutside::InternalTable,
StyleDisplayInside::TableFooterGroup),
TableColumn = StyleDisplayFrom(StyleDisplayOutside::InternalTable,
StyleDisplayInside::TableColumn),
TableColumnGroup = StyleDisplayFrom(StyleDisplayOutside::InternalTable,
StyleDisplayInside::TableColumnGroup),
TableRow = StyleDisplayFrom(StyleDisplayOutside::InternalTable,
StyleDisplayInside::TableRow),
TableCell = StyleDisplayFrom(StyleDisplayOutside::InternalTable,
StyleDisplayInside::TableCell),
/// Internal ruby boxes.
RubyBase = StyleDisplayFrom(StyleDisplayOutside::InternalRuby,
StyleDisplayInside::RubyBase),
RubyBaseContainer = StyleDisplayFrom(StyleDisplayOutside::InternalRuby,
StyleDisplayInside::RubyBaseContainer),
RubyText = StyleDisplayFrom(StyleDisplayOutside::InternalRuby,
StyleDisplayInside::RubyText),
RubyTextContainer = StyleDisplayFrom(StyleDisplayOutside::InternalRuby,
StyleDisplayInside::RubyTextContainer),
};
// The order of the StyleDisplay values isn't meaningful.
bool operator<(const StyleDisplay&, const StyleDisplay&) = delete;
bool operator<=(const StyleDisplay&, const StyleDisplay&) = delete;
bool operator>(const StyleDisplay&, const StyleDisplay&) = delete;
bool operator>=(const StyleDisplay&, const StyleDisplay&) = delete;
// box-align
enum class StyleBoxAlign : uint8_t {
Stretch,

View File

@ -1456,31 +1456,81 @@ struct MOZ_NEEDS_MEMMOVABLE_MEMBERS nsStyleDisplay {
}
}
static mozilla::StyleDisplayOutside DisplayOutside(
mozilla::StyleDisplay aDisplay) {
return mozilla::StyleDisplayOutside(
(uint16_t(aDisplay) >> mozilla::STYLE_DISPLAY_INSIDE_BITS) &
uint16_t(((1 << mozilla::STYLE_DISPLAY_OUTSIDE_BITS) - 1)));
}
mozilla::StyleDisplayOutside DisplayOutside() const {
return mDisplay.Outside();
return DisplayOutside(mDisplay);
}
static mozilla::StyleDisplayInside DisplayInside(
mozilla::StyleDisplay aDisplay) {
return mozilla::StyleDisplayInside(
uint16_t(aDisplay) &
uint16_t(((1 << mozilla::STYLE_DISPLAY_INSIDE_BITS) - 1)));
}
mozilla::StyleDisplayInside DisplayInside() const {
return mDisplay.Inside();
return DisplayInside(mDisplay);
}
bool IsListItem() const { return mDisplay.IsListItem(); }
bool IsInlineFlow() const { return mDisplay.IsInlineFlow(); }
bool IsInlineInsideStyle() const { return mDisplay.IsInlineInside(); }
static bool IsListItem(mozilla::StyleDisplay aDisplay) {
return !!(uint16_t(aDisplay) & mozilla::STYLE_DISPLAY_LIST_ITEM_BIT);
}
bool IsListItem() const { return IsListItem(mDisplay); }
// Whether display is `inline` or `inline list-item`.
static bool IsInlineFlow(mozilla::StyleDisplay aDisplay) {
return DisplayOutside(aDisplay) == mozilla::StyleDisplayOutside::Inline &&
DisplayInside(aDisplay) == mozilla::StyleDisplayInside::Flow;
}
bool IsInlineFlow() const { return IsInlineFlow(mDisplay); }
bool IsInlineInsideStyle() const {
auto inside = DisplayInside();
return IsInlineFlow() || inside == mozilla::StyleDisplayInside::Ruby ||
inside == mozilla::StyleDisplayInside::RubyBase ||
inside == mozilla::StyleDisplayInside::RubyBaseContainer ||
inside == mozilla::StyleDisplayInside::RubyText ||
inside == mozilla::StyleDisplayInside::RubyTextContainer;
}
bool IsBlockOutsideStyle() const {
return DisplayOutside() == mozilla::StyleDisplayOutside::Block;
}
bool IsInlineOutsideStyle() const { return mDisplay.IsInlineOutside(); }
bool IsOriginalDisplayInlineOutside() const {
return mOriginalDisplay.IsInlineOutside();
static bool IsDisplayTypeInlineOutside(mozilla::StyleDisplay aDisplay) {
auto outside = DisplayOutside(aDisplay);
if (outside == mozilla::StyleDisplayOutside::Inline) {
return true;
}
// just an optimization for the common case:
if (outside == mozilla::StyleDisplayOutside::Block) {
return false;
}
return mozilla::StyleDisplay::RubyBase == aDisplay ||
mozilla::StyleDisplay::RubyBaseContainer == aDisplay ||
mozilla::StyleDisplay::RubyText == aDisplay ||
mozilla::StyleDisplay::RubyTextContainer == aDisplay;
}
bool IsInnerTableStyle() const { return mDisplay.IsInternalTable(); }
bool IsInlineOutsideStyle() const {
return IsDisplayTypeInlineOutside(mDisplay);
}
bool IsOriginalDisplayInlineOutside() const {
return IsDisplayTypeInlineOutside(mOriginalDisplay);
}
bool IsInnerTableStyle() const {
return DisplayOutside() == mozilla::StyleDisplayOutside::InternalTable;
}
bool IsInternalTableStyleExceptCell() const {
return mDisplay.IsInternalTableExceptCell();
return IsInnerTableStyle() && mozilla::StyleDisplay::TableCell != mDisplay;
}
bool IsFloatingStyle() const { return mozilla::StyleFloat::None != mFloat; }
@ -1510,9 +1560,23 @@ struct MOZ_NEEDS_MEMMOVABLE_MEMBERS nsStyleDisplay {
mozilla::StylePositionProperty::Fixed == mPosition;
}
bool IsRubyDisplayType() const { return mDisplay.IsRuby(); }
static bool IsRubyDisplayType(mozilla::StyleDisplay aDisplay) {
return DisplayInside(aDisplay) == mozilla::StyleDisplayInside::Ruby ||
IsInternalRubyDisplayType(aDisplay);
}
bool IsInternalRubyDisplayType() const { return mDisplay.IsInternalRuby(); }
static bool IsInternalRubyDisplayType(mozilla::StyleDisplay aDisplay) {
return mozilla::StyleDisplay::RubyBase == aDisplay ||
mozilla::StyleDisplay::RubyBaseContainer == aDisplay ||
mozilla::StyleDisplay::RubyText == aDisplay ||
mozilla::StyleDisplay::RubyTextContainer == aDisplay;
}
bool IsRubyDisplayType() const { return IsRubyDisplayType(mDisplay); }
bool IsInternalRubyDisplayType() const {
return IsInternalRubyDisplayType(mDisplay);
}
bool IsOutOfFlowStyle() const {
return (IsAbsolutelyPositionedStyle() || IsFloatingStyle());

View File

@ -2162,14 +2162,14 @@ void nsCellMap::Dump(bool aIsBorderCollapse) const {
printf("\n ***** START GROUP CELL MAP DUMP ***** %p\n", (void*)this);
nsTableRowGroupFrame* rg = GetRowGroup();
const nsStyleDisplay* display = rg->StyleDisplay();
switch (display->DisplayInside()) {
case StyleDisplayInside::TableHeaderGroup:
switch (display->mDisplay) {
case StyleDisplay::TableHeaderGroup:
printf(" thead ");
break;
case StyleDisplayInside::TableFooterGroup:
case StyleDisplay::TableFooterGroup:
printf(" tfoot ");
break;
case StyleDisplayInside::TableRowGroup:
case StyleDisplay::TableRowGroup:
printf(" tbody ");
break;
default:

View File

@ -2624,22 +2624,22 @@ void nsTableFrame::OrderRowGroups(RowGroupArray& aChildren,
nsTableRowGroupFrame* rowGroup =
static_cast<nsTableRowGroupFrame*>(kidFrame);
switch (kidDisplay->DisplayInside()) {
case StyleDisplayInside::TableHeaderGroup:
switch (kidDisplay->mDisplay) {
case mozilla::StyleDisplay::TableHeaderGroup:
if (head) { // treat additional thead like tbody
aChildren.AppendElement(rowGroup);
} else {
head = rowGroup;
}
break;
case StyleDisplayInside::TableFooterGroup:
case mozilla::StyleDisplay::TableFooterGroup:
if (foot) { // treat additional tfoot like tbody
aChildren.AppendElement(rowGroup);
} else {
foot = rowGroup;
}
break;
case StyleDisplayInside::TableRowGroup:
case mozilla::StyleDisplay::TableRowGroup:
aChildren.AppendElement(rowGroup);
break;
default:

View File

@ -106,134 +106,102 @@ pub enum DisplayInside {
ToResolvedValue,
ToShmem,
)]
#[repr(C)]
#[repr(transparent)]
pub struct Display(u16);
/// Gecko-only impl block for Display (shared stuff later in this file):
#[allow(missing_docs)]
#[allow(non_upper_case_globals)]
impl Display {
// Our u16 bits are used as follows: LOOOOOOOIIIIIIII
pub const LIST_ITEM_MASK: u16 = 0b1000000000000000;
pub const OUTSIDE_MASK: u16 = 0b0111111100000000;
pub const INSIDE_MASK: u16 = 0b0000000011111111;
pub const OUTSIDE_SHIFT: u16 = 8;
// Our u16 bits are used as follows: LOOOOOOOIIIIIIII
const LIST_ITEM_BIT: u16 = 0x8000; //^
const DISPLAY_OUTSIDE_BITS: u16 = 7; // ^^^^^^^
const DISPLAY_INSIDE_BITS: u16 = 8; // ^^^^^^^^
/// https://drafts.csswg.org/css-display/#the-display-properties
/// ::new() inlined so cbindgen can use it
pub const None: Self =
Self(((DisplayOutside::None as u16) << Self::OUTSIDE_SHIFT) | DisplayInside::None as u16);
pub const None: Self = Self::new(DisplayOutside::None, DisplayInside::None);
#[cfg(any(feature = "servo-layout-2020", feature = "gecko"))]
pub const Contents: Self = Self(
((DisplayOutside::None as u16) << Self::OUTSIDE_SHIFT) | DisplayInside::Contents as u16,
);
pub const Inline: Self =
Self(((DisplayOutside::Inline as u16) << Self::OUTSIDE_SHIFT) | DisplayInside::Flow as u16);
pub const InlineBlock: Self = Self(
((DisplayOutside::Inline as u16) << Self::OUTSIDE_SHIFT) | DisplayInside::FlowRoot as u16,
);
pub const Block: Self =
Self(((DisplayOutside::Block as u16) << Self::OUTSIDE_SHIFT) | DisplayInside::Flow as u16);
pub const Contents: Self = Self::new(DisplayOutside::None, DisplayInside::Contents);
pub const Inline: Self = Self::new(DisplayOutside::Inline, DisplayInside::Flow);
pub const InlineBlock: Self = Self::new(DisplayOutside::Inline, DisplayInside::FlowRoot);
pub const Block: Self = Self::new(DisplayOutside::Block, DisplayInside::Flow);
#[cfg(feature = "gecko")]
pub const FlowRoot: Self =
Self(((DisplayOutside::Block as u16) << Self::OUTSIDE_SHIFT) | DisplayInside::Flow as u16);
pub const Flex: Self =
Self(((DisplayOutside::Block as u16) << Self::OUTSIDE_SHIFT) | DisplayInside::Flex as u16);
pub const InlineFlex: Self =
Self(((DisplayOutside::Inline as u16) << Self::OUTSIDE_SHIFT) | DisplayInside::Flex as u16);
pub const FlowRoot: Self = Self::new(DisplayOutside::Block, DisplayInside::FlowRoot);
pub const Flex: Self = Self::new(DisplayOutside::Block, DisplayInside::Flex);
pub const InlineFlex: Self = Self::new(DisplayOutside::Inline, DisplayInside::Flex);
#[cfg(feature = "gecko")]
pub const Grid: Self =
Self(((DisplayOutside::Block as u16) << Self::OUTSIDE_SHIFT) | DisplayInside::Grid as u16);
pub const Grid: Self = Self::new(DisplayOutside::Block, DisplayInside::Grid);
#[cfg(feature = "gecko")]
pub const InlineGrid: Self =
Self(((DisplayOutside::Inline as u16) << Self::OUTSIDE_SHIFT) | DisplayInside::Grid as u16);
pub const InlineGrid: Self = Self::new(DisplayOutside::Inline, DisplayInside::Grid);
#[cfg(any(feature = "servo-layout-2013", feature = "gecko"))]
pub const Table: Self =
Self(((DisplayOutside::Block as u16) << Self::OUTSIDE_SHIFT) | DisplayInside::Table as u16);
pub const Table: Self = Self::new(DisplayOutside::Block, DisplayInside::Table);
#[cfg(any(feature = "servo-layout-2013", feature = "gecko"))]
pub const InlineTable: Self = Self(
((DisplayOutside::Inline as u16) << Self::OUTSIDE_SHIFT) | DisplayInside::Table as u16,
);
pub const InlineTable: Self = Self::new(DisplayOutside::Inline, DisplayInside::Table);
#[cfg(any(feature = "servo-layout-2013", feature = "gecko"))]
pub const TableCaption: Self = Self(
((DisplayOutside::TableCaption as u16) << Self::OUTSIDE_SHIFT) | DisplayInside::Flow as u16,
);
pub const TableCaption: Self = Self::new(DisplayOutside::TableCaption, DisplayInside::Flow);
#[cfg(feature = "gecko")]
pub const Ruby: Self =
Self(((DisplayOutside::Inline as u16) << Self::OUTSIDE_SHIFT) | DisplayInside::Ruby as u16);
pub const Ruby: Self = Self::new(DisplayOutside::Inline, DisplayInside::Ruby);
#[cfg(feature = "gecko")]
pub const WebkitBox: Self = Self(
((DisplayOutside::Block as u16) << Self::OUTSIDE_SHIFT) | DisplayInside::WebkitBox as u16,
);
pub const WebkitBox: Self = Self::new(DisplayOutside::Block, DisplayInside::WebkitBox);
#[cfg(feature = "gecko")]
pub const WebkitInlineBox: Self = Self(
((DisplayOutside::Inline as u16) << Self::OUTSIDE_SHIFT) | DisplayInside::WebkitBox as u16,
);
pub const WebkitInlineBox: Self = Self::new(DisplayOutside::Inline, DisplayInside::WebkitBox);
// Internal table boxes.
#[cfg(any(feature = "servo-layout-2013", feature = "gecko"))]
pub const TableRowGroup: Self = Self(
((DisplayOutside::InternalTable as u16) << Self::OUTSIDE_SHIFT) |
DisplayInside::TableRowGroup as u16,
);
pub const TableRowGroup: Self =
Self::new(DisplayOutside::InternalTable, DisplayInside::TableRowGroup);
#[cfg(any(feature = "servo-layout-2013", feature = "gecko"))]
pub const TableHeaderGroup: Self = Self(
((DisplayOutside::InternalTable as u16) << Self::OUTSIDE_SHIFT) |
DisplayInside::TableHeaderGroup as u16,
pub const TableHeaderGroup: Self = Self::new(
DisplayOutside::InternalTable,
DisplayInside::TableHeaderGroup,
);
#[cfg(any(feature = "servo-layout-2013", feature = "gecko"))]
pub const TableFooterGroup: Self = Self(
((DisplayOutside::InternalTable as u16) << Self::OUTSIDE_SHIFT) |
DisplayInside::TableFooterGroup as u16,
pub const TableFooterGroup: Self = Self::new(
DisplayOutside::InternalTable,
DisplayInside::TableFooterGroup,
);
#[cfg(any(feature = "servo-layout-2013", feature = "gecko"))]
pub const TableColumn: Self = Self(
((DisplayOutside::InternalTable as u16) << Self::OUTSIDE_SHIFT) |
DisplayInside::TableColumn as u16,
);
pub const TableColumn: Self =
Self::new(DisplayOutside::InternalTable, DisplayInside::TableColumn);
#[cfg(any(feature = "servo-layout-2013", feature = "gecko"))]
pub const TableColumnGroup: Self = Self(
((DisplayOutside::InternalTable as u16) << Self::OUTSIDE_SHIFT) |
DisplayInside::TableColumnGroup as u16,
pub const TableColumnGroup: Self = Self::new(
DisplayOutside::InternalTable,
DisplayInside::TableColumnGroup,
);
#[cfg(any(feature = "servo-layout-2013", feature = "gecko"))]
pub const TableRow: Self = Self(
((DisplayOutside::InternalTable as u16) << Self::OUTSIDE_SHIFT) |
DisplayInside::TableRow as u16,
);
pub const TableRow: Self = Self::new(DisplayOutside::InternalTable, DisplayInside::TableRow);
#[cfg(any(feature = "servo-layout-2013", feature = "gecko"))]
pub const TableCell: Self = Self(
((DisplayOutside::InternalTable as u16) << Self::OUTSIDE_SHIFT) |
DisplayInside::TableCell as u16,
);
pub const TableCell: Self = Self::new(DisplayOutside::InternalTable, DisplayInside::TableCell);
/// Internal ruby boxes.
#[cfg(feature = "gecko")]
pub const RubyBase: Self = Self(
((DisplayOutside::InternalRuby as u16) << Self::OUTSIDE_SHIFT) |
DisplayInside::RubyBase as u16,
pub const RubyBase: Self = Self::new(DisplayOutside::InternalRuby, DisplayInside::RubyBase);
#[cfg(feature = "gecko")]
pub const RubyBaseContainer: Self = Self::new(
DisplayOutside::InternalRuby,
DisplayInside::RubyBaseContainer,
);
#[cfg(feature = "gecko")]
pub const RubyBaseContainer: Self = Self(
((DisplayOutside::InternalRuby as u16) << Self::OUTSIDE_SHIFT) |
DisplayInside::RubyBaseContainer as u16,
);
pub const RubyText: Self = Self::new(DisplayOutside::InternalRuby, DisplayInside::RubyText);
#[cfg(feature = "gecko")]
pub const RubyText: Self = Self(
((DisplayOutside::InternalRuby as u16) << Self::OUTSIDE_SHIFT) |
DisplayInside::RubyText as u16,
);
#[cfg(feature = "gecko")]
pub const RubyTextContainer: Self = Self(
((DisplayOutside::InternalRuby as u16) << Self::OUTSIDE_SHIFT) |
DisplayInside::RubyTextContainer as u16,
pub const RubyTextContainer: Self = Self::new(
DisplayOutside::InternalRuby,
DisplayInside::RubyTextContainer,
);
/// Make a raw display value from <display-outside> and <display-inside> values.
#[inline]
const fn new(outside: DisplayOutside, inside: DisplayInside) -> Self {
Self((outside as u16) << Self::OUTSIDE_SHIFT | inside as u16)
let o: u16 = ((outside as u8) as u16) << Self::DISPLAY_INSIDE_BITS;
let i: u16 = (inside as u8) as u16;
Self(o | i)
}
/// Make a display enum value from <display-outside> and <display-inside> values.
@ -243,19 +211,22 @@ impl Display {
if !list_item {
return v;
}
Self(v.0 | Self::LIST_ITEM_MASK)
Self(v.0 | Self::LIST_ITEM_BIT)
}
/// Accessor for the <display-inside> value.
#[inline]
pub fn inside(&self) -> DisplayInside {
DisplayInside::from_u16(self.0 & Self::INSIDE_MASK).unwrap()
DisplayInside::from_u16(self.0 & ((1 << Self::DISPLAY_INSIDE_BITS) - 1)).unwrap()
}
/// Accessor for the <display-outside> value.
#[inline]
pub fn outside(&self) -> DisplayOutside {
DisplayOutside::from_u16((self.0 & Self::OUTSIDE_MASK) >> Self::OUTSIDE_SHIFT).unwrap()
DisplayOutside::from_u16(
(self.0 >> Self::DISPLAY_INSIDE_BITS) & ((1 << Self::DISPLAY_OUTSIDE_BITS) - 1),
)
.unwrap()
}
/// Returns the raw underlying u16 value.
@ -273,7 +244,7 @@ impl Display {
/// Returns whether this `display` value is some kind of list-item.
#[inline]
pub const fn is_list_item(&self) -> bool {
(self.0 & Self::LIST_ITEM_MASK) != 0
(self.0 & Self::LIST_ITEM_BIT) != 0
}
/// Returns whether this `display` value is a ruby level container.

View File

@ -94,7 +94,6 @@ include = [
"ComputedTimingFunction",
"ComputedValueFlags",
"CursorKind",
"Display",
"DisplayOutside",
"DisplayInside",
"DisplayMode",
@ -1010,17 +1009,3 @@ renaming_overrides_prefixing = true
"GenericContainIntrinsicSize" = """
bool HasAuto() const { return IsAutoLength() || IsAutoNone(); }
"""
"Display" = """
inline StyleDisplayOutside Outside() const;
inline StyleDisplayInside Inside() const;
inline bool IsListItem() const;
inline bool IsInlineFlow() const;
inline bool IsInlineInside() const;
inline bool IsInlineOutside() const;
inline bool IsBlockOutside() const;
inline bool IsRuby() const;
inline bool IsInternalRuby() const;
inline bool IsInternalTable() const;
inline bool IsInternalTableExceptCell() const;
"""