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]
authorScott Johnson <sjohnson@mozilla.com>
Tue, 20 Aug 2013 16:38:29 -0500
changeset 156532 5b8cbc29a72ec0551d5144c40a51eba92b6b3a57
parent 156531 36a2061cff797defbd9b03c20d72cd87453674f0
child 156533 22acef5e2878f07af5558f4d718a9f2b436ad288
push id2961
push userlsblakk@mozilla.com
push dateMon, 28 Oct 2013 21:59:28 +0000
treeherdermozilla-beta@73ef4f13486f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdbaron
bugs746015
milestone26.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
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]
layout/base/nsDisplayList.h
layout/generic/nsColumnSetFrame.cpp
layout/reftests/columns/columnrule-overflow-ref.html
layout/reftests/columns/columnrule-overflow.html
layout/reftests/columns/reftest.list
--- a/layout/base/nsDisplayList.h
+++ b/layout/base/nsDisplayList.h
@@ -1733,16 +1733,46 @@ public:
 protected:
   PaintCallback mPaint;
 #ifdef MOZ_DUMP_PAINTING
   const char*   mName;
 #endif
   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
  * make all the frame names be those returned by nsFrame::GetFrameName
  * (except that tosses in the content tag name!)  and support only one color
  * and eliminate this class altogether in favor of nsDisplayGeneric, but for
  * the time being we can't pass args to a PaintCallback, so just have a
  * separate class to do the right thing.  Sadly, this alsmo means we need to
--- a/layout/generic/nsColumnSetFrame.cpp
+++ b/layout/generic/nsColumnSetFrame.cpp
@@ -1033,18 +1033,18 @@ nsColumnSetFrame::Reflow(nsPresContext* 
 
 void
 nsColumnSetFrame::BuildDisplayList(nsDisplayListBuilder*   aBuilder,
                                    const nsRect&           aDirtyRect,
                                    const nsDisplayListSet& aLists) {
   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()) {
     BuildDisplayListForChild(aBuilder, e.get(), aDirtyRect, aLists);
   }
 }
 
 NS_IMETHODIMP
new file mode 100644
--- /dev/null
+++ b/layout/reftests/columns/columnrule-overflow-ref.html
@@ -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>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/columns/columnrule-overflow.html
@@ -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>
--- a/layout/reftests/columns/reftest.list
+++ b/layout/reftests/columns/reftest.list
@@ -25,8 +25,9 @@ skip-if(B2G) == columnrule-basic.html co
 skip-if(B2G) == columnrule-complex.html columnrule-complex-ref.html # bug 773482
 != columnrule-linestyles.html columnrule-linestyles-notref.html
 == columnrule-padding.html columnrule-padding-ref.html
 skip-if(B2G) == columnfill-overflow.html columnfill-overflow-ref.html # bug 773482
 == margin-collapsing-bug616722-1.html margin-collapsing-bug616722-1-ref.html
 == 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