Closed Bug 1217833 Opened 9 years ago Closed 9 years ago

CSS :first-line rule on RTL element, text placement is wrong

Categories

(Core :: Layout, defect)

44 Branch
defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla45
Tracking Status
firefox45 --- fixed

People

(Reporter: yonizaf, Assigned: dbaron)

References

Details

(Keywords: regression, rtl)

Attachments

(3 files)

User Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:38.0) Gecko/20100101 Firefox/38.0
Build ID: 20150916094008

Steps to reproduce:

If you add a ::first-line CSS rule to a div that has dir=rtl and text-align:right, the text in the div get placed outside the element and far to the right. 

The ::first-line rule can be empty, it doesn't have to have any properties in it for this to happen.

A test file is attached to show the problem.
Keywords: regression
This is a regression, but not a recent one. The initial regression range is http://hg.mozilla.org/mozilla-central/pushloghtml?fromchange=44ae8462d6ab&tochange=46041cc216fd, though it seems to have morphed a bit since then.

A likely culprit is http://hg.mozilla.org/mozilla-central/rev/dab8e3865967 from bug 789096
Keywords: rtl
Is there a reason why this bug still has unconfirmed status?
Status: UNCONFIRMED → NEW
Ever confirmed: true
Not surprisingly, the nsFirstLineFrame frames for both the first and following lines have basically the same x-offset as their contents, double-offsetting the contents.

I suspect that before the patch we always aligned first line frames to the left edge.  But I think that in a logical coordinate world it makes more sense to align them to the start-edge.
Though another reasonable possibility would be to make the line frame fill the entire inline-size of the block (possibly excluding space taken by floats).
That said, it's not clear to me what's going wrong, given that we do call BeginSpan and EndSpan for the nsFirstLineFrame (which uses nsInlineFrame::ReflowFrames), so it's not clear to me why the use of ContainerSizeForSpan (and the calls to SetRect in VerticalAlignFrames) don't take care of this properly.
The nsLineLayout code is doing the right thing, but then nsBidiPresUtils::RepositionFrame is moving it.
The thing that seems like the obvious patch:
https://hg.mozilla.org/users/dbaron_mozilla.com/patches/raw-file/71b60ac7f7e4/remove-line-frame-exception
breaks the bidi reordering of the second of my tests (while fixing the positioning).
But adjusting aContainerSize there works.
Assignee: nobody → dbaron
Oops, I need to fix that commit message to be:

Bug 1217833 - Fix container width in exception for line frames in nsBidiPresUtils::ReorderFrames.
Attachment #8691218 - Attachment description: Remove exception for line frames from nsBidiPresUtils::ReorderFrames since line frames now lay out more like regular inlines → Fix container width in exception for line frames in nsBidiPresUtils::ReorderFrames
Comment on attachment 8691218 [details] [diff] [review]
Fix container width in exception for line frames in nsBidiPresUtils::ReorderFrames

Review of attachment 8691218 [details] [diff] [review]:
-----------------------------------------------------------------

Makes sense to me, thanks (with the corrected commit msg).
Attachment #8691218 - Flags: review?(jfkthame) → review+
https://hg.mozilla.org/integration/mozilla-inbound/rev/0ac7ee2441e58d18ecac91a19a9a886b92794c5e
Bug 1217833 - Fix container width in exception for line frames in nsBidiPresUtils::ReorderFrames.  r=jfkthame
https://hg.mozilla.org/integration/mozilla-inbound/rev/e567a54aa60420657992d405823af24b2b2e7e70
Bug 1217833 followup - Mark one test as fuzzy(43,2) on a CLOSED TREE (though fuzzy amounts needed vary by platform).
I think the fuzz was needed because the leftmost edge of the t was overlapping with the blue background, and the paint order of the two was different between test and reference.

I'll try a try run with adding a margin and removing the fuzz.
https://hg.mozilla.org/mozilla-central/rev/0ac7ee2441e5
https://hg.mozilla.org/mozilla-central/rev/e567a54aa604
Status: NEW → RESOLVED
Closed: 9 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla45
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: