Closed Bug 393970 Opened 17 years ago Closed 16 years ago

Grid columns don't line up if one <rows> block is scrollable

Categories

(Core :: Layout, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla1.9

People

(Reporter: jwkbugzilla, Assigned: jwkbugzilla)

References

Details

(Keywords: regression)

Attachments

(4 files, 6 obsolete files)

Attached file Testcase (obsolete) —
The problem occurs when using <grid> with two nested <rows> blocks - first for header, second for list body. Only the second <rows> block is scrollable. In Firefox 2.0 the columns are still lined up (last cell of the header is made larger by the width of the scroll bar), on trunk however the cells of the header are shifted (proportions are simply kept, and header has more space resulting in a shift).
This regressed between 2007-01-31-04 and 2007-02-01-04. My bet is on bug 243370, no other patch touched grid on this day. Cc'ing Andreas Lange and roc to comment.
Blocks: tomtom
Could be, but I don't see the bug looking at attachment #253459 [details] [diff] [review]. This needs to be debugged.
Flags: blocking1.9?
I can confirm that patch from attachment #253459 [details] [diff] [review] caused the issue - I checked out code from 2007-02-01 and the issue occurs there, backing out this patch fixed it. I don't see any bugs in this patch either, so I will try to find out which part of the patch causes the regression.
I am still recompiling but the bug seems to be caused by this change in nsGridRowLeafLayout.cpp:

      // go up the parent chain looking for scrollframes
-     PRBool isHorizontal = PR_FALSE;
-     aBox->GetOrientation(isHorizontal);
-
      nsIBox* scrollbox = nsnull;
      aBox->GetParentBox(&aBox);
      scrollbox = nsGrid::GetScrollBox(aBox);
        
        nsCOMPtr<nsIScrollableFrame> scrollable = do_QueryInterface(scrollbox);
        if (scrollable) {
           nsMargin scrollbarSizes = scrollable->GetActualScrollbarSizes();
 
           nsRect ourRect(scrollbox->GetRect());
           nsMargin padding(0,0,0,0);
           scrollbox->GetBorderAndPadding(padding);
           ourRect.Deflate(padding);
           scrollbox->GetInset(padding);
           ourRect.Deflate(padding);
 
           nscoord diff;
-          if (isHorizontal) {
+          if (aBox->IsHorizontal()) {
             diff = scrollbarSizes.left + scrollbarSizes.right;
           } else {
             diff = scrollbarSizes.top + scrollbarSizes.bottom;
           }

By the time we call aBox->IsHorizontal() we have already overwritten the value of aBox.
Attached patch PatchSplinter Review
Assignee: nobody → trev.moz
Status: NEW → ASSIGNED
Attachment #278874 - Flags: superreview?(roc)
Attachment #278874 - Flags: review?(roc)
Comment on attachment 278874 [details] [diff] [review]
Patch

bingo! Thanks a lot!
Attachment #278874 - Flags: superreview?(roc)
Attachment #278874 - Flags: superreview+
Attachment #278874 - Flags: review?(roc)
Attachment #278874 - Flags: review+
Attached patch Mochitest testcase (obsolete) — Splinter Review
The testcase shows that we still have issues here - columns don't line up if we put another <rows> block inside a <rows> block with vertical overflow. This bug is not a regression however, same happens in Firefox 2.0 as well.
Attachment #278929 - Flags: review?(roc)
Attachment #278563 - Attachment is obsolete: true
Attached patch Patch v2 (obsolete) — Splinter Review
The new patch now fixes the second problem as well - GetScrollBox() would only go up to the next grid part, we should check all parents however. I also removed some unused code (ourRect) and added a return at the end of |if (diff > 0)| - as far as I can tell we don't need to call nsSprocketLayout::ComputeChildSizes() again (?).

Unfortunately, I know very little about the layout code, so maybe I am doing something wrong here. I think we should be stopping walking the parent chain at the grid, but so far I could only come up with:

      // if we are at our grid - we are done
      const nsStyleDisplay* display = scrollbox->GetStyleContext()->GetStyleDisplay();
      if (display->mDisplay == NS_STYLE_DISPLAY_INLINE_GRID ||
          display->mDisplay == NS_STYLE_DISPLAY_GRID)
      {
        break;
      }

However, I guess using display property here would be wrong, and for some reason I couldn't make this patch fail without this check.

I fixed the alignment of rows, it was to difficult to edit this function. I will attach a -w patch as well.
Attachment #278929 - Attachment is obsolete: true
Attachment #279338 - Attachment is obsolete: true
Attachment #279344 - Flags: review?(roc)
Attached patch Patch v2 with -w (obsolete) — Splinter Review
Can  you check in the first patch, and then we'll do the second issue as a separate patch? Thanks!
Keywords: checkin-needed
First patch checked in. Leaving open for second patch.

Checking in layout/xul/base/src/grid/nsGridRowLeafLayout.cpp;/cvsroot/mozilla/layout/xul/base/src/grid/nsGridRowLeafLayout.cpp,v  <--  nsGridRowLeafLayout.cpp
new revision: 1.19; previous revision: 1.18
done
Keywords: checkin-needed
(In reply to comment #10)
>I think we should be stopping walking the parent chain at the grid
Can you just keep calling GetParentGridPart until it returns null?
(In reply to comment #14)
> Can you just keep calling GetParentGridPart until it returns null?

Not sure about that - can we have scrollable boxes inside a grid that are not grid parts?
Target Milestone: --- → mozilla1.9 M9
Attached patch Patch v3 (obsolete) — Splinter Review
Attaching updated patch, it no longer contains the regression fix that was already checked in. This patch also implements Neil's suggestion.
Attachment #279344 - Attachment is obsolete: true
Attachment #280448 - Flags: review?(roc)
Attachment #279344 - Flags: review?(roc)
Attached patch Patch v3 with -w (obsolete) — Splinter Review
Attachment #279345 - Attachment is obsolete: true
Attachment #280448 - Flags: superreview+
Attachment #280448 - Flags: review?(roc)
Attachment #280448 - Flags: review+
Attachment #280448 - Flags: approval1.9+
Keywords: checkin-needed
Attachment #279338 - Attachment is obsolete: false
Attachment #279338 - Attachment mime type: text/html → application/vnd.mozilla.xul+xml
Comment on attachment 280449 [details] [diff] [review]
Patch v3 with -w

>        nsCOMPtr<nsIScrollableFrame> scrollable = do_QueryInterface(scrollbox);
I didn't think frames were refcounted - you're going to get blamed for reindenting buggy code without fixing it ;-)
(In reply to comment #18)
> (From update of attachment 280449 [details] [diff] [review])
> >        nsCOMPtr<nsIScrollableFrame> scrollable = do_QueryInterface(scrollbox);
> I didn't think frames were refcounted - you're going to get blamed for
> reindenting buggy code without fixing it ;-)

Wladimir / Robert: Do you want this issue fixed or have the patch checked-in as-is?
It doesn't need to be fixed here.
Checking in layout/xul/base/Makefile.in;
/cvsroot/mozilla/layout/xul/base/Makefile.in,v  <--  Makefile.in
new revision: 1.6; previous revision: 1.5
done
Checking in layout/xul/base/src/grid/nsGridRowLeafLayout.cpp;
/cvsroot/mozilla/layout/xul/base/src/grid/nsGridRowLeafLayout.cpp,v  <--  nsGridRowLeafLayout.cpp
new revision: 1.20; previous revision: 1.19
done
RCS file: /cvsroot/mozilla/layout/xul/base/test/Makefile.in,v
done
Checking in layout/xul/base/test/Makefile.in;
/cvsroot/mozilla/layout/xul/base/test/Makefile.in,v  <--  Makefile.in
initial revision: 1.1
done
RCS file: /cvsroot/mozilla/layout/xul/base/test/test_bug393970.xul,v
done
Checking in layout/xul/base/test/test_bug393970.xul;
/cvsroot/mozilla/layout/xul/base/test/test_bug393970.xul,v  <--  test_bug393970.xul
initial revision: 1.1
done
Status: ASSIGNED → RESOLVED
Closed: 17 years ago
Keywords: checkin-needed
Resolution: --- → FIXED
Four of the tests added by this bug failed, so I had to backout the patch:

*** 36036 ERROR FAIL | Cells (1,2) and (2,2) line up horizontally (with overflow-x: hidden; overflow-y: scroll;) | got 435, expected 438 | /tests/layout/xul/base/test/test_bug393970.xul
*** 36038 ERROR FAIL | Cells (1,3) and (2,3) line up horizontally (with overflow-x: hidden; overflow-y: scroll;) | got 468, expected 471 | /tests/layout/xul/base/test/test_bug393970.xul
*** 36048 ERROR FAIL | Cells (1,2) and (2,2) line up horizontally (with overflow-x: scroll; overflow-y: scroll;) | got 435, expected 438 | /tests/layout/xul/base/test/test_bug393970.xul
*** 36050 ERROR FAIL | Cells (1,3) and (2,3) line up horizontally (with overflow-x: scroll; overflow-y: scroll;) | got 468, expected 471 | /tests/layout/xul/base/test/test_bug393970.xul
Status: RESOLVED → REOPENED
Resolution: FIXED → ---
For some reason, the testcase works correctly on its own, but it doesn't like being loaded into an iframe.
Flags: blocking1.9? → blocking1.9-
Attached patch Patch v4Splinter Review
Removed bitrot and changed width of the <grid> element in testcase to be 1000px - columns will be shifted if there is not enough space to display them properly, but that's a different issue (and maybe not even an issue).

Requesting approval for 1.9 - TomTom HOME 2.2 was released with that change several months ago, a central UI element uses a grid with fixed header and scrollable body, no issues reported.
Attachment #280448 - Attachment is obsolete: true
Attachment #314308 - Flags: superreview+
Attachment #314308 - Flags: review+
Attachment #314308 - Flags: approval1.9?
Attached patch Patch v4 with -wSplinter Review
Attachment #280449 - Attachment is obsolete: true
Attachment #314309 - Attachment description: Patch v3 with -2 → Patch v3 with -w
Attachment #314309 - Attachment description: Patch v3 with -w → Patch v4 with -w
Seems to me there's a decent chance this could regress something since we're updating a bitrotted patch, what's the risk here?  I'm hesitant to take this at this point without serious justification. 
The bitrot was in the whitespace changes only. And this regression does make the <grid> element much less useful than it should be.

This patch only affects the size calculation for grids with scrollable parts - and that is already broken on trunk. I don't see how we can do worse than we are doing now.
Comment on attachment 314308 [details] [diff] [review]
Patch v4

a1.9=beltzner
Attachment #314308 - Flags: approval1.9? → approval1.9+
Keywords: checkin-needed
mozilla/layout/xul/base/test/Makefile.in 	1.3
mozilla/layout/xul/base/test/test_bug393970.xul 	1.3
mozilla/layout/xul/base/Makefile.in 	1.8
mozilla/layout/xul/base/src/grid/nsGridRowLeafLayout.cpp 	1.25
Status: REOPENED → RESOLVED
Closed: 17 years ago16 years ago
Keywords: checkin-needed
OS: Windows XP → All
Hardware: PC → All
Resolution: --- → FIXED
Target Milestone: mozilla1.9beta1 → mozilla1.9
The test is failing on the linux tinderbox. I disabled it temporarily and filed bug 428226.
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: