Bug 746015: Add a nsDisplayGenericOverflow class that uses a frame's visual overflow rect as its bounds to correctly display column rules that lie outside of a column set frame's bounds. [r=dbaron]

This commit is contained in:
Scott Johnson 2013-08-20 16:38:29 -05:00
parent f9d9f604eb
commit bb83cf55dd
5 changed files with 123 additions and 2 deletions

View File

@ -1738,6 +1738,36 @@ protected:
Type mType;
};
/**
* Generic display item that can contain overflow. Use this in lieu of
* nsDisplayGeneric if you have a frame that should use the visual overflow
* rect of its frame when drawing items, instead of the frame's bounds.
*/
class nsDisplayGenericOverflow : public nsDisplayGeneric {
public:
nsDisplayGenericOverflow(nsDisplayListBuilder* aBuilder, nsIFrame* aFrame,
PaintCallback aPaint, const char* aName, Type aType)
: nsDisplayGeneric(aBuilder, aFrame, aPaint, aName, aType)
{
MOZ_COUNT_CTOR(nsDisplayGenericOverflow);
}
#ifdef NS_BUILD_REFCNT_LOGGING
virtual ~nsDisplayGenericOverflow() {
MOZ_COUNT_DTOR(nsDisplayGenericOverflow);
}
#endif
/**
* Returns the frame's visual overflow rect instead of the frame's bounds.
*/
virtual nsRect GetBounds(nsDisplayListBuilder* aBuilder,
bool* aSnap) MOZ_OVERRIDE
{
*aSnap = false;
return Frame()->GetVisualOverflowRect() + ToReferenceFrame();
}
};
#if defined(MOZ_REFLOW_PERF_DSP) && defined(MOZ_REFLOW_PERF)
/**
* This class implements painting of reflow counts. Ideally, we would simply

View File

@ -1038,8 +1038,8 @@ nsColumnSetFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder,
DisplayBorderBackgroundOutline(aBuilder, aLists);
aLists.BorderBackground()->AppendNewToTop(new (aBuilder)
nsDisplayGeneric(aBuilder, this, ::PaintColumnRule, "ColumnRule",
nsDisplayItem::TYPE_COLUMN_RULE));
nsDisplayGenericOverflow(aBuilder, this, ::PaintColumnRule, "ColumnRule",
nsDisplayItem::TYPE_COLUMN_RULE));
// Our children won't have backgrounds so it doesn't matter where we put them.
for (nsFrameList::Enumerator e(mFrames); !e.AtEnd(); e.Next()) {

View File

@ -0,0 +1,49 @@
<!DOCTYPE html>
<html>
<head>
<title>Bug 746015: Off-screen overflow column rules are not properly drawn.</title>
<style type="text/css">
* {
margin: 0 0;
padding: 0 0;
}
body,html {
padding: 0 0;
margin: 0 0;
line-height: 1.0;
}
div.column1 {
display: inline-block;
width: 180px;
height: 175px;
vertical-align: top;
white-space: no-wrap;
}
div.content {
width: 180px;
height: 175px;
background: blue;
}
div.column2 {
display: inline-block;
width: 180px;
height: 175px;
vertical-align: top;
}
div.colgap {
display: inline-block;
background-color: green;
width: 10px;
height: 175px;
}
</style>
</head>
<body>
<div class="column1"><div class="content"></div></div><div class="colgap"></div><div class="column2"><div class="content"></div></div>
</body>
</html>

View File

@ -0,0 +1,41 @@
<!DOCTYPE html>
<html>
<head>
<title>Bug 746015: Off-screen overflow column rules are not properly drawn.</title>
<style type="text/css">
* {
margin: 0 0;
padding: 0 0;
}
body,html {
padding: 0 0;
margin: 0 0;
line-height: 1.0;
}
body {
position: absolute;
left: -570px;
}
div.content {
width: 180px;
height: 875px;
background: blue;
}
div.multicolumn {
height: 175px;
overflow: visible;
-moz-column-width: 180px;
-moz-column-gap: 10px;
-moz-column-rule: 10px solid green;
}
</style>
</head>
<body>
<div class="multicolumn"><div class="content"></div></div>
</body>
</html>

View File

@ -30,3 +30,4 @@ skip-if(B2G) == columnfill-overflow.html columnfill-overflow-ref.html # bug 7734
== margin-collapsing-bug616722-2.html margin-collapsing-bug616722-2-ref.html
== column-balancing-nested-000.html column-balancing-nested-000-ref.html
== column-balancing-nested-001.html column-balancing-nested-001-ref.html
== columnrule-overflow.html columnrule-overflow-ref.html