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