Bug 1174003 part 7: [css-flexbox] Logicalize IsCrossAxisHorizontal() check in GetBaselineOffsetFromOuterCrossSize (and simplify a condition for baseline fallback). r=mats

This patch doesn't change our behavior -- not in opt builds, at least. In debug
builds, this patch does change an assertion condition, to remove a usage of
IsCrossAxisHorizontal().  This means debug builds may proceed a bit further
when loading e.g. bug 1384266's testcase (which up until now was tripping this
assertion).  Now that testcase fails a slighlty later assertion (which I'll
sort out on that bug).

The first hunk of this patch is just a simplification -- replacing a
complicated condition (IsRowOriented==IsOrthogonalTo) with a simpler
formulation of the same condition.  I'm making that simplification in this
patch so that we're more clearly consistent about what condition we depend on
for baseline alignment.  After this patch, that (simplified) condition matches
the condition that we assert inside of GetBaselineOffsetFromOuterCrossEdge().

Note: I'm adding two XXXdholbert comments in this patch, for outstanding issues
that I ran across which are out-of-scope for this patch series.

MozReview-Commit-ID: 5x5xqWWilQZ

--HG--
extra : rebase_source : b25e8bfd7425f76b9784df0bd60fc454d4089347
This commit is contained in:
Daniel Holbert 2018-02-27 15:50:30 -08:00
Родитель fbc7422d44
Коммит cc0ea3c45c
1 изменённых файлов: 17 добавлений и 12 удалений

Просмотреть файл

@ -1870,14 +1870,15 @@ FlexItem::FlexItem(ReflowInput& aFlexItemReflowInput,
#endif // DEBUG
// Map align-self 'baseline' value to 'start' when baseline alignment
// is not possible because the FlexItem's writing mode is orthogonal to
// the main axis of the container. If that's the case, we just directly
// is not possible because the FlexItem's block axis is orthogonal to
// the cross axis of the container. If that's the case, we just directly
// convert our align-self value here, so that we don't have to handle this
// with special cases elsewhere.
// We are treating this case as one where it is appropriate to use the
// fallback values defined at https://www.w3.org/TR/css-align-3/#baseline
if (aAxisTracker.IsRowOriented() ==
aAxisTracker.GetWritingMode().IsOrthogonalTo(mWM)) {
// fallback values defined at https://www.w3.org/TR/css-align/#baseline-values
// XXXdholbert That spec text actually says to fall back to 'start'/'end',
// not 'flex-start'/'flex-end'... Probably sort this out in bug 1207698.
if (!IsBlockAxisCrossAxis()) {
if (mAlignSelf == NS_STYLE_ALIGN_BASELINE) {
mAlignSelf = NS_STYLE_ALIGN_FLEX_START;
} else if (mAlignSelf == NS_STYLE_ALIGN_LAST_BASELINE) {
@ -1961,18 +1962,22 @@ FlexItem::GetBaselineOffsetFromOuterCrossEdge(
const FlexboxAxisTracker& aAxisTracker,
bool aUseFirstLineBaseline) const
{
// NOTE: Currently, 'mAscent' (taken from reflow) is an inherently vertical
// measurement -- it's the distance from the border-top edge of this FlexItem
// to its baseline. So, we can really only do baseline alignment when the
// cross axis is vertical. (The FlexItem constructor enforces this when
// resolving the item's "mAlignSelf" value).
MOZ_ASSERT(!aAxisTracker.IsCrossAxisHorizontal(),
// NOTE:
// * We only use baselines for aligning in the flex container's cross axis.
// * Baselines are a measurement in the item's block axis.
// ...so we only expect to get here if the item's block axis is parallel (or
// antiparallel) to the container's cross axis. (Otherwise, the FlexItem
// constructor should've resolved mAlignSelf with a fallback value, which
// would prevent this function from being called.)
MOZ_ASSERT(IsBlockAxisCrossAxis(),
"Only expecting to be doing baseline computations when the "
"cross axis is vertical");
"cross axis is the block axis");
AxisOrientationType crossAxis = aAxisTracker.GetCrossAxis();
mozilla::Side sideToMeasureFrom = kAxisOrientationToSidesMap[crossAxis][aEdge];
// XXXdholbert The "top"/"bottom" physical-axis dependencies below need to be
// logicalized -- see bug 1384266.
nscoord marginTopToBaseline = ResolvedAscent(aUseFirstLineBaseline) +
mMargin.top;