2001-09-28 20:14:13 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2012-05-21 11:12:37 +00: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 04:38:41 +00:00
|
|
|
|
|
|
|
#include "nsLegendFrame.h"
|
|
|
|
#include "nsIContent.h"
|
2005-01-12 19:45:38 +00:00
|
|
|
#include "nsGenericHTMLElement.h"
|
2012-09-30 16:40:24 +00:00
|
|
|
#include "nsAttrValueInlines.h"
|
1998-10-08 04:38:41 +00:00
|
|
|
#include "nsHTMLParts.h"
|
2007-01-30 00:06:41 +00:00
|
|
|
#include "nsGkAtoms.h"
|
1998-10-08 04:38:41 +00:00
|
|
|
#include "nsStyleConsts.h"
|
2000-02-09 19:34:39 +00:00
|
|
|
#include "nsFormControlFrame.h"
|
1998-10-08 04:38:41 +00:00
|
|
|
|
2005-11-01 20:40:54 +00:00
|
|
|
nsIFrame*
|
2006-03-26 21:30:36 +00:00
|
|
|
NS_NewLegendFrame(nsIPresShell* aPresShell, nsStyleContext* aContext)
|
1998-10-08 04:38:41 +00:00
|
|
|
{
|
2009-01-19 18:31:31 +00:00
|
|
|
#ifdef DEBUG
|
2013-02-16 21:51:02 +00:00
|
|
|
const nsStyleDisplay* disp = aContext->StyleDisplay();
|
2012-08-02 11:38:50 +00:00
|
|
|
NS_ASSERTION(!disp->IsAbsolutelyPositionedStyle() && !disp->IsFloatingStyle(),
|
2009-01-19 18:31:31 +00:00
|
|
|
"Legends should not be positioned and should not float");
|
|
|
|
#endif
|
|
|
|
|
2006-03-26 21:30:36 +00:00
|
|
|
nsIFrame* f = new (aPresShell) nsLegendFrame(aContext);
|
2006-01-22 23:20:56 +00:00
|
|
|
if (f) {
|
2009-01-05 00:39:54 +00:00
|
|
|
f->AddStateBits(NS_BLOCK_FLOAT_MGR | NS_BLOCK_MARGIN_ROOT);
|
2006-01-22 23:20:56 +00:00
|
|
|
}
|
|
|
|
return f;
|
1998-10-08 04:38:41 +00:00
|
|
|
}
|
|
|
|
|
2009-09-12 16:49:24 +00:00
|
|
|
NS_IMPL_FRAMEARENA_HELPERS(nsLegendFrame)
|
|
|
|
|
2003-10-31 20:19:18 +00:00
|
|
|
nsIAtom*
|
|
|
|
nsLegendFrame::GetType() const
|
2002-12-03 16:02:42 +00:00
|
|
|
{
|
2006-12-26 17:47:52 +00:00
|
|
|
return nsGkAtoms::legendFrame;
|
2002-12-03 16:02:42 +00:00
|
|
|
}
|
|
|
|
|
2006-04-10 00:16:29 +00:00
|
|
|
void
|
2009-12-24 05:21:15 +00:00
|
|
|
nsLegendFrame::DestroyFrom(nsIFrame* aDestructRoot)
|
2000-08-02 22:12:11 +00:00
|
|
|
{
|
2011-10-17 14:59:28 +00:00
|
|
|
nsFormControlFrame::RegUnRegAccessKey(static_cast<nsIFrame*>(this), false);
|
2009-12-24 05:21:15 +00:00
|
|
|
nsBlockFrame::DestroyFrom(aDestructRoot);
|
2000-02-09 19:34:39 +00:00
|
|
|
}
|
|
|
|
|
2009-01-12 19:20:59 +00:00
|
|
|
NS_QUERYFRAME_HEAD(nsLegendFrame)
|
|
|
|
NS_QUERYFRAME_ENTRY(nsLegendFrame)
|
|
|
|
NS_QUERYFRAME_TAIL_INHERITING(nsBlockFrame)
|
1998-10-08 04:38:41 +00:00
|
|
|
|
2014-05-13 00:47:52 +00:00
|
|
|
void
|
2004-07-31 23:15:21 +00:00
|
|
|
nsLegendFrame::Reflow(nsPresContext* aPresContext,
|
2000-02-09 19:34:39 +00: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 05:38:33 +00:00
|
|
|
DO_GLOBAL_REFLOW_COUNT("nsLegendFrame");
|
2001-11-14 13:40:03 +00: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 05:38:33 +00:00
|
|
|
if (mState & NS_FRAME_FIRST_REFLOW) {
|
2011-10-17 14:59:28 +00: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 05:38:33 +00:00
|
|
|
}
|
2008-12-29 15:07:38 +00:00
|
|
|
return nsBlockFrame::Reflow(aPresContext, aDesiredSize, aReflowState, aStatus);
|
2000-02-09 19:34:39 +00:00
|
|
|
}
|
|
|
|
|
2008-12-29 15:07:38 +00:00
|
|
|
// REVIEW: We don't need to override BuildDisplayList, nsBlockFrame will honour
|
2006-01-26 02:29:17 +00:00
|
|
|
// our visibility setting
|
2012-08-22 15:56:38 +00:00
|
|
|
int32_t nsLegendFrame::GetAlign()
|
1998-10-08 04:38:41 +00:00
|
|
|
{
|
2012-08-22 15:56:38 +00:00
|
|
|
int32_t intValue = NS_STYLE_TEXT_ALIGN_LEFT;
|
2014-05-24 22:20:41 +00:00
|
|
|
if (GetParent() &&
|
|
|
|
NS_STYLE_DIRECTION_RTL == GetParent()->StyleVisibility()->mDirection) {
|
2002-01-31 05:09:13 +00:00
|
|
|
intValue = NS_STYLE_TEXT_ALIGN_RIGHT;
|
|
|
|
}
|
2002-05-23 00:00:34 +00:00
|
|
|
|
2005-01-12 19:45:38 +00:00
|
|
|
nsGenericHTMLElement *content = nsGenericHTMLElement::FromContent(mContent);
|
2002-05-23 00:00:34 +00:00
|
|
|
|
|
|
|
if (content) {
|
2006-12-26 17:47:52 +00:00
|
|
|
const nsAttrValue* attr = content->GetParsedAttr(nsGkAtoms::align);
|
2005-01-25 00:02:58 +00:00
|
|
|
if (attr && attr->Type() == nsAttrValue::eEnum) {
|
|
|
|
intValue = attr->GetEnumValue();
|
1998-10-08 04:38:41 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return intValue;
|
|
|
|
}
|
|
|
|
|
2014-01-05 23:31:14 +00:00
|
|
|
#ifdef DEBUG_FRAME_DUMP
|
2014-02-18 07:47:48 +00:00
|
|
|
nsresult
|
2001-11-14 01:33:42 +00:00
|
|
|
nsLegendFrame::GetFrameName(nsAString& aResult) const
|
1998-11-19 17:22:29 +00:00
|
|
|
{
|
2001-11-14 01:33:42 +00:00
|
|
|
return MakeFrameName(NS_LITERAL_STRING("Legend"), aResult);
|
1998-11-19 17:22:29 +00:00
|
|
|
}
|
1999-11-01 22:12:45 +00:00
|
|
|
#endif
|