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,16 +52,21 @@ 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
PRIntn skipSides = GetSkipSides(); nsStyleDisplay* disp =
nsStyleColor* color = (nsStyleDisplay*)mStyleContext->GetData(eStyleStruct_Display);
(nsStyleColor*)mStyleContext->GetData(eStyleStruct_Color);
nsStyleSpacing* spacing = if (disp->mVisible) {
(nsStyleSpacing*)mStyleContext->GetData(eStyleStruct_Spacing); PRIntn skipSides = GetSkipSides();
nsCSSRendering::PaintBackground(aPresContext, aRenderingContext, this, nsStyleColor* color =
aDirtyRect, mRect, *color); (nsStyleColor*)mStyleContext->GetData(eStyleStruct_Color);
nsCSSRendering::PaintBorder(aPresContext, aRenderingContext, this, nsStyleSpacing* spacing =
aDirtyRect, mRect, *spacing, skipSides); (nsStyleSpacing*)mStyleContext->GetData(eStyleStruct_Spacing);
nsCSSRendering::PaintBackground(aPresContext, aRenderingContext, this,
aDirtyRect, mRect, *color);
nsCSSRendering::PaintBorder(aPresContext, aRenderingContext, this,
aDirtyRect, mRect, *spacing, skipSides);
}
} }
PaintChildren(aPresContext, aRenderingContext, aDirtyRect); PaintChildren(aPresContext, aRenderingContext, aDirtyRect);

View File

@@ -32,14 +32,19 @@ NS_METHOD nsLeafFrame::Paint(nsIPresContext& aPresContext,
nsIRenderingContext& aRenderingContext, nsIRenderingContext& aRenderingContext,
const nsRect& aDirtyRect) const nsRect& aDirtyRect)
{ {
nsStyleColor* myColor = nsStyleDisplay* disp =
(nsStyleColor*)mStyleContext->GetData(eStyleStruct_Color); (nsStyleDisplay*)mStyleContext->GetData(eStyleStruct_Display);
nsStyleSpacing* mySpacing =
(nsStyleSpacing*)mStyleContext->GetData(eStyleStruct_Spacing); if (disp->mVisible) {
nsCSSRendering::PaintBackground(aPresContext, aRenderingContext, this, nsStyleColor* myColor =
aDirtyRect, mRect, *myColor); (nsStyleColor*)mStyleContext->GetData(eStyleStruct_Color);
nsCSSRendering::PaintBorder(aPresContext, aRenderingContext, this, nsStyleSpacing* mySpacing =
aDirtyRect, mRect, *mySpacing, 0); (nsStyleSpacing*)mStyleContext->GetData(eStyleStruct_Spacing);
nsCSSRendering::PaintBackground(aPresContext, aRenderingContext, this,
aDirtyRect, mRect, *myColor);
nsCSSRendering::PaintBorder(aPresContext, aRenderingContext, this,
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,16 +52,21 @@ 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
PRIntn skipSides = GetSkipSides(); nsStyleDisplay* disp =
nsStyleColor* color = (nsStyleDisplay*)mStyleContext->GetData(eStyleStruct_Display);
(nsStyleColor*)mStyleContext->GetData(eStyleStruct_Color);
nsStyleSpacing* spacing = if (disp->mVisible) {
(nsStyleSpacing*)mStyleContext->GetData(eStyleStruct_Spacing); PRIntn skipSides = GetSkipSides();
nsCSSRendering::PaintBackground(aPresContext, aRenderingContext, this, nsStyleColor* color =
aDirtyRect, mRect, *color); (nsStyleColor*)mStyleContext->GetData(eStyleStruct_Color);
nsCSSRendering::PaintBorder(aPresContext, aRenderingContext, this, nsStyleSpacing* spacing =
aDirtyRect, mRect, *spacing, skipSides); (nsStyleSpacing*)mStyleContext->GetData(eStyleStruct_Spacing);
nsCSSRendering::PaintBackground(aPresContext, aRenderingContext, this,
aDirtyRect, mRect, *color);
nsCSSRendering::PaintBorder(aPresContext, aRenderingContext, this,
aDirtyRect, mRect, *spacing, skipSides);
}
} }
PaintChildren(aPresContext, aRenderingContext, aDirtyRect); PaintChildren(aPresContext, aRenderingContext, aDirtyRect);

View File

@@ -326,24 +326,29 @@ ImageFrame::Paint(nsIPresContext& aPresContext,
return NS_OK; return NS_OK;
} }
// First paint background and borders nsStyleDisplay* disp =
nsLeafFrame::Paint(aPresContext, aRenderingContext, aDirtyRect); (nsStyleDisplay*)mStyleContext->GetData(eStyleStruct_Display);
// XXX when rendering the broken image, do not scale! if (disp->mVisible) {
// XXX when we don't have the image, draw the we-don't-have-an-image look // First paint background and borders
nsLeafFrame::Paint(aPresContext, aRenderingContext, aDirtyRect);
nsIImage* image = mImageLoader.GetImage(); // XXX when rendering the broken image, do not scale!
if (nsnull == image) { // XXX when we don't have the image, draw the we-don't-have-an-image look
// No image yet
return NS_OK; nsIImage* image = mImageLoader.GetImage();
if (nsnull == image) {
// No image yet
return NS_OK;
}
// Now render the image into our inner area (the area without the
// borders and padding)
nsRect inner;
GetInnerArea(&aPresContext, inner);
aRenderingContext.DrawImage(image, inner);
} }
// Now render the image into our inner area (the area without the
// borders and padding)
nsRect inner;
GetInnerArea(&aPresContext, inner);
aRenderingContext.DrawImage(image, inner);
if (GetShowFrameBorders()) { if (GetShowFrameBorders()) {
nsIImageMap* map = GetImageMap(); nsIImageMap* map = GetImageMap();
if (nsnull != map) { if (nsnull != map) {

View File

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

View File

@@ -86,42 +86,47 @@ NS_METHOD BulletFrame::Paint(nsIPresContext& aCX,
nsIRenderingContext& aRenderingContext, nsIRenderingContext& aRenderingContext,
const nsRect& aDirtyRect) const nsRect& aDirtyRect)
{ {
nsStyleFont* myFont = nsStyleDisplay* disp =
(nsStyleFont*)mStyleContext->GetData(eStyleStruct_Font); (nsStyleDisplay*)mStyleContext->GetData(eStyleStruct_Display);
nsStyleColor* myColor =
(nsStyleColor*)mStyleContext->GetData(eStyleStruct_Color);
nsStyleList* myList =
(nsStyleList*)mStyleContext->GetData(eStyleStruct_List);
nsIFontMetrics* fm = aCX.GetMetricsFor(myFont->mFont);
nscoord pad; if (disp->mVisible) {
nsStyleFont* myFont =
(nsStyleFont*)mStyleContext->GetData(eStyleStruct_Font);
nsStyleColor* myColor =
(nsStyleColor*)mStyleContext->GetData(eStyleStruct_Color);
nsStyleList* myList =
(nsStyleList*)mStyleContext->GetData(eStyleStruct_List);
nsIFontMetrics* fm = aCX.GetMetricsFor(myFont->mFont);
nsAutoString text; nscoord pad;
switch (myList->mListStyleType) {
case NS_STYLE_LIST_STYLE_NONE:
break;
case NS_STYLE_LIST_STYLE_DISC: nsAutoString text;
case NS_STYLE_LIST_STYLE_CIRCLE: switch (myList->mListStyleType) {
case NS_STYLE_LIST_STYLE_SQUARE: case NS_STYLE_LIST_STYLE_NONE:
pad = PAD_DISC; break;
aRenderingContext.SetColor(myColor->mColor);
aRenderingContext.FillRect(pad, pad, mRect.width - (pad + pad),
mRect.height - (pad + pad));/* XXX */
break;
case NS_STYLE_LIST_STYLE_DECIMAL: case NS_STYLE_LIST_STYLE_DISC:
case NS_STYLE_LIST_STYLE_LOWER_ROMAN: case NS_STYLE_LIST_STYLE_CIRCLE:
case NS_STYLE_LIST_STYLE_UPPER_ROMAN: case NS_STYLE_LIST_STYLE_SQUARE:
case NS_STYLE_LIST_STYLE_LOWER_ALPHA: pad = PAD_DISC;
case NS_STYLE_LIST_STYLE_UPPER_ALPHA: aRenderingContext.SetColor(myColor->mColor);
GetListItemText(&aCX, text, *myList); aRenderingContext.FillRect(pad, pad, mRect.width - (pad + pad),
aRenderingContext.SetColor(myColor->mColor); mRect.height - (pad + pad));/* XXX */
aRenderingContext.SetFont(myFont->mFont); break;
aRenderingContext.DrawString(text, 0, 0, fm->GetWidth(text));
break; case NS_STYLE_LIST_STYLE_DECIMAL:
case NS_STYLE_LIST_STYLE_LOWER_ROMAN:
case NS_STYLE_LIST_STYLE_UPPER_ROMAN:
case NS_STYLE_LIST_STYLE_LOWER_ALPHA:
case NS_STYLE_LIST_STYLE_UPPER_ALPHA:
GetListItemText(&aCX, text, *myList);
aRenderingContext.SetColor(myColor->mColor);
aRenderingContext.SetFont(myFont->mFont);
aRenderingContext.DrawString(text, 0, 0, fm->GetWidth(text));
break;
}
NS_RELEASE(fm);
} }
NS_RELEASE(fm);
return NS_OK; return NS_OK;
} }

View File

@@ -431,31 +431,36 @@ NS_METHOD TextFrame::Paint(nsIPresContext& aPresContext,
return NS_OK; return NS_OK;
} }
// Get style data nsStyleDisplay* disp =
nsStyleColor* color = (nsStyleDisplay*)mStyleContext->GetData(eStyleStruct_Display);
(nsStyleColor*)mStyleContext->GetData(eStyleStruct_Color);
nsStyleFont* font =
(nsStyleFont*)mStyleContext->GetData(eStyleStruct_Font);
// Set font and color if (disp->mVisible) {
aRenderingContext.SetColor(color->mColor); // Get style data
aRenderingContext.SetFont(font->mFont); nsStyleColor* color =
(nsStyleColor*)mStyleContext->GetData(eStyleStruct_Color);
nsStyleFont* font =
(nsStyleFont*)mStyleContext->GetData(eStyleStruct_Font);
if (nsnull != mWords) { // Set font and color
PaintJustifiedText(aRenderingContext, aDirtyRect, 0, 0); aRenderingContext.SetColor(color->mColor);
aRenderingContext.SetFont(font->mFont);
if (nsnull != mWords) {
PaintJustifiedText(aRenderingContext, aDirtyRect, 0, 0);
if (font->mThreeD) {
nscoord onePixel = nscoord(1.0f * aPresContext.GetPixelsToTwips());
aRenderingContext.SetColor(color->mBackgroundColor);
PaintJustifiedText(aRenderingContext, aDirtyRect, onePixel, onePixel);
}
return NS_OK;
}
PaintRegularText(aPresContext, aRenderingContext, aDirtyRect, 0, 0);
//nsFrame::Paint(aPresContext, aRenderingContext, aDirtyRect);
if (font->mThreeD) { if (font->mThreeD) {
nscoord onePixel = nscoord(1.0f * aPresContext.GetPixelsToTwips()); nscoord onePixel = nscoord(1.0f * aPresContext.GetPixelsToTwips());
aRenderingContext.SetColor(color->mBackgroundColor); aRenderingContext.SetColor(color->mBackgroundColor);
PaintJustifiedText(aRenderingContext, aDirtyRect, onePixel, onePixel); PaintRegularText(aPresContext, aRenderingContext, aDirtyRect, onePixel, onePixel);
} }
return NS_OK;
}
PaintRegularText(aPresContext, aRenderingContext, aDirtyRect, 0, 0);
//nsFrame::Paint(aPresContext, aRenderingContext, aDirtyRect);
if (font->mThreeD) {
nscoord onePixel = nscoord(1.0f * aPresContext.GetPixelsToTwips());
aRenderingContext.SetColor(color->mBackgroundColor);
PaintRegularText(aPresContext, aRenderingContext, aDirtyRect, onePixel, onePixel);
} }
return NS_OK; return NS_OK;