From 779a602187f3ea82fb1fbbf19adf6e5d726206f6 Mon Sep 17 00:00:00 2001 From: peterl Date: Tue, 26 May 1998 23:15:47 +0000 Subject: [PATCH] added visibility style attribute moved attributes from position to display struct git-svn-id: svn://10.0.0.236/trunk@2304 18797224-902f-48f8-a5cc-f745e15eee43 --- .../layout/generic/nsHTMLContainerFrame.cpp | 25 ++++--- mozilla/layout/generic/nsLeafFrame.cpp | 21 +++--- .../layout/html/base/src/nsAbsoluteFrame.cpp | 28 ++++---- .../layout/html/base/src/nsAbsoluteFrame.h | 4 +- mozilla/layout/html/base/src/nsHRPart.cpp | 7 ++ .../html/base/src/nsHTMLContainerFrame.cpp | 25 ++++--- mozilla/layout/html/base/src/nsHTMLImage.cpp | 33 +++++---- mozilla/layout/html/base/src/nsLeafFrame.cpp | 21 +++--- .../layout/html/base/src/nsListItemFrame.cpp | 67 ++++++++++--------- .../layout/html/base/src/nsTextContent.cpp | 43 ++++++------ 10 files changed, 160 insertions(+), 114 deletions(-) diff --git a/mozilla/layout/generic/nsHTMLContainerFrame.cpp b/mozilla/layout/generic/nsHTMLContainerFrame.cpp index a3074c3aa6c..a21cf5ed6b3 100644 --- a/mozilla/layout/generic/nsHTMLContainerFrame.cpp +++ b/mozilla/layout/generic/nsHTMLContainerFrame.cpp @@ -52,16 +52,21 @@ NS_METHOD nsHTMLContainerFrame::Paint(nsIPresContext& aPresContext, const nsRect& aDirtyRect) { // Do not paint ourselves if we are a pseudo-frame - if (PR_FALSE == IsPseudoFrame()) { - PRIntn skipSides = GetSkipSides(); - nsStyleColor* color = - (nsStyleColor*)mStyleContext->GetData(eStyleStruct_Color); - nsStyleSpacing* spacing = - (nsStyleSpacing*)mStyleContext->GetData(eStyleStruct_Spacing); - nsCSSRendering::PaintBackground(aPresContext, aRenderingContext, this, - aDirtyRect, mRect, *color); - nsCSSRendering::PaintBorder(aPresContext, aRenderingContext, this, - aDirtyRect, mRect, *spacing, skipSides); + if (PR_FALSE == IsPseudoFrame()) { // this trip isn't really necessary + nsStyleDisplay* disp = + (nsStyleDisplay*)mStyleContext->GetData(eStyleStruct_Display); + + if (disp->mVisible) { + PRIntn skipSides = GetSkipSides(); + nsStyleColor* color = + (nsStyleColor*)mStyleContext->GetData(eStyleStruct_Color); + nsStyleSpacing* spacing = + (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); diff --git a/mozilla/layout/generic/nsLeafFrame.cpp b/mozilla/layout/generic/nsLeafFrame.cpp index 8e15b3c67be..7099f582479 100644 --- a/mozilla/layout/generic/nsLeafFrame.cpp +++ b/mozilla/layout/generic/nsLeafFrame.cpp @@ -32,14 +32,19 @@ NS_METHOD nsLeafFrame::Paint(nsIPresContext& aPresContext, nsIRenderingContext& aRenderingContext, const nsRect& aDirtyRect) { - nsStyleColor* myColor = - (nsStyleColor*)mStyleContext->GetData(eStyleStruct_Color); - nsStyleSpacing* mySpacing = - (nsStyleSpacing*)mStyleContext->GetData(eStyleStruct_Spacing); - nsCSSRendering::PaintBackground(aPresContext, aRenderingContext, this, - aDirtyRect, mRect, *myColor); - nsCSSRendering::PaintBorder(aPresContext, aRenderingContext, this, - aDirtyRect, mRect, *mySpacing, 0); + nsStyleDisplay* disp = + (nsStyleDisplay*)mStyleContext->GetData(eStyleStruct_Display); + + if (disp->mVisible) { + nsStyleColor* myColor = + (nsStyleColor*)mStyleContext->GetData(eStyleStruct_Color); + nsStyleSpacing* mySpacing = + (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; } diff --git a/mozilla/layout/html/base/src/nsAbsoluteFrame.cpp b/mozilla/layout/html/base/src/nsAbsoluteFrame.cpp index 6060f0caa13..7e39f0c92c0 100644 --- a/mozilla/layout/html/base/src/nsAbsoluteFrame.cpp +++ b/mozilla/layout/html/base/src/nsAbsoluteFrame.cpp @@ -60,7 +60,8 @@ AbsoluteFrame::~AbsoluteFrame() nsIView* AbsoluteFrame::CreateView(nsIView* aContainingView, const nsRect& aRect, - nsStylePosition* aPosition) + nsStylePosition* aPosition, + nsStyleDisplay* aDisplay) { nsIView* view; @@ -81,22 +82,22 @@ nsIView* AbsoluteFrame::CreateView(nsIView* aContainingView, nsIScrollableView* scrollView = nsnull; nsresult result; 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; // Is there a clip rect specified? if (NS_STYLE_CLIP_RECT == clipType) { - if ((NS_STYLE_CLIP_LEFT_AUTO & aPosition->mClipFlags) == 0) { - clip.mLeft = aPosition->mClip.left; + if ((NS_STYLE_CLIP_LEFT_AUTO & aDisplay->mClipFlags) == 0) { + clip.mLeft = aDisplay->mClip.left; } - if ((NS_STYLE_CLIP_RIGHT_AUTO & aPosition->mClipFlags) == 0) { - clip.mRight = aPosition->mClip.right; + if ((NS_STYLE_CLIP_RIGHT_AUTO & aDisplay->mClipFlags) == 0) { + clip.mRight = aDisplay->mClip.right; } - if ((NS_STYLE_CLIP_TOP_AUTO & aPosition->mClipFlags) == 0) { - clip.mTop = aPosition->mClip.top; + if ((NS_STYLE_CLIP_TOP_AUTO & aDisplay->mClipFlags) == 0) { + clip.mTop = aDisplay->mClip.top; } - if ((NS_STYLE_CLIP_BOTTOM_AUTO & aPosition->mClipFlags) == 0) { - clip.mBottom = aPosition->mClip.bottom; + if ((NS_STYLE_CLIP_BOTTOM_AUTO & aDisplay->mClipFlags) == 0) { + clip.mBottom = aDisplay->mClip.bottom; } pClip = &clip; } @@ -285,7 +286,8 @@ NS_METHOD AbsoluteFrame::Reflow(nsIPresContext* aPresContext, ComputeViewBounds(containingRect, position, rect); // 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); mFrame->SetView(view); @@ -294,7 +296,7 @@ NS_METHOD AbsoluteFrame::Reflow(nsIPresContext* aPresContext, // Resize reflow the absolutely positioned element 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 // contain overflowing frames availSize.height = NS_UNCONSTRAINEDSIZE; @@ -309,7 +311,7 @@ NS_METHOD AbsoluteFrame::Reflow(nsIPresContext* aPresContext, // the desired size if ((eStyleUnit_Auto == position->mWidth.GetUnit()) || ((desiredSize.width > availSize.width) && - (NS_STYLE_OVERFLOW_VISIBLE == position->mOverflow))) { + (NS_STYLE_OVERFLOW_VISIBLE == display->mOverflow))) { rect.width = desiredSize.width; } if (eStyleUnit_Auto == position->mHeight.GetUnit()) { diff --git a/mozilla/layout/html/base/src/nsAbsoluteFrame.h b/mozilla/layout/html/base/src/nsAbsoluteFrame.h index e01bf1dd142..690fa5fb3f2 100644 --- a/mozilla/layout/html/base/src/nsAbsoluteFrame.h +++ b/mozilla/layout/html/base/src/nsAbsoluteFrame.h @@ -20,6 +20,7 @@ #include "nsFrame.h" struct nsStylePosition; +struct nsStyleDisplay; // Implementation of a frame that's used as a placeholder for an absolutely // positioned frame @@ -58,7 +59,8 @@ protected: nsIView* CreateView(nsIView* aContainingView, const nsRect& aRect, - nsStylePosition* aPosition); + nsStylePosition* aPosition, + nsStyleDisplay* aDisplay); nsIFrame* GetContainingBlock(); void ComputeViewBounds(const nsRect& aContainingInnerRect, nsStylePosition* aPosition, diff --git a/mozilla/layout/html/base/src/nsHRPart.cpp b/mozilla/layout/html/base/src/nsHRPart.cpp index 9ffa587d80d..e11e2a2a92c 100644 --- a/mozilla/layout/html/base/src/nsHRPart.cpp +++ b/mozilla/layout/html/base/src/nsHRPart.cpp @@ -98,6 +98,13 @@ NS_METHOD HRuleFrame::Paint(nsIPresContext& aPresContext, nsIRenderingContext& aRenderingContext, const nsRect& aDirtyRect) { + nsStyleDisplay* disp = + (nsStyleDisplay*)mStyleContext->GetData(eStyleStruct_Display); + + if (PR_FALSE == disp->mVisible) { + return NS_OK; + } + float p2t = aPresContext.GetPixelsToTwips(); nscoord thickness = nscoord(p2t * ((HRulePart*)mContent)->mThickness); diff --git a/mozilla/layout/html/base/src/nsHTMLContainerFrame.cpp b/mozilla/layout/html/base/src/nsHTMLContainerFrame.cpp index a3074c3aa6c..a21cf5ed6b3 100644 --- a/mozilla/layout/html/base/src/nsHTMLContainerFrame.cpp +++ b/mozilla/layout/html/base/src/nsHTMLContainerFrame.cpp @@ -52,16 +52,21 @@ NS_METHOD nsHTMLContainerFrame::Paint(nsIPresContext& aPresContext, const nsRect& aDirtyRect) { // Do not paint ourselves if we are a pseudo-frame - if (PR_FALSE == IsPseudoFrame()) { - PRIntn skipSides = GetSkipSides(); - nsStyleColor* color = - (nsStyleColor*)mStyleContext->GetData(eStyleStruct_Color); - nsStyleSpacing* spacing = - (nsStyleSpacing*)mStyleContext->GetData(eStyleStruct_Spacing); - nsCSSRendering::PaintBackground(aPresContext, aRenderingContext, this, - aDirtyRect, mRect, *color); - nsCSSRendering::PaintBorder(aPresContext, aRenderingContext, this, - aDirtyRect, mRect, *spacing, skipSides); + if (PR_FALSE == IsPseudoFrame()) { // this trip isn't really necessary + nsStyleDisplay* disp = + (nsStyleDisplay*)mStyleContext->GetData(eStyleStruct_Display); + + if (disp->mVisible) { + PRIntn skipSides = GetSkipSides(); + nsStyleColor* color = + (nsStyleColor*)mStyleContext->GetData(eStyleStruct_Color); + nsStyleSpacing* spacing = + (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); diff --git a/mozilla/layout/html/base/src/nsHTMLImage.cpp b/mozilla/layout/html/base/src/nsHTMLImage.cpp index fe68b3da0f9..d4d5f5a865e 100644 --- a/mozilla/layout/html/base/src/nsHTMLImage.cpp +++ b/mozilla/layout/html/base/src/nsHTMLImage.cpp @@ -326,24 +326,29 @@ ImageFrame::Paint(nsIPresContext& aPresContext, return NS_OK; } - // First paint background and borders - nsLeafFrame::Paint(aPresContext, aRenderingContext, aDirtyRect); + nsStyleDisplay* disp = + (nsStyleDisplay*)mStyleContext->GetData(eStyleStruct_Display); - // XXX when rendering the broken image, do not scale! - // XXX when we don't have the image, draw the we-don't-have-an-image look + if (disp->mVisible) { + // First paint background and borders + nsLeafFrame::Paint(aPresContext, aRenderingContext, aDirtyRect); - nsIImage* image = mImageLoader.GetImage(); - if (nsnull == image) { - // No image yet - return NS_OK; + // XXX when rendering the broken image, do not scale! + // XXX when we don't have the image, draw the we-don't-have-an-image look + + 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()) { nsIImageMap* map = GetImageMap(); if (nsnull != map) { diff --git a/mozilla/layout/html/base/src/nsLeafFrame.cpp b/mozilla/layout/html/base/src/nsLeafFrame.cpp index 8e15b3c67be..7099f582479 100644 --- a/mozilla/layout/html/base/src/nsLeafFrame.cpp +++ b/mozilla/layout/html/base/src/nsLeafFrame.cpp @@ -32,14 +32,19 @@ NS_METHOD nsLeafFrame::Paint(nsIPresContext& aPresContext, nsIRenderingContext& aRenderingContext, const nsRect& aDirtyRect) { - nsStyleColor* myColor = - (nsStyleColor*)mStyleContext->GetData(eStyleStruct_Color); - nsStyleSpacing* mySpacing = - (nsStyleSpacing*)mStyleContext->GetData(eStyleStruct_Spacing); - nsCSSRendering::PaintBackground(aPresContext, aRenderingContext, this, - aDirtyRect, mRect, *myColor); - nsCSSRendering::PaintBorder(aPresContext, aRenderingContext, this, - aDirtyRect, mRect, *mySpacing, 0); + nsStyleDisplay* disp = + (nsStyleDisplay*)mStyleContext->GetData(eStyleStruct_Display); + + if (disp->mVisible) { + nsStyleColor* myColor = + (nsStyleColor*)mStyleContext->GetData(eStyleStruct_Color); + nsStyleSpacing* mySpacing = + (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; } diff --git a/mozilla/layout/html/base/src/nsListItemFrame.cpp b/mozilla/layout/html/base/src/nsListItemFrame.cpp index 77082b791c2..a4f531c2b95 100644 --- a/mozilla/layout/html/base/src/nsListItemFrame.cpp +++ b/mozilla/layout/html/base/src/nsListItemFrame.cpp @@ -86,42 +86,47 @@ NS_METHOD BulletFrame::Paint(nsIPresContext& aCX, nsIRenderingContext& aRenderingContext, const nsRect& aDirtyRect) { - 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); + nsStyleDisplay* disp = + (nsStyleDisplay*)mStyleContext->GetData(eStyleStruct_Display); - 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; - switch (myList->mListStyleType) { - case NS_STYLE_LIST_STYLE_NONE: - break; + nscoord pad; - case NS_STYLE_LIST_STYLE_DISC: - case NS_STYLE_LIST_STYLE_CIRCLE: - case NS_STYLE_LIST_STYLE_SQUARE: - pad = PAD_DISC; - aRenderingContext.SetColor(myColor->mColor); - aRenderingContext.FillRect(pad, pad, mRect.width - (pad + pad), - mRect.height - (pad + pad));/* XXX */ - break; + nsAutoString text; + switch (myList->mListStyleType) { + case NS_STYLE_LIST_STYLE_NONE: + 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; + case NS_STYLE_LIST_STYLE_DISC: + case NS_STYLE_LIST_STYLE_CIRCLE: + case NS_STYLE_LIST_STYLE_SQUARE: + pad = PAD_DISC; + 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_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; } diff --git a/mozilla/layout/html/base/src/nsTextContent.cpp b/mozilla/layout/html/base/src/nsTextContent.cpp index bf5bea9ddbd..c3f7244ca69 100644 --- a/mozilla/layout/html/base/src/nsTextContent.cpp +++ b/mozilla/layout/html/base/src/nsTextContent.cpp @@ -431,31 +431,36 @@ NS_METHOD TextFrame::Paint(nsIPresContext& aPresContext, return NS_OK; } - // Get style data - nsStyleColor* color = - (nsStyleColor*)mStyleContext->GetData(eStyleStruct_Color); - nsStyleFont* font = - (nsStyleFont*)mStyleContext->GetData(eStyleStruct_Font); + nsStyleDisplay* disp = + (nsStyleDisplay*)mStyleContext->GetData(eStyleStruct_Display); - // Set font and color - aRenderingContext.SetColor(color->mColor); - aRenderingContext.SetFont(font->mFont); + if (disp->mVisible) { + // Get style data + nsStyleColor* color = + (nsStyleColor*)mStyleContext->GetData(eStyleStruct_Color); + nsStyleFont* font = + (nsStyleFont*)mStyleContext->GetData(eStyleStruct_Font); - if (nsnull != mWords) { - PaintJustifiedText(aRenderingContext, aDirtyRect, 0, 0); + // Set font and color + 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) { nscoord onePixel = nscoord(1.0f * aPresContext.GetPixelsToTwips()); 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;