From bb83cf55dd66f0c112260a2ab4a7e335f28bfa24 Mon Sep 17 00:00:00 2001 From: Scott Johnson Date: Tue, 20 Aug 2013 16:38:29 -0500 Subject: [PATCH] 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 | 30 ++++++++++++ layout/generic/nsColumnSetFrame.cpp | 4 +- .../columns/columnrule-overflow-ref.html | 49 +++++++++++++++++++ .../reftests/columns/columnrule-overflow.html | 41 ++++++++++++++++ layout/reftests/columns/reftest.list | 1 + 5 files changed, 123 insertions(+), 2 deletions(-) create mode 100644 layout/reftests/columns/columnrule-overflow-ref.html create mode 100644 layout/reftests/columns/columnrule-overflow.html diff --git a/layout/base/nsDisplayList.h b/layout/base/nsDisplayList.h index 428bfceb580..161ad7853d4 100644 --- a/layout/base/nsDisplayList.h +++ b/layout/base/nsDisplayList.h @@ -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 diff --git a/layout/generic/nsColumnSetFrame.cpp b/layout/generic/nsColumnSetFrame.cpp index 44322b3103a..b81213924c1 100644 --- a/layout/generic/nsColumnSetFrame.cpp +++ b/layout/generic/nsColumnSetFrame.cpp @@ -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()) { diff --git a/layout/reftests/columns/columnrule-overflow-ref.html b/layout/reftests/columns/columnrule-overflow-ref.html new file mode 100644 index 00000000000..22bcc41a525 --- /dev/null +++ b/layout/reftests/columns/columnrule-overflow-ref.html @@ -0,0 +1,49 @@ + + + + Bug 746015: Off-screen overflow column rules are not properly drawn. + + + +
+ + diff --git a/layout/reftests/columns/columnrule-overflow.html b/layout/reftests/columns/columnrule-overflow.html new file mode 100644 index 00000000000..df273e14376 --- /dev/null +++ b/layout/reftests/columns/columnrule-overflow.html @@ -0,0 +1,41 @@ + + + + Bug 746015: Off-screen overflow column rules are not properly drawn. + + + +
+ + diff --git a/layout/reftests/columns/reftest.list b/layout/reftests/columns/reftest.list index 442ab3eeec5..add8d8ddb37 100644 --- a/layout/reftests/columns/reftest.list +++ b/layout/reftests/columns/reftest.list @@ -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