зеркало из https://github.com/mozilla/pjs.git
Make button controls paint on top of inline element backgrounds. b=107244 r=rods sr=waterson a=asa
This commit is contained in:
Родитель
56b957f998
Коммит
eecc1e0196
|
@ -126,23 +126,21 @@ void
|
|||
nsButtonFrameRenderer::PaintButton (nsIPresContext* aPresContext,
|
||||
nsIRenderingContext& aRenderingContext,
|
||||
const nsRect& aDirtyRect,
|
||||
nsFramePaintLayer aWhichLayer,
|
||||
const nsRect& aRect)
|
||||
{
|
||||
//printf("painted width='%d' height='%d'\n",aRect.width, aRect.height);
|
||||
|
||||
// draw the border and background inside the focus and outline borders
|
||||
PaintBorderAndBackground(aPresContext, aRenderingContext, aDirtyRect, aWhichLayer, aRect);
|
||||
PaintBorderAndBackground(aPresContext, aRenderingContext, aDirtyRect, aRect);
|
||||
|
||||
// draw the focus and outline borders
|
||||
PaintOutlineAndFocusBorders(aPresContext, aRenderingContext, aDirtyRect, aWhichLayer, aRect);
|
||||
PaintOutlineAndFocusBorders(aPresContext, aRenderingContext, aDirtyRect, aRect);
|
||||
}
|
||||
|
||||
void
|
||||
nsButtonFrameRenderer::PaintOutlineAndFocusBorders(nsIPresContext* aPresContext,
|
||||
nsIRenderingContext& aRenderingContext,
|
||||
const nsRect& aDirtyRect,
|
||||
nsFramePaintLayer aWhichLayer,
|
||||
const nsRect& aRect)
|
||||
{
|
||||
// once we have all that let draw the focus if we have it. We will need to draw 2 focuses.
|
||||
|
@ -152,31 +150,27 @@ nsButtonFrameRenderer::PaintOutlineAndFocusBorders(nsIPresContext* aPresContext,
|
|||
|
||||
nsRect rect;
|
||||
|
||||
if (NS_FRAME_PAINT_LAYER_BACKGROUND == aWhichLayer)
|
||||
{
|
||||
if (mOuterFocusStyle) {
|
||||
// ---------- paint the outer focus border -------------
|
||||
if (mOuterFocusStyle) {
|
||||
// ---------- paint the outer focus border -------------
|
||||
|
||||
GetButtonOuterFocusRect(aRect, rect);
|
||||
GetButtonOuterFocusRect(aRect, rect);
|
||||
|
||||
const nsStyleBorder* border = (const nsStyleBorder*)mOuterFocusStyle ->GetStyleData(eStyleStruct_Border);
|
||||
|
||||
nsCSSRendering::PaintBorder(aPresContext, aRenderingContext, mFrame,
|
||||
aDirtyRect, rect, *border, mOuterFocusStyle, 0);
|
||||
}
|
||||
|
||||
// ---------- paint the inner focus border -------------
|
||||
if (mInnerFocusStyle) {
|
||||
|
||||
GetButtonInnerFocusRect(aRect, rect);
|
||||
|
||||
const nsStyleBorder* border = (const nsStyleBorder*)mInnerFocusStyle ->GetStyleData(eStyleStruct_Border);
|
||||
|
||||
nsCSSRendering::PaintBorder(aPresContext, aRenderingContext, mFrame,
|
||||
aDirtyRect, rect, *border, mInnerFocusStyle, 0);
|
||||
}
|
||||
const nsStyleBorder* border;
|
||||
::GetStyleData(mOuterFocusStyle, &border);
|
||||
nsCSSRendering::PaintBorder(aPresContext, aRenderingContext, mFrame,
|
||||
aDirtyRect, rect, *border, mOuterFocusStyle, 0);
|
||||
}
|
||||
|
||||
if (mInnerFocusStyle) {
|
||||
// ---------- paint the inner focus border -------------
|
||||
|
||||
GetButtonInnerFocusRect(aRect, rect);
|
||||
|
||||
const nsStyleBorder* border;
|
||||
::GetStyleData(mInnerFocusStyle, &border);
|
||||
nsCSSRendering::PaintBorder(aPresContext, aRenderingContext, mFrame,
|
||||
aDirtyRect, rect, *border, mInnerFocusStyle, 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -184,14 +178,9 @@ void
|
|||
nsButtonFrameRenderer::PaintBorderAndBackground(nsIPresContext* aPresContext,
|
||||
nsIRenderingContext& aRenderingContext,
|
||||
const nsRect& aDirtyRect,
|
||||
nsFramePaintLayer aWhichLayer,
|
||||
const nsRect& aRect)
|
||||
|
||||
{
|
||||
|
||||
if (NS_FRAME_PAINT_LAYER_BACKGROUND != aWhichLayer)
|
||||
return;
|
||||
|
||||
// get the button rect this is inside the focus and outline rects
|
||||
nsRect buttonRect;
|
||||
GetButtonRect(aRect, buttonRect);
|
||||
|
|
|
@ -61,22 +61,21 @@ public:
|
|||
virtual ~nsButtonFrameRenderer();
|
||||
|
||||
|
||||
// These three functions all assume a "background" layer within the
|
||||
// button, which is itself in the foreground layer.
|
||||
virtual void PaintButton(nsIPresContext* aPresContext,
|
||||
nsIRenderingContext& aRenderingContext,
|
||||
const nsRect& aDirtyRect,
|
||||
nsFramePaintLayer aWhichLayer,
|
||||
const nsRect& aRect);
|
||||
|
||||
virtual void PaintOutlineAndFocusBorders(nsIPresContext* aPresContext,
|
||||
nsIRenderingContext& aRenderingContext,
|
||||
const nsRect& aDirtyRect,
|
||||
nsFramePaintLayer aWhichLayer,
|
||||
const nsRect& aRect);
|
||||
|
||||
virtual void PaintBorderAndBackground(nsIPresContext* aPresContext,
|
||||
nsIRenderingContext& aRenderingContext,
|
||||
const nsRect& aDirtyRect,
|
||||
nsFramePaintLayer aWhichLayer,
|
||||
const nsRect& aRect);
|
||||
|
||||
virtual void SetNameSpace(PRInt32 aNameSpace);
|
||||
|
|
|
@ -361,7 +361,8 @@ nsHTMLButtonControlFrame::GetFrameForPoint(nsIPresContext* aPresContext,
|
|||
nsFramePaintLayer aWhichLayer,
|
||||
nsIFrame** aFrame)
|
||||
{
|
||||
if (mRect.Contains(aPoint)) {
|
||||
if (aWhichLayer == NS_FRAME_PAINT_LAYER_FOREGROUND &&
|
||||
mRect.Contains(aPoint)) {
|
||||
const nsStyleVisibility* vis =
|
||||
(const nsStyleVisibility*)mStyleContext->GetStyleData(eStyleStruct_Visibility);
|
||||
|
||||
|
@ -417,15 +418,18 @@ nsHTMLButtonControlFrame::Paint(nsIPresContext* aPresContext,
|
|||
PRUint32 aFlags)
|
||||
{
|
||||
PRBool isVisible;
|
||||
if (NS_SUCCEEDED(IsVisibleForPainting(aPresContext, aRenderingContext, PR_TRUE, &isVisible)) && !isVisible) {
|
||||
if (aWhichLayer != NS_FRAME_PAINT_LAYER_FOREGROUND ||
|
||||
(NS_SUCCEEDED(IsVisibleForPainting(aPresContext, aRenderingContext, PR_TRUE, &isVisible)) && !isVisible)) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsRect rect(0, 0, mRect.width, mRect.height);
|
||||
mRenderer.PaintButton(aPresContext, aRenderingContext, aDirtyRect, aWhichLayer, rect);
|
||||
mRenderer.PaintButton(aPresContext, aRenderingContext, aDirtyRect, rect);
|
||||
|
||||
#if 0 // old way
|
||||
PaintChildren(aPresContext, aRenderingContext, aDirtyRect, aWhichLayer);
|
||||
PaintChildren(aPresContext, aRenderingContext, aDirtyRect, NS_FRAME_PAINT_LAYER_BACKGROUND);
|
||||
PaintChildren(aPresContext, aRenderingContext, aDirtyRect, NS_FRAME_PAINT_LAYER_FLOATERS);
|
||||
PaintChildren(aPresContext, aRenderingContext, aDirtyRect, NS_FRAME_PAINT_LAYER_FOREGROUND);
|
||||
|
||||
#else // temporary
|
||||
// XXX This is temporary
|
||||
|
@ -445,7 +449,9 @@ nsHTMLButtonControlFrame::Paint(nsIPresContext* aPresContext,
|
|||
|
||||
aRenderingContext.SetClipRect(rect, nsClipCombine_kIntersect, clipEmpty);
|
||||
|
||||
PaintChildren(aPresContext, aRenderingContext, aDirtyRect, aWhichLayer);
|
||||
PaintChildren(aPresContext, aRenderingContext, aDirtyRect, NS_FRAME_PAINT_LAYER_BACKGROUND);
|
||||
PaintChildren(aPresContext, aRenderingContext, aDirtyRect, NS_FRAME_PAINT_LAYER_FLOATERS);
|
||||
PaintChildren(aPresContext, aRenderingContext, aDirtyRect, NS_FRAME_PAINT_LAYER_FOREGROUND);
|
||||
|
||||
aRenderingContext.PopState(clipEmpty);
|
||||
|
||||
|
|
|
@ -126,23 +126,21 @@ void
|
|||
nsButtonFrameRenderer::PaintButton (nsIPresContext* aPresContext,
|
||||
nsIRenderingContext& aRenderingContext,
|
||||
const nsRect& aDirtyRect,
|
||||
nsFramePaintLayer aWhichLayer,
|
||||
const nsRect& aRect)
|
||||
{
|
||||
//printf("painted width='%d' height='%d'\n",aRect.width, aRect.height);
|
||||
|
||||
// draw the border and background inside the focus and outline borders
|
||||
PaintBorderAndBackground(aPresContext, aRenderingContext, aDirtyRect, aWhichLayer, aRect);
|
||||
PaintBorderAndBackground(aPresContext, aRenderingContext, aDirtyRect, aRect);
|
||||
|
||||
// draw the focus and outline borders
|
||||
PaintOutlineAndFocusBorders(aPresContext, aRenderingContext, aDirtyRect, aWhichLayer, aRect);
|
||||
PaintOutlineAndFocusBorders(aPresContext, aRenderingContext, aDirtyRect, aRect);
|
||||
}
|
||||
|
||||
void
|
||||
nsButtonFrameRenderer::PaintOutlineAndFocusBorders(nsIPresContext* aPresContext,
|
||||
nsIRenderingContext& aRenderingContext,
|
||||
const nsRect& aDirtyRect,
|
||||
nsFramePaintLayer aWhichLayer,
|
||||
const nsRect& aRect)
|
||||
{
|
||||
// once we have all that let draw the focus if we have it. We will need to draw 2 focuses.
|
||||
|
@ -152,31 +150,27 @@ nsButtonFrameRenderer::PaintOutlineAndFocusBorders(nsIPresContext* aPresContext,
|
|||
|
||||
nsRect rect;
|
||||
|
||||
if (NS_FRAME_PAINT_LAYER_BACKGROUND == aWhichLayer)
|
||||
{
|
||||
if (mOuterFocusStyle) {
|
||||
// ---------- paint the outer focus border -------------
|
||||
if (mOuterFocusStyle) {
|
||||
// ---------- paint the outer focus border -------------
|
||||
|
||||
GetButtonOuterFocusRect(aRect, rect);
|
||||
GetButtonOuterFocusRect(aRect, rect);
|
||||
|
||||
const nsStyleBorder* border = (const nsStyleBorder*)mOuterFocusStyle ->GetStyleData(eStyleStruct_Border);
|
||||
|
||||
nsCSSRendering::PaintBorder(aPresContext, aRenderingContext, mFrame,
|
||||
aDirtyRect, rect, *border, mOuterFocusStyle, 0);
|
||||
}
|
||||
|
||||
// ---------- paint the inner focus border -------------
|
||||
if (mInnerFocusStyle) {
|
||||
|
||||
GetButtonInnerFocusRect(aRect, rect);
|
||||
|
||||
const nsStyleBorder* border = (const nsStyleBorder*)mInnerFocusStyle ->GetStyleData(eStyleStruct_Border);
|
||||
|
||||
nsCSSRendering::PaintBorder(aPresContext, aRenderingContext, mFrame,
|
||||
aDirtyRect, rect, *border, mInnerFocusStyle, 0);
|
||||
}
|
||||
const nsStyleBorder* border;
|
||||
::GetStyleData(mOuterFocusStyle, &border);
|
||||
nsCSSRendering::PaintBorder(aPresContext, aRenderingContext, mFrame,
|
||||
aDirtyRect, rect, *border, mOuterFocusStyle, 0);
|
||||
}
|
||||
|
||||
if (mInnerFocusStyle) {
|
||||
// ---------- paint the inner focus border -------------
|
||||
|
||||
GetButtonInnerFocusRect(aRect, rect);
|
||||
|
||||
const nsStyleBorder* border;
|
||||
::GetStyleData(mInnerFocusStyle, &border);
|
||||
nsCSSRendering::PaintBorder(aPresContext, aRenderingContext, mFrame,
|
||||
aDirtyRect, rect, *border, mInnerFocusStyle, 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -184,14 +178,9 @@ void
|
|||
nsButtonFrameRenderer::PaintBorderAndBackground(nsIPresContext* aPresContext,
|
||||
nsIRenderingContext& aRenderingContext,
|
||||
const nsRect& aDirtyRect,
|
||||
nsFramePaintLayer aWhichLayer,
|
||||
const nsRect& aRect)
|
||||
|
||||
{
|
||||
|
||||
if (NS_FRAME_PAINT_LAYER_BACKGROUND != aWhichLayer)
|
||||
return;
|
||||
|
||||
// get the button rect this is inside the focus and outline rects
|
||||
nsRect buttonRect;
|
||||
GetButtonRect(aRect, buttonRect);
|
||||
|
|
|
@ -61,22 +61,21 @@ public:
|
|||
virtual ~nsButtonFrameRenderer();
|
||||
|
||||
|
||||
// These three functions all assume a "background" layer within the
|
||||
// button, which is itself in the foreground layer.
|
||||
virtual void PaintButton(nsIPresContext* aPresContext,
|
||||
nsIRenderingContext& aRenderingContext,
|
||||
const nsRect& aDirtyRect,
|
||||
nsFramePaintLayer aWhichLayer,
|
||||
const nsRect& aRect);
|
||||
|
||||
virtual void PaintOutlineAndFocusBorders(nsIPresContext* aPresContext,
|
||||
nsIRenderingContext& aRenderingContext,
|
||||
const nsRect& aDirtyRect,
|
||||
nsFramePaintLayer aWhichLayer,
|
||||
const nsRect& aRect);
|
||||
|
||||
virtual void PaintBorderAndBackground(nsIPresContext* aPresContext,
|
||||
nsIRenderingContext& aRenderingContext,
|
||||
const nsRect& aDirtyRect,
|
||||
nsFramePaintLayer aWhichLayer,
|
||||
const nsRect& aRect);
|
||||
|
||||
virtual void SetNameSpace(PRInt32 aNameSpace);
|
||||
|
|
|
@ -361,7 +361,8 @@ nsHTMLButtonControlFrame::GetFrameForPoint(nsIPresContext* aPresContext,
|
|||
nsFramePaintLayer aWhichLayer,
|
||||
nsIFrame** aFrame)
|
||||
{
|
||||
if (mRect.Contains(aPoint)) {
|
||||
if (aWhichLayer == NS_FRAME_PAINT_LAYER_FOREGROUND &&
|
||||
mRect.Contains(aPoint)) {
|
||||
const nsStyleVisibility* vis =
|
||||
(const nsStyleVisibility*)mStyleContext->GetStyleData(eStyleStruct_Visibility);
|
||||
|
||||
|
@ -417,15 +418,18 @@ nsHTMLButtonControlFrame::Paint(nsIPresContext* aPresContext,
|
|||
PRUint32 aFlags)
|
||||
{
|
||||
PRBool isVisible;
|
||||
if (NS_SUCCEEDED(IsVisibleForPainting(aPresContext, aRenderingContext, PR_TRUE, &isVisible)) && !isVisible) {
|
||||
if (aWhichLayer != NS_FRAME_PAINT_LAYER_FOREGROUND ||
|
||||
(NS_SUCCEEDED(IsVisibleForPainting(aPresContext, aRenderingContext, PR_TRUE, &isVisible)) && !isVisible)) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsRect rect(0, 0, mRect.width, mRect.height);
|
||||
mRenderer.PaintButton(aPresContext, aRenderingContext, aDirtyRect, aWhichLayer, rect);
|
||||
mRenderer.PaintButton(aPresContext, aRenderingContext, aDirtyRect, rect);
|
||||
|
||||
#if 0 // old way
|
||||
PaintChildren(aPresContext, aRenderingContext, aDirtyRect, aWhichLayer);
|
||||
PaintChildren(aPresContext, aRenderingContext, aDirtyRect, NS_FRAME_PAINT_LAYER_BACKGROUND);
|
||||
PaintChildren(aPresContext, aRenderingContext, aDirtyRect, NS_FRAME_PAINT_LAYER_FLOATERS);
|
||||
PaintChildren(aPresContext, aRenderingContext, aDirtyRect, NS_FRAME_PAINT_LAYER_FOREGROUND);
|
||||
|
||||
#else // temporary
|
||||
// XXX This is temporary
|
||||
|
@ -445,7 +449,9 @@ nsHTMLButtonControlFrame::Paint(nsIPresContext* aPresContext,
|
|||
|
||||
aRenderingContext.SetClipRect(rect, nsClipCombine_kIntersect, clipEmpty);
|
||||
|
||||
PaintChildren(aPresContext, aRenderingContext, aDirtyRect, aWhichLayer);
|
||||
PaintChildren(aPresContext, aRenderingContext, aDirtyRect, NS_FRAME_PAINT_LAYER_BACKGROUND);
|
||||
PaintChildren(aPresContext, aRenderingContext, aDirtyRect, NS_FRAME_PAINT_LAYER_FLOATERS);
|
||||
PaintChildren(aPresContext, aRenderingContext, aDirtyRect, NS_FRAME_PAINT_LAYER_FOREGROUND);
|
||||
|
||||
aRenderingContext.PopState(clipEmpty);
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче