1998-04-14 00:24:54 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
|
|
|
*
|
1999-11-06 06:40:37 +03:00
|
|
|
* The contents of this file are subject to the Netscape Public
|
|
|
|
* License Version 1.1 (the "License"); you may not use this file
|
|
|
|
* except in compliance with the License. You may obtain a copy of
|
|
|
|
* the License at http://www.mozilla.org/NPL/
|
1998-04-14 00:24:54 +04:00
|
|
|
*
|
1999-11-06 06:40:37 +03:00
|
|
|
* Software distributed under the License is distributed on an "AS
|
|
|
|
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
|
|
|
* implied. See the License for the specific language governing
|
|
|
|
* rights and limitations under the License.
|
1998-04-14 00:24:54 +04:00
|
|
|
*
|
1999-11-06 06:40:37 +03:00
|
|
|
* The Original Code is mozilla.org code.
|
|
|
|
*
|
|
|
|
* The Initial Developer of the Original Code is Netscape
|
1998-04-14 00:24:54 +04:00
|
|
|
* Communications Corporation. Portions created by Netscape are
|
1999-11-06 06:40:37 +03:00
|
|
|
* Copyright (C) 1998 Netscape Communications Corporation. All
|
|
|
|
* Rights Reserved.
|
|
|
|
*
|
|
|
|
* Contributor(s):
|
1998-04-14 00:24:54 +04:00
|
|
|
*/
|
1999-02-12 20:45:58 +03:00
|
|
|
#include "nsCOMPtr.h"
|
1998-04-14 00:24:54 +04:00
|
|
|
#include "nsLeafFrame.h"
|
1998-09-25 20:33:38 +04:00
|
|
|
#include "nsHTMLContainerFrame.h"
|
1998-04-14 00:24:54 +04:00
|
|
|
#include "nsCSSRendering.h"
|
1998-06-09 08:51:44 +04:00
|
|
|
#include "nsHTMLParts.h"
|
1998-09-25 20:33:38 +04:00
|
|
|
#include "nsHTMLAtoms.h"
|
1998-06-09 08:51:44 +04:00
|
|
|
#include "nsIPresShell.h"
|
1998-09-30 03:48:07 +04:00
|
|
|
#include "nsIPresContext.h"
|
1998-09-25 20:33:38 +04:00
|
|
|
#include "nsIStyleContext.h"
|
1998-04-14 00:24:54 +04:00
|
|
|
|
|
|
|
nsLeafFrame::~nsLeafFrame()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
1998-11-17 04:03:59 +03:00
|
|
|
NS_IMETHODIMP
|
1999-11-24 09:03:41 +03:00
|
|
|
nsLeafFrame::Paint(nsIPresContext* aPresContext,
|
1998-11-17 04:03:59 +03:00
|
|
|
nsIRenderingContext& aRenderingContext,
|
1998-12-18 18:54:23 +03:00
|
|
|
const nsRect& aDirtyRect,
|
|
|
|
nsFramePaintLayer aWhichLayer)
|
1998-04-14 00:24:54 +04:00
|
|
|
{
|
1999-03-26 03:39:35 +03:00
|
|
|
if (NS_FRAME_PAINT_LAYER_BACKGROUND == aWhichLayer) {
|
1998-12-18 18:54:23 +03:00
|
|
|
const nsStyleDisplay* disp = (const nsStyleDisplay*)
|
|
|
|
mStyleContext->GetStyleData(eStyleStruct_Display);
|
2000-03-17 13:15:13 +03:00
|
|
|
if (disp->IsVisibleOrCollapsed()) {
|
1998-12-18 18:54:23 +03:00
|
|
|
const nsStyleColor* myColor = (const nsStyleColor*)
|
|
|
|
mStyleContext->GetStyleData(eStyleStruct_Color);
|
|
|
|
const nsStyleSpacing* mySpacing = (const nsStyleSpacing*)
|
|
|
|
mStyleContext->GetStyleData(eStyleStruct_Spacing);
|
|
|
|
nsRect rect(0, 0, mRect.width, mRect.height);
|
|
|
|
nsCSSRendering::PaintBackground(aPresContext, aRenderingContext, this,
|
1999-01-15 21:25:58 +03:00
|
|
|
aDirtyRect, rect, *myColor, *mySpacing, 0, 0);
|
1999-08-19 18:35:48 +04:00
|
|
|
|
1998-12-18 18:54:23 +03:00
|
|
|
nsCSSRendering::PaintBorder(aPresContext, aRenderingContext, this,
|
1999-01-23 01:27:19 +03:00
|
|
|
aDirtyRect, rect, *mySpacing, mStyleContext, 0);
|
1999-08-19 18:35:48 +04:00
|
|
|
|
|
|
|
nsCSSRendering::PaintOutline(aPresContext, aRenderingContext, this,
|
|
|
|
aDirtyRect, rect, *mySpacing, mStyleContext, 0);
|
1998-12-18 18:54:23 +03:00
|
|
|
}
|
1998-05-27 03:15:47 +04:00
|
|
|
}
|
1998-04-17 05:41:24 +04:00
|
|
|
return NS_OK;
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
|
|
|
|
1998-11-17 04:03:59 +03:00
|
|
|
NS_IMETHODIMP
|
1999-11-24 09:03:41 +03:00
|
|
|
nsLeafFrame::Reflow(nsIPresContext* aPresContext,
|
1998-11-17 04:03:59 +03:00
|
|
|
nsHTMLReflowMetrics& aMetrics,
|
|
|
|
const nsHTMLReflowState& aReflowState,
|
1998-11-20 20:13:02 +03:00
|
|
|
nsReflowStatus& aStatus)
|
1998-04-14 00:24:54 +04:00
|
|
|
{
|
1998-11-17 04:03:59 +03:00
|
|
|
NS_FRAME_TRACE(NS_FRAME_TRACE_CALLS,
|
|
|
|
("enter nsLeafFrame::Reflow: aMaxSize=%d,%d",
|
1999-01-06 02:31:18 +03:00
|
|
|
aReflowState.availableWidth, aReflowState.availableHeight));
|
1998-11-17 04:03:59 +03:00
|
|
|
|
1998-05-29 00:12:02 +04:00
|
|
|
NS_PRECONDITION(mState & NS_FRAME_IN_REFLOW, "frame is not in reflow");
|
|
|
|
|
1998-04-14 00:24:54 +04:00
|
|
|
// XXX add in code to check for width/height being set via css
|
|
|
|
// and if set use them instead of calling GetDesiredSize.
|
|
|
|
|
1998-06-25 20:33:10 +04:00
|
|
|
|
1999-11-24 09:03:41 +03:00
|
|
|
GetDesiredSize(aPresContext, aReflowState, aMetrics);
|
1998-11-20 20:13:02 +03:00
|
|
|
nsMargin borderPadding;
|
1999-11-24 09:03:41 +03:00
|
|
|
AddBordersAndPadding(aPresContext, aReflowState, aMetrics, borderPadding);
|
1998-11-17 04:03:59 +03:00
|
|
|
if (nsnull != aMetrics.maxElementSize) {
|
1998-12-17 21:54:22 +03:00
|
|
|
aMetrics.AddBorderPaddingToMaxElementSize(borderPadding);
|
1998-11-17 04:03:59 +03:00
|
|
|
aMetrics.maxElementSize->width = aMetrics.width;
|
|
|
|
aMetrics.maxElementSize->height = aMetrics.height;
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
1998-05-12 08:17:56 +04:00
|
|
|
aStatus = NS_FRAME_COMPLETE;
|
1998-11-17 04:03:59 +03:00
|
|
|
|
|
|
|
NS_FRAME_TRACE(NS_FRAME_TRACE_CALLS,
|
|
|
|
("exit nsLeafFrame::Reflow: size=%d,%d",
|
|
|
|
aMetrics.width, aMetrics.height));
|
1998-04-17 05:41:24 +04:00
|
|
|
return NS_OK;
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
// XXX how should border&padding effect baseline alignment?
|
|
|
|
// => descent = borderPadding.bottom for example
|
1998-11-17 04:03:59 +03:00
|
|
|
void
|
|
|
|
nsLeafFrame::AddBordersAndPadding(nsIPresContext* aPresContext,
|
1998-11-20 20:13:02 +03:00
|
|
|
const nsHTMLReflowState& aReflowState,
|
|
|
|
nsHTMLReflowMetrics& aMetrics,
|
|
|
|
nsMargin& aBorderPadding)
|
1998-04-14 00:24:54 +04:00
|
|
|
{
|
1999-03-06 04:40:29 +03:00
|
|
|
aBorderPadding = aReflowState.mComputedBorderPadding;
|
1998-11-20 20:13:02 +03:00
|
|
|
aMetrics.width += aBorderPadding.left + aBorderPadding.right;
|
|
|
|
aMetrics.height += aBorderPadding.top + aBorderPadding.bottom;
|
1998-11-17 04:03:59 +03:00
|
|
|
aMetrics.ascent = aMetrics.height;
|
|
|
|
aMetrics.descent = 0;
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
|
|
|
|
1998-11-17 04:03:59 +03:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsLeafFrame::ContentChanged(nsIPresContext* aPresContext,
|
|
|
|
nsIContent* aChild,
|
|
|
|
nsISupports* aSubContent)
|
1998-04-14 00:24:54 +04:00
|
|
|
{
|
1) implememted box reflow coelescing.
2) implemented gfx scrollbars for list boxes
3) fixed progess meter to be an animated gif
4) fixed bugs 23521, 24721, 19114, 20546, 24385, 24457, 23156, 20226, 22543
-r hyatt, troy, rod
2000-02-10 01:02:40 +03:00
|
|
|
/*
|
1998-06-09 08:51:44 +04:00
|
|
|
// Generate a reflow command with this frame as the target frame
|
|
|
|
nsIReflowCommand* cmd;
|
1999-02-12 20:45:58 +03:00
|
|
|
nsresult rv;
|
1998-06-09 08:51:44 +04:00
|
|
|
|
1999-02-12 20:45:58 +03:00
|
|
|
rv = NS_NewHTMLReflowCommand(&cmd, this, nsIReflowCommand::ContentChanged);
|
|
|
|
if (NS_SUCCEEDED(rv)) {
|
|
|
|
nsCOMPtr<nsIPresShell> shell;
|
|
|
|
rv = aPresContext->GetShell(getter_AddRefs(shell));
|
1999-02-12 21:41:26 +03:00
|
|
|
if (NS_SUCCEEDED(rv) && shell) {
|
1999-02-12 20:45:58 +03:00
|
|
|
shell->AppendReflowCommand(cmd);
|
|
|
|
}
|
1998-06-09 08:51:44 +04:00
|
|
|
NS_RELEASE(cmd);
|
|
|
|
}
|
|
|
|
|
1999-02-12 20:45:58 +03:00
|
|
|
return rv;
|
1) implememted box reflow coelescing.
2) implemented gfx scrollbars for list boxes
3) fixed progess meter to be an animated gif
4) fixed bugs 23521, 24721, 19114, 20546, 24385, 24457, 23156, 20226, 22543
-r hyatt, troy, rod
2000-02-10 01:02:40 +03:00
|
|
|
*/
|
|
|
|
nsCOMPtr<nsIPresShell> shell;
|
|
|
|
aPresContext->GetShell(getter_AddRefs(shell));
|
|
|
|
mState |= NS_FRAME_IS_DIRTY;
|
|
|
|
return mParent->ReflowDirtyChild(shell, this);
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
1998-06-09 08:51:44 +04:00
|
|
|
|
1999-09-01 05:02:16 +04:00
|
|
|
#ifdef DEBUG
|
1999-08-31 07:09:40 +04:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsLeafFrame::SizeOf(nsISizeOfHandler* aHandler,
|
|
|
|
PRUint32* aResult) const
|
|
|
|
{
|
1999-09-01 05:02:16 +04:00
|
|
|
if (!aResult) {
|
|
|
|
return NS_ERROR_NULL_POINTER;
|
1999-08-31 07:09:40 +04:00
|
|
|
}
|
1999-09-01 05:02:16 +04:00
|
|
|
*aResult = sizeof(*this);
|
|
|
|
return NS_OK;
|
1999-08-31 07:09:40 +04:00
|
|
|
}
|
1999-09-01 05:02:16 +04:00
|
|
|
#endif
|