1998-10-08 08:38:41 +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-10-08 08:38:41 +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-10-08 08:38:41 +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-10-08 08:38:41 +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-10-08 08:38:41 +04:00
|
|
|
*/
|
|
|
|
|
|
|
|
// YY need to pass isMultiple before create called
|
|
|
|
|
|
|
|
#include "nsLegendFrame.h"
|
|
|
|
#include "nsIDOMNode.h"
|
|
|
|
#include "nsIDOMHTMLLegendElement.h"
|
|
|
|
#include "nsCSSRendering.h"
|
|
|
|
#include "nsIContent.h"
|
|
|
|
#include "nsIFrame.h"
|
|
|
|
#include "nsISupports.h"
|
|
|
|
#include "nsIAtom.h"
|
|
|
|
#include "nsIHTMLContent.h"
|
|
|
|
#include "nsHTMLIIDs.h"
|
|
|
|
#include "nsHTMLParts.h"
|
|
|
|
#include "nsHTMLAtoms.h"
|
|
|
|
#include "nsIStyleContext.h"
|
|
|
|
#include "nsStyleConsts.h"
|
|
|
|
#include "nsStyleUtil.h"
|
|
|
|
#include "nsFont.h"
|
2000-02-09 22:34:39 +03:00
|
|
|
#include "nsFormControlFrame.h"
|
1998-10-08 08:38:41 +04:00
|
|
|
|
|
|
|
static NS_DEFINE_IID(kLegendFrameCID, NS_LEGEND_FRAME_CID);
|
|
|
|
static NS_DEFINE_IID(kIDOMHTMLLegendElementIID, NS_IDOMHTMLLEGENDELEMENT_IID);
|
|
|
|
|
|
|
|
nsresult
|
1999-12-05 02:49:50 +03:00
|
|
|
NS_NewLegendFrame(nsIPresShell* aPresShell, nsIFrame** aNewFrame)
|
1998-10-08 08:38:41 +04:00
|
|
|
{
|
1999-05-12 02:03:29 +04:00
|
|
|
NS_PRECONDITION(aNewFrame, "null OUT ptr");
|
|
|
|
if (nsnull == aNewFrame) {
|
|
|
|
return NS_ERROR_NULL_POINTER;
|
|
|
|
}
|
1999-12-05 02:49:50 +03:00
|
|
|
nsLegendFrame* it = new (aPresShell) nsLegendFrame;
|
1999-05-12 02:03:29 +04:00
|
|
|
if (!it) {
|
1998-10-08 08:38:41 +04:00
|
|
|
return NS_ERROR_OUT_OF_MEMORY;
|
|
|
|
}
|
1999-05-12 02:03:29 +04:00
|
|
|
*aNewFrame = it;
|
1998-10-08 08:38:41 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1998-12-03 09:31:43 +03:00
|
|
|
nsLegendFrame::nsLegendFrame()
|
1999-06-02 01:52:11 +04:00
|
|
|
: nsAreaFrame()
|
1998-10-08 08:38:41 +04:00
|
|
|
{
|
2000-02-10 02:20:56 +03:00
|
|
|
mPresContext = nsnull;
|
1998-10-08 08:38:41 +04:00
|
|
|
}
|
|
|
|
|
2000-02-09 22:34:39 +03:00
|
|
|
nsLegendFrame::~nsLegendFrame()
|
|
|
|
{
|
|
|
|
nsFormControlFrame::RegUnRegAccessKey(mPresContext, NS_STATIC_CAST(nsIFrame*, this), PR_FALSE);
|
|
|
|
}
|
|
|
|
|
1999-11-02 04:50:15 +03:00
|
|
|
// Frames are not refcounted, no need to AddRef
|
1998-10-08 08:38:41 +04:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsLegendFrame::QueryInterface(REFNSIID aIID, void** aInstancePtrResult)
|
|
|
|
{
|
|
|
|
NS_PRECONDITION(nsnull != aInstancePtrResult, "null pointer");
|
|
|
|
if (nsnull == aInstancePtrResult) {
|
|
|
|
return NS_ERROR_NULL_POINTER;
|
|
|
|
}
|
|
|
|
if (aIID.Equals(kLegendFrameCID)) {
|
|
|
|
*aInstancePtrResult = (void*) ((nsLegendFrame*)this);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
return nsHTMLContainerFrame::QueryInterface(aIID, aInstancePtrResult);
|
|
|
|
}
|
|
|
|
|
2000-02-09 22:34:39 +03:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsLegendFrame::Reflow(nsIPresContext* aPresContext,
|
|
|
|
nsHTMLReflowMetrics& aDesiredSize,
|
|
|
|
const nsHTMLReflowState& aReflowState,
|
|
|
|
nsReflowStatus& aStatus)
|
|
|
|
{
|
|
|
|
if (eReflowReason_Initial == aReflowState.reason) {
|
|
|
|
mPresContext = aPresContext;
|
|
|
|
nsFormControlFrame::RegUnRegAccessKey(aPresContext, NS_STATIC_CAST(nsIFrame*, this), PR_TRUE);
|
|
|
|
}
|
|
|
|
return nsAreaFrame::Reflow(aPresContext, aDesiredSize, aReflowState, aStatus);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1998-10-08 08:38:41 +04:00
|
|
|
PRInt32 nsLegendFrame::GetAlign()
|
|
|
|
{
|
1999-06-02 01:52:11 +04:00
|
|
|
PRInt32 intValue = NS_STYLE_TEXT_ALIGN_LEFT;
|
1998-10-08 08:38:41 +04:00
|
|
|
nsIHTMLContent* content = nsnull;
|
|
|
|
mContent->QueryInterface(kIHTMLContentIID, (void**) &content);
|
|
|
|
if (nsnull != content) {
|
|
|
|
nsHTMLValue value;
|
1998-12-20 04:21:23 +03:00
|
|
|
if (NS_CONTENT_ATTR_HAS_VALUE == (content->GetHTMLAttribute(nsHTMLAtoms::align, value))) {
|
1998-10-08 08:38:41 +04:00
|
|
|
if (eHTMLUnit_Enumerated == value.GetUnit()) {
|
|
|
|
intValue = value.GetIntValue();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
NS_RELEASE(content);
|
|
|
|
}
|
|
|
|
return intValue;
|
|
|
|
}
|
|
|
|
|
1999-11-02 01:12:45 +03:00
|
|
|
#ifdef NS_DEBUG
|
1998-11-19 20:22:29 +03:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsLegendFrame::GetFrameName(nsString& aResult) const
|
|
|
|
{
|
|
|
|
return MakeFrameName("Legend", aResult);
|
|
|
|
}
|
1999-11-02 01:12:45 +03:00
|
|
|
#endif
|