Closed Bug 1174450 Opened 9 years ago Closed 9 years ago

margin-left affects layout in both dimensions with vertical text

Categories

(Core :: Layout: Block and Inline, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla41
Tracking Status
firefox41 --- fixed

People

(Reporter: MatsPalmgren_bugz, Assigned: MatsPalmgren_bugz)

References

(Blocks 1 open bug)

Details

(Keywords: testcase)

Attachments

(17 files, 1 obsolete file)

582 bytes, text/html
Details
13.33 KB, patch
jfkthame
: review+
Details | Diff | Splinter Review
3.66 KB, patch
Details | Diff | Splinter Review
6.69 KB, patch
jfkthame
: review+
Details | Diff | Splinter Review
6.90 KB, patch
jfkthame
: review+
Details | Diff | Splinter Review
3.03 KB, patch
jfkthame
: review+
Details | Diff | Splinter Review
4.38 KB, patch
jfkthame
: review+
Details | Diff | Splinter Review
6.77 KB, patch
jfkthame
: review+
Details | Diff | Splinter Review
11.79 KB, patch
jfkthame
: review+
Details | Diff | Splinter Review
6.86 KB, patch
jfkthame
: review+
Details | Diff | Splinter Review
13.63 KB, patch
jfkthame
: review+
Details | Diff | Splinter Review
3.27 KB, patch
jfkthame
: review+
Details | Diff | Splinter Review
4.34 KB, patch
Details | Diff | Splinter Review
3.01 KB, patch
jfkthame
: review+
Details | Diff | Splinter Review
4.54 KB, patch
jfkthame
: review+
Details | Diff | Splinter Review
15.37 KB, patch
jfkthame
: review+
Details | Diff | Splinter Review
43.01 KB, patch
Details | Diff | Splinter Review
STR: load the attached testcase ACTUAL RESULTS There's a 100px gap to the left of, and below, the red block. EXPECTED RESULTS A 100px gap to the left, no gap below, the red box. (that's what Chrome Canary renders, fwiw)
Jonathan, can you confirm this is a bug? and my expected results is correct?
Flags: needinfo?(jfkthame)
Yes, looks like a bug to me. Mixed-up writing modes when initializing the reflow-state, I'd guess. Maybe Simon can provide a quick fix?
Status: UNCONFIRMED → NEW
Ever confirmed: true
Flags: needinfo?(jfkthame) → needinfo?(smontagu)
I discovered it by accidentally fixing it while working on Grid item intrinsic sizing. The bug is in nsLayoutUtils::IntrinsicForContainer / IntrinsicISizeOffsets. I'm refactoring those to support Grid layout so I can provide a fix if you want.
Yes please, sounds good. (I'm a bit surprised we haven't been noticing this already; anyway, let's fix asap.) I presume this will mean passing the appropriate (container's) writing mode in to nsFrame::IntrinsicISizeOffsets. While you're there, it looks like we could also clean up the AddCoord calls to use logical accessors, along the lines of AddCoord(styleMargin->mMargin.GetIStart(aWM), aRenderingContext, this, &result.hMargin, &result.hPctMargin, false); instead of the ugly IsVertical()?... conditional expressions. Thanks!
OK, I'll submit my patches for those bits here.
Assignee: nobody → mats
Blocks: 1151212
Flags: needinfo?(smontagu)
Blocks: 1174546
Blocks: 1174553
I'll submit a series of patches that takes minimal steps to avoid mistakes in refactoring this code and to make it easier to review...
I intentionally didn't rename the variables (which are now params) in this patch to make it easier to review. I'll rename these in part 2/3. Also, I duplicated the GetAbsoluteCoord calculations of minISize/maxISize for now - this will come off in part 5.
Attachment #8622110 - Flags: review?(jfkthame)
This might make it easier to see the changes in the moved code.
(intentionally leaving 'min' and 'result' for now)
Attachment #8622112 - Flags: review?(jfkthame)
I made 'min' and 'result' local vars again since we'll increment these from being content-box values at the start towards margin-box at the end.
Attachment #8622114 - Flags: review?(jfkthame)
IntrinsicForContainer(...) is implemented as IntrinsicForWM(aFrame->GetParent()->GetWritingMode(), ...). (This is needed for Grid which will pass a different WM depending on whether we're calculating the intrinsic size in the column or row dimension (bug 1174553))
Attachment #8622117 - Flags: review?(jfkthame)
(In reply to Jonathan Kew (:jfkthame) from comment #4) > it looks like we could also clean up the AddCoord calls to use > logical accessors, along the lines of > AddCoord(styleMargin->mMargin.GetIStart(aWM), ... We could, but we will also need a BSize variant so I kept the code mostly intact.
Attachment #8622118 - Flags: review?(jfkthame)
Attached patch Rollup patch with all the parts. (obsolete) — Splinter Review
Comment on attachment 8622117 [details] [diff] [review] part 7 - Move most of IntrinsicForContainer into a new method, IntrinsicForWM, that takes the writing-mode to use as a parameter Review of attachment 8622117 [details] [diff] [review]: ----------------------------------------------------------------- ::: layout/base/nsLayoutUtils.cpp @@ +4678,5 @@ > +{ > + // We want the size this frame will contribute to the parent's inline-size, > + // so we work in the parent's writing mode; but if aFrame is orthogonal to > + // its parent, we'll need to look at its BSize instead of min/pref-ISize. > + WritingMode wm = aFrame->GetParent()->GetWritingMode(); Clearly, it wouldn't make sense to ever call this for a frame that doesn't have a parent; maybe worth adding a MOZ_ASSERT(aFrame->GetParent()) to make that explicit?
Attachment #8622117 - Flags: review?(jfkthame) → review+
Comment on attachment 8622118 [details] [diff] [review] part 8 - Add a new method nsIFrame::IntrinsicBSizeOffsets Review of attachment 8622118 [details] [diff] [review]: ----------------------------------------------------------------- Looks fine, except that I'd prefer to see the |orthogonal| variable renamed; see below. ::: layout/generic/nsFrame.cpp @@ +4098,5 @@ > +{ > + nsIFrame::IntrinsicISizeOffsetData result; > + WritingMode wm = aFrame->GetWritingMode(); > + const nsStyleMargin* styleMargin = aFrame->StyleMargin(); > + bool orthogonal = aForISize == wm.IsVertical(); The variable name |orthogonal| seems wrong here (at least, I found it confusing when reading the code). It doesn't seem at all clear what it's saying is orthogonal to what. This flag actually represents whether we're computing offsets in the vertical axis or the horizontal, so please rename it to |verticalAxis| or something like that. @@ +4131,5 @@ > + result.hBorder += styleBorder->GetComputedBorderWidth( > + WritingMode::PhysicalSideForBlockAxis(wm, eLogicalEdgeStart)); > + result.hBorder += styleBorder->GetComputedBorderWidth( > + WritingMode::PhysicalSideForBlockAxis(wm, eLogicalEdgeEnd)); > + } Wouldn't it be simpler to use the |verticalAxis| flag (formerly |orthogonal|) here, too? No need to go through the PhysicalSideFor... methods at all: const nsStyleBorder* styleBorder = aFrame->StyleBorder(); if (verticalAxis) { result.hBorder += styleBorder->GetComputedBorderWidth(NS_SIDE_TOP); result.hBorder += ...(NS_SIDE_BOTTOM); } else { result .... (NS_SIDE_LEFT); result .... (NS_SIDE_RIGHT); }
Attachment #8622118 - Flags: review?(jfkthame) → review+
Attachment #8622110 - Flags: review?(jfkthame) → review+
Attachment #8622112 - Flags: review?(jfkthame) → review+
Attachment #8622113 - Flags: review?(jfkthame) → review+
Attachment #8622114 - Flags: review?(jfkthame) → review+
Attachment #8622115 - Flags: review?(jfkthame) → review+
Attachment #8622116 - Flags: review?(jfkthame) → review+
Attachment #8622119 - Flags: review?(jfkthame) → review+
Attachment #8622120 - Flags: review?(jfkthame) → review+
Comment on attachment 8622110 [details] [diff] [review] part 1 - Split IntrinsicForContainer in two parts; move the latter part to a new function, AddIntrinsicSizeOffset, which applies the padding/border/margin from the given IntrinsicISizeOffsetData Review of attachment 8622110 [details] [diff] [review]: ----------------------------------------------------------------- ::: layout/base/nsLayoutUtils.cpp @@ +4330,5 @@ > + const nsStyleCoord& styleISize, > + const nsStyleCoord& styleMinISize, > + const nsStyleCoord& styleMaxISize, > + uint32_t aFlags, > + WritingMode aContainerWM) Hmm. Looking at how you end up using this later in bug 1174546, I wonder if it'd be better to pass just an 'aVerticalAxis' flag (or maybe a PhysicalAxis value -- see enum in WritingModes.h -- rather than a bool) instead of the WritingMode here. I think this would let you do nsLayoutUtils::MinISizeContributionForAxis instead of ...ForWM in bug 1174546, and avoid the need to construct a "synthetic writing mode" just to pass down the vertical/horizontal choice.
I figured it's easier to review this as an increment on top of the previous patches.
Attachment #8622663 - Flags: review?(jfkthame)
Attachment #8622122 - Attachment is obsolete: true
Attachment #8622666 - Flags: review?(jfkthame) → review+
Attachment #8622663 - Flags: review?(jfkthame) → review+
Comment on attachment 8622668 [details] [diff] [review] part 10b - Rename IntrinsicForWM to IntrinsicForAxis and make it take a PhysicalAxis instead of a WritingMode Review of attachment 8622668 [details] [diff] [review]: ----------------------------------------------------------------- ::: layout/base/nsLayoutUtils.cpp @@ +4635,5 @@ > nscoord h; > if (GetAbsoluteCoord(styleBSize, h) || > GetPercentBSize(styleBSize, aFrame, h)) { > h = std::max(0, h - bSizeTakenByBoxSizing); > + oops - a line with just spaces managed to sneak in here. ::: layout/base/nsLayoutUtils.h @@ +1308,5 @@ > enum { > IGNORE_PADDING = 0x01 > }; > + static nscoord IntrinsicForAxis(mozilla::PhysicalAxis aAxis, > + nsRenderingContext* aRenderingContext, nit: it'd be nice to fix up the alignment of the params here.
Attachment #8622668 - Flags: review?(jfkthame) → review+
Fixed. Thanks for the quick reviews!
Flags: in-testsuite+
Depends on: 1397795
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: