2001-09-29 00:14:13 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* ***** BEGIN LICENSE BLOCK *****
|
2004-04-18 18:30:37 +04:00
|
|
|
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
1998-10-08 08:38:41 +04:00
|
|
|
*
|
2004-04-18 18:30:37 +04:00
|
|
|
* The contents of this file are subject to the Mozilla 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/MPL/
|
1998-10-08 08:38:41 +04:00
|
|
|
*
|
2001-09-29 00:14:13 +04: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.
|
|
|
|
*
|
2004-04-18 18:30:37 +04:00
|
|
|
* The Initial Developer of the Original Code is
|
2001-09-29 00:14:13 +04:00
|
|
|
* Netscape Communications Corporation.
|
|
|
|
* Portions created by the Initial Developer are Copyright (C) 1998
|
|
|
|
* the Initial Developer. All Rights Reserved.
|
1999-11-06 06:40:37 +03:00
|
|
|
*
|
2001-09-29 00:14:13 +04:00
|
|
|
* Contributor(s):
|
|
|
|
*
|
|
|
|
* Alternatively, the contents of this file may be used under the terms of
|
2004-04-18 18:30:37 +04:00
|
|
|
* either of the GNU General Public License Version 2 or later (the "GPL"),
|
|
|
|
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
2001-09-29 00:14:13 +04:00
|
|
|
* in which case the provisions of the GPL or the LGPL are applicable instead
|
|
|
|
* of those above. If you wish to allow use of your version of this file only
|
|
|
|
* under the terms of either the GPL or the LGPL, and not to allow others to
|
2004-04-18 18:30:37 +04:00
|
|
|
* use your version of this file under the terms of the MPL, indicate your
|
2001-09-29 00:14:13 +04:00
|
|
|
* decision by deleting the provisions above and replace them with the notice
|
|
|
|
* and other provisions required by the GPL or the LGPL. If you do not delete
|
|
|
|
* the provisions above, a recipient may use your version of this file under
|
2004-04-18 18:30:37 +04:00
|
|
|
* the terms of any one of the MPL, the GPL or the LGPL.
|
2001-09-29 00:14:13 +04:00
|
|
|
*
|
|
|
|
* ***** END LICENSE BLOCK ***** */
|
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 "nsHTMLParts.h"
|
|
|
|
#include "nsHTMLAtoms.h"
|
2002-12-03 19:02:42 +03:00
|
|
|
#include "nsLayoutAtoms.h"
|
1998-10-08 08:38:41 +04:00
|
|
|
#include "nsStyleConsts.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);
|
|
|
|
|
|
|
|
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()
|
|
|
|
{
|
2000-08-03 02:12:11 +04:00
|
|
|
}
|
|
|
|
|
2003-10-31 23:19:18 +03:00
|
|
|
nsIAtom*
|
|
|
|
nsLegendFrame::GetType() const
|
2002-12-03 19:02:42 +03:00
|
|
|
{
|
2003-10-31 23:19:18 +03:00
|
|
|
return nsLayoutAtoms::legendFrame;
|
2002-12-03 19:02:42 +03:00
|
|
|
}
|
|
|
|
|
2000-08-03 02:12:11 +04:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsLegendFrame::Destroy(nsIPresContext *aPresContext)
|
|
|
|
{
|
|
|
|
nsFormControlFrame::RegUnRegAccessKey(aPresContext, NS_STATIC_CAST(nsIFrame*, this), PR_FALSE);
|
|
|
|
return nsAreaFrame::Destroy(aPresContext);
|
2000-02-09 22:34:39 +03:00
|
|
|
}
|
|
|
|
|
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)
|
|
|
|
{
|
2000-04-22 01:51:35 +04:00
|
|
|
DO_GLOBAL_REFLOW_COUNT("nsLegendFrame", aReflowState.reason);
|
2001-11-14 16:40:03 +03:00
|
|
|
DISPLAY_REFLOW(aPresContext, this, aReflowState, aDesiredSize, aStatus);
|
2000-02-09 22:34:39 +03:00
|
|
|
if (eReflowReason_Initial == aReflowState.reason) {
|
|
|
|
mPresContext = aPresContext;
|
|
|
|
nsFormControlFrame::RegUnRegAccessKey(aPresContext, NS_STATIC_CAST(nsIFrame*, this), PR_TRUE);
|
|
|
|
}
|
|
|
|
return nsAreaFrame::Reflow(aPresContext, aDesiredSize, aReflowState, aStatus);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-01-27 17:09:34 +03:00
|
|
|
NS_IMETHODIMP
|
2001-09-19 16:35:19 +04:00
|
|
|
nsLegendFrame::Paint(nsIPresContext* aPresContext,
|
2001-01-27 17:09:34 +03:00
|
|
|
nsIRenderingContext& aRenderingContext,
|
2001-09-19 16:35:19 +04:00
|
|
|
const nsRect& aDirtyRect,
|
|
|
|
nsFramePaintLayer aWhichLayer,
|
|
|
|
PRUint32 aFlags)
|
2001-01-27 17:09:34 +03:00
|
|
|
{
|
|
|
|
PRBool isVisible;
|
|
|
|
if (NS_SUCCEEDED(IsVisibleForPainting(aPresContext, aRenderingContext, PR_TRUE, &isVisible)) && !isVisible) {
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
return nsAreaFrame::Paint(aPresContext, aRenderingContext, aDirtyRect, aWhichLayer);
|
|
|
|
}
|
|
|
|
|
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;
|
2002-01-31 08:09:13 +03:00
|
|
|
#ifdef IBMBIDI
|
2003-05-15 07:42:21 +04:00
|
|
|
if (NS_STYLE_DIRECTION_RTL == GetStyleVisibility()->mDirection) {
|
2002-01-31 08:09:13 +03:00
|
|
|
intValue = NS_STYLE_TEXT_ALIGN_RIGHT;
|
|
|
|
}
|
|
|
|
#endif // IBMBIDI
|
2002-05-23 04:00:34 +04:00
|
|
|
|
|
|
|
nsCOMPtr<nsIHTMLContent> content(do_QueryInterface(mContent));
|
|
|
|
|
|
|
|
if (content) {
|
1998-10-08 08:38:41 +04:00
|
|
|
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();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return intValue;
|
|
|
|
}
|
|
|
|
|
1999-11-02 01:12:45 +03:00
|
|
|
#ifdef NS_DEBUG
|
1998-11-19 20:22:29 +03:00
|
|
|
NS_IMETHODIMP
|
2001-11-14 04:33:42 +03:00
|
|
|
nsLegendFrame::GetFrameName(nsAString& aResult) const
|
1998-11-19 20:22:29 +03:00
|
|
|
{
|
2001-11-14 04:33:42 +03:00
|
|
|
return MakeFrameName(NS_LITERAL_STRING("Legend"), aResult);
|
1998-11-19 20:22:29 +03:00
|
|
|
}
|
1999-11-02 01:12:45 +03:00
|
|
|
#endif
|