Skip to content

Commit

Permalink
Bug 1476054: Fixes and cleanups for Servo PR #21156. r=me
Browse files Browse the repository at this point in the history
Similar to the previous patch, logical clear doesn't appear in computed style
objects.

MozReview-Commit-ID: FbN0hiUGzYa
  • Loading branch information
emilio committed Jul 17, 2018
1 parent 9013ba1 commit 50a4dc1
Show file tree
Hide file tree
Showing 12 changed files with 33 additions and 38 deletions.
2 changes: 1 addition & 1 deletion layout/generic/BRFrame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ BRFrame::Reflow(nsPresContext* aPresContext,
}

// Return our reflow status
StyleClear breakType = aReflowInput.mStyleDisplay->PhysicalBreakType(wm);
StyleClear breakType = aReflowInput.mStyleDisplay->mBreakType;
if (StyleClear::None == breakType) {
breakType = StyleClear::Line;
}
Expand Down
2 changes: 1 addition & 1 deletion layout/generic/BlockReflowInput.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -742,7 +742,7 @@ BlockReflowInput::FlowAndPlaceFloat(nsIFrame* aFloat)
// when floats are inserted before it.
if (StyleClear::None != floatDisplay->mBreakType) {
// XXXldb Does this handle vertical margins correctly?
mBCoord = ClearFloats(mBCoord, floatDisplay->PhysicalBreakType(wm));
mBCoord = ClearFloats(mBCoord, floatDisplay->mBreakType);
}
// Get the band of available space with respect to margin box.
nsFlowAreaRect floatAvailableSpace =
Expand Down
13 changes: 0 additions & 13 deletions layout/generic/WritingModes.h
Original file line number Diff line number Diff line change
Expand Up @@ -2187,19 +2187,6 @@ nsStylePosition::MaxBSizeDependsOnContainer(mozilla::WritingMode aWM) const
: MaxHeightDependsOnContainer();
}

inline mozilla::StyleClear
nsStyleDisplay::PhysicalBreakType(mozilla::WritingMode aWM) const
{
using StyleClear = mozilla::StyleClear;
if (mBreakType == StyleClear::InlineStart) {
return aWM.IsBidiLTR() ? StyleClear::Left : StyleClear::Right;
}
if (mBreakType == StyleClear::InlineEnd) {
return aWM.IsBidiLTR() ? StyleClear::Right : StyleClear::Left;
}
return mBreakType;
}

inline bool
nsStyleMargin::HasBlockAxisAuto(mozilla::WritingMode aWM) const
{
Expand Down
6 changes: 2 additions & 4 deletions layout/generic/nsBlockFrame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -842,8 +842,7 @@ nsBlockFrame::GetPrefISize(gfxContext *aRenderingContext)
if (!data.mLineIsEmpty || BlockCanIntersectFloats(line->mFirstChild)) {
breakType = StyleClear::Both;
} else {
breakType = line->mFirstChild->
StyleDisplay()->PhysicalBreakType(data.mLineContainerWM);
breakType = line->mFirstChild->StyleDisplay()->mBreakType;
}
data.ForceBreak(breakType);
data.mCurrentLine = nsLayoutUtils::IntrinsicForContainer(aRenderingContext,
Expand Down Expand Up @@ -3226,8 +3225,7 @@ nsBlockFrame::ReflowBlockFrame(BlockReflowInput& aState,
// Prepare the block reflow engine
nsBlockReflowContext brc(aState.mPresContext, aState.mReflowInput);

StyleClear breakType = frame->StyleDisplay()->
PhysicalBreakType(aState.mReflowInput.GetWritingMode());
StyleClear breakType = frame->StyleDisplay()->mBreakType;
if (StyleClear::None != aState.mFloatBreakType) {
breakType = nsLayoutUtils::CombineBreakType(breakType,
aState.mFloatBreakType);
Expand Down
5 changes: 2 additions & 3 deletions layout/generic/nsFrame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5357,12 +5357,11 @@ nsIFrame::InlinePrefISizeData::ForceBreak(StyleClear aBreakType)
// been cleared past
floats_cur_left = 0,
floats_cur_right = 0;
const WritingMode wm = mLineContainerWM;

for (uint32_t i = 0, i_end = mFloats.Length(); i != i_end; ++i) {
const FloatInfo& floatInfo = mFloats[i];
const nsStyleDisplay* floatDisp = floatInfo.Frame()->StyleDisplay();
StyleClear breakType = floatDisp->PhysicalBreakType(wm);
StyleClear breakType = floatDisp->mBreakType;
if (breakType == StyleClear::Left ||
breakType == StyleClear::Right ||
breakType == StyleClear::Both) {
Expand Down Expand Up @@ -5424,7 +5423,7 @@ nsIFrame::InlinePrefISizeData::ForceBreak(StyleClear aBreakType)
// (earlier) floats on that side would be indirectly cleared
// as well. Thus, we should break out of this loop and stop
// considering earlier floats to be kept in mFloats.
StyleClear floatBreakType = floatDisp->PhysicalBreakType(wm);
StyleClear floatBreakType = floatDisp->mBreakType;
if (floatBreakType != aBreakType &&
floatBreakType != StyleClear::None) {
break;
Expand Down
9 changes: 1 addition & 8 deletions layout/generic/nsIFrame.h
Original file line number Diff line number Diff line change
Expand Up @@ -2190,7 +2190,7 @@ class nsIFrame : public nsQueryFrame
const nsLineList_iterator* mLine;

// The line container. Private, to ensure we always use SetLineContainer
// to update it (so that we have a chance to store the mLineContainerWM).
// to update it.
//
// Note that nsContainerFrame::DoInlineIntrinsicISize will clear the
// |mLine| and |mLineContainer| fields when following a next-in-flow link,
Expand All @@ -2203,9 +2203,6 @@ class nsIFrame : public nsQueryFrame
void SetLineContainer(nsIFrame* aLineContainer)
{
mLineContainer = aLineContainer;
if (mLineContainer) {
mLineContainerWM = mLineContainer->GetWritingMode();
}
}
nsIFrame* LineContainer() const { return mLineContainer; }

Expand All @@ -2226,10 +2223,6 @@ class nsIFrame : public nsQueryFrame
// and when the last text ended with whitespace.
bool mSkipWhitespace;

// Writing mode of the line container (stored here so that we don't
// lose track of it if the mLineContainer field is reset).
mozilla::WritingMode mLineContainerWM;

// Floats encountered in the lines.
class FloatInfo {
public:
Expand Down
2 changes: 0 additions & 2 deletions layout/generic/nsLineBox.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -210,8 +210,6 @@ nsLineBox::BreakTypeToString(StyleClear aBreakType)
case StyleClear::None: return "nobr";
case StyleClear::Left: return "leftbr";
case StyleClear::Right: return "rightbr";
case StyleClear::InlineStart: return "inlinestartbr";
case StyleClear::InlineEnd: return "inlineendbr";
case StyleClear::Both: return "leftbr+rightbr";
case StyleClear::Line: return "linebr";
case StyleClear::Max: return "leftbr+rightbr+linebr";
Expand Down
1 change: 1 addition & 0 deletions layout/style/ServoCSSPropList.mako.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ def method(prop):
# moved or perhaps using a blacklist for the ones with non-layout-dependence
# but other non-trivial dependence like scrollbar colors.
SERIALIZED_PREDEFINED_TYPES = [
"Clear",
"Color",
"Content",
"CounterIncrement",
Expand Down
5 changes: 3 additions & 2 deletions layout/style/nsStyleConsts.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,12 @@ enum class StyleClear : uint8_t {
None = 0,
Left,
Right,
InlineStart,
InlineEnd,
Both,
// StyleClear::Line can be added to one of the other values in layout
// so it needs to use a bit value that none of the other values can have.
//
// FIXME(emilio): Doesn't look like we do that anymore, so probably can be
// made a single value instead, and Max removed.
Line = 8,
Max = 13 // Max = (Both | Line)
};
Expand Down
2 changes: 0 additions & 2 deletions layout/style/nsStyleStruct.h
Original file line number Diff line number Diff line change
Expand Up @@ -2455,8 +2455,6 @@ struct MOZ_NEEDS_MEMMOVABLE_MEMBERS nsStyleDisplay
inline bool HasFixedPosContainingBlockStyleInternal(
mozilla::ComputedStyle&) const;
void GenerateCombinedTransform();
public:
inline mozilla::StyleClear PhysicalBreakType(mozilla::WritingMode aWM) const;
};

struct MOZ_NEEDS_MEMMOVABLE_MEMBERS nsStyleTable
Expand Down
8 changes: 8 additions & 0 deletions servo/components/style/properties/gecko.mako.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3086,6 +3086,14 @@ fn static_assert() {
<% float_keyword = Keyword("float", "Left Right None", gecko_enum_prefix="StyleFloat") %>
${impl_keyword('float', 'mFloat', float_keyword)}

<% clear_keyword = Keyword(
"clear",
"Left Right None Both",
gecko_enum_prefix="StyleClear",
gecko_inexhaustive=True,
) %>
${impl_keyword('clear', 'mBreakType', clear_keyword)}

<% overflow_x = data.longhands_by_name["overflow-x"] %>
pub fn set_overflow_y(&mut self, v: longhands::overflow_y::computed_value::T) {
use properties::longhands::overflow_x::computed_value::T as BaseType;
Expand Down
16 changes: 14 additions & 2 deletions servo/ports/geckolib/glue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3951,7 +3951,7 @@ pub extern "C" fn Servo_DeclarationBlock_SetKeywordValue(
use style::properties::{PropertyDeclaration, LonghandId};
use style::properties::longhands;
use style::values::specified::BorderStyle;
use style::values::specified::Float;
use style::values::specified::{Clear, Float};
use style::values::generics::font::FontStyle;

let long = get_longhand_from_id!(property);
Expand All @@ -3972,10 +3972,22 @@ pub extern "C" fn Servo_DeclarationBlock_SetKeywordValue(
_ => unreachable!(),
}
},
Clear => {
const LEFT: u32 = structs::StyleClear::Left as u32;
const RIGHT: u32 = structs::StyleClear::Right as u32;
const NONE: u32 = structs::StyleClear::None as u32;
const BOTH: u32 = structs::StyleClear::Both as u32;
match value {
LEFT => Clear::Left,
RIGHT => Clear::Right,
NONE => Clear::None,
BOTH => Clear::Both,
_ => unreachable!(),
}
},
VerticalAlign => longhands::vertical_align::SpecifiedValue::from_gecko_keyword(value),
TextAlign => longhands::text_align::SpecifiedValue::from_gecko_keyword(value),
TextEmphasisPosition => longhands::text_emphasis_position::SpecifiedValue::from_gecko_keyword(value),
Clear => longhands::clear::SpecifiedValue::from_gecko_keyword(value),
FontSize => {
// We rely on Gecko passing in font-size values (0...7) here.
longhands::font_size::SpecifiedValue::from_html_size(value as u8)
Expand Down

0 comments on commit 50a4dc1

Please sign in to comment.