Bug 317375. Reorganize frame painting and mouse event targeting around frame display lists. Some review from dbaron, lots of testing help from Martijn, Julien and others
This commit is contained in:
@@ -44,6 +44,7 @@
|
||||
#include "nsCSSPseudoElements.h"
|
||||
#include "nsINameSpaceManager.h"
|
||||
#include "nsStyleSet.h"
|
||||
#include "nsDisplayList.h"
|
||||
|
||||
#define ACTIVE "active"
|
||||
#define HOVER "hover"
|
||||
@@ -92,19 +93,66 @@ nsButtonFrameRenderer::isDisabled()
|
||||
nsHTMLAtoms::disabled);
|
||||
}
|
||||
|
||||
void
|
||||
nsButtonFrameRenderer::PaintButton (nsPresContext* aPresContext,
|
||||
nsIRenderingContext& aRenderingContext,
|
||||
const nsRect& aDirtyRect,
|
||||
const nsRect& aRect)
|
||||
class nsDisplayButtonBorderBackground : public nsDisplayItem {
|
||||
public:
|
||||
nsDisplayButtonBorderBackground(nsButtonFrameRenderer* aRenderer) : mBFR(aRenderer) {}
|
||||
virtual nsIFrame* GetUnderlyingFrame() { return mBFR->GetFrame(); }
|
||||
virtual nsIFrame* HitTest(nsDisplayListBuilder* aBuilder, nsPoint aPt) {
|
||||
return mBFR->GetFrame();
|
||||
}
|
||||
virtual void Paint(nsDisplayListBuilder* aBuilder, nsIRenderingContext* aCtx,
|
||||
const nsRect& aDirtyRect);
|
||||
NS_DISPLAY_DECL_NAME("ButtonBorderBackground")
|
||||
private:
|
||||
nsButtonFrameRenderer* mBFR;
|
||||
};
|
||||
|
||||
class nsDisplayButtonForeground : public nsDisplayItem {
|
||||
public:
|
||||
nsDisplayButtonForeground(nsButtonFrameRenderer* aRenderer) : mBFR(aRenderer) {}
|
||||
virtual nsIFrame* GetUnderlyingFrame() { return mBFR->GetFrame(); }
|
||||
virtual void Paint(nsDisplayListBuilder* aBuilder, nsIRenderingContext* aCtx,
|
||||
const nsRect& aDirtyRect);
|
||||
NS_DISPLAY_DECL_NAME("ButtonForeground")
|
||||
private:
|
||||
nsButtonFrameRenderer* mBFR;
|
||||
};
|
||||
|
||||
void nsDisplayButtonBorderBackground::Paint(nsDisplayListBuilder* aBuilder, nsIRenderingContext* aCtx,
|
||||
const nsRect& aDirtyRect)
|
||||
{
|
||||
//printf("painted width='%d' height='%d'\n",aRect.width, aRect.height);
|
||||
|
||||
nsIFrame* f = mBFR->GetFrame();
|
||||
NS_ASSERTION(f, "No frame?");
|
||||
nsPresContext* pc = f->GetPresContext();
|
||||
nsRect r = nsRect(aBuilder->ToReferenceFrame(f), f->GetSize());
|
||||
|
||||
// draw the border and background inside the focus and outline borders
|
||||
PaintBorderAndBackground(aPresContext, aRenderingContext, aDirtyRect, aRect);
|
||||
mBFR->PaintBorderAndBackground(pc, *aCtx, aDirtyRect, r);
|
||||
}
|
||||
|
||||
void nsDisplayButtonForeground::Paint(nsDisplayListBuilder* aBuilder, nsIRenderingContext* aCtx,
|
||||
const nsRect& aDirtyRect)
|
||||
{
|
||||
nsIFrame* f = mBFR->GetFrame();
|
||||
NS_ASSERTION(f, "No frame?");
|
||||
nsPresContext* pc = f->GetPresContext();
|
||||
nsRect r = nsRect(aBuilder->ToReferenceFrame(f), f->GetSize());
|
||||
|
||||
// draw the focus and outline borders
|
||||
PaintOutlineAndFocusBorders(aPresContext, aRenderingContext, aDirtyRect, aRect);
|
||||
mBFR->PaintOutlineAndFocusBorders(pc, *aCtx, aDirtyRect, r);
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsButtonFrameRenderer::DisplayButton(nsDisplayListBuilder* aBuilder,
|
||||
nsDisplayList* aBackground,
|
||||
nsDisplayList* aForeground)
|
||||
{
|
||||
nsresult rv = aBackground->AppendNewToTop(new (aBuilder)
|
||||
nsDisplayButtonBorderBackground(this));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
return aForeground->AppendNewToTop(new (aBuilder)
|
||||
nsDisplayButtonForeground(this));
|
||||
}
|
||||
|
||||
void
|
||||
|
||||
Reference in New Issue
Block a user