Skip to content

Commit

Permalink
Bug 1476054: Fixes and cleanups for Servo PR #21139. r=me
Browse files Browse the repository at this point in the history
Logical floats don't appear in the computed style objects, so there's no need to
check for them.

MozReview-Commit-ID: 3ocJrRB3jeO
  • Loading branch information
emilio committed Jul 17, 2018
1 parent 91caa85 commit 75b7197
Show file tree
Hide file tree
Showing 10 changed files with 24 additions and 31 deletions.
5 changes: 2 additions & 3 deletions layout/generic/BlockReflowInput.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -785,7 +785,7 @@ BlockReflowInput::FlowAndPlaceFloat(nsIFrame* aFloat)
// Find a place to place the float. The CSS2 spec doesn't want
// floats overlapping each other or sticking out of the containing
// block if possible (CSS2 spec section 9.5.1, see the rule list).
StyleFloat floatStyle = floatDisplay->PhysicalFloats(wm);
StyleFloat floatStyle = floatDisplay->mFloat;
MOZ_ASSERT(StyleFloat::Left == floatStyle || StyleFloat::Right == floatStyle,
"Invalid float type!");

Expand Down Expand Up @@ -1045,8 +1045,7 @@ BlockReflowInput::PushFloatPastBreak(nsIFrame *aFloat)
// must have their tops below the top of this float)
// * don't waste much time trying to reflow this float again until
// after the break
StyleFloat floatStyle =
aFloat->StyleDisplay()->PhysicalFloats(mReflowInput.GetWritingMode());
StyleFloat floatStyle = aFloat->StyleDisplay()->mFloat;
if (floatStyle == StyleFloat::Left) {
FloatManager()->SetPushedLeftFloatPastBreak();
} else {
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::StyleFloat
nsStyleDisplay::PhysicalFloats(mozilla::WritingMode aWM) const
{
using StyleFloat = mozilla::StyleFloat;
if (mFloat == StyleFloat::InlineStart) {
return aWM.IsBidiLTR() ? StyleFloat::Left : StyleFloat::Right;
}
if (mFloat == StyleFloat::InlineEnd) {
return aWM.IsBidiLTR() ? StyleFloat::Right : StyleFloat::Left;
}
return mFloat;
}

inline mozilla::StyleClear
nsStyleDisplay::PhysicalBreakType(mozilla::WritingMode aWM) const
{
Expand Down
3 changes: 1 addition & 2 deletions layout/generic/nsBlockFrame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4346,8 +4346,7 @@ nsBlockFrame::SplitFloat(BlockReflowInput& aState,
nextInFlow->AddStateBits(NS_FRAME_IS_OVERFLOW_CONTAINER);
}

StyleFloat floatStyle =
aFloat->StyleDisplay()->PhysicalFloats(aState.mReflowInput.GetWritingMode());
StyleFloat floatStyle = aFloat->StyleDisplay()->mFloat;
if (floatStyle == StyleFloat::Left) {
aState.FloatManager()->SetSplitLeftFloatAcrossBreak();
} else {
Expand Down
6 changes: 3 additions & 3 deletions layout/generic/nsFloatManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ nsFloatManager::GetFlowArea(WritingMode aWM, nscoord aBCoord, nscoord aBSize,
// This float is in our band.

// Shrink our band's width if needed.
StyleFloat floatStyle = fi.mFrame->StyleDisplay()->PhysicalFloats(aWM);
StyleFloat floatStyle = fi.mFrame->StyleDisplay()->mFloat;

// When aBandInfoType is BandFromPoint, we're only intended to
// consider a point along the y axis rather than a band.
Expand Down Expand Up @@ -283,7 +283,7 @@ nsFloatManager::AddFloat(nsIFrame* aFloatFrame, const LogicalRect& aMarginRect,
info.mLeftBEnd = nscoord_MIN;
info.mRightBEnd = nscoord_MIN;
}
StyleFloat floatStyle = aFloatFrame->StyleDisplay()->PhysicalFloats(aWM);
StyleFloat floatStyle = aFloatFrame->StyleDisplay()->mFloat;
MOZ_ASSERT(floatStyle == StyleFloat::Left || floatStyle == StyleFloat::Right,
"Unexpected float style!");
nscoord& sideBEnd =
Expand Down Expand Up @@ -316,7 +316,7 @@ nsFloatManager::CalculateRegionFor(WritingMode aWM,
// Preserve the right margin-edge for left floats and the left
// margin-edge for right floats
const nsStyleDisplay* display = aFloat->StyleDisplay();
StyleFloat floatStyle = display->PhysicalFloats(aWM);
StyleFloat floatStyle = display->mFloat;
if ((StyleFloat::Left == floatStyle) == aWM.IsBidiLTR()) {
region.IStart(aWM) = region.IEnd(aWM);
}
Expand Down
4 changes: 2 additions & 2 deletions layout/generic/nsFrame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5379,7 +5379,7 @@ nsIFrame::InlinePrefISizeData::ForceBreak(StyleClear aBreakType)
}
}

StyleFloat floatStyle = floatDisp->PhysicalFloats(wm);
StyleFloat floatStyle = floatDisp->mFloat;
nscoord& floats_cur =
floatStyle == StyleFloat::Left ? floats_cur_left : floats_cur_right;
nscoord floatWidth = floatInfo.Width();
Expand Down Expand Up @@ -5414,7 +5414,7 @@ nsIFrame::InlinePrefISizeData::ForceBreak(StyleClear aBreakType)
// no longer any floats we need to keep. See below.
for (FloatInfo& floatInfo : Reversed(mFloats)) {
const nsStyleDisplay* floatDisp = floatInfo.Frame()->StyleDisplay();
if (floatDisp->PhysicalFloats(wm) != clearFloatType) {
if (floatDisp->mFloat != clearFloatType) {
newFloats.AppendElement(floatInfo);
} else {
// This is a float on the side that this break directly clears
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 @@ -78,6 +78,7 @@ def method(prop):
"Content",
"CounterIncrement",
"CounterReset",
"Float",
"FontFamily",
"FontFeatureSettings",
"FontLanguageOverride",
Expand Down
2 changes: 0 additions & 2 deletions layout/style/nsStyleConsts.h
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,6 @@ enum class StyleFloat : uint8_t {
None,
Left,
Right,
InlineStart,
InlineEnd
};

// float-edge
Expand Down
4 changes: 0 additions & 4 deletions layout/style/nsStyleStruct.h
Original file line number Diff line number Diff line change
Expand Up @@ -2456,10 +2456,6 @@ struct MOZ_NEEDS_MEMMOVABLE_MEMBERS nsStyleDisplay
mozilla::ComputedStyle&) const;
void GenerateCombinedTransform();
public:
// Return the 'float' and 'clear' properties, with inline-{start,end} values
// resolved to {left,right} according to the given writing mode. These are
// defined in WritingModes.h.
inline mozilla::StyleFloat PhysicalFloats(mozilla::WritingMode aWM) const;
inline mozilla::StyleClear PhysicalBreakType(mozilla::WritingMode aWM) const;
};

Expand Down
3 changes: 3 additions & 0 deletions servo/components/style/properties/gecko.mako.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3083,6 +3083,9 @@ fn static_assert() {

<%call expr="impl_keyword_clone('display', 'mDisplay', display_keyword)"></%call>

<% float_keyword = Keyword("float", "Left Right None", gecko_enum_prefix="StyleFloat") %>
${impl_keyword('float', 'mFloat', float_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
14 changes: 12 additions & 2 deletions servo/ports/geckolib/glue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3951,17 +3951,27 @@ 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::generics::font::FontStyle;

let long = get_longhand_from_id!(property);
let value = value as u32;

let prop = match_wrap_declared! { long,
MozUserModify => longhands::_moz_user_modify::SpecifiedValue::from_gecko_keyword(value),
// TextEmphasisPosition => FIXME implement text-emphasis-position
Direction => longhands::direction::SpecifiedValue::from_gecko_keyword(value),
Display => longhands::display::SpecifiedValue::from_gecko_keyword(value),
Float => longhands::float::SpecifiedValue::from_gecko_keyword(value),
Float => {
const LEFT: u32 = structs::StyleFloat::Left as u32;
const RIGHT: u32 = structs::StyleFloat::Right as u32;
const NONE: u32 = structs::StyleFloat::None as u32;
match value {
LEFT => Float::Left,
RIGHT => Float::Right,
NONE => Float::None,
_ => 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),
Expand Down

0 comments on commit 75b7197

Please sign in to comment.