1998-09-09 02:34:40 +04: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"
|
|
|
|
#include "nsIInlineReflow.h"
|
1998-09-15 04:19:49 +04:00
|
|
|
#include "nsLineLayout.h"
|
1998-09-09 02:34:40 +04:00
|
|
|
#include "nsStyleConsts.h"
|
|
|
|
#include "nsHTMLAtoms.h"
|
|
|
|
#include "nsIStyleContext.h"
|
|
|
|
#include "nsIFontMetrics.h"
|
|
|
|
#include "nsIRenderingContext.h"
|
|
|
|
|
|
|
|
class BRFrame : public nsFrame, public nsIInlineReflow {
|
|
|
|
public:
|
|
|
|
BRFrame(nsIContent* aContent, nsIFrame* aParentFrame);
|
|
|
|
|
|
|
|
// nsISupports
|
|
|
|
NS_IMETHOD QueryInterface(REFNSIID aIID, void** aInstancePtr);
|
|
|
|
|
|
|
|
// nsIFrame
|
|
|
|
NS_IMETHOD Paint(nsIPresContext& aPresContext,
|
|
|
|
nsIRenderingContext& aRenderingContext,
|
|
|
|
const nsRect& aDirtyRect);
|
|
|
|
|
|
|
|
// nsIInlineReflow
|
1998-09-30 02:31:22 +04:00
|
|
|
NS_IMETHOD FindTextRuns(nsLineLayout& aLineLayout,
|
1998-09-09 02:34:40 +04:00
|
|
|
nsIReflowCommand* aReflowCommand);
|
1998-09-30 02:31:22 +04:00
|
|
|
NS_IMETHOD InlineReflow(nsLineLayout& aLineLayout,
|
1998-10-01 08:46:11 +04:00
|
|
|
nsHTMLReflowMetrics& aDesiredSize,
|
1998-10-02 08:10:00 +04:00
|
|
|
const nsHTMLReflowState& aReflowState);
|
1998-09-09 02:34:40 +04:00
|
|
|
|
|
|
|
protected:
|
|
|
|
virtual ~BRFrame();
|
|
|
|
};
|
|
|
|
|
|
|
|
nsresult
|
|
|
|
NS_NewBRFrame(nsIContent* aContent, nsIFrame* aParentFrame,
|
|
|
|
nsIFrame*& aResult)
|
|
|
|
{
|
|
|
|
nsIFrame* frame = new BRFrame(aContent, aParentFrame);
|
|
|
|
if (nsnull == frame) {
|
|
|
|
return NS_ERROR_OUT_OF_MEMORY;
|
|
|
|
}
|
|
|
|
aResult = frame;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
BRFrame::BRFrame(nsIContent* aContent,
|
|
|
|
nsIFrame* aParentFrame)
|
|
|
|
: nsFrame(aContent, aParentFrame)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
BRFrame::~BRFrame()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
BRFrame::QueryInterface(REFNSIID aIID, void** aInstancePtrResult)
|
|
|
|
{
|
|
|
|
NS_PRECONDITION(nsnull != aInstancePtrResult, "null pointer");
|
|
|
|
if (nsnull == aInstancePtrResult) {
|
|
|
|
return NS_ERROR_NULL_POINTER;
|
|
|
|
}
|
|
|
|
if (aIID.Equals(kIInlineReflowIID)) {
|
|
|
|
*aInstancePtrResult = (void*) ((nsIInlineReflow*)this);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
return nsFrame::QueryInterface(aIID, aInstancePtrResult);
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_METHOD
|
1998-09-30 02:31:22 +04:00
|
|
|
BRFrame::Paint(nsIPresContext& aPresContext,
|
1998-09-09 02:34:40 +04:00
|
|
|
nsIRenderingContext& aRenderingContext,
|
1998-09-30 02:31:22 +04:00
|
|
|
const nsRect& aDirtyRect)
|
1998-09-09 02:34:40 +04:00
|
|
|
{
|
|
|
|
if (nsIFrame::GetShowFrameBorders()) {
|
|
|
|
float p2t = aPresContext.GetPixelsToTwips();
|
1998-09-30 02:31:22 +04:00
|
|
|
nscoord five = NSIntPixelsToTwips(5, p2t);
|
1998-09-09 02:34:40 +04:00
|
|
|
aRenderingContext.SetColor(NS_RGB(0, 255, 255));
|
1998-09-30 02:31:22 +04:00
|
|
|
aRenderingContext.FillRect(0, 0, five, five*2);
|
1998-09-09 02:34:40 +04:00
|
|
|
}
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
1998-09-30 02:31:22 +04:00
|
|
|
BRFrame::FindTextRuns(nsLineLayout& aLineLayout,
|
1998-09-09 02:34:40 +04:00
|
|
|
nsIReflowCommand* aReflowCommand)
|
|
|
|
{
|
|
|
|
aLineLayout.EndTextRun();
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
1998-09-30 02:31:22 +04:00
|
|
|
BRFrame::InlineReflow(nsLineLayout& aLineLayout,
|
1998-10-01 08:46:11 +04:00
|
|
|
nsHTMLReflowMetrics& aMetrics,
|
1998-10-02 08:10:00 +04:00
|
|
|
const nsHTMLReflowState& aReflowState)
|
1998-09-09 02:34:40 +04:00
|
|
|
{
|
|
|
|
if (nsnull != aMetrics.maxElementSize) {
|
|
|
|
aMetrics.maxElementSize->width = 0;
|
|
|
|
aMetrics.maxElementSize->height = 0;
|
|
|
|
}
|
1998-09-30 02:31:22 +04:00
|
|
|
aMetrics.height = 0;
|
1998-09-09 02:34:40 +04:00
|
|
|
aMetrics.width = 0;
|
1998-09-30 02:31:22 +04:00
|
|
|
aLineLayout.SetBRFrame(this);
|
1998-09-09 02:34:40 +04:00
|
|
|
|
|
|
|
// Return our inline reflow status
|
|
|
|
const nsStyleDisplay* display = (const nsStyleDisplay*)
|
|
|
|
mStyleContext->GetStyleData(eStyleStruct_Display);
|
|
|
|
PRUint32 breakType = display->mBreakType;
|
|
|
|
if (NS_STYLE_CLEAR_NONE == breakType) {
|
|
|
|
breakType = NS_STYLE_CLEAR_LINE;
|
|
|
|
}
|
|
|
|
return NS_INLINE_BREAK | NS_INLINE_BREAK_AFTER |
|
|
|
|
NS_INLINE_MAKE_BREAK_TYPE(breakType);
|
|
|
|
}
|