Closed Bug 421239 Opened 16 years ago Closed 16 years ago

{inc}Inconsistent margin after emptying paragraph in standards mode

Categories

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

defect

Tracking

()

RESOLVED FIXED

People

(Reporter: jruderman, Assigned: dholbert)

References

Details

(Keywords: testcase)

Attachments

(8 files, 3 obsolete files)

The testcase and reference should look the same, since they have the same final DOM.  But in the testcase, there's more space above the second (nonempty) paragraph.

This reminds me of bug 372632, bug 373298, bug 405517, and bug 418766.
Attached file testcase (dynamic)
Attached file reference (static)
I see this using
Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9b4) Gecko/2008030318 Firefox/3.0b4

OS/Hardware --> All
OS: Mac OS X → All
Hardware: PC → All
Component: Layout → Layout: Block and Inline
QA Contact: layout → layout.block-and-inline
Flags: blocking1.9?
Attached file testcase 2
This testcase has the margins explicitly defined, and only uses margins on the first block (not both)
Attached file reference 2 (broken, ignoreme) (obsolete) —
Attached file reference 2
(oops, forgot to take out the 'A' in the first version of reference 2)
Attachment #307747 - Attachment is obsolete: true
Attached file testcase 3
testcase 3 has no top margin on the first div -- just a 50px bottom margin.

However, after the div is emptied, it looks like we add a top margin, or something -- the outcome looks just like that of testcase 2.
Attached file reference 3
Attachment #307747 - Attachment description: reference 2 → reference 2 (broken, ignoreme)
Depends on: 418766
(In reply to bug 418766 comment #10)
> In other words, I'm assuming that in all situations where line->CachedIsEmpty()
> returns true, line->mBounds.width should be 0.

I think this assumption stated in bug 418766 doesn't hold up in the testcases here, and so bug 418766's checking caused this bug.
Summary: Inconsistent margin(?) after emptying paragraph in standards mode → Inconsistent margin after emptying paragraph in standards mode
Summary: Inconsistent margin after emptying paragraph in standards mode → {inc}Inconsistent margin after emptying paragraph in standards mode
Attached patch patch v1 (obsolete) — Splinter Review
This patch loosens the assumption quoted in Comment 9 to this:

I'm assuming that in all situations where line->CachedIsEmpty()
returns true, line->mBounds.width OR height should be 0.
Status: NEW → ASSIGNED
Attached patch patch v1a (with reftests) (obsolete) — Splinter Review
same as patch v1, plus reftests based on testcases 2 and 3.
Attachment #307761 - Attachment is obsolete: true
Attachment #307779 - Flags: superreview?(roc)
Attachment #307779 - Flags: review?(roc)
Which line in these cases is empty and has height 0 but width nonzero?
The first one (the one from which the "A" is removed)

I *think* it had the width of the viewport, but I'll double-check.
Here's a framedump pre-JS-tweak and during-JS-tweak of testcase 3.  (using a minimized version without whitespace to simplify the frame tree, available at http://people.mozilla.com/~dholbert/tests/421239/test3.html)

Quoting from a comment in this attached framedump:

"Notice that the very first line has a width of 48240 (the same
width as the body block) and a height of 0.  That line "is empty" by height
standards, but not by width standards."
This won't work if you put an empty span in the <div> so that it has height as well as width, i.e. combine this test with the test in bug 418766. Right?

Maybe we should just scrub this optimization and hope that it doesn't matter.
This patch still works if I just add an empty span to div "a" (after the character).

IIRC from bug 418766, an empty span ONLY gets a height if we're in quirks mode.
And it seems in this bug that an empty div only gets a width in standards mode.

So, to phrase that a different way, I'm hoping this assumption holds:
  - in quirks mode, it's impossible to have an empty line with 0 width
  - in standards mode, it's impossible to have an empty line with 0 height

And hence, you'd never be able to have an empty line with nonzero height *and* width.  In which case the optimization in patch v1a would work.

Gonna play with testcases a bit more to verify that this is all true.
Comment on attachment 307779 [details] [diff] [review]
patch v1a (with reftests)

canceling review request for now; may re-request later when I have more info about how foolproof the optimization is.
Attachment #307779 - Flags: superreview?(roc)
Attachment #307779 - Flags: review?(roc)
(In reply to comment #16)
> 
> So, to phrase that a different way, I'm hoping this assumption holds:
>   - in quirks mode, it's impossible to have an empty line with 0 width
>   - in standards mode, it's impossible to have an empty line with 0 height

Sorry, I got that backwards -- s/0/nonzero.

i.e., I'm hoping this assumption holds:
   - in quirks mode, it's impossible to have an empty line with nonzero width
   - in stds mode, it's impossible to have an empty line with nonzero height
Assignee: nobody → dholbert
Status: ASSIGNED → NEW
Attached patch patch v2Splinter Review
(In reply to comment #19)
> That sounds fragile.

Yeah, I kinda agree... even if the assumption in comment 18 is correct, it seems like that could change in the future.

OK, this patch just nixes the optimization, as suggested in comment 15.
Attachment #307779 - Attachment is obsolete: true
Attachment #308493 - Flags: superreview?(roc)
Attachment #308493 - Flags: review?(roc)
Comment on attachment 308493 [details] [diff] [review]
patch v2

ok, watch very carefully for perf changes
Attachment #308493 - Flags: superreview?(roc)
Attachment #308493 - Flags: superreview+
Attachment #308493 - Flags: review?(roc)
Attachment #308493 - Flags: review+
Flags: blocking1.9? → blocking1.9+
Priority: -- → P2
Whiteboard: [needs landing]
I'm planning on landing this tonight, if/when the tree is quiet, so I can watch for perf changes.
Status: NEW → ASSIGNED
patch v2 landed:

Checking in generic/nsBlockFrame.cpp;
/cvsroot/mozilla/layout/generic/nsBlockFrame.cpp,v  <--  nsBlockFrame.cpp
new revision: 3.940; previous revision: 3.939
done
RCS file: /cvsroot/mozilla/layout/reftests/bugs/421239-1-ref.html,v
done
Checking in reftests/bugs/421239-1-ref.html;
/cvsroot/mozilla/layout/reftests/bugs/421239-1-ref.html,v  <--  421239-1-ref.html
initial revision: 1.1
done
RCS file: /cvsroot/mozilla/layout/reftests/bugs/421239-1.html,v
done
Checking in reftests/bugs/421239-1.html;
/cvsroot/mozilla/layout/reftests/bugs/421239-1.html,v  <--  421239-1.html
initial revision: 1.1
done
RCS file: /cvsroot/mozilla/layout/reftests/bugs/421239-2-ref.html,v
done
Checking in reftests/bugs/421239-2-ref.html;
/cvsroot/mozilla/layout/reftests/bugs/421239-2-ref.html,v  <--  421239-2-ref.html
initial revision: 1.1
done
RCS file: /cvsroot/mozilla/layout/reftests/bugs/421239-2.html,v
done
Checking in reftests/bugs/421239-2.html;
/cvsroot/mozilla/layout/reftests/bugs/421239-2.html,v  <--  421239-2.html
initial revision: 1.1
done
Status: ASSIGNED → RESOLVED
Closed: 16 years ago
Resolution: --- → FIXED
Whiteboard: [needs landing]
(In reply to comment #21)
> ok, watch very carefully for perf changes
(In reply to comment #22)
> I'm planning on landing this tonight, if/when the tree is quiet, so I can watch
> for perf changes.

Perf impact seems negligible -- the mac & linux tp, tp2, tdhtml, txul, and ts numbers all stayed within their range of noise for the day for the few cycles since this landed. (Most of the numbers went down, actually, though I'm pretty sure that's from noise & not due to a perf win. :))

I don't have Windows numbers yet, due to the 2+ hour cycle times on that machine. :(
Marking in-testsuite+ because tests were included in the patch.
Flags: in-testsuite+
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: