From 97e6e61f3c03c5da084b6cba522cca966588d3db Mon Sep 17 00:00:00 2001 From: "putterman%netscape.com" Date: Mon, 24 Apr 2000 22:15:55 +0000 Subject: [PATCH] Backing out troy's changes to fix various UI blocker bugs. git-svn-id: svn://10.0.0.236/trunk@66999 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/content/base/src/nsStyleContext.cpp | 2 +- mozilla/layout/base/nsPresShell.cpp | 55 ------------------ mozilla/layout/base/src/nsStyleContext.cpp | 2 +- mozilla/layout/forms/nsImageControlFrame.cpp | 2 +- mozilla/layout/generic/nsBlockFrame.cpp | 15 +++-- .../layout/generic/nsBlockReflowContext.cpp | 19 +----- mozilla/layout/generic/nsBlockReflowState.cpp | 15 +++-- mozilla/layout/generic/nsBlockReflowState.h | 15 +++-- mozilla/layout/generic/nsFrame.cpp | 41 +++++++------ mozilla/layout/generic/nsFrame.h | 9 ++- mozilla/layout/generic/nsFrameSetFrame.cpp | 2 +- .../layout/generic/nsHTMLContainerFrame.cpp | 58 ++++++------------- mozilla/layout/generic/nsImageFrame.cpp | 10 ++++ mozilla/layout/generic/nsObjectFrame.cpp | 3 +- mozilla/layout/html/base/src/nsBlockFrame.cpp | 15 +++-- .../html/base/src/nsBlockReflowContext.cpp | 19 +----- .../html/base/src/nsBlockReflowState.cpp | 15 +++-- .../layout/html/base/src/nsBlockReflowState.h | 15 +++-- mozilla/layout/html/base/src/nsFrame.cpp | 41 +++++++------ mozilla/layout/html/base/src/nsFrame.h | 9 ++- .../html/base/src/nsHTMLContainerFrame.cpp | 58 ++++++------------- mozilla/layout/html/base/src/nsImageFrame.cpp | 10 ++++ .../layout/html/base/src/nsObjectFrame.cpp | 3 +- mozilla/layout/html/base/src/nsPresShell.cpp | 55 ------------------ .../layout/html/base/src/nsScrollFrame.cpp | 2 +- .../html/base/src/nsScrollPortFrame.cpp | 2 +- .../html/document/src/nsFrameSetFrame.cpp | 2 +- .../html/forms/src/nsImageControlFrame.cpp | 2 +- .../layout/html/forms/src/nsLabelFrame.cpp | 2 +- mozilla/layout/style/nsStyleContext.cpp | 2 +- 30 files changed, 168 insertions(+), 332 deletions(-) diff --git a/mozilla/content/base/src/nsStyleContext.cpp b/mozilla/content/base/src/nsStyleContext.cpp index 0f7073218db..1f04a34d318 100644 --- a/mozilla/content/base/src/nsStyleContext.cpp +++ b/mozilla/content/base/src/nsStyleContext.cpp @@ -1031,7 +1031,7 @@ void StyleDisplayImpl::ResetFrom(const nsStyleDisplay* aParent, nsIPresContext* mBreakAfter = PR_FALSE; mOverflow = NS_STYLE_OVERFLOW_VISIBLE; mClipFlags = NS_STYLE_CLIP_AUTO; - mClip.SetRect(0,0,0,0); + mClip.SizeTo(0,0,0,0); } void StyleDisplayImpl::SetFrom(const nsStyleDisplay& aSource) diff --git a/mozilla/layout/base/nsPresShell.cpp b/mozilla/layout/base/nsPresShell.cpp index d7fafc58c51..e4fb3850b97 100644 --- a/mozilla/layout/base/nsPresShell.cpp +++ b/mozilla/layout/base/nsPresShell.cpp @@ -3072,53 +3072,6 @@ PresShell::GetPlaceholderFrameFor(nsIFrame* aFrame, //nsIViewObserver -// If the element is absolutely positioned and has a specified clip rect -// then it pushes the current rendering context and sets the clip rect. -// Returns PR_TRUE if the clip rect is set and PR_FALSE otherwise -static PRBool -SetClipRect(nsIRenderingContext& aRenderingContext, nsIFrame* aFrame) -{ - PRBool clipState; - const nsStyleDisplay* display; - aFrame->GetStyleData(eStyleStruct_Display, (const nsStyleStruct*&) display); - const nsStylePosition* position; - aFrame->GetStyleData(eStyleStruct_Position, (const nsStyleStruct*&) position); - - // 'clip' only applies to absolutely positioned elements, and is - // relative to the element's border edge. 'clip' applies to the entire - // element: border, padding, and content areas, and even scrollbars if - // there are any. - if (position->IsAbsolutelyPositioned() && (display->mClipFlags & NS_STYLE_CLIP_RECT)) { - nsSize size; - - // Start with the 'auto' values and then factor in user specified values - aFrame->GetSize(size); - nsRect clipRect(0, 0, size.width, size.height); - - if (display->mClipFlags & NS_STYLE_CLIP_RECT) { - if (0 == (NS_STYLE_CLIP_TOP_AUTO & display->mClipFlags)) { - clipRect.y = display->mClip.y; - } - if (0 == (NS_STYLE_CLIP_LEFT_AUTO & display->mClipFlags)) { - clipRect.x = display->mClip.x; - } - if (0 == (NS_STYLE_CLIP_RIGHT_AUTO & display->mClipFlags)) { - clipRect.width = clipRect.x + display->mClip.width; - } - if (0 == (NS_STYLE_CLIP_BOTTOM_AUTO & display->mClipFlags)) { - clipRect.height = clipRect.y + display->mClip.height; - } - } - - // Set updated clip-rect into the rendering context - aRenderingContext.PushState(); - aRenderingContext.SetClipRect(clipRect, nsClipCombine_kIntersect, clipState); - return PR_TRUE; - } - - return PR_FALSE; -} - NS_IMETHODIMP PresShell::Paint(nsIView *aView, nsIRenderingContext& aRenderingContext, @@ -3137,10 +3090,6 @@ PresShell::Paint(nsIView *aView, { StCaretHider caretHider(this); // stack-based class hides caret until dtor. - // If the frame is absolutely positioned, then the 'clip' property - // applies - PRBool setClipRect = SetClipRect(aRenderingContext, frame); - rv = frame->Paint(mPresContext, aRenderingContext, aDirtyRect, NS_FRAME_PAINT_LAYER_BACKGROUND); rv = frame->Paint(mPresContext, aRenderingContext, aDirtyRect, @@ -3148,10 +3097,6 @@ PresShell::Paint(nsIView *aView, rv = frame->Paint(mPresContext, aRenderingContext, aDirtyRect, NS_FRAME_PAINT_LAYER_FOREGROUND); - if (setClipRect) { - PRBool clipState; - aRenderingContext.PopState(clipState); - } #ifdef NS_DEBUG // Draw a border around the frame diff --git a/mozilla/layout/base/src/nsStyleContext.cpp b/mozilla/layout/base/src/nsStyleContext.cpp index 0f7073218db..1f04a34d318 100644 --- a/mozilla/layout/base/src/nsStyleContext.cpp +++ b/mozilla/layout/base/src/nsStyleContext.cpp @@ -1031,7 +1031,7 @@ void StyleDisplayImpl::ResetFrom(const nsStyleDisplay* aParent, nsIPresContext* mBreakAfter = PR_FALSE; mOverflow = NS_STYLE_OVERFLOW_VISIBLE; mClipFlags = NS_STYLE_CLIP_AUTO; - mClip.SetRect(0,0,0,0); + mClip.SizeTo(0,0,0,0); } void StyleDisplayImpl::SetFrom(const nsStyleDisplay& aSource) diff --git a/mozilla/layout/forms/nsImageControlFrame.cpp b/mozilla/layout/forms/nsImageControlFrame.cpp index 0245c9dcf2a..77423257fe1 100644 --- a/mozilla/layout/forms/nsImageControlFrame.cpp +++ b/mozilla/layout/forms/nsImageControlFrame.cpp @@ -240,7 +240,7 @@ nsImageControlFrame::Init(nsIPresContext* aPresContext, parWithView->GetView(aPresContext, &parView); // the view's size is not know yet, but its size will be kept in synch with our frame. nsRect boundBox(0, 0, 0, 0); - result = view->Init(viewMan, boundBox, parView); + result = view->Init(viewMan, boundBox, parView, nsnull); view->SetContentTransparency(PR_TRUE); viewMan->InsertChild(parView, view, 0); SetView(aPresContext, view); diff --git a/mozilla/layout/generic/nsBlockFrame.cpp b/mozilla/layout/generic/nsBlockFrame.cpp index 855486d5c02..dfca9ab439e 100644 --- a/mozilla/layout/generic/nsBlockFrame.cpp +++ b/mozilla/layout/generic/nsBlockFrame.cpp @@ -5929,6 +5929,13 @@ nsBlockFrame::Paint(nsIPresContext* aPresContext, const nsStyleDisplay* disp = (const nsStyleDisplay*) mStyleContext->GetStyleData(eStyleStruct_Display); + // If overflow is hidden then set the clip rect so that children + // don't leak out of us + if (NS_STYLE_OVERFLOW_HIDDEN == disp->mOverflow) { + aRenderingContext.PushState(); + SetClipRect(aRenderingContext); + } + // Only paint the border and background if we're visible if (disp->IsVisible() && (NS_FRAME_PAINT_LAYER_BACKGROUND == aWhichLayer) && (0 != mRect.width) && (0 != mRect.height)) { @@ -5949,14 +5956,6 @@ nsBlockFrame::Paint(nsIPresContext* aPresContext, aDirtyRect, rect, *spacing, mStyleContext, 0); } - // If overflow is hidden then set the clip rect so that children don't - // leak out of us. Note that because overflow'-clip' only applies to - // the content area we do this after painting the border and background - if (NS_STYLE_OVERFLOW_HIDDEN == disp->mOverflow) { - aRenderingContext.PushState(); - SetOverflowClipRect(aRenderingContext); - } - // Child elements have the opportunity to override the visibility // property and display even if the parent is hidden if (NS_FRAME_PAINT_LAYER_FLOATERS == aWhichLayer) { diff --git a/mozilla/layout/generic/nsBlockReflowContext.cpp b/mozilla/layout/generic/nsBlockReflowContext.cpp index 33dfb1e7b22..8b2d17b0da8 100644 --- a/mozilla/layout/generic/nsBlockReflowContext.cpp +++ b/mozilla/layout/generic/nsBlockReflowContext.cpp @@ -449,23 +449,10 @@ nsBlockReflowContext::ReflowBlock(nsIFrame* aFrame, // width reflowState.availableWidth = oldAvailableWidth; reflowState.mComputedWidth = oldComputedWidth; - - // We don't need to do this second reflow if we're being reflowed - // with an unconstrained reflow - if (NS_UNCONSTRAINEDSIZE != reflowState.availableWidth) { - reason = eReflowReason_Resize; - // Don't bother having the frame compute its max-element-size again - nsSize* oldMaxElementSize = mMetrics.maxElementSize; - mMetrics.maxElementSize = nsnull; - rv = aFrame->Reflow(mPresContext, mMetrics, reflowState, - aFrameReflowStatus); - mMetrics.maxElementSize = oldMaxElementSize; - } - - } else { - rv = aFrame->Reflow(mPresContext, mMetrics, reflowState, - aFrameReflowStatus); + reason = eReflowReason_Resize; } + rv = aFrame->Reflow(mPresContext, mMetrics, reflowState, + aFrameReflowStatus); mOuterReflowState.mSpaceManager->Translate(-tx, -ty); #ifdef DEBUG diff --git a/mozilla/layout/generic/nsBlockReflowState.cpp b/mozilla/layout/generic/nsBlockReflowState.cpp index 855486d5c02..dfca9ab439e 100644 --- a/mozilla/layout/generic/nsBlockReflowState.cpp +++ b/mozilla/layout/generic/nsBlockReflowState.cpp @@ -5929,6 +5929,13 @@ nsBlockFrame::Paint(nsIPresContext* aPresContext, const nsStyleDisplay* disp = (const nsStyleDisplay*) mStyleContext->GetStyleData(eStyleStruct_Display); + // If overflow is hidden then set the clip rect so that children + // don't leak out of us + if (NS_STYLE_OVERFLOW_HIDDEN == disp->mOverflow) { + aRenderingContext.PushState(); + SetClipRect(aRenderingContext); + } + // Only paint the border and background if we're visible if (disp->IsVisible() && (NS_FRAME_PAINT_LAYER_BACKGROUND == aWhichLayer) && (0 != mRect.width) && (0 != mRect.height)) { @@ -5949,14 +5956,6 @@ nsBlockFrame::Paint(nsIPresContext* aPresContext, aDirtyRect, rect, *spacing, mStyleContext, 0); } - // If overflow is hidden then set the clip rect so that children don't - // leak out of us. Note that because overflow'-clip' only applies to - // the content area we do this after painting the border and background - if (NS_STYLE_OVERFLOW_HIDDEN == disp->mOverflow) { - aRenderingContext.PushState(); - SetOverflowClipRect(aRenderingContext); - } - // Child elements have the opportunity to override the visibility // property and display even if the parent is hidden if (NS_FRAME_PAINT_LAYER_FLOATERS == aWhichLayer) { diff --git a/mozilla/layout/generic/nsBlockReflowState.h b/mozilla/layout/generic/nsBlockReflowState.h index 855486d5c02..dfca9ab439e 100644 --- a/mozilla/layout/generic/nsBlockReflowState.h +++ b/mozilla/layout/generic/nsBlockReflowState.h @@ -5929,6 +5929,13 @@ nsBlockFrame::Paint(nsIPresContext* aPresContext, const nsStyleDisplay* disp = (const nsStyleDisplay*) mStyleContext->GetStyleData(eStyleStruct_Display); + // If overflow is hidden then set the clip rect so that children + // don't leak out of us + if (NS_STYLE_OVERFLOW_HIDDEN == disp->mOverflow) { + aRenderingContext.PushState(); + SetClipRect(aRenderingContext); + } + // Only paint the border and background if we're visible if (disp->IsVisible() && (NS_FRAME_PAINT_LAYER_BACKGROUND == aWhichLayer) && (0 != mRect.width) && (0 != mRect.height)) { @@ -5949,14 +5956,6 @@ nsBlockFrame::Paint(nsIPresContext* aPresContext, aDirtyRect, rect, *spacing, mStyleContext, 0); } - // If overflow is hidden then set the clip rect so that children don't - // leak out of us. Note that because overflow'-clip' only applies to - // the content area we do this after painting the border and background - if (NS_STYLE_OVERFLOW_HIDDEN == disp->mOverflow) { - aRenderingContext.PushState(); - SetOverflowClipRect(aRenderingContext); - } - // Child elements have the opportunity to override the visibility // property and display even if the parent is hidden if (NS_FRAME_PAINT_LAYER_FLOATERS == aWhichLayer) { diff --git a/mozilla/layout/generic/nsFrame.cpp b/mozilla/layout/generic/nsFrame.cpp index 33292094a2f..80e42cd76cf 100644 --- a/mozilla/layout/generic/nsFrame.cpp +++ b/mozilla/layout/generic/nsFrame.cpp @@ -615,30 +615,33 @@ nsFrame::DisplaySelection(nsIPresContext* aPresContext, PRBool isOkToTurnOn) } void -nsFrame::SetOverflowClipRect(nsIRenderingContext& aRenderingContext) +nsFrame::SetClipRect(nsIRenderingContext& aRenderingContext) { - // 'overflow-clip' only applies to block-level elements and replaced - // elements that have 'overflow' set to 'hidden', and it is relative - // to the content area and applies to content only (not border or background) - const nsStyleSpacing* spacing; - GetStyleData(eStyleStruct_Spacing, (const nsStyleStruct*&)spacing); - - // Start with the 'auto' values and then factor in user specified values - nsRect clipRect(0, 0, mRect.width, mRect.height); + PRBool clipState; + const nsStyleDisplay* display; + GetStyleData(eStyleStruct_Display, (const nsStyleStruct*&) display); - // XXX We don't support the 'overflow-clip' property yet, so just use the - // content area (which is the default value) as the clip shape - nsMargin border, padding; - - spacing->GetBorder(border); - clipRect.Deflate(border); - // XXX We need to handle percentage padding - if (spacing->GetPadding(padding)) { - clipRect.Deflate(padding); + // Start with the auto version of the clip rect. Then overlay on top + // of it specific offsets. + nscoord top = 0; + nscoord right = mRect.width; + nscoord bottom = mRect.height; + nscoord left = 0; + if (0 == (NS_STYLE_CLIP_TOP_AUTO & display->mClipFlags)) { + top += display->mClip.top; + } + if (0 == (NS_STYLE_CLIP_RIGHT_AUTO & display->mClipFlags)) { + right -= display->mClip.right; + } + if (0 == (NS_STYLE_CLIP_BOTTOM_AUTO & display->mClipFlags)) { + bottom -= display->mClip.bottom; + } + if (0 == (NS_STYLE_CLIP_LEFT_AUTO & display->mClipFlags)) { + left += display->mClip.left; } // Set updated clip-rect into the rendering context - PRBool clipState; + nsRect clipRect(left, top, right - left, bottom - top); aRenderingContext.SetClipRect(clipRect, nsClipCombine_kIntersect, clipState); } diff --git a/mozilla/layout/generic/nsFrame.h b/mozilla/layout/generic/nsFrame.h index 0bb9549fedd..3014e71796a 100644 --- a/mozilla/layout/generic/nsFrame.h +++ b/mozilla/layout/generic/nsFrame.h @@ -423,11 +423,10 @@ protected: virtual PRBool ParentDisablesSelection() const; - // Set the overflow clip rect into the rendering-context. Used for block-level - // elements and replaced elements that have 'overflow' set to 'hidden'. This - // member function assumes that the caller has checked that the clip property - // applies to its situation. - void SetOverflowClipRect(nsIRenderingContext& aRenderingContext); + // Set the clip rect into the rendering-context after applying CSS's + // clip property. This method assumes that the caller has checked + // that the clip property applies to its situation. + void SetClipRect(nsIRenderingContext& aRenderingContext); nsRect mRect; nsIContent* mContent; diff --git a/mozilla/layout/generic/nsFrameSetFrame.cpp b/mozilla/layout/generic/nsFrameSetFrame.cpp index 96ec6f1b73b..d8e1e176db0 100644 --- a/mozilla/layout/generic/nsFrameSetFrame.cpp +++ b/mozilla/layout/generic/nsFrameSetFrame.cpp @@ -275,7 +275,7 @@ nsHTMLFramesetFrame::Init(nsIPresContext* aPresContext, GetParentWithView(aPresContext, &parWithView); parWithView->GetView(aPresContext, &parView); nsRect boundBox(0, 0, 0, 0); - result = view->Init(viewMan, boundBox, parView); + result = view->Init(viewMan, boundBox, parView, nsnull); viewMan->InsertChild(parView, view, 0); SetView(aPresContext, view); diff --git a/mozilla/layout/generic/nsHTMLContainerFrame.cpp b/mozilla/layout/generic/nsHTMLContainerFrame.cpp index b09383223af..58de574e25b 100644 --- a/mozilla/layout/generic/nsHTMLContainerFrame.cpp +++ b/mozilla/layout/generic/nsHTMLContainerFrame.cpp @@ -377,21 +377,6 @@ nsHTMLContainerFrame::ReparentFrameViewList(nsIPresContext* aPresContext, return NS_OK; } -static PRBool -IsContainerContent(nsIFrame* aFrame) -{ - nsIContent* content; - PRBool result = PR_FALSE; - - aFrame->GetContent(&content); - if (content) { - content->CanContainChildren(result); - NS_RELEASE(content); - } - - return result; -} - nsresult nsHTMLContainerFrame::CreateViewForFrame(nsIPresContext* aPresContext, nsIFrame* aFrame, @@ -473,23 +458,6 @@ nsHTMLContainerFrame::CreateViewForFrame(nsIPresContext* aPresContext, NS_IF_RELEASE(pseudoTag); } - // See if the frame is block-level and has 'overflow' set to 'hidden'. If - // so and it can have child frames, then we need to give it a view so clipping - // of any child views works correctly. Note that if it's floated it is also - // block-level, but we can't trust that the style context 'display' value is - // set correctly - if (!aForce) { - if ((display->IsBlockLevel() || display->IsFloating()) && - (display->mOverflow == NS_STYLE_OVERFLOW_HIDDEN)) { - - // The reason for the check of whether it can contain children is just - // to avoid giving it a view unnecessarily - if (::IsContainerContent(aFrame)) { - aForce = PR_TRUE; - } - } - } - if (aForce) { // Create a view nsIFrame* parent; @@ -560,18 +528,26 @@ nsHTMLContainerFrame::CreateViewForFrame(nsIPresContext* aPresContext, // If it's a container element, then leave the view visible, but // mark it as having transparent content. The reason we need to // do this is that child elements can override their parent's - // hidden visibility and be visible anyway. - // + // hidden visibility and be visible anyway + nsIContent* content; + // Because this function is called before processing the content // object's child elements, we can't tell if it's a leaf by looking // at whether the frame has any child frames - if (::IsContainerContent(aFrame)) { - // The view needs to be visible, but marked as having transparent - // content - viewHasTransparentContent = PR_TRUE; - } else { - // Go ahead and hide the view - viewIsVisible = PR_FALSE; + aFrame->GetContent(&content); + if (content) { + PRBool isContainer; + + content->CanContainChildren(isContainer); + if (isContainer) { + // The view needs to be visible, but marked as having transparent + // content + viewHasTransparentContent = PR_TRUE; + } else { + // Go ahead and hide the view + viewIsVisible = PR_FALSE; + } + NS_RELEASE(content); } } } diff --git a/mozilla/layout/generic/nsImageFrame.cpp b/mozilla/layout/generic/nsImageFrame.cpp index 806cf2cce0a..85ee628c48d 100644 --- a/mozilla/layout/generic/nsImageFrame.cpp +++ b/mozilla/layout/generic/nsImageFrame.cpp @@ -559,6 +559,11 @@ nsImageFrame::Paint(nsIPresContext* aPresContext, const nsStyleDisplay* disp = (const nsStyleDisplay*) mStyleContext->GetStyleData(eStyleStruct_Display); if (disp->IsVisible() && mRect.width && mRect.height) { + if (NS_STYLE_OVERFLOW_HIDDEN == disp->mOverflow) { + aRenderingContext.PushState(); + SetClipRect(aRenderingContext); + } + // First paint background and borders nsLeafFrame::Paint(aPresContext, aRenderingContext, aDirtyRect, aWhichLayer); @@ -634,6 +639,11 @@ nsImageFrame::Paint(nsIPresContext* aPresContext, NS_IF_RELEASE(lowImage); NS_IF_RELEASE(image); + + if (NS_STYLE_OVERFLOW_HIDDEN == disp->mOverflow) { + PRBool clipState; + aRenderingContext.PopState(clipState); + } } return nsFrame::Paint(aPresContext, aRenderingContext, aDirtyRect, aWhichLayer); diff --git a/mozilla/layout/generic/nsObjectFrame.cpp b/mozilla/layout/generic/nsObjectFrame.cpp index 758436c8b6b..f03aa601d13 100644 --- a/mozilla/layout/generic/nsObjectFrame.cpp +++ b/mozilla/layout/generic/nsObjectFrame.cpp @@ -377,7 +377,8 @@ nsObjectFrame::CreateWidget(nsIPresContext* aPresContext, { // nsWidgetInitData* initData = GetWidgetInitData(aPresContext); // needs to be deleted // initialize the view as hidden since we don't know the (x,y) until Paint - result = view->Init(viewMan, boundBox, parView, nsViewVisibility_kHide); + result = view->Init(viewMan, boundBox, parView, nsnull, + nsViewVisibility_kHide); // if (nsnull != initData) { // delete(initData); // } diff --git a/mozilla/layout/html/base/src/nsBlockFrame.cpp b/mozilla/layout/html/base/src/nsBlockFrame.cpp index 855486d5c02..dfca9ab439e 100644 --- a/mozilla/layout/html/base/src/nsBlockFrame.cpp +++ b/mozilla/layout/html/base/src/nsBlockFrame.cpp @@ -5929,6 +5929,13 @@ nsBlockFrame::Paint(nsIPresContext* aPresContext, const nsStyleDisplay* disp = (const nsStyleDisplay*) mStyleContext->GetStyleData(eStyleStruct_Display); + // If overflow is hidden then set the clip rect so that children + // don't leak out of us + if (NS_STYLE_OVERFLOW_HIDDEN == disp->mOverflow) { + aRenderingContext.PushState(); + SetClipRect(aRenderingContext); + } + // Only paint the border and background if we're visible if (disp->IsVisible() && (NS_FRAME_PAINT_LAYER_BACKGROUND == aWhichLayer) && (0 != mRect.width) && (0 != mRect.height)) { @@ -5949,14 +5956,6 @@ nsBlockFrame::Paint(nsIPresContext* aPresContext, aDirtyRect, rect, *spacing, mStyleContext, 0); } - // If overflow is hidden then set the clip rect so that children don't - // leak out of us. Note that because overflow'-clip' only applies to - // the content area we do this after painting the border and background - if (NS_STYLE_OVERFLOW_HIDDEN == disp->mOverflow) { - aRenderingContext.PushState(); - SetOverflowClipRect(aRenderingContext); - } - // Child elements have the opportunity to override the visibility // property and display even if the parent is hidden if (NS_FRAME_PAINT_LAYER_FLOATERS == aWhichLayer) { diff --git a/mozilla/layout/html/base/src/nsBlockReflowContext.cpp b/mozilla/layout/html/base/src/nsBlockReflowContext.cpp index 33dfb1e7b22..8b2d17b0da8 100644 --- a/mozilla/layout/html/base/src/nsBlockReflowContext.cpp +++ b/mozilla/layout/html/base/src/nsBlockReflowContext.cpp @@ -449,23 +449,10 @@ nsBlockReflowContext::ReflowBlock(nsIFrame* aFrame, // width reflowState.availableWidth = oldAvailableWidth; reflowState.mComputedWidth = oldComputedWidth; - - // We don't need to do this second reflow if we're being reflowed - // with an unconstrained reflow - if (NS_UNCONSTRAINEDSIZE != reflowState.availableWidth) { - reason = eReflowReason_Resize; - // Don't bother having the frame compute its max-element-size again - nsSize* oldMaxElementSize = mMetrics.maxElementSize; - mMetrics.maxElementSize = nsnull; - rv = aFrame->Reflow(mPresContext, mMetrics, reflowState, - aFrameReflowStatus); - mMetrics.maxElementSize = oldMaxElementSize; - } - - } else { - rv = aFrame->Reflow(mPresContext, mMetrics, reflowState, - aFrameReflowStatus); + reason = eReflowReason_Resize; } + rv = aFrame->Reflow(mPresContext, mMetrics, reflowState, + aFrameReflowStatus); mOuterReflowState.mSpaceManager->Translate(-tx, -ty); #ifdef DEBUG diff --git a/mozilla/layout/html/base/src/nsBlockReflowState.cpp b/mozilla/layout/html/base/src/nsBlockReflowState.cpp index 855486d5c02..dfca9ab439e 100644 --- a/mozilla/layout/html/base/src/nsBlockReflowState.cpp +++ b/mozilla/layout/html/base/src/nsBlockReflowState.cpp @@ -5929,6 +5929,13 @@ nsBlockFrame::Paint(nsIPresContext* aPresContext, const nsStyleDisplay* disp = (const nsStyleDisplay*) mStyleContext->GetStyleData(eStyleStruct_Display); + // If overflow is hidden then set the clip rect so that children + // don't leak out of us + if (NS_STYLE_OVERFLOW_HIDDEN == disp->mOverflow) { + aRenderingContext.PushState(); + SetClipRect(aRenderingContext); + } + // Only paint the border and background if we're visible if (disp->IsVisible() && (NS_FRAME_PAINT_LAYER_BACKGROUND == aWhichLayer) && (0 != mRect.width) && (0 != mRect.height)) { @@ -5949,14 +5956,6 @@ nsBlockFrame::Paint(nsIPresContext* aPresContext, aDirtyRect, rect, *spacing, mStyleContext, 0); } - // If overflow is hidden then set the clip rect so that children don't - // leak out of us. Note that because overflow'-clip' only applies to - // the content area we do this after painting the border and background - if (NS_STYLE_OVERFLOW_HIDDEN == disp->mOverflow) { - aRenderingContext.PushState(); - SetOverflowClipRect(aRenderingContext); - } - // Child elements have the opportunity to override the visibility // property and display even if the parent is hidden if (NS_FRAME_PAINT_LAYER_FLOATERS == aWhichLayer) { diff --git a/mozilla/layout/html/base/src/nsBlockReflowState.h b/mozilla/layout/html/base/src/nsBlockReflowState.h index 855486d5c02..dfca9ab439e 100644 --- a/mozilla/layout/html/base/src/nsBlockReflowState.h +++ b/mozilla/layout/html/base/src/nsBlockReflowState.h @@ -5929,6 +5929,13 @@ nsBlockFrame::Paint(nsIPresContext* aPresContext, const nsStyleDisplay* disp = (const nsStyleDisplay*) mStyleContext->GetStyleData(eStyleStruct_Display); + // If overflow is hidden then set the clip rect so that children + // don't leak out of us + if (NS_STYLE_OVERFLOW_HIDDEN == disp->mOverflow) { + aRenderingContext.PushState(); + SetClipRect(aRenderingContext); + } + // Only paint the border and background if we're visible if (disp->IsVisible() && (NS_FRAME_PAINT_LAYER_BACKGROUND == aWhichLayer) && (0 != mRect.width) && (0 != mRect.height)) { @@ -5949,14 +5956,6 @@ nsBlockFrame::Paint(nsIPresContext* aPresContext, aDirtyRect, rect, *spacing, mStyleContext, 0); } - // If overflow is hidden then set the clip rect so that children don't - // leak out of us. Note that because overflow'-clip' only applies to - // the content area we do this after painting the border and background - if (NS_STYLE_OVERFLOW_HIDDEN == disp->mOverflow) { - aRenderingContext.PushState(); - SetOverflowClipRect(aRenderingContext); - } - // Child elements have the opportunity to override the visibility // property and display even if the parent is hidden if (NS_FRAME_PAINT_LAYER_FLOATERS == aWhichLayer) { diff --git a/mozilla/layout/html/base/src/nsFrame.cpp b/mozilla/layout/html/base/src/nsFrame.cpp index 33292094a2f..80e42cd76cf 100644 --- a/mozilla/layout/html/base/src/nsFrame.cpp +++ b/mozilla/layout/html/base/src/nsFrame.cpp @@ -615,30 +615,33 @@ nsFrame::DisplaySelection(nsIPresContext* aPresContext, PRBool isOkToTurnOn) } void -nsFrame::SetOverflowClipRect(nsIRenderingContext& aRenderingContext) +nsFrame::SetClipRect(nsIRenderingContext& aRenderingContext) { - // 'overflow-clip' only applies to block-level elements and replaced - // elements that have 'overflow' set to 'hidden', and it is relative - // to the content area and applies to content only (not border or background) - const nsStyleSpacing* spacing; - GetStyleData(eStyleStruct_Spacing, (const nsStyleStruct*&)spacing); - - // Start with the 'auto' values and then factor in user specified values - nsRect clipRect(0, 0, mRect.width, mRect.height); + PRBool clipState; + const nsStyleDisplay* display; + GetStyleData(eStyleStruct_Display, (const nsStyleStruct*&) display); - // XXX We don't support the 'overflow-clip' property yet, so just use the - // content area (which is the default value) as the clip shape - nsMargin border, padding; - - spacing->GetBorder(border); - clipRect.Deflate(border); - // XXX We need to handle percentage padding - if (spacing->GetPadding(padding)) { - clipRect.Deflate(padding); + // Start with the auto version of the clip rect. Then overlay on top + // of it specific offsets. + nscoord top = 0; + nscoord right = mRect.width; + nscoord bottom = mRect.height; + nscoord left = 0; + if (0 == (NS_STYLE_CLIP_TOP_AUTO & display->mClipFlags)) { + top += display->mClip.top; + } + if (0 == (NS_STYLE_CLIP_RIGHT_AUTO & display->mClipFlags)) { + right -= display->mClip.right; + } + if (0 == (NS_STYLE_CLIP_BOTTOM_AUTO & display->mClipFlags)) { + bottom -= display->mClip.bottom; + } + if (0 == (NS_STYLE_CLIP_LEFT_AUTO & display->mClipFlags)) { + left += display->mClip.left; } // Set updated clip-rect into the rendering context - PRBool clipState; + nsRect clipRect(left, top, right - left, bottom - top); aRenderingContext.SetClipRect(clipRect, nsClipCombine_kIntersect, clipState); } diff --git a/mozilla/layout/html/base/src/nsFrame.h b/mozilla/layout/html/base/src/nsFrame.h index 0bb9549fedd..3014e71796a 100644 --- a/mozilla/layout/html/base/src/nsFrame.h +++ b/mozilla/layout/html/base/src/nsFrame.h @@ -423,11 +423,10 @@ protected: virtual PRBool ParentDisablesSelection() const; - // Set the overflow clip rect into the rendering-context. Used for block-level - // elements and replaced elements that have 'overflow' set to 'hidden'. This - // member function assumes that the caller has checked that the clip property - // applies to its situation. - void SetOverflowClipRect(nsIRenderingContext& aRenderingContext); + // Set the clip rect into the rendering-context after applying CSS's + // clip property. This method assumes that the caller has checked + // that the clip property applies to its situation. + void SetClipRect(nsIRenderingContext& aRenderingContext); nsRect mRect; nsIContent* mContent; diff --git a/mozilla/layout/html/base/src/nsHTMLContainerFrame.cpp b/mozilla/layout/html/base/src/nsHTMLContainerFrame.cpp index b09383223af..58de574e25b 100644 --- a/mozilla/layout/html/base/src/nsHTMLContainerFrame.cpp +++ b/mozilla/layout/html/base/src/nsHTMLContainerFrame.cpp @@ -377,21 +377,6 @@ nsHTMLContainerFrame::ReparentFrameViewList(nsIPresContext* aPresContext, return NS_OK; } -static PRBool -IsContainerContent(nsIFrame* aFrame) -{ - nsIContent* content; - PRBool result = PR_FALSE; - - aFrame->GetContent(&content); - if (content) { - content->CanContainChildren(result); - NS_RELEASE(content); - } - - return result; -} - nsresult nsHTMLContainerFrame::CreateViewForFrame(nsIPresContext* aPresContext, nsIFrame* aFrame, @@ -473,23 +458,6 @@ nsHTMLContainerFrame::CreateViewForFrame(nsIPresContext* aPresContext, NS_IF_RELEASE(pseudoTag); } - // See if the frame is block-level and has 'overflow' set to 'hidden'. If - // so and it can have child frames, then we need to give it a view so clipping - // of any child views works correctly. Note that if it's floated it is also - // block-level, but we can't trust that the style context 'display' value is - // set correctly - if (!aForce) { - if ((display->IsBlockLevel() || display->IsFloating()) && - (display->mOverflow == NS_STYLE_OVERFLOW_HIDDEN)) { - - // The reason for the check of whether it can contain children is just - // to avoid giving it a view unnecessarily - if (::IsContainerContent(aFrame)) { - aForce = PR_TRUE; - } - } - } - if (aForce) { // Create a view nsIFrame* parent; @@ -560,18 +528,26 @@ nsHTMLContainerFrame::CreateViewForFrame(nsIPresContext* aPresContext, // If it's a container element, then leave the view visible, but // mark it as having transparent content. The reason we need to // do this is that child elements can override their parent's - // hidden visibility and be visible anyway. - // + // hidden visibility and be visible anyway + nsIContent* content; + // Because this function is called before processing the content // object's child elements, we can't tell if it's a leaf by looking // at whether the frame has any child frames - if (::IsContainerContent(aFrame)) { - // The view needs to be visible, but marked as having transparent - // content - viewHasTransparentContent = PR_TRUE; - } else { - // Go ahead and hide the view - viewIsVisible = PR_FALSE; + aFrame->GetContent(&content); + if (content) { + PRBool isContainer; + + content->CanContainChildren(isContainer); + if (isContainer) { + // The view needs to be visible, but marked as having transparent + // content + viewHasTransparentContent = PR_TRUE; + } else { + // Go ahead and hide the view + viewIsVisible = PR_FALSE; + } + NS_RELEASE(content); } } } diff --git a/mozilla/layout/html/base/src/nsImageFrame.cpp b/mozilla/layout/html/base/src/nsImageFrame.cpp index 806cf2cce0a..85ee628c48d 100644 --- a/mozilla/layout/html/base/src/nsImageFrame.cpp +++ b/mozilla/layout/html/base/src/nsImageFrame.cpp @@ -559,6 +559,11 @@ nsImageFrame::Paint(nsIPresContext* aPresContext, const nsStyleDisplay* disp = (const nsStyleDisplay*) mStyleContext->GetStyleData(eStyleStruct_Display); if (disp->IsVisible() && mRect.width && mRect.height) { + if (NS_STYLE_OVERFLOW_HIDDEN == disp->mOverflow) { + aRenderingContext.PushState(); + SetClipRect(aRenderingContext); + } + // First paint background and borders nsLeafFrame::Paint(aPresContext, aRenderingContext, aDirtyRect, aWhichLayer); @@ -634,6 +639,11 @@ nsImageFrame::Paint(nsIPresContext* aPresContext, NS_IF_RELEASE(lowImage); NS_IF_RELEASE(image); + + if (NS_STYLE_OVERFLOW_HIDDEN == disp->mOverflow) { + PRBool clipState; + aRenderingContext.PopState(clipState); + } } return nsFrame::Paint(aPresContext, aRenderingContext, aDirtyRect, aWhichLayer); diff --git a/mozilla/layout/html/base/src/nsObjectFrame.cpp b/mozilla/layout/html/base/src/nsObjectFrame.cpp index 758436c8b6b..f03aa601d13 100644 --- a/mozilla/layout/html/base/src/nsObjectFrame.cpp +++ b/mozilla/layout/html/base/src/nsObjectFrame.cpp @@ -377,7 +377,8 @@ nsObjectFrame::CreateWidget(nsIPresContext* aPresContext, { // nsWidgetInitData* initData = GetWidgetInitData(aPresContext); // needs to be deleted // initialize the view as hidden since we don't know the (x,y) until Paint - result = view->Init(viewMan, boundBox, parView, nsViewVisibility_kHide); + result = view->Init(viewMan, boundBox, parView, nsnull, + nsViewVisibility_kHide); // if (nsnull != initData) { // delete(initData); // } diff --git a/mozilla/layout/html/base/src/nsPresShell.cpp b/mozilla/layout/html/base/src/nsPresShell.cpp index d7fafc58c51..e4fb3850b97 100644 --- a/mozilla/layout/html/base/src/nsPresShell.cpp +++ b/mozilla/layout/html/base/src/nsPresShell.cpp @@ -3072,53 +3072,6 @@ PresShell::GetPlaceholderFrameFor(nsIFrame* aFrame, //nsIViewObserver -// If the element is absolutely positioned and has a specified clip rect -// then it pushes the current rendering context and sets the clip rect. -// Returns PR_TRUE if the clip rect is set and PR_FALSE otherwise -static PRBool -SetClipRect(nsIRenderingContext& aRenderingContext, nsIFrame* aFrame) -{ - PRBool clipState; - const nsStyleDisplay* display; - aFrame->GetStyleData(eStyleStruct_Display, (const nsStyleStruct*&) display); - const nsStylePosition* position; - aFrame->GetStyleData(eStyleStruct_Position, (const nsStyleStruct*&) position); - - // 'clip' only applies to absolutely positioned elements, and is - // relative to the element's border edge. 'clip' applies to the entire - // element: border, padding, and content areas, and even scrollbars if - // there are any. - if (position->IsAbsolutelyPositioned() && (display->mClipFlags & NS_STYLE_CLIP_RECT)) { - nsSize size; - - // Start with the 'auto' values and then factor in user specified values - aFrame->GetSize(size); - nsRect clipRect(0, 0, size.width, size.height); - - if (display->mClipFlags & NS_STYLE_CLIP_RECT) { - if (0 == (NS_STYLE_CLIP_TOP_AUTO & display->mClipFlags)) { - clipRect.y = display->mClip.y; - } - if (0 == (NS_STYLE_CLIP_LEFT_AUTO & display->mClipFlags)) { - clipRect.x = display->mClip.x; - } - if (0 == (NS_STYLE_CLIP_RIGHT_AUTO & display->mClipFlags)) { - clipRect.width = clipRect.x + display->mClip.width; - } - if (0 == (NS_STYLE_CLIP_BOTTOM_AUTO & display->mClipFlags)) { - clipRect.height = clipRect.y + display->mClip.height; - } - } - - // Set updated clip-rect into the rendering context - aRenderingContext.PushState(); - aRenderingContext.SetClipRect(clipRect, nsClipCombine_kIntersect, clipState); - return PR_TRUE; - } - - return PR_FALSE; -} - NS_IMETHODIMP PresShell::Paint(nsIView *aView, nsIRenderingContext& aRenderingContext, @@ -3137,10 +3090,6 @@ PresShell::Paint(nsIView *aView, { StCaretHider caretHider(this); // stack-based class hides caret until dtor. - // If the frame is absolutely positioned, then the 'clip' property - // applies - PRBool setClipRect = SetClipRect(aRenderingContext, frame); - rv = frame->Paint(mPresContext, aRenderingContext, aDirtyRect, NS_FRAME_PAINT_LAYER_BACKGROUND); rv = frame->Paint(mPresContext, aRenderingContext, aDirtyRect, @@ -3148,10 +3097,6 @@ PresShell::Paint(nsIView *aView, rv = frame->Paint(mPresContext, aRenderingContext, aDirtyRect, NS_FRAME_PAINT_LAYER_FOREGROUND); - if (setClipRect) { - PRBool clipState; - aRenderingContext.PopState(clipState); - } #ifdef NS_DEBUG // Draw a border around the frame diff --git a/mozilla/layout/html/base/src/nsScrollFrame.cpp b/mozilla/layout/html/base/src/nsScrollFrame.cpp index 8b42831eb20..4e01367bb1b 100644 --- a/mozilla/layout/html/base/src/nsScrollFrame.cpp +++ b/mozilla/layout/html/base/src/nsScrollFrame.cpp @@ -329,7 +329,7 @@ nsScrollFrame::CreateScrollingView(nsIPresContext* aPresContext) } // Initialize the scrolling view - view->Init(viewManager, mRect, parentView, display->IsVisible()? + view->Init(viewManager, mRect, parentView, nsnull, display->IsVisible()? nsViewVisibility_kShow : nsViewVisibility_kHide); // Insert the view into the view hierarchy diff --git a/mozilla/layout/html/base/src/nsScrollPortFrame.cpp b/mozilla/layout/html/base/src/nsScrollPortFrame.cpp index 0f68eb06ec9..46f26bee117 100644 --- a/mozilla/layout/html/base/src/nsScrollPortFrame.cpp +++ b/mozilla/layout/html/base/src/nsScrollPortFrame.cpp @@ -232,7 +232,7 @@ nsScrollPortFrame::CreateScrollingView(nsIPresContext* aPresContext) } // Initialize the scrolling view - view->Init(viewManager, mRect, parentView, display->IsVisibleOrCollapsed() ? + view->Init(viewManager, mRect, parentView, nsnull, display->IsVisibleOrCollapsed() ? nsViewVisibility_kShow : nsViewVisibility_kHide); // Insert the view into the view hierarchy diff --git a/mozilla/layout/html/document/src/nsFrameSetFrame.cpp b/mozilla/layout/html/document/src/nsFrameSetFrame.cpp index 96ec6f1b73b..d8e1e176db0 100644 --- a/mozilla/layout/html/document/src/nsFrameSetFrame.cpp +++ b/mozilla/layout/html/document/src/nsFrameSetFrame.cpp @@ -275,7 +275,7 @@ nsHTMLFramesetFrame::Init(nsIPresContext* aPresContext, GetParentWithView(aPresContext, &parWithView); parWithView->GetView(aPresContext, &parView); nsRect boundBox(0, 0, 0, 0); - result = view->Init(viewMan, boundBox, parView); + result = view->Init(viewMan, boundBox, parView, nsnull); viewMan->InsertChild(parView, view, 0); SetView(aPresContext, view); diff --git a/mozilla/layout/html/forms/src/nsImageControlFrame.cpp b/mozilla/layout/html/forms/src/nsImageControlFrame.cpp index 0245c9dcf2a..77423257fe1 100644 --- a/mozilla/layout/html/forms/src/nsImageControlFrame.cpp +++ b/mozilla/layout/html/forms/src/nsImageControlFrame.cpp @@ -240,7 +240,7 @@ nsImageControlFrame::Init(nsIPresContext* aPresContext, parWithView->GetView(aPresContext, &parView); // the view's size is not know yet, but its size will be kept in synch with our frame. nsRect boundBox(0, 0, 0, 0); - result = view->Init(viewMan, boundBox, parView); + result = view->Init(viewMan, boundBox, parView, nsnull); view->SetContentTransparency(PR_TRUE); viewMan->InsertChild(parView, view, 0); SetView(aPresContext, view); diff --git a/mozilla/layout/html/forms/src/nsLabelFrame.cpp b/mozilla/layout/html/forms/src/nsLabelFrame.cpp index 3922f84944d..9aadd699488 100644 --- a/mozilla/layout/html/forms/src/nsLabelFrame.cpp +++ b/mozilla/layout/html/forms/src/nsLabelFrame.cpp @@ -518,7 +518,7 @@ nsLabelFrame::Init(nsIPresContext* aPresContext, parWithView->GetView(aPresContext, &parView); // the view's size is not know yet, but its size will be kept in synch with our frame. nsRect boundBox(0, 0, 0, 0); - result = view->Init(viewMan, boundBox, parView); + result = view->Init(viewMan, boundBox, parView, nsnull); view->SetContentTransparency(PR_TRUE); viewMan->InsertChild(parView, view, 0); SetView(aPresContext, view); diff --git a/mozilla/layout/style/nsStyleContext.cpp b/mozilla/layout/style/nsStyleContext.cpp index 0f7073218db..1f04a34d318 100644 --- a/mozilla/layout/style/nsStyleContext.cpp +++ b/mozilla/layout/style/nsStyleContext.cpp @@ -1031,7 +1031,7 @@ void StyleDisplayImpl::ResetFrom(const nsStyleDisplay* aParent, nsIPresContext* mBreakAfter = PR_FALSE; mOverflow = NS_STYLE_OVERFLOW_VISIBLE; mClipFlags = NS_STYLE_CLIP_AUTO; - mClip.SetRect(0,0,0,0); + mClip.SizeTo(0,0,0,0); } void StyleDisplayImpl::SetFrom(const nsStyleDisplay& aSource)