2001-09-29 00:14:13 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2012-05-21 15:12:37 +04:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
1998-10-08 08:38:41 +04:00
|
|
|
|
|
|
|
#include "nsLegendFrame.h"
|
|
|
|
#include "nsIContent.h"
|
2005-01-12 22:45:38 +03:00
|
|
|
#include "nsGenericHTMLElement.h"
|
2012-09-30 20:40:24 +04:00
|
|
|
#include "nsAttrValueInlines.h"
|
1998-10-08 08:38:41 +04:00
|
|
|
#include "nsHTMLParts.h"
|
2007-01-30 03:06:41 +03:00
|
|
|
#include "nsGkAtoms.h"
|
1998-10-08 08:38:41 +04:00
|
|
|
#include "nsStyleConsts.h"
|
2000-02-09 22:34:39 +03:00
|
|
|
#include "nsFormControlFrame.h"
|
1998-10-08 08:38:41 +04:00
|
|
|
|
2005-11-01 23:40:54 +03:00
|
|
|
nsIFrame*
|
2006-03-27 01:30:36 +04:00
|
|
|
NS_NewLegendFrame(nsIPresShell* aPresShell, nsStyleContext* aContext)
|
1998-10-08 08:38:41 +04:00
|
|
|
{
|
2009-01-19 21:31:31 +03:00
|
|
|
#ifdef DEBUG
|
2013-02-17 01:51:02 +04:00
|
|
|
const nsStyleDisplay* disp = aContext->StyleDisplay();
|
2012-08-02 15:38:50 +04:00
|
|
|
NS_ASSERTION(!disp->IsAbsolutelyPositionedStyle() && !disp->IsFloatingStyle(),
|
2009-01-19 21:31:31 +03:00
|
|
|
"Legends should not be positioned and should not float");
|
|
|
|
#endif
|
|
|
|
|
2006-03-27 01:30:36 +04:00
|
|
|
nsIFrame* f = new (aPresShell) nsLegendFrame(aContext);
|
2006-01-23 02:20:56 +03:00
|
|
|
if (f) {
|
2009-01-05 03:39:54 +03:00
|
|
|
f->AddStateBits(NS_BLOCK_FLOAT_MGR | NS_BLOCK_MARGIN_ROOT);
|
2006-01-23 02:20:56 +03:00
|
|
|
}
|
|
|
|
return f;
|
1998-10-08 08:38:41 +04:00
|
|
|
}
|
|
|
|
|
2009-09-12 20:49:24 +04:00
|
|
|
NS_IMPL_FRAMEARENA_HELPERS(nsLegendFrame)
|
|
|
|
|
2003-10-31 23:19:18 +03:00
|
|
|
nsIAtom*
|
|
|
|
nsLegendFrame::GetType() const
|
2002-12-03 19:02:42 +03:00
|
|
|
{
|
2006-12-26 20:47:52 +03:00
|
|
|
return nsGkAtoms::legendFrame;
|
2002-12-03 19:02:42 +03:00
|
|
|
}
|
|
|
|
|
2006-04-10 04:16:29 +04:00
|
|
|
void
|
2009-12-24 08:21:15 +03:00
|
|
|
nsLegendFrame::DestroyFrom(nsIFrame* aDestructRoot)
|
2000-08-03 02:12:11 +04:00
|
|
|
{
|
2011-10-17 18:59:28 +04:00
|
|
|
nsFormControlFrame::RegUnRegAccessKey(static_cast<nsIFrame*>(this), false);
|
2009-12-24 08:21:15 +03:00
|
|
|
nsBlockFrame::DestroyFrom(aDestructRoot);
|
2000-02-09 22:34:39 +03:00
|
|
|
}
|
|
|
|
|
2009-01-12 22:20:59 +03:00
|
|
|
NS_QUERYFRAME_HEAD(nsLegendFrame)
|
|
|
|
NS_QUERYFRAME_ENTRY(nsLegendFrame)
|
|
|
|
NS_QUERYFRAME_TAIL_INHERITING(nsBlockFrame)
|
1998-10-08 08:38:41 +04:00
|
|
|
|
2000-02-09 22:34:39 +03:00
|
|
|
NS_IMETHODIMP
|
2004-08-01 03:15:21 +04:00
|
|
|
nsLegendFrame::Reflow(nsPresContext* aPresContext,
|
2000-02-09 22:34:39 +03:00
|
|
|
nsHTMLReflowMetrics& aDesiredSize,
|
|
|
|
const nsHTMLReflowState& aReflowState,
|
|
|
|
nsReflowStatus& aStatus)
|
|
|
|
{
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 08:38:33 +03:00
|
|
|
DO_GLOBAL_REFLOW_COUNT("nsLegendFrame");
|
2001-11-14 16:40:03 +03:00
|
|
|
DISPLAY_REFLOW(aPresContext, this, aReflowState, aDesiredSize, aStatus);
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 08:38:33 +03:00
|
|
|
if (mState & NS_FRAME_FIRST_REFLOW) {
|
2011-10-17 18:59:28 +04:00
|
|
|
nsFormControlFrame::RegUnRegAccessKey(static_cast<nsIFrame*>(this), true);
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 08:38:33 +03:00
|
|
|
}
|
2008-12-29 18:07:38 +03:00
|
|
|
return nsBlockFrame::Reflow(aPresContext, aDesiredSize, aReflowState, aStatus);
|
2000-02-09 22:34:39 +03:00
|
|
|
}
|
|
|
|
|
2008-12-29 18:07:38 +03:00
|
|
|
// REVIEW: We don't need to override BuildDisplayList, nsBlockFrame will honour
|
2006-01-26 05:29:17 +03:00
|
|
|
// our visibility setting
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t nsLegendFrame::GetAlign()
|
1998-10-08 08:38:41 +04:00
|
|
|
{
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t intValue = NS_STYLE_TEXT_ALIGN_LEFT;
|
2002-01-31 08:09:13 +03:00
|
|
|
#ifdef IBMBIDI
|
2013-02-17 01:51:02 +04:00
|
|
|
if (mParent && NS_STYLE_DIRECTION_RTL == mParent->StyleVisibility()->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
|
|
|
|
2005-01-12 22:45:38 +03:00
|
|
|
nsGenericHTMLElement *content = nsGenericHTMLElement::FromContent(mContent);
|
2002-05-23 04:00:34 +04:00
|
|
|
|
|
|
|
if (content) {
|
2006-12-26 20:47:52 +03:00
|
|
|
const nsAttrValue* attr = content->GetParsedAttr(nsGkAtoms::align);
|
2005-01-25 03:02:58 +03:00
|
|
|
if (attr && attr->Type() == nsAttrValue::eEnum) {
|
|
|
|
intValue = attr->GetEnumValue();
|
1998-10-08 08:38:41 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return intValue;
|
|
|
|
}
|
|
|
|
|
2012-06-25 23:59:42 +04:00
|
|
|
#ifdef 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
|