Closed Bug 368155 Opened 18 years ago Closed 17 years ago

text-indent needs to contribute to intrinsic width (e.g., of floats)

Categories

(Core :: Layout: Floats, defect, P1)

defect

Tracking

()

VERIFIED FIXED
mozilla1.9alpha6

People

(Reporter: RyanVM, Assigned: dbaron)

References

Details

(Keywords: regression, testcase)

Attachments

(3 files, 4 obsolete files)

See the attached testcase. This is a reflow branch regression.
Attached file Reduced testcase
Reduced testcase
Flags: in-testsuite?
Hmm.  So I figure we should add the text-indent to the first line for both min and pref width if it's a coord (and treat percentages as 0).

That said, if text-indent is negative (especially if it plus the pref width of the text is negative), what should happen?
Flags: blocking1.9?
Negative is fine, except that we need to fix InlineMinWidthData::Break to no-op if the current line so far is negative.

Min and pref width should be (and are already, I think) a max over a list of line min/pref widths and zero, so that they don't go below zero.
(In reply to comment #3)
> Negative is fine, except that we need to fix InlineMinWidthData::Break to no-op
> if the current line so far is negative.

... for optional breaks, but not forced ones.
Hmm...  Why should Break() no-op in this case?
Because the negative indents absorb the ability of what follows them to widen the container.  (Likewise for negative margins.)  Nothing would ever need to break until it's at least into positive width.
Ah, ok.  Fair enough.

So we need to pass a boolean to Break() indicating whether it's forced or not, eh?
Attached file Reftests for once this bug gets fixed (obsolete) —
This is what I get for hanging out in #developers too much.
Attachment #255750 - Attachment mime type: application/octet-stream → text/plain
Attachment #255750 - Flags: superreview?(dbaron)
Attachment #255750 - Flags: review?(dbaron)
Comment on attachment 255750 [details]
Reftests for once this bug gets fixed

These tests look fine, except they'd need a "fails" at the beginning of the line in the manifest if they're checked in before the bug is fixed.
Attachment #255750 - Flags: superreview?(dbaron)
Attachment #255750 - Flags: superreview+
Attachment #255750 - Flags: review?(dbaron)
Attachment #255750 - Flags: review+
Assignee: nobody → dbaron
OS: Windows XP → All
Priority: -- → P1
Hardware: PC → All
Summary: Div width incorrectly calculated when float and indent are defined → text-indent needs to contribute to intrinsic width (e.g., of floats)
Target Milestone: --- → mozilla1.9alpha3
Oops, and, as jwalden pointed out, if they're XHTML they should have .xhtml filenames.
Sorry about that, forgot that the files should have .xhtml extensions
Attachment #255750 - Attachment is obsolete: true
Attachment #255751 - Flags: review?
Comment on attachment 255751 [details] [diff] [review]
Fixing minor filename issue

Carrying over dbaron's previous r/sr+
Attachment #255751 - Flags: superreview+
Attachment #255751 - Flags: review?
Attachment #255751 - Flags: review+
But if we did the fancy break stuff, we'd need to go to even more trouble to get the spaces to contribute to min width.  So I think it's not worth the bother.
But it is worth the bother to make sure negative text-indent can't cause min width to be greater than pref width.
Flags: blocking1.9? → blocking1.9+
Target Milestone: mozilla1.9alpha3 → mozilla1.9alpha6
Attached patch patch (obsolete) — Splinter Review
This fixes the bug, and fixes the accumulation issues for negative indents and margins, but I haven't written testcases for any of the negative stuff yet.
Writing the tests caught a bug in the patch:  In min-width calculation I need to force the first thing on the line to fit, since there is no break-opportunity after the text-indent.
Blocks: 384297
Attached patch patch (obsolete) — Splinter Review
The nsIFrame.h changes explain the basic idea of what's going on here.

roc, see my XXX comment in nsTextFrameThebes as well...
Attachment #268703 - Flags: superreview?(roc)
Attachment #268703 - Flags: review?(roc)
Attachment #255751 - Attachment is patch: true
> // XXXldb Where is the equivalent code in GetInlineMinWidth?

here:

    if (i < flowEndInTextRun && !mTextRun->CanBreakLineBefore(i)) {
      PRBool preformattedNewline = !collapseWhitespace &&
        frag->CharAt(iter.ConvertSkippedToOriginal(i)) == '\n';
      if (!preformattedNewline) {
        // we can't break here
        continue;
      }
    }

the code after this block handles both optional and forced line-breaks. You probably need to set a flag in here (maybe just move preformattedNewline out) to indicate whether the break is forced or not.
Attached patch patch (obsolete) — Splinter Review
Still an XXX comment, but nsTextFrameThebes passes my tests now...
Attachment #268703 - Attachment is obsolete: true
Attachment #269018 - Flags: superreview?(roc)
Attachment #269018 - Flags: review?(roc)
Attachment #268703 - Flags: superreview?(roc)
Attachment #268703 - Flags: review?(roc)
+      frag->CharAt(iter.ConvertSkippedToOriginal(start) == '\n')) {

I don't think the parentheses are in the right place....

+    PRBool preformattedNewline;

You probably want to initialize this to prevent warnings.

+      // XXXldb Shouldn't we be including the newline as part of the
+      // segment that it ends rather than part of the segment that it
+      // starts (and avoid the extra chunk above)?

Probably the best way would be to just have i start at "start".
Attached patch patchSplinter Review
Attachment #269237 - Flags: superreview?(roc)
Attachment #269237 - Flags: review?(roc)
Attachment #269018 - Attachment is obsolete: true
Attachment #269018 - Flags: superreview?(roc)
Attachment #269018 - Flags: review?(roc)
Comment on attachment 269237 [details] [diff] [review]
patch

+    PRBool preformattedNewline;

I still think you should initialize this to avoid warnings.

+      // XXXldb Shouldn't we be including the newline as part of the
+      // segment that it ends rather than part of the segment that it
+      // starts (and avoid the extra chunk above)?

You want to change this comment now that there is no extra chunk above...
Attachment #269237 - Flags: superreview?(roc)
Attachment #269237 - Flags: superreview+
Attachment #269237 - Flags: review?(roc)
Attachment #269237 - Flags: review+
Checked in to trunk, with those comments addressed.

Also checked in Ryan's reftest -- thanks for the test.
Status: NEW → RESOLVED
Closed: 17 years ago
Resolution: --- → FIXED
v.fixed

Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.5; en-US; rv:1.9pre) Gecko/2008050704 Minefield/3.0pre
Status: RESOLVED → VERIFIED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: