Changes to bring clipping inline with upcoming CSS2 errata

This commit is contained in:
troy%netscape.com 2000-04-23 00:56:16 +00:00
Родитель 529b908b63
Коммит 73fc3dde30
39 изменённых файлов: 432 добавлений и 328 удалений

Просмотреть файл

@ -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.SizeTo(0,0,0,0);
mClip.SetRect(0,0,0,0);
}
void StyleDisplayImpl::SetFrom(const nsStyleDisplay& aSource)

Просмотреть файл

@ -1912,35 +1912,37 @@ MapDeclarationDisplayInto(nsICSSDeclaration* aDeclaration,
display->mClipFlags = 0; // clear it
if (eCSSUnit_Auto == ourDisplay->mClip->mTop.GetUnit()) {
display->mClip.top = 0;
display->mClip.y = 0;
display->mClipFlags |= NS_STYLE_CLIP_TOP_AUTO;
}
else if (ourDisplay->mClip->mTop.IsLengthUnit()) {
display->mClip.top = CalcLength(ourDisplay->mClip->mTop, aFont->mFont, aPresContext);
fullAuto = PR_FALSE;
}
if (eCSSUnit_Auto == ourDisplay->mClip->mRight.GetUnit()) {
display->mClip.right = 0;
display->mClipFlags |= NS_STYLE_CLIP_RIGHT_AUTO;
}
else if (ourDisplay->mClip->mRight.IsLengthUnit()) {
display->mClip.right = CalcLength(ourDisplay->mClip->mRight, aFont->mFont, aPresContext);
display->mClip.y = CalcLength(ourDisplay->mClip->mTop, aFont->mFont, aPresContext);
fullAuto = PR_FALSE;
}
if (eCSSUnit_Auto == ourDisplay->mClip->mBottom.GetUnit()) {
display->mClip.bottom = 0;
display->mClip.height = 0;
display->mClipFlags |= NS_STYLE_CLIP_BOTTOM_AUTO;
}
else if (ourDisplay->mClip->mBottom.IsLengthUnit()) {
display->mClip.bottom = CalcLength(ourDisplay->mClip->mBottom, aFont->mFont, aPresContext);
display->mClip.height = CalcLength(ourDisplay->mClip->mBottom, aFont->mFont, aPresContext) -
display->mClip.y;
fullAuto = PR_FALSE;
}
if (eCSSUnit_Auto == ourDisplay->mClip->mLeft.GetUnit()) {
display->mClip.left = 0;
display->mClip.x = 0;
display->mClipFlags |= NS_STYLE_CLIP_LEFT_AUTO;
}
else if (ourDisplay->mClip->mLeft.IsLengthUnit()) {
display->mClip.left = CalcLength(ourDisplay->mClip->mLeft, aFont->mFont, aPresContext);
display->mClip.x = CalcLength(ourDisplay->mClip->mLeft, aFont->mFont, aPresContext);
fullAuto = PR_FALSE;
}
if (eCSSUnit_Auto == ourDisplay->mClip->mRight.GetUnit()) {
display->mClip.width = 0;
display->mClipFlags |= NS_STYLE_CLIP_RIGHT_AUTO;
}
else if (ourDisplay->mClip->mRight.IsLengthUnit()) {
display->mClip.width = CalcLength(ourDisplay->mClip->mRight, aFont->mFont, aPresContext) -
display->mClip.x;
fullAuto = PR_FALSE;
}
display->mClipFlags &= ~NS_STYLE_CLIP_TYPE_MASK;

Просмотреть файл

@ -3053,6 +3053,53 @@ 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,
@ -3071,6 +3118,10 @@ 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,
@ -3078,6 +3129,10 @@ 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

Просмотреть файл

@ -27,6 +27,7 @@
#include "nsColor.h"
#include "nsCoord.h"
#include "nsMargin.h"
#include "nsRect.h"
#include "nsFont.h"
#include "nsVoidArray.h"
#include "nsStyleCoord.h"
@ -163,6 +164,9 @@ struct nsStylePosition : public nsStyleStruct {
PRBool IsAbsolutelyPositioned() const {return (NS_STYLE_POSITION_ABSOLUTE == mPosition) ||
(NS_STYLE_POSITION_FIXED == mPosition);}
PRBool IsPositioned() const {return IsAbsolutelyPositioned() ||
(NS_STYLE_POSITION_RELATIVE == mPosition);}
};
struct nsStyleText : public nsStyleStruct {
@ -197,7 +201,14 @@ struct nsStyleDisplay : public nsStyleStruct {
PRUint8 mOverflow; // [reset] see nsStyleConsts.h
PRUint8 mClipFlags; // [reset] see nsStyleConsts.h
#if 0
// XXX This is how it is defined in the CSS2 spec, but the errata
// changed it to be consistent with the positioning draft and how
// Nav and IE implement it
nsMargin mClip; // [reset] offsets from respective edge
#else
nsRect mClip; // [reset] offsets from upper-left border edge
#endif
PRBool IsBlockLevel() const {return (NS_STYLE_DISPLAY_BLOCK == mDisplay) ||
(NS_STYLE_DISPLAY_LIST_ITEM == mDisplay) ||

Просмотреть файл

@ -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.SizeTo(0,0,0,0);
mClip.SetRect(0,0,0,0);
}
void StyleDisplayImpl::SetFrom(const nsStyleDisplay& aSource)

Просмотреть файл

@ -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, nsnull);
result = view->Init(viewMan, boundBox, parView);
view->SetContentTransparency(PR_TRUE);
viewMan->InsertChild(parView, view, 0);
SetView(aPresContext, view);

Просмотреть файл

@ -5929,13 +5929,6 @@ 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)) {
@ -5956,6 +5949,14 @@ 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) {

Просмотреть файл

@ -5929,13 +5929,6 @@ 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)) {
@ -5956,6 +5949,14 @@ 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) {

Просмотреть файл

@ -5929,13 +5929,6 @@ 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)) {
@ -5956,6 +5949,14 @@ 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) {

Просмотреть файл

@ -149,27 +149,11 @@ nsContainerFrame::PaintChildren(nsIPresContext* aPresContext,
const nsStyleDisplay* disp = (const nsStyleDisplay*)
mStyleContext->GetStyleData(eStyleStruct_Display);
// Child elements have the opportunity to override the visibility property
// of their parent and display even if the parent is hidden
PRBool clipState;
// 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();
aRenderingContext.SetClipRect(nsRect(0, 0, mRect.width, mRect.height),
nsClipCombine_kIntersect, clipState);
}
nsIFrame* kid = mFrames.FirstChild();
while (nsnull != kid) {
PaintChild(aPresContext, aRenderingContext, aDirtyRect, kid, aWhichLayer);
kid->GetNextSibling(&kid);
}
if (NS_STYLE_OVERFLOW_HIDDEN == disp->mOverflow) {
aRenderingContext.PopState(clipState);
}
}
// Paint one child frame
@ -527,41 +511,78 @@ nsContainerFrame::SyncFrameViewAfterReflow(nsIPresContext* aPresContext,
vm->SetViewZIndex(aView, zIndex);
vm->SetViewAutoZIndex(aView, autoZIndex);
// Clip applies to block-level and replaced elements with overflow
// set to other than 'visible'
if (display->IsBlockLevel()) {
if (display->mOverflow == NS_STYLE_OVERFLOW_HIDDEN) {
nscoord left, top, right, bottom;
// There are two types of clipping:
// - 'clip' which only applies to absolutely positioned elements, and is
// relative to the element's border edge. 'clip' applies to the entire
// element
// - 'overflow-clip' which only applies to block-level elements and replaced
// elements that have 'overflow' set to 'hidden'. 'overflow-clip' is relative
// to the content area and applies to content only (not border or background)
PRBool hasClip, hasOverflowClip;
hasClip = position->IsAbsolutelyPositioned() && (display->mClipFlags & NS_STYLE_CLIP_RECT);
hasOverflowClip = display->IsBlockLevel() && (display->mOverflow == NS_STYLE_OVERFLOW_HIDDEN);
if (hasClip || hasOverflowClip) {
nsRect clipRect, overflowClipRect;
// Start with the 'auto' values and then factor in user
// specified values
left = top = 0;
right = frameSize.width;
bottom = frameSize.height;
if (hasClip) {
// Start with the 'auto' values and then factor in user specified values
clipRect.SetRect(0, 0, frameSize.width, frameSize.height);
if (0 == (NS_STYLE_CLIP_TOP_AUTO & display->mClipFlags)) {
top += display->mClip.top;
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;
}
}
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 clipping of child views.
aView->SetChildClip(left, top, right, bottom);
PRUint32 vflags;
aView->GetViewFlags(&vflags);
aView->SetViewFlags(vflags | NS_VIEW_PUBLIC_FLAG_CLIPCHILDREN);
} else {
// Remove clipping of child views.
PRUint32 vflags;
aView->GetViewFlags(&vflags);
aView->SetViewFlags(vflags & ~NS_VIEW_PUBLIC_FLAG_CLIPCHILDREN);
}
if (hasOverflowClip) {
const nsStyleSpacing* spacing;
nsMargin border, padding;
aFrame->GetStyleData(eStyleStruct_Spacing, (const nsStyleStruct*&)spacing);
// 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
overflowClipRect.SetRect(0, 0, frameSize.width, frameSize.height);
spacing->GetBorder(border);
overflowClipRect.Deflate(border);
// XXX We need to handle percentage padding
if (spacing->GetPadding(padding)) {
overflowClipRect.Deflate(padding);
}
}
// If both 'clip' and 'overflow-clip' apply then use the intersection
// of the two
if (hasClip && hasOverflowClip) {
clipRect.IntersectRect(clipRect, overflowClipRect);
}
// Set clipping of child views.
if (hasClip) {
aView->SetChildClip(clipRect.x, clipRect.y, clipRect.XMost(), clipRect.YMost());
} else {
aView->SetChildClip(overflowClipRect.x, overflowClipRect.y,
overflowClipRect.XMost(), overflowClipRect.YMost());
}
PRUint32 vflags;
aView->GetViewFlags(&vflags);
aView->SetViewFlags(vflags | NS_VIEW_PUBLIC_FLAG_CLIPCHILDREN);
} else {
// Remove clipping of child views.
PRUint32 vflags;
aView->GetViewFlags(&vflags);
aView->SetViewFlags(vflags & ~NS_VIEW_PUBLIC_FLAG_CLIPCHILDREN);
}
NS_RELEASE(vm);

Просмотреть файл

@ -615,33 +615,30 @@ nsFrame::DisplaySelection(nsIPresContext* aPresContext, PRBool isOkToTurnOn)
}
void
nsFrame::SetClipRect(nsIRenderingContext& aRenderingContext)
nsFrame::SetOverflowClipRect(nsIRenderingContext& aRenderingContext)
{
PRBool clipState;
const nsStyleDisplay* display;
GetStyleData(eStyleStruct_Display, (const nsStyleStruct*&) display);
// '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);
// 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;
// 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);
}
// Set updated clip-rect into the rendering context
nsRect clipRect(left, top, right - left, bottom - top);
PRBool clipState;
aRenderingContext.SetClipRect(clipRect, nsClipCombine_kIntersect, clipState);
}

Просмотреть файл

@ -423,10 +423,11 @@ protected:
virtual PRBool ParentDisablesSelection() const;
// 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);
// 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);
nsRect mRect;
nsIContent* mContent;

Просмотреть файл

@ -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, nsnull);
result = view->Init(viewMan, boundBox, parView);
viewMan->InsertChild(parView, view, 0);
SetView(aPresContext, view);

Просмотреть файл

@ -559,11 +559,6 @@ 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);
@ -639,11 +634,6 @@ 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);

Просмотреть файл

@ -377,8 +377,7 @@ 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, nsnull,
nsViewVisibility_kHide);
result = view->Init(viewMan, boundBox, parView, nsViewVisibility_kHide);
// if (nsnull != initData) {
// delete(initData);
// }

Просмотреть файл

@ -5929,13 +5929,6 @@ 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)) {
@ -5956,6 +5949,14 @@ 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) {

Просмотреть файл

@ -5929,13 +5929,6 @@ 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)) {
@ -5956,6 +5949,14 @@ 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) {

Просмотреть файл

@ -5929,13 +5929,6 @@ 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)) {
@ -5956,6 +5949,14 @@ 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) {

Просмотреть файл

@ -149,27 +149,11 @@ nsContainerFrame::PaintChildren(nsIPresContext* aPresContext,
const nsStyleDisplay* disp = (const nsStyleDisplay*)
mStyleContext->GetStyleData(eStyleStruct_Display);
// Child elements have the opportunity to override the visibility property
// of their parent and display even if the parent is hidden
PRBool clipState;
// 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();
aRenderingContext.SetClipRect(nsRect(0, 0, mRect.width, mRect.height),
nsClipCombine_kIntersect, clipState);
}
nsIFrame* kid = mFrames.FirstChild();
while (nsnull != kid) {
PaintChild(aPresContext, aRenderingContext, aDirtyRect, kid, aWhichLayer);
kid->GetNextSibling(&kid);
}
if (NS_STYLE_OVERFLOW_HIDDEN == disp->mOverflow) {
aRenderingContext.PopState(clipState);
}
}
// Paint one child frame
@ -527,41 +511,78 @@ nsContainerFrame::SyncFrameViewAfterReflow(nsIPresContext* aPresContext,
vm->SetViewZIndex(aView, zIndex);
vm->SetViewAutoZIndex(aView, autoZIndex);
// Clip applies to block-level and replaced elements with overflow
// set to other than 'visible'
if (display->IsBlockLevel()) {
if (display->mOverflow == NS_STYLE_OVERFLOW_HIDDEN) {
nscoord left, top, right, bottom;
// There are two types of clipping:
// - 'clip' which only applies to absolutely positioned elements, and is
// relative to the element's border edge. 'clip' applies to the entire
// element
// - 'overflow-clip' which only applies to block-level elements and replaced
// elements that have 'overflow' set to 'hidden'. 'overflow-clip' is relative
// to the content area and applies to content only (not border or background)
PRBool hasClip, hasOverflowClip;
hasClip = position->IsAbsolutelyPositioned() && (display->mClipFlags & NS_STYLE_CLIP_RECT);
hasOverflowClip = display->IsBlockLevel() && (display->mOverflow == NS_STYLE_OVERFLOW_HIDDEN);
if (hasClip || hasOverflowClip) {
nsRect clipRect, overflowClipRect;
// Start with the 'auto' values and then factor in user
// specified values
left = top = 0;
right = frameSize.width;
bottom = frameSize.height;
if (hasClip) {
// Start with the 'auto' values and then factor in user specified values
clipRect.SetRect(0, 0, frameSize.width, frameSize.height);
if (0 == (NS_STYLE_CLIP_TOP_AUTO & display->mClipFlags)) {
top += display->mClip.top;
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;
}
}
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 clipping of child views.
aView->SetChildClip(left, top, right, bottom);
PRUint32 vflags;
aView->GetViewFlags(&vflags);
aView->SetViewFlags(vflags | NS_VIEW_PUBLIC_FLAG_CLIPCHILDREN);
} else {
// Remove clipping of child views.
PRUint32 vflags;
aView->GetViewFlags(&vflags);
aView->SetViewFlags(vflags & ~NS_VIEW_PUBLIC_FLAG_CLIPCHILDREN);
}
if (hasOverflowClip) {
const nsStyleSpacing* spacing;
nsMargin border, padding;
aFrame->GetStyleData(eStyleStruct_Spacing, (const nsStyleStruct*&)spacing);
// 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
overflowClipRect.SetRect(0, 0, frameSize.width, frameSize.height);
spacing->GetBorder(border);
overflowClipRect.Deflate(border);
// XXX We need to handle percentage padding
if (spacing->GetPadding(padding)) {
overflowClipRect.Deflate(padding);
}
}
// If both 'clip' and 'overflow-clip' apply then use the intersection
// of the two
if (hasClip && hasOverflowClip) {
clipRect.IntersectRect(clipRect, overflowClipRect);
}
// Set clipping of child views.
if (hasClip) {
aView->SetChildClip(clipRect.x, clipRect.y, clipRect.XMost(), clipRect.YMost());
} else {
aView->SetChildClip(overflowClipRect.x, overflowClipRect.y,
overflowClipRect.XMost(), overflowClipRect.YMost());
}
PRUint32 vflags;
aView->GetViewFlags(&vflags);
aView->SetViewFlags(vflags | NS_VIEW_PUBLIC_FLAG_CLIPCHILDREN);
} else {
// Remove clipping of child views.
PRUint32 vflags;
aView->GetViewFlags(&vflags);
aView->SetViewFlags(vflags & ~NS_VIEW_PUBLIC_FLAG_CLIPCHILDREN);
}
NS_RELEASE(vm);

Просмотреть файл

@ -615,33 +615,30 @@ nsFrame::DisplaySelection(nsIPresContext* aPresContext, PRBool isOkToTurnOn)
}
void
nsFrame::SetClipRect(nsIRenderingContext& aRenderingContext)
nsFrame::SetOverflowClipRect(nsIRenderingContext& aRenderingContext)
{
PRBool clipState;
const nsStyleDisplay* display;
GetStyleData(eStyleStruct_Display, (const nsStyleStruct*&) display);
// '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);
// 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;
// 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);
}
// Set updated clip-rect into the rendering context
nsRect clipRect(left, top, right - left, bottom - top);
PRBool clipState;
aRenderingContext.SetClipRect(clipRect, nsClipCombine_kIntersect, clipState);
}

Просмотреть файл

@ -423,10 +423,11 @@ protected:
virtual PRBool ParentDisablesSelection() const;
// 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);
// 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);
nsRect mRect;
nsIContent* mContent;

Просмотреть файл

@ -559,11 +559,6 @@ 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);
@ -639,11 +634,6 @@ 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);

Просмотреть файл

@ -377,8 +377,7 @@ 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, nsnull,
nsViewVisibility_kHide);
result = view->Init(viewMan, boundBox, parView, nsViewVisibility_kHide);
// if (nsnull != initData) {
// delete(initData);
// }

Просмотреть файл

@ -3053,6 +3053,53 @@ 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,
@ -3071,6 +3118,10 @@ 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,
@ -3078,6 +3129,10 @@ 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

Просмотреть файл

@ -329,7 +329,7 @@ nsScrollFrame::CreateScrollingView(nsIPresContext* aPresContext)
}
// Initialize the scrolling view
view->Init(viewManager, mRect, parentView, nsnull, display->IsVisible()?
view->Init(viewManager, mRect, parentView, display->IsVisible()?
nsViewVisibility_kShow : nsViewVisibility_kHide);
// Insert the view into the view hierarchy

Просмотреть файл

@ -232,7 +232,7 @@ nsScrollPortFrame::CreateScrollingView(nsIPresContext* aPresContext)
}
// Initialize the scrolling view
view->Init(viewManager, mRect, parentView, nsnull, display->IsVisibleOrCollapsed() ?
view->Init(viewManager, mRect, parentView, display->IsVisibleOrCollapsed() ?
nsViewVisibility_kShow : nsViewVisibility_kHide);
// Insert the view into the view hierarchy

Просмотреть файл

@ -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, nsnull);
result = view->Init(viewMan, boundBox, parView);
viewMan->InsertChild(parView, view, 0);
SetView(aPresContext, view);

Просмотреть файл

@ -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, nsnull);
result = view->Init(viewMan, boundBox, parView);
view->SetContentTransparency(PR_TRUE);
viewMan->InsertChild(parView, view, 0);
SetView(aPresContext, view);

Просмотреть файл

@ -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, nsnull);
result = view->Init(viewMan, boundBox, parView);
view->SetContentTransparency(PR_TRUE);
viewMan->InsertChild(parView, view, 0);
SetView(aPresContext, view);

Просмотреть файл

@ -1912,35 +1912,37 @@ MapDeclarationDisplayInto(nsICSSDeclaration* aDeclaration,
display->mClipFlags = 0; // clear it
if (eCSSUnit_Auto == ourDisplay->mClip->mTop.GetUnit()) {
display->mClip.top = 0;
display->mClip.y = 0;
display->mClipFlags |= NS_STYLE_CLIP_TOP_AUTO;
}
else if (ourDisplay->mClip->mTop.IsLengthUnit()) {
display->mClip.top = CalcLength(ourDisplay->mClip->mTop, aFont->mFont, aPresContext);
fullAuto = PR_FALSE;
}
if (eCSSUnit_Auto == ourDisplay->mClip->mRight.GetUnit()) {
display->mClip.right = 0;
display->mClipFlags |= NS_STYLE_CLIP_RIGHT_AUTO;
}
else if (ourDisplay->mClip->mRight.IsLengthUnit()) {
display->mClip.right = CalcLength(ourDisplay->mClip->mRight, aFont->mFont, aPresContext);
display->mClip.y = CalcLength(ourDisplay->mClip->mTop, aFont->mFont, aPresContext);
fullAuto = PR_FALSE;
}
if (eCSSUnit_Auto == ourDisplay->mClip->mBottom.GetUnit()) {
display->mClip.bottom = 0;
display->mClip.height = 0;
display->mClipFlags |= NS_STYLE_CLIP_BOTTOM_AUTO;
}
else if (ourDisplay->mClip->mBottom.IsLengthUnit()) {
display->mClip.bottom = CalcLength(ourDisplay->mClip->mBottom, aFont->mFont, aPresContext);
display->mClip.height = CalcLength(ourDisplay->mClip->mBottom, aFont->mFont, aPresContext) -
display->mClip.y;
fullAuto = PR_FALSE;
}
if (eCSSUnit_Auto == ourDisplay->mClip->mLeft.GetUnit()) {
display->mClip.left = 0;
display->mClip.x = 0;
display->mClipFlags |= NS_STYLE_CLIP_LEFT_AUTO;
}
else if (ourDisplay->mClip->mLeft.IsLengthUnit()) {
display->mClip.left = CalcLength(ourDisplay->mClip->mLeft, aFont->mFont, aPresContext);
display->mClip.x = CalcLength(ourDisplay->mClip->mLeft, aFont->mFont, aPresContext);
fullAuto = PR_FALSE;
}
if (eCSSUnit_Auto == ourDisplay->mClip->mRight.GetUnit()) {
display->mClip.width = 0;
display->mClipFlags |= NS_STYLE_CLIP_RIGHT_AUTO;
}
else if (ourDisplay->mClip->mRight.IsLengthUnit()) {
display->mClip.width = CalcLength(ourDisplay->mClip->mRight, aFont->mFont, aPresContext) -
display->mClip.x;
fullAuto = PR_FALSE;
}
display->mClipFlags &= ~NS_STYLE_CLIP_TYPE_MASK;

Просмотреть файл

@ -1912,35 +1912,37 @@ MapDeclarationDisplayInto(nsICSSDeclaration* aDeclaration,
display->mClipFlags = 0; // clear it
if (eCSSUnit_Auto == ourDisplay->mClip->mTop.GetUnit()) {
display->mClip.top = 0;
display->mClip.y = 0;
display->mClipFlags |= NS_STYLE_CLIP_TOP_AUTO;
}
else if (ourDisplay->mClip->mTop.IsLengthUnit()) {
display->mClip.top = CalcLength(ourDisplay->mClip->mTop, aFont->mFont, aPresContext);
fullAuto = PR_FALSE;
}
if (eCSSUnit_Auto == ourDisplay->mClip->mRight.GetUnit()) {
display->mClip.right = 0;
display->mClipFlags |= NS_STYLE_CLIP_RIGHT_AUTO;
}
else if (ourDisplay->mClip->mRight.IsLengthUnit()) {
display->mClip.right = CalcLength(ourDisplay->mClip->mRight, aFont->mFont, aPresContext);
display->mClip.y = CalcLength(ourDisplay->mClip->mTop, aFont->mFont, aPresContext);
fullAuto = PR_FALSE;
}
if (eCSSUnit_Auto == ourDisplay->mClip->mBottom.GetUnit()) {
display->mClip.bottom = 0;
display->mClip.height = 0;
display->mClipFlags |= NS_STYLE_CLIP_BOTTOM_AUTO;
}
else if (ourDisplay->mClip->mBottom.IsLengthUnit()) {
display->mClip.bottom = CalcLength(ourDisplay->mClip->mBottom, aFont->mFont, aPresContext);
display->mClip.height = CalcLength(ourDisplay->mClip->mBottom, aFont->mFont, aPresContext) -
display->mClip.y;
fullAuto = PR_FALSE;
}
if (eCSSUnit_Auto == ourDisplay->mClip->mLeft.GetUnit()) {
display->mClip.left = 0;
display->mClip.x = 0;
display->mClipFlags |= NS_STYLE_CLIP_LEFT_AUTO;
}
else if (ourDisplay->mClip->mLeft.IsLengthUnit()) {
display->mClip.left = CalcLength(ourDisplay->mClip->mLeft, aFont->mFont, aPresContext);
display->mClip.x = CalcLength(ourDisplay->mClip->mLeft, aFont->mFont, aPresContext);
fullAuto = PR_FALSE;
}
if (eCSSUnit_Auto == ourDisplay->mClip->mRight.GetUnit()) {
display->mClip.width = 0;
display->mClipFlags |= NS_STYLE_CLIP_RIGHT_AUTO;
}
else if (ourDisplay->mClip->mRight.IsLengthUnit()) {
display->mClip.width = CalcLength(ourDisplay->mClip->mRight, aFont->mFont, aPresContext) -
display->mClip.x;
fullAuto = PR_FALSE;
}
display->mClipFlags &= ~NS_STYLE_CLIP_TYPE_MASK;

Просмотреть файл

@ -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.SizeTo(0,0,0,0);
mClip.SetRect(0,0,0,0);
}
void StyleDisplayImpl::SetFrom(const nsStyleDisplay& aSource)

Просмотреть файл

@ -88,14 +88,12 @@ public:
* @param aParent intended parent for view. this is not actually set in the
* nsIView through this method. it is only used by the initialization
* code to walk up the view tree, if necessary, to find resources.
* @param aCilpRect initial clip rect of view
* @param aVisibilityFlag initial visibility state of view
* @result The result of the initialization, NS_OK if no errors
*/
NS_IMETHOD Init(nsIViewManager* aManager,
const nsRect &aBounds,
const nsIView *aParent,
const nsViewClip *aClip = nsnull,
nsViewVisibility aVisibilityFlag = nsViewVisibility_kShow) = 0;
/**

Просмотреть файл

@ -103,10 +103,9 @@ nsrefcnt nsScrollPortView::Release()
NS_IMETHODIMP nsScrollPortView::Init(nsIViewManager* aManager,
const nsRect &aBounds,
const nsIView *aParent,
const nsViewClip *aClip,
nsViewVisibility aVisibilityFlag)
{
return nsView::Init(aManager, aBounds, aParent, aClip, aVisibilityFlag);
return nsView::Init(aManager, aBounds, aParent, aVisibilityFlag);
}
NS_IMETHODIMP nsScrollPortView::SetDimensions(nscoord width, nscoord height, PRBool aPaint)

Просмотреть файл

@ -43,7 +43,6 @@ public:
NS_IMETHOD Init(nsIViewManager* aManager,
const nsRect &aBounds,
const nsIView *aParent,
const nsViewClip *aClip = nsnull,
nsViewVisibility aVisibilityFlag = nsViewVisibility_kShow);
NS_IMETHOD SetDimensions(nscoord width, nscoord height, PRBool aPaint = PR_TRUE);
NS_IMETHOD SetPosition(nscoord aX, nscoord aY);

Просмотреть файл

@ -444,7 +444,6 @@ nsrefcnt nsScrollingView::Release()
NS_IMETHODIMP nsScrollingView::Init(nsIViewManager* aManager,
const nsRect &aBounds,
const nsIView *aParent,
const nsViewClip *aClip,
nsViewVisibility aVisibilityFlag)
{
nsIDeviceContext *dx = nsnull;
@ -463,7 +462,7 @@ NS_IMETHODIMP nsScrollingView::Init(nsIViewManager* aManager,
NS_RELEASE(dx);
}
return nsView::Init(aManager, aBounds, aParent, aClip, aVisibilityFlag);
return nsView::Init(aManager, aBounds, aParent, aVisibilityFlag);
}
NS_IMETHODIMP nsScrollingView::SetDimensions(nscoord width, nscoord height, PRBool aPaint)
@ -840,8 +839,7 @@ NS_IMETHODIMP nsScrollingView::CreateScrollControls(nsNativeWidget aNative)
trect.height = NSToCoordRound(sbHeight);
trect.y = mBounds.y + mBounds.YMost() - trect.height;
rv = mCornerView->Init(mViewManager, trect, this,
nsnull, nsViewVisibility_kHide);
rv = mCornerView->Init(mViewManager, trect, this, nsViewVisibility_kHide);
mViewManager->InsertChild(this, mCornerView, mZindex);
mCornerView->CreateWidget(kWidgetCID, &initData,
mWindow ? nsnull : aNative);

Просмотреть файл

@ -45,7 +45,6 @@ public:
NS_IMETHOD Init(nsIViewManager* aManager,
const nsRect &aBounds,
const nsIView *aParent,
const nsViewClip *aClip = nsnull,
nsViewVisibility aVisibilityFlag = nsViewVisibility_kShow);
NS_IMETHOD SetDimensions(nscoord width, nscoord height, PRBool aPaint = PR_TRUE);
NS_IMETHOD SetPosition(nscoord aX, nscoord aY);

Просмотреть файл

@ -210,7 +210,6 @@ nsIView* nsView::GetViewFor(nsIWidget* aWidget)
NS_IMETHODIMP nsView :: Init(nsIViewManager* aManager,
const nsRect &aBounds,
const nsIView *aParent,
const nsViewClip *aClip,
nsViewVisibility aVisibilityFlag)
{
//printf(" \n callback=%d data=%d", aWidgetCreateCallback, aCallbackData);
@ -224,15 +223,10 @@ NS_IMETHODIMP nsView :: Init(nsIViewManager* aManager,
// we don't hold a reference to the view manager
mViewManager = aManager;
if (aClip != nsnull)
mClip = *aClip;
else
{
mClip.mLeft = 0;
mClip.mRight = 0;
mClip.mTop = 0;
mClip.mBottom = 0;
}
mChildClip.mLeft = 0;
mChildClip.mRight = 0;
mChildClip.mTop = 0;
mChildClip.mBottom = 0;
SetBounds(aBounds);
@ -273,18 +267,7 @@ NS_IMETHODIMP nsView :: Paint(nsIRenderingContext& rc, const nsRect& rect,
if (nsnull != mClientData) {
nsCOMPtr<nsIViewObserver> observer;
if (NS_OK == mViewManager->GetViewObserver(*getter_AddRefs(observer))) {
if ((mClip.mLeft != mClip.mRight) && (mClip.mTop != mClip.mBottom)) {
nsRect crect;
crect.x = mClip.mLeft;
crect.y = mClip.mTop;
crect.width = mClip.mRight - mClip.mLeft;
crect.height = mClip.mBottom - mClip.mTop;
rc.SetClipRect(crect, nsClipCombine_kIntersect, aResult);
if (!aResult)
observer->Paint((nsIView *)this, rc, rect);
} else {
observer->Paint((nsIView *)this, rc, rect);
}
observer->Paint((nsIView *)this, rc, rect);
}
}
} else {
@ -308,11 +291,7 @@ NS_IMETHODIMP nsView :: Paint(nsIRenderingContext& rc, const nsRect& rect,
{
nsRect brect;
GetBounds(brect);
// what does this test mean?
if ((mClip.mLeft == mClip.mRight) || (mClip.mTop == mClip.mBottom) && (this != pRoot)) {
rc.SetClipRect(brect, nsClipCombine_kIntersect, clipres);
}
rc.SetClipRect(brect, nsClipCombine_kIntersect, clipres);
}
}
@ -580,12 +559,6 @@ NS_IMETHODIMP nsView :: Paint(nsIRenderingContext& rc, const nsRect& rect,
if (nsnull != mClientData) {
nsCOMPtr<nsIViewObserver> observer;
if (NS_OK == mViewManager->GetViewObserver(*getter_AddRefs(observer))) {
if ((mClip.mLeft != mClip.mRight) && (mClip.mTop != mClip.mBottom)) {
nsRect crect(mClip.mLeft, mClip.mTop,
mClip.mRight - mClip.mLeft,
mClip.mBottom - mClip.mTop);
localcx->SetClipRect(crect, nsClipCombine_kIntersect, clipres);
}
observer->Paint((nsIView *)this, *localcx, rect);
}
}
@ -696,17 +669,7 @@ NS_IMETHODIMP nsView :: Paint(nsIRenderingContext& rc, const nsRect& rect,
nsRect brect;
GetBounds(brect);
if ((mClip.mLeft != mClip.mRight) && (mClip.mTop != mClip.mBottom))
{
nsRect crect;
crect.x = mClip.mLeft + brect.x;
crect.y = mClip.mTop + brect.y;
crect.width = mClip.mRight - mClip.mLeft;
crect.height = mClip.mBottom - mClip.mTop;
rc.SetClipRect(crect, nsClipCombine_kSubtract, clipres);
} else if (this != pRoot)
if (this != pRoot)
rc.SetClipRect(brect, nsClipCombine_kSubtract, clipres);
}
@ -1049,20 +1012,20 @@ NS_IMETHODIMP nsView :: GetBounds(nsRect &aBounds) const
NS_IMETHODIMP nsView :: SetChildClip(nscoord aLeft, nscoord aTop, nscoord aRight, nscoord aBottom)
{
NS_PRECONDITION(aLeft <= aRight && aTop <= aBottom, "bad clip values");
mClip.mLeft = aLeft;
mClip.mTop = aTop;
mClip.mRight = aRight;
mClip.mBottom = aBottom;
mChildClip.mLeft = aLeft;
mChildClip.mTop = aTop;
mChildClip.mRight = aRight;
mChildClip.mBottom = aBottom;
return NS_OK;
}
NS_IMETHODIMP nsView :: GetChildClip(nscoord *aLeft, nscoord *aTop, nscoord *aRight, nscoord *aBottom) const
{
*aLeft = mClip.mLeft;
*aTop = mClip.mTop;
*aRight = mClip.mRight;
*aBottom = mClip.mBottom;
*aLeft = mChildClip.mLeft;
*aTop = mChildClip.mTop;
*aRight = mChildClip.mRight;
*aBottom = mChildClip.mBottom;
return NS_OK;
}

Просмотреть файл

@ -49,7 +49,6 @@ public:
NS_IMETHOD Init(nsIViewManager* aManager,
const nsRect &aBounds,
const nsIView *aParent,
const nsViewClip *aClip = nsnull,
nsViewVisibility aVisibilityFlag = nsViewVisibility_kShow);
NS_IMETHOD Destroy();
@ -145,7 +144,7 @@ protected:
nsViewVisibility mVis;
PRInt32 mNumKids;
nsRect mBounds;
nsViewClip mClip;
nsViewClip mChildClip;
nsTransform2D *mXForm;
float mOpacity;
PRUint32 mVFlags;