added visibility style attribute

moved attributes from position to display struct
This commit is contained in:
peterl
1998-05-26 23:15:47 +00:00
parent 850eb7b89d
commit 62401fedf0
10 changed files with 160 additions and 114 deletions

View File

@@ -52,7 +52,11 @@ NS_METHOD nsHTMLContainerFrame::Paint(nsIPresContext& aPresContext,
const nsRect& aDirtyRect) const nsRect& aDirtyRect)
{ {
// Do not paint ourselves if we are a pseudo-frame // Do not paint ourselves if we are a pseudo-frame
if (PR_FALSE == IsPseudoFrame()) { if (PR_FALSE == IsPseudoFrame()) { // this trip isn't really necessary
nsStyleDisplay* disp =
(nsStyleDisplay*)mStyleContext->GetData(eStyleStruct_Display);
if (disp->mVisible) {
PRIntn skipSides = GetSkipSides(); PRIntn skipSides = GetSkipSides();
nsStyleColor* color = nsStyleColor* color =
(nsStyleColor*)mStyleContext->GetData(eStyleStruct_Color); (nsStyleColor*)mStyleContext->GetData(eStyleStruct_Color);
@@ -63,6 +67,7 @@ NS_METHOD nsHTMLContainerFrame::Paint(nsIPresContext& aPresContext,
nsCSSRendering::PaintBorder(aPresContext, aRenderingContext, this, nsCSSRendering::PaintBorder(aPresContext, aRenderingContext, this,
aDirtyRect, mRect, *spacing, skipSides); aDirtyRect, mRect, *spacing, skipSides);
} }
}
PaintChildren(aPresContext, aRenderingContext, aDirtyRect); PaintChildren(aPresContext, aRenderingContext, aDirtyRect);

View File

@@ -32,6 +32,10 @@ NS_METHOD nsLeafFrame::Paint(nsIPresContext& aPresContext,
nsIRenderingContext& aRenderingContext, nsIRenderingContext& aRenderingContext,
const nsRect& aDirtyRect) const nsRect& aDirtyRect)
{ {
nsStyleDisplay* disp =
(nsStyleDisplay*)mStyleContext->GetData(eStyleStruct_Display);
if (disp->mVisible) {
nsStyleColor* myColor = nsStyleColor* myColor =
(nsStyleColor*)mStyleContext->GetData(eStyleStruct_Color); (nsStyleColor*)mStyleContext->GetData(eStyleStruct_Color);
nsStyleSpacing* mySpacing = nsStyleSpacing* mySpacing =
@@ -40,6 +44,7 @@ NS_METHOD nsLeafFrame::Paint(nsIPresContext& aPresContext,
aDirtyRect, mRect, *myColor); aDirtyRect, mRect, *myColor);
nsCSSRendering::PaintBorder(aPresContext, aRenderingContext, this, nsCSSRendering::PaintBorder(aPresContext, aRenderingContext, this,
aDirtyRect, mRect, *mySpacing, 0); aDirtyRect, mRect, *mySpacing, 0);
}
return NS_OK; return NS_OK;
} }

View File

@@ -60,7 +60,8 @@ AbsoluteFrame::~AbsoluteFrame()
nsIView* AbsoluteFrame::CreateView(nsIView* aContainingView, nsIView* AbsoluteFrame::CreateView(nsIView* aContainingView,
const nsRect& aRect, const nsRect& aRect,
nsStylePosition* aPosition) nsStylePosition* aPosition,
nsStyleDisplay* aDisplay)
{ {
nsIView* view; nsIView* view;
@@ -81,22 +82,22 @@ nsIView* AbsoluteFrame::CreateView(nsIView* aContainingView,
nsIScrollableView* scrollView = nsnull; nsIScrollableView* scrollView = nsnull;
nsresult result; nsresult result;
nsViewClip clip = {0, 0, 0, 0}; nsViewClip clip = {0, 0, 0, 0};
PRUint8 clipType = (aPosition->mClipFlags & NS_STYLE_CLIP_TYPE_MASK); PRUint8 clipType = (aDisplay->mClipFlags & NS_STYLE_CLIP_TYPE_MASK);
nsViewClip* pClip = nsnull; nsViewClip* pClip = nsnull;
// Is there a clip rect specified? // Is there a clip rect specified?
if (NS_STYLE_CLIP_RECT == clipType) { if (NS_STYLE_CLIP_RECT == clipType) {
if ((NS_STYLE_CLIP_LEFT_AUTO & aPosition->mClipFlags) == 0) { if ((NS_STYLE_CLIP_LEFT_AUTO & aDisplay->mClipFlags) == 0) {
clip.mLeft = aPosition->mClip.left; clip.mLeft = aDisplay->mClip.left;
} }
if ((NS_STYLE_CLIP_RIGHT_AUTO & aPosition->mClipFlags) == 0) { if ((NS_STYLE_CLIP_RIGHT_AUTO & aDisplay->mClipFlags) == 0) {
clip.mRight = aPosition->mClip.right; clip.mRight = aDisplay->mClip.right;
} }
if ((NS_STYLE_CLIP_TOP_AUTO & aPosition->mClipFlags) == 0) { if ((NS_STYLE_CLIP_TOP_AUTO & aDisplay->mClipFlags) == 0) {
clip.mTop = aPosition->mClip.top; clip.mTop = aDisplay->mClip.top;
} }
if ((NS_STYLE_CLIP_BOTTOM_AUTO & aPosition->mClipFlags) == 0) { if ((NS_STYLE_CLIP_BOTTOM_AUTO & aDisplay->mClipFlags) == 0) {
clip.mBottom = aPosition->mClip.bottom; clip.mBottom = aDisplay->mClip.bottom;
} }
pClip = &clip; pClip = &clip;
} }
@@ -285,7 +286,8 @@ NS_METHOD AbsoluteFrame::Reflow(nsIPresContext* aPresContext,
ComputeViewBounds(containingRect, position, rect); ComputeViewBounds(containingRect, position, rect);
// Create a view for the frame // Create a view for the frame
nsIView* view = CreateView(containingView, rect, position); nsStyleDisplay* display = (nsStyleDisplay*)mStyleContext->GetData(eStyleStruct_Display);
nsIView* view = CreateView(containingView, rect, position, display);
NS_RELEASE(containingView); NS_RELEASE(containingView);
mFrame->SetView(view); mFrame->SetView(view);
@@ -294,7 +296,7 @@ NS_METHOD AbsoluteFrame::Reflow(nsIPresContext* aPresContext,
// Resize reflow the absolutely positioned element // Resize reflow the absolutely positioned element
nsSize availSize(rect.width, rect.height); nsSize availSize(rect.width, rect.height);
if (NS_STYLE_OVERFLOW_VISIBLE == position->mOverflow) { if (NS_STYLE_OVERFLOW_VISIBLE == display->mOverflow) {
// Don't constrain the height since the container should be enlarged to // Don't constrain the height since the container should be enlarged to
// contain overflowing frames // contain overflowing frames
availSize.height = NS_UNCONSTRAINEDSIZE; availSize.height = NS_UNCONSTRAINEDSIZE;
@@ -309,7 +311,7 @@ NS_METHOD AbsoluteFrame::Reflow(nsIPresContext* aPresContext,
// the desired size // the desired size
if ((eStyleUnit_Auto == position->mWidth.GetUnit()) || if ((eStyleUnit_Auto == position->mWidth.GetUnit()) ||
((desiredSize.width > availSize.width) && ((desiredSize.width > availSize.width) &&
(NS_STYLE_OVERFLOW_VISIBLE == position->mOverflow))) { (NS_STYLE_OVERFLOW_VISIBLE == display->mOverflow))) {
rect.width = desiredSize.width; rect.width = desiredSize.width;
} }
if (eStyleUnit_Auto == position->mHeight.GetUnit()) { if (eStyleUnit_Auto == position->mHeight.GetUnit()) {

View File

@@ -20,6 +20,7 @@
#include "nsFrame.h" #include "nsFrame.h"
struct nsStylePosition; struct nsStylePosition;
struct nsStyleDisplay;
// Implementation of a frame that's used as a placeholder for an absolutely // Implementation of a frame that's used as a placeholder for an absolutely
// positioned frame // positioned frame
@@ -58,7 +59,8 @@ protected:
nsIView* CreateView(nsIView* aContainingView, nsIView* CreateView(nsIView* aContainingView,
const nsRect& aRect, const nsRect& aRect,
nsStylePosition* aPosition); nsStylePosition* aPosition,
nsStyleDisplay* aDisplay);
nsIFrame* GetContainingBlock(); nsIFrame* GetContainingBlock();
void ComputeViewBounds(const nsRect& aContainingInnerRect, void ComputeViewBounds(const nsRect& aContainingInnerRect,
nsStylePosition* aPosition, nsStylePosition* aPosition,

View File

@@ -98,6 +98,13 @@ NS_METHOD HRuleFrame::Paint(nsIPresContext& aPresContext,
nsIRenderingContext& aRenderingContext, nsIRenderingContext& aRenderingContext,
const nsRect& aDirtyRect) const nsRect& aDirtyRect)
{ {
nsStyleDisplay* disp =
(nsStyleDisplay*)mStyleContext->GetData(eStyleStruct_Display);
if (PR_FALSE == disp->mVisible) {
return NS_OK;
}
float p2t = aPresContext.GetPixelsToTwips(); float p2t = aPresContext.GetPixelsToTwips();
nscoord thickness = nscoord(p2t * ((HRulePart*)mContent)->mThickness); nscoord thickness = nscoord(p2t * ((HRulePart*)mContent)->mThickness);

View File

@@ -52,7 +52,11 @@ NS_METHOD nsHTMLContainerFrame::Paint(nsIPresContext& aPresContext,
const nsRect& aDirtyRect) const nsRect& aDirtyRect)
{ {
// Do not paint ourselves if we are a pseudo-frame // Do not paint ourselves if we are a pseudo-frame
if (PR_FALSE == IsPseudoFrame()) { if (PR_FALSE == IsPseudoFrame()) { // this trip isn't really necessary
nsStyleDisplay* disp =
(nsStyleDisplay*)mStyleContext->GetData(eStyleStruct_Display);
if (disp->mVisible) {
PRIntn skipSides = GetSkipSides(); PRIntn skipSides = GetSkipSides();
nsStyleColor* color = nsStyleColor* color =
(nsStyleColor*)mStyleContext->GetData(eStyleStruct_Color); (nsStyleColor*)mStyleContext->GetData(eStyleStruct_Color);
@@ -63,6 +67,7 @@ NS_METHOD nsHTMLContainerFrame::Paint(nsIPresContext& aPresContext,
nsCSSRendering::PaintBorder(aPresContext, aRenderingContext, this, nsCSSRendering::PaintBorder(aPresContext, aRenderingContext, this,
aDirtyRect, mRect, *spacing, skipSides); aDirtyRect, mRect, *spacing, skipSides);
} }
}
PaintChildren(aPresContext, aRenderingContext, aDirtyRect); PaintChildren(aPresContext, aRenderingContext, aDirtyRect);

View File

@@ -326,6 +326,10 @@ ImageFrame::Paint(nsIPresContext& aPresContext,
return NS_OK; return NS_OK;
} }
nsStyleDisplay* disp =
(nsStyleDisplay*)mStyleContext->GetData(eStyleStruct_Display);
if (disp->mVisible) {
// First paint background and borders // First paint background and borders
nsLeafFrame::Paint(aPresContext, aRenderingContext, aDirtyRect); nsLeafFrame::Paint(aPresContext, aRenderingContext, aDirtyRect);
@@ -343,6 +347,7 @@ ImageFrame::Paint(nsIPresContext& aPresContext,
nsRect inner; nsRect inner;
GetInnerArea(&aPresContext, inner); GetInnerArea(&aPresContext, inner);
aRenderingContext.DrawImage(image, inner); aRenderingContext.DrawImage(image, inner);
}
if (GetShowFrameBorders()) { if (GetShowFrameBorders()) {
nsIImageMap* map = GetImageMap(); nsIImageMap* map = GetImageMap();

View File

@@ -32,6 +32,10 @@ NS_METHOD nsLeafFrame::Paint(nsIPresContext& aPresContext,
nsIRenderingContext& aRenderingContext, nsIRenderingContext& aRenderingContext,
const nsRect& aDirtyRect) const nsRect& aDirtyRect)
{ {
nsStyleDisplay* disp =
(nsStyleDisplay*)mStyleContext->GetData(eStyleStruct_Display);
if (disp->mVisible) {
nsStyleColor* myColor = nsStyleColor* myColor =
(nsStyleColor*)mStyleContext->GetData(eStyleStruct_Color); (nsStyleColor*)mStyleContext->GetData(eStyleStruct_Color);
nsStyleSpacing* mySpacing = nsStyleSpacing* mySpacing =
@@ -40,6 +44,7 @@ NS_METHOD nsLeafFrame::Paint(nsIPresContext& aPresContext,
aDirtyRect, mRect, *myColor); aDirtyRect, mRect, *myColor);
nsCSSRendering::PaintBorder(aPresContext, aRenderingContext, this, nsCSSRendering::PaintBorder(aPresContext, aRenderingContext, this,
aDirtyRect, mRect, *mySpacing, 0); aDirtyRect, mRect, *mySpacing, 0);
}
return NS_OK; return NS_OK;
} }

View File

@@ -86,6 +86,10 @@ NS_METHOD BulletFrame::Paint(nsIPresContext& aCX,
nsIRenderingContext& aRenderingContext, nsIRenderingContext& aRenderingContext,
const nsRect& aDirtyRect) const nsRect& aDirtyRect)
{ {
nsStyleDisplay* disp =
(nsStyleDisplay*)mStyleContext->GetData(eStyleStruct_Display);
if (disp->mVisible) {
nsStyleFont* myFont = nsStyleFont* myFont =
(nsStyleFont*)mStyleContext->GetData(eStyleStruct_Font); (nsStyleFont*)mStyleContext->GetData(eStyleStruct_Font);
nsStyleColor* myColor = nsStyleColor* myColor =
@@ -122,6 +126,7 @@ NS_METHOD BulletFrame::Paint(nsIPresContext& aCX,
break; break;
} }
NS_RELEASE(fm); NS_RELEASE(fm);
}
return NS_OK; return NS_OK;
} }

View File

@@ -431,6 +431,10 @@ NS_METHOD TextFrame::Paint(nsIPresContext& aPresContext,
return NS_OK; return NS_OK;
} }
nsStyleDisplay* disp =
(nsStyleDisplay*)mStyleContext->GetData(eStyleStruct_Display);
if (disp->mVisible) {
// Get style data // Get style data
nsStyleColor* color = nsStyleColor* color =
(nsStyleColor*)mStyleContext->GetData(eStyleStruct_Color); (nsStyleColor*)mStyleContext->GetData(eStyleStruct_Color);
@@ -457,6 +461,7 @@ NS_METHOD TextFrame::Paint(nsIPresContext& aPresContext,
aRenderingContext.SetColor(color->mBackgroundColor); aRenderingContext.SetColor(color->mBackgroundColor);
PaintRegularText(aPresContext, aRenderingContext, aDirtyRect, onePixel, onePixel); PaintRegularText(aPresContext, aRenderingContext, aDirtyRect, onePixel, onePixel);
} }
}
return NS_OK; return NS_OK;
} }