diff --git a/layout/generic/nsBlockFrame.cpp b/layout/generic/nsBlockFrame.cpp index 63f0c66833d..e9908c1a64c 100644 --- a/layout/generic/nsBlockFrame.cpp +++ b/layout/generic/nsBlockFrame.cpp @@ -49,7 +49,6 @@ #include "nsLineLayout.h" #include "nsPlaceholderFrame.h" #include "nsStyleConsts.h" -#include "nsCSSRendering.h" #include "nsIFrameManager.h" #include "nsIPresContext.h" #include "nsIPresShell.h" @@ -5652,7 +5651,7 @@ nsBlockFrame::Paint(nsIPresContext* aPresContext, #endif if (NS_FRAME_PAINT_LAYER_BACKGROUND == aWhichLayer) { - PaintSelf(aPresContext, aRenderingContext, aDirtyRect, aFlags); + PaintSelf(aPresContext, aRenderingContext, aDirtyRect); } PRBool paintingSuppressed = PR_FALSE; diff --git a/layout/generic/nsFrame.cpp b/layout/generic/nsFrame.cpp index 0ff4b8ff70d..234c7e5ac40 100644 --- a/layout/generic/nsFrame.cpp +++ b/layout/generic/nsFrame.cpp @@ -58,6 +58,7 @@ #include #include "nsISizeOfHandler.h" #include "nsIFrameManager.h" +#include "nsCSSRendering.h" #ifdef ACCESSIBILITY #include "nsIAccessibilityService.h" #include "nsIAccessible.h" @@ -945,6 +946,44 @@ nsFrame::Paint(nsIPresContext* aPresContext, return NS_OK; } +void +nsFrame::PaintSelf(nsIPresContext* aPresContext, + nsIRenderingContext& aRenderingContext, + const nsRect& aDirtyRect, + PRIntn aSkipSides) +{ + // The visibility check belongs here since child elements have the + // opportunity to override the visibility property and display even if + // their parent is hidden. + + PRBool isVisible; + if (mRect.height == 0 || mRect.width == 0 || + NS_FAILED(IsVisibleForPainting(aPresContext, aRenderingContext, + PR_TRUE, &isVisible)) || + !isVisible) { + return; + } + + // Paint our background and border + const nsStyleBorder* border; + ::GetStyleData(mStyleContext, &border); + const nsStylePadding* padding; + ::GetStyleData(mStyleContext, &padding); + const nsStyleOutline* outline; + ::GetStyleData(mStyleContext, &outline); + + nsRect rect(0, 0, mRect.width, mRect.height); + nsCSSRendering::PaintBackground(aPresContext, aRenderingContext, this, + aDirtyRect, rect, *border, *padding, + 0, 0); + nsCSSRendering::PaintBorder(aPresContext, aRenderingContext, this, + aDirtyRect, rect, *border, mStyleContext, + aSkipSides); + nsCSSRendering::PaintOutline(aPresContext, aRenderingContext, this, + aDirtyRect, rect, *border, *outline, + mStyleContext, 0); +} + /** * */ diff --git a/layout/generic/nsFrame.h b/layout/generic/nsFrame.h index 2a35962f237..5358986e7d1 100644 --- a/layout/generic/nsFrame.h +++ b/layout/generic/nsFrame.h @@ -469,6 +469,16 @@ protected: nsFrame(); virtual ~nsFrame(); + /** + * To be called by |Paint| of this class or derived classes to paint + * the background, border, and outline, when in the correct layer to + * do so. + */ + void PaintSelf(nsIPresContext* aPresContext, + nsIRenderingContext& aRenderingContext, + const nsRect& aDirtyRect, + PRIntn aSkipSides = 0); + PRInt16 DisplaySelection(nsIPresContext* aPresContext, PRBool isOkToTurnOn = PR_FALSE); //this will modify aPos and return the next frame ect. diff --git a/layout/generic/nsGfxScrollFrame.cpp b/layout/generic/nsGfxScrollFrame.cpp index 2338c4a92f1..6bc49f41cfd 100644 --- a/layout/generic/nsGfxScrollFrame.cpp +++ b/layout/generic/nsGfxScrollFrame.cpp @@ -45,7 +45,6 @@ #include "nsIView.h" #include "nsIViewManager.h" #include "nsHTMLContainerFrame.h" -#include "nsCSSRendering.h" #include "nsIScrollableView.h" #include "nsWidgetsCID.h" #include "nsGfxScrollFrame.h" diff --git a/layout/generic/nsHTMLContainerFrame.cpp b/layout/generic/nsHTMLContainerFrame.cpp index ae8d4185e2c..cd241634644 100644 --- a/layout/generic/nsHTMLContainerFrame.cpp +++ b/layout/generic/nsHTMLContainerFrame.cpp @@ -40,7 +40,6 @@ #include "nsIPresShell.h" #include "nsIStyleContext.h" #include "nsStyleConsts.h" -#include "nsCSSRendering.h" #include "nsIContent.h" #include "nsLayoutAtoms.h" #include "nsCSSAnonBoxes.h" @@ -82,52 +81,13 @@ nsHTMLContainerFrame::Paint(nsIPresContext* aPresContext, // others in the background (bug 36710). (nsInlineFrame::Paint does // this differently.) if (NS_FRAME_PAINT_LAYER_BACKGROUND == aWhichLayer) { - PaintSelf(aPresContext, aRenderingContext, aDirtyRect, aFlags); + PaintSelf(aPresContext, aRenderingContext, aDirtyRect); } PaintChildren(aPresContext, aRenderingContext, aDirtyRect, aWhichLayer, aFlags); return NS_OK; } -void -nsHTMLContainerFrame::PaintSelf(nsIPresContext* aPresContext, - nsIRenderingContext& aRenderingContext, - const nsRect& aDirtyRect, - PRUint32 aFlags) -{ - // The visibility check belongs here since child elements have the - // opportunity to override the visibility property and display even if - // their parent is hidden. - - PRBool isVisible; - if (NS_FAILED(IsVisibleForPainting(aPresContext, aRenderingContext, - PR_TRUE, &isVisible)) || - !isVisible || - mRect.width == 0 || mRect.height == 0) { - return; - } - - // Paint our background and border - PRIntn skipSides = GetSkipSides(); - const nsStyleBorder* border; - ::GetStyleData(mStyleContext, &border); - const nsStylePadding* padding; - ::GetStyleData(mStyleContext, &padding); - const nsStyleOutline* outline; - ::GetStyleData(mStyleContext, &outline); - - nsRect rect(0, 0, mRect.width, mRect.height); - nsCSSRendering::PaintBackground(aPresContext, aRenderingContext, this, - aDirtyRect, rect, *border, *padding, - 0, 0); - nsCSSRendering::PaintBorder(aPresContext, aRenderingContext, this, - aDirtyRect, rect, *border, mStyleContext, - skipSides); - nsCSSRendering::PaintOutline(aPresContext, aRenderingContext, this, - aDirtyRect, rect, *border, *outline, - mStyleContext, 0); -} - void nsHTMLContainerFrame::PaintDecorationsAndChildren( nsIPresContext* aPresContext, diff --git a/layout/generic/nsHTMLContainerFrame.h b/layout/generic/nsHTMLContainerFrame.h index 88111686c1f..9286da05dc0 100644 --- a/layout/generic/nsHTMLContainerFrame.h +++ b/layout/generic/nsHTMLContainerFrame.h @@ -123,15 +123,12 @@ public: protected: virtual PRIntn GetSkipSides() const = 0; - /** - * To be called by |Paint| of this class or derived classes to paint - * the background, border, and outline, when in the correct layer to - * do so. - */ void PaintSelf(nsIPresContext* aPresContext, nsIRenderingContext& aRenderingContext, - const nsRect& aDirtyRect, - PRUint32 aFlags); + const nsRect& aDirtyRect) { + nsContainerFrame::PaintSelf(aPresContext, aRenderingContext, + aDirtyRect, GetSkipSides()); + } /** * To be called *instead* of |PaintChildren| by frames that paint text diff --git a/layout/generic/nsHTMLFrame.cpp b/layout/generic/nsHTMLFrame.cpp index 1e7274f8480..2afb85cbfe0 100644 --- a/layout/generic/nsHTMLFrame.cpp +++ b/layout/generic/nsHTMLFrame.cpp @@ -399,7 +399,7 @@ CanvasFrame::Paint(nsIPresContext* aPresContext, shell->IsPaintingSuppressed(&paintingSuppressed); if (paintingSuppressed) { if (NS_FRAME_PAINT_LAYER_BACKGROUND == aWhichLayer) { - PaintSelf(aPresContext, aRenderingContext, aDirtyRect, aFlags); + PaintSelf(aPresContext, aRenderingContext, aDirtyRect); } return NS_OK; } diff --git a/layout/generic/nsImageFrame.cpp b/layout/generic/nsImageFrame.cpp index 139bf44dfff..e53f3fee979 100644 --- a/layout/generic/nsImageFrame.cpp +++ b/layout/generic/nsImageFrame.cpp @@ -1302,21 +1302,7 @@ nsImageFrame::Paint(nsIPresContext* aPresContext, ? NS_FRAME_PAINT_LAYER_BACKGROUND : NS_FRAME_PAINT_LAYER_FOREGROUND; if (aWhichLayer == backgroundLayer) { - const nsStyleVisibility* vis = - (const nsStyleVisibility*)mStyleContext->GetStyleData(eStyleStruct_Visibility); - if (vis->IsVisibleOrCollapsed()) { - const nsStyleBorder* myBorder = (const nsStyleBorder*) - mStyleContext->GetStyleData(eStyleStruct_Border); - const nsStylePadding* myPadding = (const nsStylePadding*) - mStyleContext->GetStyleData(eStyleStruct_Padding); - nsRect rect(0, 0, mRect.width, mRect.height); - nsCSSRendering::PaintBackground(aPresContext, aRenderingContext, this, - aDirtyRect, rect, *myBorder, *myPadding, - 0, 0); - nsCSSRendering::PaintBorder(aPresContext, aRenderingContext, this, - aDirtyRect, rect, *myBorder, - mStyleContext, 0); - } + PaintSelf(aPresContext, aRenderingContext, aDirtyRect); } nsCOMPtr imgCon; diff --git a/layout/generic/nsInlineFrame.cpp b/layout/generic/nsInlineFrame.cpp index bcea211fd32..4ea00c3cc53 100644 --- a/layout/generic/nsInlineFrame.cpp +++ b/layout/generic/nsInlineFrame.cpp @@ -337,7 +337,7 @@ nsInlineFrame::Paint(nsIPresContext* aPresContext, // Paint inline element backgrounds in the foreground layer (bug 36710). if (aWhichLayer == NS_FRAME_PAINT_LAYER_FOREGROUND) { - PaintSelf(aPresContext, aRenderingContext, aDirtyRect, aFlags); + PaintSelf(aPresContext, aRenderingContext, aDirtyRect); } // The sole purpose of this is to trigger display of the selection diff --git a/layout/generic/nsLeafFrame.cpp b/layout/generic/nsLeafFrame.cpp index e06dc7787ee..d8deac410e9 100644 --- a/layout/generic/nsLeafFrame.cpp +++ b/layout/generic/nsLeafFrame.cpp @@ -37,12 +37,10 @@ #include "nsCOMPtr.h" #include "nsLeafFrame.h" #include "nsHTMLContainerFrame.h" -#include "nsCSSRendering.h" #include "nsHTMLParts.h" #include "nsHTMLAtoms.h" #include "nsIPresShell.h" #include "nsIPresContext.h" -#include "nsIStyleContext.h" nsLeafFrame::~nsLeafFrame() { @@ -56,33 +54,7 @@ nsLeafFrame::Paint(nsIPresContext* aPresContext, PRUint32 aFlags) { if (NS_FRAME_PAINT_LAYER_BACKGROUND == aWhichLayer) { - PRBool isVisible; - if (NS_SUCCEEDED(IsVisibleForPainting(aPresContext, aRenderingContext, PR_FALSE, &isVisible)) && - !isVisible) {// just checks selection painting - return NS_OK; // not visibility - } - - const nsStyleVisibility* vis = - (const nsStyleVisibility*)mStyleContext->GetStyleData(eStyleStruct_Visibility); - - if (vis->IsVisibleOrCollapsed()) { - const nsStyleBorder* myBorder = (const nsStyleBorder*) - mStyleContext->GetStyleData(eStyleStruct_Border); - const nsStylePadding* myPadding = (const nsStylePadding*) - mStyleContext->GetStyleData(eStyleStruct_Padding); - const nsStyleOutline* myOutline = (const nsStyleOutline*) - mStyleContext->GetStyleData(eStyleStruct_Outline); - nsRect rect(0, 0, mRect.width, mRect.height); - nsCSSRendering::PaintBackground(aPresContext, aRenderingContext, this, - aDirtyRect, rect, *myBorder, *myPadding, - 0, 0); - nsCSSRendering::PaintBorder(aPresContext, aRenderingContext, this, - aDirtyRect, rect, *myBorder, - mStyleContext, 0); - nsCSSRendering::PaintOutline(aPresContext, aRenderingContext, this, - aDirtyRect, rect, *myBorder, - *myOutline, mStyleContext, 0); - } + PaintSelf(aPresContext, aRenderingContext, aDirtyRect); } DO_GLOBAL_REFLOW_COUNT_DSP("nsLeafFrame", &aRenderingContext); return NS_OK; diff --git a/layout/html/base/src/nsBlockFrame.cpp b/layout/html/base/src/nsBlockFrame.cpp index 63f0c66833d..e9908c1a64c 100644 --- a/layout/html/base/src/nsBlockFrame.cpp +++ b/layout/html/base/src/nsBlockFrame.cpp @@ -49,7 +49,6 @@ #include "nsLineLayout.h" #include "nsPlaceholderFrame.h" #include "nsStyleConsts.h" -#include "nsCSSRendering.h" #include "nsIFrameManager.h" #include "nsIPresContext.h" #include "nsIPresShell.h" @@ -5652,7 +5651,7 @@ nsBlockFrame::Paint(nsIPresContext* aPresContext, #endif if (NS_FRAME_PAINT_LAYER_BACKGROUND == aWhichLayer) { - PaintSelf(aPresContext, aRenderingContext, aDirtyRect, aFlags); + PaintSelf(aPresContext, aRenderingContext, aDirtyRect); } PRBool paintingSuppressed = PR_FALSE; diff --git a/layout/html/base/src/nsFrame.cpp b/layout/html/base/src/nsFrame.cpp index 0ff4b8ff70d..234c7e5ac40 100644 --- a/layout/html/base/src/nsFrame.cpp +++ b/layout/html/base/src/nsFrame.cpp @@ -58,6 +58,7 @@ #include #include "nsISizeOfHandler.h" #include "nsIFrameManager.h" +#include "nsCSSRendering.h" #ifdef ACCESSIBILITY #include "nsIAccessibilityService.h" #include "nsIAccessible.h" @@ -945,6 +946,44 @@ nsFrame::Paint(nsIPresContext* aPresContext, return NS_OK; } +void +nsFrame::PaintSelf(nsIPresContext* aPresContext, + nsIRenderingContext& aRenderingContext, + const nsRect& aDirtyRect, + PRIntn aSkipSides) +{ + // The visibility check belongs here since child elements have the + // opportunity to override the visibility property and display even if + // their parent is hidden. + + PRBool isVisible; + if (mRect.height == 0 || mRect.width == 0 || + NS_FAILED(IsVisibleForPainting(aPresContext, aRenderingContext, + PR_TRUE, &isVisible)) || + !isVisible) { + return; + } + + // Paint our background and border + const nsStyleBorder* border; + ::GetStyleData(mStyleContext, &border); + const nsStylePadding* padding; + ::GetStyleData(mStyleContext, &padding); + const nsStyleOutline* outline; + ::GetStyleData(mStyleContext, &outline); + + nsRect rect(0, 0, mRect.width, mRect.height); + nsCSSRendering::PaintBackground(aPresContext, aRenderingContext, this, + aDirtyRect, rect, *border, *padding, + 0, 0); + nsCSSRendering::PaintBorder(aPresContext, aRenderingContext, this, + aDirtyRect, rect, *border, mStyleContext, + aSkipSides); + nsCSSRendering::PaintOutline(aPresContext, aRenderingContext, this, + aDirtyRect, rect, *border, *outline, + mStyleContext, 0); +} + /** * */ diff --git a/layout/html/base/src/nsFrame.h b/layout/html/base/src/nsFrame.h index 2a35962f237..5358986e7d1 100644 --- a/layout/html/base/src/nsFrame.h +++ b/layout/html/base/src/nsFrame.h @@ -469,6 +469,16 @@ protected: nsFrame(); virtual ~nsFrame(); + /** + * To be called by |Paint| of this class or derived classes to paint + * the background, border, and outline, when in the correct layer to + * do so. + */ + void PaintSelf(nsIPresContext* aPresContext, + nsIRenderingContext& aRenderingContext, + const nsRect& aDirtyRect, + PRIntn aSkipSides = 0); + PRInt16 DisplaySelection(nsIPresContext* aPresContext, PRBool isOkToTurnOn = PR_FALSE); //this will modify aPos and return the next frame ect. diff --git a/layout/html/base/src/nsGfxScrollFrame.cpp b/layout/html/base/src/nsGfxScrollFrame.cpp index 2338c4a92f1..6bc49f41cfd 100644 --- a/layout/html/base/src/nsGfxScrollFrame.cpp +++ b/layout/html/base/src/nsGfxScrollFrame.cpp @@ -45,7 +45,6 @@ #include "nsIView.h" #include "nsIViewManager.h" #include "nsHTMLContainerFrame.h" -#include "nsCSSRendering.h" #include "nsIScrollableView.h" #include "nsWidgetsCID.h" #include "nsGfxScrollFrame.h" diff --git a/layout/html/base/src/nsHTMLContainerFrame.cpp b/layout/html/base/src/nsHTMLContainerFrame.cpp index ae8d4185e2c..cd241634644 100644 --- a/layout/html/base/src/nsHTMLContainerFrame.cpp +++ b/layout/html/base/src/nsHTMLContainerFrame.cpp @@ -40,7 +40,6 @@ #include "nsIPresShell.h" #include "nsIStyleContext.h" #include "nsStyleConsts.h" -#include "nsCSSRendering.h" #include "nsIContent.h" #include "nsLayoutAtoms.h" #include "nsCSSAnonBoxes.h" @@ -82,52 +81,13 @@ nsHTMLContainerFrame::Paint(nsIPresContext* aPresContext, // others in the background (bug 36710). (nsInlineFrame::Paint does // this differently.) if (NS_FRAME_PAINT_LAYER_BACKGROUND == aWhichLayer) { - PaintSelf(aPresContext, aRenderingContext, aDirtyRect, aFlags); + PaintSelf(aPresContext, aRenderingContext, aDirtyRect); } PaintChildren(aPresContext, aRenderingContext, aDirtyRect, aWhichLayer, aFlags); return NS_OK; } -void -nsHTMLContainerFrame::PaintSelf(nsIPresContext* aPresContext, - nsIRenderingContext& aRenderingContext, - const nsRect& aDirtyRect, - PRUint32 aFlags) -{ - // The visibility check belongs here since child elements have the - // opportunity to override the visibility property and display even if - // their parent is hidden. - - PRBool isVisible; - if (NS_FAILED(IsVisibleForPainting(aPresContext, aRenderingContext, - PR_TRUE, &isVisible)) || - !isVisible || - mRect.width == 0 || mRect.height == 0) { - return; - } - - // Paint our background and border - PRIntn skipSides = GetSkipSides(); - const nsStyleBorder* border; - ::GetStyleData(mStyleContext, &border); - const nsStylePadding* padding; - ::GetStyleData(mStyleContext, &padding); - const nsStyleOutline* outline; - ::GetStyleData(mStyleContext, &outline); - - nsRect rect(0, 0, mRect.width, mRect.height); - nsCSSRendering::PaintBackground(aPresContext, aRenderingContext, this, - aDirtyRect, rect, *border, *padding, - 0, 0); - nsCSSRendering::PaintBorder(aPresContext, aRenderingContext, this, - aDirtyRect, rect, *border, mStyleContext, - skipSides); - nsCSSRendering::PaintOutline(aPresContext, aRenderingContext, this, - aDirtyRect, rect, *border, *outline, - mStyleContext, 0); -} - void nsHTMLContainerFrame::PaintDecorationsAndChildren( nsIPresContext* aPresContext, diff --git a/layout/html/base/src/nsHTMLContainerFrame.h b/layout/html/base/src/nsHTMLContainerFrame.h index 88111686c1f..9286da05dc0 100644 --- a/layout/html/base/src/nsHTMLContainerFrame.h +++ b/layout/html/base/src/nsHTMLContainerFrame.h @@ -123,15 +123,12 @@ public: protected: virtual PRIntn GetSkipSides() const = 0; - /** - * To be called by |Paint| of this class or derived classes to paint - * the background, border, and outline, when in the correct layer to - * do so. - */ void PaintSelf(nsIPresContext* aPresContext, nsIRenderingContext& aRenderingContext, - const nsRect& aDirtyRect, - PRUint32 aFlags); + const nsRect& aDirtyRect) { + nsContainerFrame::PaintSelf(aPresContext, aRenderingContext, + aDirtyRect, GetSkipSides()); + } /** * To be called *instead* of |PaintChildren| by frames that paint text diff --git a/layout/html/base/src/nsHTMLFrame.cpp b/layout/html/base/src/nsHTMLFrame.cpp index 1e7274f8480..2afb85cbfe0 100644 --- a/layout/html/base/src/nsHTMLFrame.cpp +++ b/layout/html/base/src/nsHTMLFrame.cpp @@ -399,7 +399,7 @@ CanvasFrame::Paint(nsIPresContext* aPresContext, shell->IsPaintingSuppressed(&paintingSuppressed); if (paintingSuppressed) { if (NS_FRAME_PAINT_LAYER_BACKGROUND == aWhichLayer) { - PaintSelf(aPresContext, aRenderingContext, aDirtyRect, aFlags); + PaintSelf(aPresContext, aRenderingContext, aDirtyRect); } return NS_OK; } diff --git a/layout/html/base/src/nsImageFrame.cpp b/layout/html/base/src/nsImageFrame.cpp index 139bf44dfff..e53f3fee979 100644 --- a/layout/html/base/src/nsImageFrame.cpp +++ b/layout/html/base/src/nsImageFrame.cpp @@ -1302,21 +1302,7 @@ nsImageFrame::Paint(nsIPresContext* aPresContext, ? NS_FRAME_PAINT_LAYER_BACKGROUND : NS_FRAME_PAINT_LAYER_FOREGROUND; if (aWhichLayer == backgroundLayer) { - const nsStyleVisibility* vis = - (const nsStyleVisibility*)mStyleContext->GetStyleData(eStyleStruct_Visibility); - if (vis->IsVisibleOrCollapsed()) { - const nsStyleBorder* myBorder = (const nsStyleBorder*) - mStyleContext->GetStyleData(eStyleStruct_Border); - const nsStylePadding* myPadding = (const nsStylePadding*) - mStyleContext->GetStyleData(eStyleStruct_Padding); - nsRect rect(0, 0, mRect.width, mRect.height); - nsCSSRendering::PaintBackground(aPresContext, aRenderingContext, this, - aDirtyRect, rect, *myBorder, *myPadding, - 0, 0); - nsCSSRendering::PaintBorder(aPresContext, aRenderingContext, this, - aDirtyRect, rect, *myBorder, - mStyleContext, 0); - } + PaintSelf(aPresContext, aRenderingContext, aDirtyRect); } nsCOMPtr imgCon; diff --git a/layout/html/base/src/nsInlineFrame.cpp b/layout/html/base/src/nsInlineFrame.cpp index bcea211fd32..4ea00c3cc53 100644 --- a/layout/html/base/src/nsInlineFrame.cpp +++ b/layout/html/base/src/nsInlineFrame.cpp @@ -337,7 +337,7 @@ nsInlineFrame::Paint(nsIPresContext* aPresContext, // Paint inline element backgrounds in the foreground layer (bug 36710). if (aWhichLayer == NS_FRAME_PAINT_LAYER_FOREGROUND) { - PaintSelf(aPresContext, aRenderingContext, aDirtyRect, aFlags); + PaintSelf(aPresContext, aRenderingContext, aDirtyRect); } // The sole purpose of this is to trigger display of the selection diff --git a/layout/html/base/src/nsLeafFrame.cpp b/layout/html/base/src/nsLeafFrame.cpp index e06dc7787ee..d8deac410e9 100644 --- a/layout/html/base/src/nsLeafFrame.cpp +++ b/layout/html/base/src/nsLeafFrame.cpp @@ -37,12 +37,10 @@ #include "nsCOMPtr.h" #include "nsLeafFrame.h" #include "nsHTMLContainerFrame.h" -#include "nsCSSRendering.h" #include "nsHTMLParts.h" #include "nsHTMLAtoms.h" #include "nsIPresShell.h" #include "nsIPresContext.h" -#include "nsIStyleContext.h" nsLeafFrame::~nsLeafFrame() { @@ -56,33 +54,7 @@ nsLeafFrame::Paint(nsIPresContext* aPresContext, PRUint32 aFlags) { if (NS_FRAME_PAINT_LAYER_BACKGROUND == aWhichLayer) { - PRBool isVisible; - if (NS_SUCCEEDED(IsVisibleForPainting(aPresContext, aRenderingContext, PR_FALSE, &isVisible)) && - !isVisible) {// just checks selection painting - return NS_OK; // not visibility - } - - const nsStyleVisibility* vis = - (const nsStyleVisibility*)mStyleContext->GetStyleData(eStyleStruct_Visibility); - - if (vis->IsVisibleOrCollapsed()) { - const nsStyleBorder* myBorder = (const nsStyleBorder*) - mStyleContext->GetStyleData(eStyleStruct_Border); - const nsStylePadding* myPadding = (const nsStylePadding*) - mStyleContext->GetStyleData(eStyleStruct_Padding); - const nsStyleOutline* myOutline = (const nsStyleOutline*) - mStyleContext->GetStyleData(eStyleStruct_Outline); - nsRect rect(0, 0, mRect.width, mRect.height); - nsCSSRendering::PaintBackground(aPresContext, aRenderingContext, this, - aDirtyRect, rect, *myBorder, *myPadding, - 0, 0); - nsCSSRendering::PaintBorder(aPresContext, aRenderingContext, this, - aDirtyRect, rect, *myBorder, - mStyleContext, 0); - nsCSSRendering::PaintOutline(aPresContext, aRenderingContext, this, - aDirtyRect, rect, *myBorder, - *myOutline, mStyleContext, 0); - } + PaintSelf(aPresContext, aRenderingContext, aDirtyRect); } DO_GLOBAL_REFLOW_COUNT_DSP("nsLeafFrame", &aRenderingContext); return NS_OK; diff --git a/layout/mathml/base/src/nsMathMLmactionFrame.cpp b/layout/mathml/base/src/nsMathMLmactionFrame.cpp index c1963180f36..55fb9cbb3bb 100644 --- a/layout/mathml/base/src/nsMathMLmactionFrame.cpp +++ b/layout/mathml/base/src/nsMathMLmactionFrame.cpp @@ -261,27 +261,8 @@ nsMathMLmactionFrame::Paint(nsIPresContext* aPresContext, nsFramePaintLayer aWhichLayer, PRUint32 aFlags) { - const nsStyleVisibility* visib = NS_STATIC_CAST(const nsStyleVisibility*, - mStyleContext->GetStyleData(eStyleStruct_Visibility)); if (NS_FRAME_PAINT_LAYER_BACKGROUND == aWhichLayer) { - if (visib->IsVisible() && mRect.width && mRect.height) { - // Paint our background and border - PRIntn skipSides = GetSkipSides(); - const nsStyleBorder* border = (const nsStyleBorder*) - mStyleContext->GetStyleData(eStyleStruct_Border); - const nsStylePadding* padding = (const nsStylePadding*) - mStyleContext->GetStyleData(eStyleStruct_Padding); - const nsStyleOutline* outline = (const nsStyleOutline*) - mStyleContext->GetStyleData(eStyleStruct_Outline); - - nsRect rect(0, 0, mRect.width, mRect.height); - nsCSSRendering::PaintBackground(aPresContext, aRenderingContext, this, - aDirtyRect, rect, *border, *padding, 0, 0); - nsCSSRendering::PaintBorder(aPresContext, aRenderingContext, this, - aDirtyRect, rect, *border, mStyleContext, skipSides); - nsCSSRendering::PaintOutline(aPresContext, aRenderingContext, this, - aDirtyRect, rect, *border, *outline, mStyleContext, 0); - } + PaintSelf(aPresContext, aRenderingContext, aDirtyRect); } nsIFrame* childFrame = GetSelectedFrame(); diff --git a/layout/xul/base/src/nsBoxFrame.cpp b/layout/xul/base/src/nsBoxFrame.cpp index 19ba7438062..4936b0e330c 100644 --- a/layout/xul/base/src/nsBoxFrame.cpp +++ b/layout/xul/base/src/nsBoxFrame.cpp @@ -1465,43 +1465,13 @@ nsBoxFrame::Paint(nsIPresContext* aPresContext, return NS_OK; } - nsCOMPtr frameType; - GetFrameType(getter_AddRefs(frameType)); - if (NS_FRAME_PAINT_LAYER_BACKGROUND == aWhichLayer) { - if (vis->IsVisible() && mRect.width && mRect.height) { - // Paint our background and border - PRIntn skipSides = GetSkipSides(); - const nsStyleBorder* border = (const nsStyleBorder*) - mStyleContext->GetStyleData(eStyleStruct_Border); - const nsStylePadding* padding = (const nsStylePadding*) - mStyleContext->GetStyleData(eStyleStruct_Padding); - const nsStyleOutline* outline = (const nsStyleOutline*) - mStyleContext->GetStyleData(eStyleStruct_Outline); - - nsRect rect(0, 0, mRect.width, mRect.height); - nsCSSRendering::PaintBackground(aPresContext, aRenderingContext, this, - aDirtyRect, rect, *border, *padding, - 0, 0); - nsCSSRendering::PaintBorder(aPresContext, aRenderingContext, this, - aDirtyRect, rect, *border, mStyleContext, skipSides); - nsCSSRendering::PaintOutline(aPresContext, aRenderingContext, this, - aDirtyRect, rect, *border, *outline, mStyleContext, 0); - - // The sole purpose of this is to trigger display - // of the selection window for Named Anchors, - // which don't have any children and normally don't - // have any size, but in Editor we use CSS to display - // an image to represent this "hidden" element. - if (!mFrames.FirstChild()) - { - nsFrame::Paint(aPresContext, - aRenderingContext, aDirtyRect, aWhichLayer); - } - } + PaintSelf(aPresContext, aRenderingContext, aDirtyRect); } - if (frameType.get() == nsLayoutAtoms::rootFrame) { + nsCOMPtr frameType; + GetFrameType(getter_AddRefs(frameType)); + if (frameType == nsLayoutAtoms::rootFrame) { // We are wrapping the root frame of a XUL document. We // need to check the pres shell to find out if painting is locked // down (because we're still in the early stages of document diff --git a/layout/xul/base/src/nsBoxFrame.h b/layout/xul/base/src/nsBoxFrame.h index faa8b2d5e24..71cd172c5b9 100644 --- a/layout/xul/base/src/nsBoxFrame.h +++ b/layout/xul/base/src/nsBoxFrame.h @@ -232,9 +232,6 @@ protected: nsFramePaintLayer aWhichLayer, PRUint32 aFlags = 0); - virtual PRIntn GetSkipSides() const { return 0; } - - virtual PRBool GetInitialEqualSize(PRBool& aEqualSize); virtual void GetInitialOrientation(PRBool& aIsHorizontal); virtual void GetInitialDirection(PRBool& aIsNormal); diff --git a/layout/xul/base/src/nsDeckFrame.cpp b/layout/xul/base/src/nsDeckFrame.cpp index d503cc4c4ff..03f745c96f8 100644 --- a/layout/xul/base/src/nsDeckFrame.cpp +++ b/layout/xul/base/src/nsDeckFrame.cpp @@ -322,21 +322,7 @@ nsDeckFrame::Paint(nsIPresContext* aPresContext, return NS_OK; if (NS_FRAME_PAINT_LAYER_BACKGROUND == aWhichLayer) { - if (vis->IsVisible() && mRect.width && mRect.height) { - // Paint our background and border - PRIntn skipSides = GetSkipSides(); - const nsStyleBorder* border = (const nsStyleBorder*) - mStyleContext->GetStyleData(eStyleStruct_Border); - const nsStylePadding* padding = (const nsStylePadding*) - mStyleContext->GetStyleData(eStyleStruct_Padding); - - nsRect rect(0, 0, mRect.width, mRect.height); - nsCSSRendering::PaintBackground(aPresContext, aRenderingContext, this, - aDirtyRect, rect, *border, *padding, - 0, 0); - nsCSSRendering::PaintBorder(aPresContext, aRenderingContext, this, - aDirtyRect, rect, *border, mStyleContext, skipSides); - } + PaintSelf(aPresContext, aRenderingContext, aDirtyRect); } // only paint the seleced box diff --git a/layout/xul/base/src/nsGroupBoxFrame.cpp b/layout/xul/base/src/nsGroupBoxFrame.cpp index 66ee4e619b3..226c00871db 100644 --- a/layout/xul/base/src/nsGroupBoxFrame.cpp +++ b/layout/xul/base/src/nsGroupBoxFrame.cpp @@ -126,7 +126,7 @@ nsGroupBoxFrame::Paint(nsIPresContext* aPresContext, (const nsStyleVisibility*)mStyleContext->GetStyleData(eStyleStruct_Visibility); if (vis->IsVisible() && mRect.width && mRect.height) { - PRIntn skipSides = GetSkipSides(); + PRIntn skipSides = 0; const nsStyleBorder* borderStyleData = (const nsStyleBorder*)mStyleContext->GetStyleData(eStyleStruct_Border); const nsStylePadding* paddingStyleData = diff --git a/layout/xul/base/src/nsScrollBoxFrame.cpp b/layout/xul/base/src/nsScrollBoxFrame.cpp index 5e5f0f76141..8751c4dfc92 100644 --- a/layout/xul/base/src/nsScrollBoxFrame.cpp +++ b/layout/xul/base/src/nsScrollBoxFrame.cpp @@ -634,12 +634,6 @@ nsScrollBoxFrame::Paint(nsIPresContext* aPresContext, return nsFrame::Paint(aPresContext, aRenderingContext, aDirtyRect, aWhichLayer); } -PRIntn -nsScrollBoxFrame::GetSkipSides() const -{ - return 0; -} - nsresult nsScrollBoxFrame::GetContentOf(nsIContent** aContent) { diff --git a/layout/xul/base/src/nsScrollBoxFrame.h b/layout/xul/base/src/nsScrollBoxFrame.h index 33df198cae8..15022537996 100644 --- a/layout/xul/base/src/nsScrollBoxFrame.h +++ b/layout/xul/base/src/nsScrollBoxFrame.h @@ -120,7 +120,6 @@ public: protected: nsScrollBoxFrame(nsIPresShell* aShell); - virtual PRIntn GetSkipSides() const; // Creation of the widget for the scrolling view is factored into a virtual method so // that sub-classes may control widget creation. diff --git a/layout/xul/base/src/nsSliderFrame.cpp b/layout/xul/base/src/nsSliderFrame.cpp index 6fdc5009f5a..319981b97c1 100644 --- a/layout/xul/base/src/nsSliderFrame.cpp +++ b/layout/xul/base/src/nsSliderFrame.cpp @@ -308,20 +308,7 @@ nsSliderFrame::Paint(nsIPresContext* aPresContext, if (crect.width < thumbRect.width || crect.height < thumbRect.height) { if (NS_FRAME_PAINT_LAYER_BACKGROUND == aWhichLayer) { - const nsStyleVisibility* vis = (const nsStyleVisibility*) - mStyleContext->GetStyleData(eStyleStruct_Visibility); - if (vis->IsVisibleOrCollapsed()) { - const nsStyleBorder* myBorder = (const nsStyleBorder*) - mStyleContext->GetStyleData(eStyleStruct_Border); - const nsStylePadding* myPadding = (const nsStylePadding*) - mStyleContext->GetStyleData(eStyleStruct_Padding); - nsRect rect(0, 0, mRect.width, mRect.height); - nsCSSRendering::PaintBackground(aPresContext, aRenderingContext, this, - aDirtyRect, rect, *myBorder, *myPadding, - 0, 0); - nsCSSRendering::PaintBorder(aPresContext, aRenderingContext, this, - aDirtyRect, rect, *myBorder, mStyleContext, 0); - } + PaintSelf(aPresContext, aRenderingContext, aDirtyRect); } return NS_OK; } diff --git a/layout/xul/base/src/nsSliderFrame.h b/layout/xul/base/src/nsSliderFrame.h index d0442974497..a8593d1b40a 100644 --- a/layout/xul/base/src/nsSliderFrame.h +++ b/layout/xul/base/src/nsSliderFrame.h @@ -228,10 +228,6 @@ public: NS_IMETHOD_(void) Notify(nsITimer *timer); //friend nsSliderMediator; -protected: - - virtual PRIntn GetSkipSides() const { return 0; } - private: