1998-09-08 22:34:40 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
|
|
|
*
|
|
|
|
* The contents of this file are subject to the Netscape Public License
|
|
|
|
* Version 1.0 (the "NPL"); you may not use this file except in
|
|
|
|
* compliance with the NPL. You may obtain a copy of the NPL at
|
|
|
|
* http://www.mozilla.org/NPL/
|
|
|
|
*
|
|
|
|
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
|
|
|
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
|
|
|
* for the specific language governing rights and limitations under the
|
|
|
|
* NPL.
|
|
|
|
*
|
|
|
|
* The Initial Developer of this code under the NPL is Netscape
|
|
|
|
* Communications Corporation. Portions created by Netscape are
|
|
|
|
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
|
|
|
* Reserved.
|
|
|
|
*/
|
|
|
|
#include "nsFrame.h"
|
|
|
|
#include "nsHTMLParts.h"
|
|
|
|
#include "nsHTMLIIDs.h"
|
|
|
|
#include "nsIPresContext.h"
|
1998-09-15 00:19:49 +00:00
|
|
|
#include "nsLineLayout.h"
|
1998-09-08 22:34:40 +00:00
|
|
|
#include "nsStyleConsts.h"
|
|
|
|
#include "nsHTMLAtoms.h"
|
|
|
|
#include "nsIStyleContext.h"
|
|
|
|
#include "nsIFontMetrics.h"
|
|
|
|
#include "nsIRenderingContext.h"
|
|
|
|
|
1998-10-03 04:28:05 +00:00
|
|
|
class BRFrame : public nsFrame {
|
1998-09-08 22:34:40 +00:00
|
|
|
public:
|
|
|
|
// nsIFrame
|
|
|
|
NS_IMETHOD Paint(nsIPresContext& aPresContext,
|
|
|
|
nsIRenderingContext& aRenderingContext,
|
1998-12-18 15:54:23 +00:00
|
|
|
const nsRect& aDirtyRect,
|
|
|
|
nsFramePaintLayer aWhichLayer);
|
1998-09-08 22:34:40 +00:00
|
|
|
|
1998-10-03 04:28:05 +00:00
|
|
|
// nsIHTMLReflow
|
|
|
|
NS_IMETHOD Reflow(nsIPresContext& aPresContext,
|
|
|
|
nsHTMLReflowMetrics& aDesiredSize,
|
|
|
|
const nsHTMLReflowState& aReflowState,
|
|
|
|
nsReflowStatus& aStatus);
|
1998-09-08 22:34:40 +00:00
|
|
|
|
|
|
|
protected:
|
|
|
|
virtual ~BRFrame();
|
|
|
|
};
|
|
|
|
|
|
|
|
nsresult
|
1998-12-03 06:31:43 +00:00
|
|
|
NS_NewBRFrame(nsIFrame*& aResult)
|
1998-09-08 22:34:40 +00:00
|
|
|
{
|
1998-12-03 06:31:43 +00:00
|
|
|
nsIFrame* frame = new BRFrame;
|
1998-09-08 22:34:40 +00:00
|
|
|
if (nsnull == frame) {
|
|
|
|
return NS_ERROR_OUT_OF_MEMORY;
|
|
|
|
}
|
|
|
|
aResult = frame;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
BRFrame::~BRFrame()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_METHOD
|
1998-09-29 22:31:22 +00:00
|
|
|
BRFrame::Paint(nsIPresContext& aPresContext,
|
1998-09-08 22:34:40 +00:00
|
|
|
nsIRenderingContext& aRenderingContext,
|
1998-12-18 15:54:23 +00:00
|
|
|
const nsRect& aDirtyRect,
|
|
|
|
nsFramePaintLayer aWhichLayer)
|
1998-09-08 22:34:40 +00:00
|
|
|
{
|
1998-12-18 15:54:23 +00:00
|
|
|
if ((eFramePaintLayer_Overlay == aWhichLayer) &&
|
|
|
|
nsIFrame::GetShowFrameBorders()) {
|
1998-09-08 22:34:40 +00:00
|
|
|
float p2t = aPresContext.GetPixelsToTwips();
|
1998-09-29 22:31:22 +00:00
|
|
|
nscoord five = NSIntPixelsToTwips(5, p2t);
|
1998-09-08 22:34:40 +00:00
|
|
|
aRenderingContext.SetColor(NS_RGB(0, 255, 255));
|
1998-09-29 22:31:22 +00:00
|
|
|
aRenderingContext.FillRect(0, 0, five, five*2);
|
1998-09-08 22:34:40 +00:00
|
|
|
}
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
1998-10-03 04:28:05 +00:00
|
|
|
BRFrame::Reflow(nsIPresContext& aPresContext,
|
|
|
|
nsHTMLReflowMetrics& aMetrics,
|
|
|
|
const nsHTMLReflowState& aReflowState,
|
|
|
|
nsReflowStatus& aStatus)
|
1998-09-08 22:34:40 +00:00
|
|
|
{
|
|
|
|
if (nsnull != aMetrics.maxElementSize) {
|
|
|
|
aMetrics.maxElementSize->width = 0;
|
|
|
|
aMetrics.maxElementSize->height = 0;
|
|
|
|
}
|
1998-09-29 22:31:22 +00:00
|
|
|
aMetrics.height = 0;
|
1998-09-08 22:34:40 +00:00
|
|
|
aMetrics.width = 0;
|
1998-10-02 21:49:47 +00:00
|
|
|
aMetrics.ascent = 0;
|
|
|
|
aMetrics.descent = 0;
|
1998-10-03 04:28:05 +00:00
|
|
|
NS_ASSERTION(nsnull != aReflowState.lineLayout, "no line layout");
|
|
|
|
aReflowState.lineLayout->SetBRFrame(this);
|
1998-09-08 22:34:40 +00:00
|
|
|
|
1998-10-03 04:28:05 +00:00
|
|
|
// Return our reflow status
|
1998-09-08 22:34:40 +00:00
|
|
|
const nsStyleDisplay* display = (const nsStyleDisplay*)
|
|
|
|
mStyleContext->GetStyleData(eStyleStruct_Display);
|
|
|
|
PRUint32 breakType = display->mBreakType;
|
|
|
|
if (NS_STYLE_CLEAR_NONE == breakType) {
|
|
|
|
breakType = NS_STYLE_CLEAR_LINE;
|
|
|
|
}
|
1998-10-03 04:28:05 +00:00
|
|
|
|
|
|
|
aStatus = NS_INLINE_BREAK | NS_INLINE_BREAK_AFTER |
|
1998-09-08 22:34:40 +00:00
|
|
|
NS_INLINE_MAKE_BREAK_TYPE(breakType);
|
1998-10-03 04:28:05 +00:00
|
|
|
return NS_OK;
|
1998-09-08 22:34:40 +00:00
|
|
|
}
|